diff options
author | Eike Rathke <erack@redhat.com> | 2019-03-09 01:20:46 +0100 |
---|---|---|
committer | Eike Rathke <erack@redhat.com> | 2019-03-09 02:14:48 +0100 |
commit | 7fdc5df36f5b50e0629405a47ff3d5765fcfeb93 (patch) | |
tree | ab4e9af985161d7a53874018b488dcb338a763c4 | |
parent | 135d59a8de72fb69fe37c474ead45543c7fe99a9 (diff) |
Add all split shared formula groups to regrouping and mark for
listening, even if the references had not be to adjusted.
This partly also resolves tdf#120013 but there's more to that, a
remaining partial group is not updated.
Change-Id: If6d1fef7e545017232a1b7e29b4d60dd58775e88
Reviewed-on: https://gerrit.libreoffice.org/68951
Reviewed-by: Eike Rathke <erack@redhat.com>
Tested-by: Jenkins
-rw-r--r-- | sc/inc/sharedformula.hxx | 10 | ||||
-rw-r--r-- | sc/source/core/data/column.cxx | 4 | ||||
-rw-r--r-- | sc/source/core/tool/sharedformula.cxx | 25 |
3 files changed, 24 insertions, 15 deletions
diff --git a/sc/inc/sharedformula.hxx b/sc/inc/sharedformula.hxx index f4c8ab018532..97e7fc053a9f 100644 --- a/sc/inc/sharedformula.hxx +++ b/sc/inc/sharedformula.hxx @@ -65,8 +65,11 @@ public: * * @param aPos position of cell to examine. * @param pCxt context to be used, if any, may be nullptr. + * + * @return TRUE if there indeed was a split, else FALSE (e.g. split + * position was top or bottom cell or no formula group). */ - static void splitFormulaCellGroup(const CellStoreType::position_type& aPos, sc::EndListeningContext* pCxt); + static bool splitFormulaCellGroup(const CellStoreType::position_type& aPos, sc::EndListeningContext* pCxt); /** * Split existing shared formula ranges at specified row positions. @@ -75,8 +78,11 @@ public: * @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. + * + * @return TRUE if there indeed was a split, else FALSE (e.g. split + * positions were only top or bottom cells or no formula group). */ - static void splitFormulaCellGroups(CellStoreType& rCells, std::vector<SCROW>& rBounds); + static bool 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 1c9174d5d5bd..58f4e8faa29a 100644 --- a/sc/source/core/data/column.cxx +++ b/sc/source/core/data/column.cxx @@ -2481,7 +2481,7 @@ bool ScColumn::UpdateReference( sc::RefUpdateContext& rCxt, ScDocument* pUndoDoc } // Do the actual splitting. - sc::SharedFormulaUtil::splitFormulaCellGroups(maCells, aBounds); + const bool bSplit = sc::SharedFormulaUtil::splitFormulaCellGroups(maCells, aBounds); // Collect all formula groups. std::vector<sc::FormulaGroupEntry> aGroups = GetFormulaGroupEntries(); @@ -2489,7 +2489,7 @@ bool ScColumn::UpdateReference( sc::RefUpdateContext& rCxt, ScDocument* pUndoDoc // Process all collected formula groups. UpdateRefOnNonCopy aHandler(nCol, nTab, &rCxt, pUndoDoc); aHandler = std::for_each(aGroups.begin(), aGroups.end(), aHandler); - if (aHandler.isUpdated()) + if (bSplit || aHandler.isUpdated()) rCxt.maRegroupCols.set(nTab, nCol); return aHandler.isUpdated(); diff --git a/sc/source/core/tool/sharedformula.cxx b/sc/source/core/tool/sharedformula.cxx index 7b1bcd319ce5..5a488aa36258 100644 --- a/sc/source/core/tool/sharedformula.cxx +++ b/sc/source/core/tool/sharedformula.cxx @@ -17,28 +17,28 @@ namespace sc { -void SharedFormulaUtil::splitFormulaCellGroup(const CellStoreType::position_type& aPos, sc::EndListeningContext* pCxt) +bool SharedFormulaUtil::splitFormulaCellGroup(const CellStoreType::position_type& aPos, sc::EndListeningContext* pCxt) { SCROW nRow = aPos.first->position + aPos.second; if (aPos.first->type != sc::element_type_formula) // Not a formula cell block. - return; + return false; if (aPos.second == 0) // Split position coincides with the block border. Nothing to do. - return; + return false; sc::formula_block::iterator it = sc::formula_block::begin(*aPos.first->data); std::advance(it, aPos.second); ScFormulaCell& rTop = **it; if (!rTop.IsShared()) // Not a shared formula. - return; + return false; if (nRow == rTop.GetSharedTopRow()) // Already the top cell of a shared group. - return; + return false; ScFormulaCellGroupRef xGroup = rTop.GetCellGroup(); @@ -97,12 +97,14 @@ void SharedFormulaUtil::splitFormulaCellGroup(const CellStoreType::position_type ScFormulaCell& rCell = **it; rCell.SetCellGroup(xGroup2); } + + return true; } -void SharedFormulaUtil::splitFormulaCellGroups(CellStoreType& rCells, std::vector<SCROW>& rBounds) +bool SharedFormulaUtil::splitFormulaCellGroups(CellStoreType& rCells, std::vector<SCROW>& rBounds) { if (rBounds.empty()) - return; + return false; // Sort and remove duplicates. std::sort(rBounds.begin(), rBounds.end()); @@ -113,9 +115,9 @@ void SharedFormulaUtil::splitFormulaCellGroups(CellStoreType& rCells, std::vecto SCROW nRow = *it; CellStoreType::position_type aPos = rCells.position(nRow); if (aPos.first == rCells.end()) - return; + return false; - splitFormulaCellGroup(aPos, nullptr); + bool bSplit = splitFormulaCellGroup(aPos, nullptr); std::vector<SCROW>::iterator itEnd = rBounds.end(); for (++it; it != itEnd; ++it) { @@ -124,10 +126,11 @@ void SharedFormulaUtil::splitFormulaCellGroups(CellStoreType& rCells, std::vecto { aPos = rCells.position(aPos.first, nRow); if (aPos.first == rCells.end()) - return; - splitFormulaCellGroup(aPos, nullptr); + return bSplit; + bSplit |= splitFormulaCellGroup(aPos, nullptr); } } + return bSplit; } bool SharedFormulaUtil::joinFormulaCells( |