summaryrefslogtreecommitdiff
path: root/sc/source/ui/vba/vbaworkbooks.cxx
diff options
context:
space:
mode:
Diffstat (limited to 'sc/source/ui/vba/vbaworkbooks.cxx')
-rw-r--r--sc/source/ui/vba/vbaworkbooks.cxx82
1 files changed, 1 insertions, 81 deletions
diff --git a/sc/source/ui/vba/vbaworkbooks.cxx b/sc/source/ui/vba/vbaworkbooks.cxx
index 86b24c3dec92..39f6f66db091 100644
--- a/sc/source/ui/vba/vbaworkbooks.cxx
+++ b/sc/source/ui/vba/vbaworkbooks.cxx
@@ -70,86 +70,6 @@ using namespace ::com::sun::star;
const sal_Int16 CUSTOM_CHAR = 5;
-void setUpDocumentModules( const uno::Reference< sheet::XSpreadsheetDocument >& xDoc )
-{
- uno::Reference< frame::XModel > xModel( xDoc, uno::UNO_QUERY );
- ScDocShell* pShell = excel::getDocShell( xModel );
- if ( pShell )
- {
- String aPrjName( RTL_CONSTASCII_USTRINGPARAM( "Standard" ) );
- pShell->GetBasicManager()->SetName( aPrjName );
-
- /* Set library container to VBA compatibility mode. This will create
- the VBA Globals object and store it in the Basic manager of the
- document. */
- uno::Reference<script::XLibraryContainer> xLibContainer = pShell->GetBasicContainer();
- uno::Reference<script::vba::XVBACompatibility> xVBACompat( xLibContainer, uno::UNO_QUERY_THROW );
- xVBACompat->setVBACompatibilityMode( sal_True );
-
- if( xLibContainer.is() )
- {
- if( !xLibContainer->hasByName( aPrjName ) )
- xLibContainer->createLibrary( aPrjName );
- uno::Any aLibAny = xLibContainer->getByName( aPrjName );
- uno::Reference< container::XNameContainer > xLib;
- aLibAny >>= xLib;
- if( xLib.is() )
- {
- uno::Reference< script::vba::XVBAModuleInfo > xVBAModuleInfo( xLib, uno::UNO_QUERY_THROW );
- uno::Reference< lang::XMultiServiceFactory> xSF( pShell->GetModel(), uno::UNO_QUERY_THROW);
- uno::Reference< container::XNameAccess > xVBACodeNamedObjectAccess( xSF->createInstance( rtl::OUString(RTL_CONSTASCII_USTRINGPARAM( "ooo.vba.VBAObjectModuleObjectProvider"))), uno::UNO_QUERY_THROW );
- // set up the module info for the workbook and sheets in the nealy created
- // spreadsheet
- ScDocument* pDoc = pShell->GetDocument();
- String sCodeName = pDoc->GetCodeName();
- if ( sCodeName.Len() == 0 )
- {
- sCodeName = String( RTL_CONSTASCII_USTRINGPARAM("ThisWorkbook") );
- pDoc->SetCodeName( sCodeName );
- }
-
- std::vector< rtl::OUString > sDocModuleNames;
- sDocModuleNames.push_back( sCodeName );
-
- uno::Reference<container::XNameAccess > xSheets( xDoc->getSheets(), uno::UNO_QUERY_THROW );
- uno::Sequence< rtl::OUString > sSheets( xSheets->getElementNames() );
-
- for ( sal_Int32 index=0; index < sSheets.getLength() ; ++index )
- {
- sDocModuleNames.push_back( sSheets[ index ] );
- }
-
- std::vector<rtl::OUString>::iterator it_end = sDocModuleNames.end();
-
- for ( std::vector<rtl::OUString>::iterator it = sDocModuleNames.begin(); it != it_end; ++it )
- {
- script::ModuleInfo sModuleInfo;
-
- sModuleInfo.ModuleObject.set( xVBACodeNamedObjectAccess->getByName( *it ), uno::UNO_QUERY );
- sModuleInfo.ModuleType = script::ModuleType::DOCUMENT;
- xVBAModuleInfo->insertModuleInfo( *it, sModuleInfo );
- if( xLib->hasByName( *it ) )
- xLib->replaceByName( *it, uno::makeAny( rtl::OUString(RTL_CONSTASCII_USTRINGPARAM( "Option VBASupport 1\n") ) ) );
- else
- xLib->insertByName( *it, uno::makeAny( rtl::OUString(RTL_CONSTASCII_USTRINGPARAM( "Option VBASupport 1\n" ) ) ) );
- }
- }
- }
-
- /* Trigger the Workbook_Open event, event processor will register
- itself as listener for specific events. */
- try
- {
- uno::Reference< script::vba::XVBAEventProcessor > xVbaEvents( pShell->GetDocument()->GetVbaEventProcessor(), uno::UNO_SET_THROW );
- uno::Sequence< uno::Any > aArgs;
- xVbaEvents->processVbaEvent( script::vba::VBAEventId::WORKBOOK_OPEN, aArgs );
- }
- catch( uno::Exception& )
- {
- }
- }
-}
-
static uno::Any
getWorkbook( uno::Reference< uno::XComponentContext >& xContext, const uno::Reference< sheet::XSpreadsheetDocument > &xDoc, const uno::Reference< XHelperInterface >& xParent )
{
@@ -254,7 +174,7 @@ ScVbaWorkbooks::Add( const uno::Any& Template ) throw (uno::RuntimeException)
}
// need to set up the document modules ( and vba mode ) here
- setUpDocumentModules( xSpreadDoc );
+ excel::setUpDocumentModules( xSpreadDoc );
if( xSpreadDoc.is() )
return getWorkbook( mxContext, xSpreadDoc, mxParent );
return uno::Any();