diff options
author | Ivo Hinkelmann <ihi@openoffice.org> | 2010-08-03 11:54:45 +0200 |
---|---|---|
committer | Ivo Hinkelmann <ihi@openoffice.org> | 2010-08-03 11:54:45 +0200 |
commit | 24e7a75506e27981961fff8f2ecab2279e874d4b (patch) | |
tree | 5b76e0c6c9f5c9c29c16c140e85bb642354ea51e | |
parent | ed873a73fde10c2a9511388024bef97522517cf4 (diff) | |
parent | 3a2263a20629b0a3e9b4935dd43dc59817d0241c (diff) |
CWS-TOOLING: integrate CWS mib17
-rw-r--r-- | filter/source/msfilter/msvbahelper.cxx | 83 | ||||
-rw-r--r-- | filter/source/msfilter/svxmsbas.cxx | 24 | ||||
-rwxr-xr-x | oox/inc/oox/ole/vbahelper.hxx | 123 | ||||
-rwxr-xr-x | oox/inc/oox/ole/vbaproject.hxx | 151 | ||||
-rwxr-xr-x | oox/inc/oox/xls/excelvbaproject.hxx | 73 | ||||
-rw-r--r-- | oox/source/core/filterbase.cxx | 32 | ||||
-rw-r--r-- | oox/source/drawingml/chart/titlecontext.cxx | 2 | ||||
-rwxr-xr-x | oox/source/ole/vbacontrol.cxx | 28 | ||||
-rwxr-xr-x | oox/source/ole/vbahelper.cxx | 171 | ||||
-rwxr-xr-x | oox/source/ole/vbamodule.cxx | 42 | ||||
-rwxr-xr-x | oox/source/ole/vbaproject.cxx | 124 | ||||
-rw-r--r-- | oox/source/vml/vmlshapecontext.cxx | 2 | ||||
-rw-r--r-- | oox/source/xls/defnamesbuffer.cxx | 8 | ||||
-rw-r--r-- | oox/source/xls/excelfilter.cxx | 45 | ||||
-rwxr-xr-x | oox/source/xls/excelvbaproject.cxx | 214 | ||||
-rw-r--r-- | oox/source/xls/externallinkfragment.cxx | 2 | ||||
-rw-r--r-- | oox/source/xls/makefile.mk | 1 | ||||
-rw-r--r-- | oox/source/xls/workbookhelper.cxx | 8 |
18 files changed, 192 insertions, 941 deletions
diff --git a/filter/source/msfilter/msvbahelper.cxx b/filter/source/msfilter/msvbahelper.cxx index 18ecc5ae6530..19e93dbb791a 100644 --- a/filter/source/msfilter/msvbahelper.cxx +++ b/filter/source/msfilter/msvbahelper.cxx @@ -38,6 +38,7 @@ #include <com/sun/star/document/XDocumentInfoSupplier.hpp> #include <tools/urlobj.hxx> #include <osl/file.hxx> +#include <unotools/pathoptions.hxx> using namespace ::com::sun::star; @@ -108,7 +109,24 @@ SfxObjectShell* findShellForUrl( const rtl::OUString& sMacroURLOrPath ) } else { - if ( aURL.equals( xModel->getURL() ) ) + // sometimes just the name of the document ( without the path + // is used + bool bDocNameNoPathMatch = false; + if ( aURL.getLength() && aURL.indexOf( '/' ) == -1 ) + { + sal_Int32 lastSlashIndex = xModel->getURL().lastIndexOf( '/' ); + if ( lastSlashIndex > -1 ) + { + bDocNameNoPathMatch = xModel->getURL().copy( lastSlashIndex + 1 ).equals( aURL ); + if ( !bDocNameNoPathMatch ) + { + rtl::OUString aTmpName = rtl::OUString::createFromAscii("'") + xModel->getURL().copy( lastSlashIndex + 1 ) + rtl::OUString::createFromAscii("'"); + bDocNameNoPathMatch = aTmpName.equals( aURL ); + } + } + } + + if ( aURL.equals( xModel->getURL() ) || bDocNameNoPathMatch ) { pFoundShell = pShell; break; @@ -221,9 +239,19 @@ VBAMacroResolvedInfo resolveVBAMacro( SfxObjectShell* pShell, const rtl::OUStrin String sDocUrlOrPath = sMacroUrl.copy( 0, nDocSepIndex ); sMacroUrl = sMacroUrl.copy( nDocSepIndex + 1 ); OSL_TRACE("doc search, current shell is 0x%x", pShell ); - SfxObjectShell* pFoundShell = findShellForUrl( sDocUrlOrPath ); + SfxObjectShell* pFoundShell = NULL; + if( bSearchGlobalTemplates ) + { + SvtPathOptions aPathOpt; + String aAddinPath = aPathOpt.GetAddinPath(); + if( rtl::OUString( sDocUrlOrPath ).indexOf( aAddinPath ) == 0 ) + pFoundShell = pShell; + } + if( pFoundShell == NULL ) + pFoundShell = findShellForUrl( sDocUrlOrPath ); OSL_TRACE("doc search, after find, found shell is 0x%x", pFoundShell ); - aRes = resolveVBAMacro( pFoundShell, sMacroUrl ); + aRes = resolveVBAMacro( pFoundShell, sMacroUrl, bSearchGlobalTemplates ); + return aRes; } else { @@ -337,14 +365,14 @@ VBAMacroResolvedInfo resolveVBAMacro( SfxObjectShell* pShell, const rtl::OUStrin break; } } + aRes.SetResolvedMacro( sProcedure.Insert( '.', 0 ).Insert( sModule, 0).Insert( '.', 0 ).Insert( sContainer, 0 ) ); } - aRes.SetResolvedMacro( sProcedure.Insert( '.', 0 ).Insert( sModule, 0).Insert( '.', 0 ).Insert( sContainer, 0 ) ); return aRes; } // Treat the args as possible inouts ( convertion at bottom of method ) -sal_Bool executeMacro( SfxObjectShell* pShell, const String& sMacroName, uno::Sequence< uno::Any >& aArgs, uno::Any& /*aRet*/, const uno::Any& aCaller ) +sal_Bool executeMacro( SfxObjectShell* pShell, const String& sMacroName, uno::Sequence< uno::Any >& aArgs, uno::Any& aRet, const uno::Any& /*aCaller*/) { sal_Bool bRes = sal_False; if ( !pShell ) @@ -355,42 +383,25 @@ sal_Bool executeMacro( SfxObjectShell* pShell, const String& sMacroName, uno::Se uno::Sequence< uno::Any > aOutArgs; try - { - uno::Reference< script::provider::XScriptProvider > xScriptProvider; - uno::Reference< script::provider::XScriptProviderSupplier > xSPS( pShell->GetModel(), uno::UNO_QUERY_THROW ); - - xScriptProvider.set( xSPS->getScriptProvider(), uno::UNO_QUERY_THROW ); - - uno::Reference< script::provider::XScript > xScript( xScriptProvider->getScript( sUrl ), uno::UNO_QUERY_THROW ); - - if ( aCaller.hasValue() ) + { ErrCode nErr( ERRCODE_BASIC_INTERNAL_ERROR ); + if ( pShell ) { - uno::Reference< beans::XPropertySet > xProps( xScript, uno::UNO_QUERY ); - if ( xProps.is() ) + nErr = pShell->CallXScript( sUrl, + aArgs, aRet, aOutArgsIndex, aOutArgs, false ); + sal_Int32 nLen = aOutArgs.getLength(); + // convert any out params to seem like they were inouts + if ( nLen ) { - uno::Sequence< uno::Any > aCallerHack(1); - aCallerHack[ 0 ] = aCaller; - xProps->setPropertyValue( rtl::OUString::createFromAscii( "Caller" ), uno::makeAny( aCallerHack ) ); + for ( sal_Int32 index=0; index < nLen; ++index ) + { + sal_Int32 nOutIndex = aOutArgsIndex[ index ]; + aArgs[ nOutIndex ] = aOutArgs[ index ]; + } } } - - - xScript->invoke( aArgs, aOutArgsIndex, aOutArgs ); - - sal_Int32 nLen = aOutArgs.getLength(); - // convert any out params to seem like they were inouts - if ( nLen ) - { - for ( sal_Int32 index=0; index < nLen; ++index ) - { - sal_Int32 nOutIndex = aOutArgsIndex[ index ]; - aArgs[ nOutIndex ] = aOutArgs[ index ]; - } - } - - bRes = sal_True; + bRes = ( nErr == ERRCODE_NONE ); } - catch ( uno::Exception& e ) + catch ( uno::Exception& ) { bRes = sal_False; } diff --git a/filter/source/msfilter/svxmsbas.cxx b/filter/source/msfilter/svxmsbas.cxx index 49fd4a7544f3..5214b2d022c3 100644 --- a/filter/source/msfilter/svxmsbas.cxx +++ b/filter/source/msfilter/svxmsbas.cxx @@ -52,8 +52,8 @@ using namespace com::sun::star::awt; #include <com/sun/star/script/XLibraryContainer.hpp> #include <com/sun/star/script/ModuleInfo.hpp> #include <com/sun/star/script/ModuleType.hpp> -#include <com/sun/star/script/XVBAModuleInfo.hpp> -#include <com/sun/star/script/XVBACompat.hpp> +#include <com/sun/star/script/vba/XVBACompatibility.hpp> +#include <com/sun/star/script/vba/XVBAModuleInfo.hpp> using namespace com::sun::star::container; using namespace com::sun::star::script; @@ -250,13 +250,21 @@ BOOL SvxImportMSVBasic::ImportCode_Impl( const String& rStorageName, { SFX_APP()->EnterBasicCall(); Reference<XLibraryContainer> xLibContainer = rDocSh.GetBasicContainer(); - Reference<XVBACompat> xVBACompat( xLibContainer, UNO_QUERY ); - - if ( xVBACompat.is() && !bAsComment ) - xVBACompat->setVBACompatModeOn( sal_True ); - DBG_ASSERT( xLibContainer.is(), "No BasicContainer!" ); + if( !bAsComment ) try + { + Reference< vba::XVBACompatibility > xVBACompat( xLibContainer, UNO_QUERY_THROW ); + xVBACompat->setVBACompatibilityMode( sal_True ); + /* Force creation of the VBAGlobals object, each application will + create the right one and store it at the Basic manager. */ + Reference< XMultiServiceFactory > xFactory( rDocSh.GetModel(), UNO_QUERY_THROW ); + xFactory->createInstance( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "ooo.vba.VBAGlobals" ) ) ); + } + catch( Exception& ) + { + } + UINT16 nStreamCount = aVBA.GetNoStreams(); Reference<XNameContainer> xLib; String aLibName( RTL_CONSTASCII_USTRINGPARAM( "Standard" ) ); @@ -270,7 +278,7 @@ BOOL SvxImportMSVBasic::ImportCode_Impl( const String& rStorageName, } if( xLib.is() ) { - Reference< script::XVBAModuleInfo > xVBAModuleInfo( xLib, UNO_QUERY ); + Reference< script::vba::XVBAModuleInfo > xVBAModuleInfo( xLib, UNO_QUERY ); Reference< container::XNameAccess > xVBACodeNamedObjectAccess; if ( !bAsComment ) { diff --git a/oox/inc/oox/ole/vbahelper.hxx b/oox/inc/oox/ole/vbahelper.hxx index 76dc1c736025..c1e7297d0c5b 100755 --- a/oox/inc/oox/ole/vbahelper.hxx +++ b/oox/inc/oox/ole/vbahelper.hxx @@ -30,11 +30,6 @@ #include "oox/helper/binarystreambase.hxx" -namespace com { namespace sun { namespace star { - namespace container { class XNameContainer; } - namespace document { class XEventsSupplier; } -} } } - namespace oox { class BinaryInputStream; } namespace oox { @@ -102,124 +97,6 @@ public: ::rtl::OUString& rValue, const ::rtl::OUString& rKeyValue ); - /** Removes whitespace characters from the beginning of the passed string. - - @param rCodeLine (in/out parameter) The string to be modified. - - @return True = at least one whitespace character found and removed - from rCodeLine. False = rCodeLine is empty or does not start with - a whitespace character. - */ - static bool eatWhitespace( ::rtl::OUString& rCodeLine ); - - /** Removes the passed keyword from the beginning of the passed string. - - @param rCodeLine (in/out parameter) The string to be modified. - - @param rKeyword The keyword to be removed from the beginning of the - rCodeLine string. - - @return True = rCodeLine starts with the passed keyword (case - insensitive), and is followed by whitespace characters, or it ends - right after the keyword. The keyword and the following whitespace - characters have been removed from rCodeLine. False = rCodeLine is - empty or does not start with the specified keyword, or the keyword - is not followed by whitespace characters. - */ - static bool eatKeyword( ::rtl::OUString& rCodeLine, const ::rtl::OUString& rKeyword ); - - /** Returns the VBA source code of the specified module, or an empty - string, if the module does not exist. - - @param rxBasicLib The container for all VBA code modules. - @param rModuleName The name of the VBA code module. - */ - static ::rtl::OUString getSourceCode( - const ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameContainer >& rxBasicLib, - const ::rtl::OUString& rModuleName ); - - /** Checks, if a macro with the specified name exists in the passed VBA - source code. - - @param rSourceCode The VBA source code. - @param rMacroName The name of the macro. - */ - static bool hasMacro( - const ::rtl::OUString& rSourceCode, - const ::rtl::OUString& rMacroName ); - - /** Checks, if a macro with the specified name exists in the specified - module. - - @param rxBasicLib The container for all VBA code modules. - @param rModuleName The name of the VBA module to check for the macro. - @param rMacroName The name of the macro. - */ - static bool hasMacro( - const ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameContainer >& rxBasicLib, - const ::rtl::OUString& rModuleName, - const ::rtl::OUString& rMacroName ); - - /** Tries to insert a VBA macro into the specified code module. - - @descr If the specified macro does not exist, it will be generated as - following, using the passed parameters. If the parameter rMacroType - is left empty, a sub procedure macro will be generated: - - Private Sub <rMacroName> ( <rMacroArgs> ) - <rMacroCode> - End Sub - - If the parameter rMacroType is not empty, a function macro - will be generated. Note that the parameter rMacroCode has to - provide the code that returns the function value. - - Private Function <rMacroName> ( <rMacroArgs> ) As <rMacroType> - <rMacroCode> - End Function - - The source code in rMacroCode may contain a special placeholder - $MACRO that will be replaced by the macro name passed in rMacroName - before the macro will be inserted into the module. - - @param rModuleName The name of the VBA module to be used. - @param rMacroName The name of the VBA macro to be inserted. - @param rMacroArgs The argument list of the VBA macro. - @param rMacroType Macro return type (empty for sub procedure). - @param rMacroCode The VBA source code for the macro. - - @return True, if the specified VBA macro has been inserted. False, if - there already exists a macro with the specified name, or if any - error has occurred, for example, Office configuration forbids to - generate executable VBA code or the specified module does not - exist. - */ - static bool insertMacro( - const ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameContainer >& rxBasicLib, - const ::rtl::OUString& rModuleName, - const ::rtl::OUString& rMacroName, - const ::rtl::OUString& rMacroArgs, - const ::rtl::OUString& rMacroType, - const ::rtl::OUString& rMacroCode ); - - /** Tries to attach a VBA macro to an event of the passed events supplier. - - @descr The function checks if the specified macro exists and attaches - it to the event of the passed events supplier. - - @param rxEventsSupp The events supplier for the event to be attached. - @param rEventName The event name used in the office API. - @param rLibraryName The name of the Basic library containing the macro. - @param rModuleName The name of the VBA module containing the macro. - @param rMacroName The name of the VBA macro to attach to the event. - */ - static bool attachMacroToEvent( - const ::com::sun::star::uno::Reference< ::com::sun::star::document::XEventsSupplier >& rxEventsSupp, - const ::rtl::OUString& rEventName, - const ::rtl::OUString& rLibraryName, - const ::rtl::OUString& rModuleName, - const ::rtl::OUString& rMacroName ); - private: VbaHelper(); ~VbaHelper(); diff --git a/oox/inc/oox/ole/vbaproject.hxx b/oox/inc/oox/ole/vbaproject.hxx index 0422ccbd0cf8..1d2fca29dbab 100755 --- a/oox/inc/oox/ole/vbaproject.hxx +++ b/oox/inc/oox/ole/vbaproject.hxx @@ -97,157 +97,6 @@ public: /** Returns true, if the document contains the specified dialog. */ bool hasDialog( const ::rtl::OUString& rDialogName ) const; - // Insert VBA code modules and VBA macros into modules -------------------- - - /** Tries to insert a VBA macro into the specified code module. - - @descr If the specified macro does not exist, it will be generated as - following, using the passed parameters. If the parameter rMacroType - is left empty, a sub procedure macro will be generated: - - Private Sub <rMacroName> ( <rMacroArgs> ) - <rMacroCode> - End Sub - - If the parameter rMacroType is not empty, a function macro - will be generated. Note that the parameter rMacroCode has to - provide the code that returns the function value. - - Private Function <rMacroName> ( <rMacroArgs> ) As <rMacroType> - <rMacroCode> - End Function - - The source code in rMacroCode may contain a special placeholder - $MACRO that will be replaced by the macro name passed in rMacroName - before the macro will be inserted into the module. - - @param rModuleName The name of the VBA module to be used. - @param rMacroName The name of the VBA macro to be inserted. - @param rMacroArgs The argument list of the VBA macro. - @param rMacroType Macro return type (empty for sub procedure). - @param rMacroCode The VBA source code for the macro. - - @return True, if the specified VBA macro has been inserted. False, if - there already exists a macro with the specified name, or if any - error has occurred, for example, Office configuration forbids to - generate executable VBA code or the specified module does not - exist. - */ - bool insertMacro( - const ::rtl::OUString& rModuleName, - const ::rtl::OUString& rMacroName, - const ::rtl::OUString& rMacroArgs, - const ::rtl::OUString& rMacroType, - const ::rtl::OUString& rMacroCode ); - - // Attach VBA macros to generic or document events ------------------------ - - /** Tries to attach the specified VBA macro to an event directly. - - @descr The function checks if the specified macro exists and attaches - it to the event of the passed events supplier. - - @param rxEventsSupp The events supplier for the event to be attached. - @param rEventName The event name used in the office API. - @param rModuleName The name of the VBA module containing the macro. - @param rMacroName The name of the VBA macro to attach to the event. - - @return True, if the specified VBA macro exists and could be attached - to the specified event. - */ - bool attachMacroToEvent( - const ::com::sun::star::uno::Reference< ::com::sun::star::document::XEventsSupplier >& rxEventsSupp, - const ::rtl::OUString& rEventName, - const ::rtl::OUString& rModuleName, - const ::rtl::OUString& rMacroName ); - - /** Tries to attach the specified VBA macro to a document event directly. - - @descr The function checks if the specified macro exists and attaches - it to the document event. - - @param rEventName The document event name used in the office API. - @param rModuleName The name of the VBA module containing the macro. - @param rMacroName The name of the VBA macro to attach to the event. - - @return True, if the specified VBA macro exists and could be attached - to the specified document event. - */ - bool attachMacroToDocumentEvent( - const ::rtl::OUString& rEventName, - const ::rtl::OUString& rModuleName, - const ::rtl::OUString& rMacroName ); - - /** Tries to attach the specified VBA macro to an event via a generated - proxy macro that implements necessary conversion between VBA and UNO. - - @descr The function checks if the specified VBA macro exists, then it - tries to generate a proxy macro using the parameters passed to this - function, appends it to the code module, and attaches it to the - event. - - The proxy macro will execute the code specified in the rProxyCode - parameter. This code may contain special placeholders that will be - replaced before the proxy macro will be inserted into the module: - - $MACRO will be replaced by the original VBA macro name passed - in the rMacroName parameter. - - $PROXY will be replaced by the name of the proxy macro - generated by this function. - - @param rxEventsSupp The events supplier for the event to be attached. - @param rEventName The event name used in the office API. - @param rModuleName The name of the VBA module containing the macro. - @param rMacroName The name of the VBA macro to attach to the event. - @param rProxyArgs The argument list of the generated proxy macro. - @param rProxyType Proxy macro return type (empty for procedure). - @param rProxyCode Proxy macro source code. - - @return True, if the specified VBA macro exists and could be attached - to the specified event. - */ - bool attachMacroToEvent( - const ::com::sun::star::uno::Reference< ::com::sun::star::document::XEventsSupplier >& rxEventsSupp, - const ::rtl::OUString& rEventName, - const ::rtl::OUString& rModuleName, - const ::rtl::OUString& rMacroName, - const ::rtl::OUString& rProxyArgs, - const ::rtl::OUString& rProxyType, - const ::rtl::OUString& rProxyCode ); - - /** Tries to attach the specified VBA macro to a document event via a - proxy macro that implements necessary conversion between VBA and UNO. - - @descr The function checks if the specified VBA macro exists, then it - tries to generate a proxy macro using the parameters passed to this - function, appends it to the code module, and attaches it to the - document event. - - The proxy macro will execute the code specified in the rProxyCode - parameter. This code may contain special placeholders that will be - replaced before the proxy macro will be inserted into the module: - - $MACRO will be replaced by the original VBA macro name passed - in the rMacroName parameter. - - $PROXY will be replaced by the name of the proxy macro - generated by this function. - - @param rEventName The document event name used in the office API. - @param rModuleName The name of the VBA module containing the macro. - @param rMacroName The name of the VBA macro to attach to the event. - @param rProxyArgs The argument list of the generated proxy macro. - @param rProxyType Proxy macro return type (empty for procedure). - @param rProxyCode Proxy macro source code. - - @return True, if the specified VBA macro exists and could be attached - to the specified event. - */ - bool attachMacroToDocumentEvent( - const ::rtl::OUString& rEventName, - const ::rtl::OUString& rModuleName, - const ::rtl::OUString& rMacroName, - const ::rtl::OUString& rProxyArgs, - const ::rtl::OUString& rProxyType, - const ::rtl::OUString& rProxyCode ); - private: VbaProject( const VbaProject& ); VbaProject& operator=( const VbaProject& ); diff --git a/oox/inc/oox/xls/excelvbaproject.hxx b/oox/inc/oox/xls/excelvbaproject.hxx deleted file mode 100755 index 6a517d13cd88..000000000000 --- a/oox/inc/oox/xls/excelvbaproject.hxx +++ /dev/null @@ -1,73 +0,0 @@ -/************************************************************************* - * - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * Copyright 2000, 2010 Oracle and/or its affiliates. - * - * OpenOffice.org - a multi-platform office productivity suite - * - * This file is part of OpenOffice.org. - * - * OpenOffice.org is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License version 3 - * only, as published by the Free Software Foundation. - * - * OpenOffice.org is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License version 3 for more details - * (a copy is included in the LICENSE file that accompanied this code). - * - * You should have received a copy of the GNU Lesser General Public License - * version 3 along with OpenOffice.org. If not, see - * <http://www.openoffice.org/license.html> - * for a copy of the LGPLv3 License. - * - ************************************************************************/ - -#ifndef OOX_XLS_EXCELVBAPROJECT_HXX -#define OOX_XLS_EXCELVBAPROJECT_HXX - -#include "oox/ole/vbaproject.hxx" -#include "oox/dllapi.h" - -namespace com { namespace sun { namespace star { - namespace sheet { class XSpreadsheetDocument; } -} } } - -namespace oox { -namespace xls { - -// ============================================================================ - -/** Special implementation of the VBA project for the Excel filters. */ -class OOX_DLLPUBLIC VbaProject : public ::oox::ole::VbaProject -{ -public: - explicit VbaProject( - const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& rxGlobalFactory, - const ::com::sun::star::uno::Reference< ::com::sun::star::sheet::XSpreadsheetDocument >& rxDocument ); - - /** Attaches all document and sheet events to existing VBA macros. */ - void attachToEvents(); - -private: - /** Attaches VBA macros to all supported document events. */ - void attachToDocumentEvents( const ::rtl::OUString& rCodeName ); - - /** Attaches VBA macros to all supported sheet events. */ - void attachToSheetEvents( - const ::com::sun::star::uno::Reference< ::com::sun::star::document::XEventsSupplier >& rxEventsSupp, - const ::rtl::OUString& rCodeName ); - -private: - ::com::sun::star::uno::Reference< ::com::sun::star::sheet::XSpreadsheetDocument > - mxDocument; -}; - -// ============================================================================ - -} // namespace xls -} // namespace oox - -#endif diff --git a/oox/source/core/filterbase.cxx b/oox/source/core/filterbase.cxx index fb9e43c732de..9b7b00988dd0 100644 --- a/oox/source/core/filterbase.cxx +++ b/oox/source/core/filterbase.cxx @@ -74,8 +74,18 @@ namespace core { namespace { +struct UrlPool +{ + ::osl::Mutex maMutex; + ::std::set< OUString > maUrls; +}; + +struct StaticUrlPool : public ::rtl::Static< UrlPool, StaticUrlPool > {}; + +// ---------------------------------------------------------------------------- + /** This guard prevents recursive loading/saving of the same document. */ -class DocumentOpenedGuard : public ::osl::Mutex +class DocumentOpenedGuard { public: explicit DocumentOpenedGuard( const OUString& rUrl ); @@ -87,31 +97,28 @@ private: DocumentOpenedGuard( const DocumentOpenedGuard& ); DocumentOpenedGuard& operator=( const DocumentOpenedGuard& ); - typedef ::std::set< OUString > UrlSet; - struct UrlPool : public ::rtl::Static< UrlSet, UrlPool > {}; - - UrlSet& mrUrls; OUString maUrl; bool mbValid; }; -DocumentOpenedGuard::DocumentOpenedGuard( const OUString& rUrl ) : - mrUrls( UrlPool::get() ) +DocumentOpenedGuard::DocumentOpenedGuard( const OUString& rUrl ) { - ::osl::MutexGuard aGuard( *this ); - mbValid = (rUrl.getLength() == 0) || (mrUrls.count( rUrl ) == 0); + UrlPool& rUrlPool = StaticUrlPool::get(); + ::osl::MutexGuard aGuard( rUrlPool.maMutex ); + mbValid = (rUrl.getLength() == 0) || (rUrlPool.maUrls.count( rUrl ) == 0); if( mbValid && (rUrl.getLength() > 0) ) { - mrUrls.insert( rUrl ); + rUrlPool.maUrls.insert( rUrl ); maUrl = rUrl; } } DocumentOpenedGuard::~DocumentOpenedGuard() { - ::osl::MutexGuard aGuard( *this ); + UrlPool& rUrlPool = StaticUrlPool::get(); + ::osl::MutexGuard aGuard( rUrlPool.maMutex ); if( maUrl.getLength() > 0 ) - mrUrls.erase( maUrl ); + rUrlPool.maUrls.erase( maUrl ); } } // namespace @@ -563,4 +570,3 @@ GraphicHelper* FilterBase::implCreateGraphicHelper() const } // namespace core } // namespace oox - diff --git a/oox/source/drawingml/chart/titlecontext.cxx b/oox/source/drawingml/chart/titlecontext.cxx index 963ccdad595a..5ff71109b710 100644 --- a/oox/source/drawingml/chart/titlecontext.cxx +++ b/oox/source/drawingml/chart/titlecontext.cxx @@ -68,7 +68,7 @@ ContextHandlerRef TextContext::onCreateContext( sal_Int32 nElement, const Attrib } break; } - return false; + return 0; } void TextContext::onEndElement( const OUString& rChars ) diff --git a/oox/source/ole/vbacontrol.cxx b/oox/source/ole/vbacontrol.cxx index 6ea28f424a83..2a36cb4ff3ca 100755 --- a/oox/source/ole/vbacontrol.cxx +++ b/oox/source/ole/vbacontrol.cxx @@ -722,6 +722,30 @@ OUString lclGetQuotedString( const OUString& rCodeLine ) return aBuffer.makeStringAndClear(); } +bool lclEatWhitespace( OUString& rCodeLine ) +{ + sal_Int32 nIndex = 0; + while( (nIndex < rCodeLine.getLength()) && ((rCodeLine[ nIndex ] == ' ') || (rCodeLine[ nIndex ] == '\t')) ) + ++nIndex; + if( nIndex > 0 ) + { + rCodeLine = rCodeLine.copy( nIndex ); + return true; + } + return false; +} + +bool lclEatKeyword( OUString& rCodeLine, const OUString& rKeyword ) +{ + if( rCodeLine.matchIgnoreAsciiCase( rKeyword ) ) + { + rCodeLine = rCodeLine.copy( rKeyword.getLength() ); + // success, if code line ends after keyword, or if whitespace follows + return (rCodeLine.getLength() == 0) || lclEatWhitespace( rCodeLine ); + } + return false; +} + } // namespace // ---------------------------------------------------------------------------- @@ -755,10 +779,10 @@ void VbaUserForm::importForm( const Reference< XNameContainer >& rxDialogLib, while( !bBeginFound && !aFrameTextStrm.isEof() ) { aLine = aFrameTextStrm.readLine().trim(); - bBeginFound = VbaHelper::eatKeyword( aLine, aBegin ); + bBeginFound = lclEatKeyword( aLine, aBegin ); } // check for the specific GUID that represents VBA forms - if( !bBeginFound || !VbaHelper::eatKeyword( aLine, CREATE_OUSTRING( "{C62A69F0-16DC-11CE-9E98-00AA00574A4F}" ) ) ) + if( !bBeginFound || !lclEatKeyword( aLine, CREATE_OUSTRING( "{C62A69F0-16DC-11CE-9E98-00AA00574A4F}" ) ) ) return; // remaining line is the form name diff --git a/oox/source/ole/vbahelper.cxx b/oox/source/ole/vbahelper.cxx index 7293e357e746..3bf72d30bfa5 100755 --- a/oox/source/ole/vbahelper.cxx +++ b/oox/source/ole/vbahelper.cxx @@ -27,27 +27,15 @@ #include "oox/ole/vbahelper.hxx" #include <rtl/ustrbuf.hxx> -#include <com/sun/star/beans/PropertyValue.hpp> -#include <com/sun/star/container/XNameContainer.hpp> -#include <com/sun/star/document/XEventsSupplier.hpp> -#include <comphelper/string.hxx> #include "oox/helper/binaryinputstream.hxx" -using ::rtl::OUString; -using ::rtl::OUStringBuffer; -using ::com::sun::star::beans::PropertyValue; -using ::com::sun::star::container::XNameContainer; -using ::com::sun::star::container::XNameReplace; -using ::com::sun::star::document::XEventsSupplier; -using ::com::sun::star::uno::Any; -using ::com::sun::star::uno::Exception; -using ::com::sun::star::uno::Sequence; -using ::com::sun::star::uno::Reference; -using ::com::sun::star::uno::UNO_SET_THROW; - namespace oox { namespace ole { +using ::rtl::OUString; +using ::rtl::OUStringBuffer; +using namespace ::com::sun::star::uno; + // ============================================================================ /*static*/ OUString VbaHelper::getBasicScriptUrl( @@ -91,157 +79,6 @@ namespace ole { return false; } -/*static*/ bool VbaHelper::eatWhitespace( OUString& rCodeLine ) -{ - sal_Int32 nIndex = 0; - while( (nIndex < rCodeLine.getLength()) && ((rCodeLine[ nIndex ] == ' ') || (rCodeLine[ nIndex ] == '\t')) ) - ++nIndex; - if( nIndex > 0 ) - { - rCodeLine = rCodeLine.copy( nIndex ); - return true; - } - return false; -} - -/*static*/ bool VbaHelper::eatKeyword( OUString& rCodeLine, const OUString& rKeyword ) -{ - if( rCodeLine.matchIgnoreAsciiCase( rKeyword ) ) - { - rCodeLine = rCodeLine.copy( rKeyword.getLength() ); - // success, if code line ends after keyword, or if whitespace follows - return (rCodeLine.getLength() == 0) || eatWhitespace( rCodeLine ); - } - return false; -} - -/*static*/ OUString VbaHelper::getSourceCode( const Reference< XNameContainer >& rxBasicLib, const OUString& rModuleName ) -{ - OUString aSourceCode; - if( rxBasicLib.is() ) try - { - rxBasicLib->getByName( rModuleName ) >>= aSourceCode; - } - catch( Exception& ) - { - } - return aSourceCode; -} - -namespace { - -bool lclGetLine( OUString& rCodeLine, sal_Int32& rnIndex, const OUString& rSourceCode ) -{ - if( rnIndex < rSourceCode.getLength() ) - { - sal_Int32 nPosLF = rSourceCode.indexOf( '\n', rnIndex ); - if( nPosLF >= rnIndex ) - { - rCodeLine = rSourceCode.copy( rnIndex, nPosLF - rnIndex ).trim(); - rnIndex = nPosLF + 1; - return true; - } - } - return false; -} - -} // namespace - -/*static*/ bool VbaHelper::hasMacro( const OUString& rSourceCode, const OUString& rMacroName ) -{ - // scan all text lines for '[Public|Private] [Static] Sub <macroname> (...)' - const OUString aPublic = CREATE_OUSTRING( "Public" ); - const OUString aPrivate = CREATE_OUSTRING( "Private" ); - const OUString aStatic = CREATE_OUSTRING( "Static" ); - const OUString aSub = CREATE_OUSTRING( "Sub" ); - - OUString aCodeLine; - sal_Int32 nIndex = 0; - while( lclGetLine( aCodeLine, nIndex, rSourceCode ) ) - { - // eat optional 'Private' or 'Public', but do not accept both keywords in a row (therefore the ||) - eatKeyword( aCodeLine, aPublic ) || eatKeyword( aCodeLine, aPrivate ); - // eat optional 'Static' - eatKeyword( aCodeLine, aStatic ); - // eat 'Sub' keyword, check if macro name follows - if( eatKeyword( aCodeLine, aSub ) && aCodeLine.matchIgnoreAsciiCase( rMacroName ) ) - { - // eat macro name and following whitespace - aCodeLine = aCodeLine.copy( rMacroName.getLength() ); - eatWhitespace( aCodeLine ); - // opening bracket must follow the macro name - if( (aCodeLine.getLength() >= 2) && (aCodeLine[ 0 ] == '(') ) - return true; - } - } - return false; -} - -/*static*/ bool VbaHelper::hasMacro( const Reference< XNameContainer >& rxBasicLib, - const OUString& rModuleName, const OUString& rMacroName ) -{ - return hasMacro( getSourceCode( rxBasicLib, rModuleName ), rMacroName ); -} - -/*static*/ bool VbaHelper::insertMacro( const Reference< XNameContainer >& rxBasicLib, const OUString& rModuleName, - const OUString& rMacroName, const OUString& rMacroArgs, const OUString& rMacroType, const OUString& rMacroCode ) -{ - if( rxBasicLib.is() ) try - { - // receive module source code and check that the specified macro does not exist - OUString aSourceCode = getSourceCode( rxBasicLib, rModuleName ); - if( !hasMacro( aSourceCode, rMacroName ) ) - { - bool bFunction = rMacroType.getLength() > 0; - const sal_Char* pcSubFunc = bFunction ? "Function" : "Sub"; - OUStringBuffer aBuffer( aSourceCode ); - // generate the source code for the new macro - aBuffer.appendAscii( RTL_CONSTASCII_STRINGPARAM( "\nPrivate " ) ). - appendAscii( pcSubFunc ).append( sal_Unicode( ' ' ) ). - append( rMacroName ).append( sal_Unicode( '(' ) ); - if( rMacroArgs.getLength() > 0 ) - aBuffer.append( sal_Unicode( ' ' ) ).append( rMacroArgs ).append( sal_Unicode( ' ' ) ); - aBuffer.append( sal_Unicode( ')' ) ); - if( bFunction ) - aBuffer.appendAscii( RTL_CONSTASCII_STRINGPARAM( " As " ) ).append( rMacroType ); - aBuffer.append( sal_Unicode( '\n' ) ); - // replace all $MACRO placeholders with macro name - if( rMacroCode.getLength() > 0 ) - { - OUString aMacroCode = ::comphelper::string::searchAndReplaceAsciiL( rMacroCode, RTL_CONSTASCII_STRINGPARAM( "$MACRO" ), rMacroName ); - aBuffer.append( aMacroCode ).append( sal_Unicode( '\n' ) ); - } - aBuffer.appendAscii( RTL_CONSTASCII_STRINGPARAM( "End " ) ).appendAscii( pcSubFunc ).append( sal_Unicode( '\n' ) ); - rxBasicLib->replaceByName( rModuleName, Any( aBuffer.makeStringAndClear() ) ); - return true; - } - } - catch( Exception& ) - { - } - return false; -} - -/*static*/ bool VbaHelper::attachMacroToEvent( const Reference< XEventsSupplier >& rxEventsSupp, - const OUString& rEventName, const OUString& rLibraryName, const OUString& rModuleName, const OUString& rMacroName ) -{ - if( rxEventsSupp.is() ) try - { - Reference< XNameReplace > xEvents( rxEventsSupp->getEvents(), UNO_SET_THROW ); - Sequence< PropertyValue > aEvent( 2 ); - aEvent[ 0 ].Name = CREATE_OUSTRING( "EventType" ); - aEvent[ 0 ].Value <<= CREATE_OUSTRING( "Script" ); - aEvent[ 1 ].Name = CREATE_OUSTRING( "Script" ); - aEvent[ 1 ].Value <<= getBasicScriptUrl( rLibraryName, rModuleName, rMacroName ); - xEvents->replaceByName( rEventName, Any( aEvent ) ); - return true; - } - catch( Exception& ) - { - } - return false; -} - // ============================================================================ } // namespace ole diff --git a/oox/source/ole/vbamodule.cxx b/oox/source/ole/vbamodule.cxx index e9388e54215a..9886f2cc5968 100755 --- a/oox/source/ole/vbamodule.cxx +++ b/oox/source/ole/vbamodule.cxx @@ -29,7 +29,7 @@ #include <com/sun/star/container/XNameContainer.hpp> #include <com/sun/star/script/ModuleInfo.hpp> #include <com/sun/star/script/ModuleType.hpp> -#include <com/sun/star/script/XVBAModuleInfo.hpp> +#include <com/sun/star/script/vba/XVBAModuleInfo.hpp> #include "oox/helper/binaryinputstream.hxx" #include "oox/helper/storagebase.hxx" #include "oox/helper/textinputstream.hxx" @@ -38,18 +38,12 @@ using ::rtl::OUString; using ::rtl::OUStringBuffer; -using ::com::sun::star::container::XNameAccess; -using ::com::sun::star::container::XNameContainer; -using ::com::sun::star::frame::XModel; -using ::com::sun::star::script::ModuleInfo; -using ::com::sun::star::script::XVBAModuleInfo; -using ::com::sun::star::uno::Any; -using ::com::sun::star::uno::Exception; -using ::com::sun::star::uno::Reference; -using ::com::sun::star::uno::UNO_QUERY; -using ::com::sun::star::uno::UNO_QUERY_THROW; - -namespace ApiModuleType = ::com::sun::star::script::ModuleType; + +using namespace ::com::sun::star::container; +using namespace ::com::sun::star::frame; +using namespace ::com::sun::star::script; +using namespace ::com::sun::star::script::vba; +using namespace ::com::sun::star::uno; namespace oox { namespace ole { @@ -60,7 +54,7 @@ VbaModule::VbaModule( const Reference< XModel >& rxDocModel, const OUString& rNa mxDocModel( rxDocModel ), maName( rName ), meTextEnc( eTextEnc ), - mnType( ApiModuleType::UNKNOWN ), + mnType( ModuleType::UNKNOWN ), mnOffset( SAL_MAX_UINT32 ), mbReadOnly( false ), mbPrivate( false ), @@ -107,13 +101,13 @@ void VbaModule::importDirRecords( BinaryInputStream& rDirStrm ) break; case VBA_ID_MODULETYPEPROCEDURAL: OOX_ENSURE_RECORDSIZE( nRecSize == 0 ); - OSL_ENSURE( mnType == ApiModuleType::UNKNOWN, "VbaModule::importDirRecords - multiple module type records" ); - mnType = ApiModuleType::NORMAL; + OSL_ENSURE( mnType == ModuleType::UNKNOWN, "VbaModule::importDirRecords - multiple module type records" ); + mnType = ModuleType::NORMAL; break; case VBA_ID_MODULETYPEDOCUMENT: OOX_ENSURE_RECORDSIZE( nRecSize == 0 ); - OSL_ENSURE( mnType == ApiModuleType::UNKNOWN, "VbaModule::importDirRecords - multiple module type records" ); - mnType = ApiModuleType::DOCUMENT; + OSL_ENSURE( mnType == ModuleType::UNKNOWN, "VbaModule::importDirRecords - multiple module type records" ); + mnType = ModuleType::DOCUMENT; break; case VBA_ID_MODULEREADONLY: OOX_ENSURE_RECORDSIZE( nRecSize == 0 ); @@ -130,7 +124,7 @@ void VbaModule::importDirRecords( BinaryInputStream& rDirStrm ) } OSL_ENSURE( maName.getLength() > 0, "VbaModule::importDirRecords - missing module name" ); OSL_ENSURE( maStreamName.getLength() > 0, "VbaModule::importDirRecords - missing module stream name" ); - OSL_ENSURE( mnType != ApiModuleType::UNKNOWN, "VbaModule::importDirRecords - missing module type" ); + OSL_ENSURE( mnType != ModuleType::UNKNOWN, "VbaModule::importDirRecords - missing module type" ); OSL_ENSURE( mnOffset < SAL_MAX_UINT32, "VbaModule::importDirRecords - missing module stream offset" ); } @@ -155,18 +149,18 @@ void VbaModule::importSourceCode( StorageBase& rVbaStrg, aSourceCode.appendAscii( RTL_CONSTASCII_STRINGPARAM( "Rem Attribute VBA_ModuleType=" ) ); switch( mnType ) { - case ApiModuleType::NORMAL: + case ModuleType::NORMAL: aSourceCode.appendAscii( RTL_CONSTASCII_STRINGPARAM( "VBAModule" ) ); break; - case ApiModuleType::CLASS: + case ModuleType::CLASS: aSourceCode.appendAscii( RTL_CONSTASCII_STRINGPARAM( "VBAClassModule" ) ); break; - case ApiModuleType::FORM: + case ModuleType::FORM: aSourceCode.appendAscii( RTL_CONSTASCII_STRINGPARAM( "VBAFormModule" ) ); // hack from old filter, document Basic should know the XModel, but it doesn't aModuleInfo.ModuleObject.set( mxDocModel, UNO_QUERY ); break; - case ApiModuleType::DOCUMENT: + case ModuleType::DOCUMENT: aSourceCode.appendAscii( RTL_CONSTASCII_STRINGPARAM( "VBADocumentModule" ) ); // get the VBA object associated to the document module if( rxDocObjectNA.is() ) try @@ -184,7 +178,7 @@ void VbaModule::importSourceCode( StorageBase& rVbaStrg, if( mbExecutable ) { aSourceCode.appendAscii( RTL_CONSTASCII_STRINGPARAM( "Option VBASupport 1\n" ) ); - if( mnType == ApiModuleType::CLASS ) + if( mnType == ModuleType::CLASS ) aSourceCode.appendAscii( RTL_CONSTASCII_STRINGPARAM( "Option ClassModule\n" ) ); } else diff --git a/oox/source/ole/vbaproject.cxx b/oox/source/ole/vbaproject.cxx index a370fb3d168e..deff066a5ed5 100755 --- a/oox/source/ole/vbaproject.cxx +++ b/oox/source/ole/vbaproject.cxx @@ -26,14 +26,13 @@ ************************************************************************/ #include "oox/ole/vbaproject.hxx" -#include <com/sun/star/document/XEventsSupplier.hpp> #include <com/sun/star/document/XStorageBasedDocument.hpp> #include <com/sun/star/embed/ElementModes.hpp> #include <com/sun/star/embed/XTransactedObject.hpp> #include <com/sun/star/lang/XMultiServiceFactory.hpp> #include <com/sun/star/script/ModuleType.hpp> #include <com/sun/star/script/XLibraryContainer.hpp> -#include <com/sun/star/script/XVBACompat.hpp> +#include <com/sun/star/script/vba/XVBACompatibility.hpp> #include <rtl/tencinfo.h> #include <rtl/ustrbuf.h> #include <comphelper/configurationhelper.hxx> @@ -52,27 +51,17 @@ using ::rtl::OUString; using ::rtl::OUStringBuffer; -using ::com::sun::star::container::XNameAccess; -using ::com::sun::star::container::XNameContainer; -using ::com::sun::star::document::XEventsSupplier; -using ::com::sun::star::document::XStorageBasedDocument; -using ::com::sun::star::embed::XStorage; -using ::com::sun::star::embed::XTransactedObject; -using ::com::sun::star::frame::XModel; -using ::com::sun::star::io::XStream; -using ::com::sun::star::lang::XMultiServiceFactory; -using ::com::sun::star::script::XLibraryContainer; -using ::com::sun::star::script::XVBACompat; -using ::com::sun::star::uno::Any; -using ::com::sun::star::uno::Exception; -using ::com::sun::star::uno::Reference; -using ::com::sun::star::uno::UNO_QUERY; -using ::com::sun::star::uno::UNO_QUERY_THROW; -using ::com::sun::star::uno::UNO_SET_THROW; -using ::com::sun::star::uno::XInterface; using ::comphelper::ConfigurationHelper; -namespace ApiModuleType = ::com::sun::star::script::ModuleType; +using namespace ::com::sun::star::container; +using namespace ::com::sun::star::document; +using namespace ::com::sun::star::embed; +using namespace ::com::sun::star::frame; +using namespace ::com::sun::star::io; +using namespace ::com::sun::star::lang; +using namespace ::com::sun::star::script; +using namespace ::com::sun::star::script::vba; +using namespace ::com::sun::star::uno; namespace oox { namespace ole { @@ -184,70 +173,6 @@ bool VbaProject::hasDialog( const OUString& rDialogName ) const return mxDialogLib.is() && mxDialogLib->hasByName( rDialogName ); } -// Insert VBA code modules and VBA macros into modules ------------------------ - -bool VbaProject::insertMacro( const OUString& rModuleName, - const OUString& rMacroName, const OUString& rMacroArgs, - const OUString& rMacroType, const OUString& rMacroCode ) -{ - return - // do nothing if macros are imported as comments - isImportVbaExecutable() && - // try to insert the macro (will check that the macro does not exist yet) - VbaHelper::insertMacro( mxBasicLib, rModuleName, rMacroName, rMacroArgs, rMacroType, rMacroCode ); -} - -// Attach VBA macros to generic or document events ---------------------------- - -bool VbaProject::attachMacroToEvent( const Reference< XEventsSupplier >& rxEventsSupp, - const OUString& rEventName, const OUString& rModuleName, const OUString& rMacroName ) -{ - return - // do not attach if macros are imported as comments - isImportVbaExecutable() && - // check that the specified macro exists in the module - VbaHelper::hasMacro( mxBasicLib, rModuleName, rMacroName ) && - // attach the macro to the events supplier - VbaHelper::attachMacroToEvent( rxEventsSupp, rEventName, maLibName, rModuleName, rMacroName ); -} - -bool VbaProject::attachMacroToDocumentEvent( const OUString& rEventName, - const OUString& rModuleName, const OUString& rMacroName ) -{ - Reference< XEventsSupplier > xEventsSupp( mxDocModel, UNO_QUERY ); - return attachMacroToEvent( xEventsSupp, rEventName, rModuleName, rMacroName ); -} - -bool VbaProject::attachMacroToEvent( const Reference< XEventsSupplier >& rxEventsSupp, - const OUString& rEventName, const OUString& rModuleName, const OUString& rMacroName, - const OUString& rProxyArgs, const OUString& rProxyType, const OUString& rProxyCode ) -{ - // receive module source code, and check that the specified macro exists in the module - OUString aSourceCode = VbaHelper::getSourceCode( mxBasicLib, rModuleName ); - if( isImportVbaExecutable() && VbaHelper::hasMacro( aSourceCode, rMacroName ) ) - { - // create the name of the proxy macro, and the macro source code - OUString aProxyName = OUStringBuffer( rMacroName ).append( sal_Unicode( '_' ) ). - append( rEventName ).appendAscii( "_Proxy" ).makeStringAndClear(); - // replace $MACRO and $PROXY placeholders in proxy source code - OUString aProxyCode = ::comphelper::string::searchAndReplaceAsciiL( rProxyCode, RTL_CONSTASCII_STRINGPARAM( "$MACRO" ), rMacroName ); - aProxyCode = ::comphelper::string::searchAndReplaceAsciiL( aProxyCode, RTL_CONSTASCII_STRINGPARAM( "$PROXY" ), aProxyName ); - // insert the new macro into the code module and attach it to the event - return - VbaHelper::insertMacro( mxBasicLib, rModuleName, aProxyName, rProxyArgs, rProxyType, aProxyCode ) && - VbaHelper::attachMacroToEvent( rxEventsSupp, rEventName, maLibName, rModuleName, aProxyName ); - } - return false; -} - -bool VbaProject::attachMacroToDocumentEvent( - const OUString& rEventName, const OUString& rModuleName, const OUString& rMacroName, - const OUString& rProxyArgs, const OUString& rProxyType, const OUString& rProxyCode ) -{ - Reference< XEventsSupplier > xEventsSupp( mxDocModel, UNO_QUERY ); - return attachMacroToEvent( xEventsSupp, rEventName, rModuleName, rMacroName, rProxyArgs, rProxyType, rProxyCode ); -} - // private -------------------------------------------------------------------- Reference< XLibraryContainer > VbaProject::getLibraryContainer( sal_Int32 nPropId ) @@ -394,23 +319,23 @@ void VbaProject::importVba( StorageBase& rVbaPrjStrg, const GraphicHelper& rGrap bExitLoop = (nLineLen >= 2) && (aLine[ 0 ] == '[') && (aLine[ nLineLen - 1 ] == ']'); if( !bExitLoop && VbaHelper::extractKeyValue( aKey, aValue, aLine ) ) { - sal_Int32 nType = ApiModuleType::UNKNOWN; + sal_Int32 nType = ModuleType::UNKNOWN; if( aKey.equalsIgnoreAsciiCaseAsciiL( RTL_CONSTASCII_STRINGPARAM( "Document" ) ) ) { - nType = ApiModuleType::DOCUMENT; + nType = ModuleType::DOCUMENT; // strip automation server version from module names sal_Int32 nSlashPos = aValue.indexOf( '/' ); if( nSlashPos >= 0 ) aValue = aValue.copy( 0, nSlashPos ); } else if( aKey.equalsIgnoreAsciiCaseAsciiL( RTL_CONSTASCII_STRINGPARAM( "Module" ) ) ) - nType = ApiModuleType::NORMAL; + nType = ModuleType::NORMAL; else if( aKey.equalsIgnoreAsciiCaseAsciiL( RTL_CONSTASCII_STRINGPARAM( "Class" ) ) ) - nType = ApiModuleType::CLASS; + nType = ModuleType::CLASS; else if( aKey.equalsIgnoreAsciiCaseAsciiL( RTL_CONSTASCII_STRINGPARAM( "BaseClass" ) ) ) - nType = ApiModuleType::FORM; + nType = ModuleType::FORM; - if( (nType != ApiModuleType::UNKNOWN) && (aValue.getLength() > 0) ) + if( (nType != ModuleType::UNKNOWN) && (aValue.getLength() > 0) ) { OSL_ENSURE( aModules.has( aValue ), "VbaProject::importVba - module not found" ); if( VbaModule* pModule = aModules.get( aValue ).get() ) @@ -426,13 +351,23 @@ void VbaProject::importVba( StorageBase& rVbaPrjStrg, const GraphicHelper& rGrap specified. */ if( !aModules.empty() ) try { - // get the basic library + // get the model factory and the basic library + Reference< XMultiServiceFactory > xModelFactory( mxDocModel, UNO_QUERY_THROW ); Reference< XNameContainer > xBasicLib( createBasicLibrary(), UNO_SET_THROW ); // set library container to VBA compatibility mode try { - Reference< XVBACompat >( getLibraryContainer( PROP_BasicLibraries ), UNO_QUERY_THROW )->setVBACompatModeOn( sal_True ); + Reference< XVBACompatibility >( getLibraryContainer( PROP_BasicLibraries ), UNO_QUERY_THROW )->setVBACompatibilityMode( sal_True ); + } + catch( Exception& ) + { + } + + // create the VBAGlobals object, the model will store it in the Basic manager + try + { + xModelFactory->createInstance( CREATE_OUSTRING( "ooo.vba.VBAGlobals" ) ); } catch( Exception& ) { @@ -442,7 +377,6 @@ void VbaProject::importVba( StorageBase& rVbaPrjStrg, const GraphicHelper& rGrap Reference< XNameAccess > xDocObjectNA; try { - Reference< XMultiServiceFactory > xModelFactory( mxDocModel, UNO_QUERY_THROW ); xDocObjectNA.set( xModelFactory->createInstance( CREATE_OUSTRING( "ooo.vba.VBAObjectModuleObjectProvider" ) ), UNO_QUERY ); } catch( Exception& ) @@ -475,7 +409,7 @@ void VbaProject::importVba( StorageBase& rVbaPrjStrg, const GraphicHelper& rGrap { // resolve module name from storage name (which equals the module stream name) VbaModule* pModule = aModulesByStrm.get( *aIt ).get(); - OSL_ENSURE( pModule && (pModule->getType() == ApiModuleType::FORM), + OSL_ENSURE( pModule && (pModule->getType() == ModuleType::FORM), "VbaProject::importVba - form substorage without form module" ); OUString aModuleName; if( pModule ) diff --git a/oox/source/vml/vmlshapecontext.cxx b/oox/source/vml/vmlshapecontext.cxx index ec7da1d4d900..08115d4f8d25 100644 --- a/oox/source/vml/vmlshapecontext.cxx +++ b/oox/source/vml/vmlshapecontext.cxx @@ -170,7 +170,7 @@ ShapeContextBase::ShapeContextBase( ContextHandler2Helper& rParent ) : case VML_TOKEN( image ): return new ShapeContext( rParent, rAttribs, rShapes.createShape< ComplexShape >() ); } - return false; + return 0; } // ============================================================================ diff --git a/oox/source/xls/defnamesbuffer.cxx b/oox/source/xls/defnamesbuffer.cxx index 69214034fee7..a02375e2b869 100644 --- a/oox/source/xls/defnamesbuffer.cxx +++ b/oox/source/xls/defnamesbuffer.cxx @@ -486,8 +486,9 @@ void DefinedName::importDefinedName( BiffInputStream& rStrm, sal_Int16 nCalcShee void DefinedName::createNameObject() { - // do not create hidden names and names for (macro) functions - if( maModel.mbHidden || maModel.mbFunction ) + // do not create names for (macro) functions + // #163146# do not ignore hidden names (may be regular names created by VBA scripts) + if( /*maModel.mbHidden ||*/ maModel.mbFunction ) return; // convert original name to final Calc name @@ -498,10 +499,13 @@ void DefinedName::createNameObject() else maCalcName = maModel.maName; //! TODO convert to valid name + // #163146# do not rename sheet-local names by default, this breaks VBA scripts +#if 0 // append sheet index for local names in multi-sheet documents if( isWorkbookFile() && !isGlobalName() ) maCalcName = OUStringBuffer( maCalcName ).append( sal_Unicode( '_' ) ). append( static_cast< sal_Int32 >( mnCalcSheet + 1 ) ).makeStringAndClear(); +#endif // special flags for this name sal_Int32 nNameFlags = 0; diff --git a/oox/source/xls/excelfilter.cxx b/oox/source/xls/excelfilter.cxx index 71475790851f..5affbfff44a7 100644 --- a/oox/source/xls/excelfilter.cxx +++ b/oox/source/xls/excelfilter.cxx @@ -115,19 +115,18 @@ ExcelFilter::~ExcelFilter() bool ExcelFilter::importDocument() throw() { - /* to activate the XLSX/XLSB dumper, define the environment variable - OOO_XLSBDUMPER and insert the full path to the file - file:///<path-to-oox-module>/source/dump/xlsbdumper.ini. */ + /* To activate the XLSX/XLSB dumper, insert the full path to the file + file:///<path-to-oox-module>/source/dump/xlsbdumper.ini + into the environment variable OOO_XLSBDUMPER and start the office with + this variable (nonpro only). */ OOX_DUMP_FILE( ::oox::dump::xlsb::Dumper ); - bool bRet = false; OUString aWorkbookPath = getFragmentPathFromFirstType( CREATE_OFFICEDOC_RELATIONSTYPE( "officeDocument" ) ); - if( aWorkbookPath.getLength() > 0 ) - { - WorkbookHelperRoot aHelper( *this ); - bRet = aHelper.isValid() && importFragment( new OoxWorkbookFragment( aHelper, aWorkbookPath ) ); - } - return bRet; + if( aWorkbookPath.getLength() == 0 ) + return false; + + WorkbookHelperRoot aHelper( *this ); + return aHelper.isValid() && importFragment( new OoxWorkbookFragment( aHelper, aWorkbookPath ) ); } bool ExcelFilter::exportDocument() throw() @@ -198,31 +197,30 @@ ExcelBiffFilter::~ExcelBiffFilter() bool ExcelBiffFilter::importDocument() throw() { - /* to activate the BIFF dumper, define the environment variable - OOO_BIFFDUMPER and insert the full path to the file - file:///<path-to-oox-module>/source/dump/biffdumper.ini. */ + /* To activate the BIFF dumper, insert the full path to the file + file:///<path-to-oox-module>/source/dump/biffdumper.ini + into the environment variable OOO_BIFFDUMPER and start the office with + this variable (nonpro only). */ OOX_DUMP_FILE( ::oox::dump::biff::Dumper ); /* The boolean argument "UseBiffFilter" passed through XInitialisation - decides whether to use the BIFF file dumper implemented in this filter - only (false or missing), or to import/export the document (true). */ + decides whether to import/export the document with this filter (true), + or to only use the BIFF file dumper implemented in this filter (false + or missing) */ Any aUseBiffFilter = getArgument( CREATE_OUSTRING( "UseBiffFilter" ) ); bool bUseBiffFilter = false; if( !(aUseBiffFilter >>= bUseBiffFilter) || !bUseBiffFilter ) return true; - bool bRet = false; - // detect BIFF version and workbook stream name OUString aWorkbookName; BiffType eBiff = BiffDetector::detectStorageBiffVersion( aWorkbookName, getStorage() ); OSL_ENSURE( eBiff != BIFF_UNKNOWN, "ExcelBiffFilter::ExcelBiffFilter - invalid file format" ); - if( eBiff != BIFF_UNKNOWN ) - { - WorkbookHelperRoot aHelper( *this, eBiff ); - bRet = aHelper.isValid() && BiffWorkbookFragment( aHelper, aWorkbookName ).importFragment(); - } - return bRet; + if( eBiff == BIFF_UNKNOWN ) + return false; + + WorkbookHelperRoot aHelper( *this, eBiff ); + return aHelper.isValid() && BiffWorkbookFragment( aHelper, aWorkbookName ).importFragment(); } bool ExcelBiffFilter::exportDocument() throw() @@ -244,4 +242,3 @@ OUString ExcelBiffFilter::implGetImplementationName() const } // namespace xls } // namespace oox - diff --git a/oox/source/xls/excelvbaproject.cxx b/oox/source/xls/excelvbaproject.cxx deleted file mode 100755 index fc3caf7e59aa..000000000000 --- a/oox/source/xls/excelvbaproject.cxx +++ /dev/null @@ -1,214 +0,0 @@ -/************************************************************************* - * - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * Copyright 2000, 2010 Oracle and/or its affiliates. - * - * OpenOffice.org - a multi-platform office productivity suite - * - * This file is part of OpenOffice.org. - * - * OpenOffice.org is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License version 3 - * only, as published by the Free Software Foundation. - * - * OpenOffice.org is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License version 3 for more details - * (a copy is included in the LICENSE file that accompanied this code). - * - * You should have received a copy of the GNU Lesser General Public License - * version 3 along with OpenOffice.org. If not, see - * <http://www.openoffice.org/license.html> - * for a copy of the LGPLv3 License. - * - ************************************************************************/ - -#include "oox/xls/excelvbaproject.hxx" -#include <com/sun/star/container/XEnumeration.hpp> -#include <com/sun/star/container/XEnumerationAccess.hpp> -#include <com/sun/star/document/XEventsSupplier.hpp> -#include <com/sun/star/frame/XModel.hpp> -#include <com/sun/star/sheet/XSpreadsheetDocument.hpp> -#include "properties.hxx" -#include "oox/helper/helper.hxx" -#include "oox/helper/propertyset.hxx" - -using ::rtl::OUString; -using ::com::sun::star::container::XEnumeration; -using ::com::sun::star::container::XEnumerationAccess; -using ::com::sun::star::document::XEventsSupplier; -using ::com::sun::star::frame::XModel; -using ::com::sun::star::lang::XMultiServiceFactory; -using ::com::sun::star::sheet::XSpreadsheetDocument; -using ::com::sun::star::uno::Exception; -using ::com::sun::star::uno::Reference; -using ::com::sun::star::uno::UNO_QUERY; -using ::com::sun::star::uno::UNO_QUERY_THROW; -using ::com::sun::star::uno::UNO_SET_THROW; - -namespace oox { -namespace xls { - -// ============================================================================ - -VbaProject::VbaProject( const Reference< XMultiServiceFactory >& rxGlobalFactory, const Reference< XSpreadsheetDocument >& rxDocument ) : - ::oox::ole::VbaProject( rxGlobalFactory, Reference< XModel >( rxDocument, UNO_QUERY ), CREATE_OUSTRING( "Calc" ) ), - mxDocument( rxDocument ) -{ -} - -void VbaProject::attachToEvents() -{ - // do nothing is code is not executable - if( !isImportVbaExecutable() ) - return; - - // document events - PropertySet aDocProp( mxDocument ); - OUString aCodeName; - aDocProp.getProperty( aCodeName, PROP_CodeName ); - attachToDocumentEvents( aCodeName ); - - // sheet events - if( mxDocument.is() ) try - { - Reference< XEnumerationAccess > xSheetsEA( mxDocument->getSheets(), UNO_QUERY_THROW ); - Reference< XEnumeration > xSheetsEnum( xSheetsEA->createEnumeration(), UNO_SET_THROW ); - // own try/catch for every sheet - while( xSheetsEnum->hasMoreElements() ) try - { - // TODO: once we have chart sheets we need a switch/case on sheet type - Reference< XEventsSupplier > xEventsSupp( xSheetsEnum->nextElement(), UNO_QUERY_THROW ); - PropertySet aSheetProp( xEventsSupp ); - aSheetProp.getProperty( aCodeName, PROP_CodeName ); - attachToSheetEvents( xEventsSupp, aCodeName ); - } - catch( Exception& ) - { - } - } - catch( Exception& ) - { - } -} - -// private -------------------------------------------------------------------- - -void VbaProject::attachToDocumentEvents( const OUString& rCodeName ) -{ - if( (rCodeName.getLength() == 0) || !hasModule( rCodeName ) ) - return; - - attachMacroToDocumentEvent( CREATE_OUSTRING( "OnLoad" ), rCodeName, CREATE_OUSTRING( "Workbook_Open" ) ); - attachMacroToDocumentEvent( CREATE_OUSTRING( "OnFocus" ), rCodeName, CREATE_OUSTRING( "Workbook_Activate" ) ); - attachMacroToDocumentEvent( CREATE_OUSTRING( "OnUnfocus" ), rCodeName, CREATE_OUSTRING( "Workbook_Deactivate" ) ); - attachMacroToDocumentEvent( CREATE_OUSTRING( "OnSave" ), rCodeName, CREATE_OUSTRING( "Workbook_BeforeSave" ), OUString(), OUString(), CREATE_OUSTRING( "\t$MACRO False, False" ) ); - attachMacroToDocumentEvent( CREATE_OUSTRING( "OnSaveAs" ), rCodeName, CREATE_OUSTRING( "Workbook_BeforeSave" ), OUString(), OUString(), CREATE_OUSTRING( "\t$MACRO True, False" ) ); - attachMacroToDocumentEvent( CREATE_OUSTRING( "OnSaveDone" ), rCodeName, CREATE_OUSTRING( "Workbook_AfterSave" ), OUString(), OUString(), CREATE_OUSTRING( "\t$MACRO True" ) ); - attachMacroToDocumentEvent( CREATE_OUSTRING( "OnSaveAsDone" ), rCodeName, CREATE_OUSTRING( "Workbook_AfterSave" ), OUString(), OUString(), CREATE_OUSTRING( "\t$MACRO True" ) ); - attachMacroToDocumentEvent( CREATE_OUSTRING( "OnSaveFailed" ), rCodeName, CREATE_OUSTRING( "Workbook_AfterSave" ), OUString(), OUString(), CREATE_OUSTRING( "\t$MACRO False" ) ); - attachMacroToDocumentEvent( CREATE_OUSTRING( "OnSaveAsFailed" ), rCodeName, CREATE_OUSTRING( "Workbook_AfterSave" ), OUString(), OUString(), CREATE_OUSTRING( "\t$MACRO False" ) ); - attachMacroToDocumentEvent( CREATE_OUSTRING( "OnPrint" ), rCodeName, CREATE_OUSTRING( "Workbook_BeforePrint" ), OUString(), OUString(), CREATE_OUSTRING( "\t$MACRO False" ) ); - attachMacroToDocumentEvent( CREATE_OUSTRING( "OnPrepareUnload" ), rCodeName, CREATE_OUSTRING( "Workbook_BeforeClose" ), OUString(), OUString(), CREATE_OUSTRING( "\t$MACRO False" ) ); -} - -void VbaProject::attachToSheetEvents( const Reference< XEventsSupplier >& rxEventsSupp, const OUString& rCodeName ) -{ - if( !rxEventsSupp.is() || (rCodeName.getLength() == 0) || !hasModule( rCodeName ) ) - return; - - // attach macros to simple sheet events directly - attachMacroToEvent( rxEventsSupp, CREATE_OUSTRING( "OnFocus" ), rCodeName, CREATE_OUSTRING( "Worksheet_Activate" ) ); - attachMacroToEvent( rxEventsSupp, CREATE_OUSTRING( "OnUnfocus" ), rCodeName, CREATE_OUSTRING( "Worksheet_Deactivate" ) ); - attachMacroToEvent( rxEventsSupp, CREATE_OUSTRING( "OnCalculate" ), rCodeName, CREATE_OUSTRING( "Worksheet_Calculate" ) ); - - /* Attach macros to complex sheet events. The events pass a cell range or - a collection of cell ranges depending on the event type and sheet - selection. The generated proxy macros need to convert these UNO renges - to VBA compatible ranges. - */ - -#define VBA_MACRONAME_RANGECONV "Local_GetVbaRangeFromUnoRange" -#define VBA_MACRONAME_TARGETCONV "Local_GetVbaTargetFromUnoTarget" - - /* If this variable turns to true, the macros that convert UNO cell ranges - to VBA Range objects have to be inserted. - */ - bool bNeedsTargetHelper = false; - - /* Insert the proxy macros attached to sheet events that notify something - has changed (changed selection and changed cell contents). These events - cannot be cancelled. The proxy macro converts the passed UNO cell range - or collection of cell ranges to a VBA Range object, and calls the VBA - event handler. - */ - OUString aChangeProxyArgs = CREATE_OUSTRING( "ByVal unoTarget As Object" ); - OUString aChangeProxyCode = CREATE_OUSTRING( - "\tDim vbaTarget As Range : Set vbaTarget = " VBA_MACRONAME_TARGETCONV "( unoTarget )\n" - "\tIf Not vbaTarget Is Nothing Then $MACRO vbaTarget" ); - bNeedsTargetHelper |= attachMacroToEvent( rxEventsSupp, CREATE_OUSTRING( "OnChange" ), rCodeName, CREATE_OUSTRING( "Worksheet_Change" ), aChangeProxyArgs, OUString(), aChangeProxyCode ); - bNeedsTargetHelper |= attachMacroToEvent( rxEventsSupp, CREATE_OUSTRING( "OnSelect" ), rCodeName, CREATE_OUSTRING( "Worksheet_SelectionChange" ), aChangeProxyArgs, OUString(), aChangeProxyCode ); - - /* Insert the proxy macros attached to sheet events that notify an ongoing - mouse click event (double click and right click). These events can be - cancelled by returning false (in VBA: as a Boolean output parameter, in - UNO: as return value of the Basic function). The proxy macro converts - the passed UNO cell range or collection of cell ranges to a VBA Range - object, calls the VBA event handler, and returns the Boolean value - provided by the VBA event handler. - */ - OUString aClickProxyArgs = CREATE_OUSTRING( "ByVal unoTarget As Object" ); - OUString aClickProxyRetT = CREATE_OUSTRING( "Boolean" ); - OUString aClickProxyCode = CREATE_OUSTRING( - "\tDim Cancel As Boolean : Cancel = False\n" - "\tDim vbaTarget As Range : Set vbaTarget = " VBA_MACRONAME_TARGETCONV "( unoTarget )\n" - "\tIf Not vbaTarget Is Nothing Then $MACRO vbaTarget, Cancel\n" - "\t$PROXY = Cancel" ); - bNeedsTargetHelper |= attachMacroToEvent( rxEventsSupp, CREATE_OUSTRING( "OnDoubleClick" ), rCodeName, CREATE_OUSTRING( "Worksheet_BeforeDoubleClick" ), aClickProxyArgs, aClickProxyRetT, aClickProxyCode ); - bNeedsTargetHelper |= attachMacroToEvent( rxEventsSupp, CREATE_OUSTRING( "OnRightClick" ), rCodeName, CREATE_OUSTRING( "Worksheet_BeforeRightClick" ), aClickProxyArgs, aClickProxyRetT, aClickProxyCode ); - - if( bNeedsTargetHelper ) - { - /* Generate a helper function that converts a - com.sun.star.sheet.SheetCellRange object to a VBA Range object. - */ - OUString aRangeConvName = CREATE_OUSTRING( VBA_MACRONAME_RANGECONV ); - OUString aRangeConvArgs = CREATE_OUSTRING( "ByVal unoRange As com.sun.star.sheet.SheetCellRange" ); - OUString aRangeConvRetT = CREATE_OUSTRING( "Range" ); - OUString aRangeConvCode = CREATE_OUSTRING( - "\tDim unoAddress As com.sun.star.table.CellRangeAddress : Set unoAddress = unoRange.RangeAddress\n" - "\tDim vbaSheet As Worksheet : Set vbaSheet = Application.ThisWorkbook.Sheets( unoAddress.Sheet + 1 )\n" - "\tSet $MACRO = vbaSheet.Range( vbaSheet.Cells( unoAddress.StartRow + 1, unoAddress.StartColumn + 1 ), vbaSheet.Cells( unoAddress.EndRow + 1, unoAddress.EndColumn + 1 ) )" ); - insertMacro( rCodeName, aRangeConvName, aRangeConvArgs, aRangeConvRetT, aRangeConvCode ); - - /* Generate a helper function that converts a generic range selection - object (com.sun.star.sheet.SheetCellRange or - com.sun.star.sheet.SheetCellRanges) to a VBA Range object. - */ - OUString aTargetConvName = CREATE_OUSTRING( VBA_MACRONAME_TARGETCONV ); - OUString aTargetConvArgs = CREATE_OUSTRING( "ByVal unoTarget As Object" ); - OUString aTargetConvRetT = CREATE_OUSTRING( "Range" ); - OUString aTargetConvCode = CREATE_OUSTRING( - "\tDim vbaTarget As Range\n" - "\tIf unoTarget.supportsService( \"com.sun.star.sheet.SheetCellRange\" ) Then\n" - "\t\tSet vbaTarget = " VBA_MACRONAME_RANGECONV "( unoTarget )\n" - "\tElseIf unoTarget.supportsService( \"com.sun.star.sheet.SheetCellRanges\" ) Then\n" - "\t\tDim unoRangeEnum As Object : Set unoRangeEnum = unoTarget.createEnumeration\n" - "\t\tIf unoRangeEnum.hasMoreElements Then Set vbaTarget = " VBA_MACRONAME_RANGECONV "( unoRangeEnum.nextElement )\n" - "\t\tWhile unoRangeEnum.hasMoreElements\n" - "\t\t\tSet vbaTarget = Application.Union( vbaTarget, " VBA_MACRONAME_RANGECONV "( unoRangeEnum.nextElement ) )\n" - "\t\tWend\n" - "\tEnd If\n" - "\tSet $MACRO = vbaTarget" ); - insertMacro( rCodeName, aTargetConvName, aTargetConvArgs, aTargetConvRetT, aTargetConvCode ); - } -#undef VBA_MACRONAME_RANGECONV -#undef VBA_MACRONAME_TARGETCONV -} - -// ============================================================================ - -} // namespace xls -} // namespace oox diff --git a/oox/source/xls/externallinkfragment.cxx b/oox/source/xls/externallinkfragment.cxx index 15aaf8bc5412..e1bff95ff724 100644 --- a/oox/source/xls/externallinkfragment.cxx +++ b/oox/source/xls/externallinkfragment.cxx @@ -255,7 +255,7 @@ ContextHandlerRef OoxExternalLinkFragment::onCreateContext( sal_Int32 nElement, if( nElement == XLS_TOKEN( oleItem ) ) mxExtName = mrExtLink.importOleItem( rAttribs ); break; } - return false; + return 0; } void OoxExternalLinkFragment::onEndElement( const OUString& rChars ) diff --git a/oox/source/xls/makefile.mk b/oox/source/xls/makefile.mk index b5ede953bbfe..cdb2e18c262d 100644 --- a/oox/source/xls/makefile.mk +++ b/oox/source/xls/makefile.mk @@ -59,7 +59,6 @@ SLOFILES = \ $(SLO)$/excelchartconverter.obj \ $(SLO)$/excelfilter.obj \ $(SLO)$/excelhandlers.obj \ - $(SLO)$/excelvbaproject.obj \ $(SLO)$/externallinkbuffer.obj \ $(SLO)$/externallinkfragment.obj \ $(SLO)$/formulabase.obj \ diff --git a/oox/source/xls/workbookhelper.cxx b/oox/source/xls/workbookhelper.cxx index afeed95accca..5684fbd8ae75 100644 --- a/oox/source/xls/workbookhelper.cxx +++ b/oox/source/xls/workbookhelper.cxx @@ -43,6 +43,7 @@ #include "properties.hxx" #include "oox/helper/progressbar.hxx" #include "oox/helper/propertyset.hxx" +#include "oox/ole/vbaproject.hxx" #include "oox/drawingml/theme.hxx" #include "oox/xls/addressconverter.hxx" #include "oox/xls/biffinputstream.hxx" @@ -50,7 +51,6 @@ #include "oox/xls/defnamesbuffer.hxx" #include "oox/xls/excelchartconverter.hxx" #include "oox/xls/excelfilter.hxx" -#include "oox/xls/excelvbaproject.hxx" #include "oox/xls/externallinkbuffer.hxx" #include "oox/xls/formulaparser.hxx" #include "oox/xls/pagesettings.hxx" @@ -687,14 +687,12 @@ void WorkbookHelper::finalizeWorkbookImport() aDefPageStyle.setProperty< sal_Int16 >( PROP_FirstPageNumber, 0 ); /* Import the VBA project (after finalizing workbook settings which - contains the workbook code name), and attach VBA macros to document and - sheet events. */ + contains the workbook code name). */ StorageRef xVbaPrjStrg = mrBookData.getVbaProjectStorage(); if( xVbaPrjStrg.get() && xVbaPrjStrg->isStorage() ) { - VbaProject aVbaProject( getGlobalFactory(), getDocument() ); + ::oox::ole::VbaProject aVbaProject( getGlobalFactory(), getBaseFilter().getModel(), CREATE_OUSTRING( "Calc" ) ); aVbaProject.importVbaProject( *xVbaPrjStrg, getBaseFilter().getGraphicHelper() ); - aVbaProject.attachToEvents(); } } |