summaryrefslogtreecommitdiff
path: root/sc
diff options
context:
space:
mode:
authorTomaž Vajngerl <tomaz.vajngerl@collabora.co.uk>2022-01-26 16:50:41 +0900
committerTomaž Vajngerl <quikee@gmail.com>2022-01-31 03:45:32 +0100
commitb0999355c9314125a233ef386f590faf025dc97e (patch)
tree3af3452645139e55f4a89c63488654c6e032ca9f /sc
parentba4365fb28597294c20d8f3581cbfcafa761d3aa (diff)
vba: add support for Application.WindowState + test
This just delegates the get/set calls to ActiveWindow.WindowState which is already supported, but calling it directly on Application is also possible. Change-Id: Ibf6f55581a5c66a47ec4dd21cc8d0fe3558330ac Reviewed-on: https://gerrit.libreoffice.org/c/core/+/129013 Tested-by: Tomaž Vajngerl <quikee@gmail.com> Reviewed-by: Tomaž Vajngerl <quikee@gmail.com> (cherry picked from commit 93806a2831c93154981e3a6ef933270d0d5a6021) Reviewed-on: https://gerrit.libreoffice.org/c/core/+/129019 Reviewed-by: Luboš Luňák <l.lunak@collabora.com> Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoffice@gmail.com>
Diffstat (limited to 'sc')
-rw-r--r--sc/qa/extras/testdocuments/VariousTestMacros.xlsmbin0 -> 18110 bytes
-rw-r--r--sc/qa/extras/vba-macro-test.cxx23
-rw-r--r--sc/source/ui/vba/vbaapplication.cxx10
-rw-r--r--sc/source/ui/vba/vbaapplication.hxx2
4 files changed, 35 insertions, 0 deletions
diff --git a/sc/qa/extras/testdocuments/VariousTestMacros.xlsm b/sc/qa/extras/testdocuments/VariousTestMacros.xlsm
new file mode 100644
index 000000000000..455dad654eea
--- /dev/null
+++ b/sc/qa/extras/testdocuments/VariousTestMacros.xlsm
Binary files differ
diff --git a/sc/qa/extras/vba-macro-test.cxx b/sc/qa/extras/vba-macro-test.cxx
index 532e47d14ad5..174e2e7229b6 100644
--- a/sc/qa/extras/vba-macro-test.cxx
+++ b/sc/qa/extras/vba-macro-test.cxx
@@ -48,11 +48,13 @@ public:
void testSimpleCopyAndPaste();
void testMultiDocumentCopyAndPaste();
void testSheetAndColumnSelectAndHide();
+ void testWindowState();
CPPUNIT_TEST_SUITE(VBAMacroTest);
CPPUNIT_TEST(testSimpleCopyAndPaste);
CPPUNIT_TEST(testMultiDocumentCopyAndPaste);
CPPUNIT_TEST(testSheetAndColumnSelectAndHide);
+ CPPUNIT_TEST(testWindowState);
CPPUNIT_TEST_SUITE_END();
};
@@ -219,6 +221,27 @@ void VBAMacroTest::testSheetAndColumnSelectAndHide()
CPPUNIT_ASSERT_EQUAL(SCTAB(0), rViewData.GetTabNo());
}
+void VBAMacroTest::testWindowState()
+{
+ // Application.WindowState = xlMinimized
+ // Application.WindowState = xlMaximized
+ // Application.WindowState = xlNormal
+
+ OUString aFileName;
+ createFileURL(u"VariousTestMacros.xlsm", aFileName);
+ mxComponent = loadFromDesktop(aFileName, "com.sun.star.sheet.SpreadsheetDocument");
+
+ uno::Any aRet;
+ uno::Sequence<sal_Int16> aOutParamIndex;
+ uno::Sequence<uno::Any> aOutParam;
+ uno::Sequence<uno::Any> aParams;
+
+ SfxObjectShell::CallXScript(mxComponent,
+ "vnd.sun.Star.script:VBAProject.ThisWorkbook.testWindowState?"
+ "language=Basic&location=document",
+ aParams, aRet, aOutParamIndex, aOutParam);
+}
+
CPPUNIT_TEST_SUITE_REGISTRATION(VBAMacroTest);
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/ui/vba/vbaapplication.cxx b/sc/source/ui/vba/vbaapplication.cxx
index 0fd425c15cf6..0ec78418bb31 100644
--- a/sc/source/ui/vba/vbaapplication.cxx
+++ b/sc/source/ui/vba/vbaapplication.cxx
@@ -483,6 +483,16 @@ ScVbaApplication::getStatusBar()
return uno::makeAny( !getDisplayStatusBar() );
}
+css::uno::Any SAL_CALL ScVbaApplication::getWindowState()
+{
+ return getActiveWindow()->getWindowState();
+}
+
+void SAL_CALL ScVbaApplication::setWindowState(const css::uno::Any& rWindowState)
+{
+ getActiveWindow()->setWindowState(rWindowState);
+}
+
void SAL_CALL
ScVbaApplication::setStatusBar( const uno::Any& _statusbar )
{
diff --git a/sc/source/ui/vba/vbaapplication.hxx b/sc/source/ui/vba/vbaapplication.hxx
index 9a7eb8328363..d5edff95a849 100644
--- a/sc/source/ui/vba/vbaapplication.hxx
+++ b/sc/source/ui/vba/vbaapplication.hxx
@@ -110,6 +110,8 @@ public:
virtual void SAL_CALL setCutCopyMode( const css::uno::Any& _cutcopymode ) override;
virtual css::uno::Any SAL_CALL getStatusBar() override;
virtual void SAL_CALL setStatusBar( const css::uno::Any& _statusbar ) override;
+ virtual css::uno::Any SAL_CALL getWindowState() override;
+ virtual void SAL_CALL setWindowState(const css::uno::Any& rWindowState) override;
virtual ::sal_Int32 SAL_CALL getCursor() override;
virtual void SAL_CALL setCursor( ::sal_Int32 _cursor ) override;
virtual void SAL_CALL OnKey( const OUString& Key, const css::uno::Any& Procedure ) override;