sc/qa/unit/ucalc.cxx | 14 +++++++++++++- sc/source/core/data/column.cxx | 19 +++++++++++++++++++ sc/source/core/data/formulacell.cxx | 3 +++ 3 files changed, 35 insertions(+), 1 deletion(-)
New commits: commit 359af285610b2dadbf4d585dfd745b4e65cedb84 Author: Kohei Yoshida <kohei.yosh...@gmail.com> Date: Mon Jul 8 13:48:07 2013 -0400 Adjust formula grouping in InsertRow(). Change-Id: I82723a30edc361b627246b66d21dc04cd639caa6 diff --git a/sc/qa/unit/ucalc.cxx b/sc/qa/unit/ucalc.cxx index d854c59..c96d5b6 100644 --- a/sc/qa/unit/ucalc.cxx +++ b/sc/qa/unit/ucalc.cxx @@ -6517,8 +6517,20 @@ void Test::testSharedFormulas() CPPUNIT_ASSERT_EQUAL(static_cast<SCROW>(1), pFC->GetSharedTopRow()); CPPUNIT_ASSERT_EQUAL(static_cast<SCROW>(4), pFC->GetSharedLength()); - m_pDoc->DeleteTab(0); + // Insert 2 rows at row 4, to split it into B2:B3 and B6:B7. + m_pDoc->InsertRow(ScRange(0,3,0,MAXCOL,4,0)); + pFC = m_pDoc->GetFormulaCell(aPos); + CPPUNIT_ASSERT_MESSAGE("B2 should be a formula cell.", pFC); + CPPUNIT_ASSERT_EQUAL(static_cast<SCROW>(1), pFC->GetSharedTopRow()); + CPPUNIT_ASSERT_EQUAL(static_cast<SCROW>(2), pFC->GetSharedLength()); + aPos.SetRow(5); + pFC = m_pDoc->GetFormulaCell(aPos); + CPPUNIT_ASSERT_MESSAGE("B6 should be a formula cell.", pFC); + CPPUNIT_ASSERT_EQUAL(static_cast<SCROW>(5), pFC->GetSharedTopRow()); + CPPUNIT_ASSERT_EQUAL(static_cast<SCROW>(2), pFC->GetSharedLength()); + + m_pDoc->DeleteTab(0); } namespace { diff --git a/sc/source/core/data/column.cxx b/sc/source/core/data/column.cxx index 7ce8668..f77502b 100644 --- a/sc/source/core/data/column.cxx +++ b/sc/source/core/data/column.cxx @@ -2273,6 +2273,25 @@ bool ScColumn::UpdateReference( return aHandler.isUpdated(); } + bool bThisColShifted = (rRange.aStart.Tab() <= nTab && nTab <= rRange.aEnd.Tab() && rRange.aStart.Col() <= nCol && nCol <= rRange.aEnd.Col()); + if (bThisColShifted) + { + // Cells in this column is being shifted. Split formula grouping at + // the top and bottom boundaries before they get shifted. + SCROW nSplitPos = rRange.aStart.Row(); + if (ValidRow(nSplitPos)) + { + sc::CellStoreType::position_type aPos = maCells.position(nSplitPos); + SplitFormulaCellGroup(aPos); + nSplitPos = rRange.aEnd.Row() + 1; + if (ValidRow(nSplitPos)) + { + aPos = maCells.position(aPos.first, nSplitPos); + SplitFormulaCellGroup(aPos); + } + } + } + UpdateRefOnNonCopy aHandler(nCol, nTab, rRange, nDx, nDy, nDz, eUpdateRefMode, pUndoDoc); FormulaCellsUndecided(0, MAXROW); sc::ProcessFormula(maCells, aHandler); diff --git a/sc/source/core/data/formulacell.cxx b/sc/source/core/data/formulacell.cxx index 8d84221..288eaeb 100644 --- a/sc/source/core/data/formulacell.cxx +++ b/sc/source/core/data/formulacell.cxx @@ -2084,6 +2084,9 @@ bool ScFormulaCell::UpdateReference( // This formula cell itself is being shifted during cell range // insertion or deletion. Update its position. aPos.Move(nDx, nDy, nDz); + if (xGroup && xGroup->mnStart == aOldPos.Row()) + xGroup->mnStart += nDy; + bCellStateChanged = aPos != aOldPos; } else if (rRange.In(aPos)) _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits