[Libreoffice-commits] core.git: 2 commits - sc/inc sc/qa sc/source
Markus Mohrhard
markus.mohrhard at googlemail.com
Thu Oct 15 11:11:02 PDT 2015
sc/inc/externalrefmgr.hxx | 1 +
sc/qa/unit/ucalc.hxx | 2 ++
sc/qa/unit/ucalc_formula.cxx | 31 +++++++++++++++++++++++++++++++
sc/source/ui/docshell/externalrefmgr.cxx | 27 +++++++++++++++++++++++++--
4 files changed, 59 insertions(+), 2 deletions(-)
New commits:
commit 7b3e0aa8ad02c12706547616d7a5fd695bf0d75c
Author: Markus Mohrhard <markus.mohrhard at googlemail.com>
Date: Thu Oct 15 19:27:58 2015 +0200
add test for tdf#88179
Change-Id: I8407a05e89129b533f62439d3ffedecd3248ec87
diff --git a/sc/qa/unit/ucalc.hxx b/sc/qa/unit/ucalc.hxx
index 9e9a934..eb8e047 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 c631e1e..0badcac 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));
commit 65dedbd9c776afd9adf513336df80ef50d30934e
Author: Markus Mohrhard <markus.mohrhard at googlemail.com>
Date: Thu Oct 15 18:56:22 2015 +0200
store external range names in the cache, td#88179
Change-Id: I00b41f9b1fc2aec6f66c613cc02328b2968dca8d
diff --git a/sc/inc/externalrefmgr.hxx b/sc/inc/externalrefmgr.hxx
index d29006f..af8921d 100644
--- a/sc/inc/externalrefmgr.hxx
+++ b/sc/inc/externalrefmgr.hxx
@@ -234,6 +234,7 @@ public:
ScExternalRefCache::TokenArrayRef getRangeNameTokens(sal_uInt16 nFileId, const OUString& rName);
void setRangeNameTokens(sal_uInt16 nFileId, const OUString& rName, TokenArrayRef pArray);
bool isValidRangeName(sal_uInt16 nFileId, const OUString& rName) const;
+ void setRangeName(sal_uInt16 nFileId, const OUString& rName);
void setCellData(sal_uInt16 nFileId, const OUString& rTabName,
SCCOL nCol, SCROW nRow, TokenRef pToken, sal_uLong nFmtIndex);
diff --git a/sc/source/ui/docshell/externalrefmgr.cxx b/sc/source/ui/docshell/externalrefmgr.cxx
index 19bd2ca..89c6234 100644
--- a/sc/source/ui/docshell/externalrefmgr.cxx
+++ b/sc/source/ui/docshell/externalrefmgr.cxx
@@ -714,6 +714,18 @@ bool ScExternalRefCache::isValidRangeName(sal_uInt16 nFileId, const OUString& rN
return rMap.count(rName) > 0;
}
+void ScExternalRefCache::setRangeName(sal_uInt16 nFileId, const OUString& rName)
+{
+ osl::MutexGuard aGuard(&maMtxDocs);
+
+ DocItem* pDoc = getDocItem(nFileId);
+ if (!pDoc)
+ return;
+
+ OUString aUpperName = ScGlobal::pCharClass->uppercase(rName);
+ pDoc->maRealRangeNameMap.insert(NamePairMap::value_type(aUpperName, rName));
+}
+
void ScExternalRefCache::setCellData(sal_uInt16 nFileId, const OUString& rTabName, SCCOL nCol, SCROW nRow,
TokenRef pToken, sal_uLong nFmtIndex)
{
@@ -1999,7 +2011,12 @@ bool ScExternalRefManager::isValidRangeName(sal_uInt16 nFileId, const OUString&
if (pSrcDoc)
{
// Only check the presence of the name.
- return hasRangeName(*pSrcDoc, rName);
+ if (hasRangeName(*pSrcDoc, rName))
+ {
+ maRefCache.setRangeName(nFileId, rName);
+ return true;
+ }
+ return false;
}
if (maRefCache.isValidRangeName(nFileId, rName))
@@ -2011,7 +2028,13 @@ bool ScExternalRefManager::isValidRangeName(sal_uInt16 nFileId, const OUString&
// failed to load document from disk.
return false;
- return hasRangeName(*pSrcDoc, rName);
+ if (hasRangeName(*pSrcDoc, rName))
+ {
+ maRefCache.setRangeName(nFileId, rName);
+ return true;
+ }
+
+ return false;
}
void ScExternalRefManager::refreshAllRefCells(sal_uInt16 nFileId)
More information about the Libreoffice-commits
mailing list