[Libreoffice-commits] core.git: sc/inc sc/source

Eike Rathke (via logerrit) logerrit at kemper.freedesktop.org
Tue Jun 4 10:15:05 UTC 2019


 sc/inc/compiler.hxx              |    3 ++-
 sc/source/core/tool/compiler.cxx |   34 +++++++++++++++++++++++++++-------
 2 files changed, 29 insertions(+), 8 deletions(-)

New commits:
commit 4e3e0c6744b3fc33c7f4da7bd48136b861e9ed58
Author:     Eike Rathke <erack at redhat.com>
AuthorDate: Mon Jun 3 23:55:11 2019 +0200
Commit:     Eike Rathke <erack at redhat.com>
CommitDate: Tue Jun 4 12:14:27 2019 +0200

    Resolves: tdf#123752 allow group separator in formula values if possible
    
    If possible here means if it can't be an operator (is not an ASCII
    value) and is not any other separator. This restores the "working
    by chance" behaviour for some locales that use NO-BREAK SPACE as
    group separator. It never worked for locales that use one of the
    "ordinary" comma or dot or apostrophe group separator and will
    not.
    
    Change-Id: I8b7ba1b502b6b7367ffb2199d2f3922ab605a659
    Reviewed-on: https://gerrit.libreoffice.org/73422
    Reviewed-by: Eike Rathke <erack at redhat.com>
    Tested-by: Jenkins

diff --git a/sc/inc/compiler.hxx b/sc/inc/compiler.hxx
index d2500a7e0440..b93afa3909d4 100644
--- a/sc/inc/compiler.hxx
+++ b/sc/inc/compiler.hxx
@@ -198,7 +198,8 @@ public:
         virtual css::i18n::ParseResult
                     parseAnyToken( const OUString& rFormula,
                                    sal_Int32 nSrcPos,
-                                   const CharClass* pCharClass) const = 0;
+                                   const CharClass* pCharClass,
+                                   bool bGroupSeparator) const = 0;
 
         /**
          * Parse the symbol string and pick up the file name and the external
diff --git a/sc/source/core/tool/compiler.cxx b/sc/source/core/tool/compiler.cxx
index 57880f95c140..320198151ef3 100644
--- a/sc/source/core/tool/compiler.cxx
+++ b/sc/source/core/tool/compiler.cxx
@@ -709,7 +709,8 @@ struct Convention_A1 : public ScCompiler::Convention
 
     ParseResult parseAnyToken( const OUString& rFormula,
                                sal_Int32 nSrcPos,
-                               const CharClass* pCharClass) const override
+                               const CharClass* pCharClass,
+                               bool bGroupSeparator) const override
     {
         ParseResult aRet;
         if ( lcl_isValidQuotedText(rFormula, nSrcPos, aRet) )
@@ -721,7 +722,9 @@ struct Convention_A1 : public ScCompiler::Convention
         // '?' allowed in range names because of Xcl :-/
         static const char aAddAllowed[] = "?#";
         return pCharClass->parseAnyToken( rFormula,
-                nSrcPos, nStartFlags, aAddAllowed, nContFlags, aAddAllowed );
+                nSrcPos, nStartFlags, aAddAllowed,
+                (bGroupSeparator ? nContFlags | KParseTokens::GROUP_SEPARATOR_IN_NUMBER : nContFlags),
+                aAddAllowed );
     }
 
     virtual ScCharFlags getCharTableFlags( sal_Unicode c, sal_Unicode /*cLast*/ ) const override
@@ -1317,7 +1320,8 @@ struct ConventionXL_A1 : public Convention_A1, public ConventionXL
 
     virtual ParseResult parseAnyToken( const OUString& rFormula,
                                        sal_Int32 nSrcPos,
-                                       const CharClass* pCharClass) const override
+                                       const CharClass* pCharClass,
+                                       bool bGroupSeparator) const override
     {
         parseExternalDocName(rFormula, nSrcPos);
 
@@ -1331,7 +1335,9 @@ struct ConventionXL_A1 : public Convention_A1, public ConventionXL
         // '?' allowed in range names
         const OUString aAddAllowed("?!");
         return pCharClass->parseAnyToken( rFormula,
-                nSrcPos, nStartFlags, aAddAllowed, nContFlags, aAddAllowed );
+                nSrcPos, nStartFlags, aAddAllowed,
+                (bGroupSeparator ? nContFlags | KParseTokens::GROUP_SEPARATOR_IN_NUMBER : nContFlags),
+                aAddAllowed );
     }
 
     virtual sal_Unicode getSpecialSymbol( SpecialSymbolType eSymType ) const override
@@ -1627,7 +1633,8 @@ struct ConventionXL_R1C1 : public ScCompiler::Convention, public ConventionXL
 
     ParseResult parseAnyToken( const OUString& rFormula,
                                sal_Int32 nSrcPos,
-                               const CharClass* pCharClass) const override
+                               const CharClass* pCharClass,
+                               bool bGroupSeparator) const override
     {
         parseExternalDocName(rFormula, nSrcPos);
 
@@ -1642,7 +1649,9 @@ struct ConventionXL_R1C1 : public ScCompiler::Convention, public ConventionXL
         const OUString aAddAllowed("?-[]!");
 
         return pCharClass->parseAnyToken( rFormula,
-                nSrcPos, nStartFlags, aAddAllowed, nContFlags, aAddAllowed );
+                nSrcPos, nStartFlags, aAddAllowed,
+                (bGroupSeparator ? nContFlags | KParseTokens::GROUP_SEPARATOR_IN_NUMBER : nContFlags),
+                aAddAllowed );
     }
 
     virtual sal_Unicode getSpecialSymbol( SpecialSymbolType eSymType ) const override
@@ -2632,6 +2641,17 @@ Label_MaskStateMachine:
     {
         const sal_Int32 nOldSrcPos = nSrcPos;
         nSrcPos = nSrcPos + nSpaces;
+        // If group separator is not a possible operator and not one of any
+        // separators then it may be parsed away in numbers. This is
+        // specifically the case with NO-BREAK SPACE, which actually triggers
+        // the bi18n case (which we don't want to include as yet another
+        // special case above as it is rare enough and doesn't generally occur
+        // in formulas).
+        const sal_Unicode cGroupSep = ScGlobal::pLocaleData->getNumThousandSep()[0];
+        const bool bGroupSeparator = (128 <= cGroupSep && cGroupSep != cSep &&
+                cGroupSep != cArrayColSep && cGroupSep != cArrayRowSep &&
+                cGroupSep != cDecSep && cGroupSep != cDecSepAlt &&
+                cGroupSep != cSheetPrefix && cGroupSep != cSheetSep);
         OUStringBuffer aSymbol;
         mnRangeOpPosInSymbol = -1;
         FormulaError nErr = FormulaError::NONE;
@@ -2642,7 +2662,7 @@ Label_MaskStateMachine:
             if ( pStart[nSrcPos] == cSheetPrefix && pStart[nSrcPos+1] == '\'' )
                 aSymbol.append(pStart[nSrcPos++]);
 
-            ParseResult aRes = pConv->parseAnyToken( aFormula, nSrcPos, pCharClass );
+            ParseResult aRes = pConv->parseAnyToken( aFormula, nSrcPos, pCharClass, bGroupSeparator);
 
             if ( !aRes.TokenType )
             {


More information about the Libreoffice-commits mailing list