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

Eike Rathke erack at redhat.com
Thu Nov 12 14:34:19 PST 2015


 sc/source/filter/xml/XMLConverter.cxx |   32 ++++++++++++--------------------
 sc/source/filter/xml/XMLConverter.hxx |    5 ++---
 sc/source/filter/xml/xmlimprt.cxx     |    2 +-
 3 files changed, 15 insertions(+), 24 deletions(-)

New commits:
commit 41379970e8c6b75563b7c162b4e760b9e93a5bea
Author: Eike Rathke <erack at redhat.com>
Date:   Thu Nov 12 23:30:11 2015 +0100

    while at it, avoid repeated operator[] access
    
    Change-Id: Iff569f738252492df66a7c9cee654fc58ec67c98

diff --git a/sc/source/filter/xml/XMLConverter.cxx b/sc/source/filter/xml/XMLConverter.cxx
index 46d4f0e..1e5eaf1 100644
--- a/sc/source/filter/xml/XMLConverter.cxx
+++ b/sc/source/filter/xml/XMLConverter.cxx
@@ -284,16 +284,19 @@ void ScXMLConverter::ConvertCellRangeAddress(OUString& sFormula)
     OUStringBuffer sBuffer(sFormula.getLength());
     bool bInQuotationMarks(false);
     sal_Unicode chPrevious('=');
-    for (sal_Int32 i = 0; i < sFormula.getLength(); ++i)
+    const sal_Unicode* p = sFormula.getStr();
+    const sal_Unicode* const pStop = p + sFormula.getLength();
+    for ( ; p < pStop; ++p)
     {
-        if (sFormula[i] == '\'')
+        const sal_Unicode c = *p;
+        if (c == '\'')
             bInQuotationMarks = !bInQuotationMarks;
         if (bInQuotationMarks)
-            sBuffer.append(sFormula[i]);
-        else if ((sFormula[i] != '.') ||
+            sBuffer.append(c);
+        else if ((c != '.') ||
                 !((chPrevious == ':') || (chPrevious == ' ') || (chPrevious == '=')))
-                sBuffer.append(sFormula[i]);
-        chPrevious = sFormula[i];
+            sBuffer.append(c);
+        chPrevious = c;
     }
 
     sFormula = sBuffer.makeStringAndClear();
commit dec711e655bb07d2fc217a2fe038f7a8f0fa6be3
Author: Eike Rathke <erack at redhat.com>
Date:   Thu Nov 12 23:09:27 2015 +0100

    in a cellRangeAddress single quotes are escaped by doubling them
    
    ... and not by prefixing them with a backslash, geez..
    
    Change-Id: Ic088967fc2d9004ab5cc8d917253cc262edba7c9

diff --git a/sc/source/filter/xml/XMLConverter.cxx b/sc/source/filter/xml/XMLConverter.cxx
index ad4b8f1..46d4f0e 100644
--- a/sc/source/filter/xml/XMLConverter.cxx
+++ b/sc/source/filter/xml/XMLConverter.cxx
@@ -286,7 +286,7 @@ void ScXMLConverter::ConvertCellRangeAddress(OUString& sFormula)
     sal_Unicode chPrevious('=');
     for (sal_Int32 i = 0; i < sFormula.getLength(); ++i)
     {
-        if (sFormula[i] == '\'' && chPrevious != '\\')
+        if (sFormula[i] == '\'')
             bInQuotationMarks = !bInQuotationMarks;
         if (bInQuotationMarks)
             sBuffer.append(sFormula[i]);
commit ce87e82dc5c78a5a3cc174a94c11825eb674d638
Author: Eike Rathke <erack at redhat.com>
Date:   Thu Nov 12 22:58:00 2015 +0100

    there are also no significant double quotes in an ODF cellRangeAddress
    
    Change-Id: I13d33ec64b3bf61fb6ee6e392abd97dc39bcd18d

diff --git a/sc/source/filter/xml/XMLConverter.cxx b/sc/source/filter/xml/XMLConverter.cxx
index 50a1526..ad4b8f1 100644
--- a/sc/source/filter/xml/XMLConverter.cxx
+++ b/sc/source/filter/xml/XMLConverter.cxx
@@ -283,16 +283,12 @@ void ScXMLConverter::ConvertCellRangeAddress(OUString& sFormula)
 {
     OUStringBuffer sBuffer(sFormula.getLength());
     bool bInQuotationMarks(false);
-    bool bInDoubleQuotationMarks(false);
     sal_Unicode chPrevious('=');
     for (sal_Int32 i = 0; i < sFormula.getLength(); ++i)
     {
-        if (sFormula[i] == '\'' && !bInDoubleQuotationMarks &&
-            chPrevious != '\\')
+        if (sFormula[i] == '\'' && chPrevious != '\\')
             bInQuotationMarks = !bInQuotationMarks;
-        else if (sFormula[i] == '"' && !bInQuotationMarks)
-            bInDoubleQuotationMarks = !bInDoubleQuotationMarks;
-        if (bInQuotationMarks || bInDoubleQuotationMarks)
+        if (bInQuotationMarks)
             sBuffer.append(sFormula[i]);
         else if ((sFormula[i] != '.') ||
                 !((chPrevious == ':') || (chPrevious == ' ') || (chPrevious == '=')))
commit 8acf24d89235675cdd3ab4c819b580d943f740f9
Author: Eike Rathke <erack at redhat.com>
Date:   Thu Nov 12 22:48:30 2015 +0100

    there are no significant brackets in an ODF cellRangeAddress
    
    Change-Id: Id606fb432073b37354f37ace05a3574ab00e1fa7

diff --git a/sc/source/filter/xml/XMLConverter.cxx b/sc/source/filter/xml/XMLConverter.cxx
index 6be03e6..50a1526 100644
--- a/sc/source/filter/xml/XMLConverter.cxx
+++ b/sc/source/filter/xml/XMLConverter.cxx
@@ -284,7 +284,6 @@ void ScXMLConverter::ConvertCellRangeAddress(OUString& sFormula)
     OUStringBuffer sBuffer(sFormula.getLength());
     bool bInQuotationMarks(false);
     bool bInDoubleQuotationMarks(false);
-    sal_Int16 nCountBraces(0);
     sal_Unicode chPrevious('=');
     for (sal_Int32 i = 0; i < sFormula.getLength(); ++i)
     {
@@ -295,17 +294,12 @@ void ScXMLConverter::ConvertCellRangeAddress(OUString& sFormula)
             bInDoubleQuotationMarks = !bInDoubleQuotationMarks;
         if (bInQuotationMarks || bInDoubleQuotationMarks)
             sBuffer.append(sFormula[i]);
-        else if (sFormula[i] == '[')
-            ++nCountBraces;
-        else if (sFormula[i] == ']')
-            nCountBraces--;
         else if ((sFormula[i] != '.') ||
-                !((chPrevious == '[') || (chPrevious == ':') || (chPrevious == ' ') || (chPrevious == '=')))
+                !((chPrevious == ':') || (chPrevious == ' ') || (chPrevious == '=')))
                 sBuffer.append(sFormula[i]);
         chPrevious = sFormula[i];
     }
 
-    OSL_ENSURE(nCountBraces == 0, "there are some braces still open");
     sFormula = sBuffer.makeStringAndClear();
 }
 
commit c28055eb913e3e072156d47081b3c1bf680df65a
Author: Eike Rathke <erack at redhat.com>
Date:   Thu Nov 12 22:38:18 2015 +0100

    remove bIsFormula parameter, it was always false
    
    Change-Id: Ie1554cf59e0aff3e0975941fad7f99b4aba9ba7d

diff --git a/sc/source/filter/xml/XMLConverter.cxx b/sc/source/filter/xml/XMLConverter.cxx
index 59369eb..6be03e6 100644
--- a/sc/source/filter/xml/XMLConverter.cxx
+++ b/sc/source/filter/xml/XMLConverter.cxx
@@ -279,7 +279,7 @@ void ScXMLConverter::GetStringFromDetOpType(
     ScRangeStringConverter::AssignString( rString, sTypeStr, bAppendStr );
 }
 
-void ScXMLConverter::ConvertCellRangeAddress(OUString& sFormula, const bool bIsFormula)
+void ScXMLConverter::ConvertCellRangeAddress(OUString& sFormula)
 {
     OUStringBuffer sBuffer(sFormula.getLength());
     bool bInQuotationMarks(false);
@@ -300,7 +300,6 @@ void ScXMLConverter::ConvertCellRangeAddress(OUString& sFormula, const bool bIsF
         else if (sFormula[i] == ']')
             nCountBraces--;
         else if ((sFormula[i] != '.') ||
-                ((nCountBraces == 0) && bIsFormula) ||
                 !((chPrevious == '[') || (chPrevious == ':') || (chPrevious == ' ') || (chPrevious == '=')))
                 sBuffer.append(sFormula[i]);
         chPrevious = sFormula[i];
diff --git a/sc/source/filter/xml/XMLConverter.hxx b/sc/source/filter/xml/XMLConverter.hxx
index 49d627b..d249a7d 100644
--- a/sc/source/filter/xml/XMLConverter.hxx
+++ b/sc/source/filter/xml/XMLConverter.hxx
@@ -92,8 +92,7 @@ public:
 
 // IMPORT: Formulas
     static void         ConvertCellRangeAddress(
-                            OUString& sFormula,
-                            const bool bIsFormula = true);
+                            OUString& sFormula);
 // EXPORT: Core Date Time
     static void         ConvertDateTimeToString(const DateTime& aDateTime, OUStringBuffer& sDate);
 
diff --git a/sc/source/filter/xml/xmlimprt.cxx b/sc/source/filter/xml/xmlimprt.cxx
index 9fd8cbb..9e38457 100644
--- a/sc/source/filter/xml/xmlimprt.cxx
+++ b/sc/source/filter/xml/xmlimprt.cxx
@@ -3126,7 +3126,7 @@ public:
             {
                 OUString aContent = p->sContent;
                 if (!p->bIsExpression)
-                    ScXMLConverter::ConvertCellRangeAddress(aContent, false);
+                    ScXMLConverter::ConvertCellRangeAddress(aContent);
 
                 ScRangeData* pData = new ScRangeData(
                     mpDoc, p->sName, aContent, aPos, nNewType, p->eGrammar);
commit 7d116f64e558e8bcecdc1d261c569e69e612ff5b
Author: Eike Rathke <erack at redhat.com>
Date:   Thu Nov 12 22:33:30 2015 +0100

    name this what it does
    
    Change-Id: I24170e7959c3e72ade3cdb86a9e28b60f28cd4dd

diff --git a/sc/source/filter/xml/XMLConverter.cxx b/sc/source/filter/xml/XMLConverter.cxx
index 4a94d38..59369eb 100644
--- a/sc/source/filter/xml/XMLConverter.cxx
+++ b/sc/source/filter/xml/XMLConverter.cxx
@@ -279,7 +279,7 @@ void ScXMLConverter::GetStringFromDetOpType(
     ScRangeStringConverter::AssignString( rString, sTypeStr, bAppendStr );
 }
 
-void ScXMLConverter::ParseFormula(OUString& sFormula, const bool bIsFormula)
+void ScXMLConverter::ConvertCellRangeAddress(OUString& sFormula, const bool bIsFormula)
 {
     OUStringBuffer sBuffer(sFormula.getLength());
     bool bInQuotationMarks(false);
diff --git a/sc/source/filter/xml/XMLConverter.hxx b/sc/source/filter/xml/XMLConverter.hxx
index b150da7..49d627b 100644
--- a/sc/source/filter/xml/XMLConverter.hxx
+++ b/sc/source/filter/xml/XMLConverter.hxx
@@ -91,7 +91,7 @@ public:
                             bool bAppendStr = false );
 
 // IMPORT: Formulas
-    static void         ParseFormula(
+    static void         ConvertCellRangeAddress(
                             OUString& sFormula,
                             const bool bIsFormula = true);
 // EXPORT: Core Date Time
diff --git a/sc/source/filter/xml/xmlimprt.cxx b/sc/source/filter/xml/xmlimprt.cxx
index bbcdbca..9fd8cbb 100644
--- a/sc/source/filter/xml/xmlimprt.cxx
+++ b/sc/source/filter/xml/xmlimprt.cxx
@@ -3126,7 +3126,7 @@ public:
             {
                 OUString aContent = p->sContent;
                 if (!p->bIsExpression)
-                    ScXMLConverter::ParseFormula(aContent, false);
+                    ScXMLConverter::ConvertCellRangeAddress(aContent, false);
 
                 ScRangeData* pData = new ScRangeData(
                     mpDoc, p->sName, aContent, aPos, nNewType, p->eGrammar);


More information about the Libreoffice-commits mailing list