summaryrefslogtreecommitdiff
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-27 07:38:09 +0100
commit93806a2831c93154981e3a6ef933270d0d5a6021 (patch)
treeb16a569b1d59c6dbc214cfde0886bc00294e661f
parentcfa4867b0b66b0d4fb3aee52ca40d380e50de9ef (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>
-rw-r--r--oovbaapi/ooo/vba/excel/XApplication.idl1
-rw-r--r--sc/qa/extras/testdocuments/VariousTestMacros.xlsmbin0 -> 18110 bytes
-rw-r--r--sc/qa/extras/vba-macro-test.cxx24
-rw-r--r--sc/source/ui/vba/vbaapplication.cxx10
-rw-r--r--sc/source/ui/vba/vbaapplication.hxx2
5 files changed, 37 insertions, 0 deletions
diff --git a/oovbaapi/ooo/vba/excel/XApplication.idl b/oovbaapi/ooo/vba/excel/XApplication.idl
index b1bcf46336be..ab6f79655696 100644
--- a/oovbaapi/ooo/vba/excel/XApplication.idl
+++ b/oovbaapi/ooo/vba/excel/XApplication.idl
@@ -47,6 +47,7 @@ interface XApplication
[attribute] boolean DisplayFormulaBar;
[attribute] any CutCopyMode;
[attribute] any StatusBar;
+ [attribute] any WindowState;
[attribute] long Cursor;
[attribute] boolean EnableEvents;
[attribute] boolean EnableCancelKey;
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 89639ceb1863..51d8c36cbded 100644
--- a/sc/qa/extras/vba-macro-test.cxx
+++ b/sc/qa/extras/vba-macro-test.cxx
@@ -48,6 +48,8 @@ public:
void testSimpleCopyAndPaste();
void testMultiDocumentCopyAndPaste();
void testSheetAndColumnSelectAndHide();
+ void testWindowState();
+
void testVba();
void testTdf107885();
void testTdf131562();
@@ -58,6 +60,7 @@ public:
CPPUNIT_TEST(testSimpleCopyAndPaste);
CPPUNIT_TEST(testMultiDocumentCopyAndPaste);
CPPUNIT_TEST(testSheetAndColumnSelectAndHide);
+ CPPUNIT_TEST(testWindowState);
CPPUNIT_TEST(testVba);
CPPUNIT_TEST(testTdf107885);
@@ -230,6 +233,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);
+}
+
void VBAMacroTest::testVba()
{
TestMacroInfo testInfo[] = {
diff --git a/sc/source/ui/vba/vbaapplication.cxx b/sc/source/ui/vba/vbaapplication.cxx
index f518f4a82293..f11ee6f21bbe 100644
--- a/sc/source/ui/vba/vbaapplication.cxx
+++ b/sc/source/ui/vba/vbaapplication.cxx
@@ -488,6 +488,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 09d2b02d3b59..db9c91cdd677 100644
--- a/sc/source/ui/vba/vbaapplication.hxx
+++ b/sc/source/ui/vba/vbaapplication.hxx
@@ -109,6 +109,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;