sc/qa/unit/uicalc/uicalc.cxx | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+)
New commits: commit 1d4c4e82f1704eb66fb130ae03ee9ad28ddb2067 Author: Xisco Fauli <xiscofa...@libreoffice.org> AuthorDate: Fri Mar 25 12:20:40 2022 +0100 Commit: Xisco Fauli <xiscofa...@libreoffice.org> CommitDate: Fri Mar 25 17:42:01 2022 +0100 tdf#113541: sc_uicalc: Add unittest Change-Id: I8c2e2b531ef31b834d7431543c94acfb67ff9ae2 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/132113 Tested-by: Jenkins Reviewed-by: Xisco Fauli <xiscofa...@libreoffice.org> diff --git a/sc/qa/unit/uicalc/uicalc.cxx b/sc/qa/unit/uicalc/uicalc.cxx index 90bafa91f64e..917ef6b2d9b9 100644 --- a/sc/qa/unit/uicalc/uicalc.cxx +++ b/sc/qa/unit/uicalc/uicalc.cxx @@ -380,6 +380,42 @@ CPPUNIT_TEST_FIXTURE(ScUiCalcTest, testTdf103994) CPPUNIT_ASSERT_EQUAL(1.0, pDoc->GetValue(ScAddress(1, 0, 0))); } +CPPUNIT_TEST_FIXTURE(ScUiCalcTest, testTdf113541) +{ + mxComponent = loadFromDesktop("private:factory/scalc"); + ScModelObj* pModelObj = dynamic_cast<ScModelObj*>(mxComponent.get()); + CPPUNIT_ASSERT(pModelObj); + ScDocument* pDoc = pModelObj->GetDocument(); + CPPUNIT_ASSERT(pDoc); + + insertStringToCell(*pModelObj, "A1", "50"); + + // Save the document + utl::TempFile aTempFile = save(mxComponent, "calc8"); + + // Open a new document + mxComponent = loadFromDesktop("private:factory/scalc"); + pModelObj = dynamic_cast<ScModelObj*>(mxComponent.get()); + CPPUNIT_ASSERT(pModelObj); + pDoc = pModelObj->GetDocument(); + CPPUNIT_ASSERT(pDoc); + + // Change grammar to Excel A1 + pDoc->SetGrammar(formula::FormulaGrammar::GRAM_ENGLISH_XL_A1); + + // Insert the reference to the external document + OUString aFormula = "=['" + aTempFile.GetURL() + "']Sheet1!A1"; + insertStringToCell(*pModelObj, "A1", aFormula.toUtf8().getStr()); + + // Without the fix in place, this test would have failed with + // - Expected: 50 + // - Actual : Err:507 + CPPUNIT_ASSERT_EQUAL(OUString("50"), pDoc->GetString(ScAddress(0, 0, 0))); + + // Change grammar to default + pDoc->SetGrammar(formula::FormulaGrammar::GRAM_ENGLISH); +} + CPPUNIT_TEST_FIXTURE(ScUiCalcTest, testTdf126577) { mxComponent = loadFromDesktop("private:factory/scalc");