Unit test for cell function T with external references.
This commit is contained in:
parent
f7831ed5ca
commit
a725d287a2
3 changed files with 38 additions and 2 deletions
|
@ -596,6 +596,7 @@ public:
|
||||||
|
|
||||||
const ::rtl::OUString* getRealTableName(sal_uInt16 nFileId, const ::rtl::OUString& rTabName) const;
|
const ::rtl::OUString* getRealTableName(sal_uInt16 nFileId, const ::rtl::OUString& rTabName) const;
|
||||||
const ::rtl::OUString* getRealRangeName(sal_uInt16 nFileId, const ::rtl::OUString& rRangeName) const;
|
const ::rtl::OUString* getRealRangeName(sal_uInt16 nFileId, const ::rtl::OUString& rRangeName) const;
|
||||||
|
void clearCache(sal_uInt16 nFileId);
|
||||||
void refreshNames(sal_uInt16 nFileId);
|
void refreshNames(sal_uInt16 nFileId);
|
||||||
void breakLink(sal_uInt16 nFileId);
|
void breakLink(sal_uInt16 nFileId);
|
||||||
void switchSrcFile(sal_uInt16 nFileId, const ::rtl::OUString& rNewFile, const ::rtl::OUString& rNewFilter);
|
void switchSrcFile(sal_uInt16 nFileId, const ::rtl::OUString& rNewFile, const ::rtl::OUString& rNewFilter);
|
||||||
|
|
|
@ -1846,6 +1846,27 @@ void Test::testExternalRef()
|
||||||
m_pDoc->DeleteTab(0);
|
m_pDoc->DeleteTab(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void testExtRefFuncT(ScDocument* pDoc, ScDocument* pExtDoc)
|
||||||
|
{
|
||||||
|
clearRange(pDoc, ScRange(0, 0, 0, 1, 9, 0));
|
||||||
|
clearRange(pExtDoc, ScRange(0, 0, 0, 1, 9, 0));
|
||||||
|
|
||||||
|
pExtDoc->SetString(0, 0, 0, rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("'1.2")));
|
||||||
|
pExtDoc->SetString(0, 1, 0, rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Foo")));
|
||||||
|
pExtDoc->SetValue(0, 2, 0, 12.3);
|
||||||
|
pDoc->SetString(0, 0, 0, rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("=T('file:///extdata.fake'#Data.A1)")));
|
||||||
|
pDoc->SetString(0, 1, 0, rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("=T('file:///extdata.fake'#Data.A2)")));
|
||||||
|
pDoc->SetString(0, 2, 0, rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("=T('file:///extdata.fake'#Data.A3)")));
|
||||||
|
pDoc->CalcAll();
|
||||||
|
|
||||||
|
rtl::OUString aRes = pDoc->GetString(0, 0, 0);
|
||||||
|
CPPUNIT_ASSERT_MESSAGE("Unexpected result with T.", aRes.equalsAscii("1.2"));
|
||||||
|
aRes = pDoc->GetString(0, 1, 0);
|
||||||
|
CPPUNIT_ASSERT_MESSAGE("Unexpected result with T.", aRes.equalsAscii("Foo"));
|
||||||
|
aRes = pDoc->GetString(0, 2, 0);
|
||||||
|
CPPUNIT_ASSERT_MESSAGE("Unexpected result with T.", aRes.isEmpty());
|
||||||
|
}
|
||||||
|
|
||||||
void Test::testExternalRefFunctions()
|
void Test::testExternalRefFunctions()
|
||||||
{
|
{
|
||||||
ScDocShellRef xExtDocSh = new ScDocShell;
|
ScDocShellRef xExtDocSh = new ScDocShell;
|
||||||
|
@ -1855,6 +1876,13 @@ void Test::testExternalRefFunctions()
|
||||||
CPPUNIT_ASSERT_MESSAGE("external document instance not loaded.",
|
CPPUNIT_ASSERT_MESSAGE("external document instance not loaded.",
|
||||||
findLoadedDocShellByName(aExtDocName) != NULL);
|
findLoadedDocShellByName(aExtDocName) != NULL);
|
||||||
|
|
||||||
|
ScExternalRefManager* pRefMgr = m_pDoc->GetExternalRefManager();
|
||||||
|
CPPUNIT_ASSERT_MESSAGE("external reference manager doesn't exist.", pRefMgr);
|
||||||
|
sal_uInt16 nFileId = pRefMgr->getExternalFileId(aExtDocName);
|
||||||
|
const OUString* pFileName = pRefMgr->getExternalFileName(nFileId);
|
||||||
|
CPPUNIT_ASSERT_MESSAGE("file name registration has somehow failed.",
|
||||||
|
pFileName && pFileName->equals(aExtDocName));
|
||||||
|
|
||||||
// Populate the external source document.
|
// Populate the external source document.
|
||||||
ScDocument* pExtDoc = xExtDocSh->GetDocument();
|
ScDocument* pExtDoc = xExtDocSh->GetDocument();
|
||||||
pExtDoc->InsertTab(0, rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Data")));
|
pExtDoc->InsertTab(0, rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Data")));
|
||||||
|
@ -1892,6 +1920,9 @@ void Test::testExternalRefFunctions()
|
||||||
CPPUNIT_ASSERT_MESSAGE("unexpected result involving external ranges.", val == aChecks[i].fResult);
|
CPPUNIT_ASSERT_MESSAGE("unexpected result involving external ranges.", val == aChecks[i].fResult);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pRefMgr->clearCache(nFileId);
|
||||||
|
testExtRefFuncT(m_pDoc, pExtDoc);
|
||||||
|
|
||||||
// Unload the external document shell.
|
// Unload the external document shell.
|
||||||
xExtDocSh->DoClose();
|
xExtDocSh->DoClose();
|
||||||
CPPUNIT_ASSERT_MESSAGE("external document instance should have been unloaded.",
|
CPPUNIT_ASSERT_MESSAGE("external document instance should have been unloaded.",
|
||||||
|
|
|
@ -2421,10 +2421,14 @@ void lcl_removeByFileId(sal_uInt16 nFileId, MapContainer& rMap)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void ScExternalRefManager::clearCache(sal_uInt16 nFileId)
|
||||||
|
{
|
||||||
|
maRefCache.clearCache(nFileId);
|
||||||
|
}
|
||||||
|
|
||||||
void ScExternalRefManager::refreshNames(sal_uInt16 nFileId)
|
void ScExternalRefManager::refreshNames(sal_uInt16 nFileId)
|
||||||
{
|
{
|
||||||
maRefCache.clearCache(nFileId);
|
clearCache(nFileId);
|
||||||
lcl_removeByFileId(nFileId, maDocShells);
|
lcl_removeByFileId(nFileId, maDocShells);
|
||||||
|
|
||||||
if (maDocShells.empty())
|
if (maDocShells.empty())
|
||||||
|
@ -2465,7 +2469,7 @@ void ScExternalRefManager::breakLink(sal_uInt16 nFileId)
|
||||||
removeRangeNamesBySrcDoc(*pRanges, nFileId);
|
removeRangeNamesBySrcDoc(*pRanges, nFileId);
|
||||||
}
|
}
|
||||||
|
|
||||||
maRefCache.clearCache(nFileId);
|
clearCache(nFileId);
|
||||||
lcl_removeByFileId(nFileId, maDocShells);
|
lcl_removeByFileId(nFileId, maDocShells);
|
||||||
|
|
||||||
if (maDocShells.empty())
|
if (maDocShells.empty())
|
||||||
|
|
Loading…
Reference in a new issue