diff options
author | Eike Rathke [er] <erAck@sun.com> | 2010-07-16 20:13:45 +0200 |
---|---|---|
committer | Eike Rathke [er] <erAck@sun.com> | 2010-07-16 20:13:45 +0200 |
commit | 8444953804e704a4462c3416c1ad50db2ce9fec4 (patch) | |
tree | 5987e4e411507f00f06851daf26a6fbb91772f3a /svl/source/numbers | |
parent | bcd4bc56c93dd815da6b5d0e22348dabbc75ca9f (diff) |
calc56: #i108385# make TEXT return text if text was passed, handling text formats that include a @ code
Diffstat (limited to 'svl/source/numbers')
-rw-r--r-- | svl/source/numbers/zforlist.cxx | 52 | ||||
-rw-r--r-- | svl/source/numbers/zformat.cxx | 2 |
2 files changed, 53 insertions, 1 deletions
diff --git a/svl/source/numbers/zforlist.cxx b/svl/source/numbers/zforlist.cxx index cb66a75558c2..7343a0a9c0e6 100644 --- a/svl/source/numbers/zforlist.cxx +++ b/svl/source/numbers/zforlist.cxx @@ -1697,6 +1697,58 @@ BOOL SvNumberFormatter::GetPreviewStringGuess( const String& sFormatString, return FALSE; } +BOOL SvNumberFormatter::GetPreviewString( const String& sFormatString, + const String& sPreviewString, + String& sOutString, + Color** ppColor, + LanguageType eLnge ) +{ + if (sFormatString.Len() == 0) // no empty string + return FALSE; + + xub_StrLen nCheckPos = STRING_NOTFOUND; + sal_uInt32 nKey; + if (eLnge == LANGUAGE_DONTKNOW) + eLnge = IniLnge; + ChangeIntl(eLnge); // switch if needed + eLnge = ActLnge; + String sTmpString = sFormatString; + SvNumberformat* p_Entry = new SvNumberformat( sTmpString, + pFormatScanner, + pStringScanner, + nCheckPos, + eLnge); + if (nCheckPos == 0) // String ok + { + String aNonConstPreview( sPreviewString); + // 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); + 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); + else + { + *ppColor = NULL; + sOutString = sPreviewString; + } + } + delete p_Entry; + return TRUE; + } + else + { + delete p_Entry; + return FALSE; + } +} + sal_uInt32 SvNumberFormatter::TestNewString(const String& sFormatString, LanguageType eLnge) { diff --git a/svl/source/numbers/zformat.cxx b/svl/source/numbers/zformat.cxx index 2d0909c8782b..97f06171a4fc 100644 --- a/svl/source/numbers/zformat.cxx +++ b/svl/source/numbers/zformat.cxx @@ -2057,7 +2057,7 @@ BOOL SvNumberformat::GetOutputString(double fNumber, OutString = rScan.GetFalseString(); return FALSE; } - if (eType & NUMBERFORMAT_TEXT && bStandard) + if (eType & NUMBERFORMAT_TEXT) { ImpGetOutputStandard(fNumber, OutString); return FALSE; |