summaryrefslogtreecommitdiff
path: root/sc
diff options
context:
space:
mode:
authorXisco Fauli <xiscofauli@libreoffice.org>2022-03-29 16:41:56 +0200
committerXisco Fauli <xiscofauli@libreoffice.org>2022-03-29 21:06:34 +0200
commit2fa01ae540e174452bf5cd763c1464cfe37af076 (patch)
treed19dd87da4ec20941206446e1608827a3fc5a27b /sc
parentdde866578eff5eaf1d59c5a98d3e72ce87718b00 (diff)
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 <xiscofauli@libreoffice.org>
Diffstat (limited to 'sc')
-rw-r--r--sc/qa/extras/macros-test.cxx48
-rw-r--r--sc/qa/extras/testdocuments/tdf125800.odsbin0 -> 14245 bytes
2 files changed, 48 insertions, 0 deletions
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
--- /dev/null
+++ b/sc/qa/extras/testdocuments/tdf125800.ods
Binary files differ