summaryrefslogtreecommitdiff
path: root/sc
diff options
context:
space:
mode:
authorRicardo Montania <ricardo@linuxafundo.com.br>2013-05-20 07:30:19 -0300
committerFridrich Strba <fridrich@documentfoundation.org>2013-05-22 21:03:56 +0000
commitb7df3446c373a93dc5b77b495a54d873d83a91a7 (patch)
tree1de5e9567eaf1e7c5115e6b968ec4e49c45af3c1 /sc
parent8eb1fb9eff4d4eea9c0c1c2e8d3b380e227b5d50 (diff)
AppendAscii cleanup
Change-Id: I7398272de0bd340ebfb5f31b314d32fcff007eec Reviewed-on: https://gerrit.libreoffice.org/3974 Reviewed-by: Fridrich Strba <fridrich@documentfoundation.org> Tested-by: Fridrich Strba <fridrich@documentfoundation.org>
Diffstat (limited to 'sc')
-rw-r--r--sc/inc/editutil.hxx2
-rw-r--r--sc/source/core/tool/editutil.cxx8
-rw-r--r--sc/source/core/tool/interpr1.cxx38
-rw-r--r--sc/source/filter/dif/difimp.cxx9
-rw-r--r--sc/source/filter/excel/excrecds.cxx22
-rw-r--r--sc/source/filter/excel/xehelper.cxx46
-rw-r--r--sc/source/filter/inc/excrecds.hxx4
-rw-r--r--sc/source/ui/app/inputhdl.cxx14
8 files changed, 70 insertions, 73 deletions
diff --git a/sc/inc/editutil.hxx b/sc/inc/editutil.hxx
index c033415e7733..a4c7af899749 100644
--- a/sc/inc/editutil.hxx
+++ b/sc/inc/editutil.hxx
@@ -51,7 +51,7 @@ class ScEditUtil
static const char pCalcDelimiters[];
public:
- static String ModifyDelimiters( const String& rOld );
+ static OUString ModifyDelimiters( const OUString& rOld );
/// Retrieves string with paragraphs delimited by spaces
static String GetSpaceDelimitedString( const EditEngine& rEngine );
diff --git a/sc/source/core/tool/editutil.cxx b/sc/source/core/tool/editutil.cxx
index a004d8650477..bf0a7252ba21 100644
--- a/sc/source/core/tool/editutil.cxx
+++ b/sc/source/core/tool/editutil.cxx
@@ -59,12 +59,12 @@ const sal_Char ScEditUtil::pCalcDelimiters[] = "=()+-*/^&<>";
//------------------------------------------------------------------------
-String ScEditUtil::ModifyDelimiters( const String& rOld )
+OUString ScEditUtil::ModifyDelimiters( const OUString& rOld )
{
// underscore is used in function argument names
- String aRet = comphelper::string::remove(rOld, '_');
- aRet.AppendAscii( RTL_CONSTASCII_STRINGPARAM( pCalcDelimiters ) );
- aRet.Append(ScCompiler::GetNativeSymbol(ocSep)); // argument separator is localized.
+ OUString aRet = OUString( comphelper::string::remove(rOld, '_') ) +
+ OUString::createFromAscii( pCalcDelimiters ) +
+ ScCompiler::GetNativeSymbol(ocSep); // argument separator is localized.
return aRet;
}
diff --git a/sc/source/core/tool/interpr1.cxx b/sc/source/core/tool/interpr1.cxx
index 53db8dcf4707..6fc4816c3cae 100644
--- a/sc/source/core/tool/interpr1.cxx
+++ b/sc/source/core/tool/interpr1.cxx
@@ -2371,7 +2371,7 @@ static inline bool lcl_FormatHasOpenPar( const SvNumberformat* pFormat )
namespace {
-void getFormatString(SvNumberFormatter* pFormatter, sal_uLong nFormat, String& rFmtStr)
+void getFormatString(SvNumberFormatter* pFormatter, sal_uLong nFormat, OUString& rFmtStr)
{
bool bAppendPrec = true;
sal_uInt16 nPrec, nLeading;
@@ -2380,10 +2380,10 @@ void getFormatString(SvNumberFormatter* pFormatter, sal_uLong nFormat, String& r
switch( pFormatter->GetType( nFormat ) )
{
- case NUMBERFORMAT_NUMBER: rFmtStr = (bThousand ? ',' : 'F'); break;
- case NUMBERFORMAT_CURRENCY: rFmtStr = 'C'; break;
- case NUMBERFORMAT_SCIENTIFIC: rFmtStr = 'S'; break;
- case NUMBERFORMAT_PERCENT: rFmtStr = 'P'; break;
+ case NUMBERFORMAT_NUMBER: if(bThousand) rFmtStr = ","; else rFmtStr = "F"; break;
+ case NUMBERFORMAT_CURRENCY: rFmtStr = "C"; break;
+ case NUMBERFORMAT_SCIENTIFIC: rFmtStr = "S"; break;
+ case NUMBERFORMAT_PERCENT: rFmtStr = "P"; break;
default:
{
bAppendPrec = false;
@@ -2396,18 +2396,18 @@ void getFormatString(SvNumberFormatter* pFormatter, sal_uLong nFormat, String& r
case NF_DATE_SYS_DMMMYYYY:
case NF_DATE_DIN_DMMMYYYY:
case NF_DATE_SYS_DMMMMYYYY:
- case NF_DATE_DIN_DMMMMYYYY: rFmtStr.AssignAscii( RTL_CONSTASCII_STRINGPARAM( "D1" ) ); break;
- case NF_DATE_SYS_DDMMM: rFmtStr.AssignAscii( RTL_CONSTASCII_STRINGPARAM( "D2" ) ); break;
- case NF_DATE_SYS_MMYY: rFmtStr.AssignAscii( RTL_CONSTASCII_STRINGPARAM( "D3" ) ); break;
+ case NF_DATE_DIN_DMMMMYYYY: rFmtStr = "D1"; break;
+ case NF_DATE_SYS_DDMMM: rFmtStr = "D2"; break;
+ case NF_DATE_SYS_MMYY: rFmtStr = "D3"; break;
case NF_DATETIME_SYSTEM_SHORT_HHMM:
case NF_DATETIME_SYS_DDMMYYYY_HHMMSS:
- rFmtStr.AssignAscii( RTL_CONSTASCII_STRINGPARAM( "D4" ) ); break;
- case NF_DATE_DIN_MMDD: rFmtStr.AssignAscii( RTL_CONSTASCII_STRINGPARAM( "D5" ) ); break;
- case NF_TIME_HHMMSSAMPM: rFmtStr.AssignAscii( RTL_CONSTASCII_STRINGPARAM( "D6" ) ); break;
- case NF_TIME_HHMMAMPM: rFmtStr.AssignAscii( RTL_CONSTASCII_STRINGPARAM( "D7" ) ); break;
- case NF_TIME_HHMMSS: rFmtStr.AssignAscii( RTL_CONSTASCII_STRINGPARAM( "D8" ) ); break;
- case NF_TIME_HHMM: rFmtStr.AssignAscii( RTL_CONSTASCII_STRINGPARAM( "D9" ) ); break;
- default: rFmtStr = 'G';
+ rFmtStr = "D4"; break;
+ case NF_DATE_DIN_MMDD: rFmtStr = "D5"; break;
+ case NF_TIME_HHMMSSAMPM: rFmtStr = "D6"; break;
+ case NF_TIME_HHMMAMPM: rFmtStr = "D7"; break;
+ case NF_TIME_HHMMSS: rFmtStr = "D8"; break;
+ case NF_TIME_HHMM: rFmtStr = "D9"; break;
+ default: rFmtStr = "G";
}
}
}
@@ -2415,9 +2415,9 @@ void getFormatString(SvNumberFormatter* pFormatter, sal_uLong nFormat, String& r
rFmtStr += OUString::number(nPrec);
const SvNumberformat* pFormat = pFormatter->GetEntry( nFormat );
if( lcl_FormatHasNegColor( pFormat ) )
- rFmtStr += '-';
+ rFmtStr += "-";
if( lcl_FormatHasOpenPar( pFormat ) )
- rFmtStr.AppendAscii( RTL_CONSTASCII_STRINGPARAM( "()" ) );
+ rFmtStr += "()";
}
}
@@ -2584,7 +2584,7 @@ void ScInterpreter::ScCell()
// *** FORMATTING ***
else if( aInfoType.EqualsAscii( "FORMAT" ) )
{ // specific format code for standard formats
- String aFuncResult;
+ OUString aFuncResult;
sal_uLong nFormat = pDok->GetNumberFormat( aCellPos );
getFormatString(pFormatter, nFormat, aFuncResult);
PushString( aFuncResult );
@@ -2720,7 +2720,7 @@ void ScInterpreter::ScCellExternal()
}
else if ( aInfoType == "FORMAT" )
{
- String aFmtStr;
+ OUString aFmtStr;
sal_uLong nFmt = aFmt.mbIsSet ? aFmt.mnIndex : 0;
getFormatString(pFormatter, nFmt, aFmtStr);
PushString(aFmtStr);
diff --git a/sc/source/filter/dif/difimp.cxx b/sc/source/filter/dif/difimp.cxx
index 734253a6de93..816b2216ba15 100644
--- a/sc/source/filter/dif/difimp.cxx
+++ b/sc/source/filter/dif/difimp.cxx
@@ -533,12 +533,9 @@ DATASET DifParser::GetNextDataset( void )
ReadNextLine( aTmpLine );
if ( eRet == D_SYNT_ERROR )
{ // for broken records write "#ERR: data" to cell
- String aTmp( RTL_CONSTASCII_USTRINGPARAM( "#ERR: " ));
- aTmp += pAktBuffer;
- aTmp.AppendAscii( " (" );
- OSL_ENSURE( aTmpLine.getLength() <= STRING_MAXLEN - aTmp.Len() - 1, "GetNextDataset(): line doesn't fit into data");
- aTmp += aTmpLine;
- aTmp += sal_Unicode(')');
+ OUString aTmp = "#ERR: " + OUString( pAktBuffer ) + " (";
+ OSL_ENSURE( aTmpLine.getLength() <= STRING_MAXLEN - aTmp.getLength() - 1, "GetNextDataset(): line doesn't fit into data");
+ aTmp += aTmpLine + ")";
aData = aTmp;
eRet = D_STRING;
}
diff --git a/sc/source/filter/excel/excrecds.cxx b/sc/source/filter/excel/excrecds.cxx
index fc8be48a3e57..3469b36efb7f 100644
--- a/sc/source/filter/excel/excrecds.cxx
+++ b/sc/source/filter/excel/excrecds.cxx
@@ -552,14 +552,14 @@ sal_Size ExcFilterCondition::GetTextBytes() const
return pText ? (1 + pText->GetBufferSize()) : 0;
}
-void ExcFilterCondition::SetCondition( sal_uInt8 nTp, sal_uInt8 nOp, double fV, String* pT )
+void ExcFilterCondition::SetCondition( sal_uInt8 nTp, sal_uInt8 nOp, double fV, OUString* pT )
{
nType = nTp;
nOper = nOp;
fVal = fV;
delete pText;
- pText = pT ? new XclExpString( *pT, EXC_STR_8BITLENGTH ) : NULL;
+ (pT) ? pText = new XclExpString( *pT, EXC_STR_8BITLENGTH ) : pText = NULL;
}
void ExcFilterCondition::Save( XclExpStream& rStrm )
@@ -641,7 +641,7 @@ XclExpAutofilter::XclExpAutofilter( const XclExpRoot& rRoot, sal_uInt16 nC ) :
}
bool XclExpAutofilter::AddCondition( ScQueryConnect eConn, sal_uInt8 nType, sal_uInt8 nOp,
- double fVal, String* pText, bool bSimple )
+ double fVal, OUString* pText, bool bSimple )
{
if( !aCond[ 1 ].IsEmpty() )
return false;
@@ -675,28 +675,27 @@ bool XclExpAutofilter::AddEntry( const ScQueryEntry& rEntry )
return AddMultiValueEntry(rEntry);
bool bConflict = false;
- String sText;
+ OUString sText;
const ScQueryEntry::Item& rItem = rItems[0];
const OUString& rQueryStr = rItem.maString;
if (!rQueryStr.isEmpty())
{
- sText.Assign(rQueryStr);
+ sText = rQueryStr;
switch( rEntry.eOp )
{
case SC_CONTAINS:
case SC_DOES_NOT_CONTAIN:
{
- sText.InsertAscii( "*" , 0 );
- sText.AppendAscii( "*" );
+ sText = "*" + sText + "*";
}
break;
case SC_BEGINS_WITH:
case SC_DOES_NOT_BEGIN_WITH:
- sText.AppendAscii( "*" );
+ sText += "*";
break;
case SC_ENDS_WITH:
case SC_DOES_NOT_END_WITH:
- sText.InsertAscii( "*" , 0 );
+ sText = "*" + sText;
break;
default:
{
@@ -705,7 +704,7 @@ bool XclExpAutofilter::AddEntry( const ScQueryEntry& rEntry )
}
}
- bool bLen = sText.Len() > 0;
+ bool bLen = sText.getLength() > 0;
// empty/nonempty fields
if (rEntry.IsQueryByEmpty())
@@ -718,7 +717,8 @@ bool XclExpAutofilter::AddEntry( const ScQueryEntry& rEntry )
double fVal = 0.0;
sal_uInt32 nIndex = 0;
bool bIsNum = bLen ? GetFormatter().IsNumberFormat( sText, nIndex, fVal ) : true;
- String* pText = bIsNum ? NULL : &sText;
+ OUString* pText;
+ (bIsNum) ? pText = NULL : pText = &sText;
// top10 flags
sal_uInt16 nNewFlags = 0x0000;
diff --git a/sc/source/filter/excel/xehelper.cxx b/sc/source/filter/excel/xehelper.cxx
index dc05fdac8635..a13b7fe3c51b 100644
--- a/sc/source/filter/excel/xehelper.cxx
+++ b/sc/source/filter/excel/xehelper.cxx
@@ -713,7 +713,7 @@ void XclExpHFConverter::AppendPortion( const EditTextObject* pTextObj, sal_Unico
for( sal_Int32 nPara = 0; nPara < nParaCount; ++nPara )
{
ESelection aSel( nPara, 0 );
- String aParaText;
+ OUString aParaText;
sal_Int32 nParaHeight = 0;
std::vector<sal_uInt16> aPosList;
mrEE.GetPortions( nPara, aPosList );
@@ -741,7 +741,7 @@ void XclExpHFConverter::AppendPortion( const EditTextObject* pTextObj, sal_Unico
(aFontData.mbItalic != aNewData.mbItalic);
if( bNewFont || (bNewStyle && pFontList) )
{
- aParaText.AppendAscii( "&\"" ).Append( aNewData.maName );
+ aParaText = "&\"" + OUString(aNewData.maName);
if( pFontList )
{
FontInfo aFontInfo( pFontList->Get(
@@ -750,9 +750,9 @@ void XclExpHFConverter::AppendPortion( const EditTextObject* pTextObj, sal_Unico
aNewData.mbItalic ? ITALIC_NORMAL : ITALIC_NONE ) );
aNewData.maStyle = pFontList->GetStyleName( aFontInfo );
if( aNewData.maStyle.Len() )
- aParaText.Append( ',' ).Append( aNewData.maStyle );
+ aParaText += "," + OUString(aNewData.maStyle);
}
- aParaText.Append( '"' );
+ aParaText += "\"";
}
// height
@@ -762,7 +762,7 @@ void XclExpHFConverter::AppendPortion( const EditTextObject* pTextObj, sal_Unico
(aNewData.mnHeight += 10) /= 20;
bool bFontHtChanged = (aFontData.mnHeight != aNewData.mnHeight);
if( bFontHtChanged )
- aParaText.Append( '&' ).Append( OUString::number( aNewData.mnHeight ) );
+ aParaText += "&" + OUString::number( aNewData.mnHeight );
// update maximum paragraph height, convert to twips
nParaHeight = ::std::max< sal_Int32 >( nParaHeight, aNewData.mnHeight * 20 );
@@ -779,13 +779,13 @@ void XclExpHFConverter::AppendPortion( const EditTextObject* pTextObj, sal_Unico
{
sal_uInt8 nTmpUnderl = (aNewData.mnUnderline == EXC_FONTUNDERL_NONE) ?
aFontData.mnUnderline : aNewData.mnUnderline;
- aParaText.AppendAscii( (nTmpUnderl == EXC_FONTUNDERL_SINGLE) ? "&U" : "&E" );
+ (nTmpUnderl == EXC_FONTUNDERL_SINGLE)? aParaText += "&U" : aParaText += "&E";
}
// strikeout
aNewData.mbStrikeout = (aFont.GetStrikeout() != STRIKEOUT_NONE);
if( aFontData.mbStrikeout != aNewData.mbStrikeout )
- aParaText.AppendAscii( "&S" );
+ aParaText += "&S";
// super/sub script
const SvxEscapementItem& rEscapeItem = GETITEM( aEditSet, SvxEscapementItem, EE_CHAR_ESCAPEMENT );
@@ -795,9 +795,9 @@ void XclExpHFConverter::AppendPortion( const EditTextObject* pTextObj, sal_Unico
switch(aNewData.mnEscapem)
{
// close the previous super/sub script.
- case EXC_FONTESC_NONE: aParaText.AppendAscii( (aFontData.mnEscapem == EXC_FONTESC_SUPER) ? "&X" : "&Y" ); break;
- case EXC_FONTESC_SUPER: aParaText.AppendAscii( "&X" ); break;
- case EXC_FONTESC_SUB: aParaText.AppendAscii( "&Y" ); break;
+ case EXC_FONTESC_NONE: (aFontData.mnEscapem == EXC_FONTESC_SUPER) ? aParaText += "&X" : aParaText += "&Y"; break;
+ case EXC_FONTESC_SUPER: aParaText += "&X"; break;
+ case EXC_FONTESC_SUB: aParaText += "&Y"; break;
default: break;
}
}
@@ -813,30 +813,30 @@ void XclExpHFConverter::AppendPortion( const EditTextObject* pTextObj, sal_Unico
if( const SvxFieldData* pFieldData = static_cast< const SvxFieldItem* >( pItem )->GetField() )
{
if( pFieldData->ISA( SvxPageField ) )
- aParaText.AppendAscii( "&P" );
+ aParaText += "&P";
else if( pFieldData->ISA( SvxPagesField ) )
- aParaText.AppendAscii( "&N" );
+ aParaText += "&N";
else if( pFieldData->ISA( SvxDateField ) )
- aParaText.AppendAscii( "&D" );
+ aParaText += "&D";
else if( pFieldData->ISA( SvxTimeField ) || pFieldData->ISA( SvxExtTimeField ) )
- aParaText.AppendAscii( "&T" );
+ aParaText += "&T";
else if( pFieldData->ISA( SvxTableField ) )
- aParaText.AppendAscii( "&A" );
+ aParaText += "&A";
else if( pFieldData->ISA( SvxFileField ) ) // title -> file name
- aParaText.AppendAscii( "&F" );
+ aParaText += "&F";
else if( const SvxExtFileField* pFileField = PTR_CAST( SvxExtFileField, pFieldData ) )
{
switch( pFileField->GetFormat() )
{
case SVXFILEFORMAT_NAME_EXT:
case SVXFILEFORMAT_NAME:
- aParaText.AppendAscii( "&F" );
+ aParaText += "&F";
break;
case SVXFILEFORMAT_PATH:
- aParaText.AppendAscii( "&Z" );
+ aParaText += "&Z";
break;
case SVXFILEFORMAT_FULLPATH:
- aParaText.AppendAscii( "&Z&F" );
+ aParaText += "&Z&F";
break;
default:
OSL_FAIL( "XclExpHFConverter::AppendPortion - unknown file field" );
@@ -849,14 +849,14 @@ void XclExpHFConverter::AppendPortion( const EditTextObject* pTextObj, sal_Unico
String aPortionText( mrEE.GetText( aSel ) );
aPortionText.SearchAndReplaceAll( OUString('&'), OUString("&&") );
// #i17440# space between font height and numbers in text
- if( bFontHtChanged && aParaText.Len() && aPortionText.Len() )
+ if( bFontHtChanged && aParaText.getLength() && aPortionText.Len() )
{
- sal_Unicode cLast = aParaText.GetChar( aParaText.Len() - 1 );
+ sal_Unicode cLast = aParaText[ aParaText.getLength() - 1 ];
sal_Unicode cFirst = aPortionText.GetChar( 0 );
if( ('0' <= cLast) && (cLast <= '9') && ('0' <= cFirst) && (cFirst <= '9') )
- aParaText.Append( ' ' );
+ aParaText += " ";
}
- aParaText.Append( aPortionText );
+ aParaText += aPortionText;
}
}
diff --git a/sc/source/filter/inc/excrecds.hxx b/sc/source/filter/inc/excrecds.hxx
index fe70907bd330..426f0cfcd7b0 100644
--- a/sc/source/filter/inc/excrecds.hxx
+++ b/sc/source/filter/inc/excrecds.hxx
@@ -366,7 +366,7 @@ public:
inline bool HasEqual() const { return (nOper == EXC_AFOPER_EQUAL); }
sal_uLong GetTextBytes() const;
- void SetCondition( sal_uInt8 nTp, sal_uInt8 nOp, double fV, String* pT );
+ void SetCondition( sal_uInt8 nTp, sal_uInt8 nOp, double fV, OUString* pT );
void Save( XclExpStream& rStrm );
void SaveXml( XclExpXmlStream& rStrm );
@@ -386,7 +386,7 @@ private:
std::vector<OUString> maMultiValues;
bool AddCondition( ScQueryConnect eConn, sal_uInt8 nType,
- sal_uInt8 nOp, double fVal, String* pText,
+ sal_uInt8 nOp, double fVal, OUString* pText,
bool bSimple = false );
virtual void WriteBody( XclExpStream& rStrm );
diff --git a/sc/source/ui/app/inputhdl.cxx b/sc/source/ui/app/inputhdl.cxx
index 0f6ce7228342..aa761b7054eb 100644
--- a/sc/source/ui/app/inputhdl.cxx
+++ b/sc/source/ui/app/inputhdl.cxx
@@ -201,15 +201,15 @@ void ScInputHandler::InitRangeFinder( const String& rFormula )
if ( !pActiveViewSh || !SC_MOD()->GetInputOptions().GetRangeFinder() )
return;
- String aDelimiters = ScEditUtil::ModifyDelimiters(
+ OUString aDelimiters = ScEditUtil::ModifyDelimiters(
OUString::createFromAscii( pMinDelimiters ) );
- xub_StrLen nColon = aDelimiters.Search(':');
+ sal_Int32 nColon = aDelimiters.indexOf( ':' );
if ( nColon != STRING_NOTFOUND )
- aDelimiters.Erase( nColon, 1 ); // Delimiter ohne Doppelpunkt
- xub_StrLen nDot = aDelimiters.Search(cSheetSep);
+ aDelimiters = aDelimiters.replaceAt( nColon, 1, ""); // Delimiter ohne Doppelpunkt
+ sal_Int32 nDot = aDelimiters.indexOf(cSheetSep);
if ( nDot != STRING_NOTFOUND )
- aDelimiters.Erase( nDot, 1 ); // Delimiter ohne Punkt
+ aDelimiters = aDelimiters.replaceAt( nDot, 1 , ""); // Delimiter ohne Punkt
const sal_Unicode* pChar = rFormula.GetBuffer();
xub_StrLen nLen = rFormula.Len();
@@ -220,7 +220,7 @@ void ScInputHandler::InitRangeFinder( const String& rFormula )
while ( nPos < nLen && nCount < RANGEFIND_MAX )
{
// Trenner ueberlesen
- while ( nPos<nLen && ScGlobal::UnicodeStrChr( aDelimiters.GetBuffer(), pChar[nPos] ) )
+ while ( nPos<nLen && ScGlobal::UnicodeStrChr( aDelimiters.getStr(), pChar[nPos] ) )
{
if ( pChar[nPos] == '"' ) // String
{
@@ -234,7 +234,7 @@ void ScInputHandler::InitRangeFinder( const String& rFormula )
// Text zwischen Trennern
nStart = nPos;
handle_r1c1:
- while ( nPos<nLen && !ScGlobal::UnicodeStrChr( aDelimiters.GetBuffer(), pChar[nPos] ) )
+ while ( nPos<nLen && !ScGlobal::UnicodeStrChr( aDelimiters.getStr(), pChar[nPos] ) )
++nPos;
// for R1C1 '-' in R[-]... or C[-]... are not delimiters