[ooo-build-commit] .: patches/dev300

Kohei Yoshida kohei at kemper.freedesktop.org
Tue May 11 19:47:10 PDT 2010


 patches/dev300/apply                             |    3 
 patches/dev300/calc-formula-r1c1-parser-fix.diff |  201 +++++++++++++++++++++++
 2 files changed, 204 insertions(+)

New commits:
commit bb5d066d9d7872e187b7d974fcd6805815944893
Author: Kohei Yoshida <kyoshida at novell.com>
Date:   Tue May 11 22:43:34 2010 -0400

    Fixed another R1C1 parser error.
    
    The R1C1 parser failed to parse an expression involving minus operators
    e.g. R[-2]C-R[-1]C, due to the '-' occurring both within the reference
    strings and as a subtraction operator.
    
    * patches/dev300/apply:
    * patches/dev300/calc-formula-r1c1-parser-fix.diff: dynamically change
      character modifier based on the preceding character so that '-'
      following '[' can have an extra modifier value. (n#604903)

diff --git a/patches/dev300/apply b/patches/dev300/apply
index 2014765..ffcfbed 100644
--- a/patches/dev300/apply
+++ b/patches/dev300/apply
@@ -3819,6 +3819,9 @@ calc-perf-xlsx-import-string-cells.diff, n#594513, kohei
 # Speed up outline level changes with notes.
 calc-perf-outlining-with-notes.diff, kohei
 
+# Fix parse error on minus operator e.g. R[-2]C-R[-1]C.
+calc-formula-r1c1-parser-fix.diff, n#604903, kohei
+
 [ GentooExperimental ]
 SectionOwner => hmth
 # jemalloc, FreeBSD 7 allocator
diff --git a/patches/dev300/calc-formula-r1c1-parser-fix.diff b/patches/dev300/calc-formula-r1c1-parser-fix.diff
new file mode 100644
index 0000000..02468bc
--- /dev/null
+++ b/patches/dev300/calc-formula-r1c1-parser-fix.diff
@@ -0,0 +1,201 @@
+diff --git sc/inc/compiler.hxx sc/inc/compiler.hxx
+index 4155c75..a47d4a5 100644
+--- sc/inc/compiler.hxx
++++ sc/inc/compiler.hxx
+@@ -227,9 +227,7 @@ public:
+     struct Convention
+     {
+         const formula::FormulaGrammar::AddressConvention meConv;
+-        const ULONG*                mpCharTable;
+-
+-
++        
+         Convention( formula::FormulaGrammar::AddressConvention eConvP );
+         virtual ~Convention();
+ 
+@@ -278,6 +276,11 @@ public:
+             ABS_SHEET_PREFIX
+         };
+         virtual sal_Unicode getSpecialSymbol( SpecialSymbolType eSymType ) const = 0;
++
++        virtual ULONG getCharTableFlags( sal_Unicode c, sal_Unicode cLast ) const = 0;
++
++    protected:
++        const ULONG* mpCharTable;
+     };
+     friend struct Convention;
+ 
+@@ -452,10 +455,11 @@ public:
+                                        const formula::FormulaGrammar::AddressConvention eConv = formula::FormulaGrammar::CONV_OOO )
+         {
+             sal_Unicode c = rStr.GetChar( nPos );
++            sal_Unicode cLast = nPos > 0 ? rStr.GetChar(nPos-1) : 0;
+             if (c < 128)
+             {
+                 return pConventions[eConv] ? static_cast<BOOL>(
+-                        (pConventions[eConv]->mpCharTable[ UINT8(c) ] & SC_COMPILER_C_CHAR_WORD) == SC_COMPILER_C_CHAR_WORD) :
++                        (pConventions[eConv]->getCharTableFlags(c, cLast) & SC_COMPILER_C_CHAR_WORD) == SC_COMPILER_C_CHAR_WORD) :
+                     FALSE;   // no convention => assume invalid
+             }
+             else
+@@ -469,10 +473,11 @@ public:
+                                    const formula::FormulaGrammar::AddressConvention eConv = formula::FormulaGrammar::CONV_OOO )
+         {
+             sal_Unicode c = rStr.GetChar( nPos );
++            sal_Unicode cLast = nPos > 0 ? rStr.GetChar(nPos-1) : 0;
+             if (c < 128)
+             {
+                 return pConventions[eConv] ? static_cast<BOOL>(
+-                        (pConventions[eConv]->mpCharTable[ UINT8(c) ] & SC_COMPILER_C_WORD) == SC_COMPILER_C_WORD) :
++                        (pConventions[eConv]->getCharTableFlags(c, cLast) & SC_COMPILER_C_WORD) == SC_COMPILER_C_WORD) :
+                     FALSE;   // convention not known => assume invalid
+             }
+             else
+@@ -489,13 +494,14 @@ public:
+                                                  bool bTestLetterNumeric = true )
+         {
+             sal_Unicode c = rStr.GetChar( nPos );
++            sal_Unicode cLast = nPos > 0 ? rStr.GetChar( nPos-1 ) : 0;
+             if (c < 128)
+             {
+                 for ( int nConv = formula::FormulaGrammar::CONV_UNSPECIFIED;
+                         ++nConv < formula::FormulaGrammar::CONV_LAST; )
+                 {
+                     if (pConventions[nConv] && 
+-                            ((pConventions[nConv]->mpCharTable[ UINT8(c) ] & nFlags) != nFlags))
++                            ((pConventions[nConv]->getCharTableFlags(c, cLast) & nFlags) != nFlags))
+                         return false;
+                     // convention not known => assume valid
+                 }
+@@ -530,8 +536,8 @@ private:
+     virtual BOOL IsImportingXML() const;
+ 
+     /// Access the CharTable flags
+-    inline ULONG GetCharTableFlags( sal_Unicode c )
+-        { return c < 128 ? pConv->mpCharTable[ UINT8(c) ] : 0; }
++    inline ULONG GetCharTableFlags( sal_Unicode c, sal_Unicode cLast )
++        { return c < 128 ? pConv->getCharTableFlags(c, cLast) : 0; }
+ };
+ 
+ SC_DLLPUBLIC String GetScCompilerNativeSymbol( OpCode eOp ); //CHINA001
+diff --git sc/source/core/tool/compiler.cxx sc/source/core/tool/compiler.cxx
+index 52526d7..c38d640 100644
+--- sc/source/core/tool/compiler.cxx
++++ sc/source/core/tool/compiler.cxx
+@@ -548,7 +548,6 @@ ScCompiler::Convention::Convention( FormulaGrammar::AddressConvention eConv )
+ 
+         if( FormulaGrammar::CONV_XL_R1C1 == meConv )
+         {
+-/* - */     t[45] |= SC_COMPILER_C_IDENT;
+ /* [ */     t[91] |= SC_COMPILER_C_IDENT;
+ /* ] */     t[93] |= SC_COMPILER_C_IDENT;
+         }
+@@ -824,6 +823,11 @@ struct Convention_A1 : public ScCompiler::Convention
+         return pCharClass->parseAnyToken( rFormula,
+                 nSrcPos, nStartFlags, aAddAllowed, nContFlags, aAddAllowed );
+     }
++
++    virtual ULONG getCharTableFlags( sal_Unicode c, sal_Unicode /*cLast*/ ) const
++    {
++        return mpCharTable[static_cast<sal_uInt8>(c)];
++    }
+ };
+ 
+ void Convention_A1::MakeColStr( rtl::OUStringBuffer& rBuffer, SCCOL nCol )
+@@ -1792,6 +1796,15 @@ struct ConventionXL_R1C1 : public ScCompiler::Convention, public ConventionXL
+         r1c1_add_row(rBuffer, aRef.Ref2);
+         r1c1_add_col(rBuffer, aRef.Ref2);
+     }
++
++    virtual ULONG getCharTableFlags( sal_Unicode c, sal_Unicode cLast ) const
++    {
++        ULONG nFlags = mpCharTable[static_cast<sal_uInt8>(c)];
++        if (c == '-' && cLast == '[')
++            // '-' can occur within a reference string only after '[' e.g. R[-1]C.
++            nFlags |= SC_COMPILER_C_IDENT;
++        return nFlags;
++    }
+ };
+ 
+ static const ConventionXL_R1C1 ConvXL_R1C1;
+@@ -1982,7 +1995,8 @@ xub_StrLen ScCompiler::NextSymbol(bool bInArray)
+     while ((c != 0) && (eState != ssStop) )
+     {
+         pSrc++;
+-        ULONG nMask = GetCharTableFlags( c );
++        ULONG nMask = GetCharTableFlags( c, cLast );
++
+         // The parameter separator and the array column and row separators end
+         // things unconditionally if not in string or reference.
+         if (c == cSep || (bInArray && (c == cArrayColSep || c == cArrayRowSep)))
+@@ -2012,7 +2026,7 @@ Label_MaskStateMachine:
+                 if( nMask & SC_COMPILER_C_ODF_LABEL_OP )
+                 {
+                     // '!!' automatic intersection
+-                    if (GetCharTableFlags( pSrc[0] ) & SC_COMPILER_C_ODF_LABEL_OP)
++                    if (GetCharTableFlags( pSrc[0], 0 ) & SC_COMPILER_C_ODF_LABEL_OP)
+                     {
+                         /* TODO: For now the UI "space operator" is used, this
+                          * could be enhanced using a specialized OpCode to get
+@@ -2043,7 +2057,7 @@ Label_MaskStateMachine:
+                 else if( nMask & SC_COMPILER_C_ODF_NAME_MARKER )
+                 {
+                     // '$$' defined name marker
+-                    if (GetCharTableFlags( pSrc[0] ) & SC_COMPILER_C_ODF_NAME_MARKER)
++                    if (GetCharTableFlags( pSrc[0], 0 ) & SC_COMPILER_C_ODF_NAME_MARKER)
+                     {
+                         // both eaten, not added to pSym
+                         ++pSrc;
+@@ -2177,7 +2191,7 @@ Label_MaskStateMachine:
+                 }
+                 else if (c == 'E' || c == 'e')
+                 {
+-                    if (GetCharTableFlags( pSrc[0] ) & SC_COMPILER_C_VALUE_EXP)
++                    if (GetCharTableFlags( pSrc[0], 0 ) & SC_COMPILER_C_VALUE_EXP)
+                         *pSym++ = c;
+                     else
+                     {
+@@ -2189,7 +2203,7 @@ Label_MaskStateMachine:
+                 else if( nMask & SC_COMPILER_C_VALUE_SIGN )
+                 {
+                     if (((cLast == 'E') || (cLast == 'e')) &&
+-                            (GetCharTableFlags( pSrc[0] ) & SC_COMPILER_C_VALUE_VALUE))
++                            (GetCharTableFlags( pSrc[0], 0 ) & SC_COMPILER_C_VALUE_VALUE))
+                     {
+                         *pSym++ = c;
+                     }
+@@ -2822,7 +2836,7 @@ BOOL ScCompiler::IsReference( const String& rName )
+             if ( !(ch2 == '$' || CharClass::isAsciiAlpha( ch2 )) )
+                 return FALSE;
+             if ( cDecSep == '.' && (ch2 == 'E' || ch2 == 'e')   // E + - digit
+-                    && (GetCharTableFlags( pTabSep[2] ) & SC_COMPILER_C_VALUE_EXP) )
++                    && (GetCharTableFlags( pTabSep[2], pTabSep[1] ) & SC_COMPILER_C_VALUE_EXP) )
+             {   // #91053#
+                 // If it is an 1.E2 expression check if "1" is an existent sheet
+                 // name. If so, a desired value 1.E2 would have to be entered as
+@@ -3307,12 +3321,13 @@ void ScCompiler::AutoCorrectParsedSymbol()
+         const sal_Unicode cX = 'X';
+         sal_Unicode c1 = aCorrectedSymbol.GetChar( 0 );
+         sal_Unicode c2 = aCorrectedSymbol.GetChar( nPos );
++        sal_Unicode c2p = nPos > 0 ? aCorrectedSymbol.GetChar( nPos-1 ) : 0;
+         if ( c1 == cQuote && c2 != cQuote  )
+         {   // "...
+             // What's not a word doesn't belong to it.
+             // Don't be pedantic: c < 128 should be sufficient here.
+             while ( nPos && ((aCorrectedSymbol.GetChar(nPos) < 128) &&
+-                    ((GetCharTableFlags( aCorrectedSymbol.GetChar(nPos) ) &
++                    ((GetCharTableFlags(aCorrectedSymbol.GetChar(nPos), aCorrectedSymbol.GetChar(nPos-1)) &
+                     (SC_COMPILER_C_WORD | SC_COMPILER_C_CHAR_DONTCARE)) == 0)) )
+                 nPos--;
+             if ( nPos == MAXSTRLEN - 2 )
+@@ -3331,8 +3346,8 @@ void ScCompiler::AutoCorrectParsedSymbol()
+             aCorrectedSymbol = mxSymbols->getSymbol(ocMul);
+             bCorrected = TRUE;
+         }
+-        else if ( (GetCharTableFlags( c1 ) & SC_COMPILER_C_CHAR_VALUE)
+-               && (GetCharTableFlags( c2 ) & SC_COMPILER_C_CHAR_VALUE) )
++        else if ( (GetCharTableFlags( c1, 0 ) & SC_COMPILER_C_CHAR_VALUE)
++               && (GetCharTableFlags( c2, c2p ) & SC_COMPILER_C_CHAR_VALUE) )
+         {
+             xub_StrLen nXcount;
+             if ( (nXcount = aCorrectedSymbol.GetTokenCount( cx )) > 1 )


More information about the ooo-build-commit mailing list