ooo-build r12921 - trunk/patches/test/vba



Author: noelpwer
Date: Thu Jun 19 09:06:50 2008
New Revision: 12921
URL: http://svn.gnome.org/viewvc/ooo-build?rev=12921&view=rev

Log:
clean up patch a little, make containers homogeneous, adjust basic load
sequence


Modified:
   trunk/patches/test/vba/ObjectModule.diff

Modified: trunk/patches/test/vba/ObjectModule.diff
==============================================================================
--- trunk/patches/test/vba/ObjectModule.diff	(original)
+++ trunk/patches/test/vba/ObjectModule.diff	Thu Jun 19 09:06:50 2008
@@ -1,3 +1,36 @@
+diff --git .gitignore .gitignore
+index 71145e6..7f99c80 100644
+--- .gitignore
++++ .gitignore
+@@ -6,3 +6,5 @@ unxlng*.pro
+ localize.sdf
+ /solver
+ *.orig
++*.swp
++/sc.nodebug
+diff --git basctl/source/basicide/scriptdocument.cxx basctl/source/basicide/scriptdocument.cxx
+index a12fb46..fc1e511 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
@@ -202,7 +235,7 @@
  	    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 e5b3d76..4f1d26a 100644
+index e5b3d76..ac4278b 100644
 --- basic/source/inc/namecont.hxx
 +++ basic/source/inc/namecont.hxx
 @@ -62,20 +62,23 @@
@@ -230,7 +263,28 @@
      ::com::sun::star::lang::XServiceInfo > LibraryContainerHelper;
  
  typedef ::cppu::WeakImplHelper2< ::com::sun::star::container::XNameContainer,
-@@ -248,7 +251,7 @@ protected:
+@@ -109,6 +112,11 @@ NameContainerNameMap;
+ 
+ 
+ //============================================================================
++class ItemConvertor
++{
++public:
++    virtual bool convert(com::sun::star::uno::Any& item ) = 0;
++};
+ 
+ class NameContainer : public ::cppu::BaseMutex, public NameContainerHelper
+ {
+@@ -132,7 +140,7 @@ public:
+ 
+ 	void setEventSource( ::com::sun::star::uno::XInterface* pxEventSource )
+ 		{ mpxEventSource = pxEventSource; }
+-
++        bool convertContainer( const ::com::sun::star::uno::Type& rNewType, ItemConvertor& aConvertor );
+     // Methods XElementAccess
+     virtual ::com::sun::star::uno::Type SAL_CALL getElementType(  ) 
+ 		throw(::com::sun::star::uno::RuntimeException);
+@@ -248,7 +256,7 @@ protected:
  	sal_Bool        mbOwnBasMgr;
  
      InitMode meInitMode;
@@ -239,16 +293,26 @@
  	void implStoreLibrary( SfxLibrary* pLib,
  							const ::rtl::OUString& aName,
  							const ::com::sun::star::uno::Reference< ::com::sun::star::embed::XStorage >& xStorage );
-@@ -497,6 +500,8 @@ public:
+@@ -331,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;
+-
++    virtual void convertLibraryEntries() { /*default bogus implementation*/}
+     // Handle maLibInfoFileURL and maStorageURL correctly
+     void checkStorageURL
+     (
+@@ -497,6 +505,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
-@@ -556,7 +561,7 @@ private:
+@@ -556,7 +567,7 @@ private:
  	::rtl::OUString maPassword;
  
  	sal_Bool mbSharedIndexFile;
@@ -257,11 +321,95 @@
  	// Additional functionality for localisation
  	// Provide modify state including resources
  	virtual sal_Bool isModified( void ) = 0;
+@@ -646,6 +657,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);
++	bool convertContainer(const ::com::sun::star::uno::Type& rNewType, ItemConvertor& aConvertor );
+ };
+ 
+ 
+diff --git basic/source/inc/scriptcont.hxx basic/source/inc/scriptcont.hxx
+index 140a5ca..99d1cc8 100644
+--- basic/source/inc/scriptcont.hxx
++++ basic/source/inc/scriptcont.hxx
+@@ -97,6 +97,7 @@ class SfxScriptLibraryContainer : public
+     virtual const sal_Char* SAL_CALL    getOldInfoFileName() const;
+     virtual const sal_Char* SAL_CALL    getLibElementFileExtension() const;
+     virtual const sal_Char* SAL_CALL    getLibrariesDir() const;
++    virtual void convertLibraryEntries();
+ 
+ public:
+ 	SfxScriptLibraryContainer( void );
+@@ -161,7 +162,7 @@ public:
+     (
+         ModifiableHelper& _rModifiable,
+         const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& xMSF,
+-	    const ::com::sun::star::uno::Reference< ::com::sun::star::ucb::XSimpleFileAccess >& xSFI
++	    const ::com::sun::star::uno::Reference< ::com::sun::star::ucb::XSimpleFileAccess >& xSFI, bool bVBACompat
+     );
+ 
+ 	SfxScriptLibrary
+@@ -169,7 +170,7 @@ public:
+         ModifiableHelper& _rModifiable,
+         const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& xMSF,
+ 	    const ::com::sun::star::uno::Reference< ::com::sun::star::ucb::XSimpleFileAccess >& xSFI,
+-        const ::rtl::OUString& aLibInfoFileURL, const ::rtl::OUString& aStorageURL, sal_Bool ReadOnly
++        const ::rtl::OUString& aLibInfoFileURL, const ::rtl::OUString& aStorageURL, sal_Bool ReadOnly, bool bVBACOmpat
+     );
+ };
+ 
 diff --git basic/source/uno/namecont.cxx basic/source/uno/namecont.cxx
-index e5f37c7..a062c0d 100644
+index e5f37c7..2b910a4 100644
 --- basic/source/uno/namecont.cxx
 +++ basic/source/uno/namecont.cxx
-@@ -325,6 +325,17 @@ void ModifiableHelper::setModified( sal_
+@@ -105,6 +105,27 @@ static bool GbMigrationSuppressErrors = 
+ //============================================================================
+ // Implementation class NameContainer
+ 
++bool 
++NameContainer::convertContainer(const ::com::sun::star::uno::Type& rNewType, ItemConvertor& aConvertor )
++{
++        bool bRes = true;
++        uno::Sequence< uno::Any > mCopyValues( mValues );
++	for ( sal_Int32	i = 0; bRes && i < mCopyValues.getLength();  ++i )
++	{
++		if ( !aConvertor.convert( mCopyValues[ i ] ) )
++                {
++			bRes = false;
++                        break;
++                }
++	}
++	if ( bRes )
++        {
++                mValues = mCopyValues;
++		mType = rNewType;
++        }
++	return bRes;
++}
++
+ // Methods XElementAccess
+ Type NameContainer::getElementType()
+ 	throw(RuntimeException)
+@@ -153,7 +174,7 @@ void NameContainer::replaceByName( const
+ 	throw(IllegalArgumentException, NoSuchElementException, WrappedTargetException, RuntimeException)
+ {
+ 	Type aAnyType = aElement.getValueType();
+-    if( mType != aAnyType && aAnyType != getCppuType( static_cast< ModuleInfo* >( NULL ) ) )
++    if( mType != aAnyType )
+ 		throw IllegalArgumentException();
+ 
+ 	NameContainerNameMap::iterator aIt = mHashMap.find( aName );
+@@ -195,7 +216,7 @@ void NameContainer::insertByName( const 
+ 	throw(IllegalArgumentException, ElementExistException, WrappedTargetException, RuntimeException)
+ {
+ 	Type aAnyType = aElement.getValueType();
+-    if( mType != aAnyType && aAnyType != getCppuType( static_cast< ModuleInfo* >( NULL ) ) )
++    if( mType != aAnyType )
+ 		throw IllegalArgumentException();
+ 
+ 	NameContainerNameMap::iterator aIt = mHashMap.find( aName );
+@@ -325,6 +346,30 @@ void ModifiableHelper::setModified( sal_
  // Implementation class SfxLibraryContainer
  DBG_NAME( SfxLibraryContainer )
  
@@ -274,12 +422,25 @@
 +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 )
-@@ -334,6 +345,7 @@ SfxLibraryContainer::SfxLibraryContainer
+@@ -334,6 +379,7 @@ SfxLibraryContainer::SfxLibraryContainer
      , mbOasis2OOoFormat( sal_False )
      , mpBasMgr( NULL )
      , mbOwnBasMgr( sal_False )
@@ -287,7 +448,7 @@
  {
      DBG_CTOR( SfxLibraryContainer, NULL );
  
-@@ -790,7 +802,7 @@ sal_Bool SfxLibraryContainer::init_Impl(
+@@ -790,7 +836,7 @@ sal_Bool SfxLibraryContainer::init_Impl(
                  OSL_ENSURE( 0, OUStringToOString( e.Message, RTL_TEXTENCODING_ASCII_US ).getStr() );
                  return sal_False;
              }
@@ -296,27 +457,34 @@
  		    sal_Int32 nLibCount = pLibArray->mnLibCount;
  		    for( sal_Int32 i = 0 ; i < nLibCount ; i++ )
  		    {
-@@ -1620,16 +1632,33 @@ void SfxLibraryContainer::implImportLibD
+@@ -1619,17 +1665,39 @@ void SfxLibraryContainer::implImportLibD
+     {
  	    sal_Int32 nElementCount = rLib.aElementNames.getLength();
  	    const OUString* pElementNames = rLib.aElementNames.getConstArray();
- 	    Any aDummyElement = createEmptyLibraryElement();
-+            ::xmlscript::ObjectModuleDescHash::iterator it_end = rLib.hCodeNameToObjDesc.end();
+-	    Any aDummyElement = createEmptyLibraryElement();
++	    Any aDummyElement;
++            ::xmlscript::ObjectModuleDescHash::iterator it_end = rLib.hModuleTypeDesc.end();
  	    for( sal_Int32 i = 0 ; i < nElementCount ; i++ )
  	    {
-+                    ::xmlscript::ObjectModuleDescHash::iterator it = rLib.hCodeNameToObjDesc.find( pElementNames[i] );
-+                    
-+                    if ( it != it_end )
++                    if ( getVBACompatModeOn() ) 
 +                    {
-+                        // for all other types set up the ModuleInfo structure
++                        ::xmlscript::ObjectModuleDescHash::iterator it = rLib.hModuleTypeDesc.find( pElementNames[i] );
++                    
 +                        com::sun::star::script::ModuleInfo mInfo;
++                        mInfo.ModuleType = ModuleType::Normal;
 +                        mInfo.ModuleName = pElementNames[i];
-+                        mInfo.ModuleType = it->second.mnModuleType;
-+                        // hack for userform, needs to know about the document
-+                        // well really it needs the dialog library
-+                        if (  mInfo.ModuleType == ModuleType::Form )
-+                            mInfo.ModuleObject = mxOwnerDocument;
++                        if ( it != it_end )
++                        {
++                            mInfo.ModuleType = it->second.mnModuleType;
++                            // hack for userform, needs to know about the document
++                            // well really it needs the dialog library
++                            if (  mInfo.ModuleType == ModuleType::Form )
++                                mInfo.ModuleObject = mxOwnerDocument;
++                        }
 +                        aDummyElement <<= mInfo;
 +                    }
++                    else
++	                aDummyElement = createEmptyLibraryElement();
  		    pLib->maNameContainer.insertByName( pElementNames[i], aDummyElement );
 -	    }
 +        }
@@ -326,31 +494,25 @@
          pLib->implSetModified( sal_False );
  
          pLib->mbInitialised = sal_True;
-+        pLib->mhCodeNameToObjDesc = rLib.hCodeNameToObjDesc;
++        pLib->mhCodeNameToObjDesc = rLib.hModuleTypeDesc;
 +
      }
  }
  
-@@ -2177,10 +2206,26 @@ void SAL_CALL SfxLibraryContainer::loadL
+@@ -2177,13 +2245,29 @@ void SAL_CALL SfxLibraryContainer::loadL
  			}
  
  			Any aAny = importLibraryElement( aFile, xInStream );
-+            // perhaps the ModuleInfo stuff might be better done in scriptcont 
-+            // ( via importLibraryElement, probably would need to pass pImplLib though, which
-+            // defeats the purpose of the pImpl  )
-+            ::xmlscript::ObjectModuleDescHash::iterator it = pImplLib->mhCodeNameToObjDesc.find( aElementName );
-+            if ( it !=  pImplLib->mhCodeNameToObjDesc.end() )
-+            {
-+                // Replace the aAny with one containing ModuleInfo
-+                com::sun::star::script::ModuleInfo mInfo;
-+                mInfo.ModuleName = aElementName;
-+                mInfo.ModuleType = it->second.mnModuleType;
-+                mInfo.ModuleObject = mxOwnerDocument;
-+                aAny >>= mInfo.ModuleSource; 
-+                aAny <<= mInfo;
-+            }
++
++            com::sun::star::script::ModuleInfo mInfo;
  			if( pImplLib->hasByName( aElementName ) )
              {
++                if ( getVBACompatModeOn() )
++                {
++				    pImplLib->maNameContainer.getByName( aElementName ) >>= mInfo;
++                    aAny >>= mInfo.ModuleSource; 
++                    aAny <<= mInfo;
++                } 
                  if( aAny.hasValue() )
 +                {
  				    pImplLib->maNameContainer.replaceByName( aElementName, aAny );
@@ -358,6 +520,28 @@
              }
  			else
              {
++                if ( getVBACompatModeOn() )
++                {
++                    mInfo.ModuleType = ModuleType::Normal;
++                    aAny >>= mInfo.ModuleSource; 
++                    aAny <<= mInfo;
++                }
+ 				pImplLib->maNameContainer.insertByName( aElementName, aAny );
+             }
+ 		}
+@@ -2832,6 +2916,12 @@ void SAL_CALL SfxLibrary::removeContaine
+ 	maNameContainer.removeContainerListener( xListener );
+ }
+ 
++bool SfxLibrary::convertContainer(const ::com::sun::star::uno::Type& rNewType, ItemConvertor& aConvertor )
++{
++	return maNameContainer.convertContainer( rNewType, aConvertor );
++}
++
++
+ //============================================================================
+ 
+ }   // namespace basic
 diff --git basic/source/uno/sbservices.cxx basic/source/uno/sbservices.cxx
 index a2a4ded..aa076ea 100644
 --- basic/source/uno/sbservices.cxx
@@ -379,9 +563,27 @@
          }
      }
 diff --git basic/source/uno/scriptcont.cxx basic/source/uno/scriptcont.cxx
-index 7480f7c..6d72850 100644
+index 7480f7c..61955ff 100644
 --- basic/source/uno/scriptcont.cxx
 +++ basic/source/uno/scriptcont.cxx
+@@ -156,7 +156,7 @@ SfxScriptLibraryContainer::SfxScriptLibr
+ SfxLibrary* SfxScriptLibraryContainer::implCreateLibrary( const OUString& aName )
+ {
+ 	(void)aName;	// Only needed for SfxDialogLibrary
+-	SfxLibrary* pRet = new SfxScriptLibrary( maModifiable, mxMSF, mxSFI );
++	SfxLibrary* pRet = new SfxScriptLibrary( maModifiable, mxMSF, mxSFI, getVBACompatModeOn() );
+ 	return pRet;
+ }
+ 
+@@ -167,7 +167,7 @@ SfxLibrary* SfxScriptLibraryContainer::i
+ 	(void)aName;	// Only needed for SfxDialogLibrary
+ 	SfxLibrary* pRet =
+ 		new SfxScriptLibrary
+-            ( maModifiable, mxMSF, mxSFI, aLibInfoFileURL, StorageURL, ReadOnly );
++            ( maModifiable, mxMSF, mxSFI, aLibInfoFileURL, StorageURL, ReadOnly, getVBACompatModeOn() );
+ 	return pRet;
+ }
+ 
 @@ -1056,6 +1056,11 @@ SfxScriptLibraryContainer:: HasExecutabl
  
  //============================================================================
@@ -394,7 +596,29 @@
  void createRegistryInfo_SfxScriptLibraryContainer()
  {
      static OAutoRegistration< SfxScriptLibraryContainer > aAutoRegistration;
-@@ -1160,6 +1165,124 @@ void SfxScriptLibrary::storeResourcesToS
+@@ -1109,8 +1114,8 @@ Reference< XInterface > SAL_CALL SfxScri
+ // Ctor
+ SfxScriptLibrary::SfxScriptLibrary( ModifiableHelper& _rModifiable,
+                                     const Reference< XMultiServiceFactory >& xMSF,
+-                                    const Reference< XSimpleFileAccess >& xSFI )
+-	: SfxLibrary( _rModifiable, getCppuType( (const OUString *)0 ), xMSF, xSFI )
++                                    const Reference< XSimpleFileAccess >& xSFI, bool bVBA )
++	: SfxLibrary( _rModifiable, bVBA ? getCppuType( ( const script::ModuleInfo*)0 ) : getCppuType( (const OUString *)0 ), xMSF, xSFI )
+     , mbLoadedSource( sal_False )
+     , mbLoadedBinary( sal_False )
+ {
+@@ -1121,8 +1126,8 @@ SfxScriptLibrary::SfxScriptLibrary( Modi
+                                     const Reference< XSimpleFileAccess >& xSFI,
+                                     const OUString& aLibInfoFileURL,
+                                     const OUString& aStorageURL,
+-                                    sal_Bool ReadOnly )
+-	: SfxLibrary( _rModifiable, getCppuType( (const OUString *)0 ), xMSF, xSFI,
++                                    sal_Bool ReadOnly, bool bVBA )
++	: SfxLibrary( _rModifiable, bVBA ? getCppuType( ( const script::ModuleInfo*)0 ) : getCppuType( (const OUString *)0 ), xMSF, xSFI,
+ 						aLibInfoFileURL, aStorageURL, ReadOnly)
+     , mbLoadedSource( sal_False )
+     , mbLoadedBinary( sal_False )
+@@ -1160,7 +1165,183 @@ void SfxScriptLibrary::storeResourcesToS
  	// No resources
  	(void)xStorage;
  }
@@ -516,9 +740,68 @@
 +        return xRet;
 +    }
 +};
++class ConvertEntryToVbaEntry : public ItemConvertor
++{
++	virtual bool convert( Any& item )
++	{
++	    // All entries are converted to 'Normal' modules
++	    // Document Modules need to be created externall ( e.g. these are under the control
++	    // of the document itself )
++	    rtl::OUString sSource;
++	    bool bRes = false;
++	
++	    if ( item >>= sSource )
++	    {
++	        script::ModuleInfo mInfo;
++	        mInfo.ModuleSource = sSource;
++	        mInfo.ModuleType = script::ModuleType::Normal;
++	        item <<= mInfo;
++	        bRes = true;
++	    }
++	    return bRes; 
++	}
++};
++
++class ConvertEntryFromVbaEntry : public ItemConvertor
++{
++	bool convert( Any& item )
++	{
++	    bool bRes = false;
++	    script::ModuleInfo mInfo;
++	    if ( item >>= mInfo )
++	    {
++	        item <<= mInfo.ModuleSource;
++	        bRes = true;
++	    }
++	    return bRes;
++	}
++};
  
++void SfxScriptLibraryContainer::convertLibraryEntries()
++{
++    if ( getVBACompatModeOn() )
++    {
++        // going from non-vba to vba        
++        SfxLibrary* pImplLib = getImplLib( String( RTL_CONSTASCII_USTRINGPARAM("Standard") ) );
++        
++	ConvertEntryToVbaEntry converter;
++	bool bRes = pImplLib ? pImplLib->convertContainer( getCppuType( ( const script::ModuleInfo* ) NULL ), converter ) : false;
++    }
++    else
++    { 
++        // going from vba to non-vba        
++        // we must delete all Document modules
++        // what we also must do is warn the user that this is going to happen ( see. Excel )
++        // needs interaction handler love ( perhaps that needs to be passed into the setVBACompat ) 
++        // or perhaps we can access the documents InteractionHandler ?
++        SfxLibrary* pImplLib = getImplLib( String( RTL_CONSTASCII_USTRINGPARAM("Standard") ) );
++	ConvertEntryFromVbaEntry convertor;
++	bool bRes = pImplLib ? pImplLib->convertContainer( getCppuType( ( const rtl::OUString*) NULL ), convertor ) : false;
++    }
++}
  //============================================================================
  
+ }   // namespace basic
 diff --git offapi/com/sun/star/document/XVbaEventsHelper.idl offapi/com/sun/star/document/XVbaEventsHelper.idl
 index 718e68d..fd0e2db 100644
 --- offapi/com/sun/star/document/XVbaEventsHelper.idl
@@ -808,6 +1091,44 @@
          }
      }
  }
+diff --git sc/source/filter/xml/xmlsubti.cxx sc/source/filter/xml/xmlsubti.cxx
+index ab00932..f8674ae 100644
+--- sc/source/filter/xml/xmlsubti.cxx
++++ sc/source/filter/xml/xmlsubti.cxx
+@@ -228,6 +228,7 @@ void ScMyTables::NewSheet(const rtl::OUS
+ 				uno::Reference <container::XIndexAccess> xIndex( xSheets, uno::UNO_QUERY );
+ 				if ( xIndex.is() )
+ 				{
++
+                     xCurrentSheet.set(xIndex->getByIndex(nCurrentSheet), uno::UNO_QUERY);
+ 					if ( xCurrentSheet.is() )
+ 					{
+@@ -254,6 +255,25 @@ void ScMyTables::NewSheet(const rtl::OUS
+ 									}
+ 								}
+ 						}
++
++						ScDocument *pDoc = ScXMLConverter::GetScDocument(rImport.GetModel());
++						// Codenames need to be set as sheets are created and read
++						if ( pDoc  )
++						{
++							String sName;
++							pDoc->GetName( nCurrentSheet, sName );
++	                        rtl::OUString sOUName( sName );
++							uno::Reference< container::XNameAccess > xCodeNames( pDoc->GetPersistedCodeNames() );
++							if( xCodeNames.is() && xCodeNames->hasByName( sName ) )
++							{
++								rtl::OUString sOUSCodeName;
++								xCodeNames->getByName( sName ) >>= sOUSCodeName;
++								rImport.LockSolarMutex();
++								String sCodeName( sOUSCodeName );
++								pDoc->SetCodeName( nCurrentSheet, sCodeName );		
++								rImport.UnlockSolarMutex();
++							}
++						}
+ 						rImport.SetTableStyle(sStyleName);
+ 
+                         if ( sStyleName.getLength() )
 diff --git sc/source/ui/docshell/docfunc.cxx sc/source/ui/docshell/docfunc.cxx
 index 105f743..91ff9f7 100644
 --- sc/source/ui/docshell/docfunc.cxx
@@ -912,7 +1233,7 @@
          }
  		rDocShell.Broadcast( ScTablesHint( SC_TAB_INSERTED, nTab ) );
 diff --git sc/source/ui/docshell/docsh.cxx sc/source/ui/docshell/docsh.cxx
-index da54daa..6e57e1e 100644
+index da54daa..aa4dec8 100644
 --- sc/source/ui/docshell/docsh.cxx
 +++ sc/source/ui/docshell/docsh.cxx
 @@ -130,6 +130,7 @@
@@ -982,7 +1303,7 @@
  void ScDocShell::AfterXMLLoading(sal_Bool bRet)
  {
  	if (GetCreateMode() != SFX_CREATE_MODE_ORGANIZER)
-@@ -600,8 +644,36 @@ void ScDocShell::AfterXMLLoading(sal_Boo
+@@ -600,8 +644,35 @@ void ScDocShell::AfterXMLLoading(sal_Boo
      }
      else
  		aDocument.SetInsertingFromOtherDoc( FALSE );
@@ -1007,7 +1328,6 @@
 +                }
 +                aDocument.GetName( i, sObjectName );
 +                sCodeName = GetCodeName( aDocument, sObjectName );
-+                aDocument.SetCodeName( i, sCodeName );
 +                SetDocModuleForCodeName( aDocument, sCodeName );
 +            } 
 +            catch( uno::Exception& )
@@ -1207,24 +1527,48 @@
  
  #endif
 diff --git svx/source/msfilter/svxmsbas.cxx svx/source/msfilter/svxmsbas.cxx
-index e647cf8..d78c1e4 100644
+index e647cf8..83949e0 100644
 --- svx/source/msfilter/svxmsbas.cxx
 +++ svx/source/msfilter/svxmsbas.cxx
-@@ -403,20 +403,23 @@ BOOL SvxImportMSVBasic::ImportCode_Impl(
+@@ -54,6 +54,7 @@ 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;
+@@ -250,12 +251,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() )
+ 		{
+             Reference< container::XNameAccess > xVBAObjectForCodeName;
+ 			if ( !bAsComment )
+             {
+-                rDocSh.GetBasic()->SetVBAEnabled( true );
++         		xCompat->setVBACompatModeOn( sal_True );
+                 Reference< XMultiServiceFactory> xSF(rDocSh.GetModel(), UNO_QUERY);
+                 if ( xSF.is() )
+                 {
+@@ -403,20 +405,24 @@ 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 ( /*xVBAObjectForCodeName.is() && */ ( mType == ModuleType::Document || mType == ModuleType::Class || mType == ModuleType::Form ) )
++                    if ( true )
                      {
                          OSL_TRACE("vba processing  %d", mType );
                          script::ModuleInfo sModuleInfo;
                          sModuleInfo.ModuleName = aModName;
                          sModuleInfo.ModuleSource = aSource;
                          sModuleInfo.ModuleType = mType;
--                        if ( mType == ModuleType::Form )
 +// ok, try always passing the model to basic, should fit
-+//                        if ( mType == ModuleType::Form )
+                         if ( mType == ModuleType::Form )
                              // hack, the module ( in document basic should...
                              // know the XModel... ) needs fixing in basic 
                              // somewhere
@@ -1237,7 +1581,7 @@
                      }
                      else
 diff --git xmlscript/inc/xmlscript/xmllib_imexp.hxx xmlscript/inc/xmlscript/xmllib_imexp.hxx
-index 9a3048f..81d8d43 100644
+index 9a3048f..f92b154 100644
 --- xmlscript/inc/xmlscript/xmllib_imexp.hxx
 +++ xmlscript/inc/xmlscript/xmllib_imexp.hxx
 @@ -34,11 +34,21 @@
@@ -1267,7 +1611,7 @@
  	sal_Bool bPasswordProtected;
  	::com::sun::star::uno::Sequence< ::rtl::OUString > aElementNames;
  	sal_Bool bPreload;
-+	ObjectModuleDescHash hCodeNameToObjDesc;
++	ObjectModuleDescHash hModuleTypeDesc;
  };
  
 +typedef std::hash_map< rtl::OUString, rtl::OUString, ::rtl::OUStringHash, ::std::equal_to< ::rtl::OUString > > CodeNameHash;
@@ -1318,7 +1662,7 @@
  
      virtual Reference< xml::input::XElement > SAL_CALL startChildElement(
 diff --git xmlscript/source/xmllib_imexp/xmllib_import.cxx xmlscript/source/xmllib_imexp/xmllib_import.cxx
-index b533d37..b04fb4e 100644
+index b533d37..ce31ee0 100644
 --- xmlscript/source/xmllib_imexp/xmllib_import.cxx
 +++ xmlscript/source/xmllib_imexp/xmllib_import.cxx
 @@ -44,7 +44,20 @@ namespace xmlscript
@@ -1396,7 +1740,7 @@
      if( !pLib )
          pLib = &static_cast< LibrariesElement* >( _pParent )->mLibDescriptors.back();
      pLib->aElementNames = aElementNames;
-+    pLib->hCodeNameToObjDesc = mObjectDescs;
++    pLib->hModuleTypeDesc = mObjectDescs;
  }
  
  



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