sc/qa/unit/ucalc.hxx | 2 + sc/qa/unit/ucalc_sharedformula.cxx | 39 ++++++++++++++++++++++++++++++++++++ sc/source/core/data/formulacell.cxx | 8 +++++++ 3 files changed, 49 insertions(+)
New commits: commit 1556dbc451f067d8744378fb9bac0eaa7ef8f5ac Author: Kohei Yoshida <kohei.yosh...@collabora.com> Date: Sat Feb 8 15:13:18 2014 -0500 fdo#74453: Only adjust tokens for top formula cells of formula group. Change-Id: Id04387dffac271b3d617da0fbc19c862c929d60a diff --git a/sc/source/core/data/formulacell.cxx b/sc/source/core/data/formulacell.cxx index a1e9ec1..88ca441 100644 --- a/sc/source/core/data/formulacell.cxx +++ b/sc/source/core/data/formulacell.cxx @@ -3023,6 +3023,10 @@ void ScFormulaCell::UpdateInsertTabAbs(SCTAB nTable) if (pDocument->IsClipOrUndo()) return; + bool bAdjustCode = !mxGroup || mxGroup->mpTopCell == this; + if (!bAdjustCode) + return; + pCode->Reset(); ScToken* p = static_cast<ScToken*>(pCode->GetNextReferenceRPN()); while (p) @@ -3045,6 +3049,10 @@ bool ScFormulaCell::TestTabRefAbs(SCTAB nTable) if (pDocument->IsClipOrUndo()) return false; + bool bAdjustCode = !mxGroup || mxGroup->mpTopCell == this; + if (!bAdjustCode) + return false; + bool bRet = false; pCode->Reset(); ScToken* p = static_cast<ScToken*>(pCode->GetNextReferenceRPN()); commit ac5682aa3013550e3643026c571b5d851b9e7b67 Author: Kohei Yoshida <kohei.yosh...@collabora.com> Date: Sat Feb 8 14:42:31 2014 -0500 fdo#74453: Write unit test for this. Change-Id: Ic8cbc650d6608ff7af5d1d58deeeba409bb81725 diff --git a/sc/qa/unit/ucalc.hxx b/sc/qa/unit/ucalc.hxx index f595467..053e607 100644 --- a/sc/qa/unit/ucalc.hxx +++ b/sc/qa/unit/ucalc.hxx @@ -252,6 +252,7 @@ public: void testSharedFormulasRefUpdateRange(); void testSharedFormulasDeleteRows(); void testSharedFormulasRefUpdateMoveSheets(); + void testSharedFormulasRefUpdateCopySheets(); void testSharedFormulasCopyPaste(); void testSharedFormulaInsertColumn(); void testFormulaPosition(); @@ -414,6 +415,7 @@ public: CPPUNIT_TEST(testSharedFormulasRefUpdateRange); CPPUNIT_TEST(testSharedFormulasDeleteRows); CPPUNIT_TEST(testSharedFormulasRefUpdateMoveSheets); + CPPUNIT_TEST(testSharedFormulasRefUpdateCopySheets); CPPUNIT_TEST(testSharedFormulasCopyPaste); CPPUNIT_TEST(testSharedFormulaInsertColumn); CPPUNIT_TEST(testFormulaPosition); diff --git a/sc/qa/unit/ucalc_sharedformula.cxx b/sc/qa/unit/ucalc_sharedformula.cxx index 04e917f..a64398b 100644 --- a/sc/qa/unit/ucalc_sharedformula.cxx +++ b/sc/qa/unit/ucalc_sharedformula.cxx @@ -600,6 +600,45 @@ void Test::testSharedFormulasRefUpdateMoveSheets() m_pDoc->DeleteTab(0); } +void Test::testSharedFormulasRefUpdateCopySheets() +{ + sc::AutoCalcSwitch aACSwitch(*m_pDoc, true); // make sure auto calc is on. + + m_pDoc->InsertTab(0, "Sheet1"); + m_pDoc->InsertTab(1, "Sheet2"); + + m_pDoc->SetValue(ScAddress(0,0,1), 1.0); // A1 on Sheet2 + m_pDoc->SetValue(ScAddress(0,1,1), 2.0); // A2 on Sheet2 + + // Reference values on Sheet2, but use absolute sheet references. + m_pDoc->SetString(ScAddress(0,0,0), "=$Sheet2.A1"); + m_pDoc->SetString(ScAddress(0,1,0), "=$Sheet2.A2"); + + CPPUNIT_ASSERT_EQUAL(1.0, m_pDoc->GetValue(ScAddress(0,0,0))); + CPPUNIT_ASSERT_EQUAL(2.0, m_pDoc->GetValue(ScAddress(0,1,0))); + + // Copy Sheet1 and insert the copied sheet before the current Sheet1 position. + m_pDoc->CopyTab(0, 0); + + if (!checkFormula(*m_pDoc, ScAddress(0,0,0), "$Sheet2.A1")) + CPPUNIT_FAIL("Wrong formula"); + + if (!checkFormula(*m_pDoc, ScAddress(0,1,0), "$Sheet2.A2")) + CPPUNIT_FAIL("Wrong formula"); + + // Check the values on the copied sheet. + CPPUNIT_ASSERT_EQUAL(1.0, m_pDoc->GetValue(ScAddress(0,0,0))); + CPPUNIT_ASSERT_EQUAL(2.0, m_pDoc->GetValue(ScAddress(0,1,0))); + + // Check the values on the original sheet. + CPPUNIT_ASSERT_EQUAL(1.0, m_pDoc->GetValue(ScAddress(0,0,1))); + CPPUNIT_ASSERT_EQUAL(2.0, m_pDoc->GetValue(ScAddress(0,1,1))); + + m_pDoc->DeleteTab(2); + m_pDoc->DeleteTab(1); + m_pDoc->DeleteTab(0); +} + void Test::testSharedFormulasCopyPaste() { m_pDoc->InsertTab(0, "Test"); _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits