sc/inc/compiler.hxx              |   38 ++++++-------
 sc/source/core/tool/compiler.cxx |  114 +++++++++++++++++++--------------------
 2 files changed, 76 insertions(+), 76 deletions(-)

New commits:
commit 11ad730e765824ac9b954865e1d5651b6c837b2d
Author:     Luboš Luňák <l.lu...@collabora.com>
AuthorDate: Wed Mar 2 12:03:20 2022 +0100
Commit:     Luboš Luňák <l.lu...@collabora.com>
CommitDate: Wed Mar 2 21:38:51 2022 +0100

    function that modifies data should not be called IsXXX()
    
    IsXXX() is for const functions that check something. Using it
    for functions that modify data is confusing. Some of them even are
    in fact const, and the problem got "fixed" by making data mutable
    *sigh*.
    
    Change-Id: Ic385c96d6c32c818a8a6baa77ab025aab2c45a03
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/130890
    Tested-by: Jenkins
    Reviewed-by: Luboš Luňák <l.lu...@collabora.com>

diff --git a/sc/inc/compiler.hxx b/sc/inc/compiler.hxx
index f2c17fe612c8..c2bdb29b478d 100644
--- a/sc/inc/compiler.hxx
+++ b/sc/inc/compiler.hxx
@@ -285,7 +285,7 @@ private:
     sal_Unicode cSymbol[MAXSTRLEN+1];               // current Symbol + 0
     OUString    aFormula;                           // formula source code
     sal_Int32   nSrcPos;                            // tokenizer position 
(source code)
-    mutable ScRawToken maRawToken;
+    ScRawToken maRawToken;
 
     std::queue<OpCode> maPendingOpCodes; // additional opcodes generated from 
a single symbol
 
@@ -347,21 +347,21 @@ private:
 
     std::vector<Whitespace> NextSymbol(bool bInArray);
 
-    bool IsValue( const OUString& );
-    bool IsOpCode( const OUString&, bool bInArray );
-    bool IsOpCode2( const OUString& );
-    bool IsString();
-    bool IsReference( const OUString& rSymbol, const OUString* pErrRef = 
nullptr );
-    bool IsSingleReference( const OUString& rSymbol, const OUString* pErrRef = 
nullptr );
-    bool IsDoubleReference( const OUString& rSymbol, const OUString* pErrRef = 
nullptr );
-    bool IsPredetectedReference( const OUString& rSymbol );
-    bool IsPredetectedErrRefReference( const OUString& rName, const OUString* 
pErrRef );
-    bool IsMacro( const OUString& );
-    bool IsNamedRange( const OUString& );
-    bool IsExternalNamedRange( const OUString& rSymbol, bool& 
rbInvalidExternalNameRange );
-    bool IsDBRange( const OUString& );
-    bool IsColRowName( const OUString& );
-    bool IsBoolean( const OUString& );
+    bool ParseValue( const OUString& );
+    bool ParseOpCode( const OUString&, bool bInArray );
+    bool ParseOpCode2( const OUString& );
+    bool ParseString();
+    bool ParseReference( const OUString& rSymbol, const OUString* pErrRef = 
nullptr );
+    bool ParseSingleReference( const OUString& rSymbol, const OUString* 
pErrRef = nullptr );
+    bool ParseDoubleReference( const OUString& rSymbol, const OUString* 
pErrRef = nullptr );
+    bool ParsePredetectedReference( const OUString& rSymbol );
+    bool ParsePredetectedErrRefReference( const OUString& rName, const 
OUString* pErrRef );
+    bool ParseMacro( const OUString& );
+    bool ParseNamedRange( const OUString& );
+    bool ParseExternalNamedRange( const OUString& rSymbol, bool& 
rbInvalidExternalNameRange );
+    bool ParseDBRange( const OUString& );
+    bool ParseColRowName( const OUString& );
+    bool ParseBoolean( const OUString& );
     void AutoCorrectParsedSymbol();
     const ScRangeData* GetRangeData( SCTAB& rSheet, const OUString& rUpperName 
) const;
 
@@ -417,9 +417,9 @@ public:
     // Check if it is a valid english function name
     static bool IsEnglishSymbol( const OUString& rName );
 
-    bool IsErrorConstant( const OUString& ) const;
-    bool IsTableRefItem( const OUString& ) const;
-    bool IsTableRefColumn( const OUString& ) const;
+    bool ParseErrorConstant( const OUString& );
+    bool ParseTableRefItem( const OUString& );
+    bool ParseTableRefColumn( const OUString& );
 
     /** Calls GetToken() if PeekNextNoSpaces() is of given OpCode. */
     bool GetTokenIfOpCode( OpCode eOp );
diff --git a/sc/source/core/tool/compiler.cxx b/sc/source/core/tool/compiler.cxx
index 61fa95ca5f87..0b0dce39134f 100644
--- a/sc/source/core/tool/compiler.cxx
+++ b/sc/source/core/tool/compiler.cxx
@@ -2874,7 +2874,7 @@ Label_MaskStateMachine:
 
 // Convert symbol to token
 
-bool ScCompiler::IsOpCode( const OUString& rName, bool bInArray )
+bool ScCompiler::ParseOpCode( const OUString& rName, bool bInArray )
 {
     OpCodeHashMap::const_iterator iLook( mxSymbols->getHashMap().find( rName));
     bool bFound = (iLook != mxSymbols->getHashMap().end());
@@ -3061,7 +3061,7 @@ bool ScCompiler::IsOpCode( const OUString& rName, bool 
bInArray )
     return bFound;
 }
 
-bool ScCompiler::IsOpCode2( const OUString& rName )
+bool ScCompiler::ParseOpCode2( const OUString& rName )
 {
     bool bFound = false;
     sal_uInt16 i;
@@ -3083,7 +3083,7 @@ static bool lcl_ParenthesisFollows( const sal_Unicode* p )
     return *p == '(';
 }
 
-bool ScCompiler::IsValue( const OUString& rSym )
+bool ScCompiler::ParseValue( const OUString& rSym )
 {
     const sal_Int32 nFormulaLanguage = FormulaGrammar::extractFormulaLanguage( 
GetGrammar());
     if (nFormulaLanguage == css::sheet::FormulaLanguage::ODFF || 
nFormulaLanguage == css::sheet::FormulaLanguage::OOXML)
@@ -3171,7 +3171,7 @@ bool ScCompiler::IsValue( const OUString& rSym )
     return true;
 }
 
-bool ScCompiler::IsString()
+bool ScCompiler::ParseString()
 {
     if ( cSymbol[0] != '"' )
         return false;
@@ -3186,20 +3186,20 @@ bool ScCompiler::IsString()
     return true;
 }
 
-bool ScCompiler::IsPredetectedErrRefReference( const OUString& rName, const 
OUString* pErrRef )
+bool ScCompiler::ParsePredetectedErrRefReference( const OUString& rName, const 
OUString* pErrRef )
 {
     switch (mnPredetectedReference)
     {
         case 1:
-            return IsSingleReference( rName, pErrRef);
+            return ParseSingleReference( rName, pErrRef);
         case 2:
-            return IsDoubleReference( rName, pErrRef);
+            return ParseDoubleReference( rName, pErrRef);
         default:
             return false;
     }
 }
 
-bool ScCompiler::IsPredetectedReference( const OUString& rName )
+bool ScCompiler::ParsePredetectedReference( const OUString& rName )
 {
     // Speedup documents with lots of broken references, e.g. sheet deleted.
     // It could also be a broken invalidated reference that contains #REF!
@@ -3221,9 +3221,9 @@ bool ScCompiler::IsPredetectedReference( const OUString& 
rName )
             // Per ODFF the correct string for a reference error is just #REF!,
             // so pass it on.
             if (rName.getLength() == 5)
-                return IsErrorConstant( rName);
+                return ParseErrorConstant( rName);
             // #REF!.AB42 or #REF!42 or #REF!#REF!
-            return IsPredetectedErrRefReference( rName, &aErrRef);
+            return ParsePredetectedErrRefReference( rName, &aErrRef);
         }
         sal_Unicode c = rName[nPos-1];      // before #REF!
         if ('$' == c)
@@ -3231,7 +3231,7 @@ bool ScCompiler::IsPredetectedReference( const OUString& 
rName )
             if (nPos == 1)
             {
                 // $#REF!.AB42 or $#REF!42 or $#REF!#REF!
-                return IsPredetectedErrRefReference( rName, &aErrRef);
+                return ParsePredetectedErrRefReference( rName, &aErrRef);
             }
             c = rName[nPos-2];              // before $#REF!
         }
@@ -3242,7 +3242,7 @@ bool ScCompiler::IsPredetectedReference( const OUString& 
rName )
                 if ('$' == c2 || '#' == c2 || ('0' <= c2 && c2 <= '9'))
                 {
                     // sheet.#REF!42 or sheet.#REF!#REF!
-                    return IsPredetectedErrRefReference( rName, &aErrRef);
+                    return ParsePredetectedErrRefReference( rName, &aErrRef);
                 }
                 break;
             case ':':
@@ -3251,7 +3251,7 @@ bool ScCompiler::IsPredetectedReference( const OUString& 
rName )
                          ('0' <= c2 && c2 <= '9')))
                 {
                     // :#REF!.AB42 or :#REF!42 or :#REF!#REF!
-                    return IsPredetectedErrRefReference( rName, &aErrRef);
+                    return ParsePredetectedErrRefReference( rName, &aErrRef);
                 }
                 break;
             default:
@@ -3259,21 +3259,21 @@ bool ScCompiler::IsPredetectedReference( const 
OUString& rName )
                         ((mnPredetectedReference > 1 && ':' == c2) || 0 == c2))
                 {
                     // AB#REF!: or AB#REF!
-                    return IsPredetectedErrRefReference( rName, &aErrRef);
+                    return ParsePredetectedErrRefReference( rName, &aErrRef);
                 }
         }
     }
     switch (mnPredetectedReference)
     {
         case 1:
-            return IsSingleReference( rName);
+            return ParseSingleReference( rName);
         case 2:
-            return IsDoubleReference( rName);
+            return ParseDoubleReference( rName);
     }
     return false;
 }
 
-bool ScCompiler::IsDoubleReference( const OUString& rName, const OUString* 
pErrRef )
+bool ScCompiler::ParseDoubleReference( const OUString& rName, const OUString* 
pErrRef )
 {
     ScRange aRange( aPos, aPos );
     const ScAddress::Details aDetails( pConv->meConv, aPos );
@@ -3313,7 +3313,7 @@ bool ScCompiler::IsDoubleReference( const OUString& 
rName, const OUString* pErrR
     return ( nFlags & ScRefFlags::VALID ) != ScRefFlags::ZERO;
 }
 
-bool ScCompiler::IsSingleReference( const OUString& rName, const OUString* 
pErrRef )
+bool ScCompiler::ParseSingleReference( const OUString& rName, const OUString* 
pErrRef )
 {
     mnCurrentSheetEndPos = 0;
     mnCurrentSheetTab = -1;
@@ -3378,11 +3378,11 @@ bool ScCompiler::IsSingleReference( const OUString& 
rName, const OUString* pErrR
     return ( nFlags & ScRefFlags::VALID ) != ScRefFlags::ZERO;
 }
 
-bool ScCompiler::IsReference( const OUString& rName, const OUString* pErrRef )
+bool ScCompiler::ParseReference( const OUString& rName, const OUString* 
pErrRef )
 {
-    // Has to be called before IsValue
+    // Has to be called before ParseValue
 
-    // A later IsNamedRange() relies on these, being set in IsSingleReference()
+    // A later ParseNamedRange() relies on these, being set in 
ParseSingleReference()
     // if so, reset in all cases.
     mnCurrentSheetEndPos = 0;
     mnCurrentSheetTab = -1;
@@ -3442,7 +3442,7 @@ bool ScCompiler::IsReference( const OUString& rName, 
const OUString* pErrRef )
         } while(false);
     }
 
-    if (IsSingleReference( rName, pErrRef))
+    if (ParseSingleReference( rName, pErrRef))
         return true;
 
     // Though the range operator is handled explicitly, when encountering
@@ -3450,7 +3450,7 @@ bool ScCompiler::IsReference( const OUString& rName, 
const OUString* pErrRef )
     // doesn't pass as single cell reference.
     if (mnRangeOpPosInSymbol > 0)   // ":foo" would be nonsense
     {
-        if (IsDoubleReference( rName, pErrRef))
+        if (ParseDoubleReference( rName, pErrRef))
             return true;
         // Now try with a symbol up to the range operator, rewind source
         // position.
@@ -3480,7 +3480,7 @@ bool ScCompiler::IsReference( const OUString& rName, 
const OUString* pErrRef )
                 [[fallthrough]];
             case FormulaGrammar::CONV_XL_R1C1:
                 // C2 or C[1] are valid entire column references.
-                if (IsDoubleReference( rName, pErrRef))
+                if (ParseDoubleReference( rName, pErrRef))
                     return true;
                 break;
             default:
@@ -3490,7 +3490,7 @@ bool ScCompiler::IsReference( const OUString& rName, 
const OUString* pErrRef )
     return false;
 }
 
-bool ScCompiler::IsMacro( const OUString& rName )
+bool ScCompiler::ParseMacro( const OUString& rName )
 {
 #if !HAVE_FEATURE_SCRIPTING
     (void) rName;
@@ -3507,7 +3507,7 @@ bool ScCompiler::IsMacro( const OUString& rName )
     vcl::SolarMutexTryAndBuyGuard g;
     if (!g.isAcquired())
     {
-        SAL_WARN( "sc.core", "ScCompiler::IsMacro - SolarMutex would deadlock, 
not obtaining Basic");
+        SAL_WARN( "sc.core", "ScCompiler::ParseMacro - SolarMutex would 
deadlock, not obtaining Basic");
         return false;   // bad luck
     }
 
@@ -3574,9 +3574,9 @@ const ScRangeData* ScCompiler::GetRangeData( SCTAB& 
rSheet, const OUString& rUpp
     return pData;
 }
 
-bool ScCompiler::IsNamedRange( const OUString& rUpperName )
+bool ScCompiler::ParseNamedRange( const OUString& rUpperName )
 {
-    // IsNamedRange is called only from NextNewToken, with an upper-case string
+    // ParseNamedRange is called only from NextNewToken, with an upper-case 
string
 
     SCTAB nSheet = -1;
     const ScRangeData* pData = GetRangeData( nSheet, rUpperName);
@@ -3605,7 +3605,7 @@ bool ScCompiler::IsNamedRange( const OUString& rUpperName 
)
     return false;
 }
 
-bool ScCompiler::IsExternalNamedRange( const OUString& rSymbol, bool& 
rbInvalidExternalNameRange )
+bool ScCompiler::ParseExternalNamedRange( const OUString& rSymbol, bool& 
rbInvalidExternalNameRange )
 {
     /* FIXME: This code currently (2008-12-02T15:41+0100 in CWS mooxlsc)
      * correctly parses external named references in OOo, as required per RFE
@@ -3643,7 +3643,7 @@ bool ScCompiler::IsExternalNamedRange( const OUString& 
rSymbol, bool& rbInvalidE
     return true;
 }
 
-bool ScCompiler::IsDBRange( const OUString& rName )
+bool ScCompiler::ParseDBRange( const OUString& rName )
 {
     ScDBCollection::NamedDBs& rDBs = rDoc.GetDBCollection()->getNamedDBs();
     const ScDBData* p = rDBs.findByUpperName(rName);
@@ -3655,7 +3655,7 @@ bool ScCompiler::IsDBRange( const OUString& rName )
     return true;
 }
 
-bool ScCompiler::IsColRowName( const OUString& rName )
+bool ScCompiler::ParseColRowName( const OUString& rName )
 {
     bool bInList = false;
     bool bFound = false;
@@ -3910,7 +3910,7 @@ bool ScCompiler::IsColRowName( const OUString& rName )
         return false;
 }
 
-bool ScCompiler::IsBoolean( const OUString& rName )
+bool ScCompiler::ParseBoolean( const OUString& rName )
 {
     OpCodeHashMap::const_iterator iLook( mxSymbols->getHashMap().find( rName ) 
);
     if( iLook != mxSymbols->getHashMap().end() &&
@@ -3924,7 +3924,7 @@ bool ScCompiler::IsBoolean( const OUString& rName )
         return false;
 }
 
-bool ScCompiler::IsErrorConstant( const OUString& rName ) const
+bool ScCompiler::ParseErrorConstant( const OUString& rName )
 {
     FormulaError nError = GetErrorConstant( rName);
     if (nError != FormulaError::NONE)
@@ -3936,7 +3936,7 @@ bool ScCompiler::IsErrorConstant( const OUString& rName ) 
const
         return false;
 }
 
-bool ScCompiler::IsTableRefItem( const OUString& rName ) const
+bool ScCompiler::ParseTableRefItem( const OUString& rName )
 {
     bool bItem = false;
     OpCodeHashMap::const_iterator iLook( mxSymbols->getHashMap().find( rName));
@@ -4008,7 +4008,7 @@ OUString unescapeTableRefColumnSpecifier( const OUString& 
rStr )
 }
 }
 
-bool ScCompiler::IsTableRefColumn( const OUString& rName ) const
+bool ScCompiler::ParseTableRefColumn( const OUString& rName )
 {
     // Only called when there actually is a current TableRef, hence
     // accessing maTableRefs.back() is safe.
@@ -4362,7 +4362,7 @@ bool ScCompiler::NextNewToken( bool bInArray )
     {
         OUString aStr( cSymbol);
         bool bInvalidExternalNameRange;
-        if (!IsPredetectedReference( aStr) && !IsExternalNamedRange( aStr, 
bInvalidExternalNameRange ))
+        if (!ParsePredetectedReference( aStr) && !ParseExternalNamedRange( 
aStr, bInvalidExternalNameRange ))
         {
             svl::SharedString aSS = rDoc.GetSharedStringPool().intern(aStr);
             maRawToken.SetString(aSS.getData(), aSS.getDataIgnoreCase());
@@ -4386,7 +4386,7 @@ bool ScCompiler::NextNewToken( bool bInArray )
         return false;
     }
 
-    if( IsString() )
+    if( ParseString() )
         return true;
 
     bool bMayBeFuncName;
@@ -4417,7 +4417,7 @@ bool ScCompiler::NextNewToken( bool bInArray )
     if (bAsciiNonAlnum && cSymbol[1] == 0 && (eLastOp != ocTableRefOpen || 
cSymbol[0] == '[' || cSymbol[0] == ']'))
     {
         // Shortcut for operators and separators that need no further checks 
or upper.
-        if (IsOpCode( OUString( cSymbol), bInArray ))
+        if (ParseOpCode( OUString( cSymbol), bInArray ))
             return true;
     }
 
@@ -4430,8 +4430,8 @@ bool ScCompiler::NextNewToken( bool bInArray )
         bMayBeFuncName = ( *p == '(' );
     }
 
-    // Italian ARCTAN.2 resulted in #REF! => IsOpcode() before
-    // IsReference().
+    // Italian ARCTAN.2 resulted in #REF! => ParseOpcode() before
+    // ParseReference().
 
     OUString aUpper;
 
@@ -4444,7 +4444,7 @@ Label_Rewind:
         // Check for TableRef column specifier first, it may be anything.
         if (cSymbol[0] != '#' && !maTableRefs.empty() && 
maTableRefs.back().mnLevel)
         {
-            if (IsTableRefColumn( aOrg ))
+            if (ParseTableRefColumn( aOrg ))
                 return true;
             // Do not attempt to resolve as any other name.
             aUpper = aOrg;  // for ocBad
@@ -4463,12 +4463,12 @@ Label_Rewind:
                 // Check for TableRef item specifiers first.
                 if (!maTableRefs.empty() && maTableRefs.back().mnLevel == 2)
                 {
-                    if (IsTableRefItem( aUpper ))
+                    if (ParseTableRefItem( aUpper ))
                         return true;
                 }
 
                 // This can be either an error constant ...
-                if (IsErrorConstant( aUpper))
+                if (ParseErrorConstant( aUpper))
                     return true;
 
                 // ... or some invalidated reference starting with #REF!
@@ -4476,7 +4476,7 @@ Label_Rewind:
 
                 break;  // do; create ocBad token or set error.
             }
-            if (IsOpCode( aUpper, bInArray ))
+            if (ParseOpCode( aUpper, bInArray ))
                 return true;
         }
 
@@ -4484,14 +4484,14 @@ Label_Rewind:
         {
             if (aUpper.isEmpty())
                 bAsciiUpper = ToUpperAsciiOrI18nIsAscii( aUpper, aOrg);
-            if (IsOpCode( aUpper, bInArray ))
+            if (ParseOpCode( aUpper, bInArray ))
                 return true;
         }
 
         // Column 'DM' ("Deutsche Mark", German currency) couldn't be
-        // referred => IsReference() before IsValue().
+        // referred => ParseReference() before ParseValue().
         // Preserve case of file names in external references.
-        if (IsReference( aOrg ))
+        if (ParseReference( aOrg ))
         {
             if (mbRewind)   // Range operator, but no direct reference.
                 continue;   // do; up to range operator.
@@ -4509,12 +4509,12 @@ Label_Rewind:
         if (aUpper.isEmpty())
             bAsciiUpper = ToUpperAsciiOrI18nIsAscii( aUpper, aOrg);
 
-        // IsBoolean() before IsValue() to catch inline bools without the 
kludge
+        // ParseBoolean() before ParseValue() to catch inline bools without 
the kludge
         //    for inline arrays.
-        if (bAllowBooleans && IsBoolean( aUpper ))
+        if (bAllowBooleans && ParseBoolean( aUpper ))
             return true;
 
-        if (IsValue( aUpper ))
+        if (ParseValue( aUpper ))
             return true;
 
         // User defined names and such do need i18n upper also in ODF.
@@ -4527,7 +4527,7 @@ Label_Rewind:
             aUpper = ScGlobal::getCharClass().uppercase( aOrg );
         }
 
-        if (IsNamedRange( aUpper ))
+        if (ParseNamedRange( aUpper ))
             return true;
 
         // Compiling a named expression during collecting them in import shall
@@ -4540,7 +4540,7 @@ Label_Rewind:
 
         // Preserve case of file names in external references.
         bool bInvalidExternalNameRange;
-        if (IsExternalNamedRange( aOrg, bInvalidExternalNameRange ))
+        if (ParseExternalNamedRange( aOrg, bInvalidExternalNameRange ))
             return true;
         // Preserve case of file names in external references even when range
         // is not valid and previous check failed tdf#89330
@@ -4552,15 +4552,15 @@ Label_Rewind:
             maRawToken.NewOpCode( ocBad );
             return true;
         }
-        if (IsDBRange( aUpper ))
+        if (ParseDBRange( aUpper ))
             return true;
         // If followed by '(' (with or without space inbetween) it can not be a
         // column/row label. Prevent arbitrary content detection.
-        if (!bMayBeFuncName && IsColRowName( aUpper ))
+        if (!bMayBeFuncName && ParseColRowName( aUpper ))
             return true;
-        if (bMayBeFuncName && IsMacro( aUpper ))
+        if (bMayBeFuncName && ParseMacro( aUpper ))
             return true;
-        if (bMayBeFuncName && IsOpCode2( aUpper ))
+        if (bMayBeFuncName && ParseOpCode2( aUpper ))
             return true;
 
     } while (mbRewind);
@@ -4569,7 +4569,7 @@ Label_Rewind:
     // #REF! (but is not equal to), which we also wrote to ODFF between 2013
     // and 2016 until 5.1.4
     OUString aErrRef( mxSymbols->getSymbol( ocErrRef));
-    if (aUpper.indexOf( aErrRef) >= 0 && IsReference( aUpper, &aErrRef))
+    if (aUpper.indexOf( aErrRef) >= 0 && ParseReference( aUpper, &aErrRef))
     {
         if (mbRewind)
             goto Label_Rewind;

Reply via email to