summaryrefslogtreecommitdiff
path: root/sc/qa
diff options
context:
space:
mode:
authorAndreas Heinisch <andreas.heinisch@yahoo.de>2023-04-06 17:38:52 +0200
committerAndras Timar <andras.timar@collabora.com>2023-05-13 20:01:53 +0200
commita1cdacbd125afb3cbe6c017cf5084ee4581e0fc2 (patch)
tree590097a40bb443548cbb617667fc54f089598417 /sc/qa
parente3b3a51d939bbb6c7a4dcf94de2813e5f8882b2c (diff)
tdf#113027 - Allow cycling cell reference types including whitespaces
A formula containing a remote reference to a sheet including a whitespace in its name does not correctly handle switching from relative to absolute cell references using the EXCEL R1C1 formular grammar. Change-Id: I3391f4e8f57993899b5e97f0a173b624b5ef0b22 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/150109 Tested-by: Jenkins Reviewed-by: Andreas Heinisch <andreas.heinisch@yahoo.de> Signed-off-by: Xisco Fauli <xiscofauli@libreoffice.org> Reviewed-on: https://gerrit.libreoffice.org/c/core/+/150130 Reviewed-by: Adolfo Jayme Barrientos <fitojb@ubuntu.com>
Diffstat (limited to 'sc/qa')
-rw-r--r--sc/qa/unit/ucalc.cxx28
1 files changed, 28 insertions, 0 deletions
diff --git a/sc/qa/unit/ucalc.cxx b/sc/qa/unit/ucalc.cxx
index e5aa8515c663..84ffe142ef81 100644
--- a/sc/qa/unit/ucalc.cxx
+++ b/sc/qa/unit/ucalc.cxx
@@ -95,6 +95,7 @@ public:
void testInput();
void testColumnIterator();
void testTdf66613();
+ void testTdf113027();
void testTdf90698();
void testTdf114406();
void testTdf93951();
@@ -246,6 +247,7 @@ public:
CPPUNIT_TEST(testInput);
CPPUNIT_TEST(testColumnIterator);
CPPUNIT_TEST(testTdf66613);
+ CPPUNIT_TEST(testTdf113027);
CPPUNIT_TEST(testTdf90698);
CPPUNIT_TEST(testTdf114406);
CPPUNIT_TEST(testTdf93951);
@@ -701,6 +703,32 @@ void Test::testTdf66613()
m_pDoc->DeleteTab(nSecondTab);
}
+void Test::testTdf113027()
+{
+ // Insert some sheets including a whitespace in their name and switch the grammar to R1C1
+ CPPUNIT_ASSERT(m_pDoc->InsertTab(0, "Sheet 1"));
+ CPPUNIT_ASSERT(m_pDoc->InsertTab(1, "Sheet 2"));
+ FormulaGrammarSwitch aFGSwitch(m_pDoc, formula::FormulaGrammar::GRAM_ENGLISH_XL_R1C1);
+
+ // Add a formula containing a remote reference, i.e., to another sheet
+ const ScAddress aScAddress(0, 0, 0);
+ const OUString aFormula = "='Sheet 2'!RC";
+ m_pDoc->SetString(aScAddress, aFormula);
+
+ // Switch from relative to absolute cell reference
+ ScRefFinder aFinder(aFormula, aScAddress, *m_pDoc, m_pDoc->GetAddressConvention());
+ aFinder.ToggleRel(0, aFormula.getLength());
+
+ // Without the fix in place, this test would have failed with
+ // - Expected: ='Sheet 2'!R1C1
+ // - Actual : ='Sheet 2'!RC
+ // i.e. the cell reference was not changed from relative to absolute
+ CPPUNIT_ASSERT_EQUAL(OUString("='Sheet 2'!R1C1"), aFinder.GetText());
+
+ m_pDoc->DeleteTab(0);
+ m_pDoc->DeleteTab(1);
+}
+
void Test::testTdf90698()
{
CPPUNIT_ASSERT(m_pDoc->InsertTab (0, "Test"));