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:
Kohei Yoshida 2014-10-01 20:34:36 -04:00
parent 5156c5937b
commit e5084fbf72
2 changed files with 73 additions and 4 deletions

View file

@ -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( void ScColumn::CopyToClip(
@ -991,8 +1016,15 @@ void ScColumn::CopyToClip(
pAttrArray->CopyArea( nRow1, nRow2, 0, *rColumn.pAttrArray, pAttrArray->CopyArea( nRow1, nRow2, 0, *rColumn.pAttrArray,
rCxt.isKeepScenarioFlags() ? (SC_MF_ALL & ~SC_MF_SCENARIO) : SC_MF_ALL ); 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(); rColumn.CellStorageModified();
} }

View file

@ -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 // rColumn = source
@ -1001,6 +1026,10 @@ void ScColumn::CopyFromClip(
SetFormulaCell(nDestRow, new ScFormulaCell(pDocument, aDestPos, aArr)); 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; return;
} }
@ -1011,8 +1040,16 @@ void ScColumn::CopyFromClip(
// nRow1 to nRow2 is for destination (this) column. Subtract nDy to get the source range. // 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. // 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( void ScColumn::MixMarked(