Kaydet (Commit) 69a7e744 authored tarafından Kohei Yoshida's avatar Kohei Yoshida

Use "stop on error" concept rather than "ignore error if true".

Just to keep the pattern of "true" -> "action", "false" -> "no action".

Change-Id: I6303bc779cd7048eef2fdc3c2abba8be8f15da6d
üst 5db9391c
...@@ -537,9 +537,9 @@ FormulaCompiler::FormulaCompiler( FormulaTokenArray& rArr ) ...@@ -537,9 +537,9 @@ FormulaCompiler::FormulaCompiler( FormulaTokenArray& rArr )
meGrammar( formula::FormulaGrammar::GRAM_UNSPECIFIED ), meGrammar( formula::FormulaGrammar::GRAM_UNSPECIFIED ),
bAutoCorrect( false ), bAutoCorrect( false ),
bCorrected( false ), bCorrected( false ),
bIgnoreErrors( false ),
glSubTotal( false ), glSubTotal( false ),
mbJumpCommandReorder(true) mbJumpCommandReorder(true),
mbStopOnError(true)
{ {
} }
...@@ -555,9 +555,9 @@ FormulaCompiler::FormulaCompiler() ...@@ -555,9 +555,9 @@ FormulaCompiler::FormulaCompiler()
meGrammar( formula::FormulaGrammar::GRAM_UNSPECIFIED ), meGrammar( formula::FormulaGrammar::GRAM_UNSPECIFIED ),
bAutoCorrect( false ), bAutoCorrect( false ),
bCorrected( false ), bCorrected( false ),
bIgnoreErrors( false ),
glSubTotal( false ), glSubTotal( false ),
mbJumpCommandReorder(true) mbJumpCommandReorder(true),
mbStopOnError(true)
{ {
} }
...@@ -983,7 +983,7 @@ sal_uInt16 FormulaCompiler::GetErrorConstant( const OUString& rName ) const ...@@ -983,7 +983,7 @@ sal_uInt16 FormulaCompiler::GetErrorConstant( const OUString& rName ) const
void FormulaCompiler::SetCompileForFAP( bool bVal ) void FormulaCompiler::SetCompileForFAP( bool bVal )
{ {
mbJumpCommandReorder = !bVal; mbJumpCommandReorder = !bVal;
bIgnoreErrors = bVal; mbStopOnError = !bVal;
} }
...@@ -1041,7 +1041,7 @@ bool FormulaCompiler::GetToken() ...@@ -1041,7 +1041,7 @@ bool FormulaCompiler::GetToken()
aCorrectedSymbol = ""; aCorrectedSymbol = "";
} }
bool bStop = false; bool bStop = false;
if( pArr->GetCodeError() && !bIgnoreErrors ) if (pArr->GetCodeError() && mbStopOnError)
bStop = true; bStop = true;
else else
{ {
...@@ -1119,7 +1119,7 @@ bool FormulaCompiler::GetToken() ...@@ -1119,7 +1119,7 @@ bool FormulaCompiler::GetToken()
// RPN creation by recursion // RPN creation by recursion
void FormulaCompiler::Factor() void FormulaCompiler::Factor()
{ {
if ( pArr->GetCodeError() && !bIgnoreErrors ) if (pArr->GetCodeError() && mbStopOnError)
return; return;
CurrentFactor pFacToken( this ); CurrentFactor pFacToken( this );
...@@ -1157,7 +1157,7 @@ void FormulaCompiler::Factor() ...@@ -1157,7 +1157,7 @@ void FormulaCompiler::Factor()
{ {
NextToken(); NextToken();
eOp = Expression(); eOp = Expression();
while ((eOp == ocSep) && (!pArr->GetCodeError() || bIgnoreErrors)) while ((eOp == ocSep) && (!pArr->GetCodeError() || !mbStopOnError))
{ // range list (A1;A2) converted to (A1~A2) { // range list (A1;A2) converted to (A1~A2)
pFacToken = mpToken; pFacToken = mpToken;
NextToken(); NextToken();
...@@ -1292,7 +1292,7 @@ void FormulaCompiler::Factor() ...@@ -1292,7 +1292,7 @@ void FormulaCompiler::Factor()
if( !bNoParam ) if( !bNoParam )
{ {
nSepCount++; nSepCount++;
while ( (eOp == ocSep) && (!pArr->GetCodeError() || bIgnoreErrors) ) while ((eOp == ocSep) && (!pArr->GetCodeError() || !mbStopOnError))
{ {
nSepCount++; nSepCount++;
NextToken(); NextToken();
...@@ -1364,7 +1364,7 @@ void FormulaCompiler::Factor() ...@@ -1364,7 +1364,7 @@ void FormulaCompiler::Factor()
} }
short nJumpCount = 0; short nJumpCount = 0;
while ( (nJumpCount < (FORMULA_MAXJUMPCOUNT - 1)) && (eOp == ocSep) while ( (nJumpCount < (FORMULA_MAXJUMPCOUNT - 1)) && (eOp == ocSep)
&& (!pArr->GetCodeError() || bIgnoreErrors) ) && (!pArr->GetCodeError() || !mbStopOnError))
{ {
if ( ++nJumpCount <= nJumpMax ) if ( ++nJumpCount <= nJumpMax )
pFacToken->GetJump()[nJumpCount] = pc-1; pFacToken->GetJump()[nJumpCount] = pc-1;
...@@ -1641,7 +1641,7 @@ bool FormulaCompiler::CompileTokenArray() ...@@ -1641,7 +1641,7 @@ bool FormulaCompiler::CompileTokenArray()
{ {
glSubTotal = false; glSubTotal = false;
bCorrected = false; bCorrected = false;
if( !pArr->GetCodeError() || bIgnoreErrors ) if (!pArr->GetCodeError() || !mbStopOnError)
{ {
if ( bAutoCorrect ) if ( bAutoCorrect )
{ {
...@@ -1684,7 +1684,7 @@ bool FormulaCompiler::CompileTokenArray() ...@@ -1684,7 +1684,7 @@ bool FormulaCompiler::CompileTokenArray()
if( !pArr->GetCodeError() && nErrorBeforePop ) if( !pArr->GetCodeError() && nErrorBeforePop )
pArr->SetCodeError( nErrorBeforePop); pArr->SetCodeError( nErrorBeforePop);
if( pArr->GetCodeError() && !bIgnoreErrors ) if (pArr->GetCodeError() && mbStopOnError)
{ {
pArr->DelRPN(); pArr->DelRPN();
pArr->SetHyperLink( false); pArr->SetHyperLink( false);
......
...@@ -337,11 +337,10 @@ protected: ...@@ -337,11 +337,10 @@ protected:
bool bAutoCorrect; // whether to apply AutoCorrection bool bAutoCorrect; // whether to apply AutoCorrection
bool bCorrected; // AutoCorrection was applied bool bCorrected; // AutoCorrection was applied
bool bIgnoreErrors; // on AutoCorrect and CompileForFAP
// ignore errors and create RPN nevertheless
bool glSubTotal; // if code contains one or more subtotal functions bool glSubTotal; // if code contains one or more subtotal functions
bool mbJumpCommandReorder; /// Whether or not to reorder RPN for jump commands. bool mbJumpCommandReorder; /// Whether or not to reorder RPN for jump commands.
bool mbStopOnError; /// Whether to stop compilation on first encountered error.
private: private:
void InitSymbolsNative() const; /// only SymbolsNative, on first document creation void InitSymbolsNative() const; /// only SymbolsNative, on first document creation
......
...@@ -394,8 +394,7 @@ public: ...@@ -394,8 +394,7 @@ public:
//! _either_ CompileForFAP _or_ AutoCorrection, _not_ both //! _either_ CompileForFAP _or_ AutoCorrection, _not_ both
// #i101512# SetCompileForFAP is in formula::FormulaCompiler // #i101512# SetCompileForFAP is in formula::FormulaCompiler
void SetAutoCorrection( bool bVal ) void SetAutoCorrection( bool bVal );
{ bAutoCorrect = bVal; bIgnoreErrors = bVal; }
void SetCloseBrackets( bool bVal ) { mbCloseBrackets = bVal; } void SetCloseBrackets( bool bVal ) { mbCloseBrackets = bVal; }
void SetRefConvention( const Convention *pConvP ); void SetRefConvention( const Convention *pConvP );
void SetRefConvention( const formula::FormulaGrammar::AddressConvention eConv ); void SetRefConvention( const formula::FormulaGrammar::AddressConvention eConv );
......
...@@ -3199,6 +3199,12 @@ bool ScCompiler::IsErrorConstant( const OUString& rName ) const ...@@ -3199,6 +3199,12 @@ bool ScCompiler::IsErrorConstant( const OUString& rName ) const
return false; return false;
} }
void ScCompiler::SetAutoCorrection( bool bVal )
{
bAutoCorrect = bVal;
mbStopOnError = !bVal;
}
void ScCompiler::AutoCorrectParsedSymbol() void ScCompiler::AutoCorrectParsedSymbol()
{ {
sal_Int32 nPos = aCorrectedSymbol.getLength(); sal_Int32 nPos = aCorrectedSymbol.getLength();
......
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