summaryrefslogtreecommitdiffstats
path: root/kspread/kspread_util.cc
diff options
context:
space:
mode:
Diffstat (limited to 'kspread/kspread_util.cc')
-rw-r--r--kspread/kspread_util.cc248
1 files changed, 124 insertions, 124 deletions
diff --git a/kspread/kspread_util.cc b/kspread/kspread_util.cc
index 47d1a215..43c2581b 100644
--- a/kspread/kspread_util.cc
+++ b/kspread/kspread_util.cc
@@ -20,7 +20,7 @@
#include <ctype.h>
-#include <qregexp.h>
+#include <tqregexp.h>
#include <kdebug.h>
@@ -53,8 +53,8 @@ bool KSpread::formatIsFraction (FormatType fmt)
//used in Point::init, Cell::encodeFormula and
-// dialogs/kspread_dlg_paperlayout.cc
-int KSpread::util_decodeColumnLabelText( const QString &_col )
+// dialogs/kspread_dlg_papertqlayout.cc
+int KSpread::util_decodeColumnLabelText( const TQString &_col )
{
int col = 0;
int offset='a'-'A';
@@ -62,9 +62,9 @@ int KSpread::util_decodeColumnLabelText( const QString &_col )
for ( uint i=0; i < _col.length(); i++ )
{
counterColumn = (int) pow(26.0 , static_cast<int>(_col.length() - i - 1));
- if( _col[i] >= 'A' && _col[i] <= 'Z' )
+ if( (int)(_col[i]) >= 'A' && (int)(_col[i]) <= 'Z' )
col += counterColumn * ( _col[i].latin1() - 'A' + 1); // okay here (Werner)
- else if( _col[i] >= 'a' && _col[i] <= 'z' )
+ else if( (int)(_col[i]) >= 'a' && (int)(_col[i]) <= 'z' )
col += counterColumn * ( _col[i].latin1() - 'A' - offset + 1 );
else
kdDebug(36001) << "util_decodeColumnLabelText: Wrong characters in label text for col:'" << _col << "'" << endl;
@@ -72,36 +72,36 @@ int KSpread::util_decodeColumnLabelText( const QString &_col )
return col;
}
-//used in dialogs/kspread_dlg_paperlayout.cc
-QString KSpread::util_rangeColumnName( const QRect &_area)
+//used in dialogs/kspread_dlg_papertqlayout.cc
+TQString KSpread::util_rangeColumnName( const TQRect &_area)
{
- return QString("%1:%2")
- .arg( Cell::columnName( _area.left()))
- .arg( Cell::columnName(_area.right()));
+ return TQString("%1:%2")
+ .tqarg( Cell::columnName( _area.left()))
+ .tqarg( Cell::columnName(_area.right()));
}
-//used in dialogs/kspread_dlg_paperlayout.cc
-QString KSpread::util_rangeRowName( const QRect &_area)
+//used in dialogs/kspread_dlg_papertqlayout.cc
+TQString KSpread::util_rangeRowName( const TQRect &_area)
{
- return QString("%1:%2")
- .arg( _area.top())
- .arg(_area.bottom());
+ return TQString("%1:%2")
+ .tqarg( _area.top())
+ .tqarg(_area.bottom());
}
-QString KSpread::util_rangeName(const QRect &_area)
+TQString KSpread::util_rangeName(const TQRect &_area)
{
return Cell::name( _area.left(), _area.top() ) + ":" +
Cell::name( _area.right(), _area.bottom() );
}
-QString KSpread::util_rangeName(Sheet * _sheet, const QRect &_area)
+TQString KSpread::util_rangeName(Sheet * _sheet, const TQRect &_area)
{
return _sheet->sheetName() + "!" + util_rangeName(_area);
}
-QDomElement KSpread::util_createElement( const QString & tagName, const QFont & font, QDomDocument & doc )
+TQDomElement KSpread::util_createElement( const TQString & tagName, const TQFont & font, TQDomDocument & doc )
{
- QDomElement e( doc.createElement( tagName ) );
+ TQDomElement e( doc.createElement( tagName ) );
e.setAttribute( "family", font.family() );
e.setAttribute( "size", font.pointSize() );
@@ -119,28 +119,28 @@ QDomElement KSpread::util_createElement( const QString & tagName, const QFont &
return e;
}
-QDomElement KSpread::util_createElement( const QString & tagname, const QPen & pen, QDomDocument & doc )
+TQDomElement KSpread::util_createElement( const TQString & tagname, const TQPen & pen, TQDomDocument & doc )
{
- QDomElement e( doc.createElement( tagname ) );
+ TQDomElement e( doc.createElement( tagname ) );
e.setAttribute( "color", pen.color().name() );
e.setAttribute( "style", (int)pen.style() );
e.setAttribute( "width", (int)pen.width() );
return e;
}
-QFont KSpread::util_toFont( QDomElement & element )
+TQFont KSpread::util_toFont( TQDomElement & element )
{
- QFont f;
+ TQFont f;
f.setFamily( element.attribute( "family" ) );
bool ok;
f.setPointSize( element.attribute("size").toInt( &ok ) );
if ( !ok )
- return QFont();
+ return TQFont();
f.setWeight( element.attribute("weight").toInt( &ok ) );
if ( !ok )
- return QFont();
+ return TQFont();
if ( element.hasAttribute( "italic" ) && element.attribute("italic") == "yes" )
f.setItalic( true );
@@ -157,44 +157,44 @@ QFont KSpread::util_toFont( QDomElement & element )
/* Uncomment when charset is added to kspread_dlg_layout
+ save a document-global charset
if ( element.hasAttribute( "charset" ) )
- KGlobal::charsets()->setQFont( f, element.attribute("charset") );
+ KGlobal::charsets()->setTQFont( f, element.attribute("charset") );
else
*/
// ######## Not needed anymore in 3.0?
- //KGlobal::charsets()->setQFont( f, KGlobal::locale()->charset() );
+ //KGlobal::charsets()->setTQFont( f, KGlobal::locale()->charset() );
return f;
}
-QPen KSpread::util_toPen( QDomElement & element )
+TQPen KSpread::util_toPen( TQDomElement & element )
{
bool ok;
- QPen p;
+ TQPen p;
p.setStyle( (Qt::PenStyle)element.attribute("style").toInt( &ok ) );
if ( !ok )
- return QPen();
+ return TQPen();
p.setWidth( element.attribute("width").toInt( &ok ) );
if ( !ok )
- return QPen();
+ return TQPen();
- p.setColor( QColor( element.attribute("color") ) );
+ p.setColor( TQColor( element.attribute("color") ) );
return p;
}
-Point::Point(const QString & _str)
+Point::Point(const TQString & _str)
{
_sheet = 0;
init(_str);
}
-void Point::setPos(QPoint pos)
+void Point::setPos(TQPoint pos)
{
_pos=pos;
}
-QPoint Point::pos() const
+TQPoint Point::pos() const
{
return _pos;
}
@@ -206,11 +206,11 @@ KSpread::Sheet* Point::sheet() const
{
return _sheet;
}
-void Point::setSheetName(QString name)
+void Point::setSheetName(TQString name)
{
_sheetName=name;
}
-QString Point::sheetName() const
+TQString Point::sheetName() const
{
return _sheetName;
}
@@ -232,7 +232,7 @@ bool Point::rowFixed() const
}
-void Point::init(const QString & _str)
+void Point::init(const TQString & _str)
{
_columnFixed=false;
_rowFixed=false;
@@ -247,8 +247,8 @@ void Point::init(const QString & _str)
return;
}
- QString str( _str );
- int n = _str.find( '!' );
+ TQString str( _str );
+ int n = _str.tqfind( '!' );
if ( n != -1 )
{
_sheetName = _str.left( n );
@@ -284,7 +284,7 @@ void Point::init(const QString & _str)
//default is error
int x = -1;
//search for the first character != text
- int result = str.find( QRegExp("[^A-Za-z]+"), p );
+ int result = str.tqfind( TQRegExp("[^A-Za-z]+"), p );
//get the colomn number for the character between actual position and the first non text charakter
if ( result != -1 )
@@ -327,7 +327,7 @@ void Point::init(const QString & _str)
uint p2 = p;
while ( p < len )
{
- if ( !isdigit( QChar(str[p++]) ) )
+ if ( !isdigit( TQChar(str[p++]) ) )
{
kdDebug(36001) << "Point::init: no number" << endl;
return;
@@ -351,10 +351,10 @@ void Point::init(const QString & _str)
kdDebug(36001) << "Point::init: y <= 0" << endl;
return;
}
- _pos = QPoint( x, y );
+ _pos = TQPoint( x, y );
}
-bool util_isPointValid( QPoint point )
+bool util_isPointValid( TQPoint point )
{
if ( point.x() >= 1
&& point.y() >= 1
@@ -366,7 +366,7 @@ bool util_isPointValid( QPoint point )
return false;
}
-bool util_isRectValid( QRect rect )
+bool util_isRectValid( TQRect rect )
{
if ( util_isPointValid( rect.topLeft() )
&& util_isPointValid( rect.bottomRight() )
@@ -376,12 +376,12 @@ bool util_isRectValid( QRect rect )
return false;
}
-Point::Point( const QString & str, Map * map,
+Point::Point( const TQString & str, Map * map,
Sheet * sheet )
{
uint p = 0;
- int p2 = str.find( '!' );
+ int p2 = str.tqfind( '!' );
if ( p2 != -1 )
{
_sheetName = str.left( p2++ );
@@ -459,12 +459,12 @@ Range::Range()
_topFixed=false;
_bottomFixed=false;
}
-Range::Range(const QString & _str)
+Range::Range(const TQString & _str)
{
_range.setLeft(-1);
_sheet = 0;
- int p = _str.find(':');
+ int p = _str.tqfind(':');
// if (p == -1)
// return;
@@ -482,7 +482,7 @@ Range::Range(const QString & _str)
lr = ul;
}
- _range = QRect(ul.pos(), lr.pos());
+ _range = TQRect(ul.pos(), lr.pos());
_sheetName = ul.sheetName();
_leftFixed = ul.columnFixed();
@@ -506,7 +506,7 @@ Range::Range(const QString & _str)
Range::Range( const Point& ul, const Point& lr )
{
- _range = QRect( ul.pos(), lr.pos() );
+ _range = TQRect( ul.pos(), lr.pos() );
if ( ul.sheetName() != lr.sheetName() )
{
_range.setLeft( -1 );
@@ -520,7 +520,7 @@ Range::Range(const QString & _str)
_bottomFixed = lr.rowFixed();
}
-Range::Range(const QString & str, Map * map,
+Range::Range(const TQString & str, Map * map,
Sheet * sheet)
{
_range.setLeft(-1);
@@ -528,9 +528,9 @@ Range::Range(const QString & str, Map * map,
//try to parse as named area
bool gotNamed = false;
- QString tmp = str.lower();
- QValueList < Reference >::Iterator it;
- QValueList < Reference > area = map->doc()->listArea();
+ TQString tmp = str.lower();
+ TQValueList < Reference >::Iterator it;
+ TQValueList < Reference > area = map->doc()->listArea();
for (it = area.begin(); it != area.end(); ++it) {
if ((*it).ref_name.lower() == tmp) {
// success - such named area exists
@@ -554,7 +554,7 @@ Range::Range(const QString & str, Map * map,
_sheet = 0;
int p = 0;
- int p2 = str.find('!');
+ int p2 = str.tqfind('!');
if (p2 != -1)
{
_sheetName = str.left(p2++);
@@ -574,13 +574,13 @@ Range::Range(const QString & str, Map * map,
_sheet = sheet;
- int p3 = str.find(':', p);
+ int p3 = str.tqfind(':', p);
if (p3 == -1)
return;
Point ul(str.mid(p, p3 - p));
Point lr(str.mid(p3 + 1));
- _range = QRect(ul.pos(), lr.pos());
+ _range = TQRect(ul.pos(), lr.pos());
_leftFixed = ul.columnFixed();
_rightFixed = lr.columnFixed();
@@ -588,9 +588,9 @@ Range::Range(const QString & str, Map * map,
_bottomFixed = lr.rowFixed();
}
-QString Range::toString() const
+TQString Range::toString() const
{
- QString result;
+ TQString result;
if (_sheet)
{
@@ -603,7 +603,7 @@ QString Range::toString() const
//Insert $ characters to show fixed parts of range
- int pos=result.find("!")+1;
+ int pos=result.tqfind("!")+1;
Q_ASSERT(pos != -1);
if (_leftFixed)
@@ -616,7 +616,7 @@ QString Range::toString() const
result.insert(pos+Cell::columnName(_range.left()).length(),'$');
}
- pos=result.find(":")+1;
+ pos=result.tqfind(":")+1;
Q_ASSERT(pos != -1);
if (_rightFixed)
@@ -657,9 +657,9 @@ void Range::getEndPoint(Point* pt)
pt->setSheetName(_sheetName);
}
-bool Range::contains (const Point &cell) const
+bool Range::tqcontains (const Point &cell) const
{
- return _range.contains (cell.pos());
+ return _range.tqcontains (cell.pos());
}
bool Range::intersects (const Range &r) const
@@ -675,7 +675,7 @@ bool Range::isValid() const
( _range.isValid() ) ;
}
-QRect Range::range() const
+TQRect Range::range() const
{
return _range;
}
@@ -720,44 +720,44 @@ KSpread::Sheet* Range::sheet() const
{
return _sheet;
}
-void Range::setSheetName(QString sheetName)
+void Range::setSheetName(TQString sheetName)
{
_sheetName=sheetName;
}
-QString Range::sheetName() const
+TQString Range::sheetName() const
{
return _sheetName;
}
-QString Range::namedArea() const
+TQString Range::namedArea() const
{
return _namedArea;
}
-bool KSpread::util_isAllSelected(const QRect &selection)
+bool KSpread::util_isAllSelected(const TQRect &selection)
{
return ( selection.top() == 1 && selection.bottom() == KS_rowMax
&& selection.left() == 1 && selection.right() == KS_colMax);
}
-bool KSpread::util_isColumnSelected(const QRect &selection)
+bool KSpread::util_isColumnSelected(const TQRect &selection)
{
return ( (selection.top() == 1) && (selection.bottom() == KS_rowMax) );
}
-bool KSpread::util_isRowSelected(const QRect &selection)
+bool KSpread::util_isRowSelected(const TQRect &selection)
{
return ( (selection.left() == 1) && (selection.right() == KS_colMax) );
}
-bool KSpread::util_isRowOrColumnSelected(const QRect &selection)
+bool KSpread::util_isRowOrColumnSelected(const TQRect &selection)
{
return ( (selection.left() == 1) && (selection.right() == KS_colMax)
|| (selection.top() == 1) && (selection.bottom() == KS_rowMax) );
}
//used in View::slotRename
-bool KSpread::util_validateSheetName(const QString &name)
+bool KSpread::util_validateSheetName(const TQString &name)
{
if (name[0] == ' ')
{
@@ -776,11 +776,11 @@ bool KSpread::util_validateSheetName(const QString &name)
}
-RangeIterator::RangeIterator(QRect _range, Sheet* _sheet)
+RangeIterator::RangeIterator(TQRect _range, Sheet* _sheet)
{
range = _range;
sheet = _sheet;
- current = QPoint(0,0);
+ current = TQPoint(0,0);
}
RangeIterator::~RangeIterator()
@@ -826,15 +826,15 @@ Cell* RangeIterator::next()
}
//not used anywhere
-int KSpread::util_penCompare( QPen const & pen1, QPen const & pen2 )
+int KSpread::util_penCompare( TQPen const & pen1, TQPen const & pen2 )
{
- if ( pen1.style() == Qt::NoPen && pen2.style() == Qt::NoPen )
+ if ( pen1.style() == TQt::NoPen && pen2.style() == TQt::NoPen )
return 0;
- if ( pen1.style() == Qt::NoPen )
+ if ( pen1.style() == TQt::NoPen )
return -1;
- if ( pen2.style() == Qt::NoPen )
+ if ( pen2.style() == TQt::NoPen )
return 1;
if ( pen1.width() < pen2.width() )
@@ -859,46 +859,46 @@ int KSpread::util_penCompare( QPen const & pen1, QPen const & pen2 )
}
-QString KSpread::convertRefToBase( const QString & sheet, const QRect & rect )
+TQString KSpread::convertRefToBase( const TQString & sheet, const TQRect & rect )
{
- QPoint bottomRight( rect.bottomRight() );
+ TQPoint bottomRight( rect.bottomRight() );
- QString s( "$" );
+ TQString s( "$" );
s += sheet;
s += ".$";
s += Cell::columnName( bottomRight.x() );
s += '$';
- s += QString::number( bottomRight.y() );
+ s += TQString::number( bottomRight.y() );
return s;
}
-QString KSpread::convertRefToRange( const QString & sheet, const QRect & rect )
+TQString KSpread::convertRefToRange( const TQString & sheet, const TQRect & rect )
{
- QPoint topLeft( rect.topLeft() );
- QPoint bottomRight( rect.bottomRight() );
+ TQPoint topLeft( rect.topLeft() );
+ TQPoint bottomRight( rect.bottomRight() );
if ( topLeft == bottomRight )
return convertRefToBase( sheet, rect );
- QString s( "$" );
+ TQString s( "$" );
s += sheet;
s += ".$";
s += /*util_encodeColumnLabelText*/Cell::columnName( topLeft.x() );
s += '$';
- s += QString::number( topLeft.y() );
+ s += TQString::number( topLeft.y() );
s += ":.$";
s += /*util_encodeColumnLabelText*/Cell::columnName( bottomRight.x() );
s += '$';
- s += QString::number( bottomRight.y() );
+ s += TQString::number( bottomRight.y() );
return s;
}
//used in Cell::convertFormulaToOasisFormat
-void KSpread::insertBracket( QString & s )
+void KSpread::insertBracket( TQString & s )
{
- QChar c;
+ TQChar c;
int i = (int) s.length() - 1;
while ( i >= 0 )
@@ -918,39 +918,39 @@ void KSpread::insertBracket( QString & s )
// e.g.: Sheet4.A1:Sheet4.E28
//used in Sheet::saveOasis
-QString KSpread::convertRangeToRef( const QString & sheetName, const QRect & _area )
+TQString KSpread::convertRangeToRef( const TQString & sheetName, const TQRect & _area )
{
return sheetName + "." + Cell::name( _area.left(), _area.top() ) + ":" + sheetName + "."+ Cell::name( _area.right(), _area.bottom() );
}
-QString KSpread::convertOasisPenToString( const QPen & pen )
+TQString KSpread::convertOasisPenToString( const TQPen & pen )
{
-// kdDebug()<<"convertOasisPenToString( const QPen & pen ) :"<<pen<<endl;
- // NOTE Stefan: QPen api docs:
+// kdDebug()<<"convertOasisPenToString( const TQPen & pen ) :"<<pen<<endl;
+ // NOTE Stefan: TQPen api docs:
// For horizontal and vertical lines a line width of 0 is
// the same as a line width of 1.
// A line width of 0 will produce a 1 pixel wide line using
// a fast algorithm for diagonals. A line width of 1 will
// also produce a 1 pixel wide line, but uses a slower more
// accurate algorithm for diagonals.
- QString s = QString( "%1pt " ).arg( (pen.width() == 0) ? 1 : pen.width() );
+ TQString s = TQString( "%1pt " ).tqarg( (pen.width() == 0) ? 1 : pen.width() );
switch( pen.style() )
{
- case Qt::NoPen:
+ case TQt::NoPen:
return "none";
- case Qt::SolidLine:
+ case TQt::SolidLine:
s+="solid";
break;
- case Qt::DashLine:
+ case TQt::DashLine:
s+="dashed";
break;
- case Qt::DotLine:
+ case TQt::DotLine:
s+="dotted";
break;
- case Qt::DashDotLine:
+ case TQt::DashDotLine:
s+="dot-dash";
break;
- case Qt::DashDotDotLine:
+ case TQt::DashDotDotLine:
s+="dot-dot-dash";
break;
default: break;
@@ -964,9 +964,9 @@ QString KSpread::convertOasisPenToString( const QPen & pen )
return s;
}
-QPen KSpread::convertOasisStringToPen( const QString &border )
+TQPen KSpread::convertOasisStringToPen( const TQString &border )
{
- QPen pen;
+ TQPen pen;
//string like "0.088cm solid #800000"
if (border.isEmpty() || border=="none" || border=="hidden") // in fact no border
{
@@ -974,10 +974,10 @@ QPen KSpread::convertOasisStringToPen( const QString &border )
return pen;
}
//code from koborder, for the moment kspread doesn't use koborder
- // ## isn't it faster to use QStringList::split than parse it 3 times?
- QString _width = border.section(' ', 0, 0);
- QCString _style = border.section(' ', 1, 1).latin1();
- QString _color = border.section(' ', 2, 2);
+ // ## isn't it faster to use TQStringList::split than parse it 3 times?
+ TQString _width = border.section(' ', 0, 0);
+ TQCString _style = border.section(' ', 1, 1).latin1();
+ TQString _color = border.section(' ', 2, 2);
pen.setWidth( ( int )( KoUnit::parseValue( _width, 1.0 ) ) );
@@ -997,37 +997,37 @@ QPen KSpread::convertOasisStringToPen( const QString &border )
kdDebug()<<" style undefined : "<<_style<<endl;
if ( _color.isEmpty() )
- pen.setColor( QColor() );
+ pen.setColor( TQColor() );
else
- pen.setColor( QColor( _color ) );
+ pen.setColor( TQColor( _color ) );
return pen;
}
//Return true when it's a reference to cell from sheet.
-bool KSpread::localReferenceAnchor( const QString &_ref )
+bool KSpread::localReferenceAnchor( const TQString &_ref )
{
- bool isLocalRef = (_ref.find("http://") != 0 &&
- _ref.find("mailto:") != 0 &&
- _ref.find("ftp://") != 0 &&
- _ref.find("file:") != 0 );
+ bool isLocalRef = (_ref.tqfind("http://") != 0 &&
+ _ref.tqfind("mailto:") != 0 &&
+ _ref.tqfind("ftp://") != 0 &&
+ _ref.tqfind("file:") != 0 );
return isLocalRef;
}
-QString KSpread::Oasis::decodeFormula(const QString& expr, const KLocale* locale)
+TQString KSpread::Oasis::decodeFormula(const TQString& expr, const KLocale* locale)
{
// parsing state
enum { Start, InNumber, InString, InIdentifier, InReference, InSheetName } state;
// use locale settings
- QString decimal = locale ? locale->decimalSymbol() : ".";
+ TQString decimal = locale ? locale->decimalSymbol() : ".";
// initialize variables
state = Start;
unsigned int i = 0;
- const QString ex = expr;
- QString result;
+ const TQString ex = expr;
+ TQString result;
if (ex[0] == '=')
{
@@ -1038,7 +1038,7 @@ QString KSpread::Oasis::decodeFormula(const QString& expr, const KLocale* locale
// main loop
while( i < ex.length() )
{
- QChar ch = ex[i];
+ TQChar ch = ex[i];
switch( state )
{
@@ -1065,7 +1065,7 @@ QString KSpread::Oasis::decodeFormula(const QString& expr, const KLocale* locale
}
// [ marks sheet name for 3-d cell, e.g ['Sales Q3'.A4]
- else if ( ch.unicode() == '[' )
+ else if ( ch.tqunicode() == '[' )
{
++i;
state = InReference;
@@ -1086,7 +1086,7 @@ QString KSpread::Oasis::decodeFormula(const QString& expr, const KLocale* locale
else
{
int op;
- QString s;
+ TQString s;
// check for two-chars operator, such as '<=', '>=', etc
s.append( ch ).append( ex[i+1] );
@@ -1095,7 +1095,7 @@ QString KSpread::Oasis::decodeFormula(const QString& expr, const KLocale* locale
// check for one-char operator, such as '+', ';', etc
if( op == Token::InvalidOp )
{
- s = QString( ch );
+ s = TQString( ch );
op = matchOperator( s );
}
@@ -1208,7 +1208,7 @@ QString KSpread::Oasis::decodeFormula(const QString& expr, const KLocale* locale
return result;
}
-/*QString KSpread::Oasis::encodeFormula(const QString& expr, const KLocale* locale)
+/*TQString KSpread::Oasis::encodeFormula(const TQString& expr, const KLocale* locale)
{
// TODO move Cell::convertFormulaToOasisFormat to this point
//expr = "not here yet";