summaryrefslogtreecommitdiff
path: root/oox/source/ole
diff options
context:
space:
mode:
Diffstat (limited to 'oox/source/ole')
-rwxr-xr-xoox/source/ole/vbacontrol.cxx28
-rwxr-xr-xoox/source/ole/vbahelper.cxx171
-rwxr-xr-xoox/source/ole/vbamodule.cxx42
-rwxr-xr-xoox/source/ole/vbaproject.cxx124
4 files changed, 77 insertions, 288 deletions
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 )