mib17: move VBA specific interfaces into vba subdir

This commit is contained in:
Daniel Rentz 2010-07-27 14:43:33 +02:00
parent bd2d0be5cf
commit 67948f2754
3 changed files with 40 additions and 57 deletions

View file

@ -52,8 +52,8 @@ using namespace com::sun::star::awt;
#include <com/sun/star/script/XLibraryContainer.hpp> #include <com/sun/star/script/XLibraryContainer.hpp>
#include <com/sun/star/script/ModuleInfo.hpp> #include <com/sun/star/script/ModuleInfo.hpp>
#include <com/sun/star/script/ModuleType.hpp> #include <com/sun/star/script/ModuleType.hpp>
#include <com/sun/star/script/XVBAModuleInfo.hpp> #include <com/sun/star/script/vba/XVBACompatibility.hpp>
#include <com/sun/star/script/XVBACompat.hpp> #include <com/sun/star/script/vba/XVBAModuleInfo.hpp>
using namespace com::sun::star::container; using namespace com::sun::star::container;
using namespace com::sun::star::script; using namespace com::sun::star::script;
@ -254,8 +254,8 @@ BOOL SvxImportMSVBasic::ImportCode_Impl( const String& rStorageName,
if( !bAsComment ) try if( !bAsComment ) try
{ {
Reference< XVBACompat > xVBACompat( xLibContainer, UNO_QUERY_THROW ); Reference< vba::XVBACompatibility > xVBACompat( xLibContainer, UNO_QUERY_THROW );
xVBACompat->setVBACompatModeOn( sal_True ); xVBACompat->setVBACompatibilityMode( sal_True );
/* Force creation of the VBAGlobals object, each application will /* Force creation of the VBAGlobals object, each application will
create the right one and store it at the Basic manager. */ create the right one and store it at the Basic manager. */
Reference< XMultiServiceFactory > xFactory( rDocSh.GetModel(), UNO_QUERY_THROW ); Reference< XMultiServiceFactory > xFactory( rDocSh.GetModel(), UNO_QUERY_THROW );
@ -278,7 +278,7 @@ BOOL SvxImportMSVBasic::ImportCode_Impl( const String& rStorageName,
} }
if( xLib.is() ) if( xLib.is() )
{ {
Reference< script::XVBAModuleInfo > xVBAModuleInfo( xLib, UNO_QUERY ); Reference< script::vba::XVBAModuleInfo > xVBAModuleInfo( xLib, UNO_QUERY );
Reference< container::XNameAccess > xVBACodeNamedObjectAccess; Reference< container::XNameAccess > xVBACodeNamedObjectAccess;
if ( !bAsComment ) if ( !bAsComment )
{ {

View file

@ -29,7 +29,7 @@
#include <com/sun/star/container/XNameContainer.hpp> #include <com/sun/star/container/XNameContainer.hpp>
#include <com/sun/star/script/ModuleInfo.hpp> #include <com/sun/star/script/ModuleInfo.hpp>
#include <com/sun/star/script/ModuleType.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/binaryinputstream.hxx"
#include "oox/helper/storagebase.hxx" #include "oox/helper/storagebase.hxx"
#include "oox/helper/textinputstream.hxx" #include "oox/helper/textinputstream.hxx"
@ -38,18 +38,12 @@
using ::rtl::OUString; using ::rtl::OUString;
using ::rtl::OUStringBuffer; 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 oox {
namespace ole { namespace ole {
@ -60,7 +54,7 @@ VbaModule::VbaModule( const Reference< XModel >& rxDocModel, const OUString& rNa
mxDocModel( rxDocModel ), mxDocModel( rxDocModel ),
maName( rName ), maName( rName ),
meTextEnc( eTextEnc ), meTextEnc( eTextEnc ),
mnType( ApiModuleType::UNKNOWN ), mnType( ModuleType::UNKNOWN ),
mnOffset( SAL_MAX_UINT32 ), mnOffset( SAL_MAX_UINT32 ),
mbReadOnly( false ), mbReadOnly( false ),
mbPrivate( false ), mbPrivate( false ),
@ -107,13 +101,13 @@ void VbaModule::importDirRecords( BinaryInputStream& rDirStrm )
break; break;
case VBA_ID_MODULETYPEPROCEDURAL: case VBA_ID_MODULETYPEPROCEDURAL:
OOX_ENSURE_RECORDSIZE( nRecSize == 0 ); OOX_ENSURE_RECORDSIZE( nRecSize == 0 );
OSL_ENSURE( mnType == ApiModuleType::UNKNOWN, "VbaModule::importDirRecords - multiple module type records" ); OSL_ENSURE( mnType == ModuleType::UNKNOWN, "VbaModule::importDirRecords - multiple module type records" );
mnType = ApiModuleType::NORMAL; mnType = ModuleType::NORMAL;
break; break;
case VBA_ID_MODULETYPEDOCUMENT: case VBA_ID_MODULETYPEDOCUMENT:
OOX_ENSURE_RECORDSIZE( nRecSize == 0 ); OOX_ENSURE_RECORDSIZE( nRecSize == 0 );
OSL_ENSURE( mnType == ApiModuleType::UNKNOWN, "VbaModule::importDirRecords - multiple module type records" ); OSL_ENSURE( mnType == ModuleType::UNKNOWN, "VbaModule::importDirRecords - multiple module type records" );
mnType = ApiModuleType::DOCUMENT; mnType = ModuleType::DOCUMENT;
break; break;
case VBA_ID_MODULEREADONLY: case VBA_ID_MODULEREADONLY:
OOX_ENSURE_RECORDSIZE( nRecSize == 0 ); 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( maName.getLength() > 0, "VbaModule::importDirRecords - missing module name" );
OSL_ENSURE( maStreamName.getLength() > 0, "VbaModule::importDirRecords - missing module stream 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" ); 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=" ) ); aSourceCode.appendAscii( RTL_CONSTASCII_STRINGPARAM( "Rem Attribute VBA_ModuleType=" ) );
switch( mnType ) switch( mnType )
{ {
case ApiModuleType::NORMAL: case ModuleType::NORMAL:
aSourceCode.appendAscii( RTL_CONSTASCII_STRINGPARAM( "VBAModule" ) ); aSourceCode.appendAscii( RTL_CONSTASCII_STRINGPARAM( "VBAModule" ) );
break; break;
case ApiModuleType::CLASS: case ModuleType::CLASS:
aSourceCode.appendAscii( RTL_CONSTASCII_STRINGPARAM( "VBAClassModule" ) ); aSourceCode.appendAscii( RTL_CONSTASCII_STRINGPARAM( "VBAClassModule" ) );
break; break;
case ApiModuleType::FORM: case ModuleType::FORM:
aSourceCode.appendAscii( RTL_CONSTASCII_STRINGPARAM( "VBAFormModule" ) ); aSourceCode.appendAscii( RTL_CONSTASCII_STRINGPARAM( "VBAFormModule" ) );
// hack from old filter, document Basic should know the XModel, but it doesn't // hack from old filter, document Basic should know the XModel, but it doesn't
aModuleInfo.ModuleObject.set( mxDocModel, UNO_QUERY ); aModuleInfo.ModuleObject.set( mxDocModel, UNO_QUERY );
break; break;
case ApiModuleType::DOCUMENT: case ModuleType::DOCUMENT:
aSourceCode.appendAscii( RTL_CONSTASCII_STRINGPARAM( "VBADocumentModule" ) ); aSourceCode.appendAscii( RTL_CONSTASCII_STRINGPARAM( "VBADocumentModule" ) );
// get the VBA object associated to the document module // get the VBA object associated to the document module
if( rxDocObjectNA.is() ) try if( rxDocObjectNA.is() ) try
@ -184,7 +178,7 @@ void VbaModule::importSourceCode( StorageBase& rVbaStrg,
if( mbExecutable ) if( mbExecutable )
{ {
aSourceCode.appendAscii( RTL_CONSTASCII_STRINGPARAM( "Option VBASupport 1\n" ) ); 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" ) ); aSourceCode.appendAscii( RTL_CONSTASCII_STRINGPARAM( "Option ClassModule\n" ) );
} }
else else

View file

@ -26,14 +26,13 @@
************************************************************************/ ************************************************************************/
#include "oox/ole/vbaproject.hxx" #include "oox/ole/vbaproject.hxx"
#include <com/sun/star/document/XEventsSupplier.hpp>
#include <com/sun/star/document/XStorageBasedDocument.hpp> #include <com/sun/star/document/XStorageBasedDocument.hpp>
#include <com/sun/star/embed/ElementModes.hpp> #include <com/sun/star/embed/ElementModes.hpp>
#include <com/sun/star/embed/XTransactedObject.hpp> #include <com/sun/star/embed/XTransactedObject.hpp>
#include <com/sun/star/lang/XMultiServiceFactory.hpp> #include <com/sun/star/lang/XMultiServiceFactory.hpp>
#include <com/sun/star/script/ModuleType.hpp> #include <com/sun/star/script/ModuleType.hpp>
#include <com/sun/star/script/XLibraryContainer.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/tencinfo.h>
#include <rtl/ustrbuf.h> #include <rtl/ustrbuf.h>
#include <comphelper/configurationhelper.hxx> #include <comphelper/configurationhelper.hxx>
@ -52,27 +51,17 @@
using ::rtl::OUString; using ::rtl::OUString;
using ::rtl::OUStringBuffer; 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; 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 oox {
namespace ole { namespace ole {
@ -330,23 +319,23 @@ void VbaProject::importVba( StorageBase& rVbaPrjStrg, const GraphicHelper& rGrap
bExitLoop = (nLineLen >= 2) && (aLine[ 0 ] == '[') && (aLine[ nLineLen - 1 ] == ']'); bExitLoop = (nLineLen >= 2) && (aLine[ 0 ] == '[') && (aLine[ nLineLen - 1 ] == ']');
if( !bExitLoop && VbaHelper::extractKeyValue( aKey, aValue, aLine ) ) if( !bExitLoop && VbaHelper::extractKeyValue( aKey, aValue, aLine ) )
{ {
sal_Int32 nType = ApiModuleType::UNKNOWN; sal_Int32 nType = ModuleType::UNKNOWN;
if( aKey.equalsIgnoreAsciiCaseAsciiL( RTL_CONSTASCII_STRINGPARAM( "Document" ) ) ) if( aKey.equalsIgnoreAsciiCaseAsciiL( RTL_CONSTASCII_STRINGPARAM( "Document" ) ) )
{ {
nType = ApiModuleType::DOCUMENT; nType = ModuleType::DOCUMENT;
// strip automation server version from module names // strip automation server version from module names
sal_Int32 nSlashPos = aValue.indexOf( '/' ); sal_Int32 nSlashPos = aValue.indexOf( '/' );
if( nSlashPos >= 0 ) if( nSlashPos >= 0 )
aValue = aValue.copy( 0, nSlashPos ); aValue = aValue.copy( 0, nSlashPos );
} }
else if( aKey.equalsIgnoreAsciiCaseAsciiL( RTL_CONSTASCII_STRINGPARAM( "Module" ) ) ) else if( aKey.equalsIgnoreAsciiCaseAsciiL( RTL_CONSTASCII_STRINGPARAM( "Module" ) ) )
nType = ApiModuleType::NORMAL; nType = ModuleType::NORMAL;
else if( aKey.equalsIgnoreAsciiCaseAsciiL( RTL_CONSTASCII_STRINGPARAM( "Class" ) ) ) else if( aKey.equalsIgnoreAsciiCaseAsciiL( RTL_CONSTASCII_STRINGPARAM( "Class" ) ) )
nType = ApiModuleType::CLASS; nType = ModuleType::CLASS;
else if( aKey.equalsIgnoreAsciiCaseAsciiL( RTL_CONSTASCII_STRINGPARAM( "BaseClass" ) ) ) 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" ); OSL_ENSURE( aModules.has( aValue ), "VbaProject::importVba - module not found" );
if( VbaModule* pModule = aModules.get( aValue ).get() ) if( VbaModule* pModule = aModules.get( aValue ).get() )
@ -369,7 +358,7 @@ void VbaProject::importVba( StorageBase& rVbaPrjStrg, const GraphicHelper& rGrap
// set library container to VBA compatibility mode // set library container to VBA compatibility mode
try 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& ) catch( Exception& )
{ {
@ -420,7 +409,7 @@ void VbaProject::importVba( StorageBase& rVbaPrjStrg, const GraphicHelper& rGrap
{ {
// resolve module name from storage name (which equals the module stream name) // resolve module name from storage name (which equals the module stream name)
VbaModule* pModule = aModulesByStrm.get( *aIt ).get(); 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" ); "VbaProject::importVba - form substorage without form module" );
OUString aModuleName; OUString aModuleName;
if( pModule ) if( pModule )