summaryrefslogtreecommitdiff
path: root/sc
diff options
context:
space:
mode:
authorEike Rathke <erack@redhat.com>2015-06-21 18:23:54 +0200
committerEike Rathke <erack@redhat.com>2015-06-21 19:21:10 +0200
commitbf73c22c2110c8ca29e7a00e02d293a85e5db70e (patch)
tree8175065a54d977c828ba9bd1e2a8d2ae253d82b5 /sc
parente6080277c586dbc9f02b9893dd561e98d76027ba (diff)
unit test for adjustSingleRefInName() during column insertion
Change-Id: Ie406361c3a3497619f4faf3680f389f3bdf76a4b (cherry picked from commit 8ade7dce21143cd280935b174f4359d3d6d6d20b)
Diffstat (limited to 'sc')
-rw-r--r--sc/qa/unit/ucalc_formula.cxx21
1 files changed, 21 insertions, 0 deletions
diff --git a/sc/qa/unit/ucalc_formula.cxx b/sc/qa/unit/ucalc_formula.cxx
index 487981a61917..08026cbc581a 100644
--- a/sc/qa/unit/ucalc_formula.cxx
+++ b/sc/qa/unit/ucalc_formula.cxx
@@ -1704,6 +1704,11 @@ void Test::testFormulaRefUpdateInsertColumns()
m_pDoc->InsertTab(0, "Formula");
+ // Set named range for B2 with absolute column and relative same row.
+ const ScAddress aNamePos(0,1,0);
+ bool bInserted = m_pDoc->InsertNewRangeName("RowRelativeRange", aNamePos, "$Formula.$B2");
+ CPPUNIT_ASSERT(bInserted);
+
// Set values in B1:B3.
m_pDoc->SetValue(ScAddress(1,0,0), 1.0);
m_pDoc->SetValue(ScAddress(1,1,0), 2.0);
@@ -1713,6 +1718,10 @@ void Test::testFormulaRefUpdateInsertColumns()
m_pDoc->SetString(ScAddress(1,3,0), "=SUM(B1:B3)");
CPPUNIT_ASSERT_EQUAL(6.0, m_pDoc->GetValue(ScAddress(1,3,0)));
+ // Use named range in C2 to reference B2.
+ m_pDoc->SetString(ScAddress(2,1,0), "=RowRelativeRange");
+ CPPUNIT_ASSERT_EQUAL(2.0, m_pDoc->GetValue(ScAddress(2,1,0)));
+
// Inert columns over A:B.
ScMarkData aMark;
aMark.SelectOneTable(0);
@@ -1725,6 +1734,18 @@ void Test::testFormulaRefUpdateInsertColumns()
CPPUNIT_ASSERT_EQUAL(6.0, m_pDoc->GetValue(ScAddress(3,3,0)));
+ // Check that the named reference points to the moved cell, now D2.
+ ScRangeData* pName = m_pDoc->GetRangeName()->findByUpperName("ROWRELATIVERANGE");
+ CPPUNIT_ASSERT(pName);
+ OUString aSymbol;
+ pName->GetSymbol(aSymbol, aNamePos, formula::FormulaGrammar::GRAM_ENGLISH);
+ CPPUNIT_ASSERT_EQUAL(OUString("$Formula.$D2"), aSymbol);
+
+ // Check that the formula using the name, now in E2, still has the same result.
+ if (!checkFormula(*m_pDoc, ScAddress(4,1,0), "RowRelativeRange"))
+ CPPUNIT_FAIL("Wrong formula in E2 after column insertion.");
+ CPPUNIT_ASSERT_EQUAL(2.0, m_pDoc->GetValue(ScAddress(4,1,0)));
+
m_pDoc->DeleteTab(0);
}