[Libreoffice-commits] core.git: Branch 'feature/perfwork' - 2 commits - sc/inc sc/source
sc/inc/formulacell.hxx |3 ++ sc/source/core/data/column.cxx | 36 +++- sc/source/core/data/column3.cxx| 41 +++-- sc/source/core/data/documentimport.cxx | 41 - sc/source/core/data/formulacell.cxx| 25 5 files changed, 133 insertions(+), 13 deletions(-) New commits: commit 3f96f44be8048c112766819f990c3bb18366c874 Author: Kohei Yoshida kohei.yosh...@collabora.com Date: Wed Oct 1 20:34:36 2014 -0400 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 diff --git a/sc/source/core/data/column.cxx b/sc/source/core/data/column.cxx index 939069b..656d53c 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 5723b73..225276a 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. +
[Libreoffice-commits] core.git: Branch 'feature/perfwork' - 2 commits - sc/inc sc/source
sc/inc/column.hxx|3 -- sc/inc/rowheightcontext.hxx |6 sc/source/core/data/column.cxx | 19 +++--- sc/source/core/data/column2.cxx | 24 +- sc/source/core/data/rowheightcontext.cxx |5 +++ sc/source/core/data/table1.cxx | 41 +++ 6 files changed, 60 insertions(+), 38 deletions(-) New commits: commit 452d65ff7ee1dc8be16b9262a13ce9be17243f68 Author: Kohei Yoshida kohei.yosh...@collabora.com Date: Fri Sep 26 16:21:12 2014 -0400 Annotate FindEditCellsHandler. Change-Id: Ib49a7a3eccee62e5496f7f19824631866e072b6a diff --git a/sc/source/core/data/column.cxx b/sc/source/core/data/column.cxx index d6152dd..e49d765 100644 --- a/sc/source/core/data/column.cxx +++ b/sc/source/core/data/column.cxx @@ -2833,17 +2833,21 @@ class FindEditCellsHandler sc::CellStoreType::iterator miCellPos; public: -FindEditCellsHandler(ScColumn rColumn, sc::CellTextAttrStoreType rAttrs, -const sc::CellStoreType::iterator rCellItr) : -mrColumn(rColumn), miAttrPos(rAttrs.begin()), miCellPos(rCellItr) {} +FindEditCellsHandler(ScColumn rCol) : +mrColumn(rCol), +miAttrPos(rCol.GetCellAttrStore().begin()), +miCellPos(rCol.GetCellStore().begin()) {} bool operator() (size_t, const EditTextObject*) { +// This is definitely an edit text cell. return true; } bool operator() (size_t nRow, const ScFormulaCell* p) { +// With a formula cell, it's considered an edit text cell when either +// the result is multi-line or it has more than one script types. sal_uInt8 nScriptType = mrColumn.GetRangeScriptType(miAttrPos, nRow, nRow, miCellPos); if (IsAmbiguousScriptNonZero(nScriptType)) return true; @@ -2851,13 +2855,19 @@ public: return const_castScFormulaCell*(p)-IsMultilineResult(); } +/** + * Callback for a block of other types. + */ std::pairsize_t,bool operator() (const sc::CellStoreType::value_type node, size_t nOffset, size_t nDataSize) { typedef std::pairsize_t,bool RetType; if (node.type == sc::element_type_empty) +// Ignore empty blocks. return RetType(0, false); +// Check the script type of a non-empty element and see if it has +// multiple script types. for (size_t i = 0; i nDataSize; ++i) { SCROW nRow = node.position + i + nOffset; @@ -2867,6 +2877,7 @@ public: return RetType(i+nOffset, true); } +// No edit text cell found. return RetType(0, false); } }; @@ -3232,7 +3243,7 @@ bool ScColumn::HasEditCells(SCROW nStartRow, SCROW nEndRow, SCROW rFirst) { // used in GetOptimalHeight - ambiguous script type counts as edit cell -FindEditCellsHandler aFunc(*this, maCellTextAttrs, maCells.begin()); +FindEditCellsHandler aFunc(*this); std::pairsc::CellStoreType::const_iterator,size_t aPos = sc::FindFormulaEditText(maCells, nStartRow, nEndRow, aFunc); commit 3c23ec10b4b1a881b011d1ce16cc4012415c0f7a Author: Kohei Yoshida kohei.yosh...@collabora.com Date: Fri Sep 26 15:39:50 2014 -0400 Store height array to RowHeightContext and reduce function arg counts. Change-Id: I09b79bc76ffc55e25c24bbfa8f000f4a46df0a1c diff --git a/sc/inc/column.hxx b/sc/inc/column.hxx index 893ef13..7b189e0 100644 --- a/sc/inc/column.hxx +++ b/sc/inc/column.hxx @@ -461,8 +461,7 @@ public: bool bFormula, sal_uInt16 nOldWidth, const ScMarkData* pMarkData, const ScColWidthParam* pParam) const; void GetOptimalHeight( -sc::RowHeightContext rCxt, SCROW nStartRow, SCROW nEndRow, sal_uInt16* pHeight, -sal_uInt16 nMinHeight, SCROW nMinStart ); +sc::RowHeightContext rCxt, SCROW nStartRow, SCROW nEndRow, sal_uInt16 nMinHeight, SCROW nMinStart ); /// Including current, may return -1 SCsROW GetNextUnprotected( SCROW nRow, bool bUp ) const; diff --git a/sc/inc/rowheightcontext.hxx b/sc/inc/rowheightcontext.hxx index a334554..a077bd0 100644 --- a/sc/inc/rowheightcontext.hxx +++ b/sc/inc/rowheightcontext.hxx @@ -14,12 +14,16 @@ #include tools/fract.hxx +#include vector + class OutputDevice; namespace sc { class SC_DLLPUBLIC RowHeightContext { +std::vectorsal_uInt16 maHeights; + double mfPPTX; double mfPPTY; Fraction maZoomX; @@ -48,6 +52,8 @@ public: void setForceAutoSize( bool b ); bool isForceAutoSize() const { return mbForceAutoSize;} + +std::vectorsal_uInt16 getHeightArray(); }; } diff --git a/sc/source/core/data/column2.cxx b/sc/source/core/data/column2.cxx index 13cdee8..e038da3b 100644 --- a/sc/source/core/data/column2.cxx +++ b/sc/source/core/data/column2.cxx @@ -772,9 +772,9 @@ static sal_uInt16 lcl_GetAttribHeight( const