summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKohei Yoshida <kohei.yoshida@collabora.com>2014-02-25 20:40:04 -0500
committerCaolán McNamara <caolanm@redhat.com>2014-02-26 09:26:26 -0600
commit84c3d27619ed124a484196bcc2a3f496bd585ce0 (patch)
tree4e7b3073068ef7bf6e1746eb316a47c79d6a81b0
parentac7062d7fb6e5dfe0f81d53daec7f088dc4f9e3d (diff)
fdo#72041: Intern strings as we populate the external cache.
This commit covers ods import and UNO API layer. Change-Id: I3ad1b7cfefe49575694e2351bcba6e5733b009d2 (cherry picked from commit 5706ff70dbb18d03e396fd484bd1392dbcefb6c7) Reviewed-on: https://gerrit.libreoffice.org/8351 Reviewed-by: Eike Rathke <erack@redhat.com> Tested-by: Eike Rathke <erack@redhat.com> Reviewed-by: Caolán McNamara <caolanm@redhat.com> Tested-by: Caolán McNamara <caolanm@redhat.com>
-rw-r--r--sc/inc/linkuno.hxx6
-rw-r--r--sc/source/filter/xml/xmlexternaltabi.cxx8
-rw-r--r--sc/source/ui/unoobj/linkuno.cxx26
3 files changed, 27 insertions, 13 deletions
diff --git a/sc/inc/linkuno.hxx b/sc/inc/linkuno.hxx
index b5788e8e7706..0e9e23530e18 100644
--- a/sc/inc/linkuno.hxx
+++ b/sc/inc/linkuno.hxx
@@ -492,7 +492,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
@@ -518,6 +518,7 @@ private:
ScExternalSheetCacheObj(const ScExternalSheetCacheObj&);
private:
+ ScDocShell* mpDocShell;
ScExternalRefCache::TableTypeRef mpTable;
size_t mnIndex;
};
@@ -525,7 +526,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
@@ -564,6 +565,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 d4ef04ef5c0e..c34b6227dd7d 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 2d19a4631db0..6f865067309a 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"
@@ -1469,7 +1470,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)
{
@@ -1492,7 +1494,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;
@@ -1571,8 +1577,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)
{
}
@@ -1591,7 +1597,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;
}
@@ -1604,7 +1610,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;
@@ -1666,7 +1672,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;
@@ -1723,7 +1729,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;
}
@@ -1735,7 +1741,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;
@@ -1783,7 +1789,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;