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

Noel Power noelp at kemper.freedesktop.org
Tue Dec 8 11:24:36 PST 2009


 patches/dev300/apply                   |    3 
 patches/vba/vba-dont-load-for-odf.diff |  333 +++++++++++++++++++++++++++++++++
 2 files changed, 336 insertions(+)

New commits:
commit fa9fe349c23ab8228a807c10358266cdbd9416b0
Author: Noel Power <noel.power at novell.com>
Date:   Tue Dec 8 19:23:09 2009 +0000

    * patches/dev300/apply:
    * patches/vba/vba-dont-load-for-odf.diff: improve load speed/performance,
    don't load any vba crap on load of non MSO documents

diff --git a/patches/dev300/apply b/patches/dev300/apply
index 253328b..d0bc6fd 100644
--- a/patches/dev300/apply
+++ b/patches/dev300/apply
@@ -1724,6 +1724,9 @@ fix-vba-late-docevent-crash.diff, n#558907
 # support a local cache of local excel named references
 # to imported names, use that in range by name lookups
 vba-import-and-use-localrangenames.diff
+# make sure no vba libraries are loaded ( if not filtering )
+vba-dont-load-for-odf.diff
+
 [VBAUntested]
 SectionOwner => noelpwer
 # doesn't work
diff --git a/patches/vba/vba-dont-load-for-odf.diff b/patches/vba/vba-dont-load-for-odf.diff
new file mode 100644
index 0000000..52d597d
--- /dev/null
+++ b/patches/vba/vba-dont-load-for-odf.diff
@@ -0,0 +1,333 @@
+diff --git forms/source/misc/InterfaceContainer.cxx forms/source/misc/InterfaceContainer.cxx
+index a16b431..670ba03 100644
+--- forms/source/misc/InterfaceContainer.cxx
++++ forms/source/misc/InterfaceContainer.cxx
+@@ -148,9 +148,9 @@ OInterfaceContainer::fakeVbaEventsHack(  sal_Int32 _nIndex )
+ 			{
+ 				try
+ 				{
++					Reference< XCodeNameQuery > xNameQuery(  xDocFac->createInstance( rtl::OUString::createFromAscii( "ooo.vba.VBACodeNameProvider" ) ), UNO_QUERY_THROW );
+ 					Reference< ooo::vba::XVBAToOOEventDescGen > xDescSupplier( xFac->createInstance( rtl::OUString::createFromAscii( "ooo.vba.VBAToOOEventDesc" ) ), UNO_QUERY_THROW );
+ 					Reference< XInterface > xIf( getByIndex( _nIndex ) , UNO_QUERY_THROW );
+-					Reference< XCodeNameQuery > xNameQuery(  xDocFac->createInstance( rtl::OUString::createFromAscii( "ooo.vba.VBACodeNameProvider" ) ), UNO_QUERY_THROW );
+ 					rtl::OUString sCodeName;	
+ 					sCodeName = xNameQuery->getCodeNameForObject( xIf );
+ 					Reference< XPropertySet > xProps( xIf, UNO_QUERY );
+diff --git sc/source/core/data/documen2.cxx sc/source/core/data/documen2.cxx
+index 2a34517..294c86e 100644
+--- sc/source/core/data/documen2.cxx
++++ sc/source/core/data/documen2.cxx
+@@ -98,6 +98,7 @@
+ #include "clipparam.hxx"
+ #include "macromgr.hxx"
+ #include <com/sun/star/document/XVbaEventsHelper.hpp>
++#include <vbahelper/vbahelper.hxx>
+ 
+ // pImpl because including lookupcache.hxx in document.hxx isn't wanted, and
+ // dtor plus helpers are convenient.
+@@ -1268,7 +1269,7 @@ using namespace com::sun::star;
+ uno::Reference< document::XVbaEventsHelper > 
+ ScDocument::GetVbaEventsHelper()
+ {
+-	if( !mxVbaEventsHelper.is() )
++	if( !mxVbaEventsHelper.is() && pShell && ov::isAlienExcelDoc( *pShell ) )
+ 	{
+         try
+         {
+diff --git sc/source/filter/excel/excimp8.cxx sc/source/filter/excel/excimp8.cxx
+index 4cd1863..f72f975 100644
+--- sc/source/filter/excel/excimp8.cxx
++++ sc/source/filter/excel/excimp8.cxx
+@@ -277,6 +277,17 @@ void ImportExcel8::ReadBasic( void )
+         {
+             SvxImportMSVBasic aBasicImport( *pShell, *xRootStrg, bLoadCode, bLoadStrg );
+ 	    bool bAsComment = !bLoadExecutable;
++            if ( !bAsComment )
++            {
++	        uno::Any aGlobs;
++                uno::Sequence< uno::Any > aArgs(1);
++                aArgs[ 0 ] <<= pShell->GetModel();
++        	aGlobs <<= ::comphelper::getProcessServiceFactory()->createInstanceWithArguments( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "ooo.vba.excel.Globals" ) ), aArgs );
++        	pShell->GetBasicManager()->SetGlobalUNOConstant( "VBAGlobals", aGlobs );
++                BasicManager* pAppMgr = SFX_APP()->GetBasicManager();
++                if ( pAppMgr )
++                    pAppMgr->SetGlobalUNOConstant( "ThisExcelDoc", aArgs[ 0 ] );
++            }
+             aBasicImport.Import( EXC_STORAGE_VBA_PROJECT, EXC_STORAGE_VBA, AutoGeneratedCodeNames, bAsComment );
+             if ( !bAsComment )
+             {
+diff --git sc/source/ui/docshell/docsh.cxx sc/source/ui/docshell/docsh.cxx
+index 2cd4321..54e0b4f 100644
+--- sc/source/ui/docshell/docsh.cxx
++++ sc/source/ui/docshell/docsh.cxx
+@@ -372,6 +372,7 @@ void ScDocShell::AfterXMLLoading(sal_Bool bRet)
+     }
+     else
+         aDocument.SetInsertingFromOtherDoc( FALSE );
++#if 0
+ 	// add vba globals ( if they are availabl )
+ 	uno::Any aGlobs;
+         uno::Sequence< uno::Any > aArgs(1);
+@@ -398,6 +399,7 @@ void ScDocShell::AfterXMLLoading(sal_Bool bRet)
+         if ( xEvt.is() )
+             xEvt->setIgnoreEvents( sal_False );
+ #endif
++#endif
+     aDocument.SetImportingXML( FALSE );
+     aDocument.EnableExecuteLink( true );
+     aDocument.EnableUndo( TRUE );
+diff --git sc/source/ui/docshell/docsh2.cxx sc/source/ui/docshell/docsh2.cxx
+index eb7a320..653408b 100644
+--- sc/source/ui/docshell/docsh2.cxx
++++ sc/source/ui/docshell/docsh2.cxx
+@@ -105,6 +105,7 @@ BOOL __EXPORT ScDocShell::InitNew( const uno::Reference < embed::XStorage >& xSt
+ 
+     InitItems();
+     CalcOutputFactor();
++#if 0
+ 	uno::Any aGlobs;
+         uno::Sequence< uno::Any > aArgs(1);
+         aArgs[ 0 ] <<= GetModel();
+@@ -113,6 +114,7 @@ BOOL __EXPORT ScDocShell::InitNew( const uno::Reference < embed::XStorage >& xSt
+         BasicManager* pAppMgr = SFX_APP()->GetBasicManager();
+         if ( pAppMgr )
+             pAppMgr->SetGlobalUNOConstant( "ThisExcelDoc", aArgs[ 0 ] );
++#endif
+ 
+     return bRet;
+ }
+diff --git sc/source/ui/unoobj/servuno.cxx sc/source/ui/unoobj/servuno.cxx
+index 3eb6c9d..502a0bd 100644
+--- sc/source/ui/unoobj/servuno.cxx
++++ sc/source/ui/unoobj/servuno.cxx
+@@ -536,10 +536,18 @@ uno::Reference<uno::XInterface> ScServiceProvider::MakeInstance(
+             }
+             break;
+         case SC_SERVICE_VBAOBJECTPROVIDER:
+-            xRet.set(static_cast<container::XNameAccess*>(new ScVbaObjectForCodeNameProvider( pDocShell )));
++            if ( pDocShell && ov::isAlienExcelDoc( *pDocShell ) )
++            {
++                OSL_TRACE("**** creating VBA Object mapper");
++                xRet.set(static_cast<container::XNameAccess*>(new ScVbaObjectForCodeNameProvider( pDocShell )));
++            }
+             break;
+         case SC_SERVICE_VBACODENAMEPROVIDER:
+-            xRet.set(static_cast<document::XCodeNameQuery*>(new ScVbaCodeNameProvider( pDocShell )));
++            if ( pDocShell && ov::isAlienExcelDoc( *pDocShell ) )
++            {
++                OSL_TRACE("**** creating VBA Object provider");
++                xRet.set(static_cast<document::XCodeNameQuery*>(new ScVbaCodeNameProvider( pDocShell )));
++            }
+             break;
+     }
+     return xRet;
+diff --git sc/util/makefile.mk sc/util/makefile.mk
+index 179b9bb..cec3387 100644
+--- sc/util/makefile.mk
++++ sc/util/makefile.mk
+@@ -79,7 +79,6 @@ SHL1IMPLIB= sci
+ 
+ # dynamic libraries
+ SHL1STDLIBS=       \
+-		$(VBAHELPERLIB) \
+     $(BASICLIB)	\
+     $(SFXLIB)		\
+     $(SVTOOLLIB)	\
+diff --git svx/source/form/fmundo.cxx svx/source/form/fmundo.cxx
+index c438b74..adc30c7 100644
+--- svx/source/form/fmundo.cxx
++++ svx/source/form/fmundo.cxx
+@@ -74,6 +74,7 @@
+ #include <comphelper/property.hxx>
+ #include <comphelper/uno3.hxx>
+ #include <comphelper/stl_types.hxx>
++#include <vbahelper/vbahelper.hxx>
+ 
+ using namespace ::com::sun::star::uno;
+ using namespace ::com::sun::star::awt;
+@@ -98,9 +99,15 @@ class ScriptEventListenerWrapper : public ScriptEventListener_BASE
+ public:
+ 	ScriptEventListenerWrapper( FmFormModel& _rModel) throw ( RuntimeException ) : pModel(&_rModel) 
+ 	{
++		bool bSupportedAlienDoc( false );
++              	SfxObjectShellRef xObjSh = pModel->GetObjectShell();
++		if ( xObjSh.Is() )
++		{
++			bSupportedAlienDoc = ov::isAlienExcelDoc( *xObjSh ) ||  ov::isAlienWordDoc( *xObjSh );
++		} 
+ 		Reference < XPropertySet > xProps(
+ 			::comphelper::getProcessServiceFactory(), UNO_QUERY );
+-		if ( xProps.is() )
++		if ( xProps.is() && bSupportedAlienDoc )
+ 		{
+ 			Reference< XComponentContext > xCtx( xProps->getPropertyValue(
+ 				rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "DefaultContext" ))), UNO_QUERY );
+@@ -108,6 +115,7 @@ public:
+ 			{
+ 				Reference< XMultiComponentFactory > xMFac( 
+ 					xCtx->getServiceManager(), UNO_QUERY );
++
+ 				if ( xMFac.is() )
+ 				{
+ 					m_vbaListener.set( xMFac->createInstanceWithContext( 
+diff --git sw/source/core/doc/doc.cxx sw/source/core/doc/doc.cxx
+index 914a843..aba6e2f 100644
+--- sw/source/core/doc/doc.cxx
++++ sw/source/core/doc/doc.cxx
+@@ -110,6 +110,7 @@
+ 
+ #include <osl/diagnose.h>
+ #include <osl/interlck.h>
++#include <vbahelper/vbahelper.hxx>
+ 
+ /* @@@MAINTAINABILITY-HORROR@@@
+    Probably unwanted dependency on SwDocShell
+@@ -2018,7 +2019,7 @@ void SwDoc::ChkCondColls()
+ uno::Reference< document::XVbaEventsHelper > 
+ SwDoc::GetVbaEventsHelper()
+ {
+-	if( !mxVbaEventsHelper.is() )
++	if( !mxVbaEventsHelper.is() && GetDocShell() && ov::isAlienWordDoc( *GetDocShell() ) )
+ 	{
+         try
+         {
+diff --git sw/source/core/unocore/unocoll.cxx sw/source/core/unocore/unocoll.cxx
+index 7c1631a..747c1e6 100644
+--- sw/source/core/unocore/unocoll.cxx
++++ sw/source/core/unocore/unocoll.cxx
+@@ -587,14 +587,17 @@ uno::Reference< uno::XInterface >   SwXServiceProvider::MakeInstance(sal_uInt16
+ 		break;
+ 		case  SW_SERVICE_VBACODENAMEPROVIDER :
+ 		{
+-			SwVbaCodeNameProvider* pObjProv = new SwVbaCodeNameProvider( pDoc->GetDocShell() );
+-			xRet =  (cppu::OWeakObject*)pObjProv;
++			if ( pDoc->GetDocShell()  && ov::isAlienWordDoc( *pDoc->GetDocShell() ) )
++			{
++				SwVbaCodeNameProvider* pObjProv = new SwVbaCodeNameProvider( pDoc->GetDocShell() );
++				xRet =  (cppu::OWeakObject*)pObjProv;
++			}
+ 		}
+ 		break;
+ 		case  SW_SERVICE_VBAPROJECTNAMEPROVIDER :
+ 		{
+                         uno::Reference< container::XNameContainer > xProjProv = pDoc->GetVBATemplateToProjectCache();
+-                        if ( !xProjProv.is() )
++                        if ( !xProjProv.is() && pDoc->GetDocShell()  && ov::isAlienWordDoc( *pDoc->GetDocShell() ) )
+                         {
+ 			    xProjProv = new SwVbaProjectNameProvider( pDoc->GetDocShell() );
+                             pDoc->SetVBATemplateToProjectCache( xProjProv );
+diff --git sw/util/makefile.mk sw/util/makefile.mk
+index b726149..c049505 100644
+--- sw/util/makefile.mk
++++ sw/util/makefile.mk
+@@ -127,7 +127,6 @@ SHL1STDLIBS+= \
+     $(SALHELPERLIB) \
+     $(ICUUCLIB) \
+     $(I18NUTILLIB)	\
+-		        $(VBAHELPERLIB) \
+     $(AVMEDIALIB)
+ 
+ .IF "$(GUI)"=="WNT"
+diff --git vbahelper/inc/vbahelper/vbahelper.hxx vbahelper/inc/vbahelper/vbahelper.hxx
+index 54ab0ad..bd31cb6 100644
+--- vbahelper/inc/vbahelper/vbahelper.hxx
++++ vbahelper/inc/vbahelper/vbahelper.hxx
+@@ -38,17 +38,20 @@
+ #include <com/sun/star/lang/IllegalArgumentException.hpp>
+ #include <com/sun/star/awt/XControl.hpp>
+ #include <com/sun/star/awt/XDevice.hpp>
++#include <basic/basmgr.hxx>
+ #include <basic/sberrors.hxx>
+ #include <cppuhelper/implbase1.hxx>
+ #include <com/sun/star/frame/XModel.hpp>
+ #include <sfx2/dispatch.hxx>
++#include <sfx2/objsh.hxx>
++#include <sfx2/docfilt.hxx>
++#include <sfx2/docfile.hxx>
+ //#include <ooo/vba/msforms/XShape.hpp>
+ #include <vcl/pointr.hxx>
+ #define VBAHELPER_DLLIMPLEMENTATION
+ #include <vbahelper/vbadllapi.h>
+ #include <memory>
+ namespace css = ::com::sun::star;
+-
+ namespace ooo 
+ {
+ 	namespace vba 
+@@ -65,7 +68,24 @@ namespace ooo
+ 		}
+         VBAHELPER_DLLPUBLIC SfxObjectShell* getSfxObjShell( const css::uno::Reference< css::frame::XModel >& xModel ) throw ( css::uno::RuntimeException);
+         VBAHELPER_DLLPUBLIC css::uno::Reference< css::uno::XInterface > createVBAUnoAPIService( SfxObjectShell* pShell,  const sal_Char* _pAsciiName ) throw (css::uno::RuntimeException);
+-        VBAHELPER_DLLPUBLIC css::uno::Reference< css::uno::XInterface > createVBAUnoAPIServiceWithArgs( SfxObjectShell* pShell,  const sal_Char* _pAsciiName, const css::uno::Sequence< css::uno::Any >& aArgs ) throw (css::uno::RuntimeException);
++
++        VBAHELPER_DLLPRIVATE inline css::uno::Reference< css::lang::XMultiServiceFactory > getVBAServiceFactory( SfxObjectShell* pShell )
++        {
++            css::uno::Any aUnoVar;
++            if ( !pShell || ! pShell->GetBasicManager()->GetGlobalUNOConstant( "VBAGlobals", aUnoVar ) )
++                throw css::lang::IllegalArgumentException();
++            css::uno::Reference< css::lang::XMultiServiceFactory > xVBAFactory( aUnoVar, css::uno::UNO_QUERY_THROW );
++            return xVBAFactory;
++        }
++
++        VBAHELPER_DLLPUBLIC inline css::uno::Reference< css::uno::XInterface > createVBAUnoAPIServiceWithArgs( SfxObjectShell* pShell,  const sal_Char* _pAsciiName, const css::uno::Sequence< css::uno::Any >& aArgs ) throw (css::uno::RuntimeException)
++        {
++            OSL_PRECOND( pShell, "createVBAUnoAPIService: no shell!" );
++            ::rtl::OUString sVarName( ::rtl::OUString::createFromAscii( _pAsciiName ) );
++            css::uno::Reference< css::uno::XInterface > xIf = getVBAServiceFactory( pShell )->createInstanceWithArguments( sVarName, aArgs  );
++            return xIf;
++        }
++
+         css::uno::Reference< css::frame::XModel > getCurrentDoc( const rtl::OUString& sKey ) throw (css::uno::RuntimeException);
+         VBAHELPER_DLLPUBLIC css::uno::Reference< css::frame::XModel > getCurrentExcelDoc( const css::uno::Reference< css::uno::XComponentContext >& xContext ) throw (css::uno::RuntimeException);
+         VBAHELPER_DLLPUBLIC css::uno::Reference< css::frame::XModel > getCurrentWordDoc( const css::uno::Reference< css::uno::XComponentContext >& xContext ) throw (css::uno::RuntimeException);
+@@ -98,6 +118,16 @@ namespace ooo
+         VBAHELPER_DLLPUBLIC css::uno::Any getPropertyValue( const css::uno::Sequence< css::beans::PropertyValue >& aProp, const rtl::OUString& aName );
+         VBAHELPER_DLLPUBLIC sal_Bool setPropertyValue( css::uno::Sequence< css::beans::PropertyValue >& aProp, const rtl::OUString& aName, const css::uno::Any& aValue );
+         VBAHELPER_DLLPUBLIC void setOrAppendPropertyValue( css::uno::Sequence< css::beans::PropertyValue >& aProp, const rtl::OUString& aName, const css::uno::Any& aValue );
++        VBAHELPER_DLLPRIVATE inline bool isAlienDoc( SfxObjectShell& rDocShell, const char* pMimeType )
++        {
++            bool bRes( false );
++            const SfxFilter *pFilt = rDocShell.GetMedium()->GetFilter();
++            if ( pFilt && pFilt->IsAlienFormat() )
++                bRes = ( pFilt->GetMimeType().CompareToAscii( pMimeType ) == 0 );
++            return bRes;
++        }
++        VBAHELPER_DLLPUBLIC inline bool isAlienExcelDoc( SfxObjectShell& rDocShell ) { return isAlienDoc( rDocShell, "application/vnd.ms-excel" ); }
++        VBAHELPER_DLLPUBLIC inline bool isAlienWordDoc( SfxObjectShell& rDocShell ) { return isAlienDoc( rDocShell, "application/vnd.ms-word" ); }
+ 
+ class VBAHELPER_DLLPUBLIC Millimeter
+ {
+diff --git vbahelper/source/vbahelper/vbahelper.cxx vbahelper/source/vbahelper/vbahelper.cxx
+index 1290b25..5c64f99 100644
+--- vbahelper/source/vbahelper/vbahelper.cxx
++++ vbahelper/source/vbahelper/vbahelper.cxx
+@@ -102,15 +102,6 @@ namespace ooo
+ namespace vba
+ {
+ 
+-uno::Reference< lang::XMultiServiceFactory > getVBAServiceFactory( SfxObjectShell* pShell )
+-{
+-    uno::Any aUnoVar;
+-    if ( !pShell || ! pShell->GetBasicManager()->GetGlobalUNOConstant( "VBAGlobals", aUnoVar ) )
+-        throw lang::IllegalArgumentException();
+-    uno::Reference< lang::XMultiServiceFactory > xVBAFactory( aUnoVar, uno::UNO_QUERY_THROW );
+-    return xVBAFactory;
+-}
+-
+ css::uno::Reference< css::uno::XInterface > createVBAUnoAPIService( SfxObjectShell* pShell, const sal_Char* _pAsciiName ) throw (css::uno::RuntimeException)
+ {
+     OSL_PRECOND( pShell, "createVBAUnoAPIService: no shell!" );
+@@ -118,13 +109,6 @@ css::uno::Reference< css::uno::XInterface > createVBAUnoAPIService( SfxObjectShe
+     return getVBAServiceFactory( pShell )->createInstance( sVarName );
+ }
+ 
+-css::uno::Reference< css::uno::XInterface > createVBAUnoAPIServiceWithArgs( SfxObjectShell* pShell, const sal_Char* _pAsciiName, const uno::Sequence< uno::Any >& aArgs ) throw ( css::uno::RuntimeException )
+-{
+-    OSL_PRECOND( pShell, "createVBAUnoAPIService: no shell!" );
+-    ::rtl::OUString sVarName( ::rtl::OUString::createFromAscii( _pAsciiName ) );
+-    uno::Reference< uno::XInterface > xIf = getVBAServiceFactory( pShell )->createInstanceWithArguments( sVarName, aArgs  );
+-    return xIf;
+-}
+ // helper method to determine if the view ( calc ) is in print-preview mode
+ bool isInPrintPreview( SfxViewFrame* pView )
+ {


More information about the ooo-build-commit mailing list