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 18:36:24 +0200
commit8ade7dce21143cd280935b174f4359d3d6d6d20b (patch)
tree1e1a4740108cf3181eaa994298d963d09da157ca /sc
parentf35673a825ecd4c4b331302c0408c65b9906f97f (diff)
unit test for adjustSingleRefInName() during column insertion
Change-Id: Ie406361c3a3497619f4faf3680f389f3bdf76a4b
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 b7ced943a975..0cb6cfb4ceb7 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);
}