diff options
author | Kohei Yoshida <kohei.yoshida@collabora.com> | 2014-11-18 00:11:04 -0500 |
---|---|---|
committer | Kohei Yoshida <kohei.yoshida@collabora.com> | 2014-11-18 00:11:04 -0500 |
commit | 2ca14939031e1313380c68e460a9dde76c06e212 (patch) | |
tree | 0b3996842877230845c042835600d61bbc9e0906 | |
parent | Extend the test to cover insertion / deletion of rows. (diff) | |
download | core-2ca14939031e1313380c68e460a9dde76c06e212.tar.gz core-2ca14939031e1313380c68e460a9dde76c06e212.zip |
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
-rw-r--r-- | sc/inc/column.hxx | 2 | ||||
-rw-r--r-- | sc/inc/columnspanset.hxx | 2 | ||||
-rw-r--r-- | sc/source/core/data/column3.cxx | 38 | ||||
-rw-r--r-- | sc/source/core/data/column4.cxx | 11 | ||||
-rw-r--r-- | sc/source/core/data/columnspanset.cxx | 5 |
5 files changed, 39 insertions, 19 deletions
diff --git a/sc/inc/column.hxx b/sc/inc/column.hxx index 780076388021..f268c5c516d3 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 f397c3e6292e..48ae7c1e65ec 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 353a97421879..97af751d0b2f 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 40f18bf0e01e..2316a265ee7e 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 faf99add4c63..fe10528bc9c0 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: */ |