[Libreoffice-commits] core.git: sc/qa sc/source
Andreas Heinisch (via logerrit)
logerrit at kemper.freedesktop.org
Mon Mar 29 18:19:01 UTC 2021
sc/qa/extras/macros-test.cxx | 49 +++++++++++++++++++++++++++++++
sc/qa/extras/testdocuments/tdf138646.ods |binary
sc/source/core/tool/rangeutl.cxx | 4 +-
3 files changed, 52 insertions(+), 1 deletion(-)
New commits:
commit 1bdef3250fc57ea3f9b69a1f55ceb035329b6fa9
Author: Andreas Heinisch <andreas.heinisch at yahoo.de>
AuthorDate: Wed Mar 17 10:33:05 2021 +0100
Commit: Eike Rathke <erack at redhat.com>
CommitDate: Mon Mar 29 20:18:24 2021 +0200
tdf#138646 - consider the document's address convention
When accessing a named range using getCellRangeByName, consider the
document's address convention. Otherwise, an exception is raised, when
the formula syntax is EXCEL R1C1 or EXCEL A1.
Change-Id: I5df2546f1c3fd00ff30cb057dcf47f6bb01d501d
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/112602
Tested-by: Jenkins
Reviewed-by: Eike Rathke <erack at redhat.com>
diff --git a/sc/qa/extras/macros-test.cxx b/sc/qa/extras/macros-test.cxx
index 14cb8c6d8101..06f921ca35e9 100644
--- a/sc/qa/extras/macros-test.cxx
+++ b/sc/qa/extras/macros-test.cxx
@@ -55,6 +55,7 @@ public:
void testTdf43003();
void testTdf133887();
void testTdf133889();
+ void testTdf138646();
CPPUNIT_TEST_SUITE(ScMacrosTest);
CPPUNIT_TEST(testStarBasic);
@@ -77,6 +78,7 @@ public:
CPPUNIT_TEST(testTdf43003);
CPPUNIT_TEST(testTdf133887);
CPPUNIT_TEST(testTdf133889);
+ CPPUNIT_TEST(testTdf138646);
CPPUNIT_TEST_SUITE_END();
};
@@ -976,6 +978,53 @@ void ScMacrosTest::testTdf133889()
xCloseable->close(true);
}
+void ScMacrosTest::testTdf138646()
+{
+ OUString aFileName;
+ createFileURL(u"tdf138646.ods", aFileName);
+ auto xComponent = loadFromDesktop(aFileName, "com.sun.star.sheet.SpreadsheetDocument");
+ CPPUNIT_ASSERT_MESSAGE("Failed to load the doc", xComponent.is());
+
+ SfxObjectShell* pFoundShell = SfxObjectShell::GetShellFromComponent(xComponent);
+ CPPUNIT_ASSERT_MESSAGE("Failed to access document shell", pFoundShell);
+
+ ScDocShell* pDocSh = dynamic_cast<ScDocShell*>(pFoundShell);
+ CPPUNIT_ASSERT(pDocSh);
+
+ // Without the fix in place, changing the grammar from GRAM_NATIVE to either GRAM_NATIVE_XL_A1
+ // or GRAM_NATIVE_XL_R1C1 would cause a Basic exception/error in the following script.
+ pDocSh->GetDocument().SetGrammar(formula::FormulaGrammar::Grammar::GRAM_NATIVE_XL_R1C1);
+
+ const std::vector<std::pair<OUString, OUString>> aTests({
+ { "GlobalNamedCell", "GlobalNamedCell" },
+ { "GlobalNamedCellSheet", "GlobalNamedCell" },
+ { "LocalNamedCell", "LocalNamedCell" },
+ { "LocalNamedCellAccessError", "Exception" }
+ });
+
+ {
+ Any aRet;
+ Sequence<sal_Int16> aOutParamIndex;
+ Sequence<Any> aOutParam;
+ Sequence<uno::Any> aParams;
+
+ for (auto& [sTestName, sExpected] : aTests)
+ {
+ SfxObjectShell::CallXScript(xComponent,
+ "vnd.sun.Star.script:Standard.Module1." + sTestName
+ + "?language=Basic&location=document",
+ aParams, aRet, aOutParamIndex, aOutParam);
+
+ OUString aReturnValue;
+ aRet >>= aReturnValue;
+ CPPUNIT_ASSERT_EQUAL_MESSAGE(sTestName.toUtf8().getStr(), sExpected, aReturnValue);
+ }
+ }
+
+ pDocSh->DoClose();
+}
+
+
ScMacrosTest::ScMacrosTest()
: UnoApiTest("/sc/qa/extras/testdocuments")
{
diff --git a/sc/qa/extras/testdocuments/tdf138646.ods b/sc/qa/extras/testdocuments/tdf138646.ods
new file mode 100644
index 000000000000..9faa95a54334
Binary files /dev/null and b/sc/qa/extras/testdocuments/tdf138646.ods differ
diff --git a/sc/source/core/tool/rangeutl.cxx b/sc/source/core/tool/rangeutl.cxx
index 401ad6ad5722..1a7467fbb0ec 100644
--- a/sc/source/core/tool/rangeutl.cxx
+++ b/sc/source/core/tool/rangeutl.cxx
@@ -276,7 +276,9 @@ bool ScRangeUtil::MakeRangeFromName (
ScRefAddress aStartPos;
ScRefAddress aEndPos;
- pData->GetSymbol( aStrArea );
+ // tdf#138646 - consider the current grammar and address convention of the document
+ pData->GetSymbol(aStrArea,
+ FormulaGrammar::mergeToGrammar(rDoc.GetGrammar(), rDetails.eConv));
if ( IsAbsArea( aStrArea, rDoc, nTable,
nullptr, &aStartPos, &aEndPos, rDetails ) )
More information about the Libreoffice-commits
mailing list