diff options
author | Kohei Yoshida <kohei.yoshida@suse.com> | 2011-11-22 22:32:05 -0500 |
---|---|---|
committer | Kohei Yoshida <kohei.yoshida@suse.com> | 2011-11-22 22:32:05 -0500 |
commit | a725d287a2b19f56639cc727b102cc7103afe173 (patch) | |
tree | b46ebd05bc299b2f5cfc0278a66127df365d4521 /sc | |
parent | f7831ed5ca23d5b45cb5b6fb4955c0c572a32f39 (diff) |
Unit test for cell function T with external references.
Diffstat (limited to 'sc')
-rw-r--r-- | sc/inc/externalrefmgr.hxx | 1 | ||||
-rw-r--r-- | sc/qa/unit/ucalc.cxx | 31 | ||||
-rw-r--r-- | sc/source/ui/docshell/externalrefmgr.cxx | 8 |
3 files changed, 38 insertions, 2 deletions
diff --git a/sc/inc/externalrefmgr.hxx b/sc/inc/externalrefmgr.hxx index 0904871c17c8..80dda704870e 100644 --- a/sc/inc/externalrefmgr.hxx +++ b/sc/inc/externalrefmgr.hxx @@ -596,6 +596,7 @@ public: const ::rtl::OUString* getRealTableName(sal_uInt16 nFileId, const ::rtl::OUString& rTabName) const; const ::rtl::OUString* getRealRangeName(sal_uInt16 nFileId, const ::rtl::OUString& rRangeName) const; + void clearCache(sal_uInt16 nFileId); void refreshNames(sal_uInt16 nFileId); void breakLink(sal_uInt16 nFileId); void switchSrcFile(sal_uInt16 nFileId, const ::rtl::OUString& rNewFile, const ::rtl::OUString& rNewFilter); diff --git a/sc/qa/unit/ucalc.cxx b/sc/qa/unit/ucalc.cxx index 975737a17bbd..d5111b221e13 100644 --- a/sc/qa/unit/ucalc.cxx +++ b/sc/qa/unit/ucalc.cxx @@ -1846,6 +1846,27 @@ void Test::testExternalRef() 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() { ScDocShellRef xExtDocSh = new ScDocShell; @@ -1855,6 +1876,13 @@ void Test::testExternalRefFunctions() CPPUNIT_ASSERT_MESSAGE("external document instance not loaded.", 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. ScDocument* pExtDoc = xExtDocSh->GetDocument(); 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); } + pRefMgr->clearCache(nFileId); + testExtRefFuncT(m_pDoc, pExtDoc); + // Unload the external document shell. xExtDocSh->DoClose(); CPPUNIT_ASSERT_MESSAGE("external document instance should have been unloaded.", diff --git a/sc/source/ui/docshell/externalrefmgr.cxx b/sc/source/ui/docshell/externalrefmgr.cxx index 99bb129f562a..fe43efa7f9d6 100644 --- a/sc/source/ui/docshell/externalrefmgr.cxx +++ b/sc/source/ui/docshell/externalrefmgr.cxx @@ -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) { - maRefCache.clearCache(nFileId); + clearCache(nFileId); lcl_removeByFileId(nFileId, maDocShells); if (maDocShells.empty()) @@ -2465,7 +2469,7 @@ void ScExternalRefManager::breakLink(sal_uInt16 nFileId) removeRangeNamesBySrcDoc(*pRanges, nFileId); } - maRefCache.clearCache(nFileId); + clearCache(nFileId); lcl_removeByFileId(nFileId, maDocShells); if (maDocShells.empty()) |