summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEike Rathke <erack@redhat.com>2016-03-18 16:34:57 +0100
committerEike Rathke <erack@redhat.com>2016-03-18 16:36:30 +0100
commit51bd0c6b8f7bcaabecbda467285d6ffb9a73382b (patch)
treec8431e8652402405a46f4e48639d9906d1651d63
parent8d515ccd7c25120ee1f8d6d5494c8853f1268162 (diff)
unit test for other-sheet-local names, tdf#96915
Change-Id: Iee3edb4603830a4912cda5c1f16029560be04857
-rw-r--r--sc/qa/unit/ucalc.cxx26
1 files changed, 26 insertions, 0 deletions
diff --git a/sc/qa/unit/ucalc.cxx b/sc/qa/unit/ucalc.cxx
index d97e92f17d33..476ba3eb5ee3 100644
--- a/sc/qa/unit/ucalc.cxx
+++ b/sc/qa/unit/ucalc.cxx
@@ -1732,6 +1732,32 @@ void Test::testNamedRange()
CPPUNIT_ASSERT_MESSAGE("wrong range name is retrieved with the copied instance.", aName.equalsAscii(aNames[i].mpName));
}
+ // Test using an other-sheet-local name, scope Sheet1.
+ ScRangeData* pLocal1 = new ScRangeData( m_pDoc, "local1", ScAddress(0,0,0));
+ ScRangeData* pLocal2 = new ScRangeData( m_pDoc, "local2", "$Sheet1.$A$1");
+ ScRangeData* pLocal3 = new ScRangeData( m_pDoc, "local3", "Sheet1.$A$1");
+ ScRangeData* pLocal4 = new ScRangeData( m_pDoc, "local4", "$A$1"); // implicit relative sheet reference
+ ScRangeName* pLocalRangeName1 = new ScRangeName;
+ pLocalRangeName1->insert(pLocal1);
+ pLocalRangeName1->insert(pLocal2);
+ pLocalRangeName1->insert(pLocal3);
+ pLocalRangeName1->insert(pLocal4);
+ m_pDoc->SetRangeName(0, pLocalRangeName1);
+
+ CPPUNIT_ASSERT_MESSAGE ("failed to insert sheet", m_pDoc->InsertTab (1, "Sheet2"));
+
+ // Use other-sheet-local name of Sheet1 on Sheet2.
+ ScAddress aPos(1,0,1);
+ OUString aFormula("=Sheet1.local1+Sheet1.local2+Sheet1.local3+Sheet1.local4");
+ m_pDoc->SetString(aPos, aFormula);
+ OUString aString;
+ m_pDoc->GetFormula(1,0,1, aString);
+ CPPUNIT_ASSERT_EQUAL_MESSAGE("formula string should be equal", aFormula, aString);
+ double fValue = m_pDoc->GetValue(aPos);
+ ASSERT_DOUBLES_EQUAL_MESSAGE("value should be 4 times Sheet1.A1", 404.0, fValue);
+
+ m_pDoc->DeleteTab(1);
+ m_pDoc->SetRangeName(0,nullptr); // Delete the names.
m_pDoc->SetRangeName(nullptr); // Delete the names.
m_pDoc->DeleteTab(0);
}