summaryrefslogtreecommitdiff
path: root/sc/source/core/tool/sharedformula.cxx
diff options
context:
space:
mode:
Diffstat (limited to 'sc/source/core/tool/sharedformula.cxx')
-rw-r--r--sc/source/core/tool/sharedformula.cxx29
1 files changed, 29 insertions, 0 deletions
diff --git a/sc/source/core/tool/sharedformula.cxx b/sc/source/core/tool/sharedformula.cxx
index ed35690a63a7..6f6636557915 100644
--- a/sc/source/core/tool/sharedformula.cxx
+++ b/sc/source/core/tool/sharedformula.cxx
@@ -297,6 +297,35 @@ void SharedFormulaUtil::unshareFormulaCell(const CellStoreType::position_type& a
rCell.SetCellGroup(xNone);
}
+void SharedFormulaUtil::unshareFormulaCells(CellStoreType& rCells, std::vector<SCROW>& rRows)
+{
+ if (rRows.empty())
+ return;
+
+ // Sort and remove duplicates.
+ std::sort(rRows.begin(), rRows.end());
+ rRows.erase(std::unique(rRows.begin(), rRows.end()), rRows.end());
+
+ // Add next cell positions to the list (to ensure that each position becomes a single cell).
+ std::vector<SCROW> aRows2;
+ std::vector<SCROW>::const_iterator it = rRows.begin(), itEnd = rRows.end();
+ for (; it != itEnd; ++it)
+ {
+ if (*it > MAXROW)
+ break;
+
+ aRows2.push_back(*it);
+
+ if (*it < MAXROW)
+ aRows2.push_back(*it+1);
+ }
+
+ // Remove duplicates again (the vector should still be sorted).
+ aRows2.erase(std::unique(aRows2.begin(), aRows2.end()), aRows2.end());
+
+ splitFormulaCellGroups(rCells, aRows2);
+}
+
}
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */