sc/qa/unit/uicalc/uicalc.cxx |   37 +++++++++++++++++++++++++++++++++++++
 1 file changed, 37 insertions(+)

New commits:
commit 6e3ed5559ad2c7e037d04b644801d7a4f48754a0
Author:     Xisco Fauli <xiscofa...@libreoffice.org>
AuthorDate: Wed Mar 23 20:24:08 2022 +0100
Commit:     Xisco Fauli <xiscofa...@libreoffice.org>
CommitDate: Thu Mar 24 11:55:45 2022 +0100

    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 <xiscofa...@libreoffice.org>

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");

Reply via email to