sc/qa/extras/macros-test.cxx             |   48 +++++++++++++++++++++++++++++++
 sc/qa/extras/testdocuments/tdf125800.ods |binary
 2 files changed, 48 insertions(+)

New commits:
commit 2fa01ae540e174452bf5cd763c1464cfe37af076
Author:     Xisco Fauli <xiscofa...@libreoffice.org>
AuthorDate: Tue Mar 29 16:41:56 2022 +0200
Commit:     Xisco Fauli <xiscofa...@libreoffice.org>
CommitDate: Tue Mar 29 21:06:34 2022 +0200

    tdf#125800: sc_macros: Add unittest
    
    Change-Id: I9286264bbfa1e59e51d2a94417f7e8526357f821
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/132277
    Tested-by: Jenkins
    Reviewed-by: Xisco Fauli <xiscofa...@libreoffice.org>

diff --git a/sc/qa/extras/macros-test.cxx b/sc/qa/extras/macros-test.cxx
index 88195ac74153..98c469ee2217 100644
--- a/sc/qa/extras/macros-test.cxx
+++ b/sc/qa/extras/macros-test.cxx
@@ -16,6 +16,7 @@
 #include <comphelper/processfactory.hxx>
 #include <comphelper/propertyvalue.hxx>
 
+#include <conditio.hxx>
 #include <docsh.hxx>
 #include <document.hxx>
 #include <scitems.hxx>
@@ -67,6 +68,7 @@ public:
     void testTdf105558();
     void testTdf143582();
     void testTdf144085();
+    void testTdf125800();
     void testTdf130307();
     void testTdf146742();
     void testMacroButtonFormControlXlsxExport();
@@ -100,6 +102,7 @@ public:
     CPPUNIT_TEST(testTdf105558);
     CPPUNIT_TEST(testTdf143582);
     CPPUNIT_TEST(testTdf144085);
+    CPPUNIT_TEST(testTdf125800);
     CPPUNIT_TEST(testTdf130307);
     CPPUNIT_TEST(testTdf146742);
     CPPUNIT_TEST(testMacroButtonFormControlXlsxExport);
@@ -925,6 +928,51 @@ void ScMacrosTest::testTdf144085()
     xCloseable->close(true);
 }
 
+void ScMacrosTest::testTdf125800()
+{
+    OUString aFileName;
+    createFileURL(u"tdf125800.ods", aFileName);
+    auto xComponent = loadFromDesktop(aFileName, 
"com.sun.star.sheet.SpreadsheetDocument");
+
+    css::uno::Any aRet;
+    css::uno::Sequence<css::uno::Any> aParams;
+    css::uno::Sequence<css::uno::Any> aOutParam;
+    css::uno::Sequence<sal_Int16> aOutParamIndex;
+
+    SfxObjectShell* pFoundShell = 
SfxObjectShell::GetShellFromComponent(xComponent);
+
+    CPPUNIT_ASSERT_MESSAGE("Failed to access document shell", pFoundShell);
+    ScDocShell* pDocSh = static_cast<ScDocShell*>(pFoundShell);
+    ScDocument& rDoc = pDocSh->GetDocument();
+
+    ScConditionalFormat* pFormat = rDoc.GetCondFormat(1, 2, 0);
+    CPPUNIT_ASSERT(!pFormat);
+
+    // Without the fix in place, this test would have failed with
+    // - Expression: false
+    // - Unexpected dialog:  Error: Inadmissible value or data type. Index out 
of defined range.
+    SfxObjectShell::CallXScript(
+        xComponent,
+        
"vnd.sun.Star.script:Standard.cf.doItForThisSheetindexThisRange?language=Basic&location=document",
+        aParams, aRet, aOutParamIndex, aOutParam);
+
+    OUString aReturnValue;
+    aRet >>= aReturnValue;
+
+    pFormat = rDoc.GetCondFormat(1, 2, 0);
+    CPPUNIT_ASSERT(pFormat);
+
+    const ScFormatEntry* pEntry = pFormat->GetEntry(0);
+    CPPUNIT_ASSERT(pEntry);
+    CPPUNIT_ASSERT_EQUAL(ScFormatEntry::Type::Condition, pEntry->GetType());
+
+    const ScCondFormatEntry* pCondition = static_cast<const 
ScCondFormatEntry*>(pEntry);
+    CPPUNIT_ASSERT_EQUAL(ScConditionMode::Direct, pCondition->GetOperation());
+
+    css::uno::Reference<css::util::XCloseable> xCloseable(xComponent, 
css::uno::UNO_QUERY_THROW);
+    xCloseable->close(true);
+}
+
 void ScMacrosTest::testTdf130307()
 {
     OUString aFileName;
diff --git a/sc/qa/extras/testdocuments/tdf125800.ods 
b/sc/qa/extras/testdocuments/tdf125800.ods
new file mode 100644
index 000000000000..91f000d749ab
Binary files /dev/null and b/sc/qa/extras/testdocuments/tdf125800.ods differ

Reply via email to