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/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;
@ -254,8 +254,8 @@ BOOL SvxImportMSVBasic::ImportCode_Impl( const String& rStorageName,
if( !bAsComment ) try
{
Reference< XVBACompat > xVBACompat( xLibContainer, UNO_QUERY_THROW );
xVBACompat->setVBACompatModeOn( sal_True );
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 );
@ -278,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 )
{

View file

@ -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

View file

@ -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 {
@ -330,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() )
@ -369,7 +358,7 @@ void VbaProject::importVba( StorageBase& rVbaPrjStrg, const GraphicHelper& rGrap
// 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& )
{
@ -420,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 )