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 Binary files /dev/null and b/sc/qa/extras/testdocuments/VariousTestMacros.xlsm 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 aOutParamIndex; + uno::Sequence aOutParam; + uno::Sequence 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;