[Libreoffice-commits] .: sc/inc sc/qa sc/source
Kohei Yoshida
kohei at kemper.freedesktop.org
Tue Nov 22 19:32:24 PST 2011
sc/inc/externalrefmgr.hxx | 1 +
sc/qa/unit/ucalc.cxx | 31 +++++++++++++++++++++++++++++++
sc/source/ui/docshell/externalrefmgr.cxx | 8 ++++++--
3 files changed, 38 insertions(+), 2 deletions(-)
New commits:
commit a725d287a2b19f56639cc727b102cc7103afe173
Author: Kohei Yoshida <kohei.yoshida at suse.com>
Date: Tue Nov 22 22:32:05 2011 -0500
Unit test for cell function T with external references.
diff --git a/sc/inc/externalrefmgr.hxx b/sc/inc/externalrefmgr.hxx
index 0904871..80dda70 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 975737a..d5111b2 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 99bb129..fe43efa 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())
More information about the Libreoffice-commits
mailing list