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

Eike Rathke erack at redhat.com
Wed Aug 26 04:16:38 PDT 2015


 sc/qa/unit/ucalc_formula.cxx    |   33 +++++++++++++++++++++++++++++++++
 sc/source/core/tool/address.cxx |    2 +-
 2 files changed, 34 insertions(+), 1 deletion(-)

New commits:
commit 18a2a642c4a8848e2a2cb0df29c6463db8428ef9
Author: Eike Rathke <erack at redhat.com>
Date:   Wed Aug 26 13:14:45 2015 +0200

    unit test that parsing range fragments should fail
    
    Change-Id: Iff5ef2a5b2315b19cf8f0e84a08c776c3c97e0ae

diff --git a/sc/qa/unit/ucalc_formula.cxx b/sc/qa/unit/ucalc_formula.cxx
index 8a5d766..0e379f1 100644
--- a/sc/qa/unit/ucalc_formula.cxx
+++ b/sc/qa/unit/ucalc_formula.cxx
@@ -321,6 +321,39 @@ void Test::testFormulaParseReference()
     CPPUNIT_ASSERT_MESSAGE("This is not an external address.", !aExtInfo.mbExternal);
 
     ScRange aRange;
+
+    aRange.aStart.SetTab(0);
+    nRes = aRange.Parse(":B", m_pDoc, formula::FormulaGrammar::CONV_OOO);
+    CPPUNIT_ASSERT_MESSAGE("Should fail to parse.", (nRes & SCA_VALID) == 0);
+
+    aRange.aStart.SetTab(0);
+    nRes = aRange.Parse("B:", m_pDoc, formula::FormulaGrammar::CONV_OOO);
+    CPPUNIT_ASSERT_MESSAGE("Should fail to parse.", (nRes & SCA_VALID) == 0);
+
+    aRange.aStart.SetTab(0);
+    nRes = aRange.Parse(":B2", m_pDoc, formula::FormulaGrammar::CONV_OOO);
+    CPPUNIT_ASSERT_MESSAGE("Should fail to parse.", (nRes & SCA_VALID) == 0);
+
+    aRange.aStart.SetTab(0);
+    nRes = aRange.Parse("B2:", m_pDoc, formula::FormulaGrammar::CONV_OOO);
+    CPPUNIT_ASSERT_MESSAGE("Should fail to parse.", (nRes & SCA_VALID) == 0);
+
+    aRange.aStart.SetTab(0);
+    nRes = aRange.Parse(":2", m_pDoc, formula::FormulaGrammar::CONV_OOO);
+    CPPUNIT_ASSERT_MESSAGE("Should fail to parse.", (nRes & SCA_VALID) == 0);
+
+    aRange.aStart.SetTab(0);
+    nRes = aRange.Parse("2:", m_pDoc, formula::FormulaGrammar::CONV_OOO);
+    CPPUNIT_ASSERT_MESSAGE("Should fail to parse.", (nRes & SCA_VALID) == 0);
+
+    aRange.aStart.SetTab(0);
+    nRes = aRange.Parse(":2B", m_pDoc, formula::FormulaGrammar::CONV_OOO);
+    CPPUNIT_ASSERT_MESSAGE("Should fail to parse.", (nRes & SCA_VALID) == 0);
+
+    aRange.aStart.SetTab(0);
+    nRes = aRange.Parse("2B:", m_pDoc, formula::FormulaGrammar::CONV_OOO);
+    CPPUNIT_ASSERT_MESSAGE("Should fail to parse.", (nRes & SCA_VALID) == 0);
+
     aRange.aStart.SetTab(0);
     nRes = aRange.Parse("B:B", m_pDoc, formula::FormulaGrammar::CONV_OOO);
     CPPUNIT_ASSERT_MESSAGE("Failed to parse.", (nRes & SCA_VALID) != 0);
commit ed6209f572bad38bdb066be668163fe8acf52056
Author: Eike Rathke <erack at redhat.com>
Date:   Wed Aug 26 13:06:05 2015 +0200

    do not parse range fragments as valid ranges
    
    For example, "B2:" or ":B2" were accepted as valid range, with the
    missing part set to A1, which resulted in a A1:B2 range.
    
    An omitted sheet specifier always results in a valid relative sheet,
    hence that flag is set, so testing flags for non-null before the final
    result is available isn't sufficient.
    
    Change-Id: I57d1b7cf71a298e7ac108b0e13aab88208f0f00c

diff --git a/sc/source/core/tool/address.cxx b/sc/source/core/tool/address.cxx
index 81e4047..da7a195 100644
--- a/sc/source/core/tool/address.cxx
+++ b/sc/source/core/tool/address.cxx
@@ -1505,7 +1505,7 @@ static sal_uInt16 lcl_ScRange_Parse_OOo( ScRange& rRange,
                     nRes2 |= SCA_COL_ABSOLUTE;
                 }
             }
-            if (nRes1 && nRes2)
+            if ((nRes1 & SCA_VALID) && (nRes2 & SCA_VALID))
             {
                 // PutInOrder / Justify
                 sal_uInt16 nMask, nBits1, nBits2;


More information about the Libreoffice-commits mailing list