sc/inc/sharedformula.hxx | 10 +++++++++- sc/source/core/data/column.cxx | 9 ++++----- sc/source/core/tool/sharedformula.cxx | 28 ++++++++++++++++++++++++++-- sc/source/core/tool/token.cxx | 2 +- 4 files changed, 40 insertions(+), 9 deletions(-)
New commits: commit 5a29e5b6cebfc4be2856f23807a26f2507995989 Author: Kohei Yoshida <kohei.yosh...@gmail.com> Date: Mon Aug 12 15:23:28 2013 -0400 Do the splitting of formula groups. Change-Id: I5a8661895b558b67abc19cdc39de9eb027bc1c34 diff --git a/sc/inc/sharedformula.hxx b/sc/inc/sharedformula.hxx index 9423384..0b49751 100644 --- a/sc/inc/sharedformula.hxx +++ b/sc/inc/sharedformula.hxx @@ -63,7 +63,15 @@ public: */ static void splitFormulaCellGroup(const CellStoreType::position_type& aPos); - static void splitFormulaCellGroups(CellStoreType& rCells, const std::vector<SCROW>& rBounds); + /** + * Split existing shared formula ranges at specified row positions. + * + * @param rCells cell storage container + * @param rBounds row positions at which to split existing shared formula + * ranges. Note that this method will directly modify this + * parameter to sort and remove duplicates. + */ + static void splitFormulaCellGroups(CellStoreType& rCells, std::vector<SCROW>& rBounds); /** * See if two specified adjacent formula cells can be merged, and if they diff --git a/sc/source/core/data/column.cxx b/sc/source/core/data/column.cxx index a395c78..e4ad8c7 100644 --- a/sc/source/core/data/column.cxx +++ b/sc/source/core/data/column.cxx @@ -2364,6 +2364,10 @@ bool ScColumn::UpdateReference( const sc::RefUpdateContext& rCxt, ScDocument* pU if (rCxt.meMode == URM_COPY) return UpdateReferenceOnCopy(rCxt, pUndoDoc); + if (IsEmptyData()) + // Cells in this column are all empty. + return false; + std::vector<SCROW> aBounds; bool bThisColShifted = (rCxt.maRange.aStart.Tab() <= nTab && nTab <= rCxt.maRange.aEnd.Tab() && @@ -2387,11 +2391,6 @@ bool ScColumn::UpdateReference( const sc::RefUpdateContext& rCxt, ScDocument* pU UpdateRefGroupBoundChecker aBoundChecker(rCxt, aBounds); std::for_each(maCells.begin(), maCells.end(), aBoundChecker); - // Sort and remove duplicates. - std::sort(aBounds.begin(), aBounds.end()); - std::vector<SCROW>::iterator it = std::unique(aBounds.begin(), aBounds.end()); - aBounds.erase(it, aBounds.end()); - // Do the actual splitting. sc::SharedFormulaUtil::splitFormulaCellGroups(maCells, aBounds); diff --git a/sc/source/core/tool/sharedformula.cxx b/sc/source/core/tool/sharedformula.cxx index d9f3a25..9299e33 100644 --- a/sc/source/core/tool/sharedformula.cxx +++ b/sc/source/core/tool/sharedformula.cxx @@ -64,9 +64,33 @@ void SharedFormulaUtil::splitFormulaCellGroup(const CellStoreType::position_type } } -void SharedFormulaUtil::splitFormulaCellGroups(CellStoreType& rCells, const std::vector<SCROW>& rBounds) +void SharedFormulaUtil::splitFormulaCellGroups(CellStoreType& rCells, std::vector<SCROW>& rBounds) { - // TODO: Implement this. + if (rBounds.empty()) + return; + + // Sort and remove duplicates. + std::sort(rBounds.begin(), rBounds.end()); + std::vector<SCROW>::iterator it = std::unique(rBounds.begin(), rBounds.end()); + rBounds.erase(it, rBounds.end()); + + it = rBounds.begin(); + SCROW nRow = *it; + CellStoreType::position_type aPos = rCells.position(nRow); + if (aPos.first == rCells.end()) + return; + + splitFormulaCellGroup(aPos); + std::vector<SCROW>::iterator itEnd = rBounds.end(); + for (++it; it != itEnd; ++it) + { + nRow = *it; + aPos = rCells.position(aPos.first, nRow); + if (aPos.first == rCells.end()) + return; + + splitFormulaCellGroup(aPos); + } } void SharedFormulaUtil::joinFormulaCells(const CellStoreType::position_type& rPos, ScFormulaCell& rCell1, ScFormulaCell& rCell2) diff --git a/sc/source/core/tool/token.cxx b/sc/source/core/tool/token.cxx index 1fbf325..e5627ff 100644 --- a/sc/source/core/tool/token.cxx +++ b/sc/source/core/tool/token.cxx @@ -2981,7 +2981,7 @@ void checkBounds( SCROW nOffset = rCxt.maRange.aStart.Row() - aAbs.aStart.Row(); rBounds.push_back(rPos.Row()+nOffset); // Ditto. - nOffset = rCxt.maRange.aEnd.Row() - aAbs.aStart.Row(); + nOffset = rCxt.maRange.aEnd.Row() + 1 - aAbs.aStart.Row(); rBounds.push_back(rPos.Row()+nOffset); } _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits