sc/inc/column.hxx | 2 - sc/inc/columnspanset.hxx | 2 + sc/source/core/data/column3.cxx | 38 +++++++++++++++++++--------------- sc/source/core/data/column4.cxx | 11 ++++++++- sc/source/core/data/columnspanset.cxx | 5 ++++ 5 files changed, 39 insertions(+), 19 deletions(-)
New commits: commit 2ca14939031e1313380c68e460a9dde76c06e212 Author: Kohei Yoshida <kohei.yosh...@collabora.com> Date: Tue Nov 18 00:11:04 2014 -0500 Simplify DeleteCells to not require 2 out parameters for the same thing. One can easily get constructed from the other after returning from the method. Change-Id: Iafc52efa7714b7cf4d284effda8034cb6f36bf91 diff --git a/sc/inc/column.hxx b/sc/inc/column.hxx index 7800763..f268c5c 100644 --- a/sc/inc/column.hxx +++ b/sc/inc/column.hxx @@ -652,7 +652,7 @@ private: void DeleteCells( sc::ColumnBlockPosition& rBlockPos, SCROW nRow1, SCROW nRow2, InsertDeleteFlags nDelFlag, - std::vector<SCROW>& rDeleted, sc::ColumnSpanSet* pDeletedSpans = NULL ); + sc::SingleColumnSpanSet& rDeleted ); /** * Get all non-grouped formula cells and formula cell groups in the whole diff --git a/sc/inc/columnspanset.hxx b/sc/inc/columnspanset.hxx index f397c3e..48ae7c1 100644 --- a/sc/inc/columnspanset.hxx +++ b/sc/inc/columnspanset.hxx @@ -141,6 +141,8 @@ public: void getSpans(SpansType& rSpans) const; + void swap( SingleColumnSpanSet& r ); + private: ColumnSpansType maSpans; }; diff --git a/sc/source/core/data/column3.cxx b/sc/source/core/data/column3.cxx index 353a974..97af751 100644 --- a/sc/source/core/data/column3.cxx +++ b/sc/source/core/data/column3.cxx @@ -549,7 +549,7 @@ public: mrDoc.EndListeningFormulaCells(maFormulaCells); } - const sc::SingleColumnSpanSet& getSpans() const + sc::SingleColumnSpanSet& getSpans() { return maDeleteRanges; } @@ -559,7 +559,6 @@ class EmptyCells { ScColumn& mrColumn; sc::ColumnBlockPosition& mrPos; - sc::ColumnSpanSet* mpCellSpans; void splitFormulaGrouping(const sc::CellStoreType::position_type& rPos) { @@ -571,8 +570,8 @@ class EmptyCells } public: - EmptyCells( sc::ColumnBlockPosition& rPos, ScColumn& rColumn, sc::ColumnSpanSet* pCellSpans ) : - mrColumn(rColumn), mrPos(rPos), mpCellSpans(pCellSpans) {} + EmptyCells( sc::ColumnBlockPosition& rPos, ScColumn& rColumn ) : + mrColumn(rColumn), mrPos(rPos) {} void operator() (const sc::RowSpan& rSpan) { @@ -587,9 +586,6 @@ public: mrPos.miCellPos = rCells.set_empty(mrPos.miCellPos, rSpan.mnRow1, rSpan.mnRow2); mrPos.miCellTextAttrPos = mrColumn.GetCellAttrStore().set_empty(mrPos.miCellTextAttrPos, rSpan.mnRow1, rSpan.mnRow2); - - if (mpCellSpans) - mpCellSpans->set(mrColumn.GetTab(), mrColumn.GetCol(), rSpan.mnRow1, rSpan.mnRow2, true); } }; @@ -597,7 +593,7 @@ public: void ScColumn::DeleteCells( sc::ColumnBlockPosition& rBlockPos, SCROW nRow1, SCROW nRow2, InsertDeleteFlags nDelFlag, - std::vector<SCROW>& rDeleted, sc::ColumnSpanSet* pDeletedSpans ) + sc::SingleColumnSpanSet& rDeleted ) { // Determine which cells to delete based on the deletion flags. DeleteAreaHandler aFunc(*pDocument, nDelFlag); @@ -605,17 +601,15 @@ void ScColumn::DeleteCells( sc::ProcessBlock(itPos, maCells, aFunc, nRow1, nRow2); aFunc.endFormulas(); // Have the formula cells stop listening. - std::vector<SCROW> aDeletedRows; - aFunc.getSpans().getRows(aDeletedRows); - std::copy(aDeletedRows.begin(), aDeletedRows.end(), std::back_inserter(rDeleted)); - // Get the deletion spans. sc::SingleColumnSpanSet::SpansType aSpans; aFunc.getSpans().getSpans(aSpans); // Delete the cells for real. - std::for_each(aSpans.begin(), aSpans.end(), EmptyCells(rBlockPos, *this, pDeletedSpans)); + std::for_each(aSpans.begin(), aSpans.end(), EmptyCells(rBlockPos, *this)); CellStorageModified(); + + aFunc.getSpans().swap(rDeleted); } void ScColumn::DeleteArea( @@ -628,13 +622,23 @@ void ScColumn::DeleteArea( nContMask |= IDF_NOCAPTIONS; InsertDeleteFlags nContFlag = nDelFlag & nContMask; - std::vector<SCROW> aDeletedRows; + sc::SingleColumnSpanSet aDeletedRows; sc::ColumnBlockPosition aBlockPos; InitBlockPosition(aBlockPos); if (!IsEmptyData() && nContFlag) - DeleteCells(aBlockPos, nStartRow, nEndRow, nDelFlag, aDeletedRows, pBroadcastSpans); + { + DeleteCells(aBlockPos, nStartRow, nEndRow, nDelFlag, aDeletedRows); + if (pBroadcastSpans) + { + sc::SingleColumnSpanSet::SpansType aSpans; + aDeletedRows.getSpans(aSpans); + sc::SingleColumnSpanSet::SpansType::const_iterator it = aSpans.begin(), itEnd = aSpans.end(); + for (; it != itEnd; ++it) + pBroadcastSpans->set(nTab, nCol, it->mnRow1, it->mnRow2, true); + } + } if (nDelFlag & IDF_NOTE) DeleteCellNotes(aBlockPos, nStartRow, nEndRow); @@ -655,7 +659,9 @@ void ScColumn::DeleteArea( { // Broadcast on only cells that were deleted; no point broadcasting on // cells that were already empty before the deletion. - BroadcastCells(aDeletedRows, SC_HINT_DATACHANGED); + std::vector<SCROW> aRows; + aDeletedRows.getRows(aRows); + BroadcastCells(aRows, SC_HINT_DATACHANGED); } } diff --git a/sc/source/core/data/column4.cxx b/sc/source/core/data/column4.cxx index 40f18bf..2316a26 100644 --- a/sc/source/core/data/column4.cxx +++ b/sc/source/core/data/column4.cxx @@ -96,7 +96,6 @@ void ScColumn::DeleteBeforeCopyFromClip( nDestOffset += nClipRowLen; } - std::vector<SCROW> aDeletedRows; InsertDeleteFlags nDelFlag = rCxt.getDeleteFlag(); sc::ColumnBlockPosition aBlockPos; InitBlockPosition(aBlockPos); @@ -108,7 +107,15 @@ void ScColumn::DeleteBeforeCopyFromClip( SCROW nRow2 = it->mnRow2; if (nDelFlag & IDF_CONTENTS) - DeleteCells(aBlockPos, nRow1, nRow2, nDelFlag, aDeletedRows, &rBroadcastSpans); + { + sc::SingleColumnSpanSet aDeletedRows; + DeleteCells(aBlockPos, nRow1, nRow2, nDelFlag, aDeletedRows); + aDeletedRows.getSpans(aSpans); + it = aSpans.begin(); + itEnd = aSpans.end(); + for (; it != itEnd; ++it) + rBroadcastSpans.set(nTab, nCol, it->mnRow1, it->mnRow2, true); + } if (nDelFlag & IDF_NOTE) DeleteCellNotes(aBlockPos, nRow1, nRow2); diff --git a/sc/source/core/data/columnspanset.cxx b/sc/source/core/data/columnspanset.cxx index faf99ad..fe10528 100644 --- a/sc/source/core/data/columnspanset.cxx +++ b/sc/source/core/data/columnspanset.cxx @@ -324,6 +324,11 @@ void SingleColumnSpanSet::getSpans(SpansType& rSpans) const rSpans.swap(aSpans); } +void SingleColumnSpanSet::swap( SingleColumnSpanSet& r ) +{ + maSpans.swap(r.maSpans); +} + } /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits