summaryrefslogtreecommitdiff
path: root/sc/source
diff options
context:
space:
mode:
authorKohei Yoshida <kohei.yoshida@gmail.com>2013-07-10 19:46:46 -0400
committerKohei Yoshida <kohei.yoshida@gmail.com>2013-07-11 00:25:38 -0400
commitde9dc7b88d7d7437ebc583b029fb46e2f1db8319 (patch)
tree95915e2b3255654f45db4a597c575d1341370c8f /sc/source
parent1fd0ab0c53e73b50857e5bfed4b307468202354f (diff)
Move more methods to SharedFormulaUtil.
Change-Id: Ibd58f5d15292805d50823223d1ebe94e7b51b808
Diffstat (limited to 'sc/source')
-rw-r--r--sc/source/core/data/column3.cxx67
-rw-r--r--sc/source/core/tool/sharedformula.cxx6
2 files changed, 3 insertions, 70 deletions
diff --git a/sc/source/core/data/column3.cxx b/sc/source/core/data/column3.cxx
index de8adde65b8a..2136e04f30b3 100644
--- a/sc/source/core/data/column3.cxx
+++ b/sc/source/core/data/column3.cxx
@@ -306,69 +306,6 @@ sc::CellStoreType::iterator ScColumn::GetPositionToInsert( SCROW nRow )
return GetPositionToInsert(maCells.begin(), nRow);
}
-namespace {
-
-void joinFormulaCells(const sc::CellStoreType::position_type& rPos, ScFormulaCell& rCell1, ScFormulaCell& rCell2)
-{
- ScFormulaCell::CompareState eState = rCell1.CompareByTokenArray(rCell2);
- if (eState == ScFormulaCell::NotEqual)
- return;
-
- SCROW nRow = rPos.first->position + rPos.second;
-
- // Formula tokens equal those of the previous formula cell.
- ScFormulaCellGroupRef xGroup1 = rCell1.GetCellGroup();
- ScFormulaCellGroupRef xGroup2 = rCell2.GetCellGroup();
- if (xGroup1)
- {
- if (xGroup2)
- {
- // Both cell 1 and cell 2 are shared. Merge them together.
- if (xGroup1.get() == xGroup2.get())
- // They belong to the same group.
- return;
-
- // Set the group object from cell 1 to all cells in group 2.
- xGroup1->mnLength += xGroup2->mnLength;
- size_t nOffset = rPos.second + 1; // position of cell 2
- for (size_t i = 0, n = xGroup2->mnLength; i < n; ++i)
- {
- ScFormulaCell& rCell = *sc::formula_block::at(*rPos.first->data, nOffset+i);
- rCell.SetCellGroup(xGroup1);
- }
- }
- else
- {
- // cell 1 is shared but cell 2 is not.
- rCell2.SetCellGroup(xGroup1);
- ++xGroup1->mnLength;
- }
- }
- else
- {
- if (xGroup2)
- {
- // cell 1 is not shared, but cell 2 is already shared.
- rCell1.SetCellGroup(xGroup2);
- xGroup2->mnStart = nRow;
- ++xGroup2->mnLength;
- }
- else
- {
- // neither cells are shared.
- xGroup1.reset(new ScFormulaCellGroup);
- xGroup1->mnStart = nRow;
- xGroup1->mbInvariant = (eState == ScFormulaCell::EqualInvariant);
- xGroup1->mnLength = 2;
-
- rCell1.SetCellGroup(xGroup1);
- rCell2.SetCellGroup(xGroup1);
- }
- }
-}
-
-}
-
void ScColumn::JoinNewFormulaCell(
const sc::CellStoreType::position_type& aPos, ScFormulaCell& rCell ) const
{
@@ -378,14 +315,14 @@ void ScColumn::JoinNewFormulaCell(
ScFormulaCell& rPrev = *sc::formula_block::at(*aPos.first->data, aPos.second-1);
sc::CellStoreType::position_type aPosPrev = aPos;
--aPosPrev.second;
- joinFormulaCells(aPosPrev, rPrev, rCell);
+ sc::SharedFormulaUtil::joinFormulaCells(aPosPrev, rPrev, rCell);
}
// Check the next row position for possible grouping.
if (aPos.first->type == sc::element_type_formula && aPos.second+1 < aPos.first->size)
{
ScFormulaCell& rNext = *sc::formula_block::at(*aPos.first->data, aPos.second+1);
- joinFormulaCells(aPos, rCell, rNext);
+ sc::SharedFormulaUtil::joinFormulaCells(aPos, rCell, rNext);
}
}
diff --git a/sc/source/core/tool/sharedformula.cxx b/sc/source/core/tool/sharedformula.cxx
index c1bc56447dd6..5cdfc78522b5 100644
--- a/sc/source/core/tool/sharedformula.cxx
+++ b/sc/source/core/tool/sharedformula.cxx
@@ -62,9 +62,7 @@ void SharedFormulaUtil::splitFormulaCellGroup(const CellStoreType::position_type
}
}
-namespace {
-
-void joinFormulaCells(const sc::CellStoreType::position_type& rPos, ScFormulaCell& rCell1, ScFormulaCell& rCell2)
+void SharedFormulaUtil::joinFormulaCells(const CellStoreType::position_type& rPos, ScFormulaCell& rCell1, ScFormulaCell& rCell2)
{
ScFormulaCell::CompareState eState = rCell1.CompareByTokenArray(rCell2);
if (eState == ScFormulaCell::NotEqual)
@@ -123,8 +121,6 @@ void joinFormulaCells(const sc::CellStoreType::position_type& rPos, ScFormulaCel
}
}
-}
-
void SharedFormulaUtil::joinFormulaCellAbove(const CellStoreType::position_type& aPos)
{
if (aPos.first->type != sc::element_type_formula)