[Libreoffice-commits] core.git: 2 commits - sc/qa sc/source
Kohei Yoshida
kohei.yoshida at collabora.com
Sun Oct 12 07:21:28 PDT 2014
sc/qa/unit/ucalc_formula.cxx | 32 ++++++++++++++++++++++++++++++++
sc/source/core/data/column.cxx | 6 ++++++
sc/source/core/data/formulacell.cxx | 2 +-
3 files changed, 39 insertions(+), 1 deletion(-)
New commits:
commit 352958b7c6bbfeb8352570b28487cc1713f5a850
Author: Kohei Yoshida <kohei.yoshida at collabora.com>
Date: Sun Oct 12 10:19:49 2014 -0400
fdo#83901: Write a test for this.
Change-Id: If805ba07baa36cbf94ee22f77f98ef4057d8b306
diff --git a/sc/qa/unit/ucalc_formula.cxx b/sc/qa/unit/ucalc_formula.cxx
index d4344e2..45112d1 100644
--- a/sc/qa/unit/ucalc_formula.cxx
+++ b/sc/qa/unit/ucalc_formula.cxx
@@ -2541,6 +2541,38 @@ void Test::testFuncROW()
// The cell that references the moved cell should update its value as well.
CPPUNIT_ASSERT_EQUAL(11.0, m_pDoc->GetValue(ScAddress(0,1,0)));
+ // Clear sheet and start over.
+ clearSheet(m_pDoc, 0);
+
+ m_pDoc->SetString(ScAddress(0,1,0), "=ROW(A5)");
+ m_pDoc->SetString(ScAddress(1,1,0), "=ROW(B5)");
+ m_pDoc->SetString(ScAddress(1,2,0), "=ROW(B6)");
+ CPPUNIT_ASSERT_EQUAL(5.0, m_pDoc->GetValue(ScAddress(0,1,0)));
+ CPPUNIT_ASSERT_EQUAL(5.0, m_pDoc->GetValue(ScAddress(1,1,0)));
+ CPPUNIT_ASSERT_EQUAL(6.0, m_pDoc->GetValue(ScAddress(1,2,0)));
+
+ // B2:B3 should be shared.
+ const ScFormulaCell* pFC = m_pDoc->GetFormulaCell(ScAddress(1,1,0));
+ CPPUNIT_ASSERT(pFC);
+ CPPUNIT_ASSERT_EQUAL(static_cast<SCROW>(1), pFC->GetSharedTopRow());
+ CPPUNIT_ASSERT_EQUAL(static_cast<SCROW>(2), pFC->GetSharedLength());
+
+ // Insert a new row at row 4.
+ ScDocFunc& rFunc = getDocShell().GetDocFunc();
+ ScMarkData aMark;
+ aMark.SelectOneTable(0);
+ rFunc.InsertCells(ScRange(0,3,0,MAXCOL,3,0), &aMark, INS_INSROWS, false, true, false);
+ if (!checkFormula(*m_pDoc, ScAddress(0,1,0), "ROW(A6)"))
+ CPPUNIT_FAIL("Wrong formula!");
+ if (!checkFormula(*m_pDoc, ScAddress(1,1,0), "ROW(B6)"))
+ CPPUNIT_FAIL("Wrong formula!");
+ if (!checkFormula(*m_pDoc, ScAddress(1,2,0), "ROW(B7)"))
+ CPPUNIT_FAIL("Wrong formula!");
+
+ CPPUNIT_ASSERT_EQUAL(6.0, m_pDoc->GetValue(ScAddress(0,1,0)));
+ CPPUNIT_ASSERT_EQUAL(6.0, m_pDoc->GetValue(ScAddress(1,1,0)));
+ CPPUNIT_ASSERT_EQUAL(7.0, m_pDoc->GetValue(ScAddress(1,2,0)));
+
m_pDoc->DeleteTab(0);
}
commit 0b29a16d1dcffd75e49bd7ad3da867b0d0ebfa38
Author: Kohei Yoshida <kohei.yoshida at collabora.com>
Date: Sun Oct 12 10:18:09 2014 -0400
fdo#83901: ROW() and COLUMN() to be properly recalculated on cell move.
For cases where ROW or COLUMN references another cell that has shifted.
Change-Id: Ic4bef8672dab811ceff6886d9af0388306a66485
diff --git a/sc/source/core/data/column.cxx b/sc/source/core/data/column.cxx
index d6152dd..521b942 100644
--- a/sc/source/core/data/column.cxx
+++ b/sc/source/core/data/column.cxx
@@ -2044,6 +2044,12 @@ class UpdateRefOnNonCopy : std::unary_function<sc::FormulaGroupEntry, void>
if (pCode->IsRecalcModeOnRefMove())
aRes.mbValueChanged = true;
}
+ else if (aRes.mbReferenceModified && pCode->IsRecalcModeOnRefMove())
+ {
+ // The cell itself hasn't shifted. But it may have ROW or COLUMN
+ // referencing another cell that has.
+ aRes.mbValueChanged = true;
+ }
if (aRes.mbNameModified)
recompileTokenArray(*pTop);
diff --git a/sc/source/core/data/formulacell.cxx b/sc/source/core/data/formulacell.cxx
index 8cd9598..33f64e9 100644
--- a/sc/source/core/data/formulacell.cxx
+++ b/sc/source/core/data/formulacell.cxx
@@ -2788,7 +2788,7 @@ bool ScFormulaCell::UpdateReferenceOnShift(
if (bOnRefMove)
// Cell may reference itself, e.g. ocColumn, ocRow without parameter
- bOnRefMove = (bValChanged || (aPos != aOldPos));
+ bOnRefMove = (bValChanged || (aPos != aOldPos) || bRefModified);
bool bNewListening = false;
bool bInDeleteUndo = false;
More information about the Libreoffice-commits
mailing list