summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNoel Grandin <noel@peralex.com>2013-09-13 15:00:34 +0200
committerNoel Grandin <noel@peralex.com>2013-09-17 09:03:54 +0200
commit85eb736beea67cc5bf8cfc036ef08b8d6d85081d (patch)
tree548995bb82ad6ae97659c1b4b9b16c0be0908401
parent7625372d553f7aebb84bdd41674b59497e2c3ccc (diff)
convert the resust of include/formula/FormulaCompiler.hxx to OUString
Change-Id: I7cbc371e90869c481a23450722a1a025b110b235
-rw-r--r--formula/source/core/api/FormulaCompiler.cxx38
-rw-r--r--include/formula/FormulaCompiler.hxx16
-rw-r--r--sc/inc/compiler.hxx4
-rw-r--r--sc/source/core/tool/compiler.cxx10
-rw-r--r--sc/source/core/tool/interpr1.cxx2
-rw-r--r--sc/source/core/tool/rangenam.cxx8
-rw-r--r--sc/source/ui/vba/vbarange.cxx4
7 files changed, 38 insertions, 44 deletions
diff --git a/formula/source/core/api/FormulaCompiler.cxx b/formula/source/core/api/FormulaCompiler.cxx
index 23a7320e64eb..7fed5b3f8957 100644
--- a/formula/source/core/api/FormulaCompiler.cxx
+++ b/formula/source/core/api/FormulaCompiler.cxx
@@ -587,9 +587,9 @@ FormulaCompiler::OpCodeMapPtr FormulaCompiler::GetOpCodeMap( const sal_Int32 nLa
return xMap;
}
-String FormulaCompiler::FindAddInFunction( const String& /*rUpperName*/, bool /*bLocalFirst*/ ) const
+OUString FormulaCompiler::FindAddInFunction( const OUString& /*rUpperName*/, bool /*bLocalFirst*/ ) const
{
- return String();
+ return OUString();
}
FormulaCompiler::OpCodeMapPtr FormulaCompiler::CreateOpCodeMap(
@@ -769,19 +769,13 @@ bool FormulaCompiler::IsOpCodeVolatile( OpCode eOp )
}
// Remove quotes, escaped quotes are unescaped.
-bool FormulaCompiler::DeQuote( String& rStr )
+bool FormulaCompiler::DeQuote( OUString& rStr )
{
- xub_StrLen nLen = rStr.Len();
- if ( nLen > 1 && rStr.GetChar(0) == '\'' && rStr.GetChar( nLen-1 ) == '\'' )
+ sal_Int32 nLen = rStr.getLength();
+ if ( nLen > 1 && rStr[0] == '\'' && rStr[ nLen-1 ] == '\'' )
{
- rStr.Erase( nLen-1, 1 );
- rStr.Erase( 0, 1 );
- xub_StrLen nPos = 0;
- while ( (nPos = rStr.SearchAscii( "\\\'", nPos)) != STRING_NOTFOUND )
- {
- rStr.Erase( nPos, 1 );
- ++nPos;
- }
+ rStr = rStr.copy( 1, nLen-2 );
+ rStr = rStr.replaceAll( "\\\'", "\'" );
return true;
}
return false;
@@ -893,7 +887,7 @@ void FormulaCompiler::OpCodeMap::copyFrom( const OpCodeMap& r, bool bOverrideKno
}
-sal_uInt16 FormulaCompiler::GetErrorConstant( const String& rName ) const
+sal_uInt16 FormulaCompiler::GetErrorConstant( const OUString& rName ) const
{
sal_uInt16 nError = 0;
OpCodeHashMap::const_iterator iLook( mxSymbols->getHashMap()->find( rName));
@@ -1665,7 +1659,7 @@ void FormulaCompiler::PopTokenArray()
}
}
-void FormulaCompiler::CreateStringFromTokenArray( String& rFormula )
+void FormulaCompiler::CreateStringFromTokenArray( OUString& rFormula )
{
OUStringBuffer aBuffer( pArr->GetLen() * 5 );
CreateStringFromTokenArray( aBuffer );
@@ -1809,7 +1803,7 @@ FormulaToken* FormulaCompiler::CreateStringFromToken( OUStringBuffer& rBuffer, F
case svExternal:
{
// mapped or translated name of AddIns
- String aAddIn( t->GetExternal() );
+ OUString aAddIn( t->GetExternal() );
bool bMapped = mxSymbols->isPODF(); // ODF 1.1 directly uses programmatical name
if (!bMapped && mxSymbols->hasExternals())
{
@@ -1875,16 +1869,15 @@ void FormulaCompiler::AppendBoolean( OUStringBuffer& rBuffer, bool bVal )
rBuffer.append( mxSymbols->getSymbol( static_cast<OpCode>(bVal ? ocTrue : ocFalse)) );
}
-void FormulaCompiler::AppendString( OUStringBuffer& rBuffer, const String & rStr )
+void FormulaCompiler::AppendString( OUStringBuffer& rBuffer, const OUString & rStr )
{
rBuffer.append( sal_Unicode('"'));
- if ( lcl_UnicodeStrChr( rStr.GetBuffer(), '"' ) == NULL )
+ if ( lcl_UnicodeStrChr( rStr.getStr(), '"' ) == NULL )
rBuffer.append( rStr );
else
{
- String aStr( rStr );
- aStr.SearchAndReplaceAll( OUString('"'), OUString("\"\"") );
- rBuffer.append( aStr);
+ OUString aStr = rStr.replaceAll( "\"", "\"\"" );
+ rBuffer.append(aStr);
}
rBuffer.append( sal_Unicode('"'));
}
@@ -2071,9 +2064,10 @@ void FormulaCompiler::CreateStringFromExternal( OUStringBuffer& /*rBuffer*/, For
{
}
-void FormulaCompiler::LocalizeString( String& /*rName*/ )
+void FormulaCompiler::LocalizeString( OUString& /*rName*/ )
{
}
+
void FormulaCompiler::PushTokenArray( FormulaTokenArray* pa, bool bTemp )
{
if ( bAutoCorrect && !pStack )
diff --git a/include/formula/FormulaCompiler.hxx b/include/formula/FormulaCompiler.hxx
index cfa4f1e42038..0d0373eacb6e 100644
--- a/include/formula/FormulaCompiler.hxx
+++ b/include/formula/FormulaCompiler.hxx
@@ -230,14 +230,14 @@ public:
*/
OpCode GetEnglishOpCode( const OUString& rName ) const;
- sal_uInt16 GetErrorConstant( const String& rName ) const;
+ sal_uInt16 GetErrorConstant( const OUString& rName ) const;
void SetCompileForFAP( bool bVal )
{ bCompileForFAP = bVal; bIgnoreErrors = bVal; }
static bool IsOpCodeVolatile( OpCode eOp );
- static bool DeQuote( String& rStr );
+ static bool DeQuote( OUString& rStr );
static const OUString& GetNativeSymbol( OpCode eOp );
@@ -247,18 +247,18 @@ public:
short GetNumFormatType() const { return nNumFmt; }
bool CompileTokenArray();
- void CreateStringFromTokenArray( String& rFormula );
+ void CreateStringFromTokenArray( OUString& rFormula );
void CreateStringFromTokenArray( OUStringBuffer& rBuffer );
- FormulaToken* CreateStringFromToken( OUString& rFormula, FormulaToken* pToken,
- bool bAllowArrAdvance = false );
FormulaToken* CreateStringFromToken( String& rFormula, FormulaToken* pToken,
bool bAllowArrAdvance = false );
+ FormulaToken* CreateStringFromToken( OUString& rFormula, FormulaToken* pToken,
+ bool bAllowArrAdvance = false );
FormulaToken* CreateStringFromToken( OUStringBuffer& rBuffer, FormulaToken* pToken,
bool bAllowArrAdvance = false );
void AppendBoolean( OUStringBuffer& rBuffer, bool bVal );
void AppendDouble( OUStringBuffer& rBuffer, double fVal );
- void AppendString( OUStringBuffer& rBuffer, const String & rStr );
+ void AppendString( OUStringBuffer& rBuffer, const OUString & rStr );
/** Set symbol map corresponding to one of predefined formula::FormulaGrammar::Grammar,
including an address reference convention. */
@@ -268,7 +268,7 @@ public:
static void ResetNativeSymbols();
static void SetNativeSymbols( const OpCodeMapPtr& xMap );
protected:
- virtual String FindAddInFunction( const String& rUpperName, bool bLocalFirst ) const;
+ virtual OUString FindAddInFunction( const OUString& rUpperName, bool bLocalFirst ) const;
virtual void fillFromAddInCollectionUpperName( NonConstOpCodeMapPtr xMap ) const;
virtual void fillFromAddInMap( NonConstOpCodeMapPtr xMap, FormulaGrammar::Grammar _eGrammar ) const;
virtual void fillFromAddInCollectionEnglishName( NonConstOpCodeMapPtr xMap ) const;
@@ -286,7 +286,7 @@ protected:
virtual void CreateStringFromDoubleRef(OUStringBuffer& rBuffer,FormulaToken* pTokenP);
virtual void CreateStringFromMatrix(OUStringBuffer& rBuffer,FormulaToken* pTokenP);
virtual void CreateStringFromIndex(OUStringBuffer& rBuffer,FormulaToken* pTokenP);
- virtual void LocalizeString( String& rName ); // modify rName - input: exact name
+ virtual void LocalizeString(OUString& rName ); // modify rName - input: exact name
void AppendErrorConstant( OUStringBuffer& rBuffer, sal_uInt16 nError );
diff --git a/sc/inc/compiler.hxx b/sc/inc/compiler.hxx
index b0fc18c1bf1d..08f848d4773f 100644
--- a/sc/inc/compiler.hxx
+++ b/sc/inc/compiler.hxx
@@ -446,7 +446,7 @@ public:
private:
// FormulaCompiler
- virtual String FindAddInFunction( const String& rUpperName, bool bLocalFirst ) const;
+ virtual OUString FindAddInFunction( const OUString& rUpperName, bool bLocalFirst ) const;
virtual void fillFromAddInCollectionUpperName( NonConstOpCodeMapPtr xMap ) const;
virtual void fillFromAddInCollectionEnglishName( NonConstOpCodeMapPtr xMap ) const;
virtual void fillFromAddInMap( NonConstOpCodeMapPtr xMap, formula::FormulaGrammar::Grammar _eGrammar ) const;
@@ -463,7 +463,7 @@ private:
virtual void CreateStringFromDoubleRef(OUStringBuffer& rBuffer,formula::FormulaToken* _pTokenP);
virtual void CreateStringFromMatrix( OUStringBuffer& rBuffer, formula::FormulaToken* _pTokenP);
virtual void CreateStringFromIndex(OUStringBuffer& rBuffer,formula::FormulaToken* _pTokenP);
- virtual void LocalizeString( String& rName ); // modify rName - input: exact name
+ virtual void LocalizeString( OUString& rName ); // modify rName - input: exact name
/// Access the CharTable flags
inline sal_uLong GetCharTableFlags( sal_Unicode c, sal_Unicode cLast )
diff --git a/sc/source/core/tool/compiler.cxx b/sc/source/core/tool/compiler.cxx
index 82e9a131084e..35bfbd788dc1 100644
--- a/sc/source/core/tool/compiler.cxx
+++ b/sc/source/core/tool/compiler.cxx
@@ -274,7 +274,7 @@ void ScCompiler::SetGrammarAndRefConvention(
SetRefConvention( eConv );
}
-String ScCompiler::FindAddInFunction( const String& rUpperName, bool bLocalFirst ) const
+OUString ScCompiler::FindAddInFunction( const OUString& rUpperName, bool bLocalFirst ) const
{
return ScGlobal::GetAddInCollection()->FindFunction(rUpperName, bLocalFirst); // bLocalFirst=false for english
}
@@ -2953,7 +2953,7 @@ bool ScCompiler::IsColRowName( const String& rName )
bool bInList = false;
bool bFound = false;
ScSingleRefData aRef;
- String aName( rName );
+ OUString aName( rName );
DeQuote( aName );
SCTAB nThisTab = aPos.Tab();
for ( short jThisTab = 1; jThisTab >= 0 && !bInList; jThisTab-- )
@@ -4235,11 +4235,9 @@ void ScCompiler::CreateStringFromIndex(OUStringBuffer& rBuffer,FormulaToken* _pT
rBuffer.append(ScGlobal::GetRscString(STR_NO_NAME_REF));
}
-void ScCompiler::LocalizeString( String& rName )
+void ScCompiler::LocalizeString( OUString& rName )
{
- OUString aName(rName);
- ScGlobal::GetAddInCollection()->LocalizeString( aName );
- rName = aName;
+ ScGlobal::GetAddInCollection()->LocalizeString( rName );
}
// Put quotes around string if non-alphanumeric characters are contained,
diff --git a/sc/source/core/tool/interpr1.cxx b/sc/source/core/tool/interpr1.cxx
index 85c0f917fc3e..b54e1a383a85 100644
--- a/sc/source/core/tool/interpr1.cxx
+++ b/sc/source/core/tool/interpr1.cxx
@@ -2616,7 +2616,7 @@ void ScInterpreter::ScCellExternal()
aArray.AddExternalSingleReference(nFileId, aTabName, aRef);
ScCompiler aComp(pDok, aPos, aArray);
aComp.SetGrammar(formula::FormulaGrammar::GRAM_ODFF_A1);
- String aStr;
+ OUString aStr;
aComp.CreateStringFromTokenArray(aStr);
PushString(aStr);
}
diff --git a/sc/source/core/tool/rangenam.cxx b/sc/source/core/tool/rangenam.cxx
index f520c16b463c..f4668bd2c404 100644
--- a/sc/source/core/tool/rangenam.cxx
+++ b/sc/source/core/tool/rangenam.cxx
@@ -186,7 +186,7 @@ void ScRangeData::CompileUnresolvedXML()
if (pCode->GetCodeError() == errNoName)
{
// Reconstruct the symbol/formula and then recompile.
- String aSymbol;
+ OUString aSymbol;
ScCompiler aComp( pDoc, aPos, *pCode);
aComp.SetGrammar( eTempGrammar);
aComp.CreateStringFromTokenArray( aSymbol);
@@ -238,7 +238,9 @@ void ScRangeData::GetSymbol( String& rSymbol, const FormulaGrammar::Grammar eGra
{
ScCompiler aComp(pDoc, aPos, *pCode);
aComp.SetGrammar(eGrammar);
- aComp.CreateStringFromTokenArray( rSymbol );
+ OUString aTmpSymbol (rSymbol);
+ aComp.CreateStringFromTokenArray( aTmpSymbol );
+ rSymbol = aTmpSymbol;
}
void ScRangeData::GetSymbol( OUString& rSymbol, const FormulaGrammar::Grammar eGrammar ) const
@@ -250,7 +252,7 @@ void ScRangeData::GetSymbol( OUString& rSymbol, const FormulaGrammar::Grammar eG
void ScRangeData::GetSymbol( OUString& rSymbol, const ScAddress& rPos, const FormulaGrammar::Grammar eGrammar ) const
{
- String aStr;
+ OUString aStr;
ScCompiler aComp(pDoc, rPos, *pCode);
aComp.SetGrammar(eGrammar);
aComp.CreateStringFromTokenArray( aStr );
diff --git a/sc/source/ui/vba/vbarange.cxx b/sc/source/ui/vba/vbarange.cxx
index bb4a7a8f04bc..817e3299dc4f 100644
--- a/sc/source/ui/vba/vbarange.cxx
+++ b/sc/source/ui/vba/vbarange.cxx
@@ -904,7 +904,7 @@ protected:
aCompiler.CompileString( sFormula );
// set desired convention to that of the document
aCompiler.SetGrammar( formula::FormulaGrammar::GRAM_PODF_A1 );
- String sConverted;
+ OUString sConverted;
aCompiler.CreateStringFromTokenArray(sConverted);
sFormula = EQUALS + sConverted;
}
@@ -947,7 +947,7 @@ public:
aCompiler.CompileString( sVal );
// set desired convention
aCompiler.SetGrammar( m_eGrammar );
- String sConverted;
+ OUString sConverted;
aCompiler.CreateStringFromTokenArray(sConverted);
sVal = EQUALS + sConverted;
aValue <<= sVal;