summaryrefslogtreecommitdiff
path: root/sc/source/core/tool/sharedformula.cxx
diff options
context:
space:
mode:
authorKohei Yoshida <kohei.yoshida@collabora.com>2014-06-02 18:29:27 -0400
committerKohei Yoshida <kohei.yoshida@collabora.com>2014-07-13 18:07:14 -0400
commit5c6ee09126631342939ae8766fe36083d8c011e3 (patch)
tree48081d36ae5000542adb49cc037267992f59ec66 /sc/source/core/tool/sharedformula.cxx
parentb5bb15013617c6b9f1cdd089acae0bfb7104fa3a (diff)
fdo#81309: Adjust references during sort.
Change-Id: I2b98610f6b774400ecfaffe2905201c27fcab33f
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: */