add test for tdf#88179

Change-Id: I8407a05e89129b533f62439d3ffedecd3248ec87
This commit is contained in:
Markus Mohrhard 2015-10-15 19:27:58 +02:00
parent 65dedbd9c7
commit 7b3e0aa8ad
2 changed files with 33 additions and 0 deletions

View file

@ -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);

View file

@ -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));