diff options
author | Kohei Yoshida <kohei.yoshida@gmail.com> | 2013-08-12 16:42:53 -0400 |
---|---|---|
committer | Kohei Yoshida <kohei.yoshida@gmail.com> | 2013-08-12 19:46:30 -0400 |
commit | 05f86f50a66602761d3f5cff6a9be20994ee2224 (patch) | |
tree | bcf022d39681e26bafea4acc531ee75c27353009 | |
parent | f6d37f03cf9c0ff8427612a99c963542e822fcce (diff) |
Ungroup a cell when the group length becomes 1.
Change-Id: Ic656d4837ab1fc5feb4b19765ae427371dfdfe10
-rw-r--r-- | sc/source/core/tool/sharedformula.cxx | 24 |
1 files changed, 18 insertions, 6 deletions
diff --git a/sc/source/core/tool/sharedformula.cxx b/sc/source/core/tool/sharedformula.cxx index 07d902999b08..6583ac901e13 100644 --- a/sc/source/core/tool/sharedformula.cxx +++ b/sc/source/core/tool/sharedformula.cxx @@ -38,13 +38,25 @@ void SharedFormulaUtil::splitFormulaCellGroup(const CellStoreType::position_type ScFormulaCellGroupRef xGroup = rTop.GetCellGroup(); - ScFormulaCellGroupRef xGroup2(new ScFormulaCellGroup); - xGroup2->mbInvariant = xGroup->mbInvariant; - xGroup2->mnStart = nRow; - xGroup2->mnLength = xGroup->mnStart + xGroup->mnLength - nRow; - xGroup2->mpCode = xGroup->mpCode->Clone(); + SCROW nLength2 = xGroup->mnStart + xGroup->mnLength - nRow; + ScFormulaCellGroupRef xGroup2; + if (nLength2 > 1) + { + xGroup2.reset(new ScFormulaCellGroup); + xGroup2->mbInvariant = xGroup->mbInvariant; + xGroup2->mnStart = nRow; + xGroup2->mnLength = nLength2; + xGroup2->mpCode = xGroup->mpCode->Clone(); + } xGroup->mnLength = nRow - xGroup->mnStart; + if (xGroup->mnLength == 1) + { + // The top group consists of only one cell. Ungroup this. + ScFormulaCellGroupRef xNone; + ScFormulaCell& rPrev = *sc::formula_block::at(*aPos.first->data, aPos.second-1); + rPrev.SetCellGroup(xNone); + } // Apply the lower group object to the lower cells. #if DEBUG_COLUMN_STORAGE @@ -56,7 +68,7 @@ void SharedFormulaUtil::splitFormulaCellGroup(const CellStoreType::position_type } #endif sc::formula_block::iterator itEnd = it; - std::advance(itEnd, xGroup2->mnLength); + std::advance(itEnd, nLength2); for (; it != itEnd; ++it) { ScFormulaCell& rCell = **it; |