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

Markus Mohrhard markus.mohrhard at googlemail.com
Thu Mar 16 21:02:07 UTC 2017


 sc/qa/unit/ucalc.hxx             |    4 +++
 sc/qa/unit/ucalc_condformat.cxx  |   40 +++++++++++++++++++++++++++++++++++++++
 sc/source/core/data/conditio.cxx |    6 ++---
 3 files changed, 47 insertions(+), 3 deletions(-)

New commits:
commit ad9336f29650dc38be06d771f5c3dbc7f0078ff1
Author: Markus Mohrhard <markus.mohrhard at googlemail.com>
Date:   Thu Mar 16 20:07:04 2017 +0100

    add tests for tdf#104026
    
    Change-Id: I928828f5f3ee22429e174e6e761d6683a36fdb24
    Reviewed-on: https://gerrit.libreoffice.org/35290
    Tested-by: Jenkins <ci at libreoffice.org>
    Reviewed-by: Markus Mohrhard <markus.mohrhard at googlemail.com>

diff --git a/sc/qa/unit/ucalc.hxx b/sc/qa/unit/ucalc.hxx
index 076e5b0e404a..92f0d6dd04d5 100644
--- a/sc/qa/unit/ucalc.hxx
+++ b/sc/qa/unit/ucalc.hxx
@@ -485,6 +485,8 @@ public:
     void testCondFormatUpdateDeleteTab();
     void testCondFormatUpdateInsertTab();
     void testCondFormatUpdateReference();
+    void testCondFormatUpdateReferenceDelRow();
+    void testCondFormatUpdateReferenceInsRow();
 
     void testCondFormatEndsWithStr();
     void testCondFormatEndsWithVal();
@@ -745,6 +747,8 @@ public:
     CPPUNIT_TEST(testCondCopyPasteSheet);
     CPPUNIT_TEST(testCondFormatEndsWithStr);
     CPPUNIT_TEST(testCondFormatEndsWithVal);
+    CPPUNIT_TEST(testCondFormatUpdateReferenceDelRow);
+    CPPUNIT_TEST(testCondFormatUpdateReferenceInsRow);
     CPPUNIT_TEST(testIconSet);
     CPPUNIT_TEST(testDataBarLengthAutomaticAxis);
     CPPUNIT_TEST(testDataBarLengthMiddleAxis);
diff --git a/sc/qa/unit/ucalc_condformat.cxx b/sc/qa/unit/ucalc_condformat.cxx
index 47230e100aac..ee0d8abee066 100644
--- a/sc/qa/unit/ucalc_condformat.cxx
+++ b/sc/qa/unit/ucalc_condformat.cxx
@@ -875,4 +875,44 @@ void Test::testCondFormatUpdateReference()
     m_pDoc->DeleteTab(0);
 }
 
+void Test::testCondFormatUpdateReferenceDelRow()
+{
+    m_pDoc->InsertTab(0, "test");
+
+    ScConditionEntry* pEntry = new ScConditionEntry(SC_COND_EQUAL, "B6", "", m_pDoc, ScAddress(0, 5, 0), "", "", formula::FormulaGrammar::GRAM_DEFAULT, formula::FormulaGrammar::GRAM_DEFAULT);
+
+    ScConditionalFormat* pFormat = new ScConditionalFormat(0, m_pDoc);
+    pFormat->SetRange(ScRange(0, 5, 0, 0, 5, 0));
+    m_pDoc->AddCondFormat(pFormat, 0);
+
+    pFormat->AddEntry(pEntry);
+
+    m_pDoc->DeleteRow(0, 0, MAXCOL, 0, 4, 1);
+
+    OUString aStr = pEntry->GetExpression(ScAddress(0, 4, 0), 0);
+    CPPUNIT_ASSERT_EQUAL(OUString("B5"), aStr);
+
+    m_pDoc->DeleteTab(0);
+}
+
+void Test::testCondFormatUpdateReferenceInsRow()
+{
+    m_pDoc->InsertTab(0, "test");
+
+    ScConditionEntry* pEntry = new ScConditionEntry(SC_COND_EQUAL, "B6", "", m_pDoc, ScAddress(0, 5, 0), "", "", formula::FormulaGrammar::GRAM_DEFAULT, formula::FormulaGrammar::GRAM_DEFAULT);
+
+    ScConditionalFormat* pFormat = new ScConditionalFormat(0, m_pDoc);
+    pFormat->SetRange(ScRange(0, 5, 0, 0, 5, 0));
+    m_pDoc->AddCondFormat(pFormat, 0);
+
+    pFormat->AddEntry(pEntry);
+
+    m_pDoc->InsertRow(0, 0, MAXCOL, 0, 4, 1);
+
+    OUString aStr = pEntry->GetExpression(ScAddress(0, 6, 0), 0);
+    CPPUNIT_ASSERT_EQUAL(OUString("B7"), aStr);
+
+    m_pDoc->DeleteTab(0);
+}
+
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
commit 3f0f35c89f3f64fcb110483fd562a59f729dc344
Author: Markus Mohrhard <markus.mohrhard at googlemail.com>
Date:   Thu Mar 16 20:08:30 2017 +0100

    the range should be updated after the references, tdf#104026
    
    Change-Id: I2cb674b8b3bc64df031b473b337d266a2eaab43d
    Reviewed-on: https://gerrit.libreoffice.org/35289
    Tested-by: Jenkins <ci at libreoffice.org>
    Reviewed-by: Markus Mohrhard <markus.mohrhard at googlemail.com>

diff --git a/sc/source/core/data/conditio.cxx b/sc/source/core/data/conditio.cxx
index 6657dcf37608..f4f0f116ba61 100644
--- a/sc/source/core/data/conditio.cxx
+++ b/sc/source/core/data/conditio.cxx
@@ -1926,13 +1926,13 @@ void ScConditionalFormat::CompileXML()
 
 void ScConditionalFormat::UpdateReference( sc::RefUpdateContext& rCxt, bool bCopyAsMove )
 {
+    for(CondFormatContainer::iterator itr = maEntries.begin(); itr != maEntries.end(); ++itr)
+        (*itr)->UpdateReference(rCxt);
+
     if (rCxt.meMode == URM_COPY && bCopyAsMove)
         maRanges.UpdateReference(URM_MOVE, pDoc, rCxt.maRange, rCxt.mnColDelta, rCxt.mnRowDelta, rCxt.mnTabDelta);
     else
         maRanges.UpdateReference(rCxt.meMode, pDoc, rCxt.maRange, rCxt.mnColDelta, rCxt.mnRowDelta, rCxt.mnTabDelta);
-
-    for(CondFormatContainer::iterator itr = maEntries.begin(); itr != maEntries.end(); ++itr)
-        (*itr)->UpdateReference(rCxt);
 }
 
 void ScConditionalFormat::InsertRow(SCTAB nTab, SCCOL nColStart, SCCOL nColEnd, SCROW nRowPos, SCSIZE nSize)


More information about the Libreoffice-commits mailing list