diff options
author | Norbert Thiebaud <nthiebaud@gmail.com> | 2012-11-25 13:48:51 -0600 |
---|---|---|
committer | Norbert Thiebaud <nthiebaud@gmail.com> | 2012-11-27 23:00:04 -0600 |
commit | fb4685458544670fba5f627d4572ea780f9f7785 (patch) | |
tree | dd4313bfc40c55f01b7a1e9a0a685a23037083aa /svl | |
parent | 7796d003bd6e0c5b2e4325ea79b4ad022e8e5938 (diff) |
more wrapper in zforlist to isolate String/OUString issues
Change-Id: I53e5e60f59739bdcedb6e7b13006850e0e5b22c0
Diffstat (limited to 'svl')
-rw-r--r-- | svl/inc/svl/zforlist.hxx | 18 | ||||
-rw-r--r-- | svl/source/numbers/zforlist.cxx | 50 |
2 files changed, 49 insertions, 19 deletions
diff --git a/svl/inc/svl/zforlist.hxx b/svl/inc/svl/zforlist.hxx index 4558dc99bde6..c31499867483 100644 --- a/svl/inc/svl/zforlist.hxx +++ b/svl/inc/svl/zforlist.hxx @@ -494,7 +494,7 @@ 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( OUString& sString, sal_uInt32 nFIndex, + void GetOutputString( const OUString& sString, sal_uInt32 nFIndex, OUString& sOutString, Color** ppColor, bool bUseStarFormat = false ); /** Format a number according to the standard default format matching @@ -524,18 +524,26 @@ public: /** Same as <method>GetPreviewString</method> but the format code string may be either language/country eLnge or en_US english US */ + bool GetPreviewStringGuess( const OUString& sFormatString, double fPreviewNumber, + OUString& sOutString, Color** ppColor, + LanguageType eLnge = LANGUAGE_DONTKNOW ); + bool GetPreviewStringGuess( const String& sFormatString, double fPreviewNumber, - String& sOutString, Color** ppColor, - LanguageType eLnge = LANGUAGE_DONTKNOW ); + String& sOutString, Color** ppColor, + LanguageType eLnge = LANGUAGE_DONTKNOW ); /** Format a string according to a format code string to be scanned. @return <FALSE/> if format code contains an error <TRUE/> else, in which case the string and color are returned. */ + bool GetPreviewString( const OUString& sFormatString, const OUString& sPreviewString, + OUString& sOutString, Color** ppColor, + LanguageType eLnge = LANGUAGE_DONTKNOW ); + bool GetPreviewString( const String& sFormatString, const String& sPreviewString, - String& sOutString, Color** ppColor, - LanguageType eLnge = LANGUAGE_DONTKNOW ); + String& sOutString, Color** ppColor, + LanguageType eLnge = LANGUAGE_DONTKNOW ); /** Test whether the format code string is already present in container @return diff --git a/svl/source/numbers/zforlist.cxx b/svl/source/numbers/zforlist.cxx index e1b97cca11ce..f443dd67585b 100644 --- a/svl/source/numbers/zforlist.cxx +++ b/svl/source/numbers/zforlist.cxx @@ -1555,7 +1555,7 @@ void SvNumberFormatter::GetInputLineString(const double& fOutNumber, rOutString = aTmp; } -void SvNumberFormatter::GetOutputString(OUString& sString, +void SvNumberFormatter::GetOutputString(const OUString& sString, sal_uInt32 nFIndex, OUString& sOutString, Color** ppColor, @@ -1683,7 +1683,7 @@ bool SvNumberFormatter::GetPreviewString(const String& sFormatString, { bool result; OUString sTemp(sOutString); - result = GetPreviewString(sFormatString, fPreviewNumber, sTemp, + result = GetPreviewString(OUString(sFormatString), fPreviewNumber, sTemp, ppColor, eLnge, bUseStarFormat ); sOutString = sTemp; return result; @@ -1695,7 +1695,21 @@ bool SvNumberFormatter::GetPreviewStringGuess( const String& sFormatString, Color** ppColor, LanguageType eLnge ) { - if (sFormatString.Len() == 0) // no empty string + bool result; + OUString sTemp(sOutString); + result = GetPreviewStringGuess( OUString(sFormatString), fPreviewNumber, + sTemp, ppColor, eLnge ); + sOutString = sTemp; + return result; +} + +bool SvNumberFormatter::GetPreviewStringGuess( const OUString& sFormatString, + double fPreviewNumber, + OUString& sOutString, + Color** ppColor, + LanguageType eLnge ) +{ + if (sFormatString.isEmpty()) // no empty string { return false; } @@ -1707,7 +1721,7 @@ bool SvNumberFormatter::GetPreviewStringGuess( const String& sFormatString, eLnge = ActLnge; bool bEnglish = (eLnge == LANGUAGE_ENGLISH_US); - String aFormatStringUpper( pCharClass->uppercase( sFormatString ) ); + OUString aFormatStringUpper( pCharClass->uppercase( sFormatString ) ); sal_uInt32 nCLOffset = ImpGenerateCL( eLnge ); sal_uInt32 nKey = ImpIsEntry( aFormatStringUpper, nCLOffset, eLnge ); if ( nKey != NUMBERFORMAT_ENTRY_NOT_FOUND ) @@ -1782,9 +1796,7 @@ bool SvNumberFormatter::GetPreviewStringGuess( const String& sFormatString, if (nCheckPos == 0) // String ok { ImpGenerateCL( eLnge ); // create new standard formats if necessary - OUString sTemp(sOutString); - pEntry->GetOutputString( fPreviewNumber, sTemp, ppColor ); - sOutString = sTemp; + pEntry->GetOutputString( fPreviewNumber, sOutString, ppColor ); delete pEntry; return true; } @@ -1798,7 +1810,21 @@ bool SvNumberFormatter::GetPreviewString( const String& sFormatString, Color** ppColor, LanguageType eLnge ) { - if (sFormatString.Len() == 0) // no empty string + bool result; + OUString sTemp(sOutString); + result = GetPreviewString( OUString(sFormatString), OUString(sPreviewString), + sTemp, ppColor, eLnge ); + sOutString = sTemp; + return result; +} + +bool SvNumberFormatter::GetPreviewString( const OUString& sFormatString, + const OUString& sPreviewString, + OUString& sOutString, + Color** ppColor, + LanguageType eLnge ) +{ + if (sFormatString.isEmpty()) // no empty string { return false; } @@ -1818,15 +1844,12 @@ bool SvNumberFormatter::GetPreviewString( const String& sFormatString, eLnge); if (nCheckPos == 0) // String ok { - 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, sTemp, ppColor); - sOutString = sTemp; + GetOutputString( sPreviewString, nKey, sOutString, ppColor); } else { @@ -1835,8 +1858,7 @@ bool SvNumberFormatter::GetPreviewString( const String& sFormatString, // in SvNumberFormatter::GetOutputString() if (p_Entry->IsTextFormat() || p_Entry->HasTextFormat()) { - p_Entry->GetOutputString( aNonConstPreview, sTemp, ppColor); - sOutString = sTemp; + p_Entry->GetOutputString( sPreviewString, sOutString, ppColor); } else { |