diff options
author | Kohei Yoshida <kohei.yoshida@gmail.com> | 2013-08-12 15:23:28 -0400 |
---|---|---|
committer | Kohei Yoshida <kohei.yoshida@gmail.com> | 2013-08-12 19:46:29 -0400 |
commit | 2624788f23d265f0dfeda544f57b9d90a2ab2979 (patch) | |
tree | fe2885a75a7bfbde4936f9cac8df21412c0f0da0 /sc/source/core/tool/sharedformula.cxx | |
parent | 30503611efc30ac7a3b09744913f048bf28ef70a (diff) |
Do the splitting of formula groups.
Change-Id: I5a8661895b558b67abc19cdc39de9eb027bc1c34
Diffstat (limited to 'sc/source/core/tool/sharedformula.cxx')
-rw-r--r-- | sc/source/core/tool/sharedformula.cxx | 28 |
1 files changed, 26 insertions, 2 deletions
diff --git a/sc/source/core/tool/sharedformula.cxx b/sc/source/core/tool/sharedformula.cxx index d9f3a2595f67..9299e3349aa2 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) |