summaryrefslogtreecommitdiffstats
path: root/sc
diff options
context:
space:
mode:
authorKohei Yoshida <kohei.yoshida@collabora.com>2014-02-25 20:40:04 -0500
committerKohei Yoshida <kohei.yoshida@collabora.com>2014-02-25 20:55:17 -0500
commit5706ff70dbb18d03e396fd484bd1392dbcefb6c7 (patch)
tree5130622ab8bf63d5e94950ba7b066f7e585710b9 /sc
parentfdo#72041: Add import test to catch an issue with external ref cache. (diff)
downloadcore-5706ff70dbb18d03e396fd484bd1392dbcefb6c7.tar.gz
core-5706ff70dbb18d03e396fd484bd1392dbcefb6c7.zip
fdo#72041: Intern strings as we populate the external cache.
This commit covers ods import and UNO API layer. Change-Id: I3ad1b7cfefe49575694e2351bcba6e5733b009d2
Diffstat (limited to 'sc')
-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 aa6a2dcf0752..e079e75db655 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 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 9bba5babc6d2..a47032e657f7 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;