ooo-build r14185 - trunk/patches/vba



Author: noelpwer
Date: Thu Oct  2 10:47:29 2008
New Revision: 14185
URL: http://svn.gnome.org/viewvc/ooo-build?rev=14185&view=rev

Log:
native import/export of object/form modules ( updated to m7 )


Modified:
   trunk/patches/vba/vbainfo-import-export-support.diff

Modified: trunk/patches/vba/vbainfo-import-export-support.diff
==============================================================================
--- trunk/patches/vba/vbainfo-import-export-support.diff	(original)
+++ trunk/patches/vba/vbainfo-import-export-support.diff	Thu Oct  2 10:47:29 2008
@@ -1,26 +1,3 @@
-diff --git basctl/source/basicide/scriptdocument.cxx basctl/source/basicide/scriptdocument.cxx
-index 645c396..7e48d82 100644
---- basctl/source/basicide/scriptdocument.cxx
-+++ basctl/source/basicide/scriptdocument.cxx
-@@ -749,8 +749,16 @@ namespace basctl
-             Reference< XNameContainer > xLib( getOrCreateLibrary( E_SCRIPTS, _rLibName ), UNO_QUERY_THROW );
- 	        if ( !xLib->hasByName( _rModName ) )
-                 return false;
--
--            xLib->replaceByName( _rModName, makeAny( _rModuleCode ) );
-+            ModuleInfo mInfo;
-+            Any aMod;
-+            if ( xLib->getByName( _rModName ) >>= mInfo )
-+            {
-+                mInfo.ModuleSource = _rModuleCode;
-+                aMod <<= mInfo;
-+            }
-+            else
-+                aMod <<= _rModuleCode;
-+            xLib->replaceByName( _rModName, aMod );
-             return true;
-         }
-         catch( const Exception& )
 diff --git basic/inc/basic/basmgr.hxx basic/inc/basic/basmgr.hxx
 index 2674c59..3c4f364 100644
 --- basic/inc/basic/basmgr.hxx
@@ -46,31 +23,11 @@
  	{}
  };
  
-diff --git basic/inc/basic/sbobjmod.hxx basic/inc/basic/sbobjmod.hxx
-index eeb7869..96cbe9b 100644
---- basic/inc/basic/sbobjmod.hxx
-+++ basic/inc/basic/sbobjmod.hxx
-@@ -56,6 +56,7 @@ public:
-     SbObjModule( const com::sun::star::script::ModuleInfo& mInfo, bool bIsVbaCompatible );
-     virtual SbxVariable* Find( const XubString& rName, SbxClassType t );
-     SbxVariable* GetObject();
-+    void SetUnoObject( const com::sun::star::uno::Any& aObj )throw ( com::sun::star::uno::RuntimeException ) ;
- };
- 
- class SbUserFormModule : public SbObjModule
 diff --git basic/source/basmgr/basmgr.cxx basic/source/basmgr/basmgr.cxx
-index 4ac2e48..0a4ca77 100644
+index 1c8962c..0a4ca77 100644
 --- basic/source/basmgr/basmgr.cxx
 +++ basic/source/basmgr/basmgr.cxx
-@@ -44,6 +44,7 @@
- #include <tools/debug.hxx>
- #include <tools/diagnose_ex.h>
- #include <basic/sbmod.hxx>
-+#include <basic/sbobjmod.hxx>
- 
- #include <basic/sbuno.hxx>
- #include <basic/basmgr.hxx>
-@@ -60,6 +61,7 @@
+@@ -61,6 +61,7 @@
  
  // Library API, implemented for XML import/export
  
@@ -78,7 +35,7 @@
  #include <com/sun/star/container/XNameContainer.hpp>
  #include <com/sun/star/container/XContainer.hpp>
  #include <com/sun/star/script/XStarBasicAccess.hpp>
-@@ -290,6 +292,12 @@ void SAL_CALL BasMgrContainerListenerImp
+@@ -291,6 +292,12 @@ void SAL_CALL BasMgrContainerListenerImpl::elementInserted( const ContainerEvent
  	{
          Reference< XLibraryContainer > xScriptCont( Event.Source, UNO_QUERY );
  		insertLibraryImpl( xScriptCont, mpMgr, Event.Element, aName );
@@ -91,58 +48,7 @@
  	}
  	else
  	{
-@@ -335,25 +343,35 @@ void SAL_CALL BasMgrContainerListenerImp
-     DBG_ASSERT( !bLibContainer, "library container fired elementReplaced()");
- 
- 	StarBASIC* pLib = mpMgr->GetLib( maLibName );
-+    
- 	if( pLib )
- 	{
--         ModuleInfo mInfo;
-+	    SbModule* pMod = pLib->FindModule( aName );
-+		::rtl::OUString aMod;
-+        ModuleInfo mInfo;
-         if( Event.Element >>= mInfo )
--        {
--            OSL_TRACE("#elementReplaced Mod");
--            pLib->MakeModule32( mInfo );
--        }
--        else
--        {
--		    SbModule* pMod = pLib->FindModule( aName );
--
--		    ::rtl::OUString aMod;
-+			aMod = mInfo.ModuleSource;
-+        else 
-             Event.Element >>= aMod;
--		    if( pMod )
--		   	    pMod->SetSource32( aMod );
--            else
--			    pLib->MakeModule32( aName, aMod );
--        }
-+		if( pMod )
-+		{
-+			pMod->SetSource32( aMod );
-+			if ( mInfo.ModuleType == ModuleType::Document )
-+			{
-+				SbObjModule* pObjModule = dynamic_cast< SbObjModule* >( pMod );
-+				if ( pObjModule )	
-+					pObjModule->SetUnoObject( makeAny( mInfo.ModuleObject ) );
-+			}
-+		}
-+        else
-+			// Probably we should have an assert for
-+			// unknow module type, e.g. either we are using
-+			// the ModuleInfo structure ( vba ) for *all* modules
-+			// or not ( normal )
-+			if ( mInfo.ModuleType == ModuleType::Unknown )
-+				pLib->MakeModule32( aName, aMod );
-+			else
-+				pLib->MakeModule32( mInfo );
- 
- 		pLib->SetModified( FALSE );
- 	}
-@@ -820,6 +838,12 @@ void BasicManager::SetLibraryContainerIn
+@@ -831,6 +838,12 @@ void BasicManager::SetLibraryContainerInfo( const LibraryContainerInfo& rInfo )
  
  	Reference< XLibraryContainer > xScriptCont( mpImpl->maContainerInfo.mxScriptCont.get() );
  	StarBASIC* pStdLib = GetStdLib();
@@ -155,91 +61,11 @@
  	String aLibName = pStdLib->GetName();
  	if( xScriptCont.is() )
  	{
-diff --git basic/source/classes/sbxmod.cxx basic/source/classes/sbxmod.cxx
-index bfb0cf6..fc164e6 100644
---- basic/source/classes/sbxmod.cxx
-+++ basic/source/classes/sbxmod.cxx
-@@ -2233,25 +2233,26 @@ SbObjModule::SbObjModule( const com::sun
-     if ( mInfo.ModuleType == script::ModuleType::Form )
-     {
-         SetClassName( rtl::OUString::createFromAscii( "Form" ) );
--        return;
-     }
--    try
-+    else if ( mInfo.ModuleObject.is() )
-+        SetUnoObject( uno::makeAny( mInfo.ModuleObject ) );   
-+}
-+void
-+SbObjModule::SetUnoObject( const uno::Any& aObj ) throw ( uno::RuntimeException )
-+{
-+    SbUnoObject* pUnoObj = PTR_CAST(SbUnoObject,(SbxVariable*)pDocObject);
-+    if ( pUnoObj && pUnoObj->getUnoAny() == aObj ) // object is equal, nothing to do
-+        return;
-+    pDocObject = new SbUnoObject( GetName(), uno::makeAny( aObj ) );
-+            
-+    com::sun::star::uno::Reference< com::sun::star::lang::XServiceInfo > xServiceInfo( aObj, com::sun::star::uno::UNO_QUERY_THROW );
-+    if( xServiceInfo->supportsService( rtl::OUString::createFromAscii( "org.openoffice.excel.Worksheet" ) ) )
-     {
--        com::sun::star::uno::Any aObject( mInfo.ModuleObject );
--        pDocObject = new SbUnoObject( GetName(), aObject );
--        com::sun::star::uno::Reference< com::sun::star::lang::XServiceInfo > xServiceInfo( aObject, com::sun::star::uno::UNO_QUERY_THROW );
--        if( xServiceInfo->supportsService( rtl::OUString::createFromAscii( "org.openoffice.excel.Worksheet" ) ) )
--        {
--            SetClassName( rtl::OUString::createFromAscii( "Worksheet" ) );
--        }
--        else if( xServiceInfo->supportsService( rtl::OUString::createFromAscii( "org.openoffice.excel.Workbook" ) ) )
--        {
--            SetClassName( rtl::OUString::createFromAscii( "Workbook" ) );
--        }
-+        SetClassName( rtl::OUString::createFromAscii( "Worksheet" ) );
-     }
--    catch( com::sun::star::uno::RuntimeException e )
-+    else if( xServiceInfo->supportsService( rtl::OUString::createFromAscii( "org.openoffice.excel.Workbook" ) ) )
-     {
--        OSL_TRACE("***** Failed to initialise API Object." );
-+        SetClassName( rtl::OUString::createFromAscii( "Workbook" ) );
-     }
- }
- 
-@@ -2286,7 +2287,7 @@ class FormObjEventListenerImpl : public 
- public:
-     FormObjEventListenerImpl( SbUserFormModule* pUserForm, const uno::Reference< lang::XComponent >& xComponent ) : mpUserForm( pUserForm ), mxComponent( xComponent) , mbDisposed( false ), mbOpened( sal_False ), mbActivated( sal_False )
-     {
--        if ( mxComponent.is() );
-+        if ( mxComponent.is() )
-         {
- 	    uno::Reference< awt::XTopWindow > xList( mxComponent, uno::UNO_QUERY_THROW );;
-             //uno::Reference< awt::XWindow > xList( mxComponent, uno::UNO_QUERY_THROW );;
 diff --git basic/source/inc/namecont.hxx basic/source/inc/namecont.hxx
-index 3572d95..67d95bb 100644
+index c099b01..7a99f86 100644
 --- basic/source/inc/namecont.hxx
 +++ basic/source/inc/namecont.hxx
-@@ -63,20 +63,23 @@
- #include <cppuhelper/implbase2.hxx>
- #include <cppuhelper/compbase6.hxx>
- #include <cppuhelper/compbase7.hxx>
-+#include <cppuhelper/compbase8.hxx>
- #include <cppuhelper/interfacecontainer.hxx>
-+#include <com/sun/star/script/XVBACompat.hpp>
- 
- class BasicManager;
- 
- namespace basic
- {
- 
--typedef ::cppu::WeakComponentImplHelper7< 
-+typedef ::cppu::WeakComponentImplHelper8< 
-     ::com::sun::star::lang::XInitialization,
-     ::com::sun::star::script::XStorageBasedLibraryContainer,
-     ::com::sun::star::script::XLibraryContainerPassword,
-     ::com::sun::star::script::XLibraryContainerExport,
-     ::com::sun::star::container::XContainer,
-     ::com::sun::star::script::XLibraryQueryExecutable,
-+    ::com::sun::star::script::XVBACompat,
-     ::com::sun::star::lang::XServiceInfo > LibraryContainerHelper;
- 
- typedef ::cppu::WeakImplHelper2< ::com::sun::star::container::XNameContainer,
-@@ -110,6 +113,11 @@ NameContainerNameMap;
+@@ -113,6 +113,11 @@ NameContainerNameMap;
  
  
  //============================================================================
@@ -251,7 +77,7 @@
  
  class NameContainer : public ::cppu::BaseMutex, public NameContainerHelper
  {
-@@ -133,7 +141,7 @@ public:
+@@ -136,7 +141,7 @@ public:
  
  	void setEventSource( ::com::sun::star::uno::XInterface* pxEventSource )
  		{ mpxEventSource = pxEventSource; }
@@ -260,7 +86,7 @@
      // Methods XElementAccess
      virtual ::com::sun::star::uno::Type SAL_CALL getElementType(  ) 
  		throw(::com::sun::star::uno::RuntimeException);
-@@ -248,7 +256,7 @@ protected:
+@@ -251,7 +256,7 @@ protected:
  	sal_Bool        mbOwnBasMgr;
  
      InitMode meInitMode;
@@ -269,7 +95,7 @@
  	void implStoreLibrary( SfxLibrary* pLib,
  							const ::rtl::OUString& aName,
  							const ::com::sun::star::uno::Reference< ::com::sun::star::embed::XStorage >& xStorage );
-@@ -331,7 +339,7 @@ protected:
+@@ -334,7 +339,7 @@ protected:
      virtual const sal_Char* SAL_CALL    getOldInfoFileName() const = 0;
      virtual const sal_Char* SAL_CALL    getLibElementFileExtension() const = 0;
      virtual const sal_Char* SAL_CALL    getLibrariesDir() const = 0;
@@ -278,17 +104,7 @@
      // Handle maLibInfoFileURL and maStorageURL correctly
      void checkStorageURL
      (
-@@ -499,6 +507,9 @@ public:
-         throw (::com::sun::star::uno::RuntimeException);
-     virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL getSupportedServiceNames( )
-         throw (::com::sun::star::uno::RuntimeException) = 0;
-+    // Methods XVBACompat
-+    virtual ::sal_Bool SAL_CALL getVBACompatModeOn() throw (::com::sun::star::uno::RuntimeException);
-+    virtual void SAL_CALL setVBACompatModeOn( ::sal_Bool _vbacompatmodeon ) throw (::com::sun::star::uno::RuntimeException);
- };
- 
- class LibraryContainerMethodGuard
-@@ -560,6 +571,7 @@ private:
+@@ -567,6 +572,7 @@ private:
  	sal_Bool mbSharedIndexFile;
  	sal_Bool mbExtension;
  
@@ -296,7 +112,7 @@
  	// Additional functionality for localisation
  	// Provide modify state including resources
  	virtual sal_Bool isModified( void ) = 0;
-@@ -653,6 +665,7 @@ public:
+@@ -660,6 +666,7 @@ public:
  	virtual void SAL_CALL removeContainerListener( const ::com::sun::star::uno::Reference< 
  		::com::sun::star::container::XContainerListener >& xListener ) 
  			throw (::com::sun::star::uno::RuntimeException);
@@ -308,7 +124,7 @@
 index 1679b30..b9d3415 100644
 --- basic/source/inc/scriptcont.hxx
 +++ basic/source/inc/scriptcont.hxx
-@@ -97,6 +97,7 @@ class SfxScriptLibraryContainer : public
+@@ -97,6 +97,7 @@ class SfxScriptLibraryContainer : public SfxLibraryContainer, public OldBasicPas
      virtual const sal_Char* SAL_CALL    getOldInfoFileName() const;
      virtual const sal_Char* SAL_CALL    getLibElementFileExtension() const;
      virtual const sal_Char* SAL_CALL    getLibrariesDir() const;
@@ -346,7 +162,7 @@
  
  #include <com/sun/star/container/XIndexAccess.hpp>
  #include <com/sun/star/script/XDefaultMethod.hpp>
-@@ -708,7 +709,6 @@ void SbiRuntime::StepELEM( UINT32 nOp1, 
+@@ -708,7 +709,6 @@ void SbiRuntime::StepELEM( UINT32 nOp1, UINT32 nOp2 )
  	// #74254 Jetzt per Liste
  	if( pObj )
  		SaveRef( (SbxVariable*)pObj );
@@ -355,16 +171,10 @@
  }
  
 diff --git basic/source/uno/namecont.cxx basic/source/uno/namecont.cxx
-index da495ca..a369363 100644
+index ac96039..52efd0c 100644
 --- basic/source/uno/namecont.cxx
 +++ basic/source/uno/namecont.cxx
-@@ -1,4 +1,5 @@
- /*************************************************************************
-+			rLib.hModuleTypeDesc = 
-  *
-  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
-  * 
-@@ -75,6 +76,7 @@
+@@ -75,6 +75,7 @@
  #endif
  #include <cppuhelper/exc_hlp.hxx>
  #include <basic/sbmod.hxx>
@@ -372,7 +182,7 @@
  
  #ifndef _COM_SUN_STAR_SCRIPT_MODULEINFO_HPP_
  #include <com/sun/star/script/ModuleInfo.hpp>
-@@ -104,12 +106,85 @@ using namespace osl;
+@@ -104,12 +105,85 @@ using namespace osl;
  
  using com::sun::star::uno::Reference;
  
@@ -458,7 +268,7 @@
  // Methods XElementAccess
  Type NameContainer::getElementType()
  	throw(RuntimeException)
-@@ -158,7 +233,7 @@ void NameContainer::replaceByName( const
+@@ -158,7 +232,7 @@ void NameContainer::replaceByName( const OUString& aName, const Any& aElement )
  	throw(IllegalArgumentException, NoSuchElementException, WrappedTargetException, RuntimeException)
  {
  	Type aAnyType = aElement.getValueType();
@@ -467,7 +277,7 @@
  		throw IllegalArgumentException();
  
  	NameContainerNameMap::iterator aIt = mHashMap.find( aName );
-@@ -200,7 +275,7 @@ void NameContainer::insertByName( const 
+@@ -200,7 +274,7 @@ void NameContainer::insertByName( const OUString& aName, const Any& aElement )
  	throw(IllegalArgumentException, ElementExistException, WrappedTargetException, RuntimeException)
  {
  	Type aAnyType = aElement.getValueType();
@@ -476,38 +286,7 @@
  		throw IllegalArgumentException();
  
  	NameContainerNameMap::iterator aIt = mHashMap.find( aName );
-@@ -330,6 +405,30 @@ void ModifiableHelper::setModified( sal_
- // Implementation class SfxLibraryContainer
- DBG_NAME( SfxLibraryContainer )
- 
-+::sal_Bool SAL_CALL 
-+SfxLibraryContainer::getVBACompatModeOn() throw (RuntimeException)
-+{
-+    return mbVBACompatModeOn;
-+}
-+void SAL_CALL 
-+SfxLibraryContainer::setVBACompatModeOn( ::sal_Bool _vbacompatmodeon ) throw (RuntimeException)
-+{
-+    // will need to trigger event so that basicmanager can get it	
-+    bool bNeedsConversion = ( mbVBACompatModeOn != _vbacompatmodeon );
-+    mbVBACompatModeOn =  ( _vbacompatmodeon == sal_True );
-+    // for Dialogs 'convertLibraryEntries' does nothing ( for now ) 
-+    // for Scripts the Library's NameContainer needs to be converted as follows
-+    // When vba mode is turned off
-+    // Userform and Document modules need to be deleted
-+    //    String -> Any( ModuleInfo ) to
-+    //    String -> Any( String ) 
-+    // When vba mode is turned on
-+    //    String -> Any( String )  to
-+    //    String -> Any( ModuleInfo )
-+    // Userform and Document modules need to be created
-+    if ( bNeedsConversion )
-+        convertLibraryEntries(); // for Dialogs this does nothing ( for now ) 
-+}
- // Ctor
- SfxLibraryContainer::SfxLibraryContainer( void )
- 	: LibraryContainerHelper( maMutex )
-@@ -339,6 +438,7 @@ SfxLibraryContainer::SfxLibraryContainer
+@@ -339,6 +413,7 @@ SfxLibraryContainer::SfxLibraryContainer( void )
      , mbOasis2OOoFormat( sal_False )
      , mpBasMgr( NULL )
      , mbOwnBasMgr( sal_False )
@@ -515,7 +294,7 @@
  {
      DBG_CTOR( SfxLibraryContainer, NULL );
  
-@@ -798,11 +898,20 @@ sal_Bool SfxLibraryContainer::init_Impl(
+@@ -798,11 +873,23 @@ sal_Bool SfxLibraryContainer::init_Impl(
                  OSL_ENSURE( 0, OUStringToOString( e.Message, RTL_TEXTENCODING_ASCII_US ).getStr() );
                  return sal_False;
              }
@@ -532,12 +311,15 @@
 +		if ( rLib.aName.equalsAscii("Standard") )
 +		{
 +			OSL_TRACE("*** iteration %d have got Standard Library**** VBA MODE is %d", i, rLib.bVBAMode );
-+           		    	mbVBACompatModeOn = rLib.bVBAMode;
++						// can't use the api here ( because setVBACompat will try to 
++						// convert the Libraries )
++           		    	//SfxLibraryContainer::setVBACompatModeOn( rLib.bVBAMode );
++						mbVBACompatModeOn = rLib.bVBAMode;
 +		}
  
  			    // Check storage URL
  			    OUString aStorageURL = rLib.aStorageURL;
-@@ -897,7 +1006,9 @@ sal_Bool SfxLibraryContainer::init_Impl(
+@@ -897,7 +984,9 @@ sal_Bool SfxLibraryContainer::init_Impl(
  				    if( !pImplLib->mbInitialised && (!bStorage || xLibraryStor.is()) )
  				    {
  					    OUString aIndexFileName;
@@ -547,15 +329,15 @@
  					    if( bLoaded && aLibName != rLib.aName )
  					    {
  						    OSL_ENSURE( 0, "Different library names in library"
-@@ -1140,6 +1251,7 @@ sal_Bool SfxLibraryContainer::init_Impl(
+@@ -1135,6 +1224,7 @@ sal_Bool SfxLibraryContainer::init_Impl(
  						Reference< XNameContainer > xLib = createLibrary( aLibName );
-                			SfxLibrary* pNewLib = static_cast< SfxLibrary* >( xLib.get() );
+            				SfxLibrary* pNewLib = static_cast< SfxLibrary* >( xLib.get() );
  						pNewLib->mbLoaded = false;
 +
  						pNewLib->implSetModified( sal_False );
  						checkStorageURL( aLibFolder, pNewLib->maLibInfoFileURL,
  							pNewLib->maStorageURL, pNewLib->maUnexpandedStorageURL );
-@@ -1690,21 +1802,60 @@ void SfxLibraryContainer::implImportLibD
+@@ -1724,21 +1814,60 @@ void SfxLibraryContainer::implImportLibDescriptor
      {
  	    sal_Int32 nElementCount = rLib.aElementNames.getLength();
  	    const OUString* pElementNames = rLib.aElementNames.getConstArray();
@@ -619,7 +401,7 @@
  // Methods of new XLibraryStorage interface?
  void SfxLibraryContainer::storeLibraries_Impl( const uno::Reference< embed::XStorage >& xStorage, sal_Bool bComplete )
  {
-@@ -1813,7 +1964,18 @@ void SfxLibraryContainer::storeLibraries
+@@ -1851,7 +1980,18 @@ void SfxLibraryContainer::storeLibraries_Impl( const uno::Reference< embed::XSto
  		rLib.bPreload = pImplLib->mbPreload;
  		rLib.bPasswordProtected = pImplLib->mbPasswordProtected;
  		rLib.aElementNames = pImplLib->getElementNames();
@@ -639,7 +421,7 @@
  		if( pImplLib->implIsModified() || bComplete )
  		{
              // Can we copy the storage?
-@@ -2277,13 +2439,29 @@ void SAL_CALL SfxLibraryContainer::loadL
+@@ -2319,13 +2459,29 @@ void SAL_CALL SfxLibraryContainer::loadLibrary( const OUString& Name )
  			}
  
  			Any aAny = importLibraryElement( aFile, xInStream );
@@ -669,7 +451,55 @@
  				pImplLib->maNameContainer.insertByName( aElementName, aAny );
              }
  		}
-@@ -2694,6 +2872,12 @@ OUString SfxLibraryContainer::expand_url
+@@ -2725,31 +2881,26 @@ OUString SfxLibraryContainer::expand_url( const OUString& url )
+ 
+ ::sal_Bool SAL_CALL SfxLibraryContainer::getVBACompatModeOn() throw (RuntimeException)
+ {
+-	sal_Bool bVBACompat = sal_False;
+-	BasicManager* pBasMgr = getBasicManager();
+-	if( pBasMgr )
+-	{
+-		// get the standard library
+-		String aLibName( RTL_CONSTASCII_USTRINGPARAM( "Standard" ) );
+-		StarBASIC* pBasic = pBasMgr->GetLib( aLibName );
+-		if( pBasic )
+-			bVBACompat = pBasic->isVBAEnabled();
+-	}
+-
+-	return bVBACompat;
++	return mbVBACompatModeOn;
+ }
+ 
+ void SAL_CALL SfxLibraryContainer::setVBACompatModeOn( ::sal_Bool _vbacompatmodeon ) throw (RuntimeException)
+ {
+-	BasicManager* pBasMgr = getBasicManager();
+-	if( pBasMgr )
+-	{
+-		// get the standard library
+-		String aLibName( RTL_CONSTASCII_USTRINGPARAM( "Standard" ) );
+-		StarBASIC* pBasic = pBasMgr->GetLib( aLibName );
+-		if( pBasic )
+-			pBasic->SetVBAEnabled( _vbacompatmodeon );
+-	}
++    // will need to trigger event so that basicmanager can get it	
++    bool bNeedsConversion = ( mbVBACompatModeOn != _vbacompatmodeon );
++    mbVBACompatModeOn =  ( _vbacompatmodeon == sal_True );
++    // for Dialogs 'convertLibraryEntries' does nothing ( for now ) 
++    // for Scripts the Library's NameContainer needs to be converted as follows
++    // When vba mode is turned off
++    // Userform and Document modules need to be deleted
++    //    String -> Any( ModuleInfo ) to
++    //    String -> Any( String ) 
++    // When vba mode is turned on
++    //    String -> Any( String )  to
++    //    String -> Any( ModuleInfo )
++    // Userform and Document modules need to be created
++    if ( bNeedsConversion )
++        convertLibraryEntries(); // for Dialogs this does nothing ( for now )
+ }
+ 
+ // Methods XServiceInfo
+@@ -2765,6 +2916,12 @@ void SAL_CALL SfxLibraryContainer::setVBACompatModeOn( ::sal_Bool _vbacompatmode
      return sal_False;
  }
  
@@ -706,7 +536,7 @@
 index 4a46e98..1a84f9f 100644
 --- basic/source/uno/scriptcont.cxx
 +++ basic/source/uno/scriptcont.cxx
-@@ -157,7 +157,7 @@ SfxScriptLibraryContainer::SfxScriptLibr
+@@ -157,7 +157,7 @@ SfxScriptLibraryContainer::SfxScriptLibraryContainer( const uno::Reference< embe
  SfxLibrary* SfxScriptLibraryContainer::implCreateLibrary( const OUString& aName )
  {
  	(void)aName;	// Only needed for SfxDialogLibrary
@@ -715,7 +545,7 @@
  	return pRet;
  }
  
-@@ -168,7 +168,7 @@ SfxLibrary* SfxScriptLibraryContainer::i
+@@ -168,7 +168,7 @@ SfxLibrary* SfxScriptLibraryContainer::implCreateLibraryLink
  	(void)aName;	// Only needed for SfxDialogLibrary
  	SfxLibrary* pRet =
  		new SfxScriptLibrary
@@ -724,7 +554,7 @@
  	return pRet;
  }
  
-@@ -1068,6 +1068,11 @@ SfxScriptLibraryContainer:: HasExecutabl
+@@ -1068,6 +1068,11 @@ SfxScriptLibraryContainer:: HasExecutableCode( const ::rtl::OUString& Library )
  
  //============================================================================
  // Service
@@ -736,7 +566,7 @@
  void createRegistryInfo_SfxScriptLibraryContainer()
  {
      static OAutoRegistration< SfxScriptLibraryContainer > aAutoRegistration;
-@@ -1121,8 +1126,8 @@ Reference< XInterface > SAL_CALL SfxScri
+@@ -1121,8 +1126,8 @@ Reference< XInterface > SAL_CALL SfxScriptLibraryContainer::Create
  // Ctor
  SfxScriptLibrary::SfxScriptLibrary( ModifiableHelper& _rModifiable,
                                      const Reference< XMultiServiceFactory >& xMSF,
@@ -747,7 +577,7 @@
      , mbLoadedSource( sal_False )
      , mbLoadedBinary( sal_False )
  {
-@@ -1133,8 +1138,8 @@ SfxScriptLibrary::SfxScriptLibrary( Modi
+@@ -1133,8 +1138,8 @@ SfxScriptLibrary::SfxScriptLibrary( ModifiableHelper& _rModifiable,
                                      const Reference< XSimpleFileAccess >& xSFI,
                                      const OUString& aLibInfoFileURL,
                                      const OUString& aStorageURL,
@@ -758,7 +588,7 @@
  						aLibInfoFileURL, aStorageURL, ReadOnly)
      , mbLoadedSource( sal_False )
      , mbLoadedBinary( sal_False )
-@@ -1188,7 +1193,193 @@ bool SAL_CALL SfxScriptLibrary::isLibrar
+@@ -1188,7 +1193,193 @@ bool SAL_CALL SfxScriptLibrary::isLibraryElementValid( ::com::sun::star::uno::An
  {
      return SfxScriptLibrary::containsValidModule( aElement );
  }
@@ -952,75 +782,8 @@
  //============================================================================
  
  }   // namespace basic
-diff --git offapi/com/sun/star/script/XVBACompat.idl offapi/com/sun/star/script/XVBACompat.idl
-new file mode 100644
-index 0000000..e1b2d28
---- /dev/null
-+++ offapi/com/sun/star/script/XVBACompat.idl
-@@ -0,0 +1,49 @@
-+/*************************************************************************
-+ *
-+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
-+ * 
-+ * Copyright 2008 by Sun Microsystems, Inc.
-+ *
-+ * OpenOffice.org - a multi-platform office productivity suite
-+ *
-+ * $RCSfile: XLibraryContainer.idl,v $
-+ * $Revision: 1.4 $
-+ *
-+ * 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 __com_sun_star_script_XVBACompat_idl__ 
-+#define __com_sun_star_script_XVBACompat_idl__ 
-+ 
-+#ifndef __com_sun_star_uno_XInterface_idl__ 
-+#include <com/sun/star/uno/XInterface.idl> 
-+#endif 
-+ 
-+//============================================================================= 
-+ 
-+module com {  module sun {  module star {  module script {  
-+ 
-+interface XVBACompat: com::sun::star::uno::XInterface
-+{ 
-+
-+//============================================================================= 
-+    [attribute ] boolean VBACompatModeOn;
-+ 
-+}; }; }; };  
-+}; 
-+#endif 
-diff --git offapi/com/sun/star/script/makefile.mk offapi/com/sun/star/script/makefile.mk
-index ea9bbd1..9837104 100644
---- offapi/com/sun/star/script/makefile.mk
-+++ offapi/com/sun/star/script/makefile.mk
-@@ -52,6 +52,7 @@ IDLFILES=\
- 	XPersistentLibraryContainer.idl\
- 	XStorageBasedLibraryContainer.idl\
- 	XLibraryQueryExecutable.idl \
-+	XVBACompat.idl\
- 	ModuleSizeExceededRequest.idl\
- 
- # ------------------------------------------------------------------
 diff --git sc/inc/document.hxx sc/inc/document.hxx
-index 8c50532..18b573a 100644
+index 35fd858..8b608f1 100644
 --- sc/inc/document.hxx
 +++ sc/inc/document.hxx
 @@ -34,6 +34,7 @@
@@ -1031,7 +794,7 @@
  #include <com/sun/star/uno/Reference.hxx>
  #include <vos/ref.hxx>
  #include "scdllapi.h"
-@@ -316,7 +317,7 @@ private:
+@@ -319,7 +320,7 @@ private:
  	Timer				aTrackTimer;
  
      com::sun::star::uno::Reference< com::sun::star::document::XVbaEventsHelper > mxVbaEventsHelper;
@@ -1040,7 +803,7 @@
  public:
      ScTabOpList         aTableOpList;		            // list of ScInterpreterTableOpParams currently in use
      ScInterpreterTableOpParams  aLastTableOpParams;     // remember last params
-@@ -435,6 +436,7 @@ public:
+@@ -439,6 +440,7 @@ public:
  								SfxObjectShell* pDocShell = NULL );
  					~ScDocument();
  
@@ -1049,10 +812,10 @@
  					GetServiceManager() const { return xServiceManager; }
  
 diff --git sc/source/core/data/documen2.cxx sc/source/core/data/documen2.cxx
-index 156b2ae..e29dc3c 100644
+index 7bd7a09..a9bda22 100644
 --- sc/source/core/data/documen2.cxx
 +++ sc/source/core/data/documen2.cxx
-@@ -263,6 +263,7 @@ ScDocument::ScDocument( ScDocumentMode	e
+@@ -263,6 +263,7 @@ ScDocument::ScDocument( ScDocumentMode	eMode,
  
  	aTrackTimer.SetTimeoutHdl( LINK( this, ScDocument, TrackTimeHdl ) );
  	aTrackTimer.SetTimeout( 100 );
@@ -1061,20 +824,20 @@
  
  
 diff --git sc/source/core/data/document.cxx sc/source/core/data/document.cxx
-index 886156d..680a311 100644
+index a94a264..fee5545 100644
 --- sc/source/core/data/document.cxx
 +++ sc/source/core/data/document.cxx
-@@ -91,6 +91,9 @@
- #include "bcaslot.hxx"
+@@ -92,6 +92,9 @@
  #include "postit.hxx"
  #include "tabprotection.hxx"
+ #include "externalrefmgr.hxx"
 +#include <comphelper/processfactory.hxx>
 +
 +using namespace ::com::sun::star;
  
  struct ScDefaultAttr
  {
-@@ -4891,5 +4894,30 @@ BOOL ScDocument::NeedPageResetAfterTab( 
+@@ -4485,5 +4488,30 @@ BOOL ScDocument::NeedPageResetAfterTab( SCTAB nTab ) const
  	return FALSE;		// sonst nicht
  }
  
@@ -1105,34 +868,11 @@
 +
  
  
-diff --git sc/source/filter/excel/excimp8.cxx sc/source/filter/excel/excimp8.cxx
-index fa27688..aff8877 100644
---- sc/source/filter/excel/excimp8.cxx
-+++ sc/source/filter/excel/excimp8.cxx
-@@ -103,6 +103,7 @@
- 
- #include <com/sun/star/document/XDocumentProperties.hpp>
- #include <com/sun/star/document/XDocumentPropertiesSupplier.hpp>
-+#include <com/sun/star/script/ModuleInfo.hpp>
- 
- 
- using namespace com::sun::star;
-@@ -110,8 +111,8 @@ using namespace com::sun::star;
- 
- #define	INVALID_POS		0xFFFFFFFF
- 
--
--
-+// defined in docfunc.cxx ( really this needs a new name )
-+script::ModuleInfo lcl_InitModuleInfo( SfxObjectShell& rDocSh, String& sModule );
- 
- ImportExcel8::ImportExcel8( XclImpRootData& rImpData, SvStream& rStrm ) :
-     ImportExcel( rImpData, rStrm ), mnTab(0)
 diff --git sc/source/filter/xml/xmlsubti.cxx sc/source/filter/xml/xmlsubti.cxx
-index ab00932..05871e7 100644
+index c56f867..a7b3c40 100644
 --- sc/source/filter/xml/xmlsubti.cxx
 +++ sc/source/filter/xml/xmlsubti.cxx
-@@ -228,6 +228,7 @@ void ScMyTables::NewSheet(const rtl::OUS
+@@ -220,6 +220,7 @@ void ScMyTables::NewSheet(const rtl::OUString& sTableName, const rtl::OUString&
  				uno::Reference <container::XIndexAccess> xIndex( xSheets, uno::UNO_QUERY );
  				if ( xIndex.is() )
  				{
@@ -1140,7 +880,7 @@
                      xCurrentSheet.set(xIndex->getByIndex(nCurrentSheet), uno::UNO_QUERY);
  					if ( xCurrentSheet.is() )
  					{
-@@ -254,6 +255,27 @@ void ScMyTables::NewSheet(const rtl::OUS
+@@ -246,6 +247,27 @@ void ScMyTables::NewSheet(const rtl::OUString& sTableName, const rtl::OUString&
  									}
  								}
  						}
@@ -1168,122 +908,8 @@
  						rImport.SetTableStyle(sStyleName);
  
                          if ( sStyleName.getLength() )
-diff --git sc/source/ui/docshell/docfunc.cxx sc/source/ui/docshell/docfunc.cxx
-index a8e6602..eee88d8 100644
---- sc/source/ui/docshell/docfunc.cxx
-+++ sc/source/ui/docshell/docfunc.cxx
-@@ -2028,23 +2028,29 @@ BOOL ScDocFunc::MoveBlock( const ScRange
- }
- 
- //------------------------------------------------------------------------
--script::ModuleInfo lcl_InitModuleInfo( ScDocShell& rDocSh, String& sModule )
-+uno::Reference< uno::XInterface > GetDocModuleObject( SfxObjectShell& rDocSh, String& sCodeName )
- {
--    ::rtl::OUString aModName( sModule );
-     uno::Reference< lang::XMultiServiceFactory> xSF(rDocSh.GetModel(), uno::UNO_QUERY);
-+    uno::Reference< container::XNameAccess > xVBACodeNamedObjectAccess;
-+    uno::Reference< uno::XInterface > xDocModuleApiObject;
-+    if ( xSF.is() )
-+    {
-+        xVBACodeNamedObjectAccess.set( xSF->createInstance( rtl::OUString(RTL_CONSTASCII_USTRINGPARAM( "org.openoffice.vba.VBAObjectModuleObjectProvider"))), uno::UNO_QUERY );    
-+        xDocModuleApiObject.set( xVBACodeNamedObjectAccess->getByName( sCodeName ), uno::UNO_QUERY );    
-+    }
-+    return xDocModuleApiObject;
-+
-+}
-+
-+script::ModuleInfo lcl_InitModuleInfo( SfxObjectShell& rDocSh, String& sModule )
-+{
-+    ::rtl::OUString aModName( sModule );
-     ::rtl::OUString sVbaOption( RTL_CONSTASCII_USTRINGPARAM( "Rem Attribute VBA_ModuleType=VBADocumentModule\nOption VBASupport 1\n" ));
-     script::ModuleInfo sModuleInfo;
-     sModuleInfo.ModuleName = aModName;
-     sModuleInfo.ModuleSource = sVbaOption;
-     sModuleInfo.ModuleType = script::ModuleType::Document;
--    uno::Reference< container::XNameAccess > xVBACodeNamedObjectAccess;
--    if ( xSF.is() )
--    {
--        uno::Sequence< uno::Any > aArgs(1);
--        aArgs[0] = uno::Any( aModName );
--        xVBACodeNamedObjectAccess.set( xSF->createInstanceWithArguments( rtl::OUString(RTL_CONSTASCII_USTRINGPARAM( "org.openoffice.vba.VBAObjectModuleObjectProvider")), aArgs), uno::UNO_QUERY );    
--        sModuleInfo.ModuleObject.set( xVBACodeNamedObjectAccess->getByName( aModName ), uno::UNO_QUERY );    
--    }
-+    sModuleInfo.ModuleObject = GetDocModuleObject( rDocSh, sModule );
-     return sModuleInfo;
- }
- 
-@@ -2064,21 +2070,19 @@ void lcl_InsertModule( ScDocShell& rDocS
-     }
-     if( xLib.is() )
-     {
--        // test Module has exist
--        // if the Module is exist. changed to another name
--        // and at this time the string like "SheetX"
-+        // if the Module with codename exists then find a new name
-         sal_Int32 nNum = 1;
-+        sModuleInfo.ModuleName = sModuleName;
-         while( xLib->hasByName( sModuleInfo.ModuleName  ) )
-         {
--            sModuleName = rtl::OUString::createFromAscii( "Sheet" ) + rtl::OUString::valueOf( nNum );
-+            sModuleInfo.ModuleName = rtl::OUString::createFromAscii( "Sheet" ) + rtl::OUString::valueOf( nNum );
-             nNum += 1;
-         }
--        sModuleInfo.ModuleName = sModuleName;
-         uno::Any aSourceAny;
-         aSourceAny <<= sModuleInfo;
--        xLib->insertByName( sModuleName, aSourceAny );
-+        xLib->insertByName( sModuleInfo.ModuleName, aSourceAny );
-         ScDocument* pDoc = rDocSh.GetDocument();
--        String sCodeName( sModuleName );
-+        String sCodeName( sModuleInfo.ModuleName );
-         pDoc->SetCodeName( nTab, sCodeName );
-     }
-     SFX_APP()->LeaveBasicCall();
-@@ -2116,12 +2120,18 @@ BOOL ScDocFunc::InsertTable( SCTAB nTab,
- 	ScDocShellModificator aModificator( rDocShell );
- 
- 	ScDocument* pDoc = rDocShell.GetDocument();
--    StarBASIC* pStarBASIC = rDocShell.GetBasic();
--    BOOL bVbaEnabled = pStarBASIC->isVBAEnabled();
--	if (bRecord && !pDoc->IsUndoEnabled())
-+    // Strange loop, also basic is loaded too early ( InsertTable )
-+    // is called via the xml import for sheets in described in odf 
-+    BOOL bInsertDocModule = false;
-+
-+    if(  !rDocShell.GetDocument()->IsImportingXML() )
-+    {
-+        StarBASIC* pStarBASIC = rDocShell.GetBasic(); 
-+        bInsertDocModule = pStarBASIC ? pStarBASIC->isVBAEnabled() : false;
-+    }
-+	if ( bInsertDocModule || ( bRecord && !pDoc->IsUndoEnabled() ) )
- 		bRecord = FALSE;
--    if ( bVbaEnabled )
--        bRecord = FALSE;
-+
- 	if (bRecord)
- 		pDoc->BeginDrawUndo();							//	InsertTab erzeugt ein SdrUndoNewPage
- 
-@@ -2132,13 +2142,16 @@ BOOL ScDocFunc::InsertTable( SCTAB nTab,
- 
- 	if (pDoc->InsertTab( nTab, rName ))
- 	{
-+		String sCodeName;
- 		if (bRecord)
- 			rDocShell.GetUndoManager()->AddUndoAction(
- 						new ScUndoInsertTab( &rDocShell, nTab, bAppend, rName));
- 		//	Views updaten:
--        if( bVbaEnabled )
-+        // Only insert vba modules if vba mode ( and not currently importing XML )
-+        if( bInsertDocModule )
-         {
--            String sCodeName( rName );
-+            if ( sCodeName.Len() == 0 )
-+		sCodeName = rName;
-             lcl_InsertModule( rDocShell, nTab, sCodeName );
-         }
- 		rDocShell.Broadcast( ScTablesHint( SC_TAB_INSERTED, nTab ) );
 diff --git sc/source/ui/docshell/docsh.cxx sc/source/ui/docshell/docsh.cxx
-index 2d114ff..5eff243 100644
+index 073a68d..31e9003 100644
 --- sc/source/ui/docshell/docsh.cxx
 +++ sc/source/ui/docshell/docsh.cxx
 @@ -131,6 +131,7 @@
@@ -1294,7 +920,7 @@
  
  using namespace com::sun::star;
  using namespace com::sun::star::document::VbaEventId;
-@@ -535,6 +536,14 @@ void ScDocShell::BeforeXMLLoading()
+@@ -299,6 +300,14 @@ void ScDocShell::BeforeXMLLoading()
  		ScColumn::bDoubleAlloc = sal_True;
  }
  
@@ -1309,7 +935,7 @@
  void ScDocShell::AfterXMLLoading(sal_Bool bRet)
  {
  	if (GetCreateMode() != SFX_CREATE_MODE_ORGANIZER)
-@@ -608,8 +617,32 @@ void ScDocShell::AfterXMLLoading(sal_Boo
+@@ -372,8 +381,32 @@ void ScDocShell::AfterXMLLoading(sal_Bool bRet)
  
          // suppress VBA events when loading the xml
          uno::Reference< document::XVbaEventsHelper > xEvt( aDocument.GetVbaEventsHelper() );
@@ -1343,10 +969,10 @@
      aDocument.EnableUndo( TRUE );
      bIsEmpty = FALSE;
 diff --git sc/source/ui/vba/vbaeventshelper.cxx sc/source/ui/vba/vbaeventshelper.cxx
-index 7e1e1c5..65bc73a 100644
+index a315af0..b4d0bd9 100644
 --- sc/source/ui/vba/vbaeventshelper.cxx
 +++ sc/source/ui/vba/vbaeventshelper.cxx
-@@ -620,7 +620,7 @@ String ScVbaEventsHelper::getSheetModule
+@@ -620,7 +620,7 @@ String ScVbaEventsHelper::getSheetModuleName( SCTAB nTab )
  {
  	ScExtDocOptions* pExtOptions = pDoc->GetExtDocOptions();
  	String aCodeName;
@@ -1355,84 +981,32 @@
  	// Use code name if that exists
  	if ( pExtOptions )
  		aCodeName = pExtOptions->GetCodeName( nTab );
-@@ -844,7 +844,7 @@ sal_Bool SAL_CALL 
- ScVbaEventsHelper::ProcessCompatibleVbaEvent( sal_Int32 nEventId, const uno::Sequence< uno::Any >& aArgs ) throw (uno::RuntimeException)
- {
- 	SfxObjectShell* pShell = pDoc->GetDocumentShell();
--	if( !pShell )
-+	if( !pShell || mbIgnoreEvents )
- 		return sal_False;
-     
-     // In order to better support "withevents" in the future, 
 diff --git svx/source/msfilter/svxmsbas.cxx svx/source/msfilter/svxmsbas.cxx
-index 7acf7db..39dae92 100644
+index b00e19c..26b8ca1 100644
 --- svx/source/msfilter/svxmsbas.cxx
 +++ svx/source/msfilter/svxmsbas.cxx
-@@ -54,6 +54,7 @@ using namespace com::sun::star::awt;
+@@ -54,6 +54,8 @@ using namespace com::sun::star::awt;
  #include <com/sun/star/container/XNameContainer.hpp>
  #include <com/sun/star/script/XLibraryContainer.hpp>
  #include <com/sun/star/script/ModuleInfo.hpp>
 +#include <com/sun/star/script/XVBACompat.hpp>
++
  using namespace com::sun::star::container;
  using namespace com::sun::star::script;
  using namespace com::sun::star::uno;
-@@ -267,12 +268,13 @@ BOOL SvxImportMSVBasic::ImportCode_Impl(
-             Any aLibAny = xLibContainer->getByName( aLibName );
- 		    aLibAny >>= xLib;
-         }
--		if( xLib.is() )
-+		Reference< XVBACompat > xCompat( xLibContainer, UNO_QUERY );
-+		if( xLib.is() && xCompat.is() )
- 		{
+@@ -272,7 +274,11 @@ BOOL SvxImportMSVBasic::ImportCode_Impl( const String& rStorageName,
              Reference< container::XNameAccess > xVBAObjectForCodeName;
  			if ( !bAsComment )
              {
 -                rDocSh.GetBasic()->SetVBAEnabled( true );
-+         		xCompat->setVBACompatModeOn( sal_True );
++                Reference< XVBACompat > xCompat( xLibContainer, UNO_QUERY );
++                if( xCompat.is() )
++                    xCompat->setVBACompatModeOn( sal_True );
++                else
++                    rDocSh.GetBasic()->SetVBAEnabled( true );
                  Reference< XMultiServiceFactory> xSF(rDocSh.GetModel(), UNO_QUERY);
                  if ( xSF.is() )
                  {
-@@ -425,20 +427,34 @@ BOOL SvxImportMSVBasic::ImportCode_Impl(
- 
- 					Any aSourceAny;
-                     OSL_TRACE("erm %d", mType );
--                    if (  xVBAObjectForCodeName.is() && ( mType == ModuleType::Document || mType == ModuleType::Class || mType == ModuleType::Form ) )
-+                    //if ( /*xVBAObjectForCodeName.is() && */ ( mType == ModuleType::Document || mType == ModuleType::Class || mType == ModuleType::Form ) )
-+                    if ( !bAsComment )
-                     {
-                         OSL_TRACE("vba processing  %d", mType );
-                         script::ModuleInfo sModuleInfo;
-                         sModuleInfo.ModuleName = aModName;
-                         sModuleInfo.ModuleSource = aSource;
-                         sModuleInfo.ModuleType = mType;
-+// ok, try always passing the model to basic, should fit
-                         if ( mType == ModuleType::Form )
--                            // hack, the module ( in document basic should...
--                            // know the XModel... ) needs fixing in basic 
--                            // somewhere
-+                            // hack, the module ( imo document basic should...
-+                            // know the XModel... ) but it doesn't
-                             sModuleInfo.ModuleObject.set( rDocSh.GetModel(), UNO_QUERY );
--                        else if ( mType != ModuleType::Class )
--                            sModuleInfo.ModuleObject.set( xVBAObjectForCodeName->getByName( aModName ), UNO_QUERY );
-+			//  document modules, we should be able to access
-+			//  the api objects at this time
-+                        else if ( mType == ModuleType::Document )
-+			{
-+				uno::Reference< lang::XMultiServiceFactory> xSF( rDocSh.GetModel(), uno::UNO_QUERY);
-+				uno::Reference< container::XNameAccess > xVBACodeNamedObjectAccess;
-+    				if ( xSF.is() )
-+				        xVBACodeNamedObjectAccess.set( xSF->createInstance( rtl::OUString(RTL_CONSTASCII_USTRINGPARAM( "org.openoffice.vba.VBAObjectModuleObjectProvider"))), uno::UNO_QUERY );    
-+				// get the api object for the codename
-+				if ( xVBACodeNamedObjectAccess.is() )
-+				{
-+					sModuleInfo.ModuleObject.set( xVBACodeNamedObjectAccess->getByName( sModuleInfo.ModuleName ), uno::UNO_QUERY );    
-+					OSL_TRACE("** Straight up creation of Module");
-+				}
-+			}
-                         aSourceAny <<= sModuleInfo;
-                     }
-                     else
 diff --git xmlscript/inc/xmlscript/xmllib_imexp.hxx xmlscript/inc/xmlscript/xmllib_imexp.hxx
 index 9a3048f..93826a9 100644
 --- xmlscript/inc/xmlscript/xmllib_imexp.hxx
@@ -1488,11 +1062,64 @@
  
  void
  SAL_CALL exportLibrary(
+diff --git xmlscript/source/xmldlg_imexp/xmldlg_import.cxx xmlscript/source/xmldlg_imexp/xmldlg_import.cxx
+index 5548016..f739361 100644
+--- xmlscript/source/xmldlg_imexp/xmldlg_import.cxx
++++ xmlscript/source/xmldlg_imexp/xmldlg_import.cxx
+@@ -1880,22 +1880,22 @@ Reference< xml::input::XElement > DialogImport::getStyle(
+ //__________________________________________________________________________________________________
+ Reference< script::XLibraryContainer > DialogImport::getScriptLibraryContainer()
+ {
+-	if( !_xScriptLibraryContainer.is() )
+-	{
+-		try
+-		{
+-			Reference< document::XStorageBasedDocument > xStorageDoc( _xDoc, UNO_QUERY );
+-			if( xStorageDoc.is() )
+-				_xScriptLibraryContainer.set(
+-									script::DocumentScriptLibraryContainer::create( comphelper_getProcessComponentContext(), xStorageDoc ), 
+-									UNO_QUERY );
+-		}
+-		catch( const Exception& )
+-		{
+-		}
+-	}
+-
+-	return _xScriptLibraryContainer;
++    Reference< script::XLibraryContainer >  xLib;
++    if ( _xDoc.is() )
++    {
++        Reference< beans::XPropertySet > xProps( _xDoc, UNO_QUERY );
++        if ( xProps.is() )
++        {
++            try
++            {
++                xProps->getPropertyValue( OUSTR("BasicLibraries") ) >>= xLib;
++            }
++            catch( Exception& )
++            {
++            }
++        }
++   }
++   return xLib;
+ }
+ 
+ //##################################################################################################
+@@ -1911,6 +1911,9 @@ Reference< xml::sax::XDocumentHandler > SAL_CALL importDialogModel(
+     uno::Reference< script::XVBACompat > xVBAModeSource( pImport->getScriptLibraryContainer(), uno::UNO_QUERY );
+     
+     uno::Reference< script::XVBACompat > xVBAModeDest( xDialogModel, uno::UNO_QUERY );
++    bool bOn = false;
++    if ( xVBAModeSource.is() )
++        bOn =  xVBAModeSource->getVBACompatModeOn();
+     if ( xVBAModeSource.is() && xVBAModeDest.is() )
+         xVBAModeDest->setVBACompatModeOn( xVBAModeSource->getVBACompatModeOn() );
+     return ::xmlscript::createDocumentHandler(
 diff --git xmlscript/source/xmllib_imexp/imp_share.hxx xmlscript/source/xmllib_imexp/imp_share.hxx
 index d602103..fdc0536 100644
 --- xmlscript/source/xmllib_imexp/imp_share.hxx
 +++ xmlscript/source/xmllib_imexp/imp_share.hxx
-@@ -220,7 +220,6 @@ class LibrariesElement : public LibEleme
+@@ -220,7 +220,6 @@ class LibrariesElement : public LibElementBase
      
  protected:
      vector< LibDescriptor > mLibDescriptors;
@@ -1500,7 +1127,7 @@
  public:
      virtual Reference< xml::input::XElement > SAL_CALL startChildElement(
          sal_Int32 nUid, OUString const & rLocalName,
-@@ -244,7 +243,7 @@ class LibraryElement : public LibElement
+@@ -244,7 +243,7 @@ class LibraryElement : public LibElementBase
  {
  protected:
      vector< OUString > mElements;
@@ -1625,7 +1252,7 @@
  //__________________________________________________________________________________________________
  Reference< xml::input::XElement > LibElementBase::getParent()
      throw (RuntimeException)
-@@ -206,7 +219,11 @@ Reference< xml::input::XElement > Librar
+@@ -206,7 +219,11 @@ Reference< xml::input::XElement > LibraryImport::startRootElement(
              &aDesc.bPreload,
              OUString( RTL_CONSTASCII_USTRINGPARAM("preload") ),
              xAttributes, XMLNS_LIBRARY_UID );
@@ -1638,7 +1265,7 @@
          return new LibraryElement( rLocalName, xAttributes, 0, this );
      }
      else
-@@ -265,7 +282,10 @@ Reference< xml::input::XElement > Librar
+@@ -265,7 +282,10 @@ Reference< xml::input::XElement > LibrariesElement::startChildElement(
              &aDesc.bPasswordProtected,
              OUString( RTL_CONSTASCII_USTRINGPARAM("passwordprotected") ),
              xAttributes, _pImport->XMLNS_LIBRARY_UID );
@@ -1650,7 +1277,7 @@
          mLibDescriptors.push_back( aDesc );
          return new LibraryElement( rLocalName, xAttributes, this, _pImport );
      }
-@@ -312,6 +332,17 @@ Reference< xml::input::XElement > Librar
+@@ -312,6 +332,17 @@ Reference< xml::input::XElement > LibraryElement::startChildElement(
          if (aValue.getLength())
              mElements.push_back( aValue );
  
@@ -1676,7 +1303,7 @@
  }
  
  
-@@ -348,6 +380,15 @@ SAL_CALL importLibraryContainer( LibDesc
+@@ -348,6 +380,15 @@ SAL_CALL importLibraryContainer( LibDescriptorArray* pLibArray )
          static_cast< xml::input::XRoot * >( new LibraryImport( pLibArray ) ) );
  }
  
@@ -1692,7 +1319,7 @@
  //##################################################################################################
  
  ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XDocumentHandler >
-@@ -360,6 +401,13 @@ SAL_CALL importLibrary( LibDescriptor& r
+@@ -360,6 +401,13 @@ SAL_CALL importLibrary( LibDescriptor& rLib )
  
  
  //##################################################################################################



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]