diff options
-rw-r--r-- | sc/source/ui/app/inputhdl.cxx | 10 | ||||
-rw-r--r-- | sc/source/ui/formdlg/formula.cxx | 6 | ||||
-rw-r--r-- | svl/inc/svl/zforlist.hxx | 7 | ||||
-rw-r--r-- | svl/inc/svl/zformat.hxx | 6 | ||||
-rw-r--r-- | svl/source/numbers/numfmuno.cxx | 25 | ||||
-rw-r--r-- | svl/source/numbers/zforlist.cxx | 52 | ||||
-rw-r--r-- | svl/source/numbers/zformat.cxx | 39 | ||||
-rw-r--r-- | svtools/source/control/fmtfield.cxx | 21 | ||||
-rw-r--r-- | svx/source/items/numfmtsh.cxx | 22 | ||||
-rw-r--r-- | sw/source/core/fields/fldbas.cxx | 16 | ||||
-rw-r--r-- | sw/source/core/table/swtable.cxx | 6 | ||||
-rw-r--r-- | sw/source/ui/utlui/numfmtlb.cxx | 12 |
12 files changed, 142 insertions, 80 deletions
diff --git a/sc/source/ui/app/inputhdl.cxx b/sc/source/ui/app/inputhdl.cxx index 9b92164efb95..172dd54ce03c 100644 --- a/sc/source/ui/app/inputhdl.cxx +++ b/sc/source/ui/app/inputhdl.cxx @@ -1360,8 +1360,14 @@ static String lcl_Calculate( const String& rFormula, ScDocument* pDoc, const ScA String aStr = pCell->GetString(); sal_uLong nFormat = aFormatter.GetStandardFormat( pCell->GetFormatType(), ScGlobal::eLnge); - aFormatter.GetOutputString( aStr, nFormat, - aValue, &pColor ); + { + OUString sTempIn(aStr); + OUString sTempOut(aValue); + aFormatter.GetOutputString( sTempIn, nFormat, + sTempOut, &pColor ); + aStr = sTempIn; + aValue = sTempOut; + } aValue.Insert('"',0); // in Anfuehrungszeichen aValue+='"'; diff --git a/sc/source/ui/formdlg/formula.cxx b/sc/source/ui/formdlg/formula.cxx index b96919261207..4c01577df640 100644 --- a/sc/source/ui/formdlg/formula.cxx +++ b/sc/source/ui/formdlg/formula.cxx @@ -367,11 +367,13 @@ bool ScFormulaDlg::calculateValue( const String& rStrExp, String& rStrResult ) } else { - String aStr = pFCell->GetString(); + OUString aStr = pFCell->GetString(); + OUString sTempOut(rStrResult); sal_uLong nFormat = aFormatter.GetStandardFormat( pFCell->GetFormatType(), ScGlobal::eLnge); aFormatter.GetOutputString( aStr, nFormat, - rStrResult, &pColor ); + sTempOut, &pColor ); + rStrResult = sTempOut; } ScRange aTestRange; diff --git a/svl/inc/svl/zforlist.hxx b/svl/inc/svl/zforlist.hxx index 4c7b949021dd..71e6bbabf6ab 100644 --- a/svl/inc/svl/zforlist.hxx +++ b/svl/inc/svl/zforlist.hxx @@ -490,13 +490,6 @@ public: /** Format a string according to a format index, return string and color. Formats only if the format code is of type text or the 4th subcode of a format code is specified, otherwise sOutString will be == "" */ - void GetOutputString( String& sString, sal_uInt32 nFIndex, - String& sOutString, Color** ppColor, bool bUseStarFormat = false ); - - - /** Format a string according to a format index, return string and color. - Formats only if the format code is of type text or the 4th subcode - of a format code is specified, otherwise sOutString will be == "" */ void GetOutputString( OUString& sString, sal_uInt32 nFIndex, OUString& sOutString, Color** ppColor, bool bUseStarFormat = false ); diff --git a/svl/inc/svl/zformat.hxx b/svl/inc/svl/zformat.hxx index 5abec42b9c88..6e13b2ddf028 100644 --- a/svl/inc/svl/zformat.hxx +++ b/svl/inc/svl/zformat.hxx @@ -248,7 +248,7 @@ public: bool GetOutputString( double fNumber, sal_uInt16 nCharCount, String& rOutString ) const; bool GetOutputString( double fNumber, String& OutString, Color** ppColor ); - bool GetOutputString( String& sString, String& OutString, Color** ppColor ); + bool GetOutputString( OUString& sString, OUString& OutString, Color** ppColor ); // True if type text bool IsTextFormat() const { return (eType & NUMBERFORMAT_TEXT) != 0; } @@ -388,6 +388,10 @@ public: the width of character c for underscore formats */ static xub_StrLen InsertBlanks( String& r, xub_StrLen nPos, sal_Unicode c ); + /** Insert the number of blanks into the string that is needed to simulate + the width of character c for underscore formats */ + static sal_Int32 InsertBlanks( OUStringBuffer& r, sal_Int32 nPos, sal_Unicode c ); + /// One of YMD,DMY,MDY if date format DateFormat GetDateOrder() const; diff --git a/svl/source/numbers/numfmuno.cxx b/svl/source/numbers/numfmuno.cxx index 80ec23a91c92..f3041b04882c 100644 --- a/svl/source/numbers/numfmuno.cxx +++ b/svl/source/numbers/numfmuno.cxx @@ -253,28 +253,31 @@ util::Color SAL_CALL SvNumberFormatterServiceObj::queryColorForNumber( sal_Int32 return nRet; } -rtl::OUString SAL_CALL SvNumberFormatterServiceObj::formatString( sal_Int32 nKey, - const rtl::OUString& aString ) throw(uno::RuntimeException) +OUString SAL_CALL SvNumberFormatterServiceObj::formatString( sal_Int32 nKey, + const OUString& aString ) + throw(uno::RuntimeException) { ::osl::MutexGuard aGuard( m_aMutex ); - String aRet; + OUString aRet; SvNumberFormatter* pFormatter = xSupplier.is() ? xSupplier->GetNumberFormatter() : NULL; if (pFormatter) { - String aTemp = aString; + OUString aTemp = aString; Color* pColor = NULL; pFormatter->GetOutputString(aTemp, nKey, aRet, &pColor); } else + { throw uno::RuntimeException(); - + } return aRet; } util::Color SAL_CALL SvNumberFormatterServiceObj::queryColorForString( sal_Int32 nKey, - const rtl::OUString& aString,util::Color aDefaultColor ) - throw(uno::RuntimeException) + const OUString& aString, + util::Color aDefaultColor ) + throw(uno::RuntimeException) { ::osl::MutexGuard aGuard( m_aMutex ); @@ -282,16 +285,20 @@ util::Color SAL_CALL SvNumberFormatterServiceObj::queryColorForString( sal_Int32 SvNumberFormatter* pFormatter = xSupplier.is() ? xSupplier->GetNumberFormatter() : NULL; if (pFormatter) { - String aTemp = aString; - String aStr; + OUString aTemp = aString; + OUString aStr; Color* pColor = NULL; pFormatter->GetOutputString(aTemp, nKey, aStr, &pColor); if (pColor) + { nRet = pColor->GetColor(); + } // sonst Default behalten } else + { throw uno::RuntimeException(); + } return nRet; } diff --git a/svl/source/numbers/zforlist.cxx b/svl/source/numbers/zforlist.cxx index 2e1c20d2146f..ae027731d1b0 100644 --- a/svl/source/numbers/zforlist.cxx +++ b/svl/source/numbers/zforlist.cxx @@ -1481,15 +1481,17 @@ void SvNumberFormatter::GetOutputString(const double& fOutNumber, pFormat->SetStarFormatSupport( false ); } -void SvNumberFormatter::GetOutputString(String& sString, +void SvNumberFormatter::GetOutputString(OUString& sString, sal_uInt32 nFIndex, - String& sOutString, + OUString& sOutString, Color** ppColor, bool bUseStarFormat ) { SvNumberformat* pFormat = GetFormatEntry( nFIndex ); if (!pFormat) + { pFormat = GetFormatEntry(ZF_STANDARD_TEXT); + } if (!pFormat->IsTextFormat() && !pFormat->HasTextFormat()) { *ppColor = NULL; @@ -1499,10 +1501,14 @@ void SvNumberFormatter::GetOutputString(String& sString, { ChangeIntl(pFormat->GetLanguage()); if ( bUseStarFormat ) + { pFormat->SetStarFormatSupport( true ); + } pFormat->GetOutputString(sString, sOutString, ppColor); if ( bUseStarFormat ) + { pFormat->SetStarFormatSupport( false ); + } } } @@ -1530,35 +1536,6 @@ void SvNumberFormatter::GetOutputString(const double& fOutNumber, sOutString = aOutString; } -void SvNumberFormatter::GetOutputString(OUString& sString, - sal_uInt32 nFIndex, - OUString& sOutString, - Color** ppColor, - bool bUseStarFormat ) -{ - SvNumberformat* pFormat = GetFormatEntry( nFIndex ); - if (!pFormat) - pFormat = GetFormatEntry(ZF_STANDARD_TEXT); - if (!pFormat->IsTextFormat() && !pFormat->HasTextFormat()) - { - *ppColor = NULL; - sOutString = sString; - } - else - { - ChangeIntl(pFormat->GetLanguage()); - String aString = sString; - String aOutString = sOutString; - if ( bUseStarFormat ) - pFormat->SetStarFormatSupport( true ); - pFormat->GetOutputString(aString, aOutString, ppColor); - if ( bUseStarFormat ) - pFormat->SetStarFormatSupport( false ); - sString = aString; - sOutString = aOutString; - } -} - bool SvNumberFormatter::GetPreviewString(const String& sFormatString, double fPreviewNumber, String& sOutString, @@ -1723,19 +1700,26 @@ bool SvNumberFormatter::GetPreviewString( const String& sFormatString, eLnge); if (nCheckPos == 0) // String ok { - String aNonConstPreview( sPreviewString); + OUString aNonConstPreview( sPreviewString); + OUString sTemp; // May have to create standard formats for this locale. sal_uInt32 CLOffset = ImpGenerateCL(eLnge); nKey = ImpIsEntry( p_Entry->GetFormatstring(), CLOffset, eLnge); if (nKey != NUMBERFORMAT_ENTRY_NOT_FOUND) // already present - GetOutputString( aNonConstPreview, nKey, sOutString, ppColor); + { + GetOutputString( aNonConstPreview, nKey, sTemp, ppColor); + sOutString = sTemp; + } else { // If the format is valid but not a text format and does not // include a text subformat, an empty string would result. Same as // in SvNumberFormatter::GetOutputString() if (p_Entry->IsTextFormat() || p_Entry->HasTextFormat()) - p_Entry->GetOutputString( aNonConstPreview, sOutString, ppColor); + { + p_Entry->GetOutputString( aNonConstPreview, sTemp, ppColor); + sOutString = sTemp; + } else { *ppColor = NULL; diff --git a/svl/source/numbers/zformat.cxx b/svl/source/numbers/zformat.cxx index ce0a35de536d..b691dbacdda9 100644 --- a/svl/source/numbers/zformat.cxx +++ b/svl/source/numbers/zformat.cxx @@ -101,6 +101,23 @@ xub_StrLen SvNumberformat::InsertBlanks( String& r, xub_StrLen nPos, sal_Unicode return nPos; } +sal_Int32 SvNumberformat::InsertBlanks( OUStringBuffer& r, sal_Int32 nPos, sal_Unicode c ) +{ + if( c >= 32 ) + { + int n = 2; // Default fuer Zeichen > 128 (HACK!) + if( c <= 127 ) + { + n = (int)cCharWidths[ c - 32 ]; + } + while( n-- ) + { + r.insert( nPos++, (sal_Unicode)' '); + } + } + return nPos; +} + static long GetPrecExp( double fAbsVal ) { DBG_ASSERT( fAbsVal > 0.0, "GetPrecExp: fAbsVal <= 0.0" ); @@ -2190,11 +2207,11 @@ short SvNumberformat::ImpCheckCondition(double& fNumber, } } -bool SvNumberformat::GetOutputString(String& sString, - String& OutString, +bool SvNumberformat::GetOutputString(OUString& sString, + OUString& OutString, Color** ppColor) { - OutString.Erase(); + OUStringBuffer sOutBuff; sal_uInt16 nIx; if (eType & NUMBERFORMAT_TEXT) { @@ -2211,9 +2228,9 @@ bool SvNumberformat::GetOutputString(String& sString, } *ppColor = NumFor[nIx].GetColor(); const ImpSvNumberformatInfo& rInfo = NumFor[nIx].Info(); + bool bRes = false; if (rInfo.eScannedType == NUMBERFORMAT_TEXT) { - bool bRes = false; const sal_uInt16 nAnz = NumFor[nIx].GetCount(); for (sal_uInt16 i = 0; i < nAnz; i++) { @@ -2222,26 +2239,26 @@ bool SvNumberformat::GetOutputString(String& sString, case NF_SYMBOLTYPE_STAR: if( bStarFlag ) { - OutString += (sal_Unicode) 0x1B; - OutString += rInfo.sStrArray[i][1]; + sOutBuff.append((sal_Unicode) 0x1B); + sOutBuff.append(rInfo.sStrArray[i][1]); bRes = true; } break; case NF_SYMBOLTYPE_BLANK: - InsertBlanks( OutString, OutString.Len(), + InsertBlanks( sOutBuff, sOutBuff.getLength(), rInfo.sStrArray[i][1] ); break; case NF_KEY_GENERAL : // #77026# "General" is the same as "@" case NF_SYMBOLTYPE_DEL : - OutString += sString; + sOutBuff.append(sString); break; default: - OutString += rInfo.sStrArray[i]; + sOutBuff.append(rInfo.sStrArray[i]); } } - return bRes; } - return false; + OutString = sOutBuff.makeStringAndClear(); + return bRes; } sal_uLong SvNumberformat::ImpGGT(sal_uLong x, sal_uLong y) diff --git a/svtools/source/control/fmtfield.cxx b/svtools/source/control/fmtfield.cxx index 3bfa00a81b3f..2d1445f9b38e 100644 --- a/svtools/source/control/fmtfield.cxx +++ b/svtools/source/control/fmtfield.cxx @@ -413,9 +413,17 @@ void FormattedField::SetTextFormatted(const OUString& rStr) sal_uInt32 nTempFormatKey = static_cast< sal_uInt32 >( m_nFormatKey ); if( IsUsingInputStringForFormatting() && ImplGetFormatter()->IsNumberFormat(m_sCurrentTextValue, nTempFormatKey, dNumber) ) + { ImplGetFormatter()->GetInputLineString(dNumber, m_nFormatKey, sFormatted); + } else - ImplGetFormatter()->GetOutputString(m_sCurrentTextValue, m_nFormatKey, sFormatted, &m_pLastOutputColor); + { + OUString sTempIn(m_sCurrentTextValue); + OUString sTempOut(sFormatted); + ImplGetFormatter()->GetOutputString(sTempIn, m_nFormatKey, sTempOut, &m_pLastOutputColor); + m_sCurrentTextValue = sTempIn; + sFormatted = sTempOut; + } // calculate the new selection Selection aSel(GetSelection()); @@ -956,14 +964,23 @@ void FormattedField::ImplSetValue(double dVal, sal_Bool bForce) String sTemp; ImplGetFormatter()->GetOutputString(dVal, 0, sTemp, &m_pLastOutputColor); // dann den String entsprechend dem Text-Format - ImplGetFormatter()->GetOutputString(sTemp, m_nFormatKey, sNewText, &m_pLastOutputColor); + { + OUString sTempIn(m_sCurrentTextValue); + OUString sTempOut; + ImplGetFormatter()->GetOutputString(sTempIn, m_nFormatKey, sTempOut, &m_pLastOutputColor); + sNewText = sTempOut; + } } else { if( IsUsingInputStringForFormatting()) + { ImplGetFormatter()->GetInputLineString(dVal, m_nFormatKey, sNewText); + } else + { ImplGetFormatter()->GetOutputString(dVal, m_nFormatKey, sNewText, &m_pLastOutputColor); + } } ImplSetTextImpl(sNewText, NULL); diff --git a/svx/source/items/numfmtsh.cxx b/svx/source/items/numfmtsh.cxx index c2495313b2bb..5e12eb8ace56 100644 --- a/svx/source/items/numfmtsh.cxx +++ b/svx/source/items/numfmtsh.cxx @@ -449,11 +449,19 @@ void SvxNumberFormatShell::MakePreviewString( const String& rFormatStr, bool bUseText = ( eValType == SVX_VALUE_TYPE_STRING || ( aValStr.Len() && ( pFormatter->GetType(nExistingFormat) & NUMBERFORMAT_TEXT ) ) ); if ( bUseText ) - pFormatter->GetOutputString( aValStr, nExistingFormat, - rPreviewStr, &rpFontColor ); + { + OUString sTempIn(aValStr); + OUString sTempOut(rPreviewStr); + pFormatter->GetOutputString( sTempIn, nExistingFormat, + sTempOut, &rpFontColor ); + aValStr = sTempIn; + rPreviewStr = sTempOut; + } else + { pFormatter->GetOutputString( nValNum, nExistingFormat, rPreviewStr, &rpFontColor, bUseStarFormat ); + } } } @@ -1150,9 +1158,17 @@ void SvxNumberFormatShell::GetPreviewString_Impl( String& rString, Color*& rpCol ( aValStr.Len() && ( pFormatter->GetType(nCurFormatKey) & NUMBERFORMAT_TEXT ) ) ); if ( bUseText ) - pFormatter->GetOutputString( aValStr, nCurFormatKey, rString, &rpColor ); + { + OUString sTempIn(aValStr); + OUString sTempOut(rString); + pFormatter->GetOutputString( sTempIn, nCurFormatKey, sTempOut, &rpColor ); + aValStr = sTempIn; + rString = sTempOut; + } else + { pFormatter->GetOutputString( nValNum, nCurFormatKey, rString, &rpColor, bUseStarFormat ); + } } // ----------------------------------------------------------------------- diff --git a/sw/source/core/fields/fldbas.cxx b/sw/source/core/fields/fldbas.cxx index 38bcee9173ce..f2439f1f49f4 100644 --- a/sw/source/core/fields/fldbas.cxx +++ b/sw/source/core/fields/fldbas.cxx @@ -511,11 +511,15 @@ String SwValueFieldType::ExpandValue( const double& rVal, { String sValue; DoubleToString(sValue, rVal, nFmtLng); - pFormatter->GetOutputString(sValue, nFmt, sExpand, &pCol); + OUString sTempIn(sValue); + OUString sTempOut(sExpand); + pFormatter->GetOutputString(sTempIn, nFmt, sTempOut, &pCol); + sExpand = sTempOut; } else + { pFormatter->GetOutputString(rVal, nFmt, sExpand, &pCol); - + } return sExpand; } @@ -748,11 +752,15 @@ String SwFormulaField::GetExpandedFormula() const { String sValue; ((SwValueFieldType *)GetTyp())->DoubleToString(sValue, GetValue(), nFmt); - pFormatter->GetOutputString(sValue, nFmt, sFormattedValue, &pCol); + OUString sTempOut(sFormattedValue); + OUString sTempIn(sValue); + pFormatter->GetOutputString(sTempIn, nFmt, sTempOut, &pCol); + sFormattedValue = sTempOut; } else + { pFormatter->GetOutputString(GetValue(), nFmt, sFormattedValue, &pCol); - + } return sFormattedValue; } else diff --git a/sw/source/core/table/swtable.cxx b/sw/source/core/table/swtable.cxx index b790bbe66207..413b7efd8302 100644 --- a/sw/source/core/table/swtable.cxx +++ b/sw/source/core/table/swtable.cxx @@ -2148,7 +2148,11 @@ void ChgNumToText( SwTableBox& rBox, sal_uLong nFmt ) { // special text format: String sTmp, sTxt( pTNd->GetTxt() ); - pDoc->GetNumberFormatter()->GetOutputString( sTxt, nFmt, sTmp, &pCol ); + OUString sTempIn(sTxt); + OUString sTempOut; + pDoc->GetNumberFormatter()->GetOutputString( sTempIn, nFmt, sTempOut, &pCol ); + sTxt = sTempIn; + sTmp = sTempOut; if( sTxt != sTmp ) { // exchange text diff --git a/sw/source/ui/utlui/numfmtlb.cxx b/sw/source/ui/utlui/numfmtlb.cxx index 8f3679f6556c..71def9e92e66 100644 --- a/sw/source/ui/utlui/numfmtlb.cxx +++ b/sw/source/ui/utlui/numfmtlb.cxx @@ -242,8 +242,10 @@ void NumFormatListBox::SetFormatType(const short nFormatType) sValue = pFmt->GetFormatstring(); else if( nFormatType == NUMBERFORMAT_TEXT ) { - String sTxt(rtl::OUString("\"ABC\"")); - pFormatter->GetOutputString( sTxt, nFormat, sValue, &pCol); + OUString sTxt("\"ABC\""); + OUString sTempOut(sValue); + pFormatter->GetOutputString( sTxt, nFormat, sTempOut, &pCol); + sValue = sTempOut; } if (nFormat != nSysNumFmt && @@ -317,8 +319,10 @@ void NumFormatListBox::SetDefFormat(const sal_uLong nDefFmt) if (nType == NUMBERFORMAT_TEXT) { - String sTxt(rtl::OUString("\"ABC\"")); - pFormatter->GetOutputString(sTxt, nDefFmt, sValue, &pCol); + OUString sTxt("\"ABC\""); + OUString sTempOut(sValue); + pFormatter->GetOutputString(sTxt, nDefFmt, sTempOut, &pCol); + sValue = sTempOut; } else pFormatter->GetOutputString(fValue, nDefFmt, sValue, &pCol); |