[Libreoffice-commits] core.git: sc/qa

Xisco Fauli (via logerrit) logerrit at kemper.freedesktop.org
Fri Jul 10 15:35:47 UTC 2020


 sc/qa/extras/macros-test.cxx              |   46 ++++++++++++++++++++++++++++++
 sc/qa/extras/testdocuments/tdf107902.xlsm |binary
 2 files changed, 46 insertions(+)

New commits:
commit 88424a4adca388c8708b164751a4144a62814224
Author:     Xisco Fauli <xiscofauli at libreoffice.org>
AuthorDate: Fri Jul 10 14:59:43 2020 +0200
Commit:     Xisco Fauli <xiscofauli at libreoffice.org>
CommitDate: Fri Jul 10 17:35:21 2020 +0200

    tdf#107902: sc_macros_test: Add unittest
    
    Change-Id: I6fb494944c51a06ffec955e900f146e748f8f2f9
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/98522
    Tested-by: Jenkins
    Reviewed-by: Xisco Fauli <xiscofauli at libreoffice.org>

diff --git a/sc/qa/extras/macros-test.cxx b/sc/qa/extras/macros-test.cxx
index 502b9ba6d8ee..2630484e4122 100644
--- a/sc/qa/extras/macros-test.cxx
+++ b/sc/qa/extras/macros-test.cxx
@@ -16,6 +16,8 @@
 
 #include <docsh.hxx>
 #include <document.hxx>
+#include <attrib.hxx>
+#include <scitems.hxx>
 
 #include <com/sun/star/script/XLibraryContainerPassword.hpp>
 
@@ -39,6 +41,7 @@ public:
     void testRowColumn();
     void testTdf131562();
     void testPasswordProtectedUnicodeString();
+    void testTdf107902();
     void testTdf131296_legacy();
     void testTdf131296_new();
 
@@ -51,6 +54,7 @@ public:
     CPPUNIT_TEST(testRowColumn);
     CPPUNIT_TEST(testTdf131562);
     CPPUNIT_TEST(testPasswordProtectedUnicodeString);
+    CPPUNIT_TEST(testTdf107902);
     CPPUNIT_TEST(testTdf131296_legacy);
     CPPUNIT_TEST(testTdf131296_new);
 
@@ -529,6 +533,48 @@ void ScMacrosTest::testPasswordProtectedUnicodeString()
     xCloseable->close(true);
 }
 
+void ScMacrosTest::testTdf107902()
+{
+    OUString aFileName;
+    createFileURL("tdf107902.xlsm", aFileName);
+    uno::Reference< css::lang::XComponent > xComponent = loadFromDesktop(aFileName, "com.sun.star.sheet.SpreadsheetDocument");
+
+    CPPUNIT_ASSERT_MESSAGE("Failed to load the doc", xComponent.is());
+
+    Any aRet;
+    Sequence< sal_Int16 > aOutParamIndex;
+    Sequence< Any > aOutParam;
+    Sequence< uno::Any > aParams;
+
+    SfxObjectShell* pFoundShell = SfxObjectShell::GetShellFromComponent(xComponent);
+
+    CPPUNIT_ASSERT_MESSAGE("Failed to access document shell", pFoundShell);
+    ScDocShell* pDocSh = static_cast<ScDocShell*>(pFoundShell);
+    ScDocument& rDoc = pDocSh->GetDocument();
+
+    //Without the fix in place, it would have failed with 'Unexpected dialog:  Error: BASIC runtime error.'
+    SfxObjectShell::CallXScript(
+        xComponent,
+        "vnd.sun.Star.script:VBAProject.Module1.AF?language=Basic&location=document",
+        aParams, aRet, aOutParamIndex, aOutParam);
+
+    //Check the autofilter was created
+    const ScPatternAttr* pPattern = rDoc.GetPattern(0, 0, 0);
+    CPPUNIT_ASSERT(pPattern);
+
+    const ScMergeFlagAttr& rAttr = pPattern->GetItem(ATTR_MERGE_FLAG);
+    CPPUNIT_ASSERT_MESSAGE("Autofilter was not created", rAttr.HasAutoFilter());
+
+    //Check the last row is hidden
+    CPPUNIT_ASSERT(!rDoc.RowHidden(0,0));
+    CPPUNIT_ASSERT(!rDoc.RowHidden(1,0));
+    CPPUNIT_ASSERT(!rDoc.RowHidden(2,0));
+    CPPUNIT_ASSERT(!rDoc.RowHidden(3,0));
+    CPPUNIT_ASSERT(rDoc.RowHidden(4,0));
+
+    pDocSh->DoClose();
+}
+
 void ScMacrosTest::testTdf131296_legacy()
 {
     // For legacy password-protected library images, we must correctly get the constants' values,
diff --git a/sc/qa/extras/testdocuments/tdf107902.xlsm b/sc/qa/extras/testdocuments/tdf107902.xlsm
new file mode 100644
index 000000000000..f5333959b0e5
Binary files /dev/null and b/sc/qa/extras/testdocuments/tdf107902.xlsm differ


More information about the Libreoffice-commits mailing list