sc/qa/unit/ucalc.cxx | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+)
New commits: commit c94a51494ae4f8fd84be838709abba28a37cd0f5 Author: Kohei Yoshida <kohei.yosh...@gmail.com> Date: Tue Feb 5 16:00:10 2013 -0500 fdo#39135: Add unit test for this. Change-Id: Id857bfdfd7a2e9024eabdc2b63c02d3d61e7e4f6 diff --git a/sc/qa/unit/ucalc.cxx b/sc/qa/unit/ucalc.cxx index 691ad87..2e3e5fb 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. _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits