diff options
author | Kohei Yoshida <kohei.yoshida@gmail.com> | 2013-02-05 16:00:10 -0500 |
---|---|---|
committer | Kohei Yoshida <kohei.yoshida@gmail.com> | 2013-02-05 16:01:00 -0500 |
commit | c94a51494ae4f8fd84be838709abba28a37cd0f5 (patch) | |
tree | 9fcee628f34e082cee8b080965fd8e12239949c8 | |
parent | 1651080f8a11cd02d316d661b65c6d4e247d085e (diff) |
fdo#39135: Add unit test for this.
Change-Id: Id857bfdfd7a2e9024eabdc2b63c02d3d61e7e4f6
-rw-r--r-- | sc/qa/unit/ucalc.cxx | 35 |
1 files changed, 35 insertions, 0 deletions
diff --git a/sc/qa/unit/ucalc.cxx b/sc/qa/unit/ucalc.cxx index 691ad87078c1..2e3e5fb2e332 100644 --- a/sc/qa/unit/ucalc.cxx +++ b/sc/qa/unit/ucalc.cxx @@ -4991,6 +4991,41 @@ void Test::testToggleRefFlag() CPPUNIT_ASSERT_MESSAGE( "Wrong conversion.", aFormula == "=R2C1" ); } + { + // Excel R1C1: Selection at the end of the formula string and does not + // overlap the formula string at all (inspired by fdo#39135). + OUString aFormula("=R1C1"); + ScAddress aPos(1, 1, 0); + ScRefFinder aFinder(aFormula, aPos, m_pDoc, formula::FormulaGrammar::CONV_XL_R1C1); + + // Original + CPPUNIT_ASSERT_EQUAL(aFormula, OUString(aFinder.GetText())); + + // Make the column relative. + sal_Int32 n = aFormula.getLength(); + aFinder.ToggleRel(n, n); + aFormula = aFinder.GetText(); + CPPUNIT_ASSERT_EQUAL(OUString("=R1C[-1]"), aFormula); + + // Make the row relative. + n = aFormula.getLength(); + aFinder.ToggleRel(n, n); + aFormula = aFinder.GetText(); + CPPUNIT_ASSERT_EQUAL(OUString("=R[-1]C1"), aFormula); + + // Make both relative. + n = aFormula.getLength(); + aFinder.ToggleRel(n, n); + aFormula = aFinder.GetText(); + CPPUNIT_ASSERT_EQUAL(OUString("=R[-1]C[-1]"), aFormula); + + // Back to the original. + n = aFormula.getLength(); + aFinder.ToggleRel(n, n); + aFormula = aFinder.GetText(); + CPPUNIT_ASSERT_EQUAL(OUString("=R1C1"), aFormula); + } + // TODO: Add more test cases esp. for 3D references, Excel A1 syntax, and // partial selection within formula string. |