[Libreoffice-commits] core.git: Branch 'libreoffice-4-2' - sc/source
Eike Rathke
erack at redhat.com
Fri Feb 7 13:06:44 PST 2014
sc/source/core/data/column.cxx | 29 ++++++++++++++++++++++++-----
sc/source/core/data/column3.cxx | 28 ++++++++++++++++++++++++----
2 files changed, 48 insertions(+), 9 deletions(-)
New commits:
commit 0d8253bc17cb5476fb558c0e17f5422d76f3e3db
Author: Eike Rathke <erack at redhat.com>
Date: Fri Feb 7 21:27:22 2014 +0100
resolved fdo#74622 re-intern shared strings copied between documents
(cherry picked from commit bba69a3449598eddc465e3467e52ff975fd81938)
Conflicts:
sc/source/core/data/column4.cxx
Change-Id: I64719e12be1f1c61bc86c99f1698f35db87d97be
Reviewed-on: https://gerrit.libreoffice.org/7937
Tested-by: Kohei Yoshida <libreoffice at kohei.us>
Reviewed-by: Kohei Yoshida <libreoffice at kohei.us>
diff --git a/sc/source/core/data/column.cxx b/sc/source/core/data/column.cxx
index 5e85ace..31da531 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 54b53f2..4fdaf11 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;
bool isDateCell(SCROW nSrcRow) const
{
@@ -713,7 +714,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),
@@ -722,7 +723,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;
@@ -798,6 +800,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);
}
@@ -906,8 +914,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);
+ }
}
}
}
@@ -978,10 +994,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);
}
More information about the Libreoffice-commits
mailing list