From 7b3e0aa8ad02c12706547616d7a5fd695bf0d75c Mon Sep 17 00:00:00 2001 From: Markus Mohrhard Date: Thu, 15 Oct 2015 19:27:58 +0200 Subject: add test for tdf#88179 Change-Id: I8407a05e89129b533f62439d3ffedecd3248ec87 --- sc/qa/unit/ucalc.hxx | 2 ++ sc/qa/unit/ucalc_formula.cxx | 31 +++++++++++++++++++++++++++++++ 2 files changed, 33 insertions(+) (limited to 'sc/qa') diff --git a/sc/qa/unit/ucalc.hxx b/sc/qa/unit/ucalc.hxx index 9e9a934f8a7f..eb8e047af1e7 100644 --- a/sc/qa/unit/ucalc.hxx +++ b/sc/qa/unit/ucalc.hxx @@ -195,6 +195,7 @@ public: void testExternalRef(); void testExternalRefFunctions(); + void testExternalRangeName(); void testCopyToDocument(); @@ -531,6 +532,7 @@ public: CPPUNIT_TEST(testFuncLCM); CPPUNIT_TEST(testFuncSUMSQ); CPPUNIT_TEST(testExternalRef); + CPPUNIT_TEST(testExternalRangeName); CPPUNIT_TEST(testExternalRefFunctions); CPPUNIT_TEST(testCopyToDocument); CPPUNIT_TEST(testFuncSHEET); diff --git a/sc/qa/unit/ucalc_formula.cxx b/sc/qa/unit/ucalc_formula.cxx index c631e1e36018..0badcac64f44 100644 --- a/sc/qa/unit/ucalc_formula.cxx +++ b/sc/qa/unit/ucalc_formula.cxx @@ -5157,6 +5157,37 @@ void Test::testExternalRef() m_pDoc->DeleteTab(0); } +void Test::testExternalRangeName() +{ + ScDocShellRef xExtDocSh = new ScDocShell; + OUString aExtDocName("file:///extdata.fake"); + OUString aExtSh1Name("Data1"); + SfxMedium* pMed = new SfxMedium(aExtDocName, STREAM_STD_READWRITE); + xExtDocSh->DoInitNew(pMed); + CPPUNIT_ASSERT_MESSAGE("external document instance not loaded.", + findLoadedDocShellByName(aExtDocName) != NULL); + + ScDocument& rExtDoc = xExtDocSh->GetDocument(); + rExtDoc.InsertTab(0, aExtSh1Name); + rExtDoc.SetValue(0, 0, 0, 123.456); + + ScRangeName* pRangeName = rExtDoc.GetRangeName(); + ScRangeData* pRangeData = new ScRangeData(&rExtDoc, "ExternalName", + "$Data1.$A$1"); + pRangeName->insert(pRangeData); + + m_pDoc->InsertTab(0, "Test Sheet"); + m_pDoc->SetString(0, 1, 0, OUString("='file:///extdata.fake'#ExternalName")); + + double nVal = m_pDoc->GetValue(0, 1, 0); + ASSERT_DOUBLES_EQUAL(123.456, nVal); + + xExtDocSh->DoClose(); + CPPUNIT_ASSERT_MESSAGE("external document instance should have been unloaded.", + findLoadedDocShellByName(aExtDocName) == NULL); + m_pDoc->DeleteTab(0); +} + void testExtRefFuncT(ScDocument* pDoc, ScDocument& rExtDoc) { Test::clearRange(pDoc, ScRange(0, 0, 0, 1, 9, 0)); -- cgit