ooo-build r13662 - trunk/patches/vba



Author: noelpwer
Date: Mon Aug 25 08:42:35 2008
New Revision: 13662
URL: http://svn.gnome.org/viewvc/ooo-build?rev=13662&view=rev

Log:
tweak objectmodule creation, fix some misc bugs


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	Mon Aug 25 08:42:35 2008
@@ -47,7 +47,7 @@
  };
  
 diff --git basic/inc/basic/sbobjmod.hxx basic/inc/basic/sbobjmod.hxx
-index bdc23d9..ecc1a8c 100644
+index eeb7869..96cbe9b 100644
 --- basic/inc/basic/sbobjmod.hxx
 +++ basic/inc/basic/sbobjmod.hxx
 @@ -56,6 +56,7 @@ public:
@@ -58,15 +58,6 @@
  };
  
  class SbUserFormModule : public SbObjModule
-@@ -66,7 +67,7 @@ class SbUserFormModule : public SbObjMod
-     String sFormName;
-     SbUserFormModule( const SbUserFormModule& );
-     SbUserFormModule();
--
-+    bool mbInit;
- protected:
-     virtual void InitObject();
- public:
 diff --git basic/source/basmgr/basmgr.cxx basic/source/basmgr/basmgr.cxx
 index 4ac2e48..0a4ca77 100644
 --- basic/source/basmgr/basmgr.cxx
@@ -165,7 +156,7 @@
  	if( xScriptCont.is() )
  	{
 diff --git basic/source/classes/sbxmod.cxx basic/source/classes/sbxmod.cxx
-index 24921f8..d9f69e7 100644
+index bfb0cf6..fc164e6 100644
 --- basic/source/classes/sbxmod.cxx
 +++ basic/source/classes/sbxmod.cxx
 @@ -2233,25 +2233,26 @@ SbObjModule::SbObjModule( const com::sun
@@ -219,48 +210,6 @@
          {
  	    uno::Reference< awt::XTopWindow > xList( mxComponent, uno::UNO_QUERY_THROW );;
              //uno::Reference< awt::XWindow > xList( mxComponent, uno::UNO_QUERY_THROW );;
-@@ -2362,7 +2363,7 @@ public:
- };
- 
- SbUserFormModule::SbUserFormModule( const com::sun::star::script::ModuleInfo& mInfo, bool bIsCompat )
--    :SbObjModule( mInfo, bIsCompat )
-+    :SbObjModule( mInfo, bIsCompat ), mbInit( false )
- {
-         m_xModel.set( mInfo.ModuleObject, uno::UNO_QUERY_THROW );
- }
-@@ -2403,12 +2404,13 @@ void SbUserFormModule::triggerDeActivate
- }
- 
- void SbUserFormModule::triggerInitializeEvent( void )
--
- {
-+        if ( mbInit )
-+            return;
-         OSL_TRACE("**** SbUserFormModule::triggerInitializeEvent");
- 	static String aInitMethodName( RTL_CONSTASCII_USTRINGPARAM("Userform_Initialize") );
-+        mbInit = true;
- 	triggerMethod( aInitMethodName );
--
- }
- 
- void SbUserFormModule::triggerTerminateEvent( void )
-@@ -2416,6 +2418,7 @@ void SbUserFormModule::triggerTerminateE
-         OSL_TRACE("**** SbUserFormModule::triggerTerminateEvent");
- 	static String aTermMethodName( RTL_CONSTASCII_USTRINGPARAM("Userform_Terminate") );
- 	triggerMethod( aTermMethodName );
-+        mbInit=false;
- }
- 
- void SbUserFormModule::load()
-@@ -2473,7 +2476,7 @@ void SbUserFormModule::InitObject()
-             m_DialogListener = new FormObjEventListenerImpl( this, xComponent );
- 
-             // trigger initialise event
--            triggerInitializeEvent();
-+            //triggerInitializeEvent();
-         } 
-     }
-     catch( uno::Exception& e )
 diff --git basic/source/inc/namecont.hxx basic/source/inc/namecont.hxx
 index 3572d95..67d95bb 100644
 --- basic/source/inc/namecont.hxx
@@ -386,7 +335,7 @@
  
      static bool containsValidModule( const ::com::sun::star::uno::Any& _rElement );
 diff --git basic/source/runtime/step2.cxx basic/source/runtime/step2.cxx
-index 1f659e1..80d144f 100644
+index 1f659e1..7382974 100644
 --- basic/source/runtime/step2.cxx
 +++ basic/source/runtime/step2.cxx
 @@ -39,6 +39,7 @@
@@ -397,22 +346,16 @@
  
  #include <com/sun/star/container/XIndexAccess.hpp>
  #include <com/sun/star/script/XDefaultMethod.hpp>
-@@ -707,8 +708,12 @@ void SbiRuntime::StepELEM( UINT32 nOp1, 
- 	// zu fueh die Referenz verlieren
+@@ -708,7 +709,6 @@ void SbiRuntime::StepELEM( UINT32 nOp1, 
  	// #74254 Jetzt per Liste
  	if( pObj )
-+        {
-+	        SbUserFormModule* pUserForm = PTR_CAST(SbUserFormModule,(SbxVariable*) pObjVar);
-+                if ( pUserForm )
-+                    pUserForm->triggerInitializeEvent();
  		SaveRef( (SbxVariable*)pObj );
 -
-+        }
  	PushVar( FindElement( pObj, nOp1, nOp2, SbERR_NO_METHOD, FALSE ) );
  }
  
 diff --git basic/source/uno/namecont.cxx basic/source/uno/namecont.cxx
-index 5c9c44b..912fd80 100644
+index da495ca..a369363 100644
 --- basic/source/uno/namecont.cxx
 +++ basic/source/uno/namecont.cxx
 @@ -1,4 +1,5 @@
@@ -572,16 +515,47 @@
  {
      DBG_CTOR( SfxLibraryContainer, NULL );
  
-@@ -798,7 +898,7 @@ sal_Bool SfxLibraryContainer::init_Impl(
+@@ -798,11 +898,20 @@ sal_Bool SfxLibraryContainer::init_Impl(
                  OSL_ENSURE( 0, OUStringToOString( e.Message, RTL_TEXTENCODING_ASCII_US ).getStr() );
                  return sal_False;
              }
 -
-+            mbVBACompatModeOn = pLibArray->mbVBAMode; 
  		    sal_Int32 nLibCount = pLibArray->mnLibCount;
  		    for( sal_Int32 i = 0 ; i < nLibCount ; i++ )
  		    {
-@@ -1696,21 +1796,42 @@ void SfxLibraryContainer::implImportLibD
+ 			    ::xmlscript::LibDescriptor& rLib = pLibArray->mpLibs[i];
++        // mbVBACompatMode needs to be setup before createLibrary is called
++		// ( and this is called before the library desc. is read )
++        // this implies we need an xml property at the script-lc.xml
++		//
++
++		if ( rLib.aName.equalsAscii("Standard") )
++		{
++			OSL_TRACE("*** iteration %d have got Standard Library**** VBA MODE is %d", i, rLib.bVBAMode );
++           		    	mbVBACompatModeOn = rLib.bVBAMode;
++		}
+ 
+ 			    // Check storage URL
+ 			    OUString aStorageURL = rLib.aStorageURL;
+@@ -897,7 +1006,9 @@ sal_Bool SfxLibraryContainer::init_Impl(
+ 				    if( !pImplLib->mbInitialised && (!bStorage || xLibraryStor.is()) )
+ 				    {
+ 					    OUString aIndexFileName;
++						
+ 					    sal_Bool bLoaded = implLoadLibraryIndexFile( pImplLib, rLib, xLibraryStor, aIndexFileName );
++						OSL_TRACE("** Loaded %s", rtl::OUStringToOString( rLib.aName, RTL_TEXTENCODING_UTF8 ).getStr() );
+ 					    if( bLoaded && aLibName != rLib.aName )
+ 					    {
+ 						    OSL_ENSURE( 0, "Different library names in library"
+@@ -1140,6 +1251,7 @@ sal_Bool SfxLibraryContainer::init_Impl(
+ 						Reference< XNameContainer > xLib = createLibrary( aLibName );
+                			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
      {
  	    sal_Int32 nElementCount = rLib.aElementNames.getLength();
  	    const OUString* pElementNames = rLib.aElementNames.getConstArray();
@@ -604,6 +578,24 @@
 +                            // well really it needs the dialog library
 +                            if (  mInfo.ModuleType == ModuleType::Form )
 +                                mInfo.ModuleObject = mxOwnerDocument;
++                            else
++                            {
++                                try
++                                {
++                                    Reference< XMultiServiceFactory> xSF( mxOwnerDocument.get(), 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() )
++                                        mInfo.ModuleObject.set( xVBACodeNamedObjectAccess->getByName( mInfo.ModuleName ), uno::UNO_QUERY );
++                                }
++                                catch( Exception& e )
++                                { 
++                                    DBG_UNHANDLED_EXCEPTION();
++                                }
++
++                            }
 +                        }
 +                        aDummyElement <<= mInfo;
 +                    }
@@ -627,7 +619,7 @@
  // Methods of new XLibraryStorage interface?
  void SfxLibraryContainer::storeLibraries_Impl( const uno::Reference< embed::XStorage >& xStorage, sal_Bool bComplete )
  {
-@@ -1819,7 +1940,18 @@ void SfxLibraryContainer::storeLibraries
+@@ -1813,7 +1964,18 @@ void SfxLibraryContainer::storeLibraries
  		rLib.bPreload = pImplLib->mbPreload;
  		rLib.bPasswordProtected = pImplLib->mbPasswordProtected;
  		rLib.aElementNames = pImplLib->getElementNames();
@@ -641,13 +633,13 @@
 +		// so, leaving for the moment
 +		if ( pName->equals( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("Standard") ) ) )
 +		{
-+			pLibArray->mbVBAMode = getVBACompatModeOn();
++			rLib.bVBAMode = getVBACompatModeOn();
 +			rLib.hModuleTypeDesc = lcl_getObjModDescHash( *pImplLib );
 +		}
  		if( pImplLib->implIsModified() || bComplete )
  		{
              // Can we copy the storage?
-@@ -2283,13 +2415,29 @@ void SAL_CALL SfxLibraryContainer::loadL
+@@ -2277,13 +2439,29 @@ void SAL_CALL SfxLibraryContainer::loadL
  			}
  
  			Any aAny = importLibraryElement( aFile, xInStream );
@@ -677,7 +669,7 @@
  				pImplLib->maNameContainer.insertByName( aElementName, aAny );
              }
  		}
-@@ -2700,6 +2848,12 @@ OUString SfxLibraryContainer::expand_url
+@@ -2694,6 +2872,12 @@ OUString SfxLibraryContainer::expand_url
      return sal_False;
  }
  
@@ -1028,7 +1020,7 @@
  
  # ------------------------------------------------------------------
 diff --git sc/inc/document.hxx sc/inc/document.hxx
-index 6d361ae..ce9fdf0 100644
+index 8c50532..18b573a 100644
 --- sc/inc/document.hxx
 +++ sc/inc/document.hxx
 @@ -34,6 +34,7 @@
@@ -1038,8 +1030,8 @@
 +#include <com/sun/star/container/XNameAccess.hpp>
  #include <com/sun/star/uno/Reference.hxx>
  #include <vos/ref.hxx>
- #include "tabprotection.hxx"
-@@ -314,7 +315,7 @@ private:
+ #include "scdllapi.h"
+@@ -316,7 +317,7 @@ private:
  	Timer				aTrackTimer;
  
      com::sun::star::uno::Reference< com::sun::star::document::XVbaEventsHelper > mxVbaEventsHelper;
@@ -1048,7 +1040,7 @@
  public:
      ScTabOpList         aTableOpList;		            // list of ScInterpreterTableOpParams currently in use
      ScInterpreterTableOpParams  aLastTableOpParams;     // remember last params
-@@ -433,6 +434,7 @@ public:
+@@ -435,6 +436,7 @@ public:
  								SfxObjectShell* pDocShell = NULL );
  					~ScDocument();
  
@@ -1057,10 +1049,10 @@
  					GetServiceManager() const { return xServiceManager; }
  
 diff --git sc/source/core/data/documen2.cxx sc/source/core/data/documen2.cxx
-index 08912c2..60926e2 100644
+index 156b2ae..e29dc3c 100644
 --- sc/source/core/data/documen2.cxx
 +++ sc/source/core/data/documen2.cxx
-@@ -260,6 +260,7 @@ ScDocument::ScDocument( ScDocumentMode	e
+@@ -263,6 +263,7 @@ ScDocument::ScDocument( ScDocumentMode	e
  
  	aTrackTimer.SetTimeoutHdl( LINK( this, ScDocument, TrackTimeHdl ) );
  	aTrackTimer.SetTimeout( 100 );
@@ -1069,7 +1061,7 @@
  
  
 diff --git sc/source/core/data/document.cxx sc/source/core/data/document.cxx
-index c5dc8b8..f1766c0 100644
+index 886156d..680a311 100644
 --- sc/source/core/data/document.cxx
 +++ sc/source/core/data/document.cxx
 @@ -91,6 +91,9 @@
@@ -1082,7 +1074,7 @@
  
  struct ScDefaultAttr
  {
-@@ -4865,5 +4868,30 @@ BOOL ScDocument::NeedPageResetAfterTab( 
+@@ -4891,5 +4894,30 @@ BOOL ScDocument::NeedPageResetAfterTab( 
  	return FALSE;		// sonst nicht
  }
  
@@ -1114,7 +1106,7 @@
  
  
 diff --git sc/source/filter/excel/excimp8.cxx sc/source/filter/excel/excimp8.cxx
-index fa27688..7028b3d 100644
+index fa27688..aff8877 100644
 --- sc/source/filter/excel/excimp8.cxx
 +++ sc/source/filter/excel/excimp8.cxx
 @@ -103,6 +103,7 @@
@@ -1136,53 +1128,8 @@
  
  ImportExcel8::ImportExcel8( XclImpRootData& rImpData, SvStream& rStrm ) :
      ImportExcel( rImpData, rStrm ), mnTab(0)
-@@ -290,6 +291,44 @@ void ImportExcel8::ReadBasic( void )
- 			bool bAsComment = !bLoadExecutable || !lcl_hasVBAEnabled();
-             aBasicImport.Import( EXC_STORAGE_VBA_PROJECT, EXC_STORAGE_VBA, bAsComment );
-             GetObjectManager().SetOleNameOverrideInfo( aBasicImport.ControlNameForObjectId() );
-+            // for each document module get the associated object for the codename and do a replacebyname
-+            ScDocument& aDoc = GetDoc();
-+            uno::Reference< script::XLibraryContainer > xLibContainer = GetDocShell()->GetBasicContainer();
-+            uno::Reference< container::XNameContainer > xLib;
-+            if( xLibContainer.is() )
-+            {
-+                String aLibName( RTL_CONSTASCII_USTRINGPARAM( "Standard" ) );
-+                uno::Any aLibAny = xLibContainer->getByName( aLibName );
-+                aLibAny >>= xLib;
-+            }
-+            if ( xLib.is() )
-+            {
-+                rtl::OUString sOUCodeName( aDoc.GetCodeName() );
-+                if ( xLib->hasByName( sOUCodeName ) )
-+                {
-+                    script::ModuleInfo mInfo;
-+                    xLib->getByName( sOUCodeName ) >>= mInfo; 
-+                    String sTmp = sOUCodeName;
-+                    mInfo.ModuleObject = lcl_InitModuleInfo( *GetDocShell(), sTmp ).ModuleObject;
-+                    xLib->replaceByName( sOUCodeName, uno::makeAny( mInfo ) );
-+			
-+                }
-+                SCTAB nCount = aDoc.GetTableCount();
-+    
-+                for( SCTAB i = 0; i < nCount; ++i )
-+                {
-+                    String sName;
-+                    aDoc.GetCodeName( i, sName );
-+                    sOUCodeName = sName;
-+                    if ( xLib->hasByName( sOUCodeName ) )
-+                    {
-+                        script::ModuleInfo mInfo;
-+                        xLib->getByName( sOUCodeName ) >>= mInfo; 
-+                        mInfo.ModuleObject = lcl_InitModuleInfo( *GetDocShell(), sName ).ModuleObject;
-+                        xLib->replaceByName( sOUCodeName, uno::makeAny( mInfo ) );
-+                    }
-+                }
-+            }
-         }
-     }
- }
 diff --git sc/source/filter/xml/xmlsubti.cxx sc/source/filter/xml/xmlsubti.cxx
-index ab00932..f8674ae 100644
+index ab00932..05871e7 100644
 --- sc/source/filter/xml/xmlsubti.cxx
 +++ sc/source/filter/xml/xmlsubti.cxx
 @@ -228,6 +228,7 @@ void ScMyTables::NewSheet(const rtl::OUS
@@ -1193,7 +1140,7 @@
                      xCurrentSheet.set(xIndex->getByIndex(nCurrentSheet), uno::UNO_QUERY);
  					if ( xCurrentSheet.is() )
  					{
-@@ -254,6 +255,25 @@ void ScMyTables::NewSheet(const rtl::OUS
+@@ -254,6 +255,27 @@ void ScMyTables::NewSheet(const rtl::OUS
  									}
  								}
  						}
@@ -1204,12 +1151,14 @@
 +						{
 +							String sName;
 +							pDoc->GetName( nCurrentSheet, sName );
++							OSL_TRACE("** import processing %s", rtl::OUStringToOString( sName, RTL_TEXTENCODING_UTF8 ).getStr() );
 +	                        rtl::OUString sOUName( sName );
 +							uno::Reference< container::XNameAccess > xCodeNames( pDoc->GetPersistedCodeNames() );
 +							if( xCodeNames.is() && xCodeNames->hasByName( sName ) )
 +							{
 +								rtl::OUString sOUSCodeName;
 +								xCodeNames->getByName( sName ) >>= sOUSCodeName;
++							    OSL_TRACE("** import processing setting codename %s for %s", rtl::OUStringToOString( sOUSCodeName, RTL_TEXTENCODING_UTF8 ).getStr(), rtl::OUStringToOString( sName, RTL_TEXTENCODING_UTF8 ).getStr() );
 +								rImport.LockSolarMutex();
 +								String sCodeName( sOUSCodeName );
 +								pDoc->SetCodeName( nCurrentSheet, sCodeName );		
@@ -1220,7 +1169,7 @@
  
                          if ( sStyleName.getLength() )
 diff --git sc/source/ui/docshell/docfunc.cxx sc/source/ui/docshell/docfunc.cxx
-index 105f743..91ff9f7 100644
+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
@@ -1290,20 +1239,31 @@
          pDoc->SetCodeName( nTab, sCodeName );
      }
      SFX_APP()->LeaveBasicCall();
-@@ -2116,8 +2120,10 @@ BOOL ScDocFunc::InsertTable( SCTAB nTab,
+@@ -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 
-+    StarBASIC* pStarBASIC = rDocShell.GetBasic(); 
-+    BOOL bVbaEnabled = pStarBASIC ? pStarBASIC->isVBAEnabled() : false;
- 	if (bRecord && !pDoc->IsUndoEnabled())
++    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 )
-@@ -2132,13 +2138,16 @@ BOOL ScDocFunc::InsertTable( SCTAB nTab,
+-    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 ))
  	{
@@ -1314,7 +1274,7 @@
  		//	Views updaten:
 -        if( bVbaEnabled )
 +        // Only insert vba modules if vba mode ( and not currently importing XML )
-+        if( bVbaEnabled && !rDocShell.GetDocument()->IsImportingXML() )
++        if( bInsertDocModule )
          {
 -            String sCodeName( rName );
 +            if ( sCodeName.Len() == 0 )
@@ -1323,7 +1283,7 @@
          }
  		rDocShell.Broadcast( ScTablesHint( SC_TAB_INSERTED, nTab ) );
 diff --git sc/source/ui/docshell/docsh.cxx sc/source/ui/docshell/docsh.cxx
-index c702954..5ce0d4b 100644
+index 2d114ff..5eff243 100644
 --- sc/source/ui/docshell/docsh.cxx
 +++ sc/source/ui/docshell/docsh.cxx
 @@ -131,6 +131,7 @@
@@ -1334,13 +1294,10 @@
  
  using namespace com::sun::star;
  using namespace com::sun::star::document::VbaEventId;
-@@ -535,6 +536,45 @@ void ScDocShell::BeforeXMLLoading()
+@@ -535,6 +536,14 @@ void ScDocShell::BeforeXMLLoading()
  		ScColumn::bDoubleAlloc = sal_True;
  }
  
-+// defined in docfunc.cxx ( really this needs a new name )
-+uno::Reference< uno::XInterface > GetDocModuleObject( SfxObjectShell& rDocSh, String& sCodeName );
-+
 +rtl::OUString GetCodeName( ScDocument& aDocument, String& sObjectName )
 +{
 +    uno::Reference< container::XNameAccess > xCodeNames( aDocument.GetPersistedCodeNames() );
@@ -1349,41 +1306,17 @@
 +    return sOUSCodeName;
 +}
 +
-+void SetDocModuleForCodeName( ScDocument& aDocument, String& sCodeName )
-+{
-+    uno::Reference< script::XLibraryContainer > xLibContainer = aDocument.GetDocumentShell()->GetBasicContainer();
-+    uno::Reference< container::XNameContainer > xLib;
-+
-+    if( xLibContainer.is() )
-+    {
-+        String aLibName( RTL_CONSTASCII_USTRINGPARAM( "Standard" ) );
-+        uno::Any aLibAny = xLibContainer->getByName( aLibName );
-+        aLibAny >>= xLib;
-+    }
-+
-+    if ( xLib.is() )
-+    {
-+        rtl::OUString sOUCodeName( sCodeName );
-+        script::ModuleInfo mInfo;
-+        if ( xLib->getByName( sOUCodeName ) >>= mInfo )
-+        {
-+            mInfo.ModuleObject = GetDocModuleObject( *aDocument.GetDocumentShell(), sCodeName );
-+            xLib->replaceByName( sOUCodeName, uno::makeAny( mInfo ) );         
-+        }
-+        else
-+        {
-+            // Insert a big fat assertion etc
-+        }
-+    }
-+}
-+
  void ScDocShell::AfterXMLLoading(sal_Bool bRet)
  {
  	if (GetCreateMode() != SFX_CREATE_MODE_ORGANIZER)
-@@ -610,6 +650,29 @@ void ScDocShell::AfterXMLLoading(sal_Boo
+@@ -608,8 +617,32 @@ void ScDocShell::AfterXMLLoading(sal_Boo
+ 
+         // suppress VBA events when loading the xml
          uno::Reference< document::XVbaEventsHelper > xEvt( aDocument.GetVbaEventsHelper() );
++	OSL_TRACE("About to enable events again");
          if ( xEvt.is() )
              xEvt->setIgnoreEvents( sal_False );
++/*
 +        // SetCodenames for each tab  ( and set up the vba DOC Modules ) 
 +        SCTAB nTabCount = aDocument.GetTableCount();
 +        for (SCTAB i = 0; i < nTabCount; ++i)
@@ -1396,7 +1329,6 @@
 +                {
 +                    sObjectName = String( RTL_CONSTASCII_USTRINGPARAM("ThisWorkbook") );
 +                    sCodeName = GetCodeName( aDocument, sObjectName );
-+                    SetDocModuleForCodeName( aDocument, sCodeName );
 +                }
 +                aDocument.GetName( i, sObjectName );
 +                sCodeName = GetCodeName( aDocument, sObjectName );
@@ -1406,12 +1338,12 @@
 +            {
 +            }
 +        }
-+            
++ */           
  	aDocument.SetImportingXML( FALSE );
      aDocument.EnableUndo( TRUE );
      bIsEmpty = FALSE;
 diff --git sc/source/ui/vba/vbaeventshelper.cxx sc/source/ui/vba/vbaeventshelper.cxx
-index 7e1e1c5..1287c13 100644
+index 7e1e1c5..65bc73a 100644
 --- sc/source/ui/vba/vbaeventshelper.cxx
 +++ sc/source/ui/vba/vbaeventshelper.cxx
 @@ -620,7 +620,7 @@ String ScVbaEventsHelper::getSheetModule
@@ -1423,8 +1355,17 @@
  	// 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..14ed343 100644
+index 7acf7db..39dae92 100644
 --- svx/source/msfilter/svxmsbas.cxx
 +++ svx/source/msfilter/svxmsbas.cxx
 @@ -54,6 +54,7 @@ using namespace com::sun::star::awt;
@@ -1451,13 +1392,13 @@
                  Reference< XMultiServiceFactory> xSF(rDocSh.GetModel(), UNO_QUERY);
                  if ( xSF.is() )
                  {
-@@ -425,20 +427,24 @@ BOOL SvxImportMSVBasic::ImportCode_Impl(
+@@ -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 ( true )
++                    if ( !bAsComment )
                      {
                          OSL_TRACE("vba processing  %d", mType );
                          script::ModuleInfo sModuleInfo;
@@ -1466,19 +1407,34 @@
                          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 ( 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 );
-+*/
+-                        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..8d8930d 100644
+index 9a3048f..93826a9 100644
 --- xmlscript/inc/xmlscript/xmllib_imexp.hxx
 +++ xmlscript/inc/xmlscript/xmllib_imexp.hxx
 @@ -34,11 +34,21 @@
@@ -1504,11 +1460,15 @@
  //==============================================================================
  // Library container export
  // HACK C++ struct to transport info. Later the container 
-@@ -53,14 +63,18 @@ struct LibDescriptor
+@@ -51,10 +61,15 @@ struct LibDescriptor
+ 	sal_Bool bLink;
+ 	sal_Bool bReadOnly;
  	sal_Bool bPasswordProtected;
++	sal_Bool bVBAMode;
  	::com::sun::star::uno::Sequence< ::rtl::OUString > aElementNames;
  	sal_Bool bPreload;
 +	ObjectModuleDescHash hModuleTypeDesc;
++	LibDescriptor(); 
  };
  
 +typedef std::hash_map< rtl::OUString, rtl::OUString, ::rtl::OUStringHash, ::std::equal_to< ::rtl::OUString > > CodeNameHash;
@@ -1516,15 +1476,7 @@
  struct LibDescriptorArray
  {
      LibDescriptor* mpLibs;
-     sal_Int32 mnLibCount;
- 
--    LibDescriptorArray( void ) { mpLibs = NULL; mnLibCount = 0; }
-+    bool mbVBAMode;
-+    LibDescriptorArray( void ) { mpLibs = NULL; mnLibCount = 0; mbVBAMode = false; }
-     LibDescriptorArray( sal_Int32 nLibCount );
- 
-     ~LibDescriptorArray();
-@@ -79,6 +93,11 @@ SAL_CALL exportLibraryContainer(
+@@ -79,6 +94,11 @@ SAL_CALL exportLibraryContainer(
  SAL_CALL importLibraryContainer( LibDescriptorArray* pLibArray )
  		SAL_THROW( (::com::sun::star::uno::Exception) );
  
@@ -1558,7 +1510,7 @@
  
      virtual Reference< xml::input::XElement > SAL_CALL startChildElement(
 diff --git xmlscript/source/xmllib_imexp/xmllib_export.cxx xmlscript/source/xmllib_imexp/xmllib_export.cxx
-index 4f6de54..9f48234 100644
+index 4f6de54..1ee7c50 100644
 --- xmlscript/source/xmllib_imexp/xmllib_export.cxx
 +++ xmlscript/source/xmllib_imexp/xmllib_export.cxx
 @@ -44,6 +44,28 @@ namespace xmlscript
@@ -1590,41 +1542,38 @@
  //##################################################################################################
  
  
-@@ -73,11 +95,31 @@ SAL_CALL exportLibraryContainer(
+@@ -73,11 +95,10 @@ SAL_CALL exportLibraryContainer(
  	pLibsElement->addAttribute( OUString( RTL_CONSTASCII_USTRINGPARAM("xmlns:" XMLNS_XLINK_PREFIX) ),
  							    OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_XLINK_URI) ) );
  
-+    int nLibCount = pLibArray->mnLibCount;
-+	if ( pLibArray->mbVBAMode )
-+		pLibsElement->addAttribute( OUString( RTL_CONSTASCII_USTRINGPARAM( XMLNS_LIBRARY_PREFIX ":vbaenabled") ), aTrueStr );
- 
+-
 -	xOut->ignorableWhitespace( OUString() );
++    int nLibCount = pLibArray->mnLibCount;
  	xOut->startElement( aLibrariesName, xAttributes );
 +	xOut->ignorableWhitespace( OUString() );
  
 -    int nLibCount = pLibArray->mnLibCount;
-+/*
-+	if ( pLibArray->mbVBAMode )
-+	{
-+		CodeNameHash::const_iterator it_end = pLibArray->mCodeNames.end();
-+		for ( CodeNameHash::const_iterator it =  pLibArray->mCodeNames.begin() ; it!=it_end; ++it )
-+		{
-+			OUString aCodeName( RTL_CONSTASCII_USTRINGPARAM(XMLNS_LIBRARY_PREFIX ":codename") );
-+			XMLElement* pLibElement = new XMLElement( aCodeName );
-+			Reference< xml::sax::XAttributeList > xLibElementAttribs;
-+			xLibElementAttribs = static_cast< xml::sax::XAttributeList* >( pLibElement );
-+
-+			pLibElement->addAttribute( OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_LIBRARY_PREFIX ":name") ), it->first );
-+			pLibElement->addAttribute( OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_LIBRARY_PREFIX ":objectname") ), it->second );
-+			pLibElement->dump( xOut.get() );
-+		
-+		}
-+	}
-+*/
  	for( sal_Int32 i = 0 ; i < nLibCount ; i++ )
  	{
  		LibDescriptor& rLib = pLibArray->mpLibs[i];
-@@ -157,6 +199,7 @@ SAL_CALL exportLibrary(
+@@ -108,6 +129,9 @@ SAL_CALL exportLibraryContainer(
+ 								        rLib.bReadOnly ? aTrueStr : aFalseStr );
+         }
+ 
++    if( rLib.bVBAMode )
++		pLibElement->addAttribute( OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_LIBRARY_PREFIX ":vbaenabled") ), aTrueStr );
++
+ 		pLibElement->dump( xOut.get() );
+ 	}
+ 
+@@ -153,10 +177,14 @@ SAL_CALL exportLibrary(
+     if( rLib.bPreload )
+ 		pLibElement->addAttribute( OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_LIBRARY_PREFIX ":preload") ), aTrueStr );
+ 
++/*    if( rLib.bVBAMode )
++		pLibElement->addAttribute( OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_LIBRARY_PREFIX ":vbaenabled") ), aTrueStr );
++*/
+ 	sal_Int32 nElementCount = rLib.aElementNames.getLength();
  	if( nElementCount )
  	{
  		const OUString* pElementNames = rLib.aElementNames.getConstArray();
@@ -1632,7 +1581,7 @@
  		for( sal_Int32 i = 0 ; i < nElementCount ; i++ )
  		{
  			XMLElement* pElement = new XMLElement( OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_LIBRARY_PREFIX ":element" ) ) );
-@@ -165,7 +208,16 @@ SAL_CALL exportLibrary(
+@@ -165,7 +193,16 @@ SAL_CALL exportLibrary(
  
  			pElement->addAttribute( OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_LIBRARY_PREFIX ":name") ),
  										pElementNames[i] );
@@ -1651,7 +1600,7 @@
  		}
  	}
 diff --git xmlscript/source/xmllib_imexp/xmllib_import.cxx xmlscript/source/xmllib_imexp/xmllib_import.cxx
-index b533d37..48fc051 100644
+index b533d37..24b2834 100644
 --- xmlscript/source/xmllib_imexp/xmllib_import.cxx
 +++ xmlscript/source/xmllib_imexp/xmllib_import.cxx
 @@ -44,7 +44,20 @@ namespace xmlscript
@@ -1676,20 +1625,31 @@
  //__________________________________________________________________________________________________
  Reference< xml::input::XElement > LibElementBase::getParent()
      throw (RuntimeException)
-@@ -185,6 +198,13 @@ Reference< xml::input::XElement > Librar
+@@ -206,7 +219,11 @@ Reference< xml::input::XElement > Librar
+             &aDesc.bPreload,
+             OUString( RTL_CONSTASCII_USTRINGPARAM("preload") ),
+             xAttributes, XMLNS_LIBRARY_UID );
+-
++/*        getBoolAttr(
++            &aDesc.bVBAMode,
++            OUString( RTL_CONSTASCII_USTRINGPARAM("vbaenabled") ),
++            xAttributes, XMLNS_LIBRARY_UID );
++*/
+         return new LibraryElement( rLocalName, xAttributes, 0, this );
      }
-     else if (mpLibArray && rLocalName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("libraries") ))
-     {
-+        rtl::OUString sVbaCompatMode;
-+        sVbaCompatMode =  xAttributes->getValueByUidName(
-+            XMLNS_LIBRARY_UID,
-+            OUString( RTL_CONSTASCII_USTRINGPARAM("vbaenabled") ) );
-+
-+        if ( sVbaCompatMode.equalsIgnoreAsciiCase( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("true") ) ) )
-+            mpLibArray->mbVBAMode = true;
-         return new LibrariesElement( rLocalName, xAttributes, 0, this );
+     else
+@@ -265,7 +282,10 @@ Reference< xml::input::XElement > Librar
+             &aDesc.bPasswordProtected,
+             OUString( RTL_CONSTASCII_USTRINGPARAM("passwordprotected") ),
+             xAttributes, _pImport->XMLNS_LIBRARY_UID );
+-
++        getBoolAttr(
++            &aDesc.bVBAMode,
++            OUString( RTL_CONSTASCII_USTRINGPARAM("vbaenabled") ),
++            xAttributes, _pImport->XMLNS_LIBRARY_UID );
+         mLibDescriptors.push_back( aDesc );
+         return new LibraryElement( rLocalName, xAttributes, this, _pImport );
      }
-     else if (mpLibDesc && rLocalName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("library") ))
 @@ -312,6 +332,17 @@ Reference< xml::input::XElement > Librar
          if (aValue.getLength())
              mElements.push_back( aValue );
@@ -1732,11 +1692,17 @@
  //##################################################################################################
  
  ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XDocumentHandler >
-@@ -365,6 +406,7 @@ LibDescriptorArray::LibDescriptorArray( 
- {
-     mnLibCount = nLibCount;
-     mpLibs = new LibDescriptor[ mnLibCount ];
-+    mbVBAMode = false;
- }
+@@ -360,6 +401,13 @@ SAL_CALL importLibrary( LibDescriptor& r
  
- LibDescriptorArray::~LibDescriptorArray()
+ 
+ //##################################################################################################
++LibDescriptor::LibDescriptor()
++{
++    bLink = sal_False;
++    bReadOnly = sal_False;
++    bPasswordProtected = sal_False;
++    bVBAMode = sal_False;
++}
+ 
+ LibDescriptorArray::LibDescriptorArray( sal_Int32 nLibCount )
+ {



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