Kaydet (Commit) c88ce903 authored tarafından Noel Grandin's avatar Noel Grandin

convert aCorrectedFormula in formula::FormulaCompiler to OUString

Change-Id: I048ec33effc33e94943f5110d6a9a0937a1dfdfe
üst 8f23a3b0
...@@ -1382,9 +1382,9 @@ void FormulaCompiler::Factor() ...@@ -1382,9 +1382,9 @@ void FormulaCompiler::Factor()
{ {
if ( eOp == ocStop ) if ( eOp == ocStop )
{ // trailing operator w/o operand { // trailing operator w/o operand
xub_StrLen nLen = aCorrectedFormula.Len(); sal_Int32 nLen = aCorrectedFormula.getLength();
if ( nLen ) if ( nLen )
aCorrectedFormula.Erase( nLen - 1 ); aCorrectedFormula = aCorrectedFormula.copy( 0, nLen - 1 );
aCorrectedSymbol = ""; aCorrectedSymbol = "";
bCorrected = true; bCorrected = true;
} }
...@@ -1592,7 +1592,7 @@ bool FormulaCompiler::CompileTokenArray() ...@@ -1592,7 +1592,7 @@ bool FormulaCompiler::CompileTokenArray()
{ {
if ( bAutoCorrect ) if ( bAutoCorrect )
{ {
aCorrectedFormula.Erase(); aCorrectedFormula = "";
aCorrectedSymbol = ""; aCorrectedSymbol = "";
} }
pArr->nRefs = 0; // count from start pArr->nRefs = 0; // count from start
...@@ -1604,7 +1604,7 @@ bool FormulaCompiler::CompileTokenArray() ...@@ -1604,7 +1604,7 @@ bool FormulaCompiler::CompileTokenArray()
if ( bWasForced ) if ( bWasForced )
{ {
if ( bAutoCorrect ) if ( bAutoCorrect )
aCorrectedFormula = '='; aCorrectedFormula = "=";
} }
pArr->ClearRecalcMode(); pArr->ClearRecalcMode();
pArr->Reset(); pArr->Reset();
...@@ -1947,18 +1947,18 @@ OpCode FormulaCompiler::NextToken() ...@@ -1947,18 +1947,18 @@ OpCode FormulaCompiler::NextToken()
} }
else else
{ {
xub_StrLen nPos = aCorrectedFormula.Len(); sal_Int32 nPos = aCorrectedFormula.getLength();
if ( nPos ) if ( nPos )
{ {
nPos--; nPos--;
sal_Unicode c = aCorrectedFormula.GetChar( nPos ); sal_Unicode c = aCorrectedFormula[ nPos ];
switch ( eOp ) switch ( eOp )
{ // swap operators { // swap operators
case ocGreater: case ocGreater:
if ( c == mxSymbols->getSymbolChar( ocEqual) ) if ( c == mxSymbols->getSymbolChar( ocEqual) )
{ // >= instead of => { // >= instead of =>
aCorrectedFormula.SetChar( nPos, aCorrectedFormula = aCorrectedFormula.replaceAt( nPos, 1,
mxSymbols->getSymbolChar( ocGreater) ); OUString( mxSymbols->getSymbolChar(ocGreater) ) );
aCorrectedSymbol = OUString(c); aCorrectedSymbol = OUString(c);
bCorrected = true; bCorrected = true;
} }
...@@ -1966,15 +1966,15 @@ OpCode FormulaCompiler::NextToken() ...@@ -1966,15 +1966,15 @@ OpCode FormulaCompiler::NextToken()
case ocLess: case ocLess:
if ( c == mxSymbols->getSymbolChar( ocEqual) ) if ( c == mxSymbols->getSymbolChar( ocEqual) )
{ // <= instead of =< { // <= instead of =<
aCorrectedFormula.SetChar( nPos, aCorrectedFormula = aCorrectedFormula.replaceAt( nPos, 1,
mxSymbols->getSymbolChar( ocLess) ); OUString( mxSymbols->getSymbolChar(ocLess) ) );
aCorrectedSymbol = OUString(c); aCorrectedSymbol = OUString(c);
bCorrected = true; bCorrected = true;
} }
else if ( c == mxSymbols->getSymbolChar( ocGreater) ) else if ( c == mxSymbols->getSymbolChar( ocGreater) )
{ // <> instead of >< { // <> instead of ><
aCorrectedFormula.SetChar( nPos, aCorrectedFormula = aCorrectedFormula.replaceAt( nPos, 1,
mxSymbols->getSymbolChar( ocLess) ); OUString( mxSymbols->getSymbolChar(ocLess) ) );
aCorrectedSymbol = OUString(c); aCorrectedSymbol = OUString(c);
bCorrected = true; bCorrected = true;
} }
...@@ -1982,8 +1982,8 @@ OpCode FormulaCompiler::NextToken() ...@@ -1982,8 +1982,8 @@ OpCode FormulaCompiler::NextToken()
case ocMul: case ocMul:
if ( c == mxSymbols->getSymbolChar( ocSub) ) if ( c == mxSymbols->getSymbolChar( ocSub) )
{ // *- instead of -* { // *- instead of -*
aCorrectedFormula.SetChar( nPos, aCorrectedFormula = aCorrectedFormula.replaceAt( nPos, 1,
mxSymbols->getSymbolChar( ocMul) ); OUString( mxSymbols->getSymbolChar(ocMul) ) );
aCorrectedSymbol = OUString(c); aCorrectedSymbol = OUString(c);
bCorrected = true; bCorrected = true;
} }
...@@ -1991,8 +1991,8 @@ OpCode FormulaCompiler::NextToken() ...@@ -1991,8 +1991,8 @@ OpCode FormulaCompiler::NextToken()
case ocDiv: case ocDiv:
if ( c == mxSymbols->getSymbolChar( ocSub) ) if ( c == mxSymbols->getSymbolChar( ocSub) )
{ // /- instead of -/ { // /- instead of -/
aCorrectedFormula.SetChar( nPos, aCorrectedFormula = aCorrectedFormula.replaceAt( nPos, 1,
mxSymbols->getSymbolChar( ocDiv) ); OUString( mxSymbols->getSymbolChar(ocDiv) ) );
aCorrectedSymbol = OUString(c); aCorrectedSymbol = OUString(c);
bCorrected = true; bCorrected = true;
} }
......
...@@ -311,7 +311,7 @@ protected: ...@@ -311,7 +311,7 @@ protected:
bool MergeRangeReference( FormulaToken * * const pCode1, FormulaToken * const * const pCode2 ); bool MergeRangeReference( FormulaToken * * const pCode1, FormulaToken * const * const pCode2 );
String aCorrectedFormula; // autocorrected Formula OUString aCorrectedFormula; // autocorrected Formula
OUString aCorrectedSymbol; // autocorrected Symbol OUString aCorrectedSymbol; // autocorrected Symbol
OpCodeMapPtr mxSymbols; // which symbols are used OpCodeMapPtr mxSymbols; // which symbols are used
......
...@@ -425,7 +425,7 @@ public: ...@@ -425,7 +425,7 @@ public:
void SetExtendedErrorDetection( ExtendedErrorDetection eVal ) { meExtendedErrorDetection = eVal; } void SetExtendedErrorDetection( ExtendedErrorDetection eVal ) { meExtendedErrorDetection = eVal; }
bool IsCorrected() { return bCorrected; } bool IsCorrected() { return bCorrected; }
const String& GetCorrectedFormula() { return aCorrectedFormula; } const OUString& GetCorrectedFormula() { return aCorrectedFormula; }
// Use convention from this->aPos by default // Use convention from this->aPos by default
ScTokenArray* CompileString( const OUString& rFormula ); ScTokenArray* CompileString( const OUString& rFormula );
......
...@@ -3664,7 +3664,7 @@ ScTokenArray* ScCompiler::CompileString( const OUString& rFormula ) ...@@ -3664,7 +3664,7 @@ ScTokenArray* ScCompiler::CompileString( const OUString& rFormula )
bCorrected = false; bCorrected = false;
if ( bAutoCorrect ) if ( bAutoCorrect )
{ {
aCorrectedFormula.Erase(); aCorrectedFormula = "";
aCorrectedSymbol = ""; aCorrectedSymbol = "";
} }
sal_uInt8 nForced = 0; // ==formula forces recalc even if cell is not visible sal_uInt8 nForced = 0; // ==formula forces recalc even if cell is not visible
...@@ -3673,14 +3673,14 @@ ScTokenArray* ScCompiler::CompileString( const OUString& rFormula ) ...@@ -3673,14 +3673,14 @@ ScTokenArray* ScCompiler::CompileString( const OUString& rFormula )
nSrcPos++; nSrcPos++;
nForced++; nForced++;
if ( bAutoCorrect ) if ( bAutoCorrect )
aCorrectedFormula += '='; aCorrectedFormula += "=";
} }
if( aFormula.GetChar(nSrcPos) == '=' ) if( aFormula.GetChar(nSrcPos) == '=' )
{ {
nSrcPos++; nSrcPos++;
nForced++; nForced++;
if ( bAutoCorrect ) if ( bAutoCorrect )
aCorrectedFormula += '='; aCorrectedFormula += "=";
} }
struct FunctionStack struct FunctionStack
{ {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment