diff options
Diffstat (limited to 'kspread/valueformatter.cc')
-rw-r--r-- | kspread/valueformatter.cc | 240 |
1 files changed, 120 insertions, 120 deletions
diff --git a/kspread/valueformatter.cc b/kspread/valueformatter.cc index ac2119f3..1bef11e2 100644 --- a/kspread/valueformatter.cc +++ b/kspread/valueformatter.cc @@ -38,36 +38,36 @@ ValueFormatter::ValueFormatter (ValueConverter *conv) : converter( conv ) { } -QString ValueFormatter::formatText (Cell *cell, FormatType fmtType) +TQString ValueFormatter::formatText (Cell *cell, FormatType fmtType) { if (cell->hasError ()) return errorFormat (cell); - QString str; + TQString str; Format::FloatFormat floatFormat = cell->format()->floatFormat (cell->column(), cell->row()); int precision = cell->format()->precision (cell->column(), cell->row()); - QString prefix = cell->format()->prefix (cell->column(), cell->row()); - QString postfix = cell->format()->postfix (cell->column(), cell->row()); + TQString prefix = cell->format()->prefix (cell->column(), cell->row()); + TQString postfix = cell->format()->postfix (cell->column(), cell->row()); Format::Currency currency; bool valid = cell->format()->currencyInfo(currency); - QString currencySymbol = valid ? currency.symbol : QString::null; + TQString currencySymbol = valid ? currency.symbol : TQString(); return formatText (cell->value(), fmtType, precision, floatFormat, prefix, postfix, currencySymbol); } -QString ValueFormatter::formatText (const Value &value, +TQString ValueFormatter::formatText (const Value &value, FormatType fmtType, int precision, Format::FloatFormat floatFormat, - const QString &prefix, const QString &postfix, const QString ¤cySymbol) + const TQString &prefix, const TQString &postfix, const TQString ¤cySymbol) { //if we have an array, use its first element if (value.isArray()) return formatText (value.element (0, 0), fmtType, precision, floatFormat, prefix, postfix, currencySymbol); - QString str; + TQString str; //step 1: determine formatting that will be used fmtType = determineFormatting (value, fmtType); @@ -112,7 +112,7 @@ QString ValueFormatter::formatText (const Value &value, // unless the number has no decimal point if (precision == -1) { - QChar decimal_point = converter->locale()->decimalSymbol()[0]; + TQChar decimal_point = converter->locale()->decimalSymbol()[0]; if ( decimal_point.isNull() ) decimal_point = '.'; @@ -199,20 +199,20 @@ FormatType ValueFormatter::determineFormatting (const Value &value, } -void ValueFormatter::removeTrailingZeros (QString &str, QChar decimal_point) +void ValueFormatter::removeTrailingZeros (TQString &str, TQChar decimal_point) { - if (str.find (decimal_point) < 0) + if (str.tqfind (decimal_point) < 0) //no decimal point -> nothing to do return; int start = 0; int cslen = converter->locale()->currencySymbol().length(); - if (str.find ('%') != -1) + if (str.tqfind ('%') != -1) start = 2; - else if (str.find (converter->locale()->currencySymbol()) == + else if (str.tqfind (converter->locale()->currencySymbol()) == ((int) (str.length() - cslen))) start = cslen + 1; - else if ((start = str.find ('E')) != -1) + else if ((start = str.tqfind ('E')) != -1) start = str.length() - start; else start = 0; @@ -221,7 +221,7 @@ void ValueFormatter::removeTrailingZeros (QString &str, QChar decimal_point) bool bFinished = false; while ( !bFinished && i > 0 ) { - QChar ch = str[i - 1]; + TQChar ch = str[i - 1]; if (ch == '0') str.remove (--i,1); else @@ -233,14 +233,14 @@ void ValueFormatter::removeTrailingZeros (QString &str, QChar decimal_point) } } -QString ValueFormatter::createNumberFormat ( double value, int precision, - FormatType fmt, bool alwaysSigned, const QString& currencySymbol) +TQString ValueFormatter::createNumberFormat ( double value, int precision, + FormatType fmt, bool alwaysSigned, const TQString& currencySymbol) { // if precision is -1, ask for a huge number of decimals, we'll remove // the zeros later. Is 8 ok ? // Stefan: No. Use maximum possible decimal precision (DBL_DIG) instead. int p = (precision == -1) ? 8 : precision; - QString localizedNumber; + TQString localizedNumber; int pos = 0; //multiply value by 100 for percentage format @@ -261,7 +261,7 @@ QString ValueFormatter::createNumberFormat ( double value, int precision, if( neg ) value = -value; } - QChar decimal_point; + TQChar decimal_point; switch (fmt) { case Number_format: @@ -276,9 +276,9 @@ QString ValueFormatter::createNumberFormat ( double value, int precision, break; case Scientific_format: decimal_point = converter->locale()->decimalSymbol()[0]; - localizedNumber = QString::number (value, 'E', p); - if ((pos = localizedNumber.find ('.')) != -1) - localizedNumber = localizedNumber.replace (pos, 1, decimal_point); + localizedNumber = TQString::number (value, 'E', p); + if ((pos = localizedNumber.tqfind ('.')) != -1) + localizedNumber = localizedNumber.tqreplace (pos, 1, decimal_point); break; default : //other formatting? @@ -295,7 +295,7 @@ QString ValueFormatter::createNumberFormat ( double value, int precision, return localizedNumber; } -QString ValueFormatter::fractionFormat (double value, FormatType fmtType) +TQString ValueFormatter::fractionFormat (double value, FormatType fmtType) { double result = value - floor(value); int index; @@ -303,7 +303,7 @@ QString ValueFormatter::fractionFormat (double value, FormatType fmtType) /* return w/o fraction part if not necessary */ if (result == 0) - return QString::number(value); + return TQString::number(value); switch (fmtType) { case fraction_half: @@ -338,7 +338,7 @@ QString ValueFormatter::fractionFormat (double value, FormatType fmtType) break; default: kdDebug(36001) << "Error in Fraction format\n"; - return QString::number(value); + return TQString::number(value); break; } /* switch */ @@ -358,15 +358,15 @@ QString ValueFormatter::fractionFormat (double value, FormatType fmtType) diff = fabs(result - calc); } } - if( index1 == 0 ) return QString("%1").arg( floor(value) ); - if( index1 == index ) return QString("%1").arg( floor(value)+1 ); + if( index1 == 0 ) return TQString("%1").tqarg( floor(value) ); + if( index1 == index ) return TQString("%1").tqarg( floor(value)+1 ); if( floor(value) == 0) - return QString("%1/%2").arg( index1 ).arg( index ); + return TQString("%1/%2").tqarg( index1 ).tqarg( index ); - return QString("%1 %2/%3") - .arg( floor(value) ) - .arg( index1 ) - .arg( index ); + return TQString("%1 %2/%3") + .tqarg( floor(value) ) + .tqarg( index1 ) + .tqarg( index ); } @@ -403,20 +403,20 @@ QString ValueFormatter::fractionFormat (double value, FormatType fmtType) numerator = fabs(numerator); if (denominator == numerator) - return QString().setNum(floor(value + 1)); + return TQString().setNum(floor(value + 1)); else { if ( floor(value) == 0 ) - return QString("%1/%2").arg(numerator).arg(denominator); + return TQString("%1/%2").tqarg(numerator).tqarg(denominator); else - return QString("%1 %2/%3") - .arg(floor(value)) - .arg(numerator) - .arg(denominator); + return TQString("%1 %2/%3") + .tqarg(floor(value)) + .tqarg(numerator) + .tqarg(denominator); } } -QString ValueFormatter::timeFormat (const QDateTime &dt, FormatType fmtType) +TQString ValueFormatter::timeFormat (const TQDateTime &dt, FormatType fmtType) { if (fmtType == Time_format) return converter->locale()->formatTime(dt.time(), false); @@ -428,47 +428,47 @@ QString ValueFormatter::timeFormat (const QDateTime &dt, FormatType fmtType) int m = dt.time().minute(); int s = dt.time().second(); - QString hour = ( h < 10 ? "0" + QString::number(h) : QString::number(h) ); - QString minute = ( m < 10 ? "0" + QString::number(m) : QString::number(m) ); - QString second = ( s < 10 ? "0" + QString::number(s) : QString::number(s) ); + TQString hour = ( h < 10 ? "0" + TQString::number(h) : TQString::number(h) ); + TQString minute = ( m < 10 ? "0" + TQString::number(m) : TQString::number(m) ); + TQString second = ( s < 10 ? "0" + TQString::number(s) : TQString::number(s) ); bool pm = (h > 12); - QString AMPM( pm ? i18n("PM"):i18n("AM") ); + TQString AMPM( pm ? i18n("PM"):i18n("AM") ); if (fmtType == Time_format1) { // 9 : 01 AM - return QString("%1:%2 %3") - .arg((pm ? h - 12 : h),2) - .arg(minute,2) - .arg(AMPM); + return TQString("%1:%2 %3") + .tqarg((pm ? h - 12 : h),2) + .tqarg(minute,2) + .tqarg(AMPM); } if (fmtType == Time_format2) { //9:01:05 AM - return QString("%1:%2:%3 %4") - .arg((pm ? h-12 : h),2) - .arg(minute,2) - .arg(second,2) - .arg(AMPM); + return TQString("%1:%2:%3 %4") + .tqarg((pm ? h-12 : h),2) + .tqarg(minute,2) + .tqarg(second,2) + .tqarg(AMPM); } if (fmtType == Time_format3) { - return QString("%1 %2 %3 %4 %5 %6") // 9 h 01 min 28 s - .arg(hour,2) - .arg(i18n("h")) - .arg(minute,2) - .arg(i18n("min")) - .arg(second,2) - .arg(i18n("s")); + return TQString("%1 %2 %3 %4 %5 %6") // 9 h 01 min 28 s + .tqarg(hour,2) + .tqarg(i18n("h")) + .tqarg(minute,2) + .tqarg(i18n("min")) + .tqarg(second,2) + .tqarg(i18n("s")); } if (fmtType == Time_format4) { // 9:01 - return QString("%1:%2").arg(hour, 2).arg(minute, 2); + return TQString("%1:%2").tqarg(hour, 2).tqarg(minute, 2); } if (fmtType == Time_format5) { // 9:01:12 - return QString("%1:%2:%3").arg(hour, 2).arg(minute, 2).arg(second, 2); + return TQString("%1:%2:%3").tqarg(hour, 2).tqarg(minute, 2).tqarg(second, 2); } - QDate d1(dt.date()); - QDate d2( 1899, 12, 31 ); + TQDate d1(dt.date()); + TQDate d2( 1899, 12, 31 ); int d = d2.daysTo( d1 ) + 1; h += d * 24; @@ -476,23 +476,23 @@ QString ValueFormatter::timeFormat (const QDateTime &dt, FormatType fmtType) if (fmtType == Time_format6) { // [mm]:ss m += (h * 60); - return QString("%1:%2").arg(m, 1).arg(second, 2); + return TQString("%1:%2").tqarg(m, 1).tqarg(second, 2); } if (fmtType == Time_format7) { // [h]:mm:ss - return QString("%1:%2:%3").arg(h, 1).arg(minute, 2).arg(second, 2); + return TQString("%1:%2:%3").tqarg(h, 1).tqarg(minute, 2).tqarg(second, 2); } if (fmtType == Time_format8) { // [h]:mm m += (h * 60); - return QString("%1:%2").arg(h, 1).arg(minute, 2); + return TQString("%1:%2").tqarg(h, 1).tqarg(minute, 2); } return converter->locale()->formatTime( dt.time(), false ); } -QString ValueFormatter::dateFormat (const QDate &date, FormatType fmtType) +TQString ValueFormatter::dateFormat (const TQDate &date, FormatType fmtType) { - QString tmp; + TQString tmp; if (fmtType == ShortDate_format) { tmp = converter->locale()->formatDate(date, true); } @@ -500,121 +500,121 @@ QString ValueFormatter::dateFormat (const QDate &date, FormatType fmtType) tmp = converter->locale()->formatDate(date, false); } else if (fmtType == date_format1) { /*18-Feb-99 */ - tmp = QString().sprintf("%02d", date.day()); + tmp = TQString().sprintf("%02d", date.day()); tmp += "-" + converter->locale()->calendar()->monthString(date, true) + "-"; - tmp += QString::number(date.year()).right(2); + tmp += TQString::number(date.year()).right(2); } else if (fmtType == date_format2) { /*18-Feb-1999 */ - tmp = QString().sprintf("%02d", date.day()); + tmp = TQString().sprintf("%02d", date.day()); tmp += "-" + converter->locale()->calendar()->monthString(date, true) + "-"; - tmp += QString::number(date.year()); + tmp += TQString::number(date.year()); } else if (fmtType == date_format3) { /*18-Feb */ - tmp = QString().sprintf("%02d", date.day()); + tmp = TQString().sprintf("%02d", date.day()); tmp += "-" + converter->locale()->calendar()->monthString(date, true); } else if (fmtType == date_format4) { /*18-05 */ - tmp = QString().sprintf("%02d", date.day()); - tmp += "-" + QString().sprintf("%02d", date.month() ); + tmp = TQString().sprintf("%02d", date.day()); + tmp += "-" + TQString().sprintf("%02d", date.month() ); } else if (fmtType == date_format5) { /*18/05/00 */ - tmp = QString().sprintf("%02d", date.day()); - tmp += "/" + QString().sprintf("%02d", date.month()) + "/"; - tmp += QString::number(date.year()).right(2); + tmp = TQString().sprintf("%02d", date.day()); + tmp += "/" + TQString().sprintf("%02d", date.month()) + "/"; + tmp += TQString::number(date.year()).right(2); } else if (fmtType == date_format6) { /*18/05/1999 */ - tmp = QString().sprintf("%02d", date.day()); - tmp += "/" + QString().sprintf("%02d", date.month()) + "/"; - tmp += QString::number(date.year()); + tmp = TQString().sprintf("%02d", date.day()); + tmp += "/" + TQString().sprintf("%02d", date.month()) + "/"; + tmp += TQString::number(date.year()); } else if (fmtType == date_format7) { /*Feb-99 */ tmp = converter->locale()->calendar()->monthString(date, true) + "-"; - tmp += QString::number(date.year()).right(2); + tmp += TQString::number(date.year()).right(2); } else if (fmtType == date_format8) { /*February-99 */ tmp = converter->locale()->calendar()->monthString(date, false) + "-"; - tmp += QString::number(date.year()).right(2); + tmp += TQString::number(date.year()).right(2); } else if (fmtType == date_format9) { /*February-1999 */ tmp = converter->locale()->calendar()->monthString(date, false) + "-"; - tmp += QString::number(date.year()); + tmp += TQString::number(date.year()); } else if (fmtType == date_format10) { /*F-99 */ - tmp = converter->locale()->calendar()->monthString(date, false).at(0) + "-"; - tmp += QString::number(date.year()).right(2); + tmp = converter->locale()->calendar()->monthString(date, false).tqat(0) + "-"; + tmp += TQString::number(date.year()).right(2); } else if (fmtType == date_format11) { /*18/Feb */ - tmp = QString().sprintf("%02d", date.day()) + "/"; + tmp = TQString().sprintf("%02d", date.day()) + "/"; tmp += converter->locale()->calendar()->monthString(date, true); } else if (fmtType == date_format12) { /*18/02 */ - tmp = QString().sprintf("%02d", date.day()) + "/"; - tmp += QString().sprintf("%02d", date.month()); + tmp = TQString().sprintf("%02d", date.day()) + "/"; + tmp += TQString().sprintf("%02d", date.month()); } else if (fmtType == date_format13) { /*18/Feb/1999 */ - tmp = QString().sprintf("%02d", date.day()); + tmp = TQString().sprintf("%02d", date.day()); tmp += "/" + converter->locale()->calendar()->monthString(date, true) + "/"; - tmp += QString::number(date.year()); + tmp += TQString::number(date.year()); } else if (fmtType == date_format14) { /*2000/Feb/18 */ - tmp = QString::number(date.year()); + tmp = TQString::number(date.year()); tmp += "/" + converter->locale()->calendar()->monthString(date, true) + "/"; - tmp += QString().sprintf("%02d", date.day()); + tmp += TQString().sprintf("%02d", date.day()); } else if (fmtType == date_format15) { /*2000-Feb-18 */ - tmp = QString::number(date.year()); + tmp = TQString::number(date.year()); tmp += "-" + converter->locale()->calendar()->monthString(date, true) + "-"; - tmp += QString().sprintf("%02d", date.day()); + tmp += TQString().sprintf("%02d", date.day()); } else if (fmtType == date_format16) { /*2000-02-18 */ - tmp = QString::number(date.year()); - tmp += "-" + QString().sprintf("%02d", date.month()) + "-"; - tmp += QString().sprintf("%02d", date.day()); + tmp = TQString::number(date.year()); + tmp += "-" + TQString().sprintf("%02d", date.month()) + "-"; + tmp += TQString().sprintf("%02d", date.day()); } else if (fmtType == date_format17) { /*2 february 2000 */ - tmp = QString().sprintf("%d", date.day()); + tmp = TQString().sprintf("%d", date.day()); tmp += " " + converter->locale()->calendar()->monthString(date, false) + " "; - tmp += QString::number(date.year()); + tmp += TQString::number(date.year()); } else if (fmtType == date_format18) { /*02/18/1999 */ - tmp = QString().sprintf("%02d", date.month()); - tmp += "/" + QString().sprintf("%02d", date.day()); - tmp += "/" + QString::number(date.year()); + tmp = TQString().sprintf("%02d", date.month()); + tmp += "/" + TQString().sprintf("%02d", date.day()); + tmp += "/" + TQString::number(date.year()); } else if (fmtType == date_format19) { /*02/18/99 */ - tmp = QString().sprintf("%02d", date.month()); - tmp += "/" + QString().sprintf("%02d", date.day()); - tmp += "/" + QString::number(date.year()).right(2); + tmp = TQString().sprintf("%02d", date.month()); + tmp += "/" + TQString().sprintf("%02d", date.day()); + tmp += "/" + TQString::number(date.year()).right(2); } else if (fmtType == date_format20) { /*Feb/18/99 */ tmp = converter->locale()->calendar()->monthString(date, true); - tmp += "/" + QString().sprintf("%02d", date.day()); - tmp += "/" + QString::number(date.year()).right(2); + tmp += "/" + TQString().sprintf("%02d", date.day()); + tmp += "/" + TQString::number(date.year()).right(2); } else if (fmtType == date_format21) { /*Feb/18/1999 */ tmp = converter->locale()->calendar()->monthString(date, true); - tmp += "/" + QString().sprintf("%02d", date.day()); - tmp += "/" + QString::number(date.year()); + tmp += "/" + TQString().sprintf("%02d", date.day()); + tmp += "/" + TQString::number(date.year()); } else if (fmtType == date_format22) { /*Feb-1999 */ tmp = converter->locale()->calendar()->monthString(date, true) + "-"; - tmp += QString::number(date.year()); + tmp += TQString::number(date.year()); } else if (fmtType == date_format23) { /*1999 */ - tmp = QString::number(date.year()); + tmp = TQString::number(date.year()); } else if (fmtType == date_format24) { /*99 */ - tmp = QString::number(date.year()).right(2); + tmp = TQString::number(date.year()).right(2); } else if (fmtType == date_format25) { /*2000/02/18 */ - tmp = QString::number(date.year()); - tmp += "/" + QString().sprintf("%02d", date.month()); - tmp += "/" + QString().sprintf("%02d", date.day()); + tmp = TQString::number(date.year()); + tmp += "/" + TQString().sprintf("%02d", date.month()); + tmp += "/" + TQString().sprintf("%02d", date.day()); } else if (fmtType == date_format26) { /*2000/Feb/18 */ - tmp = QString::number(date.year()); + tmp = TQString::number(date.year()); tmp += "/" + converter->locale()->calendar()->monthString(date, true); - tmp += "/" + QString().sprintf("%02d", date.day()); + tmp += "/" + TQString().sprintf("%02d", date.day()); } else tmp = converter->locale()->formatDate(date, true); @@ -630,9 +630,9 @@ QString ValueFormatter::dateFormat (const QDate &date, FormatType fmtType) return tmp; } -QString ValueFormatter::errorFormat (Cell *cell) +TQString ValueFormatter::errorFormat (Cell *cell) { - QString err; + TQString err; if (cell->testFlag (Cell::Flag_ParseError)) err = "#" + i18n ("Parse") + "!"; else if ( cell->testFlag (Cell::Flag_CircularCalculation)) |