diff options
author | Xisco Fauli <xiscofauli@libreoffice.org> | 2022-03-23 20:24:08 +0100 |
---|---|---|
committer | Xisco Fauli <xiscofauli@libreoffice.org> | 2022-03-24 11:55:45 +0100 |
commit | 6e3ed5559ad2c7e037d04b644801d7a4f48754a0 (patch) | |
tree | d6c1e47c071820fa1f67416093ab73cde204263f | |
parent | 14393256231c69ed143ddede4e7532ed8faa6a88 (diff) |
tdf#36387: sc_uicalc: Add unittest
Change-Id: I6da7fbb03d127a093042a5dc6546f314b6af40ed
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/131988
Tested-by: Jenkins
Reviewed-by: Xisco Fauli <xiscofauli@libreoffice.org>
-rw-r--r-- | sc/qa/unit/uicalc/uicalc.cxx | 37 |
1 files changed, 37 insertions, 0 deletions
diff --git a/sc/qa/unit/uicalc/uicalc.cxx b/sc/qa/unit/uicalc/uicalc.cxx index 13e12973c07b..fe90247e16ce 100644 --- a/sc/qa/unit/uicalc/uicalc.cxx +++ b/sc/qa/unit/uicalc/uicalc.cxx @@ -195,6 +195,43 @@ ScModelObj* ScUiCalcTest::saveAndReload(css::uno::Reference<css::lang::XComponen return pModelObj; } +CPPUNIT_TEST_FIXTURE(ScUiCalcTest, testTdf36387) +{ + 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", "1"); + insertStringToCell(*pModelObj, "B1", "2"); + insertStringToCell(*pModelObj, "C1", "3"); + insertStringToCell(*pModelObj, "D1", "4"); + + // 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); + + // Insert the reference to the external document + OUString aAndFormula = "=AND('" + aTempFile.GetURL() + "'#$Sheet1.A1:D1)"; + insertStringToCell(*pModelObj, "A1", aAndFormula.toUtf8().getStr()); + + OUString aOrFormula = "=OR('" + aTempFile.GetURL() + "'#$Sheet1.A1:D1)"; + insertStringToCell(*pModelObj, "B1", aOrFormula.toUtf8().getStr()); + + // Without the fix in place, this test would have failed with + // - Expected: TRUE + // - Actual : Err:504 + CPPUNIT_ASSERT_EQUAL(OUString("TRUE"), pDoc->GetString(ScAddress(0, 0, 0))); + CPPUNIT_ASSERT_EQUAL(OUString("TRUE"), pDoc->GetString(ScAddress(1, 0, 0))); +} + CPPUNIT_TEST_FIXTURE(ScUiCalcTest, testTdf103994) { mxComponent = loadFromDesktop("private:factory/scalc"); |