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
This commit is contained in:
parent
5156c5937b
commit
e5084fbf72
2 changed files with 73 additions and 4 deletions
|
@ -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();
|
||||
}
|
||||
|
|
|
@ -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(
|
||||
|
|
Loading…
Reference in a new issue