[Libreoffice-commits] core.git: 2 commits - sc/qa sc/source
Kohei Yoshida
kohei.yoshida at collabora.com
Wed Sep 3 13:57:36 PDT 2014
sc/qa/unit/ucalc.hxx | 2 +
sc/qa/unit/ucalc_formula.cxx | 56 ++++++++++++++++++++++++++++++++++++++++++
sc/source/core/tool/token.cxx | 6 +++-
3 files changed, 63 insertions(+), 1 deletion(-)
New commits:
commit 41afbdcc624c075888610a049e84a14c548bdaac
Author: Kohei Yoshida <kohei.yoshida at collabora.com>
Date: Wed Sep 3 22:59:11 2014 +0200
fdo#83217: Write test for this.
Change-Id: I5af25079a24d4c18eed70a7f0abc42d84cfc2242
diff --git a/sc/qa/unit/ucalc.hxx b/sc/qa/unit/ucalc.hxx
index 031517b..ec9542c 100644
--- a/sc/qa/unit/ucalc.hxx
+++ b/sc/qa/unit/ucalc.hxx
@@ -131,6 +131,7 @@ public:
void testFormulaRefUpdateInsertColumns();
void testFormulaRefUpdateMove();
void testFormulaRefUpdateMoveUndo();
+ void testFormulaRefUpdateMoveToSheet();
void testFormulaRefUpdateDeleteContent();
void testFormulaRefUpdateNamedExpression();
void testFormulaRefUpdateNamedExpressionMove();
@@ -412,6 +413,7 @@ public:
CPPUNIT_TEST(testFormulaRefUpdateInsertColumns);
CPPUNIT_TEST(testFormulaRefUpdateMove);
CPPUNIT_TEST(testFormulaRefUpdateMoveUndo);
+ CPPUNIT_TEST(testFormulaRefUpdateMoveToSheet);
CPPUNIT_TEST(testFormulaRefUpdateDeleteContent);
CPPUNIT_TEST(testFormulaRefUpdateNamedExpression);
CPPUNIT_TEST(testFormulaRefUpdateNamedExpressionMove);
diff --git a/sc/qa/unit/ucalc_formula.cxx b/sc/qa/unit/ucalc_formula.cxx
index 416e41d..d4344e2 100644
--- a/sc/qa/unit/ucalc_formula.cxx
+++ b/sc/qa/unit/ucalc_formula.cxx
@@ -1849,6 +1849,62 @@ void Test::testFormulaRefUpdateMoveUndo()
m_pDoc->DeleteTab(0);
}
+void Test::testFormulaRefUpdateMoveToSheet()
+{
+ sc::AutoCalcSwitch aACSwitch(*m_pDoc, true); // turn auto calc on.
+
+ m_pDoc->InsertTab(0, "Sheet1");
+ m_pDoc->InsertTab(1, "Sheet2");
+
+ // Set values to A1:A2 on Sheet1, and B1:B2 to reference them.
+ m_pDoc->SetValue(ScAddress(0,0,0), 11);
+ m_pDoc->SetValue(ScAddress(0,1,0), 12);
+ m_pDoc->SetString(ScAddress(1,0,0), "=A1");
+ m_pDoc->SetString(ScAddress(1,1,0), "=A2");
+
+ if (!checkFormula(*m_pDoc, ScAddress(1,0,0), "A1"))
+ CPPUNIT_FAIL("Wrong formula");
+
+ if (!checkFormula(*m_pDoc, ScAddress(1,1,0), "A2"))
+ CPPUNIT_FAIL("Wrong formula");
+
+ CPPUNIT_ASSERT_EQUAL(11.0, m_pDoc->GetValue(ScAddress(1,0,0)));
+ CPPUNIT_ASSERT_EQUAL(12.0, m_pDoc->GetValue(ScAddress(1,1,0)));
+
+ // Move A1:A2 on Sheet1 to B3:B4 on Sheet2.
+ ScDocFunc& rFunc = getDocShell().GetDocFunc();
+ bool bMoved = rFunc.MoveBlock(ScRange(0,0,0,0,1,0), ScAddress(1,2,1), true, true, false, true);
+ CPPUNIT_ASSERT(bMoved);
+
+ if (!checkFormula(*m_pDoc, ScAddress(1,0,0), "Sheet2.B3"))
+ CPPUNIT_FAIL("Wrong formula");
+
+ if (!checkFormula(*m_pDoc, ScAddress(1,1,0), "Sheet2.B4"))
+ CPPUNIT_FAIL("Wrong formula");
+
+ // Undo and check again.
+ SfxUndoManager* pUndoMgr = m_pDoc->GetUndoManager();
+ pUndoMgr->Undo();
+
+ if (!checkFormula(*m_pDoc, ScAddress(1,0,0), "A1"))
+ CPPUNIT_FAIL("Wrong formula");
+
+ if (!checkFormula(*m_pDoc, ScAddress(1,1,0), "A2"))
+ CPPUNIT_FAIL("Wrong formula");
+
+ // Redo and check.
+ pUndoMgr->Redo();
+
+ if (!checkFormula(*m_pDoc, ScAddress(1,0,0), "Sheet2.B3"))
+ CPPUNIT_FAIL("Wrong formula");
+
+ if (!checkFormula(*m_pDoc, ScAddress(1,1,0), "Sheet2.B4"))
+ CPPUNIT_FAIL("Wrong formula");
+
+ m_pDoc->DeleteTab(1);
+ m_pDoc->DeleteTab(0);
+}
+
void Test::testFormulaRefUpdateDeleteContent()
{
sc::AutoCalcSwitch aACSwitch(*m_pDoc, true); // turn auto calc on.
commit 31abf4ce4e18cf2e94c6e598f255ae7cd8f675fa
Author: Kohei Yoshida <kohei.yoshida at collabora.com>
Date: Wed Sep 3 22:32:07 2014 +0200
fdo#83217: Set 3D flags correctly when moving block of cells.
Change-Id: Ibca5ff36f50f2b6fe182b008ead3efcb1c5a0be6
diff --git a/sc/source/core/tool/token.cxx b/sc/source/core/tool/token.cxx
index 7e04064..396ffcb 100644
--- a/sc/source/core/tool/token.cxx
+++ b/sc/source/core/tool/token.cxx
@@ -2812,7 +2812,7 @@ sc::RefUpdateResult ScTokenArray::AdjustReferenceOnMove(
ScRange aOldRange = rCxt.maRange;
aOldRange.Move(-rCxt.mnColDelta, -rCxt.mnRowDelta, -rCxt.mnTabDelta);
- bool b3DFlag = rOldPos.Tab() != rNewPos.Tab();
+ bool b3DFlag = rOldPos.Tab() != rNewPos.Tab() || rCxt.mnTabDelta;
FormulaToken** p = pCode;
FormulaToken** pEnd = p + static_cast<size_t>(nLen);
@@ -2888,6 +2888,8 @@ sc::RefUpdateResult ScTokenArray::MoveReference( const ScAddress& rPos, const sc
{
aAbs.Move(rCxt.mnColDelta, rCxt.mnRowDelta, rCxt.mnTabDelta);
rRef.SetAddress(aAbs, rPos);
+ if (rCxt.mnTabDelta)
+ rRef.SetFlag3D(aAbs.Tab()!=rPos.Tab());
}
}
break;
@@ -2900,6 +2902,8 @@ sc::RefUpdateResult ScTokenArray::MoveReference( const ScAddress& rPos, const sc
{
aAbs.Move(rCxt.mnColDelta, rCxt.mnRowDelta, rCxt.mnTabDelta);
rRef.SetRange(aAbs, rPos);
+ if (rCxt.mnTabDelta)
+ rRef.Ref1.SetFlag3D(aAbs.aStart.Tab()!=rPos.Tab());
}
}
break;
More information about the Libreoffice-commits
mailing list