summaryrefslogtreecommitdiff
path: root/sc
diff options
context:
space:
mode:
authorKohei Yoshida <kohei.yoshida@collabora.com>2014-10-01 20:34:36 -0400
committerKohei Yoshida <kohei.yoshida@collabora.com>2014-10-22 18:07:27 -0400
commite5084fbf728e4eaff7cb67296222e6d54e3e4757 (patch)
tree1e57f2f3793afb0ac175c85094139988ca571af2 /sc
parent5156c5937b428b0923c7ede51bbbf9c407f68bc1 (diff)
Be sure to copy the cell text attributes values to and from clip.
Otherwise we'd have to unnecessarily re-calculate the script types again which is not cheap... Change-Id: Ie589fb4a7e5ec9b5ef646dabea4e6bd0c0aca560
Diffstat (limited to 'sc')
-rw-r--r--sc/source/core/data/column.cxx36
-rw-r--r--sc/source/core/data/column3.cxx41
2 files changed, 73 insertions, 4 deletions
diff --git a/sc/source/core/data/column.cxx b/sc/source/core/data/column.cxx
index b00bf9243c5f..e0fb0ece7cfb 100644
--- a/sc/source/core/data/column.cxx
+++ b/sc/source/core/data/column.cxx
@@ -983,6 +983,31 @@ public:
}
};
+class CopyTextAttrToClipHandler
+{
+ sc::CellTextAttrStoreType& mrDestAttrs;
+ sc::CellTextAttrStoreType::iterator miPos;
+
+public:
+ CopyTextAttrToClipHandler( sc::CellTextAttrStoreType& rAttrs ) :
+ mrDestAttrs(rAttrs), miPos(mrDestAttrs.begin()) {}
+
+ void operator() ( const sc::CellTextAttrStoreType::value_type& aNode, size_t nOffset, size_t nDataSize )
+ {
+ if (aNode.type != sc::element_type_celltextattr)
+ return;
+
+ sc::celltextattr_block::const_iterator it = sc::celltextattr_block::begin(*aNode.data);
+ std::advance(it, nOffset);
+ sc::celltextattr_block::const_iterator itEnd = it;
+ std::advance(itEnd, nDataSize);
+
+ size_t nPos = aNode.position + nOffset;
+ miPos = mrDestAttrs.set(miPos, nPos, it, itEnd);
+ }
+};
+
+
}
void ScColumn::CopyToClip(
@@ -991,8 +1016,15 @@ void ScColumn::CopyToClip(
pAttrArray->CopyArea( nRow1, nRow2, 0, *rColumn.pAttrArray,
rCxt.isKeepScenarioFlags() ? (SC_MF_ALL & ~SC_MF_SCENARIO) : SC_MF_ALL );
- CopyToClipHandler aFunc(*this, rColumn, rCxt.getBlockPosition(rColumn.nTab, rColumn.nCol), rCxt.isCloneNotes());
- sc::ParseBlock(maCells.begin(), maCells, aFunc, nRow1, nRow2);
+ {
+ CopyToClipHandler aFunc(*this, rColumn, rCxt.getBlockPosition(rColumn.nTab, rColumn.nCol), rCxt.isCloneNotes());
+ sc::ParseBlock(maCells.begin(), maCells, aFunc, nRow1, nRow2);
+ }
+
+ {
+ CopyTextAttrToClipHandler aFunc(rColumn.maCellTextAttrs);
+ sc::ParseBlock(maCellTextAttrs.begin(), maCellTextAttrs, aFunc, nRow1, nRow2);
+ }
rColumn.CellStorageModified();
}
diff --git a/sc/source/core/data/column3.cxx b/sc/source/core/data/column3.cxx
index 5723b73911fd..225276a24d2f 100644
--- a/sc/source/core/data/column3.cxx
+++ b/sc/source/core/data/column3.cxx
@@ -950,6 +950,31 @@ public:
}
};
+class CopyTextAttrsFromClipHandler
+{
+ sc::CellTextAttrStoreType& mrAttrs;
+ sc::CellTextAttrStoreType::iterator miPos;
+ size_t mnDelta;
+
+public:
+ CopyTextAttrsFromClipHandler( sc::CellTextAttrStoreType& rAttrs, size_t nDelta ) :
+ mrAttrs(rAttrs), miPos(mrAttrs.begin()), mnDelta(nDelta) {}
+
+ void operator() ( const sc::CellTextAttrStoreType::value_type& aNode, size_t nOffset, size_t nDataSize )
+ {
+ if (aNode.type != sc::element_type_celltextattr)
+ return;
+
+ sc::celltextattr_block::const_iterator it = sc::celltextattr_block::begin(*aNode.data);
+ std::advance(it, nOffset);
+ sc::celltextattr_block::const_iterator itEnd = it;
+ std::advance(itEnd, nDataSize);
+
+ size_t nPos = aNode.position + nOffset + mnDelta;
+ miPos = mrAttrs.set(miPos, nPos, it, itEnd);
+ }
+};
+
}
// rColumn = source
@@ -1001,6 +1026,10 @@ void ScColumn::CopyFromClip(
SetFormulaCell(nDestRow, new ScFormulaCell(pDocument, aDestPos, aArr));
}
+ // Don't forget to copy the cell text attributes.
+ CopyTextAttrsFromClipHandler aFunc(maCellTextAttrs, nDy);
+ sc::ParseBlock(rColumn.maCellTextAttrs.begin(), rColumn.maCellTextAttrs, aFunc, nRow1-nDy, nRow2-nDy);
+
return;
}
@@ -1011,8 +1040,16 @@ void ScColumn::CopyFromClip(
// 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, pSharedStringPool);
- sc::ParseBlock(rColumn.maCells.begin(), rColumn.maCells, aFunc, nRow1-nDy, nRow2-nDy);
+ {
+ CopyCellsFromClipHandler aFunc(rCxt, rColumn, *this, nTab, nCol, nDy, pSharedStringPool);
+ sc::ParseBlock(rColumn.maCells.begin(), rColumn.maCells, aFunc, nRow1-nDy, nRow2-nDy);
+ }
+
+ {
+ // Don't forget to copy the cell text attributes.
+ CopyTextAttrsFromClipHandler aFunc(maCellTextAttrs, nDy);
+ sc::ParseBlock(rColumn.maCellTextAttrs.begin(), rColumn.maCellTextAttrs, aFunc, nRow1-nDy, nRow2-nDy);
+ }
}
void ScColumn::MixMarked(