sc/inc/linkuno.hxx | 6 ++++-- sc/qa/unit/data/ods/external-ref-cache.ods |binary sc/qa/unit/subsequent_filters-test.cxx | 17 +++++++++++++++++ sc/source/filter/xml/xmlexternaltabi.cxx | 8 +++++++- sc/source/ui/unoobj/linkuno.cxx | 26 ++++++++++++++++---------- 5 files changed, 44 insertions(+), 13 deletions(-)
New commits: commit 5706ff70dbb18d03e396fd484bd1392dbcefb6c7 Author: Kohei Yoshida <kohei.yosh...@collabora.com> Date: Tue Feb 25 20:40:04 2014 -0500 fdo#72041: Intern strings as we populate the external cache. This commit covers ods import and UNO API layer. Change-Id: I3ad1b7cfefe49575694e2351bcba6e5733b009d2 diff --git a/sc/inc/linkuno.hxx b/sc/inc/linkuno.hxx index aa6a2dc..e079e75 100644 --- a/sc/inc/linkuno.hxx +++ b/sc/inc/linkuno.hxx @@ -502,7 +502,7 @@ public: class ScExternalSheetCacheObj : public cppu::WeakImplHelper1< ::com::sun::star::sheet::XExternalSheetCache > { public: - explicit ScExternalSheetCacheObj(ScExternalRefCache::TableTypeRef pTable, size_t nIndex); + explicit ScExternalSheetCacheObj(ScDocShell* pDocShell, ScExternalRefCache::TableTypeRef pTable, size_t nIndex); ~ScExternalSheetCacheObj(); // XExternalSheetCache @@ -528,6 +528,7 @@ private: ScExternalSheetCacheObj(const ScExternalSheetCacheObj&); private: + ScDocShell* mpDocShell; ScExternalRefCache::TableTypeRef mpTable; size_t mnIndex; }; @@ -535,7 +536,7 @@ private: class ScExternalDocLinkObj : public cppu::WeakImplHelper1< ::com::sun::star::sheet::XExternalDocLink > { public: - ScExternalDocLinkObj(ScExternalRefManager* pRefMgr, sal_uInt16 nFileId); + ScExternalDocLinkObj(ScDocShell* pDocShell, ScExternalRefManager* pRefMgr, sal_uInt16 nFileId); ~ScExternalDocLinkObj(); // XExternalDocLink @@ -574,6 +575,7 @@ public: throw (::com::sun::star::uno::RuntimeException); private: + ScDocShell* mpDocShell; ScExternalRefManager* mpRefMgr; sal_uInt16 mnFileId; }; diff --git a/sc/source/filter/xml/xmlexternaltabi.cxx b/sc/source/filter/xml/xmlexternaltabi.cxx index d4ef04e..c34b622 100644 --- a/sc/source/filter/xml/xmlexternaltabi.cxx +++ b/sc/source/filter/xml/xmlexternaltabi.cxx @@ -24,7 +24,9 @@ #include "token.hxx" #include "document.hxx" +#include <documentimport.hxx> +#include <svl/sharedstringpool.hxx> #include <xmloff/nmspmap.hxx> #include <xmloff/xmlnmspe.hxx> #include <xmloff/xmltoken.hxx> @@ -376,7 +378,11 @@ void ScXMLExternalRefCellContext::EndElement() if (mbIsNumeric) aToken.reset(new formula::FormulaDoubleToken(mfCellValue)); else - aToken.reset(new formula::FormulaStringToken(maCellString)); + { + ScDocument& rDoc = mrScImport.GetDoc().getDoc(); + svl::SharedString aSS = rDoc.GetSharedStringPool().intern(maCellString); + aToken.reset(new formula::FormulaStringToken(aSS)); + } sal_uInt32 nNumFmt = mnNumberFormat >= 0 ? static_cast<sal_uInt32>(mnNumberFormat) : 0; mrExternalRefInfo.mpCacheTable->setCell( diff --git a/sc/source/ui/unoobj/linkuno.cxx b/sc/source/ui/unoobj/linkuno.cxx index 9bba5ba..a47032e 100644 --- a/sc/source/ui/unoobj/linkuno.cxx +++ b/sc/source/ui/unoobj/linkuno.cxx @@ -20,6 +20,7 @@ #include <svl/smplhint.hxx> #include <sfx2/linkmgr.hxx> #include <vcl/svapp.hxx> +#include <svl/sharedstringpool.hxx> #include "linkuno.hxx" #include "miscuno.hxx" @@ -1471,7 +1472,8 @@ uno::Reference< sheet::XDDELink > ScDDELinksObj::addDDELink( // ============================================================================ -ScExternalSheetCacheObj::ScExternalSheetCacheObj(ScExternalRefCache::TableTypeRef pTable, size_t nIndex) : +ScExternalSheetCacheObj::ScExternalSheetCacheObj(ScDocShell* pDocShell, ScExternalRefCache::TableTypeRef pTable, size_t nIndex) : + mpDocShell(pDocShell), mpTable(pTable), mnIndex(nIndex) { @@ -1494,7 +1496,11 @@ void SAL_CALL ScExternalSheetCacheObj::setCellValue(sal_Int32 nCol, sal_Int32 nR if (rValue >>= fVal) pToken.reset(new FormulaDoubleToken(fVal)); else if (rValue >>= aVal) - pToken.reset(new FormulaStringToken(aVal)); + { + svl::SharedStringPool& rPool = mpDocShell->GetDocument()->GetSharedStringPool(); + svl::SharedString aSS = rPool.intern(aVal); + pToken.reset(new FormulaStringToken(aSS)); + } else // unidentified value type. return; @@ -1573,8 +1579,8 @@ sal_Int32 SAL_CALL ScExternalSheetCacheObj::getTokenIndex() // ============================================================================ -ScExternalDocLinkObj::ScExternalDocLinkObj(ScExternalRefManager* pRefMgr, sal_uInt16 nFileId) : - mpRefMgr(pRefMgr), mnFileId(nFileId) +ScExternalDocLinkObj::ScExternalDocLinkObj(ScDocShell* pDocShell, ScExternalRefManager* pRefMgr, sal_uInt16 nFileId) : + mpDocShell(pDocShell), mpRefMgr(pRefMgr), mnFileId(nFileId) { } @@ -1593,7 +1599,7 @@ Reference< sheet::XExternalSheetCache > SAL_CALL ScExternalDocLinkObj::addSheetC // Set the whole table cached to prevent access to the source document. pTable->setWholeTableCached(); - Reference< sheet::XExternalSheetCache > aSheetCache(new ScExternalSheetCacheObj(pTable, nIndex)); + Reference< sheet::XExternalSheetCache > aSheetCache(new ScExternalSheetCacheObj(mpDocShell, pTable, nIndex)); return aSheetCache; } @@ -1606,7 +1612,7 @@ Any SAL_CALL ScExternalDocLinkObj::getByName(const OUString &aName) if (!pTable) throw container::NoSuchElementException(); - Reference< sheet::XExternalSheetCache > aSheetCache(new ScExternalSheetCacheObj(pTable, nIndex)); + Reference< sheet::XExternalSheetCache > aSheetCache(new ScExternalSheetCacheObj(mpDocShell, pTable, nIndex)); Any aAny; aAny <<= aSheetCache; @@ -1668,7 +1674,7 @@ Any SAL_CALL ScExternalDocLinkObj::getByIndex(sal_Int32 nApiIndex) if (!pTable) throw lang::IndexOutOfBoundsException(); - Reference< sheet::XExternalSheetCache > aSheetCache(new ScExternalSheetCacheObj(pTable, nIndex)); + Reference< sheet::XExternalSheetCache > aSheetCache(new ScExternalSheetCacheObj(mpDocShell, pTable, nIndex)); Any aAny; aAny <<= aSheetCache; @@ -1725,7 +1731,7 @@ Reference< sheet::XExternalDocLink > SAL_CALL ScExternalDocLinksObj::addDocLink( { SolarMutexGuard aGuard; sal_uInt16 nFileId = mpRefMgr->getExternalFileId(aDocName); - Reference< sheet::XExternalDocLink > aDocLink(new ScExternalDocLinkObj(mpRefMgr, nFileId)); + Reference< sheet::XExternalDocLink > aDocLink(new ScExternalDocLinkObj(mpDocShell, mpRefMgr, nFileId)); return aDocLink; } @@ -1737,7 +1743,7 @@ Any SAL_CALL ScExternalDocLinksObj::getByName(const OUString &aName) throw container::NoSuchElementException(); sal_uInt16 nFileId = mpRefMgr->getExternalFileId(aName); - Reference< sheet::XExternalDocLink > aDocLink(new ScExternalDocLinkObj(mpRefMgr, nFileId)); + Reference< sheet::XExternalDocLink > aDocLink(new ScExternalDocLinkObj(mpDocShell, mpRefMgr, nFileId)); Any aAny; aAny <<= aDocLink; @@ -1785,7 +1791,7 @@ Any SAL_CALL ScExternalDocLinksObj::getByIndex(sal_Int32 nIndex) if (!mpRefMgr->hasExternalFile(nFileId)) throw lang::IndexOutOfBoundsException(); - Reference< sheet::XExternalDocLink > aDocLink(new ScExternalDocLinkObj(mpRefMgr, nFileId)); + Reference< sheet::XExternalDocLink > aDocLink(new ScExternalDocLinkObj(mpDocShell, mpRefMgr, nFileId)); Any aAny; aAny <<= aDocLink; return aAny; commit 5bba4c56d2d0a57725b3bc97a3bb8b13a727fa9f Author: Kohei Yoshida <kohei.yosh...@collabora.com> Date: Tue Feb 25 19:53:45 2014 -0500 fdo#72041: Add import test to catch an issue with external ref cache. Change-Id: I648d2d04c86d61b1cbe291e7aa79bf9219833328 diff --git a/sc/qa/unit/data/ods/external-ref-cache.ods b/sc/qa/unit/data/ods/external-ref-cache.ods new file mode 100644 index 0000000..b83ba07 Binary files /dev/null and b/sc/qa/unit/data/ods/external-ref-cache.ods differ diff --git a/sc/qa/unit/subsequent_filters-test.cxx b/sc/qa/unit/subsequent_filters-test.cxx index 7c332c4..474700b 100644 --- a/sc/qa/unit/subsequent_filters-test.cxx +++ b/sc/qa/unit/subsequent_filters-test.cxx @@ -160,6 +160,7 @@ public: void testSharedFormulaHorizontalXLS(); void testExternalRefCacheXLSX(); + void testExternalRefCacheODS(); CPPUNIT_TEST_SUITE(ScFiltersTest); CPPUNIT_TEST(testBasicCellContentODS); @@ -236,6 +237,7 @@ public: CPPUNIT_TEST(testColumnStyleXLSX); CPPUNIT_TEST(testSharedFormulaHorizontalXLS); CPPUNIT_TEST(testExternalRefCacheXLSX); + CPPUNIT_TEST(testExternalRefCacheODS); CPPUNIT_TEST_SUITE_END(); private: @@ -2488,6 +2490,21 @@ void ScFiltersTest::testExternalRefCacheXLSX() xDocSh->DoClose(); } +void ScFiltersTest::testExternalRefCacheODS() +{ + ScDocShellRef xDocSh = loadDoc("external-ref-cache.", ODS); + + CPPUNIT_ASSERT(xDocSh.Is()); + ScDocument* pDoc = xDocSh->GetDocument(); + + // Cells B2:B4 have VLOOKUP with external references which should all show "text". + CPPUNIT_ASSERT_EQUAL(OUString("text"), pDoc->GetString(ScAddress(1,1,0))); + CPPUNIT_ASSERT_EQUAL(OUString("text"), pDoc->GetString(ScAddress(1,2,0))); + CPPUNIT_ASSERT_EQUAL(OUString("text"), pDoc->GetString(ScAddress(1,3,0))); + + xDocSh->DoClose(); +} + ScFiltersTest::ScFiltersTest() : ScBootstrapFixture( "/sc/qa/unit/data" ) { _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits