[Libreoffice-commits] core.git: sc/qa
Eike Rathke
erack at redhat.com
Thu Mar 24 16:40:32 UTC 2016
sc/qa/unit/ucalc_formula.cxx | 38 ++++++++++++++++++++++++++++++++++++++
1 file changed, 38 insertions(+)
New commits:
commit f0cce530862e22823ae65977ea2972809237c28e
Author: Eike Rathke <erack at redhat.com>
Date: Thu Mar 24 17:38:23 2016 +0100
unit test for copying global names to sheet-local names, tdf#75372
Change-Id: Ice179cfcbb81b6455648d67e6f8aec516f7c8576
diff --git a/sc/qa/unit/ucalc_formula.cxx b/sc/qa/unit/ucalc_formula.cxx
index 5d5f3b0..8e8d092 100644
--- a/sc/qa/unit/ucalc_formula.cxx
+++ b/sc/qa/unit/ucalc_formula.cxx
@@ -3143,6 +3143,44 @@ void Test::testFormulaRefUpdateNameCopySheet()
nVal = m_pDoc->GetValue(2, 2, 0);
CPPUNIT_ASSERT_EQUAL(5.0, nVal);
+ m_pDoc->DeleteTab(2);
+ m_pDoc->DeleteTab(1);
+ m_pDoc->DeleteTab(0);
+
+ m_pDoc->InsertTab(0, "Test1");
+ // Global name referencing sheet Test1.
+ bInserted = m_pDoc->InsertNewRangeName("sheetnumber", ScAddress(0,0,0), "$Test1.$A$1");
+ CPPUNIT_ASSERT(bInserted);
+ m_pDoc->SetString(ScAddress(0,0,0), "=SHEET()");
+ m_pDoc->SetString(ScAddress(1,0,0), "=sheetnumber");
+ nVal = m_pDoc->GetValue(1,0,0);
+ CPPUNIT_ASSERT_EQUAL_MESSAGE("Sheet number should be 1", 1.0, nVal);
+
+ // Copy sheet after.
+ m_pDoc->CopyTab(0, 1);
+ nVal = m_pDoc->GetValue(1,0,1);
+ CPPUNIT_ASSERT_EQUAL_MESSAGE("New sheet number should be 2", 2.0, nVal);
+ nVal = m_pDoc->GetValue(1,0,0);
+ CPPUNIT_ASSERT_EQUAL_MESSAGE("Org sheet number should be 1", 1.0, nVal);
+ const ScRangeData* pName = m_pDoc->GetRangeName(1)->findByUpperName("SHEETNUMBER");
+ CPPUNIT_ASSERT_MESSAGE("New sheet-local name should exist", pName);
+
+ // Copy sheet before, shifting following now two sheets.
+ m_pDoc->CopyTab(0, 0);
+ nVal = m_pDoc->GetValue(1,0,0);
+ CPPUNIT_ASSERT_EQUAL_MESSAGE("New sheet number should be 1", 1.0, nVal);
+ pName = m_pDoc->GetRangeName(0)->findByUpperName("SHEETNUMBER");
+ CPPUNIT_ASSERT_MESSAGE("New sheet-local name should exist", pName);
+ nVal = m_pDoc->GetValue(1,0,1);
+ CPPUNIT_ASSERT_EQUAL_MESSAGE("Org sheet number should be 2", 2.0, nVal);
+ pName = m_pDoc->GetRangeName(1)->findByUpperName("SHEETNUMBER");
+ CPPUNIT_ASSERT_MESSAGE("Org sheet-local name should not exist", !pName);
+ nVal = m_pDoc->GetValue(1,0,2);
+ CPPUNIT_ASSERT_EQUAL_MESSAGE("Old sheet number should be 3", 3.0, nVal);
+ pName = m_pDoc->GetRangeName(2)->findByUpperName("SHEETNUMBER");
+ CPPUNIT_ASSERT_MESSAGE("Old sheet-local name should exist", pName);
+
+ m_pDoc->DeleteTab(2);
m_pDoc->DeleteTab(1);
m_pDoc->DeleteTab(0);
}
More information about the Libreoffice-commits
mailing list