summaryrefslogtreecommitdiff
path: root/xmloff
diff options
context:
space:
mode:
authorNorbert Thiebaud <nthiebaud@gmail.com>2012-11-05 02:35:29 -0600
committerNorbert Thiebaud <nthiebaud@gmail.com>2012-11-18 19:57:21 -0600
commit566adca89eeccc53d72704cc43f0c4afc4254fce (patch)
tree0ced4906cd395c41414de7ca959245eb27247cbd /xmloff
parentd35ce2d9be2c67239b74e8f699e1c04558bfc0af (diff)
xmloff: simplify the use of AddToCode
most use of that API is to add a single sal_Unicode, it is silly to manufacture a full OUString just to pass that via AddToCode to then append it to a OUStringBuffer adding AddToCode(sal_Unicode c) to simplify these case also remove a silly iteration over a OUString's character to re-add each character one by one via AddToCode() Change-Id: Ia8a58551a1c24312baaa250b8d36fe21c46127e7
Diffstat (limited to 'xmloff')
-rw-r--r--xmloff/inc/xmloff/xmlnumfi.hxx1
-rw-r--r--xmloff/source/style/xmlnumfi.cxx36
2 files changed, 24 insertions, 13 deletions
diff --git a/xmloff/inc/xmloff/xmlnumfi.hxx b/xmloff/inc/xmloff/xmlnumfi.hxx
index 552caa5f3815..f162f5be8aa1 100644
--- a/xmloff/inc/xmloff/xmlnumfi.hxx
+++ b/xmloff/inc/xmloff/xmlnumfi.hxx
@@ -202,6 +202,7 @@ public:
const LocaleDataWrapper& GetLocaleData() const;
void AddToCode( const rtl::OUString& rString );
+ void AddToCode( sal_Unicode c );
void AddNumber( const SvXMLNumberInfo& rInfo );
void AddCurrency( const rtl::OUString& rContent, LanguageType nLang );
diff --git a/xmloff/source/style/xmlnumfi.cxx b/xmloff/source/style/xmlnumfi.cxx
index f5b8c2124fab..f142ce936e5b 100644
--- a/xmloff/source/style/xmlnumfi.cxx
+++ b/xmloff/source/style/xmlnumfi.cxx
@@ -1098,13 +1098,13 @@ void SvXMLNumFmtElementContext::EndElement()
break;
case XML_TOK_STYLE_TEXT_CONTENT:
- rParent.AddToCode( OUString::valueOf((sal_Unicode)'@') );
+ rParent.AddToCode( (sal_Unicode)'@');
break;
case XML_TOK_STYLE_FILL_CHARACTER:
if ( aContent.getLength() )
{
- rParent.AddToCode( OUString::valueOf((sal_Unicode)'*') );
- rParent.AddToCode( OUString::valueOf( aContent[0] ) );
+ rParent.AddToCode( (sal_Unicode)'*' );
+ rParent.AddToCode( aContent[0] );
}
break;
case XML_TOK_STYLE_BOOLEAN:
@@ -1188,13 +1188,11 @@ void SvXMLNumFmtElementContext::EndElement()
if ( aNumInfo.nDecimals > 0 )
{
// manually add the decimal places
- const String& rSep = rParent.GetLocaleData().getNumDecimalSep();
- for ( xub_StrLen j=0; j<rSep.Len(); j++ )
+ rParent.AddToCode(rParent.GetLocaleData().getNumDecimalSep());
+ for (sal_Int32 i=0; i<aNumInfo.nDecimals; i++)
{
- rParent.AddToCode( OUString::valueOf( rSep.GetChar(j) ) );
+ rParent.AddToCode( (sal_Unicode)'0');
}
- for (sal_Int32 i=0; i<aNumInfo.nDecimals; i++)
- rParent.AddToCode( OUString::valueOf((sal_Unicode)'0') );
}
break;
@@ -1205,15 +1203,17 @@ void SvXMLNumFmtElementContext::EndElement()
// add integer part only if min-integer-digits attribute is there
aNumInfo.nDecimals = 0;
rParent.AddNumber( aNumInfo ); // number without decimals
- rParent.AddToCode( OUString::valueOf((sal_Unicode)' ') );
+ rParent.AddToCode( (sal_Unicode)' ' );
}
//! build string and add at once
sal_Int32 i;
for (i=0; i<aNumInfo.nNumerDigits; i++)
- rParent.AddToCode( OUString::valueOf((sal_Unicode)'?') );
- rParent.AddToCode( OUString::valueOf((sal_Unicode)'/') );
+ {
+ rParent.AddToCode( (sal_Unicode)'?' );
+ }
+ rParent.AddToCode( (sal_Unicode)'/' );
if ( aNumInfo.nFracDenominator > 0 )
{
rParent.AddToCode( OUString::valueOf( aNumInfo.nFracDenominator ) );
@@ -1221,7 +1221,9 @@ void SvXMLNumFmtElementContext::EndElement()
else
{
for (i=0; i<aNumInfo.nDenomDigits; i++)
- rParent.AddToCode( OUString::valueOf((sal_Unicode)'?') );
+ {
+ rParent.AddToCode( (sal_Unicode)'?');
+ }
}
}
break;
@@ -1232,7 +1234,9 @@ void SvXMLNumFmtElementContext::EndElement()
rParent.AddToCode( OUString("E+") );
for (sal_Int32 i=0; i<aNumInfo.nExpDigits; i++)
- rParent.AddToCode( OUString::valueOf((sal_Unicode)'0') );
+ {
+ rParent.AddToCode( (sal_Unicode)'0' );
+ }
}
break;
@@ -1713,6 +1717,12 @@ const LocaleDataWrapper& SvXMLNumFormatContext::GetLocaleData() const
return pData->GetLocaleData( nFormatLang );
}
+void SvXMLNumFormatContext::AddToCode( sal_Unicode c )
+{
+ aFormatCode.append( c );
+ bHasExtraText = sal_True;
+}
+
void SvXMLNumFormatContext::AddToCode( const rtl::OUString& rString )
{
aFormatCode.append( rString );