summaryrefslogtreecommitdiff
path: root/svl
diff options
context:
space:
mode:
authorNorbert Thiebaud <nthiebaud@gmail.com>2012-11-18 18:55:49 -0600
committerNorbert Thiebaud <nthiebaud@gmail.com>2012-11-18 19:57:23 -0600
commit271b11a3d56ba0c5f542a142ab859a0819530dba (patch)
treed8719dd652134f89ea980b1a42d3a59a8db949b6 /svl
parentcc63555fd02217e3b68caccfa5c8a0171aca149c (diff)
migrate one GetOutputString variatn to OUString
that create some clutter on some of the caller, this will be resolved as things progress to ward OUString only This is done that way to be incremental and avoid creating too big patches Change-Id: I4a881d85cc2ee1eb53bc0c0d0902838b1d3720a2
Diffstat (limited to 'svl')
-rw-r--r--svl/inc/svl/zforlist.hxx7
-rw-r--r--svl/inc/svl/zformat.hxx6
-rw-r--r--svl/source/numbers/numfmuno.cxx25
-rw-r--r--svl/source/numbers/zforlist.cxx52
-rw-r--r--svl/source/numbers/zformat.cxx39
5 files changed, 67 insertions, 62 deletions
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)