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

Eike Rathke erack at redhat.com
Mon Jun 29 04:51:28 PDT 2015


 sc/qa/unit/ucalc_formula.cxx |   39 +++++++++++++++++++++++++++++++++++++++
 1 file changed, 39 insertions(+)

New commits:
commit 621a7689375a4c23bb1dd23c2643c9ac42aa29a9
Author: Eike Rathke <erack at redhat.com>
Date:   Mon Jun 29 13:49:07 2015 +0200

    insert/shift unit test for tdf#44419
    
    Change-Id: If056bd05ca8895ad301a45bb078d303b56cd172a

diff --git a/sc/qa/unit/ucalc_formula.cxx b/sc/qa/unit/ucalc_formula.cxx
index c270852..0e3c63f 100644
--- a/sc/qa/unit/ucalc_formula.cxx
+++ b/sc/qa/unit/ucalc_formula.cxx
@@ -1747,6 +1747,14 @@ void Test::testFormulaRefUpdateInsertColumns()
     bool bInserted = m_pDoc->InsertNewRangeName("RowRelativeRange", aNamePos, "$Formula.$B2");
     CPPUNIT_ASSERT(bInserted);
 
+    // Set named range for entire absolute column B.
+    bInserted = m_pDoc->InsertNewRangeName("EntireColumn", aNamePos, "$B:$B");
+    CPPUNIT_ASSERT(bInserted);
+
+    // Set named range for entire absolute row 2.
+    bInserted = m_pDoc->InsertNewRangeName("EntireRow", aNamePos, "$2:$2");
+    CPPUNIT_ASSERT(bInserted);
+
     // Set values in B1:B3.
     m_pDoc->SetValue(ScAddress(1,0,0), 1.0);
     m_pDoc->SetValue(ScAddress(1,1,0), 2.0);
@@ -1760,6 +1768,14 @@ void Test::testFormulaRefUpdateInsertColumns()
     m_pDoc->SetString(ScAddress(2,1,0), "=RowRelativeRange");
     CPPUNIT_ASSERT_EQUAL(2.0, m_pDoc->GetValue(ScAddress(2,1,0)));
 
+    // Use named range in C3 to reference column B, values in B1,B2,B3,B4
+    m_pDoc->SetString(ScAddress(2,2,0), "=SUM(EntireColumn)");
+    CPPUNIT_ASSERT_EQUAL(12.0, m_pDoc->GetValue(ScAddress(2,2,0)));
+
+    // Use named range in C4 to reference row 2, values in B2 and C2.
+    m_pDoc->SetString(ScAddress(2,3,0), "=SUM(EntireRow)");
+    CPPUNIT_ASSERT_EQUAL(4.0, m_pDoc->GetValue(ScAddress(2,3,0)));
+
     // Inert columns over A:B.
     ScMarkData aMark;
     aMark.SelectOneTable(0);
@@ -1784,6 +1800,29 @@ void Test::testFormulaRefUpdateInsertColumns()
         CPPUNIT_FAIL("Wrong formula in E2 after column insertion.");
     CPPUNIT_ASSERT_EQUAL(2.0, m_pDoc->GetValue(ScAddress(4,1,0)));
 
+    // Check that the named column reference points to the moved column, now D.
+    pName = m_pDoc->GetRangeName()->findByUpperName("ENTIRECOLUMN");
+    CPPUNIT_ASSERT(pName);
+    pName->GetSymbol(aSymbol, aNamePos, formula::FormulaGrammar::GRAM_ENGLISH);
+    CPPUNIT_ASSERT_EQUAL(OUString("$D:$D"), aSymbol);
+
+    // Check that the formula using the name, now in E3, still has the same result.
+    if (!checkFormula(*m_pDoc, ScAddress(4,2,0), "SUM(EntireColumn)"))
+        CPPUNIT_FAIL("Wrong formula in E3 after column insertion.");
+    CPPUNIT_ASSERT_EQUAL(12.0, m_pDoc->GetValue(ScAddress(4,2,0)));
+
+    // Check that the named row reference still points to the same entire row
+    // and does not have a #REF! error due to inserted columns.
+    pName = m_pDoc->GetRangeName()->findByUpperName("ENTIREROW");
+    CPPUNIT_ASSERT(pName);
+    pName->GetSymbol(aSymbol, aNamePos, formula::FormulaGrammar::GRAM_ENGLISH);
+    CPPUNIT_ASSERT_EQUAL(OUString("$2:$2"), aSymbol);
+
+    // Check that the formula using the name, now in E4, still has the same result.
+    if (!checkFormula(*m_pDoc, ScAddress(4,3,0), "SUM(EntireRow)"))
+        CPPUNIT_FAIL("Wrong formula in E4 after column insertion.");
+    CPPUNIT_ASSERT_EQUAL(4.0, m_pDoc->GetValue(ScAddress(4,3,0)));
+
     m_pDoc->DeleteTab(0);
 }
 


More information about the Libreoffice-commits mailing list