[ooo-build-commit] patches/dev300 patches/vba

Noel Power noelp at kemper.freedesktop.org
Mon Jun 8 07:35:06 PDT 2009


 patches/dev300/apply                  |    2 
 patches/vba/vba-application-quit.diff |  185 ++++++++++++++++++++++++++++++++++
 2 files changed, 187 insertions(+)

New commits:
commit 2ecd53535c31e256b5ebc88f758a2fe3b5e31813
Author: Noel Power <npower at linux-h0uc.site>
Date:   Mon Jun 8 15:33:29 2009 +0100

    add application.quit api n#510003
    
    * patches/dev300/apply:
    * patches/vba/vba-application-quit.diff: Application.Quit( n#510003 )

diff --git a/patches/dev300/apply b/patches/dev300/apply
index 048d1dc..b9d9f36 100644
--- a/patches/dev300/apply
+++ b/patches/dev300/apply
@@ -1804,6 +1804,8 @@ vba-fix-range-delete-shift.diff, n#508101
 vba-fix-worksheet-add-before-param-object.diff, n#507760 
 # active newly added worksheet
 vba-fix-worksheet-add-activate.diff, n#507758
+# add Application.Quit api
+vba-application-quit.diff, n#510003
 [VBAUntested]
 SectionOwner => noelpwer
 # doesn't work
diff --git a/patches/vba/vba-application-quit.diff b/patches/vba/vba-application-quit.diff
new file mode 100644
index 0000000..da8d15b
--- /dev/null
+++ b/patches/vba/vba-application-quit.diff
@@ -0,0 +1,185 @@
+diff --git basic/inc/basic/sbstar.hxx basic/inc/basic/sbstar.hxx
+index ea7e75e..f610f56 100644
+--- basic/inc/basic/sbstar.hxx
++++ basic/inc/basic/sbstar.hxx
+@@ -75,6 +75,7 @@ class StarBASIC : public SbxObject
+     BOOL            bVBAEnabled;
+ 	BasicLibInfo*	pLibInfo;			// Infoblock fuer Basic-Manager
+ 	SbLanguageMode	eLanguageMode;		// LanguageMode des Basic-Objekts
++	BOOL			bQuit;
+ 
+ 	SbxObjectRef pVBAGlobals; 
+ 	SbxObject* getVBAGlobals( );
+@@ -205,6 +206,8 @@ public:
+ 	BOOL IsDocBasic() { return bDocBasic; }
+ 	SbxVariable* VBAFind( const String& rName, SbxClassType t );
+ 	bool GetUNOConstant( const sal_Char* _pAsciiName, ::com::sun::star::uno::Any& aOut );
++	void QuitAndExitApplication();
++	BOOL IsQuitApplication() { return bQuit; };
+ };
+ 
+ #ifndef __SB_SBSTARBASICREF_HXX
+diff --git basic/source/classes/sb.cxx basic/source/classes/sb.cxx
+index de99045..6b96c4f 100644
+--- basic/source/classes/sb.cxx
++++ basic/source/classes/sb.cxx
+@@ -658,6 +658,7 @@ StarBASIC::StarBASIC( StarBASIC* p, BOOL bIsDocBasic  )
+ 	// Suche ueber StarBASIC ist immer global
+ 	SetFlag( SBX_GBLSEARCH );
+ 	pVBAGlobals = NULL;
++	bQuit = FALSE;
+ }
+ 
+ // #51727 SetModified ueberladen, damit der Modified-
+@@ -1013,6 +1014,12 @@ SbxVariable* StarBASIC::FindVarInCurrentScopy
+ 	return pVar;
+ }
+ 
++void StarBASIC::QuitAndExitApplication()
++{
++    Stop();
++    bQuit = TRUE;
++}
++
+ void StarBASIC::Stop()
+ {
+ 	SbiInstance* p = pINST;
+diff --git basic/source/classes/sbxmod.cxx basic/source/classes/sbxmod.cxx
+index d82b9d0..3646b7c 100644
+--- basic/source/classes/sbxmod.cxx
++++ basic/source/classes/sbxmod.cxx
+@@ -81,6 +81,8 @@
+ #include <cppuhelper/implbase1.hxx>
+ #include <comphelper/anytostring.hxx>
+ 
++#include <com/sun/star/frame/XDesktop.hpp>
++#include <vcl/svapp.hxx>
+ using namespace ::com::sun::star; 
+ 
+ TYPEINIT1(SbModule,SbxObject)
+@@ -98,6 +100,36 @@ SV_IMPL_VARARR(SbiBreakpoints,USHORT)
+ 
+ SV_IMPL_VARARR(HighlightPortions, HighlightPortion)
+ 
++class AsyncQuitHandler
++{
++    AsyncQuitHandler() {}
++    AsyncQuitHandler( const AsyncQuitHandler&);
++public:
++    static AsyncQuitHandler& instance() 
++    {
++        static AsyncQuitHandler dInst;
++        return dInst;
++    }
++
++    void QuitApplication()
++    {
++        uno::Reference< lang::XMultiServiceFactory > xFactory = comphelper::getProcessServiceFactory();
++        if ( xFactory.is() )
++	{
++            uno::Reference< frame::XDesktop > xDeskTop( xFactory->createInstance( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.frame.Desktop") ) ), uno::UNO_QUERY );
++           if ( xDeskTop.is() )
++               xDeskTop->terminate(); 
++        }
++    }
++    DECL_LINK( OnAsyncQuit, void* );
++};
++
++IMPL_LINK( AsyncQuitHandler, OnAsyncQuit, void*, pNull )
++{
++    QuitApplication();
++    return 0L;
++}
++
+ bool UnlockControllerHack( StarBASIC* pBasic )
+ {
+     bool bRes = false;
+@@ -654,6 +686,8 @@ USHORT SbModule::Run( SbMethod* pMeth )
+ 
+ 	USHORT nRes = 0;
+ 	BOOL bDelInst = BOOL( pINST == NULL );
++        bool bQuit = false;
++{
+ 	StarBASICRef xBasic;
+ 	if( bDelInst )
+ 	{
+@@ -821,6 +855,15 @@ USHORT SbModule::Run( SbMethod* pMeth )
+ 		delete pINST;
+ 		pINST = NULL;
+ 	}
++	if ( pBasic && pBasic->IsDocBasic() && pBasic->IsQuitApplication() && !pINST )
++            bQuit = true;
++}
++        if ( bQuit )
++        {
++            //QuitApplicationHack();
++            Application::PostUserEvent( LINK( &AsyncQuitHandler::instance(), AsyncQuitHandler, OnAsyncQuit ), NULL );
++
++        }
+ 	return nRes;
+ }
+ 
+diff --git oovbaapi/ooo/vba/XApplicationBase.idl oovbaapi/ooo/vba/XApplicationBase.idl
+index 38efadd..f6c6bf0 100644
+--- oovbaapi/ooo/vba/XApplicationBase.idl
++++ oovbaapi/ooo/vba/XApplicationBase.idl
+@@ -54,6 +54,8 @@ interface XApplicationBase
+ 	[attribute] boolean DisplayStatusBar;
+ 	[attribute, readonly] string Version;
+ 
++	void Quit();
++
+     any CommandBars( [in] any aIndex );
+ 	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);
+     float CentimetersToPoints([in] float Centimeters );
+diff --git vbahelper/inc/vbahelper/vbaapplicationbase.hxx vbahelper/inc/vbahelper/vbaapplicationbase.hxx
+index e100387..eb292f3 100644
+--- vbahelper/inc/vbahelper/vbaapplicationbase.hxx
++++ vbahelper/inc/vbahelper/vbaapplicationbase.hxx
+@@ -56,7 +56,7 @@ public:
+ 	virtual ::rtl::OUString SAL_CALL getVersion() throw (css::uno::RuntimeException);
+     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);
+     virtual float SAL_CALL CentimetersToPoints( float _Centimeters ) throw (css::uno::RuntimeException);
+-
++    virtual void SAL_CALL Quit(  ) throw (::com::sun::star::uno::RuntimeException);
+ 	// XHelperInterface
+ 	virtual rtl::OUString& getServiceImplName();
+ 	virtual css::uno::Sequence<rtl::OUString> getServiceNames();
+diff --git vbahelper/source/vbahelper/vbaapplicationbase.cxx vbahelper/source/vbahelper/vbaapplicationbase.cxx
+index b73013f..73e7db2 100644
+--- vbahelper/source/vbahelper/vbaapplicationbase.cxx
++++ vbahelper/source/vbahelper/vbaapplicationbase.cxx
+@@ -44,6 +44,13 @@
+ #include "vbacommandbars.hxx"
+ #include <svx/msvbahelper.hxx>
+ 
++// start basic includes
++#include <basic/sbx.hxx>
++#include <basic/sbstar.hxx>
++#include <basic/sbuno.hxx>
++#include <basic/sbmeth.hxx>
++#include <basic/sbmod.hxx>
++// end basic includes
+ using namespace com::sun::star;
+ using namespace ooo::vba;
+ 
+@@ -194,4 +201,18 @@ VbaApplicationBase::getServiceNames()
+ 	return aServiceNames;
+ }
+ 
+-
++void VbaApplicationBase::Quit() throw (uno::RuntimeException)
++{
++    // need to stop basic
++    SbMethod* pMeth = StarBASIC::GetActiveMethod();
++    if ( pMeth )
++    {
++        SbModule* pMod = dynamic_cast< SbModule* >( pMeth->GetParent() );
++        if ( pMod )
++        { 
++            StarBASIC* pBasic = dynamic_cast< StarBASIC* >( pMod->GetParent() );
++            if ( pBasic )
++                pBasic->QuitAndExitApplication();
++        }
++    }
++}


More information about the ooo-build-commit mailing list