summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEike Rathke <erack@redhat.com>2016-03-25 22:13:13 +0100
committerEike Rathke <erack@redhat.com>2016-03-25 22:15:04 +0100
commit19567deb49cdb4a49f251b1aacb305f68aee3c4a (patch)
treef92ab8f3eb77f964943efa0a33e84e5353244051
parent0189bfe9828c3f52cd72cf2f9da22d110e08c327 (diff)
unit test for copying sheet-local names before original position
Change-Id: I3a70539480b5b1d85b717fd6638359aa9ce5075a
-rw-r--r--sc/qa/unit/ucalc_formula.cxx33
1 files changed, 33 insertions, 0 deletions
diff --git a/sc/qa/unit/ucalc_formula.cxx b/sc/qa/unit/ucalc_formula.cxx
index 8e8d0923b927..6c1ac90f50d5 100644
--- a/sc/qa/unit/ucalc_formula.cxx
+++ b/sc/qa/unit/ucalc_formula.cxx
@@ -3183,6 +3183,39 @@ void Test::testFormulaRefUpdateNameCopySheet()
m_pDoc->DeleteTab(2);
m_pDoc->DeleteTab(1);
m_pDoc->DeleteTab(0);
+
+ m_pDoc->InsertTab(0, "Test2");
+ // Local name referencing sheet Test2.
+ bInserted = m_pDoc->GetRangeName(0)->insert( new ScRangeData( m_pDoc, "localname", "$Test2.$A$1"));
+ CPPUNIT_ASSERT(bInserted);
+ m_pDoc->SetString(ScAddress(0,0,0), "=SHEET()");
+ m_pDoc->SetString(ScAddress(1,0,0), "=localname");
+ nVal = m_pDoc->GetValue(1,0,0);
+ CPPUNIT_ASSERT_EQUAL_MESSAGE("Localname sheet number should be 1", 1.0, nVal);
+
+ // Insert sheet before and shift sheet with local name.
+ m_pDoc->InsertTab(0, "Test1");
+ pName = m_pDoc->GetRangeName(1)->findByUpperName("LOCALNAME");
+ CPPUNIT_ASSERT_MESSAGE("Org sheet-local name should exist", pName);
+ nVal = m_pDoc->GetValue(1,0,1);
+ CPPUNIT_ASSERT_EQUAL_MESSAGE("Localname sheet number should be 2", 2.0, nVal);
+
+ // Copy sheet before, shifting following now two sheets.
+ m_pDoc->CopyTab(1, 0);
+ pName = m_pDoc->GetRangeName(0)->findByUpperName("LOCALNAME");
+ CPPUNIT_ASSERT_MESSAGE("New sheet-local name should exist", pName);
+ nVal = m_pDoc->GetValue(1,0,0);
+ CPPUNIT_ASSERT_EQUAL_MESSAGE("New sheet number should be 1", 1.0, nVal);
+ pName = m_pDoc->GetRangeName(1)->findByUpperName("LOCALNAME");
+ CPPUNIT_ASSERT_MESSAGE("Old sheet-local name should not exist", !pName);
+ pName = m_pDoc->GetRangeName(2)->findByUpperName("LOCALNAME");
+ CPPUNIT_ASSERT_MESSAGE("Org sheet-local name should exist", pName);
+ nVal = m_pDoc->GetValue(1,0,2);
+ CPPUNIT_ASSERT_EQUAL_MESSAGE("New sheet number should be 3", 3.0, nVal);
+
+ m_pDoc->DeleteTab(2);
+ m_pDoc->DeleteTab(1);
+ m_pDoc->DeleteTab(0);
}
void Test::testFormulaRefUpdateNameDelete()