1 diff --git basic/inc/basic/sbstar.hxx basic/inc/basic/sbstar.hxx
2 index ea7e75e..f610f56 100644
3 --- basic/inc/basic/sbstar.hxx
4 +++ basic/inc/basic/sbstar.hxx
5 @@ -75,6 +75,7 @@ class StarBASIC : public SbxObject
7 BasicLibInfo* pLibInfo; // Infoblock fuer Basic-Manager
8 SbLanguageMode eLanguageMode; // LanguageMode des Basic-Objekts
11 SbxObjectRef pVBAGlobals;
12 SbxObject* getVBAGlobals( );
13 @@ -205,6 +206,8 @@ public:
14 BOOL IsDocBasic() { return bDocBasic; }
15 SbxVariable* VBAFind( const String& rName, SbxClassType t );
16 bool GetUNOConstant( const sal_Char* _pAsciiName, ::com::sun::star::uno::Any& aOut );
17 + void QuitAndExitApplication();
18 + BOOL IsQuitApplication() { return bQuit; };
21 #ifndef __SB_SBSTARBASICREF_HXX
22 diff --git basic/source/classes/sb.cxx basic/source/classes/sb.cxx
23 index de99045..6b96c4f 100644
24 --- basic/source/classes/sb.cxx
25 +++ basic/source/classes/sb.cxx
26 @@ -658,6 +658,7 @@ StarBASIC::StarBASIC( StarBASIC* p, BOOL bIsDocBasic )
27 // Suche ueber StarBASIC ist immer global
28 SetFlag( SBX_GBLSEARCH );
33 // #51727 SetModified ueberladen, damit der Modified-
34 @@ -1013,6 +1014,12 @@ SbxVariable* StarBASIC::FindVarInCurrentScopy
38 +void StarBASIC::QuitAndExitApplication()
44 void StarBASIC::Stop()
46 SbiInstance* p = pINST;
47 diff --git basic/source/classes/sbxmod.cxx basic/source/classes/sbxmod.cxx
48 index d82b9d0..3646b7c 100644
49 --- basic/source/classes/sbxmod.cxx
50 +++ basic/source/classes/sbxmod.cxx
52 #include <cppuhelper/implbase1.hxx>
53 #include <comphelper/anytostring.hxx>
55 +#include <com/sun/star/frame/XDesktop.hpp>
56 +#include <vcl/svapp.hxx>
57 using namespace ::com::sun::star;
59 TYPEINIT1(SbModule,SbxObject)
60 @@ -98,6 +100,36 @@ SV_IMPL_VARARR(SbiBreakpoints,USHORT)
62 SV_IMPL_VARARR(HighlightPortions, HighlightPortion)
64 +class AsyncQuitHandler
66 + AsyncQuitHandler() {}
67 + AsyncQuitHandler( const AsyncQuitHandler&);
69 + static AsyncQuitHandler& instance()
71 + static AsyncQuitHandler dInst;
75 + void QuitApplication()
77 + uno::Reference< lang::XMultiServiceFactory > xFactory = comphelper::getProcessServiceFactory();
78 + if ( xFactory.is() )
80 + uno::Reference< frame::XDesktop > xDeskTop( xFactory->createInstance( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.frame.Desktop") ) ), uno::UNO_QUERY );
81 + if ( xDeskTop.is() )
82 + xDeskTop->terminate();
85 + DECL_LINK( OnAsyncQuit, void* );
88 +IMPL_LINK( AsyncQuitHandler, OnAsyncQuit, void*, pNull )
94 bool UnlockControllerHack( StarBASIC* pBasic )
97 @@ -654,6 +686,8 @@ USHORT SbModule::Run( SbMethod* pMeth )
100 BOOL bDelInst = BOOL( pINST == NULL );
101 + bool bQuit = false;
106 @@ -821,6 +855,15 @@ USHORT SbModule::Run( SbMethod* pMeth )
110 + if ( pBasic && pBasic->IsDocBasic() && pBasic->IsQuitApplication() && !pINST )
115 + //QuitApplicationHack();
116 + Application::PostUserEvent( LINK( &AsyncQuitHandler::instance(), AsyncQuitHandler, OnAsyncQuit ), NULL );
122 diff --git oovbaapi/ooo/vba/XApplicationBase.idl oovbaapi/ooo/vba/XApplicationBase.idl
123 index 38efadd..f6c6bf0 100644
124 --- oovbaapi/ooo/vba/XApplicationBase.idl
125 +++ oovbaapi/ooo/vba/XApplicationBase.idl
126 @@ -54,6 +54,8 @@ interface XApplicationBase
127 [attribute] boolean DisplayStatusBar;
128 [attribute, readonly] string Version;
132 any CommandBars( [in] any aIndex );
133 void Run([in] string MacroName, [in] /*Optional*/ any varg1, [in] /*Optional*/ any varg2, [in] /*Optional*/ any varg3, [in] /*Optional*/ any varg4, [in] /*Optional*/ any varg5, [in] /*Optional*/ any varg6, [in] /*Optional*/ any varg7, [in] /*Optional*/ any varg8, [in] /*Optional*/ any varg9, [in] /*Optional*/ any varg10, [in] /*Optional*/ any varg11, [in] /*Optional*/ any varg12, [in] /*Optional*/ any varg13, [in] /*Optional*/ any varg14, [in] /*Optional*/ any varg15, [in] /*Optional*/ any varg16, [in] /*Optional*/ any varg17, [in] /*Optional*/ any varg18, [in] /*Optional*/ any varg19, [in] /*Optional*/ any varg20, [in] /*Optional*/ any varg21, [in] /*Optional*/ any varg22, [in] /*Optional*/ any varg23, [in] /*Optional*/ any varg24, [in] /*Optional*/ any varg25, [in] /*Optional*/ any varg26, [in] /*Optional*/ any varg27, [in] /*Optional*/ any varg28, [in] /*Optional*/ any varg29, [in] /*Optional*/ any varg30);
134 float CentimetersToPoints([in] float Centimeters );
135 diff --git vbahelper/inc/vbahelper/vbaapplicationbase.hxx vbahelper/inc/vbahelper/vbaapplicationbase.hxx
136 index e100387..eb292f3 100644
137 --- vbahelper/inc/vbahelper/vbaapplicationbase.hxx
138 +++ vbahelper/inc/vbahelper/vbaapplicationbase.hxx
139 @@ -56,7 +56,7 @@ public:
140 virtual ::rtl::OUString SAL_CALL getVersion() throw (css::uno::RuntimeException);
141 virtual void SAL_CALL Run( const ::rtl::OUString& MacroName, const css::uno::Any& varg1, const css::uno::Any& varg2, const css::uno::Any& varg3, const css::uno::Any& varg4, const css::uno::Any& varg5, const css::uno::Any& varg6, const css::uno::Any& varg7, const css::uno::Any& varg8, const css::uno::Any& varg9, const css::uno::Any& varg10, const css::uno::Any& varg11, const css::uno::Any& varg12, const css::uno::Any& varg13, const css::uno::Any& varg14, const css::uno::Any& varg15, const css::uno::Any& varg16, const css::uno::Any& varg17, const css::uno::Any& varg18, const css::uno::Any& varg19, const css::uno::Any& varg20, const css::uno::Any& varg21, const css::uno::Any& varg22, const css::uno::Any& varg23, const css::uno::Any& varg24, const css::uno::Any& varg25, const css::uno::Any& varg26, const css::uno::Any& varg27, const css::uno::Any& varg28, const css::uno::Any& varg29, const css::uno::Any& varg30 ) throw (css::uno::RuntimeException);
142 virtual float SAL_CALL CentimetersToPoints( float _Centimeters ) throw (css::uno::RuntimeException);
144 + virtual void SAL_CALL Quit( ) throw (::com::sun::star::uno::RuntimeException);
146 virtual rtl::OUString& getServiceImplName();
147 virtual css::uno::Sequence<rtl::OUString> getServiceNames();
148 diff --git vbahelper/source/vbahelper/vbaapplicationbase.cxx vbahelper/source/vbahelper/vbaapplicationbase.cxx
149 index b73013f..73e7db2 100644
150 --- vbahelper/source/vbahelper/vbaapplicationbase.cxx
151 +++ vbahelper/source/vbahelper/vbaapplicationbase.cxx
153 #include "vbacommandbars.hxx"
154 #include <svx/msvbahelper.hxx>
156 +// start basic includes
157 +#include <basic/sbx.hxx>
158 +#include <basic/sbstar.hxx>
159 +#include <basic/sbuno.hxx>
160 +#include <basic/sbmeth.hxx>
161 +#include <basic/sbmod.hxx>
162 +// end basic includes
163 using namespace com::sun::star;
164 using namespace ooo::vba;
166 @@ -194,4 +201,18 @@ VbaApplicationBase::getServiceNames()
167 return aServiceNames;
171 +void VbaApplicationBase::Quit() throw (uno::RuntimeException)
173 + // need to stop basic
174 + SbMethod* pMeth = StarBASIC::GetActiveMethod();
177 + SbModule* pMod = dynamic_cast< SbModule* >( pMeth->GetParent() );
180 + StarBASIC* pBasic = dynamic_cast< StarBASIC* >( pMod->GetParent() );
182 + pBasic->QuitAndExitApplication();