summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--sc/source/core/data/column.cxx29
-rw-r--r--sc/source/core/data/column3.cxx28
-rw-r--r--sc/source/core/data/column4.cxx12
3 files changed, 58 insertions, 11 deletions
diff --git a/sc/source/core/data/column.cxx b/sc/source/core/data/column.cxx
index 52eb27eb9a7e..7d10c20fbbbf 100644
--- a/sc/source/core/data/column.cxx
+++ b/sc/source/core/data/column.cxx
@@ -1714,6 +1714,7 @@ class CopyByCloneHandler
ScColumn& mrDestCol;
sc::ColumnBlockPosition maDestPos;
sc::ColumnBlockPosition* mpDestPos;
+ svl::SharedStringPool* mpSharedStringPool;
sal_uInt16 mnCopyFlags;
void setDefaultAttrToDest(size_t nRow)
@@ -1827,8 +1828,10 @@ class CopyByCloneHandler
}
public:
- CopyByCloneHandler(const ScColumn& rSrcCol, ScColumn& rDestCol, sc::ColumnBlockPosition* pDestPos, sal_uInt16 nCopyFlags) :
- mrSrcCol(rSrcCol), mrDestCol(rDestCol), mpDestPos(pDestPos), mnCopyFlags(nCopyFlags)
+ CopyByCloneHandler(const ScColumn& rSrcCol, ScColumn& rDestCol, sc::ColumnBlockPosition* pDestPos,
+ sal_uInt16 nCopyFlags, svl::SharedStringPool* pSharedStringPool) :
+ mrSrcCol(rSrcCol), mrDestCol(rDestCol), mpDestPos(pDestPos), mpSharedStringPool(pSharedStringPool),
+ mnCopyFlags(nCopyFlags)
{
if (mpDestPos)
maDestPos = *mpDestPos;
@@ -1896,8 +1899,18 @@ public:
}
else
{
- maDestPos.miCellPos =
- mrDestCol.GetCellStore().set(maDestPos.miCellPos, nRow, rStr);
+ if (mpSharedStringPool)
+ {
+ // Re-intern the string if source is a different document.
+ svl::SharedString aInterned = mpSharedStringPool->intern( rStr.getString());
+ maDestPos.miCellPos =
+ mrDestCol.GetCellStore().set(maDestPos.miCellPos, nRow, aInterned);
+ }
+ else
+ {
+ maDestPos.miCellPos =
+ mrDestCol.GetCellStore().set(maDestPos.miCellPos, nRow, rStr);
+ }
setDefaultAttrToDest(nRow);
}
}
@@ -1998,7 +2011,13 @@ void ScColumn::CopyToColumn(
}
else
{
- CopyByCloneHandler aFunc(*this, rColumn, rCxt.getBlockPosition(rColumn.nTab, rColumn.nCol), nFlags);
+ // Compare the ScDocumentPool* to determine if we are copying
+ // within the same document. If not, re-intern shared strings.
+ svl::SharedStringPool* pSharedStringPool =
+ (pDocument->GetPool() != rColumn.pDocument->GetPool()) ?
+ &rColumn.pDocument->GetSharedStringPool() : NULL;
+ CopyByCloneHandler aFunc(*this, rColumn, rCxt.getBlockPosition(rColumn.nTab, rColumn.nCol), nFlags,
+ pSharedStringPool);
sc::ParseBlock(maCells.begin(), maCells, aFunc, nRow1, nRow2);
}
diff --git a/sc/source/core/data/column3.cxx b/sc/source/core/data/column3.cxx
index b97e396d12f5..ccd62e90597b 100644
--- a/sc/source/core/data/column3.cxx
+++ b/sc/source/core/data/column3.cxx
@@ -683,6 +683,7 @@ class CopyCellsFromClipHandler
long mnRowOffset;
sc::ColumnBlockPosition maDestBlockPos;
sc::ColumnBlockPosition* mpDestBlockPos; // to save it for next iteration.
+ svl::SharedStringPool* mpSharedStringPool;
void insertRefCell(SCROW nSrcRow, SCROW nDestRow)
{
@@ -705,7 +706,7 @@ class CopyCellsFromClipHandler
}
public:
- CopyCellsFromClipHandler(sc::CopyFromClipContext& rCxt, ScColumn& rSrcCol, ScColumn& rDestCol, SCTAB nDestTab, SCCOL nDestCol, long nRowOffset) :
+ CopyCellsFromClipHandler(sc::CopyFromClipContext& rCxt, ScColumn& rSrcCol, ScColumn& rDestCol, SCTAB nDestTab, SCCOL nDestCol, long nRowOffset, svl::SharedStringPool* pSharedStringPool) :
mrCxt(rCxt),
mrSrcCol(rSrcCol),
mrDestCol(rDestCol),
@@ -714,7 +715,8 @@ public:
mnSrcTab(rSrcCol.GetTab()),
mnSrcCol(rSrcCol.GetCol()),
mnRowOffset(nRowOffset),
- mpDestBlockPos(mrCxt.getBlockPosition(nDestTab, nDestCol))
+ mpDestBlockPos(mrCxt.getBlockPosition(nDestTab, nDestCol)),
+ mpSharedStringPool(pSharedStringPool)
{
if (mpDestBlockPos)
maDestBlockPos = *mpDestBlockPos;
@@ -789,6 +791,12 @@ public:
{
if (bAsLink)
insertRefCell(nSrcRow, nSrcRow + mnRowOffset);
+ else if (mpSharedStringPool)
+ {
+ // Re-intern the string if source is a different document.
+ svl::SharedString aInterned = mpSharedStringPool->intern( (*it).getString());
+ mrDestCol.SetRawString(maDestBlockPos, nSrcRow + mnRowOffset, aInterned);
+ }
else
mrDestCol.SetRawString(maDestBlockPos, nSrcRow + mnRowOffset, *it);
}
@@ -897,8 +905,16 @@ public:
rEngine.SetText(aStr.getString());
mrDestCol.SetEditText(maDestBlockPos, nSrcRow + mnRowOffset, rEngine.CreateTextObject());
}
+ else if (mpSharedStringPool)
+ {
+ // Re-intern the string if source is a different document.
+ svl::SharedString aInterned = mpSharedStringPool->intern( aStr.getString());
+ mrDestCol.SetRawString(maDestBlockPos, nSrcRow + mnRowOffset, aInterned);
+ }
else
+ {
mrDestCol.SetRawString(maDestBlockPos, nSrcRow + mnRowOffset, aStr);
+ }
}
}
}
@@ -969,10 +985,14 @@ void ScColumn::CopyFromClip(
return;
}
- // nRow1 to nRow2 is for destination (this) column. Subtract nDy to get the source range.
+ // Compare the ScDocumentPool* to determine if we are copying within the
+ // same document. If not, re-intern shared strings.
+ svl::SharedStringPool* pSharedStringPool = (rColumn.pDocument->GetPool() != pDocument->GetPool()) ?
+ &pDocument->GetSharedStringPool() : NULL;
+ // nRow1 to nRow2 is for destination (this) column. Subtract nDy to get the source range.
// Copy all cells in the source column (rColumn) from nRow1-nDy to nRow2-nDy to this column.
- CopyCellsFromClipHandler aFunc(rCxt, rColumn, *this, nTab, nCol, nDy);
+ CopyCellsFromClipHandler aFunc(rCxt, rColumn, *this, nTab, nCol, nDy, pSharedStringPool);
sc::ParseBlock(rColumn.maCells.begin(), rColumn.maCells, aFunc, nRow1-nDy, nRow2-nDy);
}
diff --git a/sc/source/core/data/column4.cxx b/sc/source/core/data/column4.cxx
index 29a1acc6f6e9..5848183442a7 100644
--- a/sc/source/core/data/column4.cxx
+++ b/sc/source/core/data/column4.cxx
@@ -18,7 +18,7 @@
#include <listenercontext.hxx>
#include <mtvcellfunc.hxx>
-#include <svl/sharedstring.hxx>
+#include <svl/sharedstringpool.hxx>
#include <vector>
#include <cassert>
@@ -68,7 +68,15 @@ void ScColumn::CopyOneCellFromClip( sc::CopyFromClipContext& rCxt, SCROW nRow1,
break;
case CELLTYPE_STRING:
{
- std::vector<svl::SharedString> aStrs(nDestSize, *rSrcCell.mpString);
+ // Compare the ScDocumentPool* to determine if we are copying within the
+ // same document. If not, re-intern shared strings.
+ svl::SharedStringPool* pSharedStringPool = (rCxt.getClipDoc()->GetPool() != pDocument->GetPool()) ?
+ &pDocument->GetSharedStringPool() : NULL;
+ svl::SharedString aStr = (pSharedStringPool ?
+ pSharedStringPool->intern( rSrcCell.mpString->getString()) :
+ *rSrcCell.mpString);
+
+ std::vector<svl::SharedString> aStrs(nDestSize, aStr);
pBlockPos->miCellPos =
maCells.set(pBlockPos->miCellPos, nRow1, aStrs.begin(), aStrs.end());
pBlockPos->miCellTextAttrPos =