ooo-build r12528 - in trunk: . patches/dev300 patches/test/vba patches/vba



Author: noelpwer
Date: Tue May 13 16:11:44 2008
New Revision: 12528
URL: http://svn.gnome.org/viewvc/ooo-build?rev=12528&view=rev

Log:
2008-05-13  Noel Power  <noel power novell com>

        * patches/dev300/apply: split the Userform stuff into ObjectModule
        & Userform specific patches, some minor tweaking as well. Added
        to Untested ( e.g. Experimental section )
        * patches/test/vba/UserFormObjectModuleEventsSuperBigPatch.diff:  not
        so big anymore ;-)
        * patches/vba/ObjectModule.diff


Added:
   trunk/patches/vba/ObjectModule.diff
Modified:
   trunk/ChangeLog
   trunk/patches/dev300/apply
   trunk/patches/test/vba/UserFormObjectModuleEventsSuperBigPatch.diff

Modified: trunk/patches/dev300/apply
==============================================================================
--- trunk/patches/dev300/apply	(original)
+++ trunk/patches/dev300/apply	Tue May 13 16:11:44 2008
@@ -1493,7 +1493,9 @@
 vba-always-set-defaultprop.diff, n#388049, noelpwer
 [ VBAUntested ]
 SectionOwner => noelpwer
-# total hack at the moment
+# getting there
+ObjectModule.diff
+# total hack at the moment, getting smaller
 UserFormObjectModuleEventsSuperBigPatch.diff
 # start LCL hacks
 # incomplete solution ( works for import of ocx radio buttons only )

Modified: trunk/patches/test/vba/UserFormObjectModuleEventsSuperBigPatch.diff
==============================================================================
--- trunk/patches/test/vba/UserFormObjectModuleEventsSuperBigPatch.diff	(original)
+++ trunk/patches/test/vba/UserFormObjectModuleEventsSuperBigPatch.diff	Tue May 13 16:11:44 2008
@@ -1,1664 +1,76 @@
---- /dev/null	2007-05-04 11:54:36.000000000 +0100
-+++ udkapi/com/sun/star/script/ModuleType.idl	2008-03-28 10:30:33.000000000 +0000
-@@ -0,0 +1,58 @@
-+/*************************************************************************
-+ *
-+ *  OpenOffice.org - a multi-platform office productivity suite
-+ *
-+ *  $RCSfile: ModuleType.idl,v $
-+ *
-+ *  $Revision: 1.2 $
-+ *
-+ *  last change: $Author: rt $ $Date: 2006/05/05 10:14:46 $
-+ *
-+ *  The Contents of this file are made available subject to
-+ *  the terms of GNU Lesser General Public License Version 2.1.
-+ *
-+ *
-+ *    GNU Lesser General Public License Version 2.1
-+ *    =============================================
-+ *    Copyright 2005 by Sun Microsystems, Inc.
-+ *    901 San Antonio Road, Palo Alto, CA 94303, USA
-+ *
-+ *    This library is free software; you can redistribute it and/or
-+ *    modify it under the terms of the GNU Lesser General Public
-+ *    License version 2.1, as published by the Free Software Foundation.
-+ *
-+ *    This library 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 for more details.
-+ *
-+ *    You should have received a copy of the GNU Lesser General Public
-+ *    License along with this library; if not, write to the Free Software
-+ *    Foundation, Inc., 59 Temple Place, Suite 330, Boston,
-+ *    MA  02111-1307  USA
-+ *
-+ ************************************************************************/
-+
-+#ifndef __com_sun_star_script_ModuleType_idl__
-+#define __com_sun_star_script_ModuleType_idl__
-+
-+#ifndef __com_sun_star_uno_XInterface_idl__
-+#include <com/sun/star/uno/XInterface.idl>
-+#endif
-+
-+//=============================================================================
-+module com {  module sun {  module star { module script {
-+published constants ModuleType
-+{
-+    const long Unknown = 0;
-+    const long Normal = 1;  
-+    const long Class = 2;
-+    const long Form = 3;
-+    const long Document = 4;
-+};
-+
-+//=============================================================================
-+
-+}; }; }; };
-+
-+#endif
---- /dev/null	2007-05-04 11:54:36.000000000 +0100
-+++ udkapi/com/sun/star/script/ModuleInfo.idl	2008-03-28 10:30:33.000000000 +0000
-@@ -0,0 +1,57 @@
-+/*************************************************************************
-+ *
-+ *  OpenOffice.org - a multi-platform office productivity suite
-+ *
-+ *  $RCSfile: ModuleInfo.idl,v $
-+ *
-+ *  $Revision: 1.2 $
-+ *
-+ *  last change: $Author: rt $ $Date: 2006/05/05 10:14:46 $
-+ *
-+ *  The Contents of this file are made available subject to
-+ *  the terms of GNU Lesser General Public License Version 2.1.
-+ *
-+ *
-+ *    GNU Lesser General Public License Version 2.1
-+ *    =============================================
-+ *    Copyright 2005 by Sun Microsystems, Inc.
-+ *    901 San Antonio Road, Palo Alto, CA 94303, USA
-+ *
-+ *    This library is free software; you can redistribute it and/or
-+ *    modify it under the terms of the GNU Lesser General Public
-+ *    License version 2.1, as published by the Free Software Foundation.
-+ *
-+ *    This library 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 for more details.
-+ *
-+ *    You should have received a copy of the GNU Lesser General Public
-+ *    License along with this library; if not, write to the Free Software
-+ *    Foundation, Inc., 59 Temple Place, Suite 330, Boston,
-+ *    MA  02111-1307  USA
-+ *
-+ ************************************************************************/
-+
-+#ifndef __com_sun_star_script_ModuleInfo_idl__
-+#define __com_sun_star_script_ModuleInfo_idl__
-+
-+#ifndef __com_sun_star_uno_XInterface_idl__
-+#include <com/sun/star/uno/XInterface.idl>
-+#endif
-+
-+//=============================================================================
-+module com {  module sun {  module star { module script {
-+struct ModuleInfo
-+{
-+	string ModuleName; 
-+	string ModuleSource; 
-+	com::sun::star::uno::XInterface ModuleObjectProvider; 
-+	short ModuleType; // string?
-+};
-+
-+//=============================================================================
-+
-+}; }; }; };
-+
-+#endif
---- /dev/null	2007-05-04 11:54:36.000000000 +0100
-+++ udkapi/com/sun/star/script/XObjectProvider.idl	2008-03-28 10:30:33.000000000 +0000
-@@ -0,0 +1,52 @@
-+/*************************************************************************
-+ *
-+ *  OpenOffice.org - a multi-platform office productivity suite
-+ *
-+ *  $RCSfile: XDefaultMethod.idl,v $
-+ *
-+ *  $Revision: 1.3 $
-+ *
-+ *  last change: $Author: vg $ $Date: 2006/11/02 16:34:45 $
-+ *
-+ *  The Contents of this file are made available subject to
-+ *  the terms of GNU Lesser General Public License Version 2.1.
-+ *
-+ *
-+ *    GNU Lesser General Public License Version 2.1
-+ *    =============================================
-+ *    Copyright 2005 by Sun Microsystems, Inc.
-+ *    901 San Antonio Road, Palo Alto, CA 94303, USA
-+ *
-+ *    This library is free software; you can redistribute it and/or
-+ *    modify it under the terms of the GNU Lesser General Public
-+ *    License version 2.1, as published by the Free Software Foundation.
-+ *
-+ *    This library 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 for more details.
-+ *
-+ *    You should have received a copy of the GNU Lesser General Public
-+ *    License along with this library; if not, write to the Free Software
-+ *    Foundation, Inc., 59 Temple Place, Suite 330, Boston,
-+ *    MA  02111-1307  USA
-+ *
-+ ************************************************************************/
-+
-+#ifndef __com_sun_star_script_XObjectProvider_idl__
-+#define __com_sun_star_script_XObjectProvider_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 XObjectProvider : ::com::sun::star::uno::XInterface
-+{
-+  any getObject();
-+
-+};
-+
-+};  };  };  };
-+#endif
-diff -rup /data4/OOOBuildM12/ooo-build/build/ooh680-m12/udkapi/com/sun/star/script/makefile.mk udkapi/com/sun/star/script/makefile.mk
---- /data4/OOOBuildM12/ooo-build/build/ooh680-m12/udkapi/com/sun/star/script/makefile.mk	2008-03-29 23:08:19.000000000 +0000
-+++ udkapi/com/sun/star/script/makefile.mk	2008-03-28 10:30:33.000000000 +0000
-@@ -89,6 +89,9 @@ IDLFILES=\
- 	XScriptEventsAttacher.idl\
- 	XDefaultMethod.idl\
- 	XDefaultProperty.idl\
-+    ModuleInfo.idl\
-+    ModuleType.idl\
-+    XObjectProvider.idl\
- 	DateType.idl\
- 
- # ------------------------------------------------------------------
-diff -rup /data4/OOOBuildM12/ooo-build/build/ooh680-m12/svx/source/msfilter/msvbasic.cxx svx/source/msfilter/msvbasic.cxx
---- /data4/OOOBuildM12/ooo-build/build/ooh680-m12/svx/source/msfilter/msvbasic.cxx	2006-09-17 06:28:12.000000000 +0100
-+++ svx/source/msfilter/msvbasic.cxx	2008-03-28 10:30:33.000000000 +0000
-@@ -54,6 +54,8 @@
- #include "msvbasic.hxx"
- #endif
- 
-+using namespace ::com::sun::star::script;
-+
- /*
- A few urls which may in the future be of some use
- http://www.virusbtn.com/vb2000/Programme/papers/bontchev.pdf
-@@ -445,7 +447,7 @@ int VBA_Impl::ReadVBAProject(const SvSto
-  *
- */
- 
--ModuleType VBA_Impl::GetModuleType( const UniString& rModuleName )
-+ModType VBA_Impl::GetModuleType( const UniString& rModuleName )
- {
-     ModuleTypeHash::iterator iter = mhModHash.find( rModuleName );
-     ModuleTypeHash::iterator iterEnd = mhModHash.end();
-@@ -453,7 +455,7 @@ ModuleType VBA_Impl::GetModuleType( cons
-     {
-         return iter->second;
-     }
--    return Unknown;
-+    return ModuleType::Unknown;
- }
- 
- bool VBA_Impl::Open( const String &rToplevel, const String &rSublevel )
-@@ -496,7 +498,7 @@ bool VBA_Impl::Open( const String &rTopl
-         static const String sClass(     RTL_CONSTASCII_USTRINGPARAM( "Class" ) );
-         static const String sBaseClass( RTL_CONSTASCII_USTRINGPARAM( "BaseClass" ) );
-         static const String sDocument(  RTL_CONSTASCII_USTRINGPARAM( "Document" ) );
--        mhModHash[ sThisDoc ] = Class;
-+        mhModHash[ sThisDoc ] = ModuleType::Class;
-         while ( pStp->ReadByteStringLine( tmp, meCharSet ) )
-         {
-             xub_StrLen index = tmp.Search( '=' );
-@@ -506,14 +508,14 @@ bool VBA_Impl::Open( const String &rTopl
-                 String value = tmp.Copy( index + 1 );
-                 if ( key == sClass )
-                 {
--                    mhModHash[ value ] = Class;
-+                    mhModHash[ value ] = ModuleType::Class;
-                     OSL_TRACE("Module %s is of type Class",
-                         ::rtl::OUStringToOString( value ,
-                             RTL_TEXTENCODING_ASCII_US ).pData->buffer );
-                 }
-                 else if ( key == sBaseClass )
-                 {
--                    mhModHash[ value ] =  Form;
-+                    mhModHash[ value ] =  ModuleType::Form;
-                     OSL_TRACE("Module %s is of type Form",
-                         ::rtl::OUStringToOString( value ,
-                             RTL_TEXTENCODING_ASCII_US ).pData->buffer );
-@@ -526,14 +528,14 @@ bool VBA_Impl::Open( const String &rTopl
-                     // value is of form <name>/&H<identifier>, strip the identifier
-                     value.Erase( value.Search( '/' ) );
- 
--                    mhModHash[ value ] = Document;
-+                    mhModHash[ value ] = ModuleType::Document;
-                     OSL_TRACE("Module %s is of type Document VBA",
-                         ::rtl::OUStringToOString( value ,
-                             RTL_TEXTENCODING_ASCII_US ).pData->buffer );
-                 }
-                 else if ( key == sModule )
-                 {
--                    mhModHash[ value ] = Normal;
-+                    mhModHash[ value ] = ModuleType::Normal;
-                     OSL_TRACE("Module %s is of type Normal VBA",
-                         ::rtl::OUStringToOString( value ,
-                             RTL_TEXTENCODING_ASCII_US ).pData->buffer );
---- svx/source/msfilter/msvbasic.hxx	2008-04-11 03:07:15.000000000 +0100
-+++ svx.patched/source/msfilter/msvbasic.hxx	2008-05-09 17:13:58.000000000 +0100
-@@ -45,6 +45,8 @@
- #include <vector>
- #endif
- #include<map>
-+#include <com/sun/star/script/ModuleType.hpp>
-+using namespace ::com::sun::star::script::ModuleType;
- 
- /* class VBA:
-  * The VBA class provides a set of methods to handle Visual Basic For
-@@ -68,13 +70,12 @@ DECLARE_DYNARRAY(StringArray,String *)
- // #117718# define internal types to distinguish between
- // module types, form, class & normal
- // #i37965# DR 2004-12-03: add "Document", used in Excel for macros attached to sheet
--enum ModuleType { Unknown = 0, Normal, Class, Form, Document };
- 
- // #117718# define map to hold types of module
- //
--
-+typedef sal_Int32 ModType;
- typedef ::std::map< UniString,
--    ModuleType > ModuleTypeHash;
-+    ModType > ModuleTypeHash;
- 
- class VBA_Impl
- {
-@@ -95,7 +96,7 @@ public:
-     void Output(int len, const sal_uInt8 *data);
-     //
-     // #117718# member map of module names to types of module
--    ModuleType GetModuleType( const UniString& rModuleName );
-+    ModType GetModuleType( const UniString& rModuleName );
- 
-     std::vector<String> maReferences;
- private:
-diff -rup /data4/OOOBuildM12/ooo-build/build/ooh680-m12/svx/source/msfilter/svxmsbas.cxx svx/source/msfilter/svxmsbas.cxx
---- /data4/OOOBuildM12/ooo-build/build/ooh680-m12/svx/source/msfilter/svxmsbas.cxx	2007-12-07 12:21:21.000000000 +0000
-+++ svx/source/msfilter/svxmsbas.cxx	2008-03-28 10:30:33.000000000 +0000
-@@ -88,6 +88,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/XObjectProvider.hpp>
- using namespace com::sun::star::container;
- using namespace com::sun::star::script;
- using namespace com::sun::star::uno;
-@@ -319,7 +321,7 @@ BOOL SvxImportMSVBasic::ImportCode_Impl(
-                 // is the same as the encoding for the names
-                 // that are keys in the map used by GetModuleType method
-                 const String &sOrigVBAModName = aVBA.GetStreamName( i );
--                ModuleType mType = aVBA.GetModuleType( sOrigVBAModName );
-+                ModType mType = aVBA.GetModuleType( sOrigVBAModName );
- 
-                 rtl::OUString sClassRem( RTL_CONSTASCII_USTRINGPARAM( "Rem Attribute VBA_ModuleType=" ) );
- 
-@@ -327,23 +329,23 @@ BOOL SvxImportMSVBasic::ImportCode_Impl(
- 
-                 switch( mType )
-                 {
--                    case Class:
-+                    case ModuleType::Class:
-                         modeTypeComment = sClassRem +
-                             ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "VBAClassModule\n" ) );
-                         break;
--                    case Form:
-+                    case ModuleType::Form:
-                         modeTypeComment = sClassRem +
-                             ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "VBAFormModule\n" ) );
-                         break;
--                    case Document:
-+                    case ModuleType::Document:
-                         modeTypeComment = sClassRem +
-                             ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "VBADocumentModule\n" ) );
-                         break;
--                    case Normal:
-+                    case ModuleType::Normal:
-                         modeTypeComment = sClassRem +
-                             ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "VBAModule\n" ) );
-                         break;
--                    case Unknown:
-+                    case ModuleType::Unknown:
-                         modeTypeComment = sClassRem +
-                             ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "VBAUnknown\n" ) );
-                         break;
-@@ -356,7 +358,7 @@ BOOL SvxImportMSVBasic::ImportCode_Impl(
- 				if ( !bAsComment )
- 				{
- 					modeTypeComment = modeTypeComment + sVBAOption;
--					if ( mType == Class )
-+					if ( mType == ModuleType::Class )
- 						modeTypeComment = modeTypeComment + sClassOption;
- 
- 				}
-@@ -418,12 +420,39 @@ BOOL SvxImportMSVBasic::ImportCode_Impl(
- 						aSource += rtl::OUString::createFromAscii("\nEnd Sub");
- 				}
- 				::rtl::OUString aModName( sModule );
--				if ( aSource.getLength() )
- 				{
-+                    Reference< script::XObjectProvider > xVBAObjectProvider;
-+                    if( mType == ModuleType::Document )
-+                    {
-+                        Reference< XMultiServiceFactory> xSF(rDocSh.GetModel(), UNO_QUERY);
-+                        if ( xSF.is() )
-+                        {
-+                            try
-+                            {
-+                                uno::Sequence< uno::Any > aArgs(1);
-+                                aArgs[0] = uno::Any( aModName );
-+                                    xVBAObjectProvider.set( xSF->createInstanceWithArguments( rtl::OUString(RTL_CONSTASCII_USTRINGPARAM( "org.openoffice.vba.VBAObjectModuleObjectProvider")), aArgs), UNO_QUERY );
-+                            }
-+                            catch( Exception& ) { }
-+                        }
-+                    }
+--- svx/source/msfilter/svxmsbas.cxx	2008-05-13 16:25:54.000000000 +0100
++++ svx/source/msfilter/svxmsbas.cxx	2008-05-13 16:29:44.000000000 +0100
+@@ -404,13 +404,16 @@ BOOL SvxImportMSVBasic::ImportCode_Impl(
  					aSource = modeTypeComment + aSource;
  
  					Any aSourceAny;
--					aSourceAny <<= aSource;
-+                    if ( !bAsComment && ( xVBAObjectProvider.is() && mType == ModuleType::Document ) || mType == ModuleType::Form )
-+                    {
-+                        script::ModuleInfo sModuleInfo;
-+                        sModuleInfo.ModuleName = aModName;
-+                        sModuleInfo.ModuleSource = aSource;
-+                        sModuleInfo.ModuleType = mType;
-+                        if ( mType == ModuleType::Form ) 
-+                            sModuleInfo.ModuleObjectProvider.set( rDocSh.GetModel(), UNO_QUERY );
-+                        else
-+                            sModuleInfo.ModuleObjectProvider.set( xVBAObjectProvider, UNO_QUERY );
-+                        aSourceAny <<= sModuleInfo;
-+                    }
-+                    else
-+					    aSourceAny <<= aSource;
- 					if( xLib->hasByName( aModName ) )
- 						xLib->replaceByName( aModName, aSourceAny );
- 					else
-@@ -433,6 +462,8 @@ BOOL SvxImportMSVBasic::ImportCode_Impl(
- 				bRet = true;
- 			}
- 		}
-+        if( bRet )
-+            rDocSh.GetBasic()->SetVBAEnabled( true );
- 		SFX_APP()->LeaveBasicCall();
- 	}
- 	return bRet;
---- /data4/OOOBuildM12/ooo-build/build/ooh680-m12/svx/inc/svx/msocximex.hxx	2008-04-02 12:14:58.000000000 +0100
-+++ svx/inc/svx/msocximex.hxx	2008-04-01 15:22:20.000000000 +0100
-@@ -298,6 +298,7 @@ public:
- 	sal_Int32 mnForeColor;
-         sal_uInt16 mnTabPos;
- 	UniString sName;
-+	UniString msToolTip;
- 	OCX_FontData aFontData;
-         SfxObjectShell *pDocSh;
- protected:
-@@ -908,7 +908,7 @@ public:
- 	sal_uInt8   nKeepScrollBarsVisible;
- 	sal_uInt8   nCycle;
- 	sal_uInt16	nBorderStyle;
--	sal_uInt16	nSpecialEffect;
-+	sal_uInt8	nSpecialEffect;
- 	sal_uInt16	nPicture;
- 	sal_uInt8   nPictureAlignment;
- 	sal_uInt8   nPictureSizeMode;
---- /data4/OOOBuildM12/ooo-build/build/ooh680-m12/svx/source/msfilter/msocximex.cxx	2008-04-02 15:01:33.000000000 +0100
-+++ svx/source/msfilter/msocximex.cxx	2008-04-02 14:49:08.000000000 +0100
-@@ -138,7 +138,7 @@
- #include <comphelper/processfactory.hxx> // shouldn't be needed
- #include <com/sun/star/ucb/XSimpleFileAccess.hpp>
- 
--
-+#include <fstream>
- #include <algorithm>
- #include <memory>
- 
-@@ -746,13 +746,16 @@ class ContainerRecReader
-                 ReadAlign( pS, pS->Tell() - nStartPos, 4 );
-                 *pS >> rec.nLeft >> rec.nTop;
-             }
--
-+   
-             // control infotip
-             sal_uInt32 nTipBufSize = lclGetBufferSize( nTipLen );
-             if( nTipBufSize > 0 )
-             {
-+                std::auto_ptr< sal_Char > pTipName;
-+                pTipName.reset( new sal_Char[ nTipBufSize ] );
-                 ReadAlign( pS, pS->Tell() - nStartPos, 4 );
--                pS->SeekRel( nTipBufSize );
-+                pS->Read( pTipName.get(), nTipBufSize );
-+            	rec.controlTip = lclCreateOUString( pTipName.get(), nTipLen );
-             }
-             // control id
-             sal_uInt32 nCntrlIdSize = lclGetBufferSize( nCntrlIdLen );
-@@ -1262,6 +1265,11 @@ sal_Bool OCX_Control::Import(uno::Refere
-     xPropSet->setPropertyValue(WW8_ASCII2STR("Width"), aTmp);
-     aTmp <<= sal_Int32((nHeight * 2) / 100);
-     xPropSet->setPropertyValue(WW8_ASCII2STR("Height"), aTmp);
-+    if ( msToolTip.Len() > 0 )
-+    {
-+	uno::Any aTmp(&msToolTip,getCppuType((OUString *)0));
-+        xPropSet->setPropertyValue(WW8_ASCII2STR("HelpText"), aTmp);
-+    }
- 
-     if ( mnStep )
-     {
-@@ -3664,6 +3666,7 @@ void OCX_ContainerControl::ProcessContro
-         }
- 
-         pControl->sName = rec.cName;
-+        pControl->msToolTip = rec.controlTip;
-         // Position of controls is relative to the container
-         pControl->mnTop = rec.nTop + mnTop;
-         pControl->mnLeft = rec.nLeft + mnLeft;
-@@ -3750,7 +3750,8 @@ OCX_MultiPage::OCX_MultiPage( SotStorage
- 		nScrollWidth(0), nScrollHeight(0), nIconLen(0), pIcon(0), nPictureLen(0),
- 		pPicture(0)
- {
--    msDialogType = C2U("NotSupported");
-+    //msDialogType = C2U("NotSupported");
-+    msDialogType = C2U("com.sun.star.awt.UnoMultiPageModel");
-     mnForeColor = 0x80000012L,
-     mnBackColor = 0x8000000FL;
-     bSetInDialog = true;// UserForm control only
-@@ -3814,7 +3815,6 @@ sal_Bool OCX_MultiPage::Read(SvStorageSt
- sal_Bool OCX_MultiPage::Import(com::sun::star::uno::Reference<
-     com::sun::star::beans::XPropertySet> &rPropSet)
- {
--    // Calls import on contained controls
-     OCX_ContainerControl::Import( rPropSet );
-     return sal_True;
- }
-@@ -3835,6 +3835,43 @@ sal_Bool OCX_MultiPage::Import(com::sun:
- 
-     if ( xPropSet.is() )
-     {
-+        uno::Reference<lang::XMultiServiceFactory>
-+            xFactory(rDialog, uno::UNO_QUERY);
-+	OSL_TRACE("** MultiPage creating control %s", rtl::OUStringToOString( msDialogType, RTL_TEXTENCODING_UTF8 ).getStr() );
-+	uno::Reference<uno::XInterface> xCreate = xFactory->createInstance(msDialogType);
-+	if (!xCreate.is())
-+		return sal_False;
-+
-+	uno::Reference<awt::XControlModel> xModel(xCreate, uno::UNO_QUERY);
-+	if (!xModel.is())
-+		return sal_False;
-+
-+        try
-+        {
-+		// we should just call MultiPage::Import( XPropertySet )
-+    		OSL_TRACE("********* MULTIPAGE cName %s", rtl::OUStringToOString( sName, RTL_TEXTENCODING_UTF8 ).getStr() );
-+		uno::Any aTmp(&sName,getCppuType((OUString *)0));
-+		uno::Reference<beans::XPropertySet> xPrps(xModel, uno::UNO_QUERY);
-+		xPrps->setPropertyValue( WW8_ASCII2STR("Name"), aTmp );
-+		aTmp = uno::makeAny( mnCurrentPageStep );
-+		xPrps->setPropertyValue( WW8_ASCII2STR("ProgressValueMax"), aTmp );
-+		// default current page to 0 ( #FIXME, we need to read this value )
-+		aTmp = uno::makeAny( sal_Int32(0) );
-+		xPrps->setPropertyValue( WW8_ASCII2STR("ProgressValue"), aTmp );
-+    		OSL_TRACE("********* MULTIPAGE vomitted out properties");
-+
-+    // Calls import on contained controls
-+            rDialog->insertByName(sName, uno::makeAny(xModel));
-+            OSL_TRACE("*** inserted ***");
-+        }
-+        catch( uno::Exception& )
-+        {
-+            DBG_ERRORFILE(
-+                ByteString( "OCX_Control::Import - cannot insert control \"" ).
-+                Append( ByteString( sName, RTL_TEXTENCODING_UTF8 ) ).
-+                Append( '"' ).GetBuffer() );
-+        }
-+
-         // Calls import on contained pages
-         return OCX_ContainerControl::Import( xPropSet );
-     }
---- sc/inc/servuno.hxx	2008-04-10 19:53:59.000000000 +0100
-+++ sc/inc/servuno.hxx	2008-05-09 18:11:50.000000000 +0100
-@@ -93,8 +93,8 @@ class ScDocShell;
- 
- #define SC_SERVICE_FORMULAPARS  38
- #define SC_SERVICE_OPCODEMAPPER 39
--
--#define SC_SERVICE_COUNT        40
-+#define SC_SERVICE_VBAOBJECTPROVIDER   40
-+#define SC_SERVICE_COUNT        41
- #define SC_SERVICE_INVALID		USHRT_MAX
- 
- 
---- sc/source/ui/unoobj/servuno.cxx	2008-04-11 01:43:36.000000000 +0100
-+++ sc/source/ui/unoobj/servuno.cxx	2008-05-09 18:16:21.000000000 +0100
-@@ -61,8 +61,93 @@
- #include <svx/xmleohlp.hxx>
- #include <svx/xmlgrhlp.hxx>
- 
-+#include <com/sun/star/script/XObjectProvider.hpp>
-+#include <comphelper/processfactory.hxx>
-+
- using namespace ::com::sun::star;
- 
-+class ScVbaObjectProvider : public ::cppu::WeakImplHelper2< script::XObjectProvider, lang::XInitialization >
-+{
-+    ScDocShell* mpDocShell;
-+    uno::Any aObj;
-+    String msName;
-+public:
-+    ScVbaObjectProvider( const rtl::OUString& sName, ScDocShell* pDocShell ) : mpDocShell( pDocShell ), msName(sName) {}
-+    ScVbaObjectProvider( ScDocShell* pDocShell ) : mpDocShell( pDocShell ) {}
-+    virtual void SAL_CALL initialize( const uno::Sequence< uno::Any >& aArguments ) throw (uno::Exception, uno::RuntimeException)
-+    {
-+        OSL_TRACE("ScVbaObjectProvider::initialize ");
-+        if(aArguments.getLength() != 1)
-+        {
-+            throw lang::IllegalArgumentException(rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("give a string instanciating this component!") ), static_cast< script::XObjectProvider * >(this), 0 );
-+        }
-+        rtl::OUString sName;
-+        aArguments[0] >>= sName;
-+        msName = sName;
-+    }
-+    virtual uno::Any SAL_CALL getObject() throw (uno::RuntimeException)
-+    {
-+        if ( !aObj.hasValue() )
-+        {
-+            BOOL bWorkbook = FALSE;
-+            uno::Type aType;
-+            uno::Reference<lang::XMultiServiceFactory> xSF(comphelper::getProcessServiceFactory());
-+            uno::Reference<beans::XPropertySet> xProps(xSF, uno::UNO_QUERY);
-+            if( xProps.is() )
-+            {
-+                ScDocument* pDoc = mpDocShell->GetDocument();
-+                if ( !pDoc )
-+                    throw uno::RuntimeException( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("")), uno::Reference< uno::XInterface >() );
-+                String sGlobCodeName = pDoc->GetCodeName();
-+                uno::Reference< uno::XInterface > xIf;
-+
-+                uno::Sequence< uno::Any > aArgs(2);
-+                aArgs[0] = uno::Any( uno::Reference< uno::XInterface >() );
-+                aArgs[1] = uno::Any( mpDocShell->GetModel() );
-+                uno::Reference< uno::XInterface > xWorkbook( xSF->createInstanceWithArguments(  rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("org.openoffice.excel.Workbook") ), aArgs ), uno::UNO_QUERY );
-+                if( sGlobCodeName == msName )
-+                {
-+                    xIf.set( xWorkbook, uno::UNO_QUERY );
-+                    bWorkbook = TRUE;
-+                }
-+                 else
-+                 {
-+                    String sCodeName;
-+                    SCTAB nCount = pDoc->GetTableCount();
-+                    for( SCTAB i = 0; i < nCount; i++ )
-+                    {
-+                        pDoc->GetCodeName( i, sCodeName );
-+                        if( sCodeName == msName )
-+                        {
-+                            String sSheetName;
-+                            if( pDoc->GetName( i, sSheetName ) )
-+                            {
-+                            uno::Reference< frame::XModel > xModel( mpDocShell->GetModel() );
-+                            uno::Reference <sheet::XSpreadsheetDocument> xSpreadDoc( xModel, uno::UNO_QUERY_THROW );
-+                            uno::Reference<sheet::XSpreadsheets > xSheets( xSpreadDoc->getSheets(), uno::UNO_QUERY_THROW );
-+                            uno::Reference< container::XIndexAccess > xIndexAccess( xSheets, uno::UNO_QUERY_THROW );
-+                            uno::Reference< sheet::XSpreadsheet > xSheet( xIndexAccess->getByIndex( i ), uno::UNO_QUERY_THROW );
-+                            uno::Sequence< uno::Any > aArgs(3);
-+                            aArgs[0] = uno::Any( xWorkbook );
-+                            aArgs[1] = uno::Any( xModel );
-+                            aArgs[2] = uno::Any( rtl::OUString( sSheetName ) );
-+                            uno::Reference< uno::XInterface > xWorksheet( xSF->createInstanceWithArguments(  rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("org.openoffice.excel.Worksheet") ), aArgs ), uno::UNO_QUERY );
-+                            xIf.set( xWorksheet, uno::UNO_QUERY );
-+                            bWorkbook = FALSE;
-+                            break;
-+                            }
-+                        }
-+                    }
-+                 }
-+                 if( xIf.is() )
-+                 {
-+                    aObj <<= xIf;
-+                 }
-+            }
-+        }
-+        return aObj;
-+    }
-+};
- 
- //------------------------------------------------------------------------
- 
-@@ -112,7 +197,8 @@ static const sal_Char* __FAR_DATA aProvN
- 
-         SC_SERVICENAME_CHDATAPROV,                  // SC_SERVICE_CHDATAPROV
-         SC_SERVICENAME_FORMULAPARS,                 // SC_SERVICE_FORMULAPARS
--        SC_SERVICENAME_OPCODEMAPPER                 // SC_SERVICE_OPCODEMAPPER
-+        SC_SERVICENAME_OPCODEMAPPER,                 // SC_SERVICE_OPCODEMAPPER
-+"org.openoffice.vba.VBAObjectModuleObjectProvider",// SC_SERVICE_VBAOBJECTPROVIDER
- 	};
- 
- //
-@@ -164,7 +250,8 @@ static const sal_Char* __FAR_DATA aOldNa
-         "",                                         // SC_SERVICE_SHEETDOCSET
-         "",                                         // SC_SERVICE_CHDATAPROV
-         "",                                         // SC_SERVICE_FORMULAPARS
--        ""                                          // SC_SERVICE_OPCODEMAPPER
-+        "",                                         // SC_SERVICE_OPCODEMAPPER
-+        "",                                         // SC_SERVICE_VBAOBJECTPROVIDER
- 	};
- 
- 
-@@ -357,6 +444,9 @@ uno::Reference<uno::XInterface> ScServic
-         case SC_SERVICE_OPCODEMAPPER:
-             xRet.set(static_cast<sheet::XFormulaOpCodeMapper*>(new ScFormulaOpCodeMapperObj));
-             break;
-+        case SC_SERVICE_VBAOBJECTPROVIDER:
-+            xRet.set(static_cast<script::XObjectProvider*>(new ScVbaObjectProvider( pDocShell )));
-+            break;
- 	}
- 	return xRet;
- }
-diff -rup /data4/OOOBuildM12/ooo-build/build/ooh680-m12/sc/source/ui/docshell/docfunc.cxx sc/source/ui/docshell/docfunc.cxx
---- /data4/OOOBuildM12/ooo-build/build/ooh680-m12/sc/source/ui/docshell/docfunc.cxx	2008-03-29 23:08:20.000000000 +0000
-+++ sc/source/ui/docshell/docfunc.cxx	2008-03-28 10:30:33.000000000 +0000
-@@ -58,6 +58,13 @@
- #include <svtools/PasswordHelper.hxx>
- #endif
- 
-+#include <basic/sbstar.hxx>
-+#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/ModuleType.hpp>
-+#include <com/sun/star/script/XObjectProvider.hpp>
-+
- #include <list>
- 
- #include "docfunc.hxx"
-@@ -101,6 +108,7 @@
- #include "scui_def.hxx" //CHINA001
- using namespace com::sun::star;
- 
-+
- // STATIC DATA -----------------------------------------------------------
- 
- //========================================================================
-@@ -2022,6 +2030,86 @@ BOOL ScDocFunc::MoveBlock( const ScRange
- }
- 
- //------------------------------------------------------------------------
-+script::ModuleInfo lcl_InitModuleInfo( ScDocShell& rDocSh, String& sModule )
-+{
-+    ::rtl::OUString aModName( sModule );
-+    uno::Reference< lang::XMultiServiceFactory> xSF(rDocSh.GetModel(), uno::UNO_QUERY);
-+    uno::Reference< script::XObjectProvider > xVBAObjectProvider;
-+    if ( xSF.is() )
-+    {
-+        uno::Sequence< uno::Any > aArgs(1);
-+        aArgs[0] = uno::Any( aModName );
-+        xVBAObjectProvider.set( xSF->createInstanceWithArguments( rtl::OUString(RTL_CONSTASCII_USTRINGPARAM( "org.openoffice.vba.VBAObjectModuleObjectProvider")), aArgs), uno::UNO_QUERY );    
-+    }
-+    script::ModuleInfo sModuleInfo;
-+    ::rtl::OUString sVbaOption( RTL_CONSTASCII_USTRINGPARAM( "Rem Attribute VBA_ModuleType=VBADocumentModule\nOption VBASupport 1\n" ));
-+    sModuleInfo.ModuleName = aModName;
-+    sModuleInfo.ModuleSource = sVbaOption;
-+    sModuleInfo.ModuleType = script::ModuleType::Document;
-+    sModuleInfo.ModuleObjectProvider.set( xVBAObjectProvider, uno::UNO_QUERY );
-+    return sModuleInfo;
-+}
-+
-+void lcl_InsertModule( ScDocShell& rDocSh, SCTAB nTab, String& sModuleName )
-+{
-+    SFX_APP()->EnterBasicCall();
-+    script::ModuleInfo sModuleInfo = lcl_InitModuleInfo(  rDocSh, sModuleName );
-+    uno::Reference< script::XLibraryContainer > xLibContainer = rDocSh.GetBasicContainer();
-+    DBG_ASSERT( xLibContainer.is(), "No BasicContainer!" );
-+
-+    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() )
-+    {
-+        // test Module has exist
-+        // if the Module is exist. changed to another name
-+        // and at this time the string like "SheetX"
-+        rtl::OUString sModuleName( sModuleInfo.ModuleName );
-+        sal_Int32 nNum = 1;
-+        while( xLib->hasByName( sModuleName ) )
-+        {
-+            sModuleName = rtl::OUString::createFromAscii( "Sheet" ) + rtl::OUString::valueOf( nNum );
-+            nNum += 1;
-+        }
-+        sModuleInfo.ModuleName = sModuleName;
-+        uno::Any aSourceAny;
-+        aSourceAny <<= sModuleInfo;
-+        xLib->insertByName( sModuleName, aSourceAny );
-+        ScDocument* pDoc = rDocSh.GetDocument();
-+        String sCodeName( sModuleName );
-+        pDoc->SetCodeName( nTab, sCodeName );
-+    }
-+    SFX_APP()->LeaveBasicCall();
-+}
-+
-+void lcl_DeleteModule( ScDocShell& rDocSh, String& sModuleName )
-+{
-+    SFX_APP()->EnterBasicCall();
-+    uno::Reference< script::XLibraryContainer > xLibContainer = rDocSh.GetBasicContainer();
-+    DBG_ASSERT( xLibContainer.is(), "No BasicContainer!" );
-+
-+    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() )
-+    {
-+        if( xLib->hasByName( sModuleName ) )
-+        {
-+            xLib->removeByName( sModuleName );
-+        }
-+    }
-+    SFX_APP()->LeaveBasicCall();
-+}
-+
- 
- BOOL ScDocFunc::InsertTable( SCTAB nTab, const String& rName, BOOL bRecord, BOOL bApi )
- {
-@@ -2031,8 +2119,12 @@ BOOL ScDocFunc::InsertTable( SCTAB nTab,
- 	ScDocShellModificator aModificator( rDocShell );
- 
- 	ScDocument* pDoc = rDocShell.GetDocument();
-+    StarBASIC* pStarBASIC = rDocShell.GetBasic();
-+    BOOL bVbaEnabled = pStarBASIC->isVBAEnabled();
- 	if (bRecord && !pDoc->IsUndoEnabled())
- 		bRecord = FALSE;
-+    if ( bVbaEnabled )
-+        bRecord = FALSE;
- 	if (bRecord)
- 		pDoc->BeginDrawUndo();							//	InsertTab erzeugt ein SdrUndoNewPage
- 
-@@ -2047,6 +2139,11 @@ BOOL ScDocFunc::InsertTable( SCTAB nTab,
- 			rDocShell.GetUndoManager()->AddUndoAction(
- 						new ScUndoInsertTab( &rDocShell, nTab, bAppend, rName));
- 		//	Views updaten:
-+        if( bVbaEnabled )
-+        {
-+            String sCodeName( rName );
-+            lcl_InsertModule( rDocShell, nTab, sCodeName );
-+        }
- 		rDocShell.Broadcast( ScTablesHint( SC_TAB_INSERTED, nTab ) );
- 
- 		rDocShell.PostPaintExtras();
-@@ -2068,8 +2165,12 @@ BOOL ScDocFunc::DeleteTable( SCTAB nTab,
- 
- 	BOOL bSuccess = FALSE;
- 	ScDocument* pDoc = rDocShell.GetDocument();
-+    StarBASIC* pStarBASIC = rDocShell.GetBasic();
-+    BOOL bVbaEnabled = pStarBASIC->isVBAEnabled();
- 	if (bRecord && !pDoc->IsUndoEnabled())
- 		bRecord = FALSE;
-+    if ( bVbaEnabled )
-+        bRecord = FALSE;
- 	BOOL bWasLinked = pDoc->IsLinked(nTab);
- 	ScDocument* pUndoDoc = NULL;
- 	ScRefUndoData* pUndoData = NULL;
-@@ -2110,6 +2211,8 @@ BOOL ScDocFunc::DeleteTable( SCTAB nTab,
- 		pUndoData = new ScRefUndoData( pDoc );
- 	}
- 
-+    String sCodeName;
-+    BOOL bHasCodeName = pDoc->GetCodeName( nTab, sCodeName );
- 	if (pDoc->DeleteTab( nTab, pUndoDoc ))
- 	{
- 		if (bRecord)
-@@ -2120,6 +2223,13 @@ BOOL ScDocFunc::DeleteTable( SCTAB nTab,
- 						new ScUndoDeleteTab( &rDocShell, theTabs, pUndoDoc, pUndoData ));
- 		}
- 		//	Views updaten:
-+        if( bVbaEnabled )
-+        {
-+            if( bHasCodeName )
-+            {
-+                lcl_DeleteModule( rDocShell, sCodeName );
-+            }
-+        }
- 		rDocShell.Broadcast( ScTablesHint( SC_TAB_DELETED, nTab ) );
- 
- 		if (bWasLinked)
-diff -rup /data4/OOOBuildM12/ooo-build/build/ooh680-m12/sc/source/ui/unoobj/makefile.mk sc/source/ui/unoobj/makefile.mk
---- /data4/OOOBuildM12/ooo-build/build/ooh680-m12/sc/source/ui/unoobj/makefile.mk	2008-03-29 23:08:20.000000000 +0000
-+++ sc/source/ui/unoobj/makefile.mk	2008-03-28 10:30:33.000000000 +0000
-@@ -54,6 +54,7 @@ AUTOSEG=true
- .INCLUDE :  sc.mk
- .INCLUDE :  $(PRJ)$/util$/makefile.pmk
- 
-+INCPRE=$(INCCOM)$/vbaobj
- # --- Files --------------------------------------------------------
- SLO1FILES =  \
-         $(SLO)$/docuno.obj \
-diff -rup /data4/OOOBuildM12/ooo-build/build/ooh680-m12/sc/source/ui/view/viewfun2.cxx sc/source/ui/view/viewfun2.cxx
---- /data4/OOOBuildM12/ooo-build/build/ooh680-m12/sc/source/ui/view/viewfun2.cxx	2008-03-29 23:08:24.000000000 +0000
-+++ sc/source/ui/view/viewfun2.cxx	2008-03-28 10:30:34.000000000 +0000
-@@ -62,6 +62,11 @@
- #include <vcl/sound.hxx>
- #include <vcl/waitobj.hxx>
- 
-+#include <basic/sbstar.hxx>
-+#include <com/sun/star/container/XNameContainer.hpp>
-+#include <com/sun/star/script/XLibraryContainer.hpp>
-+using namespace com::sun::star;
-+
- #include "viewfunc.hxx"
- 
- #include "sc.hrc"
-@@ -2095,15 +2100,42 @@ BOOL ScViewFunc::DeleteTable( SCTAB nTab
- 	return bSuccess;
- }
- 
-+void lcl_DeleteModule( ScDocShell* rDocSh, String& sModuleName )
-+{
-+    SFX_APP()->EnterBasicCall();
-+    uno::Reference< script::XLibraryContainer > xLibContainer = rDocSh->GetBasicContainer();
-+    DBG_ASSERT( xLibContainer.is(), "No BasicContainer!" );
-+
-+    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() )
-+    {
-+        if( xLib->hasByName( sModuleName ) )
-+        {
-+            xLib->removeByName( sModuleName );
-+        }
-+    }
-+    SFX_APP()->LeaveBasicCall();
-+}
-+
- BOOL ScViewFunc::DeleteTables(const SvShorts &TheTabs, BOOL bRecord )
- {
- 	ScDocShell* pDocSh	= GetViewData()->GetDocShell();
- 	ScDocument* pDoc 	= pDocSh->GetDocument();
-+    StarBASIC* pStarBASIC = pDocSh->GetBasic();
-+    BOOL bVbaEnabled = pStarBASIC->isVBAEnabled();
- 	SCTAB		nNewTab = TheTabs[0];
- 	int			i;
- 	WaitObject aWait( GetFrameWin() );
- 	if (bRecord && !pDoc->IsUndoEnabled())
- 		bRecord = FALSE;
-+    if ( bVbaEnabled )
-+        bRecord = FALSE;
- 
- 	while ( nNewTab > 0 && !pDoc->IsVisible( nNewTab ) )
- 		--nNewTab;
-@@ -2170,9 +2202,18 @@ BOOL ScViewFunc::DeleteTables(const SvSh
- 
- 	for(i=TheTabs.Count()-1;i>=0;i--)
- 	{
-+        String sCodeName;
-+        BOOL bHasCodeName = pDoc->GetCodeName( TheTabs[sal::static_int_cast<USHORT>(i)], sCodeName );
-         if (pDoc->DeleteTab( TheTabs[sal::static_int_cast<USHORT>(i)], pUndoDoc ))
- 		{
- 			bDelDone = TRUE;
-+            if( bVbaEnabled )
-+            {
-+                if( bHasCodeName )
-+                {
-+                    lcl_DeleteModule( pDocSh, sCodeName );
-+                }
-+            }
-             pDocSh->Broadcast( ScTablesHint( SC_TAB_DELETED, TheTabs[sal::static_int_cast<USHORT>(i)] ) );
- 		}
- 	}
-@@ -2200,6 +2241,7 @@ BOOL ScViewFunc::DeleteTables(const SvSh
- 		pDocSh->PostPaintExtras();
- 		pDocSh->SetDocumentModified();
- 
-+
-         SfxApplication* pSfxApp = SFX_APP();                                // Navigator
-         pSfxApp->Broadcast( SfxSimpleHint( SC_HINT_TABLES_CHANGED ) );
-         pSfxApp->Broadcast( SfxSimpleHint( SC_HINT_DBAREAS_CHANGED ) );
-diff -rup /data4/OOOBuildM12/ooo-build/build/ooh680-m12/basctl/source/basicide/basides1.cxx basctl/source/basicide/basides1.cxx
---- /data4/OOOBuildM12/ooo-build/build/ooh680-m12/basctl/source/basicide/basides1.cxx	2008-01-14 16:00:33.000000000 +0000
-+++ basctl/source/basicide/basides1.cxx	2008-03-28 10:30:34.000000000 +0000
-@@ -1229,10 +1229,16 @@ IDEBaseWindow* BasicIDEShell::FindWindow
-                 // return any non-suspended window
-                 return pWin;
-             }
--            else if ( pWin->IsDocument( rDocument ) && pWin->GetLibName() == rLibName && pWin->GetName() == rName &&
-+            else if ( pWin->IsDocument( rDocument ) )
-+            {
-+                OSL_TRACE("FindWindow pWin->GetLibName() %s rLibName %s",
-+			rtl::OUStringToOString( pWin->GetLibName(), RTL_TEXTENCODING_UTF8 ).getStr(),
-+			rtl::OUStringToOString( rLibName, RTL_TEXTENCODING_UTF8 ).getStr() );
-+                OSL_TRACE("pWin->pWin->IsA( TYPE( ModulWindow ) %d && nType %d = BASICIDE_TYPE_MODULE %d", pWin->IsA( TYPE( ModulWindow ) ), nType, BASICIDE_TYPE_MODULE );
-+                OSL_TRACE("pWin->pWin->IsA( TYPE( DialogWindow ) %d && nType %d = BASICIDE_TYPE_DIALOG %d", pWin->IsA( TYPE( DialogWindow ) ), nType, BASICIDE_TYPE_DIALOG );
-+		if (  pWin->GetLibName() == rLibName && pWin->GetName() == rName &&
-                       ( ( pWin->IsA( TYPE( ModulWindow ) )  && nType == BASICIDE_TYPE_MODULE ) ||
-                         ( pWin->IsA( TYPE( DialogWindow ) ) && nType == BASICIDE_TYPE_DIALOG ) ) )
--            {
-                 return pWin;
-             }
-         }
-diff -rup /data4/OOOBuildM12/ooo-build/build/ooh680-m12/basctl/source/basicide/basides2.cxx basctl/source/basicide/basides2.cxx
---- /data4/OOOBuildM12/ooo-build/build/ooh680-m12/basctl/source/basicide/basides2.cxx	2007-11-21 16:37:21.000000000 +0000
-+++ basctl/source/basicide/basides2.cxx	2008-03-28 10:30:34.000000000 +0000
-@@ -252,9 +252,12 @@ ModulWindow* BasicIDEShell::CreateBasWin
- 
-         if ( bSuccess )
-         {
--			// new module window
--			pWin = new ModulWindow( pModulLayout, rDocument, aLibName, aModName, aModule );
--			nKey = InsertWindowInTable( pWin );
-+			pWin = FindBasWin( rDocument, aLibName, aModName, FALSE, TRUE );
-+            if( !pWin )
-+			{    // new module window
-+			    pWin = new ModulWindow( pModulLayout, rDocument, aLibName, aModName, aModule );
-+			    nKey = InsertWindowInTable( pWin );
-+            }
-         }
- 	}
- 	else
-@@ -269,7 +272,8 @@ ModulWindow* BasicIDEShell::CreateBasWin
- 		}
- 		DBG_ASSERT( nKey, "CreateBasWin: Kein Key- Fenster nicht gefunden!" );
- 	}
--	pTabBar->InsertPage( (USHORT)nKey, aModName );
-+    if( nKey )
-+	    pTabBar->InsertPage( (USHORT)nKey, aModName );
- 	pTabBar->Sort();
- 	pWin->GrabScrollBars( &aHScrollBar, &aVScrollBar );
- 	if ( !pCurWin )
-diff -rup /data4/OOOBuildM12/ooo-build/build/ooh680-m12/basctl/source/basicide/basidesh.cxx basctl/source/basicide/basidesh.cxx
---- /data4/OOOBuildM12/ooo-build/build/ooh680-m12/basctl/source/basicide/basidesh.cxx	2008-01-14 16:00:46.000000000 +0000
-+++ basctl/source/basicide/basidesh.cxx	2008-03-28 10:30:34.000000000 +0000
-@@ -97,6 +97,9 @@
- #include <com/sun/star/script/XLibraryContainer.hpp>
- #include <com/sun/star/script/XLibraryContainerPassword.hpp>
- #include <com/sun/star/container/XNameContainer.hpp>
-+#include <com/sun/star/container/XContainer.hpp>
-+#include <com/sun/star/container/XContainerListener.hpp>
-+#include <com/sun/star/script/XLibraryContainer.hpp>
- 
- #include <svx/xmlsecctrl.hxx>
- 
-@@ -104,6 +107,71 @@ using namespace ::com::sun::star::uno;
- using namespace ::com::sun::star;
- using ::rtl::OUString;
- 
-+static const rtl::OUString sStandardLibName(  rtl::OUString::createFromAscii("Standard") );
-+
-+typedef ::cppu::WeakImplHelper1< container::XContainerListener > ContainerListenerBASE;
-+
-+class ContainerListenerImpl : public ContainerListenerBASE
-+{
-+    BasicIDEShell* mpShell;
-+public:
-+
-+    ContainerListenerImpl( BasicIDEShell* pShell ) : mpShell( pShell ) {}
-+
-+    ~ContainerListenerImpl() 
-+    {
-+    }
-+
-+    void addContainerListener( const ScriptDocument& rScriptDocument )
-+    {
-+        uno::Reference< container::XContainer > xContainer( rScriptDocument.getLibrary( E_SCRIPTS, sStandardLibName, FALSE ), uno::UNO_QUERY );
-+        if ( rScriptDocument.isDocument() && xContainer.is() )
-+        {
-+            uno::Reference< container::XContainerListener > xContainerListener( this );
-+            try
-+            {
-+                xContainer->addContainerListener( xContainerListener );
-+            }
-+            catch( uno::Exception& ) {}
-+        }
-+    }
-+    void removeContainerListener( const ScriptDocument& rScriptDocument )
-+    {
-+        uno::Reference< container::XContainer > xContainer( rScriptDocument.getLibrary( E_SCRIPTS, sStandardLibName, FALSE ), uno::UNO_QUERY );
-+        if ( rScriptDocument.isDocument(), xContainer.is() )
-+        {
-+            uno::Reference< container::XContainerListener > xContainerListener( this );
-+            try
-+            {
-+               xContainer->removeContainerListener( xContainerListener );
-+            }
-+            catch( uno::Exception& ) {}
-+        }
-+    }
-+
-+    // XEventListener
-+    virtual void SAL_CALL disposing( const lang::EventObject& ) throw( uno::RuntimeException ) {}
-+
-+    // XContainerListener
-+    virtual void SAL_CALL elementInserted( const container::ContainerEvent& Event ) throw( uno::RuntimeException )
-+    {
-+        rtl::OUString sModuleName;
-+        if( mpShell && ( Event.Accessor >>= sModuleName ) )
-+            mpShell->FindBasWin( mpShell->m_aCurDocument, sStandardLibName, sModuleName, TRUE, FALSE );
-+    }
-+    virtual void SAL_CALL elementReplaced( const container::ContainerEvent& ) throw( com::sun::star::uno::RuntimeException ) { }
-+    virtual void SAL_CALL elementRemoved( const container::ContainerEvent& Event ) throw( com::sun::star::uno::RuntimeException )
-+    {
-+        rtl::OUString sModuleName;
-+        if( mpShell  && ( Event.Accessor >>= sModuleName ) )
-+        {
-+            IDEBaseWindow* pWin = mpShell->FindWindow( mpShell->m_aCurDocument, sStandardLibName, sModuleName, BASICIDE_TYPE_MODULE, TRUE );
-+            if( pWin )
-+                mpShell->RemoveWindow( pWin, FALSE, TRUE );
-+        }
-+    }
-+
-+};
- 
- TYPEINIT1( BasicIDEShell, SfxViewShell );
- 
-@@ -141,6 +209,7 @@ BasicIDEShell::BasicIDEShell( SfxViewFra
-         m_bAppBasicModified( FALSE ),
-         m_aNotifier( *this )
- {
-+    m_xLibListener = new ContainerListenerImpl( this );
- 	Init();
-     GnBasicIDEShellCount++;
- }
-@@ -156,6 +225,7 @@ BasicIDEShell::BasicIDEShell( SfxViewFra
-         m_aNotifier( *this )
- {
- 	DBG_ERROR( "Zweite Ansicht auf Debugger nicht moeglich!" );
-+    m_xLibListener = new ContainerListenerImpl( this );
-     GnBasicIDEShellCount++;
- }
- 
-@@ -170,6 +240,7 @@ BasicIDEShell::BasicIDEShell( SfxViewFra
-         m_aNotifier( *this )
- {
- 	Init();
-+    m_xLibListener = new ContainerListenerImpl( this );
-     GnBasicIDEShellCount++;
- }
- 
-@@ -258,6 +329,12 @@ __EXPORT BasicIDEShell::~BasicIDEShell()
- 	delete pTabBar;
- 	delete pObjectCatalog;
- 	DestroyModulWindowLayout();
-+
-+        ContainerListenerImpl* pListener = dynamic_cast< ContainerListenerImpl* >( m_xLibListener.get() );
-+        // Destroy all ContainerListeners for Basic Container.
-+        if ( pListener )
-+            pListener->removeContainerListener( m_aCurDocument );
-+    
- 	// MI: Das gab einen GPF im SDT beim Schliessen da dann der ViewFrame die
- 	// ObjSh loslaesst. Es wusste auch keiner mehr wozu das gut war.
- 	// GetViewFrame()->GetObjectShell()->Broadcast( SfxSimpleHint( SFX_HINT_DYING ) );
-@@ -275,6 +352,7 @@ sal_Bool BasicIDEShell::HasBasic() const
- 
- void BasicIDEShell::onDocumentCreated( const ScriptDocument& /*_rDocument*/ )
- {
-+    // _rDocument is not a valid ScriptDocument.
-     UpdateWindows();
- }
- 
-@@ -303,6 +381,8 @@ void BasicIDEShell::onDocumentSaveAsDone
-     // not interested in
- }
- 
-+//============================================================================
-+
- void BasicIDEShell::onDocumentClosed( const ScriptDocument& _rDocument )
- {
-     if ( !_rDocument.isValid() )
-@@ -402,7 +482,6 @@ void BasicIDEShell::StoreAllWindowData( 
- 	}
- }
- 
--
- USHORT __EXPORT BasicIDEShell::PrepareClose( BOOL bUI, BOOL bForBrowsing )
- {
- 	(void)bForBrowsing;
-@@ -600,7 +679,6 @@ void BasicIDEShell::ShowObjectDialog( BO
- }
- 
- 
--
- void __EXPORT BasicIDEShell::SFX_NOTIFY( SfxBroadcaster& rBC, const TypeId&,
- 										const SfxHint& rHint, const TypeId& )
- {
-@@ -983,7 +1061,15 @@ void BasicIDEShell::SetCurLib( const Scr
- {
-     if ( !bCheck || ( rDocument != m_aCurDocument || aLibName != m_aCurLibName ) )
-     {
-+        ContainerListenerImpl* pListener = dynamic_cast< ContainerListenerImpl* >( m_xLibListener.get() );
-+        if ( pListener )
-+        	pListener->removeContainerListener( m_aCurDocument );
-+
-         m_aCurDocument = rDocument;
-+
-+        if ( pListener )
-+            pListener->addContainerListener( m_aCurDocument );
-+
-         m_aCurLibName = aLibName;
-         if ( bUpdateWindows )
-             UpdateWindows();
-diff -rup /data4/OOOBuildM12/ooo-build/build/ooh680-m12/basctl/source/basicide/scriptdocument.cxx basctl/source/basicide/scriptdocument.cxx
---- /data4/OOOBuildM12/ooo-build/build/ooh680-m12/basctl/source/basicide/scriptdocument.cxx	2007-10-09 16:24:54.000000000 +0100
-+++ basctl/source/basicide/scriptdocument.cxx	2008-03-28 10:30:34.000000000 +0000
-@@ -61,6 +61,7 @@
- #include <com/sun/star/frame/XModel2.hpp>
- #include <com/sun/star/awt/XWindow2.hpp>
- #include <com/sun/star/document/XEmbeddedScripts.hpp>
-+#include <com/sun/star/script/ModuleInfo.hpp>
- /** === end UNO includes === **/
- 
- #include <sfx2/objsh.hxx>
-@@ -146,6 +147,7 @@ namespace basctl
-     using ::com::sun::star::uno::RuntimeException;
-     using ::com::sun::star::document::XEventBroadcaster;
-     using ::com::sun::star::document::XEmbeddedScripts;
-+    using ::com::sun::star::script::ModuleInfo;
-     /** === end UNO using === **/
-     namespace MacroExecMode = ::com::sun::star::document::MacroExecMode;
-     namespace FrameSearchFlag = ::com::sun::star::frame::FrameSearchFlag;
-@@ -678,6 +680,15 @@ namespace basctl
-             }
- 
- 		    // insert element by new name in container
-+            if ( _eType == E_SCRIPTS )
-+            {
-+                ModuleInfo sModuleInfo;
-+                if ( aElement >>= sModuleInfo )
-+                {
-+                    sModuleInfo.ModuleName = _rNewName;
-+                    aElement <<= sModuleInfo;
-+                }
-+            }
- 		    xLib->insertByName( _rNewName, aElement );
-             return true;
-         }
-@@ -1433,7 +1444,15 @@ namespace basctl
-         Any aCode;
-         if ( !m_pImpl->getModuleOrDialog( E_SCRIPTS, _rLibName, _rModName, aCode ) )
-             return false;
--        OSL_VERIFY( aCode >>= _out_rModuleSource );
-+        ModuleInfo sModuleInfo;
-+        if ( aCode >>= sModuleInfo )
-+        {
-+            _out_rModuleSource = sModuleInfo.ModuleSource;
-+        }
-+        else
-+        {
-+            OSL_VERIFY( aCode >>= _out_rModuleSource );
-+        }
-         return true;
-     }
- 
-diff -rup /data4/OOOBuildM12/ooo-build/build/ooh680-m12/basctl/source/inc/basidesh.hxx basctl/source/inc/basidesh.hxx
---- /data4/OOOBuildM12/ooo-build/build/ooh680-m12/basctl/source/inc/basidesh.hxx	2007-10-09 16:25:06.000000000 +0100
-+++ basctl/source/inc/basidesh.hxx	2008-03-28 10:30:34.000000000 +0000
-@@ -62,7 +62,7 @@
- #ifndef _COM_SUN_STAR_IO_XINPUTSTREAMPROVIDER_HXX_
- #include <com/sun/star/io/XInputStreamProvider.hpp>
- #endif
--
-+#include <com/sun/star/container/XContainerListener.hpp>
- 
- //----------------------------------------------------------------------------
- 
-@@ -90,13 +90,15 @@ DECLARE_TABLE( IDEWindowTable, IDEBaseWi
- typedef Table IDEWindowTable;
- #endif
- 
-+namespace css = ::com::sun::star;
-+
- class BasicIDEShell :public SfxViewShell
-                     ,public ::basctl::DocumentEventListener
- {
- friend class JavaDebuggingListenerImpl;
- friend class LocalizationMgr;
- friend class BasicIDE;
--
-+friend class ContainerListenerImpl;
- 	ObjectCatalog* 		pObjectCatalog;
- 
- 	IDEWindowTable		aIDEWindowTable;
-@@ -116,6 +118,7 @@ friend class BasicIDE;
-     BOOL                m_bAppBasicModified;
-     ::basctl::DocumentEventNotifier
-                         m_aNotifier;
-+	css::uno::Reference< css::container::XContainerListener > m_xLibListener; 	
- 
- #if _SOLAR__PRIVATE
- 	void				Init();
-diff -rup /data4/OOOBuildM12/ooo-build/build/ooh680-m12/basic/inc/basic/sbdef.hxx basic/inc/basic/sbdef.hxx
---- /data4/OOOBuildM12/ooo-build/build/ooh680-m12/basic/inc/basic/sbdef.hxx	2007-04-11 13:51:38.000000000 +0100
-+++ basic/inc/basic/sbdef.hxx	2008-03-28 10:30:34.000000000 +0000
-@@ -100,6 +100,8 @@ void setBasicWatchMode( bool bOn );
- 
- #define SBXID_BASIC			0x6273			// sb: StarBASIC
- #define	SBXID_BASICMOD		0x6d62			// bm: StarBASIC-Modul
-+#define SBXID_DOCUMENTMOD   0x6d63          // Special document Module
-+#define SBXID_USERFORMMOD   0x6d64          // Special userform Module
- #define SBXID_BASICPROP		0x7262			// pr: StarBASIC-Property
- #define	SBXID_BASICMETHOD	0x6d65          // me: StarBASIC-Methode
- #define	SBXID_JSCRIPTMOD	0x6a62			// jm: JavaScript-Modul
-diff -rup /data4/OOOBuildM12/ooo-build/build/ooh680-m12/basic/inc/basic/sbstar.hxx basic/inc/basic/sbstar.hxx
---- /data4/OOOBuildM12/ooo-build/build/ooh680-m12/basic/inc/basic/sbstar.hxx	2007-08-30 10:58:14.000000000 +0100
-+++ basic/inc/basic/sbstar.hxx	2008-03-28 10:30:34.000000000 +0000
-@@ -51,6 +51,7 @@
- 
- #include <basic/sbdef.hxx>
- #include <basic/sberrors.hxx>
-+#include <com/sun/star/script/ModuleInfo.hpp>
- 
- class SbModule;                     // fertiges Modul
- class SbiInstance;                  // Laufzeit-Instanz
-@@ -82,6 +83,7 @@ class StarBASIC : public SbxObject
- 	BOOL			bNoRtl;				// TRUE: RTL nicht durchsuchen
- 	BOOL			bBreak;				// TRUE: Break, sonst Step
- 	BOOL			bDocBasic;
-+    BOOL            bVBAEnabled;
- 	BasicLibInfo*	pLibInfo;			// Infoblock fuer Basic-Manager
- 	SbLanguageMode	eLanguageMode;		// LanguageMode des Basic-Objekts
- protected:
-@@ -124,7 +126,8 @@ public:
- 
- 	// Compiler-Interface
- 	SbModule*   	MakeModule( const String& rName, const String& rSrc );
--    SbModule*   	MakeModule32( const String& rName, const ::rtl::OUString& rSrc );
-+    SbModule*       MakeModule32( const String& rName, const ::rtl::OUString& rSrc );
-+    SbModule*       MakeObjModule( const String& rName, const com::sun::star::script::ModuleInfo& mInfo );
- 	BOOL			Compile( SbModule* );
- 	BOOL 			Disassemble( SbModule*, String& rText );
- 	static void 	Stop();
-@@ -196,6 +199,8 @@ public:
- 					( const String& rName, USHORT& rStatus );
- 	static SbMethod* GetActiveMethod( USHORT nLevel = 0 );
- 	static SbModule* GetActiveModule();
-+    void SetVBAEnabled( BOOL bEnabled );
-+    BOOL isVBAEnabled();
- 
- 	// #60175 TRUE: SFX-Resource wird bei Basic-Fehlern nicht angezogen
- 	static void StaticSuppressSfxResource( BOOL bSuppress );
-diff -rup /data4/OOOBuildM12/ooo-build/build/ooh680-m12/basic/inc/basic/sbxobj.hxx basic/inc/basic/sbxobj.hxx
---- /data4/OOOBuildM12/ooo-build/build/ooh680-m12/basic/inc/basic/sbxobj.hxx	2007-04-11 13:55:16.000000000 +0100
-+++ basic/inc/basic/sbxobj.hxx	2008-03-28 10:30:34.000000000 +0000
-@@ -80,7 +80,7 @@ public:
- 	virtual SbxClassType GetClass() const;
- 	virtual void Clear();
- 
--	virtual BOOL  IsClass( const String& ) const;
-+	virtual BOOL  IsClass( const String& );
- 	const String& GetClassName() const { return aClassName; }
- 	void		  SetClassName( const String &rNew ) { aClassName = rNew; }
- 	// Default-Property
-diff -rup /data4/OOOBuildM12/ooo-build/build/ooh680-m12/basic/source/basmgr/basmgr.cxx basic/source/basmgr/basmgr.cxx
---- /data4/OOOBuildM12/ooo-build/build/ooh680-m12/basic/source/basmgr/basmgr.cxx	2007-08-30 10:58:48.000000000 +0100
-+++ basic/source/basmgr/basmgr.cxx	2008-03-28 10:30:34.000000000 +0000
-@@ -102,6 +102,8 @@
- #include <com/sun/star/script/XStarBasicDialogInfo.hpp>
- #include <com/sun/star/script/XStarBasicLibraryInfo.hpp>
- #include <com/sun/star/script/XLibraryContainerPassword.hpp>
-+#include <com/sun/star/script/ModuleInfo.hpp>
-+#include <com/sun/star/script/ModuleType.hpp>
- 
- #include <cppuhelper/implbase1.hxx>
- 
-@@ -145,6 +147,7 @@ static const char* szScriptLanguage = "S
- static const String BasicStreamName( String::CreateFromAscii(szBasicStorage) );
- static const String ManagerStreamName( String::CreateFromAscii(szManagerStream) );
- 
-+//enum ModuleType { Unknown = 0, Normal, Class, Form, Document };
- 
- #define	DEFINE_CONST_UNICODE(CONSTASCII)    UniString(RTL_CONSTASCII_USTRINGPARAM(CONSTASCII))
- 
-@@ -280,9 +283,22 @@ void BasMgrContainerListenerImpl::addLib
- 		{
- 			OUString aModuleName = pNames[ j ];
- 			Any aElement = xLibNameAccess->getByName( aModuleName );
-+            ModuleInfo mInfo;
- 			OUString aMod;
--			aElement >>= aMod;
--			pLib->MakeModule32( aModuleName, aMod );
-+            sal_Int16 mType;
-+            if ( aElement >>= mInfo )
-+            {
-+                aMod = mInfo.ModuleSource;
-+                mType = mInfo.ModuleType;
-+                OSL_TRACE("#1 - aMod");
-+                //pLib->MakeModule32( aModuleName, aMod, SBXID_DOCUMENTMOD );
-+                pLib->MakeObjModule( aModuleName, mInfo );
-+            }
-+            else
-+            {
-+			    aElement >>= aMod;
-+			    pLib->MakeModule32( aModuleName, aMod );
-+            }
- 		}
- 	}
- 
-@@ -319,8 +335,16 @@ void SAL_CALL BasMgrContainerListenerImp
- 	}
- 	else
- 	{
-+        ModuleInfo mInfo;
- 		OUString aMod;
--		Event.Element >>= aMod;
-+        sal_Int16 mType;
-+        if( Event.Element >>= mInfo )
-+        {
-+            aMod = mInfo.ModuleSource;
-+            mType = mInfo.ModuleType;
-+        }
-+        else
-+		    Event.Element >>= aMod;
- 
- 		StarBASIC* pLib = mpMgr->GetLib( maLibName );
- 		DBG_ASSERT( pLib, "BasMgrContainerListenerImpl::elementInserted: Unknown lib!");
-@@ -329,7 +353,15 @@ void SAL_CALL BasMgrContainerListenerImp
-     		SbModule* pMod = pLib->FindModule( aName );
-             if( !pMod )
-             {
--			    pLib->MakeModule32( aName, aMod );
-+                if ( mType == ::com::sun::star::script::ModuleType::Document )
-+                {
-+                    //pLib->MakeModule32( aName, aMod, SBXID_DOCUMENTMOD );
-+                    pLib->MakeObjModule( aName, mInfo );
-+                }
-+                else
-+                {
-+			        pLib->MakeModule32( aName, aMod );
-+                }
- 			    pLib->SetModified( FALSE );
-             }
- 		}
-@@ -356,12 +388,27 @@ void SAL_CALL BasMgrContainerListenerImp
- 	if( pLib )
- 	{
- 		SbModule* pMod = pLib->FindModule( aName );
-+        ModuleInfo mInfo;
- 		OUString aMod;
-+        sal_Int16 mType;
- 		Event.Element >>= aMod;
- 		if( pMod )
- 			pMod->SetSource32( aMod );
- 		else
--			pLib->MakeModule32( aName, aMod );
-+        {
-+            if( Event.Element >>= mInfo )
-+            {
-+                aMod = mInfo.ModuleSource;
-+                mType = mInfo.ModuleType;
-+                //pLib->MakeModule32( aName, aMod, SBXID_DOCUMENTMOD );
-+                pLib->MakeObjModule( aName, mInfo );
-+            }
-+            else
-+            {
-+                Event.Element >>= aMod;
-+			    pLib->MakeModule32( aName, aMod );
-+            }
-+        }
- 
- 		pLib->SetModified( FALSE );
- 	}
-diff -rup /data4/OOOBuildM12/ooo-build/build/ooh680-m12/basic/source/classes/sb.cxx basic/source/classes/sb.cxx
---- /data4/OOOBuildM12/ooo-build/build/ooh680-m12/basic/source/classes/sb.cxx	2008-03-29 23:08:18.000000000 +0000
-+++ basic/source/classes/sb.cxx	2008-03-28 10:30:34.000000000 +0000
-@@ -70,6 +70,7 @@
- #include "disas.hxx"
- #include "runtime.hxx"
- #include <basic/sbuno.hxx>
-+#include <basic/sbobjmod.hxx>
- #include "stdobj.hxx"
- #include "filefmt.hxx"
- #include "sb.hrc"
-@@ -79,6 +80,10 @@
- #include <vos/mutex.hxx>
- #endif
- 
-+#include <com/sun/star/script/ModuleType.hpp>
-+#include <com/sun/star/script/ModuleInfo.hpp>
-+using namespace ::com::sun::star::script;
-+
- // #pragma SW_SEGMENT_CLASS( SBASIC, SBASIC_CODE )
- 
- SV_IMPL_VARARR(SbTextPortions,SbTextPortion)
-@@ -667,6 +672,7 @@ StarBASIC::StarBASIC( StarBASIC* p, BOOL
- 	SetParent( p );
- 	pLibInfo = NULL;
- 	bNoRtl = bBreak = FALSE;
-+    bVBAEnabled = FALSE;
- 	pModules = new SbxArray;
- 
- 	if( !GetSbData()->nInst++ )
-@@ -769,13 +775,36 @@ SbModule* StarBASIC::MakeModule( const S
- 
- SbModule* StarBASIC::MakeModule32( const String& rName, const ::rtl::OUString& rSrc )
- {
--	SbModule* p = new SbModule( rName );
-+    SbModule* p = new SbModule( rName );
- 	p->SetSource32( rSrc );
- 	p->SetParent( this );
- 	pModules->Insert( p, pModules->Count() );
- 	SetModified( TRUE );
- 	return p;
- }
-+SbModule* StarBASIC::MakeObjModule( const String& rName, const ModuleInfo& mInfo )
-+{
-+    
-+    SbObjModule* p = NULL;
-+    switch ( mInfo.ModuleType )
-+    {
-+        case ModuleType::Document:
-+            p = new SbObjModule( rName, mInfo );
-+            break;
-+        case ModuleType::Form:
-+            p = new SbUserFormModule( rName, mInfo );
-+            break;
-+        default:
-+            break; // 
-+    }
-+    if ( p )
-+    {
-+ 	pModules->Insert( p, pModules->Count() );
-+	SetModified( TRUE );
-+	p->SetParent( this );
-+    }
-+    return p;
-+}
- 
- void StarBASIC::Insert( SbxVariable* pVar )
- {
-@@ -948,6 +977,9 @@ SbxVariable* StarBASIC::Find( const Stri
- 				}
- 				pNamed = p;
- 			}
-+            if ( p->GetSbxId() == SBXID_DOCUMENTMOD 
-+            || p->GetSbxId() == SBXID_USERFORMMOD )
-+                 continue;
- 			// Sonst testen, ob das Element vorhanden ist
- 			// GBLSEARCH-Flag rausnehmen (wg. Rekursion)
- 			USHORT nGblFlag = p->GetFlags() & SBX_GBLSEARCH;
---- /data4/OOOBuildM12/ooo-build/build/ooh680-m12/basic/source/classes/sbxmod.cxx	2008-04-08 12:03:51.000000000 +0100
-+++ basic/source/classes/sbxmod.cxx	2008-04-06 21:34:40.000000000 +0100
-@@ -51,6 +51,9 @@
- #include <basic/hilight.hxx>
- #include <basic/basrdll.hxx>
- #include <vos/mutex.hxx>
-+#include <basic/sbobjmod.hxx>
-+#include <com/sun/star/script/XObjectProvider.hpp>
-+#include <com/sun/star/lang/XServiceInfo.hpp>
- 
- // for the bsearch
- #ifdef WNT
-@@ -80,7 +83,20 @@
- 
- #include <stdio.h>
- 
-+#include <comphelper/processfactory.hxx>
-+#include <com/sun/star/script/XLibraryContainer.hpp>
-+#include <com/sun/star/lang/XMultiServiceFactory.hpp>
-+#include <com/sun/star/awt/XDialogProvider.hpp>
-+#include <com/sun/star/awt/XTopWindow.hpp>
-+#include <com/sun/star/awt/XControl.hpp>
-+#include <com/sun/star/frame/XModel.hpp>
-+#include <cppuhelper/implbase1.hxx>
-+#include <comphelper/anytostring.hxx>
-+
-+using namespace ::com::sun::star; 
-+
- static const String sThisWorkbook( RTL_CONSTASCII_USTRINGPARAM("ThisWorkbook"));
-+static const rtl::OUString sStandard( RTL_CONSTASCII_USTRINGPARAM("Standard") );
- 
- TYPEINIT1(SbModule,SbxObject)
- TYPEINIT1(SbMethod,SbxMethod)
-@@ -88,6 +104,8 @@ TYPEINIT1(SbProperty,SbxProperty)
- TYPEINIT1(SbProcedureProperty,SbxProperty)
- TYPEINIT1(SbJScriptModule,SbModule)
- TYPEINIT1(SbJScriptMethod,SbMethod)
-+TYPEINIT1(SbObjModule,SbModule)
-+TYPEINIT1(SbUserFormModule,SbModule)
- 
- SV_DECL_VARARR(SbiBreakpoints,USHORT,4,4)
- SV_IMPL_VARARR(SbiBreakpoints,USHORT)
-@@ -1903,6 +1921,307 @@ void SyntaxHighlighter::getHighlightPort
- 	m_pSimpleTokenizer->getHighlightPortions( nLine, rLine, portions );
- }
- 
-+/////////////////////////////////////////////////////////////////////////
-+SbObjModule::SbObjModule( const rtl::OUString& rName, const com::sun::star::script::ModuleInfo& mInfo )
-+    :SbModule( rName ), pDocObject( NULL )
-+{
-+    m_mInfo = mInfo;
-+    SetSource32( mInfo.ModuleSource );
-+}
-+
-+BOOL
-+SbObjModule::IsClass( const XubString& rName )
-+{
-+    GetObject();
-+    return SbxObject::IsClass( rName );
-+}
-+
-+SbxVariable*
-+SbObjModule::GetObject() 
-+{
-+    if( !pDocObject )
-+        InitObject();
-+    return pDocObject;
-+}
-+SbxVariable*
-+SbObjModule::Find( const XubString& rName, SbxClassType t )
-+{
-+    //OSL_TRACE("SbObjectModule find for %s", rtl::OUStringToOString(  rName, RTL_TEXTENCODING_UTF8 ).getStr() );
-+    if ( !pDocObject )
-+        InitObject();
-+    //OSL_TRACE("!!!!try to find in derived module " );
-+    SbxVariable* pVar = NULL;
-+    if ( !pVar && pDocObject)
-+    {
-+        pVar = pDocObject->Find( rName, t );
-+        if ( pVar )
-+        {
-+           //OSL_TRACE("found in uno (psuedo-base) object" );
-+        }
-+        else
-+	{
-+           //OSL_TRACE("NOT found in uno (psuedo-base) object" );
-+	}
-+    }
-+    if ( !pVar )
-+    {
-+        pVar = SbModule::Find( rName, t );
-+        if ( pVar )
-+	{
-+           //OSL_TRACE("! found in (normal) module " );
-+	}
-+    }
-+
-+    return pVar;
-+}
+-                    if ( !bAsComment && ( xVBAObjectProvider.is() && mType == ModuleType::Document ) )
++                    if ( !bAsComment && ( xVBAObjectProvider.is() && mType == ModuleType::Document ) || mType == ModuleType::Form )
+                     {
+                         script::ModuleInfo sModuleInfo;
+                         sModuleInfo.ModuleName = aModName;
+                         sModuleInfo.ModuleSource = aSource;
+                         sModuleInfo.ModuleType = mType;
+-                        sModuleInfo.ModuleObjectProvider.set( xVBAObjectProvider, UNO_QUERY );
++                        if ( mType == ModuleType::Form )
++                            sModuleInfo.ModuleObjectProvider.set( rDocSh.GetModel(), UNO_QUERY );
++                        else
++                            sModuleInfo.ModuleObjectProvider.set( xVBAObjectProvider, UNO_QUERY );
+                         aSourceAny <<= sModuleInfo;
+                     }
+                     else
+--- basic/inc/basic/sbdef.hxx	2008-05-13 16:25:54.000000000 +0100
++++ basic/inc/basic/sbdef.hxx	2008-05-13 16:31:44.000000000 +0100
+@@ -99,6 +99,8 @@ void setBasicWatchMode( bool bOn );
+ #define SBX_HINT_BASICSTART		SFX_HINT_USER04
+ #define SBX_HINT_BASICSTOP		SFX_HINT_USER05
+ 
++#define SBXID_USERFORMMOD   0x6d64          // Special userform Module
 +
-+void
-+SbObjModule::InitObject()
-+{
-+   // OSL_TRACE("Initialize pDocObject");
-+    try
-+    {
-+        com::sun::star::uno::Reference< com::sun::star::script::XObjectProvider > xObjectProvider( m_mInfo.ModuleObjectProvider, com::sun::star::uno::UNO_QUERY_THROW );
-+        com::sun::star::uno::Any aObject = xObjectProvider->getObject();
-+        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" ) );
-+        }
-+    }catch( com::sun::star::uno::RuntimeException e )
-+    {
-+        //OSL_TRACE("Object is not exist." );
-+    }
-+}
+ // #115826
+ enum PropertyMode
+ {
+--- basic/source/classes/sb.cxx	2008-05-13 16:25:54.000000000 +0100
++++ basic/source/classes/sb.cxx	2008-05-13 16:37:22.000000000 +0100
+@@ -770,6 +770,9 @@ SbModule* StarBASIC::MakeObjModule( cons
+         case ModuleType::Document:
+             p = new SbObjModule( rName, mInfo );
+             break;
++        case ModuleType::Form:
++            p = new SbUserFormModule( rName, mInfo );
++            break;
+         default:
+             break; // 
+     }
+@@ -953,7 +956,8 @@ SbxVariable* StarBASIC::Find( const Stri
+ 				}
+ 				pNamed = p;
+ 			}
+-            if ( p->GetSbxId() == SBXID_DOCUMENTMOD )
++            if ( p->GetSbxId() == SBXID_DOCUMENTMOD 
++            || p->GetSbxId() == SBXID_USERFORMMOD )
+                 continue;
+ 			// Sonst testen, ob das Element vorhanden ist
+ 			// GBLSEARCH-Flag rausnehmen (wg. Rekursion)
+--- basic/source/classes/sbxmod.cxx	2008-05-13 16:25:54.000000000 +0100
++++ basic/source/classes/sbxmod.cxx	2008-05-13 16:43:53.000000000 +0100
+@@ -96,6 +96,7 @@ SV_IMPL_VARARR(SbiBreakpoints,USHORT)
+ 
+ 
+ SV_IMPL_VARARR(HighlightPortions, HighlightPortion)
++TYPEINIT1(SbUserFormModule,SbObjModule)
+ 
+ // ##########################################################################
+ // ACHTUNG!!!  Alle Woerter dieser Tabelle müKLEIN geschrieben werden!!!
+@@ -2226,3 +2227,199 @@ SbObjModule::InitObject()
+         //OSL_TRACE("Object is not exist." );
+     }
+ }
 +
 +typedef ::cppu::WeakImplHelper1< awt::XTopWindowListener > EventListener_BASE;
 +
 +class FormObjEventListenerImpl : public EventListener_BASE
 +{
-+    class ActivateGuard 
-+    {
-+    public:
-+        ActivateGuard() { ++getCounter(); }	
-+        virtual ~ActivateGuard() { --getCounter(); }	
-+        virtual int& getCounter()
-+        {
-+            static int activateCount = 0;
-+            return activateCount;
-+        }
-+        bool alreadyProcessing() { return ( getCounter() > 1 ); }
-+    };
-+
-+    class DeActivateGuard 
-+    {
-+    public:
-+        DeActivateGuard() { ++getCounter(); }	
-+        virtual ~DeActivateGuard() { --getCounter(); }	
-+        virtual int& getCounter()
-+        {
-+            static int deactivateCount = 0;
-+            return deactivateCount;
-+        }
-+        bool alreadyProcessing() { return ( getCounter() > 1 ); }
-+    };
-+
 +    SbUserFormModule* mpUserForm;
 +    uno::Reference< lang::XComponent > mxComponent;
 +    bool mbDisposed;
@@ -1701,16 +113,12 @@
 +    virtual void SAL_CALL windowNormalized( const lang::EventObject& /*e*/ ) throw (uno::RuntimeException){}
 +    virtual void SAL_CALL windowActivated( const lang::EventObject& /*e*/ ) throw (uno::RuntimeException)
 +    {
-+//        ActivateGuard aGuard;
-+//        if ( mpUserForm && !aGuard.alreadyProcessing() )
 +        if ( mpUserForm  )
 +            mpUserForm->triggerActivateEvent();
 +    }
 +   
 +    virtual void SAL_CALL windowDeactivated( const lang::EventObject& /*e*/ ) throw (uno::RuntimeException)
 +    {
-+//        DeActivateGuard aGuard;
-+//        if ( mpUserForm && !aGuard.alreadyProcessing() )
 +        if ( mpUserForm  )
 +            mpUserForm->triggerDeActivateEvent();
 +    }
@@ -1852,55 +260,42 @@
 +{
 +    return SbObjModule::Find( rName, t );
 +}
++
++
+--- basic/inc/basic/sbobjmod.hxx	2008-05-13 16:25:54.000000000 +0100
++++ basic/inc/basic/sbobjmod.hxx	2008-05-13 16:46:58.000000000 +0100
+@@ -61,6 +61,31 @@ public:
+ 	virtual BOOL  IsClass( const String& );
+ };
  
- /////////////////////////////////////////////////////////////////////////
- // Implementation SbJScriptModule (Basic-Modul fuer JavaScript-Sourcen)
-diff -rup /data4/OOOBuildM12/ooo-build/build/ooh680-m12/basic/source/runtime/methods1.cxx basic/source/runtime/methods1.cxx
---- /data4/OOOBuildM12/ooo-build/build/ooh680-m12/basic/source/runtime/methods1.cxx	2007-09-20 16:55:19.000000000 +0100
-+++ basic/source/runtime/methods1.cxx	2008-03-28 10:30:34.000000000 +0000
-@@ -44,6 +44,7 @@
- #ifndef _SBX_HXX
- #include <basic/sbx.hxx>
- #endif
-+#include <basic/sbstar.hxx>
- #include <svtools/zforlist.hxx>
- #include <tools/fsys.hxx>
- #include <tools/urlobj.hxx>
-@@ -86,6 +89,7 @@
- #endif
- 
- #include <vcl/jobset.hxx>
-+#include <basic/sbobjmod.hxx>
++class SbUserFormModule : public SbObjModule
++{
++    css::uno::Reference<css::lang::XEventListener> m_DialogListener;
++    css::uno::Reference<css::awt::XDialog> m_xDialog;
++    String sFormName;
++
++    bool m_bUnloaded;
++    static USHORT nHideHash;
++protected:
++    virtual void InitObject();
++public:
++    TYPEINFO();
++	SBX_DECL_PERSIST_NODATA(SBXCR_SBX,SBXID_USERFORMMOD,2);
++    SbUserFormModule( const rtl::OUString& rName, const com::sun::star::script::ModuleInfo& mInfo );
++    virtual SbxVariable* Find( const XubString& rName, SbxClassType t );
++    void ResetApiObj( bool bUnloaded = true );
++    void Unload();
++    void load();
++    void triggerMethod( const String& );
++    void triggerActivateEvent();
++    void triggerDeActivateEvent();
++    void triggerInitializeEvent();
++    void triggerTerminateEvent();
++};
++
+ #ifndef __SB_SBOBJMODULEREF_HXX
+ #define __SB_SBOBJMODULEREF_HXX
  
- #include "sbintern.hxx"
- #include "runtime.hxx"
-@@ -2611,13 +2615,22 @@ RTLFUNC(Me)
-     
- 	SbModule* pActiveModule = pINST->GetActiveModule();
- 	SbClassModuleObject* pClassModuleObject = PTR_CAST(SbClassModuleObject,pActiveModule);
-+    SbxVariableRef refVar = rPar.Get(0);
- 	if( pClassModuleObject == NULL )
- 	{
--		StarBASIC::Error( SbERR_INVALID_USAGE_OBJECT );
-+        SbObjModule* pMod = PTR_CAST(SbObjModule,pActiveModule);
-+        if ( pMod == NULL )
-+        {
-+            SbUserFormModule* pFormMod = PTR_CAST(SbUserFormModule,pActiveModule);
-+            if ( !pFormMod )
-+		        StarBASIC::Error( SbERR_INVALID_USAGE_OBJECT );
-+            else
-+                refVar->PutObject( pFormMod );
-+  
-+        }
-+        else
-+            refVar->PutObject( pMod );
- 	}
- 	else
--	{
--		SbxVariableRef refVar = rPar.Get(0);
- 		refVar->PutObject( pClassModuleObject );
--	}
- }
 diff -rup /data4/OOOBuildM12/ooo-build/build/ooh680-m12/basic/source/runtime/methods.cxx basic/source/runtime/methods.cxx
 --- /data4/OOOBuildM12/ooo-build/build/ooh680-m12/basic/source/runtime/methods.cxx	2008-03-29 23:08:19.000000000 +0000
 +++ basic/source/runtime/methods.cxx	2008-03-28 10:30:34.000000000 +0000
@@ -1941,247 +336,128 @@
  	{
  		SbxVariable* pVar = ((SbxObject*)pObj)->
  			Find( String( RTL_CONSTASCII_USTRINGPARAM("Unload") ), SbxCLASS_METHOD );
-diff -rup /data4/OOOBuildM12/ooo-build/build/ooh680-m12/basic/source/runtime/runtime.cxx basic/source/runtime/runtime.cxx
---- /data4/OOOBuildM12/ooo-build/build/ooh680-m12/basic/source/runtime/runtime.cxx	2008-03-29 23:08:19.000000000 +0000
-+++ basic/source/runtime/runtime.cxx	2008-03-29 00:19:02.000000000 +0000
-@@ -82,6 +82,17 @@ void StarBASIC::StaticEnableReschedule( 
- {
-     bStaticGlobalEnableReschedule = bReschedule;
- }
-+void StarBASIC::SetVBAEnabled( BOOL bEnabled )
-+{
-+    bVBAEnabled = bEnabled;
-+}
-+
-+BOOL StarBASIC::isVBAEnabled()
-+{
-+    if( SbiRuntime::isVBAEnabled() )
-+        return TRUE;
-+    return bVBAEnabled;
-+}
- 
- 
- struct SbiArgvStack {					// Argv stack:
-diff -rup /data4/OOOBuildM12/ooo-build/build/ooh680-m12/basic/source/sbx/sbxobj.cxx basic/source/sbx/sbxobj.cxx
---- /data4/OOOBuildM12/ooo-build/build/ooh680-m12/basic/source/sbx/sbxobj.cxx	2007-06-27 15:31:34.000000000 +0100
-+++ basic/source/sbx/sbxobj.cxx	2008-03-28 10:30:34.000000000 +0000
-@@ -187,7 +187,7 @@ void SbxObject::SFX_NOTIFY( SfxBroadcast
- 	}
- }
- 
--BOOL SbxObject::IsClass( const XubString& rName ) const
-+BOOL SbxObject::IsClass( const XubString& rName )
- {
- 	return BOOL( aClassName.EqualsIgnoreCaseAscii( rName ) );
- }
-diff -rup /data4/OOOBuildM12/ooo-build/build/ooh680-m12/basic/source/uno/namecont.cxx basic/source/uno/namecont.cxx
---- /data4/OOOBuildM12/ooo-build/build/ooh680-m12/basic/source/uno/namecont.cxx	2008-02-26 17:01:46.000000000 +0000
-+++ basic/source/uno/namecont.cxx	2008-03-28 10:30:34.000000000 +0000
-@@ -139,6 +139,9 @@
- #endif
- #include <basic/sbmod.hxx>
+--- /data4/OOOBuildM12/ooo-build/build/ooh680-m12/svx/inc/svx/msocximex.hxx	2008-04-02 12:14:58.000000000 +0100
++++ svx/inc/svx/msocximex.hxx	2008-04-01 15:22:20.000000000 +0100
+@@ -298,6 +298,7 @@ public:
+ 	sal_Int32 mnForeColor;
+         sal_uInt16 mnTabPos;
+ 	UniString sName;
++	UniString msToolTip;
+ 	OCX_FontData aFontData;
+         SfxObjectShell *pDocSh;
+ protected:
+@@ -908,7 +908,7 @@ public:
+ 	sal_uInt8   nKeepScrollBarsVisible;
+ 	sal_uInt8   nCycle;
+ 	sal_uInt16	nBorderStyle;
+-	sal_uInt16	nSpecialEffect;
++	sal_uInt8	nSpecialEffect;
+ 	sal_uInt16	nPicture;
+ 	sal_uInt8   nPictureAlignment;
+ 	sal_uInt8   nPictureSizeMode;
+--- /data4/OOOBuildM12/ooo-build/build/ooh680-m12/svx/source/msfilter/msocximex.cxx	2008-04-02 15:01:33.000000000 +0100
++++ svx/source/msfilter/msocximex.cxx	2008-04-02 14:49:08.000000000 +0100
+@@ -746,13 +746,16 @@ class ContainerRecReader
+                 ReadAlign( pS, pS->Tell() - nStartPos, 4 );
+                 *pS >> rec.nLeft >> rec.nTop;
+             }
+-
++   
+             // control infotip
+             sal_uInt32 nTipBufSize = lclGetBufferSize( nTipLen );
+             if( nTipBufSize > 0 )
+             {
++                std::auto_ptr< sal_Char > pTipName;
++                pTipName.reset( new sal_Char[ nTipBufSize ] );
+                 ReadAlign( pS, pS->Tell() - nStartPos, 4 );
+-                pS->SeekRel( nTipBufSize );
++                pS->Read( pTipName.get(), nTipBufSize );
++            	rec.controlTip = lclCreateOUString( pTipName.get(), nTipLen );
+             }
+             // control id
+             sal_uInt32 nCntrlIdSize = lclGetBufferSize( nCntrlIdLen );
+@@ -1262,6 +1265,11 @@ sal_Bool OCX_Control::Import(uno::Refere
+     xPropSet->setPropertyValue(WW8_ASCII2STR("Width"), aTmp);
+     aTmp <<= sal_Int32((nHeight * 2) / 100);
+     xPropSet->setPropertyValue(WW8_ASCII2STR("Height"), aTmp);
++    if ( msToolTip.Len() > 0 )
++    {
++	uno::Any aTmp(&msToolTip,getCppuType((OUString *)0));
++        xPropSet->setPropertyValue(WW8_ASCII2STR("HelpText"), aTmp);
++    }
  
-+#ifndef _COM_SUN_STAR_SCRIPT_MODULEINFO_HPP_
-+#include <com/sun/star/script/ModuleInfo.hpp>
-+#endif
+     if ( mnStep )
+     {
+@@ -3664,6 +3666,7 @@ void OCX_ContainerControl::ProcessContro
+         }
  
- namespace basic
- {
-@@ -217,7 +220,7 @@ void NameContainer::replaceByName( const
- 	throw(IllegalArgumentException, NoSuchElementException, WrappedTargetException, RuntimeException)
+         pControl->sName = rec.cName;
++        pControl->msToolTip = rec.controlTip;
+         // Position of controls is relative to the container
+         pControl->mnTop = rec.nTop + mnTop;
+         pControl->mnLeft = rec.nLeft + mnLeft;
+@@ -3750,7 +3750,8 @@ OCX_MultiPage::OCX_MultiPage( SotStorage
+ 		nScrollWidth(0), nScrollHeight(0), nIconLen(0), pIcon(0), nPictureLen(0),
+ 		pPicture(0)
  {
- 	Type aAnyType = aElement.getValueType();
--	if( mType != aAnyType )
-+    if( mType != aAnyType && aAnyType != getCppuType( static_cast< ModuleInfo* >( NULL ) ) )
- 		throw IllegalArgumentException();
- 
- 	NameContainerNameMap::iterator aIt = mHashMap.find( aName );
-@@ -259,7 +262,7 @@ void NameContainer::insertByName( const 
- 	throw(IllegalArgumentException, ElementExistException, WrappedTargetException, RuntimeException)
+-    msDialogType = C2U("NotSupported");
++    //msDialogType = C2U("NotSupported");
++    msDialogType = C2U("com.sun.star.awt.UnoMultiPageModel");
+     mnForeColor = 0x80000012L,
+     mnBackColor = 0x8000000FL;
+     bSetInDialog = true;// UserForm control only
+@@ -3814,7 +3815,6 @@ sal_Bool OCX_MultiPage::Read(SvStorageSt
+ sal_Bool OCX_MultiPage::Import(com::sun::star::uno::Reference<
+     com::sun::star::beans::XPropertySet> &rPropSet)
  {
- 	Type aAnyType = aElement.getValueType();
--	if( mType != aAnyType )
-+    if( mType != aAnyType && aAnyType != getCppuType( static_cast< ModuleInfo* >( NULL ) ) )
- 		throw IllegalArgumentException();
+-    // Calls import on contained controls
+     OCX_ContainerControl::Import( rPropSet );
+     return sal_True;
+ }
+@@ -3835,6 +3835,43 @@ sal_Bool OCX_MultiPage::Import(com::sun:
  
- 	NameContainerNameMap::iterator aIt = mHashMap.find( aName );
---- /dev/null	2007-05-04 11:54:36.000000000 +0100
-+++ basic/inc/basic/sbobjmod.hxx	2008-04-02 17:40:27.000000000 +0100
-@@ -0,0 +1,97 @@
-+/*************************************************************************
-+ *
-+ *  OpenOffice.org - a multi-platform office productivity suite
-+ *
-+ *  $RCSfile: sbobjmod.hxx,v $
-+ *
-+ *  $Revision: 1.4 $
-+ *
-+ *  last change: $Author:  $ $Date: 2007/08/27 16:31:39 $
-+ *
-+ *  The Contents of this file are made available subject to
-+ *  the terms of GNU Lesser General Public License Version 2.1.
-+ *
-+ *
-+ *    GNU Lesser General Public License Version 2.1
-+ *    =============================================
-+ *    Copyright 2005 by Sun Microsystems, Inc.
-+ *    901 San Antonio Road, Palo Alto, CA 94303, USA
-+ *
-+ *    This library is free software; you can redistribute it and/or
-+ *    modify it under the terms of the GNU Lesser General Public
-+ *    License version 2.1, as published by the Free Software Foundation.
-+ *
-+ *    This library 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 for more details.
-+ *
-+ *    You should have received a copy of the GNU Lesser General Public
-+ *    License along with this library; if not, write to the Free Software
-+ *    Foundation, Inc., 59 Temple Place, Suite 330, Boston,
-+ *    MA  02111-1307  USA
-+ *
-+ ************************************************************************/
-+
-+#ifndef _SB_OBJMOD_HXX
-+#define _SB_OBJMOD_HXX
-+
-+#include <basic/sbmod.hxx>
-+#include <basic/sbstar.hxx>
-+#include <com/sun/star/script/ModuleInfo.hpp>
-+#include <com/sun/star/lang/XEventListener.hpp>
-+#include <com/sun/star/awt/XDialog.hpp>
-+
-+namespace css = ::com::sun::star;
-+
-+// Basic-Module for excel object.
+     if ( xPropSet.is() )
+     {
++        uno::Reference<lang::XMultiServiceFactory>
++            xFactory(rDialog, uno::UNO_QUERY);
++	OSL_TRACE("** MultiPage creating control %s", rtl::OUStringToOString( msDialogType, RTL_TEXTENCODING_UTF8 ).getStr() );
++	uno::Reference<uno::XInterface> xCreate = xFactory->createInstance(msDialogType);
++	if (!xCreate.is())
++		return sal_False;
 +
-+class SbObjModule : public SbModule
-+{
-+protected:
-+    com::sun::star::script::ModuleInfo m_mInfo;
-+    SbxObjectRef pDocObject; // a vba api object.
-+    virtual void InitObject();
-+public:
-+    TYPEINFO();
-+	SBX_DECL_PERSIST_NODATA(SBXCR_SBX,SBXID_DOCUMENTMOD,2);
-+    SbObjModule( const rtl::OUString& rName, const com::sun::star::script::ModuleInfo& mInfo );
-+    virtual SbxVariable* Find( const XubString& rName, SbxClassType t );
-+    SbxVariable* GetObject();
-+	virtual BOOL  IsClass( const String& );
-+};
++	uno::Reference<awt::XControlModel> xModel(xCreate, uno::UNO_QUERY);
++	if (!xModel.is())
++		return sal_False;
 +
-+class SbUserFormModule : public SbObjModule
-+{
-+    css::uno::Reference<css::lang::XEventListener> m_DialogListener;
-+    css::uno::Reference<css::awt::XDialog> m_xDialog;
-+    String sFormName;
++        try
++        {
++		// we should just call MultiPage::Import( XPropertySet )
++    		OSL_TRACE("********* MULTIPAGE cName %s", rtl::OUStringToOString( sName, RTL_TEXTENCODING_UTF8 ).getStr() );
++		uno::Any aTmp(&sName,getCppuType((OUString *)0));
++		uno::Reference<beans::XPropertySet> xPrps(xModel, uno::UNO_QUERY);
++		xPrps->setPropertyValue( WW8_ASCII2STR("Name"), aTmp );
++		aTmp = uno::makeAny( mnCurrentPageStep );
++		xPrps->setPropertyValue( WW8_ASCII2STR("ProgressValueMax"), aTmp );
++		// default current page to 0 ( #FIXME, we need to read this value )
++		aTmp = uno::makeAny( sal_Int32(0) );
++		xPrps->setPropertyValue( WW8_ASCII2STR("ProgressValue"), aTmp );
++    		OSL_TRACE("********* MULTIPAGE vomitted out properties");
 +
-+    bool m_bUnloaded;
-+    static USHORT nHideHash;
-+protected:
-+    virtual void InitObject();
-+public:
-+    TYPEINFO();
-+	SBX_DECL_PERSIST_NODATA(SBXCR_SBX,SBXID_USERFORMMOD,2);
-+    SbUserFormModule( const rtl::OUString& rName, const com::sun::star::script::ModuleInfo& mInfo );
-+    virtual SbxVariable* Find( const XubString& rName, SbxClassType t );
-+    void ResetApiObj( bool bUnloaded = true );
-+    void Unload();
-+    void load();
-+    void triggerMethod( const String& );
-+    void triggerActivateEvent();
-+    void triggerDeActivateEvent();
-+    void triggerInitializeEvent();
-+    void triggerTerminateEvent();
-+};
++    // Calls import on contained controls
++            rDialog->insertByName(sName, uno::makeAny(xModel));
++            OSL_TRACE("*** inserted ***");
++        }
++        catch( uno::Exception& )
++        {
++            DBG_ERRORFILE(
++                ByteString( "OCX_Control::Import - cannot insert control \"" ).
++                Append( ByteString( sName, RTL_TEXTENCODING_UTF8 ) ).
++                Append( '"' ).GetBuffer() );
++        }
 +
-+SV_DECL_IMPL_REF(SbUserFormModule);
-+#ifndef __SB_SBOBJMODULEREF_HXX
-+#define __SB_SBOBJMODULEREF_HXX
-+
-+SV_DECL_IMPL_REF(SbObjModule);
-+
-+#endif
-+#endif
-+
-diff -rup /data4/OOOBuildM12/ooo-build/build/ooh680-m12/sfx2/source/doc/docmacromode.cxx sfx2/source/doc/docmacromode.cxx
---- /data4/OOOBuildM12/ooo-build/build/ooh680-m12/sfx2/source/doc/docmacromode.cxx	2008-01-24 15:54:21.000000000 +0000
-+++ sfx2/source/doc/docmacromode.cxx	2008-03-28 10:30:34.000000000 +0000
-@@ -45,6 +45,7 @@
- #include <com/sun/star/task/DocumentMacroConfirmationRequest.hpp>
- #include <com/sun/star/task/InteractionClassification.hpp>
- #include <com/sun/star/security/XDocumentDigitalSignatures.hpp>
-+#include <com/sun/star/script/ModuleInfo.hpp>
- /** === end UNO includes === **/
- 
- #include <comphelper/componentcontext.hxx>
-@@ -80,8 +81,11 @@ namespace sfx2
-     using ::com::sun::star::document::XEmbeddedScripts;
-     using ::com::sun::star::uno::UNO_SET_THROW;
-     using ::com::sun::star::script::XLibraryContainer;
-+    using ::com::sun::star::script::ModuleInfo;
-     using ::com::sun::star::container::XNameAccess;
-+    using ::com::sun::star::container::XNameContainer;
-     using ::com::sun::star::uno::UNO_QUERY_THROW;
-+    using ::com::sun::star::uno::Sequence;
- 	/** === end UNO using === **/
-     namespace MacroExecMode = ::com::sun::star::document::MacroExecMode;
- 
-@@ -427,7 +431,7 @@ namespace sfx2
-                     bHasMacroLib = sal_False;
-                 else
- 			    {
--				    ::rtl::OUString aStdLibName( RTL_CONSTASCII_USTRINGPARAM( "Standard" ) );
-+				    ::rtl::OUString aStdLibName( ::rtl::OUString::intern( RTL_CONSTASCII_USTRINGPARAM( "Standard" ) ) );
- 				    Sequence< ::rtl::OUString > aElements = xContainer->getElementNames();
- 				    if ( aElements.getLength() )
- 				    {
-@@ -447,8 +451,43 @@ namespace sfx2
- 						    Any aAny = xContainer->getByName( aStdLibName );
- 						    aAny >>= xLib;
- 						    if ( xLib.is() )
-+                            {
- 							    bHasMacroLib = xLib->hasElements();
--					    }
-+                                if( !bHasMacroLib )
-+                                    return bHasMacroLib;
-+                                // VBA will introduce some empty Object Module
-+                                // If all module only include
-+                                // "Rem Attribute VBA_ModuleType=VBADocumentModule\nOption VBASupport"
-+                                // it should be set bHasMacros as false
-+                                Sequence< ::rtl::OUString > sNames = xLib->getElementNames();
-+                                Reference < XNameContainer > xNameContainer( xContainer->getByName( aStdLibName ), UNO_QUERY_THROW );
-+                                sal_Int32 nCount = sNames.getLength();
-+                                ::rtl::OUString sName;
-+                                Any aCode;
-+                                ModuleInfo sModuleInfo;
-+                                ::rtl::OUString sMod;
-+                                ::rtl::OUString sVbaOptiona( ::rtl::OUString::intern( RTL_CONSTASCII_USTRINGPARAM( "Rem Attribute VBA_ModuleType=VBADocumentModule\nOption VBASupport 1\n" )));
-+                                ::rtl::OUString sVbaOptionb( ::rtl::OUString::intern( RTL_CONSTASCII_USTRINGPARAM( "\r\n" )));
-+                                sVbaOptionb = sVbaOptiona + sVbaOptionb;
-+                                for ( sal_Int32 nMod = 0; nMod < nCount; nMod++ )
-+                                {
-+                                    sName = sNames[nMod];
-+                                    if ( xNameContainer->hasByName( sName ) )
-+                                        aCode = xNameContainer->getByName( sName );
-+                                    if ( aCode >>= sModuleInfo )
-+                                    {
-+                                        sMod = sModuleInfo.ModuleSource;
-+                                        if ( sMod.getLength() && !( sMod.equals( sVbaOptiona ) || sMod.equals( sVbaOptionb ) ) )
-+                                            return bHasMacroLib;
-+                                    }
-+                                    else
-+                                    {
-+                                        return bHasMacroLib;
-+                                    }
-+                                }
-+                                bHasMacroLib = sal_False;
-+					        }
-+                        }
- 				    }
- 			    }
- 		    }
+         // Calls import on contained pages
+         return OCX_ContainerControl::Import( xPropSet );
+     }
 --- /data4/OOOBuildM12/ooo-build/build/ooh680-m12/toolkit/source/controls/unocontrols.cxx	2008-01-24 15:30:00.000000000 +0000
 +++ toolkit/source/controls/unocontrols.cxx	2008-04-11 11:07:03.000000000 +0100
 @@ -1887,6 +1887,77 @@ sal_Bool UnoGroupBoxControl::isTranspare
@@ -2562,124 +838,3 @@
  	// bulletinboard
  	else if (rLocalName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("bulletinboard") ))
  	{
---- sc/source/core/tool/vbaeventshelper.cxx	2008-05-12 17:34:02.000000000 +0100
-+++ sc/source/core/tool/vbaeventshelper.cxx	2008-05-12 17:44:52.000000000 +0100
-@@ -204,11 +204,10 @@ VbaWindowListener::disposing(  const lan
- 
- String ScVbaEventsHelper::getWorkbookModuleName()
- {
--	String sCodeName( RTL_CONSTASCII_USTRINGPARAM("ThisWorkbook") );
-+	String sCodeName; // leave blank to force a search of all modules
- 	if ( ScExtDocOptions* pExtDocOpts = pDoc->GetExtDocOptions() )
- 	{
--		if ( pExtDocOpts->GetDocSettings().maGlobCodeName.Len() > 0 ) 
--			sCodeName = pExtDocOpts->GetDocSettings().maGlobCodeName;
-+		sCodeName = pDoc->GetCodeName();
- 	}
- 	return sCodeName;
- }
-@@ -305,7 +304,8 @@ sal_Bool ScVbaEventsHelper::processDocBe
-     	uno::Sequence< uno::Any > aArgs( 1 );
-     	aArgs[ 0 ] <<= bCancel;
-     	const static String sBeforeClose( RTL_CONSTASCII_USTRINGPARAM("Workbook_BeforeClose") );
--    	String sFullClose = docMacroExists( pShell, String(), sBeforeClose );
-+        rtl::OUString workbookModule = getWorkbookModuleName();
-+    	String sFullClose = docMacroExists( pShell, workbookModule, sBeforeClose );
-     	if ( sFullClose.Len() > 0 )
-     	{ 
-     		if ( !executeWorkBookMacro( pShell, sFullClose, aArgs, aRet ) )
-@@ -512,12 +512,11 @@ void ScVbaEventsHelper::getSheetEventNam
- 
- String ScVbaEventsHelper::getSheetModuleName( SCTAB nTab )
- {
--	ScExtDocOptions* pExtOptions = pDoc->GetExtDocOptions();
--	String aCodeName;
--	pDoc->GetName( nTab, aCodeName);
-+	String aCodeName; // leave blank to force full search
- 	// Use code name if that exists
--	if ( pExtOptions )
--		aCodeName = pExtOptions->GetCodeName( nTab );
-+	if ( ScExtDocOptions* pExtOptions = pDoc->GetExtDocOptions() )
-+		// for an imported excel doc we always have the codename
-+		pDoc->GetCodeName( nTab, aCodeName );
- 	return aCodeName;	
- }
- 
-@@ -649,7 +648,8 @@ sal_Bool ScVbaEventsHelper::processDocBe
- 	sal_Bool bCancel = sal_False;
- 	aArgs[ 0 ] <<= bCancel;
- 	const static String sBeforeClose( RTL_CONSTASCII_USTRINGPARAM("Workbook_BeforePrint") );
--	String sFullClose = docMacroExists( pShell, String(), sBeforeClose );
-+	rtl::OUString workbookModule = getWorkbookModuleName(); 
-+	String sFullClose = docMacroExists( pShell, workbookModule, sBeforeClose );
- 	if ( sFullClose.Len() > 0 )
- 	{ 
- 		if ( !executeWorkBookMacro( pShell, sFullClose, aArgs, aRet ) )
-@@ -667,7 +667,8 @@ void ScVbaEventsHelper::processDocNewShe
-         uno::Sequence< uno::Any > aArgs(1);
-         aArgs[0] = aElement;
-         const static String sNewSheet( RTL_CONSTASCII_USTRINGPARAM("Workbook_NewSheet") );
--        String sFullClose = docMacroExists( pShell, String(), sNewSheet );
-+        rtl::OUString workbookModule = getWorkbookModuleName();
-+        String sFullClose = docMacroExists( pShell, workbookModule, sNewSheet );
-         if ( sFullClose.Len() > 0 )
-         {
-             executeWorkBookMacro( pShell, sFullClose, aArgs, aRet );
-@@ -702,7 +703,8 @@ void ScVbaEventsHelper::processWindowMac
-     {
-         uno::Sequence< uno::Any > aArgs(1);
-         aArgs[0] = aElement;
--        String sMacro = docMacroExists( pShell, String(), sFuncName );
-+        rtl::OUString workbookModule = getWorkbookModuleName();
-+        String sMacro = docMacroExists( pShell, workbookModule, sFuncName );
-         if ( sMacro.Len() > 0 )
-         {
-             executeWorkBookMacro( pShell, sMacro, aArgs, aRet );
-@@ -767,7 +769,7 @@ sal_Bool ScVbaEventsHelper::processDocAc
-     sal_Bool result = sal_True;
-     const static rtl::OUString sAtctivateMacro( RTL_CONSTASCII_USTRINGPARAM("Workbook_Activate") );
-     const static rtl::OUString sOnFocusEvt( RTL_CONSTASCII_USTRINGPARAM("OnFocus") );
--    rtl::OUString sWorkbookModule;
-+    rtl::OUString sWorkbookModule = getWorkbookModuleName();
-     String sFullOnFocus = docMacroExists( pShell, sWorkbookModule, sAtctivateMacro );
-     if( sFullOnFocus.Len() > 0 )
-     {
-@@ -782,7 +784,7 @@ sal_Bool ScVbaEventsHelper::processDocDe
-     sal_Bool result = sal_True;
-     const static rtl::OUString sDeatctivateMacro( RTL_CONSTASCII_USTRINGPARAM("Workbook_Deactivate") );
-     const static rtl::OUString sOnFocusEvt( RTL_CONSTASCII_USTRINGPARAM("OnUnfocus") );
--    rtl::OUString sWorkbookModule;
-+    rtl::OUString sWorkbookModule = getWorkbookModuleName();
-     String sFullUnOnfocus = docMacroExists( pShell, sWorkbookModule, sDeatctivateMacro );
-     if( sFullUnOnfocus.Len() > 0 )
-     {
-@@ -797,7 +799,8 @@ void ScVbaEventsHelper::processDocDeacti
-     uno::Any aRet;
-     uno::Sequence< uno::Any > aArgs;
-     const static String sDeactivate( RTL_CONSTASCII_USTRINGPARAM("Workbook_Deactivate") );
--    String sDeactivateMacro = docMacroExists( pShell, String(), sDeactivate );
-+    rtl::OUString sWorkbookModule = getWorkbookModuleName();
-+    String sDeactivateMacro = docMacroExists( pShell, sWorkbookModule, sDeactivate );
-     if ( sDeactivateMacro.Len() > 0 )
-     {
-         executeWorkBookMacro( pShell, sDeactivateMacro, aArgs, aRet );
-@@ -853,7 +856,8 @@ sal_Bool ScVbaEventsHelper::processDocBe
-     aArgs[ 0 ] <<= bSaveAsUI;
- 	aArgs[ 1 ] <<= bCancel;
- 	const static String sBeforeClose( RTL_CONSTASCII_USTRINGPARAM("Workbook_BeforeSave") );
--	String sFullClose = docMacroExists( pShell, String(), sBeforeClose );
-+	rtl::OUString workbookModule = getWorkbookModuleName(); 
-+	String sFullClose = docMacroExists( pShell, workbookModule, sBeforeClose );
- 	if ( sFullClose.Len() > 0 )
- 	{ 
- 		if ( !executeWorkBookMacro( pShell, sFullClose, aArgs, aRet ) )
-@@ -880,8 +884,7 @@ sal_Bool ScVbaEventsHelper::processDocOp
- 	// until ObjectModules ( and persisting of codename )  are supported if this is a
- 	// document saved from XL then we won't be able to determine the codename for the Workbook
- 	// Module, so... we have no choice but to search all modules for the moment 	
--	//rtl::OUString workbookModule = getWorkbookModuleName( pShell );
--	rtl::OUString workbookModule; // no name means all modules will be searched
-+	rtl::OUString workbookModule = getWorkbookModuleName(); 
- 	String sFullOpen = docMacroExists( pShell, workbookModule, sOpenMacro );
- 	if ( sFullOpen.Len() > 0 )
- 	{

Added: trunk/patches/vba/ObjectModule.diff
==============================================================================
--- (empty file)
+++ trunk/patches/vba/ObjectModule.diff	Tue May 13 16:11:44 2008
@@ -0,0 +1,1866 @@
+--- /dev/null	2007-05-04 11:54:36.000000000 +0100
++++ udkapi/com/sun/star/script/ModuleType.idl	2008-03-28 10:30:33.000000000 +0000
+@@ -0,0 +1,58 @@
++/*************************************************************************
++ *
++ *  OpenOffice.org - a multi-platform office productivity suite
++ *
++ *  $RCSfile: ModuleType.idl,v $
++ *
++ *  $Revision: 1.2 $
++ *
++ *  last change: $Author: rt $ $Date: 2006/05/05 10:14:46 $
++ *
++ *  The Contents of this file are made available subject to
++ *  the terms of GNU Lesser General Public License Version 2.1.
++ *
++ *
++ *    GNU Lesser General Public License Version 2.1
++ *    =============================================
++ *    Copyright 2005 by Sun Microsystems, Inc.
++ *    901 San Antonio Road, Palo Alto, CA 94303, USA
++ *
++ *    This library is free software; you can redistribute it and/or
++ *    modify it under the terms of the GNU Lesser General Public
++ *    License version 2.1, as published by the Free Software Foundation.
++ *
++ *    This library 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 for more details.
++ *
++ *    You should have received a copy of the GNU Lesser General Public
++ *    License along with this library; if not, write to the Free Software
++ *    Foundation, Inc., 59 Temple Place, Suite 330, Boston,
++ *    MA  02111-1307  USA
++ *
++ ************************************************************************/
++
++#ifndef __com_sun_star_script_ModuleType_idl__
++#define __com_sun_star_script_ModuleType_idl__
++
++#ifndef __com_sun_star_uno_XInterface_idl__
++#include <com/sun/star/uno/XInterface.idl>
++#endif
++
++//=============================================================================
++module com {  module sun {  module star { module script {
++published constants ModuleType
++{
++    const long Unknown = 0;
++    const long Normal = 1;  
++    const long Class = 2;
++    const long Form = 3;
++    const long Document = 4;
++};
++
++//=============================================================================
++
++}; }; }; };
++
++#endif
+--- /dev/null	2007-05-04 11:54:36.000000000 +0100
++++ udkapi/com/sun/star/script/ModuleInfo.idl	2008-03-28 10:30:33.000000000 +0000
+@@ -0,0 +1,57 @@
++/*************************************************************************
++ *
++ *  OpenOffice.org - a multi-platform office productivity suite
++ *
++ *  $RCSfile: ModuleInfo.idl,v $
++ *
++ *  $Revision: 1.2 $
++ *
++ *  last change: $Author: rt $ $Date: 2006/05/05 10:14:46 $
++ *
++ *  The Contents of this file are made available subject to
++ *  the terms of GNU Lesser General Public License Version 2.1.
++ *
++ *
++ *    GNU Lesser General Public License Version 2.1
++ *    =============================================
++ *    Copyright 2005 by Sun Microsystems, Inc.
++ *    901 San Antonio Road, Palo Alto, CA 94303, USA
++ *
++ *    This library is free software; you can redistribute it and/or
++ *    modify it under the terms of the GNU Lesser General Public
++ *    License version 2.1, as published by the Free Software Foundation.
++ *
++ *    This library 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 for more details.
++ *
++ *    You should have received a copy of the GNU Lesser General Public
++ *    License along with this library; if not, write to the Free Software
++ *    Foundation, Inc., 59 Temple Place, Suite 330, Boston,
++ *    MA  02111-1307  USA
++ *
++ ************************************************************************/
++
++#ifndef __com_sun_star_script_ModuleInfo_idl__
++#define __com_sun_star_script_ModuleInfo_idl__
++
++#ifndef __com_sun_star_uno_XInterface_idl__
++#include <com/sun/star/uno/XInterface.idl>
++#endif
++
++//=============================================================================
++module com {  module sun {  module star { module script {
++struct ModuleInfo
++{
++	string ModuleName; 
++	string ModuleSource; 
++	com::sun::star::uno::XInterface ModuleObjectProvider; 
++	short ModuleType; // string?
++};
++
++//=============================================================================
++
++}; }; }; };
++
++#endif
+--- /dev/null	2007-05-04 11:54:36.000000000 +0100
++++ udkapi/com/sun/star/script/XObjectProvider.idl	2008-03-28 10:30:33.000000000 +0000
+@@ -0,0 +1,52 @@
++/*************************************************************************
++ *
++ *  OpenOffice.org - a multi-platform office productivity suite
++ *
++ *  $RCSfile: XDefaultMethod.idl,v $
++ *
++ *  $Revision: 1.3 $
++ *
++ *  last change: $Author: vg $ $Date: 2006/11/02 16:34:45 $
++ *
++ *  The Contents of this file are made available subject to
++ *  the terms of GNU Lesser General Public License Version 2.1.
++ *
++ *
++ *    GNU Lesser General Public License Version 2.1
++ *    =============================================
++ *    Copyright 2005 by Sun Microsystems, Inc.
++ *    901 San Antonio Road, Palo Alto, CA 94303, USA
++ *
++ *    This library is free software; you can redistribute it and/or
++ *    modify it under the terms of the GNU Lesser General Public
++ *    License version 2.1, as published by the Free Software Foundation.
++ *
++ *    This library 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 for more details.
++ *
++ *    You should have received a copy of the GNU Lesser General Public
++ *    License along with this library; if not, write to the Free Software
++ *    Foundation, Inc., 59 Temple Place, Suite 330, Boston,
++ *    MA  02111-1307  USA
++ *
++ ************************************************************************/
++
++#ifndef __com_sun_star_script_XObjectProvider_idl__
++#define __com_sun_star_script_XObjectProvider_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 XObjectProvider : ::com::sun::star::uno::XInterface
++{
++  any getObject();
++
++};
++
++};  };  };  };
++#endif
+diff -rup /data4/OOOBuildM12/ooo-build/build/ooh680-m12/udkapi/com/sun/star/script/makefile.mk udkapi/com/sun/star/script/makefile.mk
+--- /data4/OOOBuildM12/ooo-build/build/ooh680-m12/udkapi/com/sun/star/script/makefile.mk	2008-03-29 23:08:19.000000000 +0000
++++ udkapi/com/sun/star/script/makefile.mk	2008-03-28 10:30:33.000000000 +0000
+@@ -89,6 +89,9 @@ IDLFILES=\
+ 	XScriptEventsAttacher.idl\
+ 	XDefaultMethod.idl\
+ 	XDefaultProperty.idl\
++    ModuleInfo.idl\
++    ModuleType.idl\
++    XObjectProvider.idl\
+ 	DateType.idl\
+ 
+ # ------------------------------------------------------------------
+diff -rup /data4/OOOBuildM12/ooo-build/build/ooh680-m12/svx/source/msfilter/msvbasic.cxx svx/source/msfilter/msvbasic.cxx
+--- /data4/OOOBuildM12/ooo-build/build/ooh680-m12/svx/source/msfilter/msvbasic.cxx	2006-09-17 06:28:12.000000000 +0100
++++ svx/source/msfilter/msvbasic.cxx	2008-03-28 10:30:33.000000000 +0000
+@@ -54,6 +54,8 @@
+ #include "msvbasic.hxx"
+ #endif
+ 
++using namespace ::com::sun::star::script;
++
+ /*
+ A few urls which may in the future be of some use
+ http://www.virusbtn.com/vb2000/Programme/papers/bontchev.pdf
+@@ -445,7 +447,7 @@ int VBA_Impl::ReadVBAProject(const SvSto
+  *
+ */
+ 
+-ModuleType VBA_Impl::GetModuleType( const UniString& rModuleName )
++ModType VBA_Impl::GetModuleType( const UniString& rModuleName )
+ {
+     ModuleTypeHash::iterator iter = mhModHash.find( rModuleName );
+     ModuleTypeHash::iterator iterEnd = mhModHash.end();
+@@ -453,7 +455,7 @@ ModuleType VBA_Impl::GetModuleType( cons
+     {
+         return iter->second;
+     }
+-    return Unknown;
++    return ModuleType::Unknown;
+ }
+ 
+ bool VBA_Impl::Open( const String &rToplevel, const String &rSublevel )
+@@ -496,7 +498,7 @@ bool VBA_Impl::Open( const String &rTopl
+         static const String sClass(     RTL_CONSTASCII_USTRINGPARAM( "Class" ) );
+         static const String sBaseClass( RTL_CONSTASCII_USTRINGPARAM( "BaseClass" ) );
+         static const String sDocument(  RTL_CONSTASCII_USTRINGPARAM( "Document" ) );
+-        mhModHash[ sThisDoc ] = Class;
++        mhModHash[ sThisDoc ] = ModuleType::Class;
+         while ( pStp->ReadByteStringLine( tmp, meCharSet ) )
+         {
+             xub_StrLen index = tmp.Search( '=' );
+@@ -506,14 +508,14 @@ bool VBA_Impl::Open( const String &rTopl
+                 String value = tmp.Copy( index + 1 );
+                 if ( key == sClass )
+                 {
+-                    mhModHash[ value ] = Class;
++                    mhModHash[ value ] = ModuleType::Class;
+                     OSL_TRACE("Module %s is of type Class",
+                         ::rtl::OUStringToOString( value ,
+                             RTL_TEXTENCODING_ASCII_US ).pData->buffer );
+                 }
+                 else if ( key == sBaseClass )
+                 {
+-                    mhModHash[ value ] =  Form;
++                    mhModHash[ value ] =  ModuleType::Form;
+                     OSL_TRACE("Module %s is of type Form",
+                         ::rtl::OUStringToOString( value ,
+                             RTL_TEXTENCODING_ASCII_US ).pData->buffer );
+@@ -526,14 +528,14 @@ bool VBA_Impl::Open( const String &rTopl
+                     // value is of form <name>/&H<identifier>, strip the identifier
+                     value.Erase( value.Search( '/' ) );
+ 
+-                    mhModHash[ value ] = Document;
++                    mhModHash[ value ] = ModuleType::Document;
+                     OSL_TRACE("Module %s is of type Document VBA",
+                         ::rtl::OUStringToOString( value ,
+                             RTL_TEXTENCODING_ASCII_US ).pData->buffer );
+                 }
+                 else if ( key == sModule )
+                 {
+-                    mhModHash[ value ] = Normal;
++                    mhModHash[ value ] = ModuleType::Normal;
+                     OSL_TRACE("Module %s is of type Normal VBA",
+                         ::rtl::OUStringToOString( value ,
+                             RTL_TEXTENCODING_ASCII_US ).pData->buffer );
+--- svx/source/msfilter/msvbasic.hxx	2008-04-11 03:07:15.000000000 +0100
++++ svx.patched/source/msfilter/msvbasic.hxx	2008-05-09 17:13:58.000000000 +0100
+@@ -45,6 +45,8 @@
+ #include <vector>
+ #endif
+ #include<map>
++#include <com/sun/star/script/ModuleType.hpp>
++using namespace ::com::sun::star::script::ModuleType;
+ 
+ /* class VBA:
+  * The VBA class provides a set of methods to handle Visual Basic For
+@@ -68,13 +70,12 @@ DECLARE_DYNARRAY(StringArray,String *)
+ // #117718# define internal types to distinguish between
+ // module types, form, class & normal
+ // #i37965# DR 2004-12-03: add "Document", used in Excel for macros attached to sheet
+-enum ModuleType { Unknown = 0, Normal, Class, Form, Document };
+ 
+ // #117718# define map to hold types of module
+ //
+-
++typedef sal_Int32 ModType;
+ typedef ::std::map< UniString,
+-    ModuleType > ModuleTypeHash;
++    ModType > ModuleTypeHash;
+ 
+ class VBA_Impl
+ {
+@@ -95,7 +96,7 @@ public:
+     void Output(int len, const sal_uInt8 *data);
+     //
+     // #117718# member map of module names to types of module
+-    ModuleType GetModuleType( const UniString& rModuleName );
++    ModType GetModuleType( const UniString& rModuleName );
+ 
+     std::vector<String> maReferences;
+ private:
+--- svx/source/msfilter/svxmsbas.cxx	2008-05-13 11:47:13.000000000 +0100
++++ svx/source/msfilter.patched/svxmsbas.cxx	2008-05-13 16:23:28.000000000 +0100
+@@ -53,6 +53,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/XObjectProvider.hpp>
+ using namespace com::sun::star::container;
+ using namespace com::sun::star::script;
+ using namespace com::sun::star::uno;
+@@ -284,7 +286,7 @@ BOOL SvxImportMSVBasic::ImportCode_Impl(
+                 // is the same as the encoding for the names
+                 // that are keys in the map used by GetModuleType method
+                 const String &sOrigVBAModName = aVBA.GetStreamName( i );
+-                ModuleType mType = aVBA.GetModuleType( sOrigVBAModName );
++                ModType mType = aVBA.GetModuleType( sOrigVBAModName );
+ 
+                 rtl::OUString sClassRem( RTL_CONSTASCII_USTRINGPARAM( "Rem Attribute VBA_ModuleType=" ) );
+ 
+@@ -292,23 +294,23 @@ BOOL SvxImportMSVBasic::ImportCode_Impl(
+ 
+                 switch( mType )
+                 {
+-                    case Class:
++                    case ModuleType::Class:
+                         modeTypeComment = sClassRem +
+                             ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "VBAClassModule\n" ) );
+                         break;
+-                    case Form:
++                    case ModuleType::Form:
+                         modeTypeComment = sClassRem +
+                             ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "VBAFormModule\n" ) );
+                         break;
+-                    case Document:
++                    case ModuleType::Document:
+                         modeTypeComment = sClassRem +
+                             ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "VBADocumentModule\n" ) );
+                         break;
+-                    case Normal:
++                    case ModuleType::Normal:
+                         modeTypeComment = sClassRem +
+                             ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "VBAModule\n" ) );
+                         break;
+-                    case Unknown:
++                    case ModuleType::Unknown:
+                         modeTypeComment = sClassRem +
+                             ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "VBAUnknown\n" ) );
+                         break;
+@@ -321,7 +323,7 @@ BOOL SvxImportMSVBasic::ImportCode_Impl(
+ 				if ( !bAsComment )
+ 				{
+ 					modeTypeComment = modeTypeComment + sVBAOption;
+-					if ( mType == Class )
++					if ( mType == ModuleType::Class )
+ 						modeTypeComment = modeTypeComment + sClassOption;
+ 
+ 				}
+@@ -383,12 +385,36 @@ BOOL SvxImportMSVBasic::ImportCode_Impl(
+ 						aSource += rtl::OUString::createFromAscii("\nEnd Sub");
+ 				}
+ 				::rtl::OUString aModName( sModule );
+-				if ( aSource.getLength() )
+ 				{
++                    Reference< script::XObjectProvider > xVBAObjectProvider;
++                    if( mType == ModuleType::Document )
++                    {
++                        Reference< XMultiServiceFactory> xSF(rDocSh.GetModel(), UNO_QUERY);
++                        if ( xSF.is() )
++                        {
++                            try
++                            {
++                                uno::Sequence< uno::Any > aArgs(1);
++                                aArgs[0] = uno::Any( aModName );
++                                    xVBAObjectProvider.set( xSF->createInstanceWithArguments( rtl::OUString(RTL_CONSTASCII_USTRINGPARAM( "org.openoffice.vba.VBAObjectModuleObjectProvider")), aArgs), UNO_QUERY );
++                            }
++                            catch( Exception& ) { }
++                        }
++                    }
+ 					aSource = modeTypeComment + aSource;
+ 
+ 					Any aSourceAny;
+-					aSourceAny <<= aSource;
++                    if ( !bAsComment && ( xVBAObjectProvider.is() && mType == ModuleType::Document ) )
++                    {
++                        script::ModuleInfo sModuleInfo;
++                        sModuleInfo.ModuleName = aModName;
++                        sModuleInfo.ModuleSource = aSource;
++                        sModuleInfo.ModuleType = mType;
++                        sModuleInfo.ModuleObjectProvider.set( xVBAObjectProvider, UNO_QUERY );
++                        aSourceAny <<= sModuleInfo;
++                    }
++                    else
++					    aSourceAny <<= aSource;
+ 					if( xLib->hasByName( aModName ) )
+ 						xLib->replaceByName( aModName, aSourceAny );
+ 					else
+@@ -398,6 +424,8 @@ BOOL SvxImportMSVBasic::ImportCode_Impl(
+ 				bRet = true;
+ 			}
+ 		}
++        if( bRet )
++            rDocSh.GetBasic()->SetVBAEnabled( true );
+ 		SFX_APP()->LeaveBasicCall();
+ 	}
+ 	return bRet;
+--- sc/inc/servuno.hxx	2008-04-10 19:53:59.000000000 +0100
++++ sc/inc/servuno.hxx	2008-05-09 18:11:50.000000000 +0100
+@@ -93,8 +93,8 @@ class ScDocShell;
+ 
+ #define SC_SERVICE_FORMULAPARS  38
+ #define SC_SERVICE_OPCODEMAPPER 39
+-
+-#define SC_SERVICE_COUNT        40
++#define SC_SERVICE_VBAOBJECTPROVIDER   40
++#define SC_SERVICE_COUNT        41
+ #define SC_SERVICE_INVALID		USHRT_MAX
+ 
+ 
+--- sc/source/ui/unoobj/servuno.cxx	2008-04-11 01:43:36.000000000 +0100
++++ sc/source/ui/unoobj/servuno.cxx	2008-05-09 18:16:21.000000000 +0100
+@@ -61,8 +61,93 @@
+ #include <svx/xmleohlp.hxx>
+ #include <svx/xmlgrhlp.hxx>
+ 
++#include <com/sun/star/script/XObjectProvider.hpp>
++#include <comphelper/processfactory.hxx>
++
+ using namespace ::com::sun::star;
+ 
++class ScVbaObjectProvider : public ::cppu::WeakImplHelper2< script::XObjectProvider, lang::XInitialization >
++{
++    ScDocShell* mpDocShell;
++    uno::Any aObj;
++    String msName;
++public:
++    ScVbaObjectProvider( const rtl::OUString& sName, ScDocShell* pDocShell ) : mpDocShell( pDocShell ), msName(sName) {}
++    ScVbaObjectProvider( ScDocShell* pDocShell ) : mpDocShell( pDocShell ) {}
++    virtual void SAL_CALL initialize( const uno::Sequence< uno::Any >& aArguments ) throw (uno::Exception, uno::RuntimeException)
++    {
++        OSL_TRACE("ScVbaObjectProvider::initialize ");
++        if(aArguments.getLength() != 1)
++        {
++            throw lang::IllegalArgumentException(rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("give a string instanciating this component!") ), static_cast< script::XObjectProvider * >(this), 0 );
++        }
++        rtl::OUString sName;
++        aArguments[0] >>= sName;
++        msName = sName;
++    }
++    virtual uno::Any SAL_CALL getObject() throw (uno::RuntimeException)
++    {
++        if ( !aObj.hasValue() )
++        {
++            BOOL bWorkbook = FALSE;
++            uno::Type aType;
++            uno::Reference<lang::XMultiServiceFactory> xSF(comphelper::getProcessServiceFactory());
++            uno::Reference<beans::XPropertySet> xProps(xSF, uno::UNO_QUERY);
++            if( xProps.is() )
++            {
++                ScDocument* pDoc = mpDocShell->GetDocument();
++                if ( !pDoc )
++                    throw uno::RuntimeException( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("")), uno::Reference< uno::XInterface >() );
++                String sGlobCodeName = pDoc->GetCodeName();
++                uno::Reference< uno::XInterface > xIf;
++
++                uno::Sequence< uno::Any > aArgs(2);
++                aArgs[0] = uno::Any( uno::Reference< uno::XInterface >() );
++                aArgs[1] = uno::Any( mpDocShell->GetModel() );
++                uno::Reference< uno::XInterface > xWorkbook( xSF->createInstanceWithArguments(  rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("org.openoffice.excel.Workbook") ), aArgs ), uno::UNO_QUERY );
++                if( sGlobCodeName == msName )
++                {
++                    xIf.set( xWorkbook, uno::UNO_QUERY );
++                    bWorkbook = TRUE;
++                }
++                 else
++                 {
++                    String sCodeName;
++                    SCTAB nCount = pDoc->GetTableCount();
++                    for( SCTAB i = 0; i < nCount; i++ )
++                    {
++                        pDoc->GetCodeName( i, sCodeName );
++                        if( sCodeName == msName )
++                        {
++                            String sSheetName;
++                            if( pDoc->GetName( i, sSheetName ) )
++                            {
++                            uno::Reference< frame::XModel > xModel( mpDocShell->GetModel() );
++                            uno::Reference <sheet::XSpreadsheetDocument> xSpreadDoc( xModel, uno::UNO_QUERY_THROW );
++                            uno::Reference<sheet::XSpreadsheets > xSheets( xSpreadDoc->getSheets(), uno::UNO_QUERY_THROW );
++                            uno::Reference< container::XIndexAccess > xIndexAccess( xSheets, uno::UNO_QUERY_THROW );
++                            uno::Reference< sheet::XSpreadsheet > xSheet( xIndexAccess->getByIndex( i ), uno::UNO_QUERY_THROW );
++                            uno::Sequence< uno::Any > aArgs(3);
++                            aArgs[0] = uno::Any( xWorkbook );
++                            aArgs[1] = uno::Any( xModel );
++                            aArgs[2] = uno::Any( rtl::OUString( sSheetName ) );
++                            uno::Reference< uno::XInterface > xWorksheet( xSF->createInstanceWithArguments(  rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("org.openoffice.excel.Worksheet") ), aArgs ), uno::UNO_QUERY );
++                            xIf.set( xWorksheet, uno::UNO_QUERY );
++                            bWorkbook = FALSE;
++                            break;
++                            }
++                        }
++                    }
++                 }
++                 if( xIf.is() )
++                 {
++                    aObj <<= xIf;
++                 }
++            }
++        }
++        return aObj;
++    }
++};
+ 
+ //------------------------------------------------------------------------
+ 
+@@ -112,7 +197,8 @@ static const sal_Char* __FAR_DATA aProvN
+ 
+         SC_SERVICENAME_CHDATAPROV,                  // SC_SERVICE_CHDATAPROV
+         SC_SERVICENAME_FORMULAPARS,                 // SC_SERVICE_FORMULAPARS
+-        SC_SERVICENAME_OPCODEMAPPER                 // SC_SERVICE_OPCODEMAPPER
++        SC_SERVICENAME_OPCODEMAPPER,                 // SC_SERVICE_OPCODEMAPPER
++"org.openoffice.vba.VBAObjectModuleObjectProvider",// SC_SERVICE_VBAOBJECTPROVIDER
+ 	};
+ 
+ //
+@@ -164,7 +250,8 @@ static const sal_Char* __FAR_DATA aOldNa
+         "",                                         // SC_SERVICE_SHEETDOCSET
+         "",                                         // SC_SERVICE_CHDATAPROV
+         "",                                         // SC_SERVICE_FORMULAPARS
+-        ""                                          // SC_SERVICE_OPCODEMAPPER
++        "",                                         // SC_SERVICE_OPCODEMAPPER
++        "",                                         // SC_SERVICE_VBAOBJECTPROVIDER
+ 	};
+ 
+ 
+@@ -357,6 +444,9 @@ uno::Reference<uno::XInterface> ScServic
+         case SC_SERVICE_OPCODEMAPPER:
+             xRet.set(static_cast<sheet::XFormulaOpCodeMapper*>(new ScFormulaOpCodeMapperObj));
+             break;
++        case SC_SERVICE_VBAOBJECTPROVIDER:
++            xRet.set(static_cast<script::XObjectProvider*>(new ScVbaObjectProvider( pDocShell )));
++            break;
+ 	}
+ 	return xRet;
+ }
+diff -rup /data4/OOOBuildM12/ooo-build/build/ooh680-m12/sc/source/ui/docshell/docfunc.cxx sc/source/ui/docshell/docfunc.cxx
+--- /data4/OOOBuildM12/ooo-build/build/ooh680-m12/sc/source/ui/docshell/docfunc.cxx	2008-03-29 23:08:20.000000000 +0000
++++ sc/source/ui/docshell/docfunc.cxx	2008-03-28 10:30:33.000000000 +0000
+@@ -58,6 +58,13 @@
+ #include <svtools/PasswordHelper.hxx>
+ #endif
+ 
++#include <basic/sbstar.hxx>
++#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/ModuleType.hpp>
++#include <com/sun/star/script/XObjectProvider.hpp>
++
+ #include <list>
+ 
+ #include "docfunc.hxx"
+@@ -101,6 +108,7 @@
+ #include "scui_def.hxx" //CHINA001
+ using namespace com::sun::star;
+ 
++
+ // STATIC DATA -----------------------------------------------------------
+ 
+ //========================================================================
+@@ -2022,6 +2030,86 @@ BOOL ScDocFunc::MoveBlock( const ScRange
+ }
+ 
+ //------------------------------------------------------------------------
++script::ModuleInfo lcl_InitModuleInfo( ScDocShell& rDocSh, String& sModule )
++{
++    ::rtl::OUString aModName( sModule );
++    uno::Reference< lang::XMultiServiceFactory> xSF(rDocSh.GetModel(), uno::UNO_QUERY);
++    uno::Reference< script::XObjectProvider > xVBAObjectProvider;
++    if ( xSF.is() )
++    {
++        uno::Sequence< uno::Any > aArgs(1);
++        aArgs[0] = uno::Any( aModName );
++        xVBAObjectProvider.set( xSF->createInstanceWithArguments( rtl::OUString(RTL_CONSTASCII_USTRINGPARAM( "org.openoffice.vba.VBAObjectModuleObjectProvider")), aArgs), uno::UNO_QUERY );    
++    }
++    script::ModuleInfo sModuleInfo;
++    ::rtl::OUString sVbaOption( RTL_CONSTASCII_USTRINGPARAM( "Rem Attribute VBA_ModuleType=VBADocumentModule\nOption VBASupport 1\n" ));
++    sModuleInfo.ModuleName = aModName;
++    sModuleInfo.ModuleSource = sVbaOption;
++    sModuleInfo.ModuleType = script::ModuleType::Document;
++    sModuleInfo.ModuleObjectProvider.set( xVBAObjectProvider, uno::UNO_QUERY );
++    return sModuleInfo;
++}
++
++void lcl_InsertModule( ScDocShell& rDocSh, SCTAB nTab, String& sModuleName )
++{
++    SFX_APP()->EnterBasicCall();
++    script::ModuleInfo sModuleInfo = lcl_InitModuleInfo(  rDocSh, sModuleName );
++    uno::Reference< script::XLibraryContainer > xLibContainer = rDocSh.GetBasicContainer();
++    DBG_ASSERT( xLibContainer.is(), "No BasicContainer!" );
++
++    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() )
++    {
++        // test Module has exist
++        // if the Module is exist. changed to another name
++        // and at this time the string like "SheetX"
++        rtl::OUString sModuleName( sModuleInfo.ModuleName );
++        sal_Int32 nNum = 1;
++        while( xLib->hasByName( sModuleName ) )
++        {
++            sModuleName = rtl::OUString::createFromAscii( "Sheet" ) + rtl::OUString::valueOf( nNum );
++            nNum += 1;
++        }
++        sModuleInfo.ModuleName = sModuleName;
++        uno::Any aSourceAny;
++        aSourceAny <<= sModuleInfo;
++        xLib->insertByName( sModuleName, aSourceAny );
++        ScDocument* pDoc = rDocSh.GetDocument();
++        String sCodeName( sModuleName );
++        pDoc->SetCodeName( nTab, sCodeName );
++    }
++    SFX_APP()->LeaveBasicCall();
++}
++
++void lcl_DeleteModule( ScDocShell& rDocSh, String& sModuleName )
++{
++    SFX_APP()->EnterBasicCall();
++    uno::Reference< script::XLibraryContainer > xLibContainer = rDocSh.GetBasicContainer();
++    DBG_ASSERT( xLibContainer.is(), "No BasicContainer!" );
++
++    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() )
++    {
++        if( xLib->hasByName( sModuleName ) )
++        {
++            xLib->removeByName( sModuleName );
++        }
++    }
++    SFX_APP()->LeaveBasicCall();
++}
++
+ 
+ BOOL ScDocFunc::InsertTable( SCTAB nTab, const String& rName, BOOL bRecord, BOOL bApi )
+ {
+@@ -2031,8 +2119,12 @@ BOOL ScDocFunc::InsertTable( SCTAB nTab,
+ 	ScDocShellModificator aModificator( rDocShell );
+ 
+ 	ScDocument* pDoc = rDocShell.GetDocument();
++    StarBASIC* pStarBASIC = rDocShell.GetBasic();
++    BOOL bVbaEnabled = pStarBASIC->isVBAEnabled();
+ 	if (bRecord && !pDoc->IsUndoEnabled())
+ 		bRecord = FALSE;
++    if ( bVbaEnabled )
++        bRecord = FALSE;
+ 	if (bRecord)
+ 		pDoc->BeginDrawUndo();							//	InsertTab erzeugt ein SdrUndoNewPage
+ 
+@@ -2047,6 +2139,11 @@ BOOL ScDocFunc::InsertTable( SCTAB nTab,
+ 			rDocShell.GetUndoManager()->AddUndoAction(
+ 						new ScUndoInsertTab( &rDocShell, nTab, bAppend, rName));
+ 		//	Views updaten:
++        if( bVbaEnabled )
++        {
++            String sCodeName( rName );
++            lcl_InsertModule( rDocShell, nTab, sCodeName );
++        }
+ 		rDocShell.Broadcast( ScTablesHint( SC_TAB_INSERTED, nTab ) );
+ 
+ 		rDocShell.PostPaintExtras();
+@@ -2068,8 +2165,12 @@ BOOL ScDocFunc::DeleteTable( SCTAB nTab,
+ 
+ 	BOOL bSuccess = FALSE;
+ 	ScDocument* pDoc = rDocShell.GetDocument();
++    StarBASIC* pStarBASIC = rDocShell.GetBasic();
++    BOOL bVbaEnabled = pStarBASIC->isVBAEnabled();
+ 	if (bRecord && !pDoc->IsUndoEnabled())
+ 		bRecord = FALSE;
++    if ( bVbaEnabled )
++        bRecord = FALSE;
+ 	BOOL bWasLinked = pDoc->IsLinked(nTab);
+ 	ScDocument* pUndoDoc = NULL;
+ 	ScRefUndoData* pUndoData = NULL;
+@@ -2110,6 +2211,8 @@ BOOL ScDocFunc::DeleteTable( SCTAB nTab,
+ 		pUndoData = new ScRefUndoData( pDoc );
+ 	}
+ 
++    String sCodeName;
++    BOOL bHasCodeName = pDoc->GetCodeName( nTab, sCodeName );
+ 	if (pDoc->DeleteTab( nTab, pUndoDoc ))
+ 	{
+ 		if (bRecord)
+@@ -2120,6 +2223,13 @@ BOOL ScDocFunc::DeleteTable( SCTAB nTab,
+ 						new ScUndoDeleteTab( &rDocShell, theTabs, pUndoDoc, pUndoData ));
+ 		}
+ 		//	Views updaten:
++        if( bVbaEnabled )
++        {
++            if( bHasCodeName )
++            {
++                lcl_DeleteModule( rDocShell, sCodeName );
++            }
++        }
+ 		rDocShell.Broadcast( ScTablesHint( SC_TAB_DELETED, nTab ) );
+ 
+ 		if (bWasLinked)
+diff -rup /data4/OOOBuildM12/ooo-build/build/ooh680-m12/sc/source/ui/unoobj/makefile.mk sc/source/ui/unoobj/makefile.mk
+--- /data4/OOOBuildM12/ooo-build/build/ooh680-m12/sc/source/ui/unoobj/makefile.mk	2008-03-29 23:08:20.000000000 +0000
++++ sc/source/ui/unoobj/makefile.mk	2008-03-28 10:30:33.000000000 +0000
+@@ -54,6 +54,7 @@ AUTOSEG=true
+ .INCLUDE :  sc.mk
+ .INCLUDE :  $(PRJ)$/util$/makefile.pmk
+ 
++INCPRE=$(INCCOM)$/vbaobj
+ # --- Files --------------------------------------------------------
+ SLO1FILES =  \
+         $(SLO)$/docuno.obj \
+diff -rup /data4/OOOBuildM12/ooo-build/build/ooh680-m12/sc/source/ui/view/viewfun2.cxx sc/source/ui/view/viewfun2.cxx
+--- /data4/OOOBuildM12/ooo-build/build/ooh680-m12/sc/source/ui/view/viewfun2.cxx	2008-03-29 23:08:24.000000000 +0000
++++ sc/source/ui/view/viewfun2.cxx	2008-03-28 10:30:34.000000000 +0000
+@@ -62,6 +62,11 @@
+ #include <vcl/sound.hxx>
+ #include <vcl/waitobj.hxx>
+ 
++#include <basic/sbstar.hxx>
++#include <com/sun/star/container/XNameContainer.hpp>
++#include <com/sun/star/script/XLibraryContainer.hpp>
++using namespace com::sun::star;
++
+ #include "viewfunc.hxx"
+ 
+ #include "sc.hrc"
+@@ -2095,15 +2100,42 @@ BOOL ScViewFunc::DeleteTable( SCTAB nTab
+ 	return bSuccess;
+ }
+ 
++void lcl_DeleteModule( ScDocShell* rDocSh, String& sModuleName )
++{
++    SFX_APP()->EnterBasicCall();
++    uno::Reference< script::XLibraryContainer > xLibContainer = rDocSh->GetBasicContainer();
++    DBG_ASSERT( xLibContainer.is(), "No BasicContainer!" );
++
++    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() )
++    {
++        if( xLib->hasByName( sModuleName ) )
++        {
++            xLib->removeByName( sModuleName );
++        }
++    }
++    SFX_APP()->LeaveBasicCall();
++}
++
+ BOOL ScViewFunc::DeleteTables(const SvShorts &TheTabs, BOOL bRecord )
+ {
+ 	ScDocShell* pDocSh	= GetViewData()->GetDocShell();
+ 	ScDocument* pDoc 	= pDocSh->GetDocument();
++    StarBASIC* pStarBASIC = pDocSh->GetBasic();
++    BOOL bVbaEnabled = pStarBASIC->isVBAEnabled();
+ 	SCTAB		nNewTab = TheTabs[0];
+ 	int			i;
+ 	WaitObject aWait( GetFrameWin() );
+ 	if (bRecord && !pDoc->IsUndoEnabled())
+ 		bRecord = FALSE;
++    if ( bVbaEnabled )
++        bRecord = FALSE;
+ 
+ 	while ( nNewTab > 0 && !pDoc->IsVisible( nNewTab ) )
+ 		--nNewTab;
+@@ -2170,9 +2202,18 @@ BOOL ScViewFunc::DeleteTables(const SvSh
+ 
+ 	for(i=TheTabs.Count()-1;i>=0;i--)
+ 	{
++        String sCodeName;
++        BOOL bHasCodeName = pDoc->GetCodeName( TheTabs[sal::static_int_cast<USHORT>(i)], sCodeName );
+         if (pDoc->DeleteTab( TheTabs[sal::static_int_cast<USHORT>(i)], pUndoDoc ))
+ 		{
+ 			bDelDone = TRUE;
++            if( bVbaEnabled )
++            {
++                if( bHasCodeName )
++                {
++                    lcl_DeleteModule( pDocSh, sCodeName );
++                }
++            }
+             pDocSh->Broadcast( ScTablesHint( SC_TAB_DELETED, TheTabs[sal::static_int_cast<USHORT>(i)] ) );
+ 		}
+ 	}
+@@ -2200,6 +2241,7 @@ BOOL ScViewFunc::DeleteTables(const SvSh
+ 		pDocSh->PostPaintExtras();
+ 		pDocSh->SetDocumentModified();
+ 
++
+         SfxApplication* pSfxApp = SFX_APP();                                // Navigator
+         pSfxApp->Broadcast( SfxSimpleHint( SC_HINT_TABLES_CHANGED ) );
+         pSfxApp->Broadcast( SfxSimpleHint( SC_HINT_DBAREAS_CHANGED ) );
+diff -rup /data4/OOOBuildM12/ooo-build/build/ooh680-m12/basctl/source/basicide/basides1.cxx basctl/source/basicide/basides1.cxx
+--- /data4/OOOBuildM12/ooo-build/build/ooh680-m12/basctl/source/basicide/basides1.cxx	2008-01-14 16:00:33.000000000 +0000
++++ basctl/source/basicide/basides1.cxx	2008-03-28 10:30:34.000000000 +0000
+@@ -1229,10 +1229,16 @@ IDEBaseWindow* BasicIDEShell::FindWindow
+                 // return any non-suspended window
+                 return pWin;
+             }
+-            else if ( pWin->IsDocument( rDocument ) && pWin->GetLibName() == rLibName && pWin->GetName() == rName &&
++            else if ( pWin->IsDocument( rDocument ) )
++            {
++                OSL_TRACE("FindWindow pWin->GetLibName() %s rLibName %s",
++			rtl::OUStringToOString( pWin->GetLibName(), RTL_TEXTENCODING_UTF8 ).getStr(),
++			rtl::OUStringToOString( rLibName, RTL_TEXTENCODING_UTF8 ).getStr() );
++                OSL_TRACE("pWin->pWin->IsA( TYPE( ModulWindow ) %d && nType %d = BASICIDE_TYPE_MODULE %d", pWin->IsA( TYPE( ModulWindow ) ), nType, BASICIDE_TYPE_MODULE );
++                OSL_TRACE("pWin->pWin->IsA( TYPE( DialogWindow ) %d && nType %d = BASICIDE_TYPE_DIALOG %d", pWin->IsA( TYPE( DialogWindow ) ), nType, BASICIDE_TYPE_DIALOG );
++		if (  pWin->GetLibName() == rLibName && pWin->GetName() == rName &&
+                       ( ( pWin->IsA( TYPE( ModulWindow ) )  && nType == BASICIDE_TYPE_MODULE ) ||
+                         ( pWin->IsA( TYPE( DialogWindow ) ) && nType == BASICIDE_TYPE_DIALOG ) ) )
+-            {
+                 return pWin;
+             }
+         }
+diff -rup /data4/OOOBuildM12/ooo-build/build/ooh680-m12/basctl/source/basicide/basides2.cxx basctl/source/basicide/basides2.cxx
+--- /data4/OOOBuildM12/ooo-build/build/ooh680-m12/basctl/source/basicide/basides2.cxx	2007-11-21 16:37:21.000000000 +0000
++++ basctl/source/basicide/basides2.cxx	2008-03-28 10:30:34.000000000 +0000
+@@ -252,9 +252,12 @@ ModulWindow* BasicIDEShell::CreateBasWin
+ 
+         if ( bSuccess )
+         {
+-			// new module window
+-			pWin = new ModulWindow( pModulLayout, rDocument, aLibName, aModName, aModule );
+-			nKey = InsertWindowInTable( pWin );
++			pWin = FindBasWin( rDocument, aLibName, aModName, FALSE, TRUE );
++            if( !pWin )
++			{    // new module window
++			    pWin = new ModulWindow( pModulLayout, rDocument, aLibName, aModName, aModule );
++			    nKey = InsertWindowInTable( pWin );
++            }
+         }
+ 	}
+ 	else
+@@ -269,7 +272,8 @@ ModulWindow* BasicIDEShell::CreateBasWin
+ 		}
+ 		DBG_ASSERT( nKey, "CreateBasWin: Kein Key- Fenster nicht gefunden!" );
+ 	}
+-	pTabBar->InsertPage( (USHORT)nKey, aModName );
++    if( nKey )
++	    pTabBar->InsertPage( (USHORT)nKey, aModName );
+ 	pTabBar->Sort();
+ 	pWin->GrabScrollBars( &aHScrollBar, &aVScrollBar );
+ 	if ( !pCurWin )
+diff -rup /data4/OOOBuildM12/ooo-build/build/ooh680-m12/basctl/source/basicide/basidesh.cxx basctl/source/basicide/basidesh.cxx
+--- /data4/OOOBuildM12/ooo-build/build/ooh680-m12/basctl/source/basicide/basidesh.cxx	2008-01-14 16:00:46.000000000 +0000
++++ basctl/source/basicide/basidesh.cxx	2008-03-28 10:30:34.000000000 +0000
+@@ -97,6 +97,9 @@
+ #include <com/sun/star/script/XLibraryContainer.hpp>
+ #include <com/sun/star/script/XLibraryContainerPassword.hpp>
+ #include <com/sun/star/container/XNameContainer.hpp>
++#include <com/sun/star/container/XContainer.hpp>
++#include <com/sun/star/container/XContainerListener.hpp>
++#include <com/sun/star/script/XLibraryContainer.hpp>
+ 
+ #include <svx/xmlsecctrl.hxx>
+ 
+@@ -104,6 +107,71 @@ using namespace ::com::sun::star::uno;
+ using namespace ::com::sun::star;
+ using ::rtl::OUString;
+ 
++static const rtl::OUString sStandardLibName(  rtl::OUString::createFromAscii("Standard") );
++
++typedef ::cppu::WeakImplHelper1< container::XContainerListener > ContainerListenerBASE;
++
++class ContainerListenerImpl : public ContainerListenerBASE
++{
++    BasicIDEShell* mpShell;
++public:
++
++    ContainerListenerImpl( BasicIDEShell* pShell ) : mpShell( pShell ) {}
++
++    ~ContainerListenerImpl() 
++    {
++    }
++
++    void addContainerListener( const ScriptDocument& rScriptDocument )
++    {
++        uno::Reference< container::XContainer > xContainer( rScriptDocument.getLibrary( E_SCRIPTS, sStandardLibName, FALSE ), uno::UNO_QUERY );
++        if ( rScriptDocument.isDocument() && xContainer.is() )
++        {
++            uno::Reference< container::XContainerListener > xContainerListener( this );
++            try
++            {
++                xContainer->addContainerListener( xContainerListener );
++            }
++            catch( uno::Exception& ) {}
++        }
++    }
++    void removeContainerListener( const ScriptDocument& rScriptDocument )
++    {
++        uno::Reference< container::XContainer > xContainer( rScriptDocument.getLibrary( E_SCRIPTS, sStandardLibName, FALSE ), uno::UNO_QUERY );
++        if ( rScriptDocument.isDocument(), xContainer.is() )
++        {
++            uno::Reference< container::XContainerListener > xContainerListener( this );
++            try
++            {
++               xContainer->removeContainerListener( xContainerListener );
++            }
++            catch( uno::Exception& ) {}
++        }
++    }
++
++    // XEventListener
++    virtual void SAL_CALL disposing( const lang::EventObject& ) throw( uno::RuntimeException ) {}
++
++    // XContainerListener
++    virtual void SAL_CALL elementInserted( const container::ContainerEvent& Event ) throw( uno::RuntimeException )
++    {
++        rtl::OUString sModuleName;
++        if( mpShell && ( Event.Accessor >>= sModuleName ) )
++            mpShell->FindBasWin( mpShell->m_aCurDocument, sStandardLibName, sModuleName, TRUE, FALSE );
++    }
++    virtual void SAL_CALL elementReplaced( const container::ContainerEvent& ) throw( com::sun::star::uno::RuntimeException ) { }
++    virtual void SAL_CALL elementRemoved( const container::ContainerEvent& Event ) throw( com::sun::star::uno::RuntimeException )
++    {
++        rtl::OUString sModuleName;
++        if( mpShell  && ( Event.Accessor >>= sModuleName ) )
++        {
++            IDEBaseWindow* pWin = mpShell->FindWindow( mpShell->m_aCurDocument, sStandardLibName, sModuleName, BASICIDE_TYPE_MODULE, TRUE );
++            if( pWin )
++                mpShell->RemoveWindow( pWin, FALSE, TRUE );
++        }
++    }
++
++};
+ 
+ TYPEINIT1( BasicIDEShell, SfxViewShell );
+ 
+@@ -141,6 +209,7 @@ BasicIDEShell::BasicIDEShell( SfxViewFra
+         m_bAppBasicModified( FALSE ),
+         m_aNotifier( *this )
+ {
++    m_xLibListener = new ContainerListenerImpl( this );
+ 	Init();
+     GnBasicIDEShellCount++;
+ }
+@@ -156,6 +225,7 @@ BasicIDEShell::BasicIDEShell( SfxViewFra
+         m_aNotifier( *this )
+ {
+ 	DBG_ERROR( "Zweite Ansicht auf Debugger nicht moeglich!" );
++    m_xLibListener = new ContainerListenerImpl( this );
+     GnBasicIDEShellCount++;
+ }
+ 
+@@ -170,6 +240,7 @@ BasicIDEShell::BasicIDEShell( SfxViewFra
+         m_aNotifier( *this )
+ {
+ 	Init();
++    m_xLibListener = new ContainerListenerImpl( this );
+     GnBasicIDEShellCount++;
+ }
+ 
+@@ -258,6 +329,12 @@ __EXPORT BasicIDEShell::~BasicIDEShell()
+ 	delete pTabBar;
+ 	delete pObjectCatalog;
+ 	DestroyModulWindowLayout();
++
++        ContainerListenerImpl* pListener = dynamic_cast< ContainerListenerImpl* >( m_xLibListener.get() );
++        // Destroy all ContainerListeners for Basic Container.
++        if ( pListener )
++            pListener->removeContainerListener( m_aCurDocument );
++    
+ 	// MI: Das gab einen GPF im SDT beim Schliessen da dann der ViewFrame die
+ 	// ObjSh loslaesst. Es wusste auch keiner mehr wozu das gut war.
+ 	// GetViewFrame()->GetObjectShell()->Broadcast( SfxSimpleHint( SFX_HINT_DYING ) );
+@@ -275,6 +352,7 @@ sal_Bool BasicIDEShell::HasBasic() const
+ 
+ void BasicIDEShell::onDocumentCreated( const ScriptDocument& /*_rDocument*/ )
+ {
++    // _rDocument is not a valid ScriptDocument.
+     UpdateWindows();
+ }
+ 
+@@ -303,6 +381,8 @@ void BasicIDEShell::onDocumentSaveAsDone
+     // not interested in
+ }
+ 
++//============================================================================
++
+ void BasicIDEShell::onDocumentClosed( const ScriptDocument& _rDocument )
+ {
+     if ( !_rDocument.isValid() )
+@@ -402,7 +482,6 @@ void BasicIDEShell::StoreAllWindowData( 
+ 	}
+ }
+ 
+-
+ USHORT __EXPORT BasicIDEShell::PrepareClose( BOOL bUI, BOOL bForBrowsing )
+ {
+ 	(void)bForBrowsing;
+@@ -600,7 +679,6 @@ void BasicIDEShell::ShowObjectDialog( BO
+ }
+ 
+ 
+-
+ void __EXPORT BasicIDEShell::SFX_NOTIFY( SfxBroadcaster& rBC, const TypeId&,
+ 										const SfxHint& rHint, const TypeId& )
+ {
+@@ -983,7 +1061,15 @@ void BasicIDEShell::SetCurLib( const Scr
+ {
+     if ( !bCheck || ( rDocument != m_aCurDocument || aLibName != m_aCurLibName ) )
+     {
++        ContainerListenerImpl* pListener = dynamic_cast< ContainerListenerImpl* >( m_xLibListener.get() );
++        if ( pListener )
++        	pListener->removeContainerListener( m_aCurDocument );
++
+         m_aCurDocument = rDocument;
++
++        if ( pListener )
++            pListener->addContainerListener( m_aCurDocument );
++
+         m_aCurLibName = aLibName;
+         if ( bUpdateWindows )
+             UpdateWindows();
+diff -rup /data4/OOOBuildM12/ooo-build/build/ooh680-m12/basctl/source/basicide/scriptdocument.cxx basctl/source/basicide/scriptdocument.cxx
+--- /data4/OOOBuildM12/ooo-build/build/ooh680-m12/basctl/source/basicide/scriptdocument.cxx	2007-10-09 16:24:54.000000000 +0100
++++ basctl/source/basicide/scriptdocument.cxx	2008-03-28 10:30:34.000000000 +0000
+@@ -61,6 +61,7 @@
+ #include <com/sun/star/frame/XModel2.hpp>
+ #include <com/sun/star/awt/XWindow2.hpp>
+ #include <com/sun/star/document/XEmbeddedScripts.hpp>
++#include <com/sun/star/script/ModuleInfo.hpp>
+ /** === end UNO includes === **/
+ 
+ #include <sfx2/objsh.hxx>
+@@ -146,6 +147,7 @@ namespace basctl
+     using ::com::sun::star::uno::RuntimeException;
+     using ::com::sun::star::document::XEventBroadcaster;
+     using ::com::sun::star::document::XEmbeddedScripts;
++    using ::com::sun::star::script::ModuleInfo;
+     /** === end UNO using === **/
+     namespace MacroExecMode = ::com::sun::star::document::MacroExecMode;
+     namespace FrameSearchFlag = ::com::sun::star::frame::FrameSearchFlag;
+@@ -678,6 +680,15 @@ namespace basctl
+             }
+ 
+ 		    // insert element by new name in container
++            if ( _eType == E_SCRIPTS )
++            {
++                ModuleInfo sModuleInfo;
++                if ( aElement >>= sModuleInfo )
++                {
++                    sModuleInfo.ModuleName = _rNewName;
++                    aElement <<= sModuleInfo;
++                }
++            }
+ 		    xLib->insertByName( _rNewName, aElement );
+             return true;
+         }
+@@ -1433,7 +1444,15 @@ namespace basctl
+         Any aCode;
+         if ( !m_pImpl->getModuleOrDialog( E_SCRIPTS, _rLibName, _rModName, aCode ) )
+             return false;
+-        OSL_VERIFY( aCode >>= _out_rModuleSource );
++        ModuleInfo sModuleInfo;
++        if ( aCode >>= sModuleInfo )
++        {
++            _out_rModuleSource = sModuleInfo.ModuleSource;
++        }
++        else
++        {
++            OSL_VERIFY( aCode >>= _out_rModuleSource );
++        }
+         return true;
+     }
+ 
+diff -rup /data4/OOOBuildM12/ooo-build/build/ooh680-m12/basctl/source/inc/basidesh.hxx basctl/source/inc/basidesh.hxx
+--- /data4/OOOBuildM12/ooo-build/build/ooh680-m12/basctl/source/inc/basidesh.hxx	2007-10-09 16:25:06.000000000 +0100
++++ basctl/source/inc/basidesh.hxx	2008-03-28 10:30:34.000000000 +0000
+@@ -62,7 +62,7 @@
+ #ifndef _COM_SUN_STAR_IO_XINPUTSTREAMPROVIDER_HXX_
+ #include <com/sun/star/io/XInputStreamProvider.hpp>
+ #endif
+-
++#include <com/sun/star/container/XContainerListener.hpp>
+ 
+ //----------------------------------------------------------------------------
+ 
+@@ -90,13 +90,15 @@ DECLARE_TABLE( IDEWindowTable, IDEBaseWi
+ typedef Table IDEWindowTable;
+ #endif
+ 
++namespace css = ::com::sun::star;
++
+ class BasicIDEShell :public SfxViewShell
+                     ,public ::basctl::DocumentEventListener
+ {
+ friend class JavaDebuggingListenerImpl;
+ friend class LocalizationMgr;
+ friend class BasicIDE;
+-
++friend class ContainerListenerImpl;
+ 	ObjectCatalog* 		pObjectCatalog;
+ 
+ 	IDEWindowTable		aIDEWindowTable;
+@@ -116,6 +118,7 @@ friend class BasicIDE;
+     BOOL                m_bAppBasicModified;
+     ::basctl::DocumentEventNotifier
+                         m_aNotifier;
++	css::uno::Reference< css::container::XContainerListener > m_xLibListener; 	
+ 
+ #if _SOLAR__PRIVATE
+ 	void				Init();
+diff -rup /data4/OOOBuildM12/ooo-build/build/ooh680-m12/basic/inc/basic/sbdef.hxx basic/inc/basic/sbdef.hxx
+--- /data4/OOOBuildM12/ooo-build/build/ooh680-m12/basic/inc/basic/sbdef.hxx	2007-04-11 13:51:38.000000000 +0100
++++ basic/inc/basic/sbdef.hxx	2008-03-28 10:30:34.000000000 +0000
+@@ -100,6 +100,7 @@ void setBasicWatchMode( bool bOn );
+ 
+ #define SBXID_BASIC			0x6273			// sb: StarBASIC
+ #define	SBXID_BASICMOD		0x6d62			// bm: StarBASIC-Modul
++#define SBXID_DOCUMENTMOD   0x6d63          // Special document Module
+ #define SBXID_BASICPROP		0x7262			// pr: StarBASIC-Property
+ #define	SBXID_BASICMETHOD	0x6d65          // me: StarBASIC-Methode
+ #define	SBXID_JSCRIPTMOD	0x6a62			// jm: JavaScript-Modul
+diff -rup /data4/OOOBuildM12/ooo-build/build/ooh680-m12/basic/inc/basic/sbstar.hxx basic/inc/basic/sbstar.hxx
+--- /data4/OOOBuildM12/ooo-build/build/ooh680-m12/basic/inc/basic/sbstar.hxx	2007-08-30 10:58:14.000000000 +0100
++++ basic/inc/basic/sbstar.hxx	2008-03-28 10:30:34.000000000 +0000
+@@ -51,6 +51,7 @@
+ 
+ #include <basic/sbdef.hxx>
+ #include <basic/sberrors.hxx>
++#include <com/sun/star/script/ModuleInfo.hpp>
+ 
+ class SbModule;                     // fertiges Modul
+ class SbiInstance;                  // Laufzeit-Instanz
+@@ -82,6 +83,7 @@ class StarBASIC : public SbxObject
+ 	BOOL			bNoRtl;				// TRUE: RTL nicht durchsuchen
+ 	BOOL			bBreak;				// TRUE: Break, sonst Step
+ 	BOOL			bDocBasic;
++    BOOL            bVBAEnabled;
+ 	BasicLibInfo*	pLibInfo;			// Infoblock fuer Basic-Manager
+ 	SbLanguageMode	eLanguageMode;		// LanguageMode des Basic-Objekts
+ protected:
+@@ -124,7 +126,8 @@ public:
+ 
+ 	// Compiler-Interface
+ 	SbModule*   	MakeModule( const String& rName, const String& rSrc );
+-    SbModule*   	MakeModule32( const String& rName, const ::rtl::OUString& rSrc );
++    SbModule*       MakeModule32( const String& rName, const ::rtl::OUString& rSrc );
++    SbModule*       MakeObjModule( const String& rName, const com::sun::star::script::ModuleInfo& mInfo );
+ 	BOOL			Compile( SbModule* );
+ 	BOOL 			Disassemble( SbModule*, String& rText );
+ 	static void 	Stop();
+@@ -196,6 +199,8 @@ public:
+ 					( const String& rName, USHORT& rStatus );
+ 	static SbMethod* GetActiveMethod( USHORT nLevel = 0 );
+ 	static SbModule* GetActiveModule();
++    void SetVBAEnabled( BOOL bEnabled );
++    BOOL isVBAEnabled();
+ 
+ 	// #60175 TRUE: SFX-Resource wird bei Basic-Fehlern nicht angezogen
+ 	static void StaticSuppressSfxResource( BOOL bSuppress );
+diff -rup /data4/OOOBuildM12/ooo-build/build/ooh680-m12/basic/inc/basic/sbxobj.hxx basic/inc/basic/sbxobj.hxx
+--- /data4/OOOBuildM12/ooo-build/build/ooh680-m12/basic/inc/basic/sbxobj.hxx	2007-04-11 13:55:16.000000000 +0100
++++ basic/inc/basic/sbxobj.hxx	2008-03-28 10:30:34.000000000 +0000
+@@ -80,7 +80,7 @@ public:
+ 	virtual SbxClassType GetClass() const;
+ 	virtual void Clear();
+ 
+-	virtual BOOL  IsClass( const String& ) const;
++	virtual BOOL  IsClass( const String& );
+ 	const String& GetClassName() const { return aClassName; }
+ 	void		  SetClassName( const String &rNew ) { aClassName = rNew; }
+ 	// Default-Property
+diff -rup /data4/OOOBuildM12/ooo-build/build/ooh680-m12/basic/source/basmgr/basmgr.cxx basic/source/basmgr/basmgr.cxx
+--- /data4/OOOBuildM12/ooo-build/build/ooh680-m12/basic/source/basmgr/basmgr.cxx	2007-08-30 10:58:48.000000000 +0100
++++ basic/source/basmgr/basmgr.cxx	2008-03-28 10:30:34.000000000 +0000
+@@ -102,6 +102,8 @@
+ #include <com/sun/star/script/XStarBasicDialogInfo.hpp>
+ #include <com/sun/star/script/XStarBasicLibraryInfo.hpp>
+ #include <com/sun/star/script/XLibraryContainerPassword.hpp>
++#include <com/sun/star/script/ModuleInfo.hpp>
++#include <com/sun/star/script/ModuleType.hpp>
+ 
+ #include <cppuhelper/implbase1.hxx>
+ 
+@@ -145,6 +147,7 @@ static const char* szScriptLanguage = "S
+ static const String BasicStreamName( String::CreateFromAscii(szBasicStorage) );
+ static const String ManagerStreamName( String::CreateFromAscii(szManagerStream) );
+ 
++//enum ModuleType { Unknown = 0, Normal, Class, Form, Document };
+ 
+ #define	DEFINE_CONST_UNICODE(CONSTASCII)    UniString(RTL_CONSTASCII_USTRINGPARAM(CONSTASCII))
+ 
+@@ -280,9 +283,22 @@ void BasMgrContainerListenerImpl::addLib
+ 		{
+ 			OUString aModuleName = pNames[ j ];
+ 			Any aElement = xLibNameAccess->getByName( aModuleName );
++            ModuleInfo mInfo;
+ 			OUString aMod;
+-			aElement >>= aMod;
+-			pLib->MakeModule32( aModuleName, aMod );
++            sal_Int16 mType;
++            if ( aElement >>= mInfo )
++            {
++                aMod = mInfo.ModuleSource;
++                mType = mInfo.ModuleType;
++                OSL_TRACE("#1 - aMod");
++                //pLib->MakeModule32( aModuleName, aMod, SBXID_DOCUMENTMOD );
++                pLib->MakeObjModule( aModuleName, mInfo );
++            }
++            else
++            {
++			    aElement >>= aMod;
++			    pLib->MakeModule32( aModuleName, aMod );
++            }
+ 		}
+ 	}
+ 
+@@ -319,8 +335,16 @@ void SAL_CALL BasMgrContainerListenerImp
+ 	}
+ 	else
+ 	{
++        ModuleInfo mInfo;
+ 		OUString aMod;
+-		Event.Element >>= aMod;
++        sal_Int16 mType;
++        if( Event.Element >>= mInfo )
++        {
++            aMod = mInfo.ModuleSource;
++            mType = mInfo.ModuleType;
++        }
++        else
++		    Event.Element >>= aMod;
+ 
+ 		StarBASIC* pLib = mpMgr->GetLib( maLibName );
+ 		DBG_ASSERT( pLib, "BasMgrContainerListenerImpl::elementInserted: Unknown lib!");
+@@ -329,7 +353,15 @@ void SAL_CALL BasMgrContainerListenerImp
+     		SbModule* pMod = pLib->FindModule( aName );
+             if( !pMod )
+             {
+-			    pLib->MakeModule32( aName, aMod );
++                if ( mType == ::com::sun::star::script::ModuleType::Document )
++                {
++                    //pLib->MakeModule32( aName, aMod, SBXID_DOCUMENTMOD );
++                    pLib->MakeObjModule( aName, mInfo );
++                }
++                else
++                {
++			        pLib->MakeModule32( aName, aMod );
++                }
+ 			    pLib->SetModified( FALSE );
+             }
+ 		}
+@@ -356,12 +388,27 @@ void SAL_CALL BasMgrContainerListenerImp
+ 	if( pLib )
+ 	{
+ 		SbModule* pMod = pLib->FindModule( aName );
++        ModuleInfo mInfo;
+ 		OUString aMod;
++        sal_Int16 mType;
+ 		Event.Element >>= aMod;
+ 		if( pMod )
+ 			pMod->SetSource32( aMod );
+ 		else
+-			pLib->MakeModule32( aName, aMod );
++        {
++            if( Event.Element >>= mInfo )
++            {
++                aMod = mInfo.ModuleSource;
++                mType = mInfo.ModuleType;
++                //pLib->MakeModule32( aName, aMod, SBXID_DOCUMENTMOD );
++                pLib->MakeObjModule( aName, mInfo );
++            }
++            else
++            {
++                Event.Element >>= aMod;
++			    pLib->MakeModule32( aName, aMod );
++            }
++        }
+ 
+ 		pLib->SetModified( FALSE );
+ 	}
+diff -rup /data4/OOOBuildM12/ooo-build/build/ooh680-m12/basic/source/classes/sb.cxx basic/source/classes/sb.cxx
+--- /data4/OOOBuildM12/ooo-build/build/ooh680-m12/basic/source/classes/sb.cxx	2008-03-29 23:08:18.000000000 +0000
++++ basic/source/classes/sb.cxx	2008-03-28 10:30:34.000000000 +0000
+@@ -70,6 +70,7 @@
+ #include "disas.hxx"
+ #include "runtime.hxx"
+ #include <basic/sbuno.hxx>
++#include <basic/sbobjmod.hxx>
+ #include "stdobj.hxx"
+ #include "filefmt.hxx"
+ #include "sb.hrc"
+@@ -79,6 +80,10 @@
+ #include <vos/mutex.hxx>
+ #endif
+ 
++#include <com/sun/star/script/ModuleType.hpp>
++#include <com/sun/star/script/ModuleInfo.hpp>
++using namespace ::com::sun::star::script;
++
+ // #pragma SW_SEGMENT_CLASS( SBASIC, SBASIC_CODE )
+ 
+ SV_IMPL_VARARR(SbTextPortions,SbTextPortion)
+@@ -667,6 +672,7 @@ StarBASIC::StarBASIC( StarBASIC* p, BOOL
+ 	SetParent( p );
+ 	pLibInfo = NULL;
+ 	bNoRtl = bBreak = FALSE;
++    bVBAEnabled = FALSE;
+ 	pModules = new SbxArray;
+ 
+ 	if( !GetSbData()->nInst++ )
+@@ -769,13 +775,33 @@ SbModule* StarBASIC::MakeModule( const S
+ 
+ SbModule* StarBASIC::MakeModule32( const String& rName, const ::rtl::OUString& rSrc )
+ {
+-	SbModule* p = new SbModule( rName );
++    SbModule* p = new SbModule( rName );
+ 	p->SetSource32( rSrc );
+ 	p->SetParent( this );
+ 	pModules->Insert( p, pModules->Count() );
+ 	SetModified( TRUE );
+ 	return p;
+ }
++SbModule* StarBASIC::MakeObjModule( const String& rName, const ModuleInfo& mInfo )
++{
++    
++    SbObjModule* p = NULL;
++    switch ( mInfo.ModuleType )
++    {
++        case ModuleType::Document:
++            p = new SbObjModule( rName, mInfo );
++            break;
++        default:
++            break; // 
++    }
++    if ( p )
++    {
++ 	pModules->Insert( p, pModules->Count() );
++	SetModified( TRUE );
++	p->SetParent( this );
++    }
++    return p;
++}
+ 
+ void StarBASIC::Insert( SbxVariable* pVar )
+ {
+@@ -948,6 +977,8 @@ SbxVariable* StarBASIC::Find( const Stri
+ 				}
+ 				pNamed = p;
+ 			}
++            if ( p->GetSbxId() == SBXID_DOCUMENTMOD )
++                continue;
+ 			// Sonst testen, ob das Element vorhanden ist
+ 			// GBLSEARCH-Flag rausnehmen (wg. Rekursion)
+ 			USHORT nGblFlag = p->GetFlags() & SBX_GBLSEARCH;
+--- /dev/null	2007-05-04 11:54:36.000000000 +0100
++++ basic/inc/basic/sbobjmod.hxx	2008-04-02 17:40:27.000000000 +0100
+@@ -0,0 +1,71 @@
++/*************************************************************************
++ *
++ *  OpenOffice.org - a multi-platform office productivity suite
++ *
++ *  $RCSfile: sbobjmod.hxx,v $
++ *
++ *  $Revision: 1.4 $
++ *
++ *  last change: $Author:  $ $Date: 2007/08/27 16:31:39 $
++ *
++ *  The Contents of this file are made available subject to
++ *  the terms of GNU Lesser General Public License Version 2.1.
++ *
++ *
++ *    GNU Lesser General Public License Version 2.1
++ *    =============================================
++ *    Copyright 2005 by Sun Microsystems, Inc.
++ *    901 San Antonio Road, Palo Alto, CA 94303, USA
++ *
++ *    This library is free software; you can redistribute it and/or
++ *    modify it under the terms of the GNU Lesser General Public
++ *    License version 2.1, as published by the Free Software Foundation.
++ *
++ *    This library 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 for more details.
++ *
++ *    You should have received a copy of the GNU Lesser General Public
++ *    License along with this library; if not, write to the Free Software
++ *    Foundation, Inc., 59 Temple Place, Suite 330, Boston,
++ *    MA  02111-1307  USA
++ *
++ ************************************************************************/
++
++#ifndef _SB_OBJMOD_HXX
++#define _SB_OBJMOD_HXX
++
++#include <basic/sbmod.hxx>
++#include <basic/sbstar.hxx>
++#include <com/sun/star/script/ModuleInfo.hpp>
++#include <com/sun/star/lang/XEventListener.hpp>
++#include <com/sun/star/awt/XDialog.hpp>
++
++namespace css = ::com::sun::star;
++
++// Basic-Module for excel object.
++
++class SbObjModule : public SbModule
++{
++protected:
++    com::sun::star::script::ModuleInfo m_mInfo;
++    SbxObjectRef pDocObject; // a vba api object.
++    virtual void InitObject();
++public:
++    TYPEINFO();
++	SBX_DECL_PERSIST_NODATA(SBXCR_SBX,SBXID_DOCUMENTMOD,2);
++    SbObjModule( const rtl::OUString& rName, const com::sun::star::script::ModuleInfo& mInfo );
++    virtual SbxVariable* Find( const XubString& rName, SbxClassType t );
++    SbxVariable* GetObject();
++	virtual BOOL  IsClass( const String& );
++};
++
++#ifndef __SB_SBOBJMODULEREF_HXX
++#define __SB_SBOBJMODULEREF_HXX
++
++SV_DECL_IMPL_REF(SbObjModule);
++
++#endif
++#endif
++
+--- /data4/OOOBuildM12/ooo-build/build/ooh680-m12/basic/source/classes/sbxmod.cxx	2008-04-08 12:03:51.000000000 +0100
++++ basic/source/classes/sbxmod.cxx	2008-04-06 21:34:40.000000000 +0100
+@@ -51,6 +51,9 @@
+ #include <basic/hilight.hxx>
+ #include <basic/basrdll.hxx>
+ #include <vos/mutex.hxx>
++#include <basic/sbobjmod.hxx>
++#include <com/sun/star/script/XObjectProvider.hpp>
++#include <com/sun/star/lang/XServiceInfo.hpp>
+ 
+ // for the bsearch
+ #ifdef WNT
+@@ -80,7 +83,20 @@
+ 
+ #include <stdio.h>
+ 
++#include <comphelper/processfactory.hxx>
++#include <com/sun/star/script/XLibraryContainer.hpp>
++#include <com/sun/star/lang/XMultiServiceFactory.hpp>
++#include <com/sun/star/awt/XDialogProvider.hpp>
++#include <com/sun/star/awt/XTopWindow.hpp>
++#include <com/sun/star/awt/XControl.hpp>
++#include <com/sun/star/frame/XModel.hpp>
++#include <cppuhelper/implbase1.hxx>
++#include <comphelper/anytostring.hxx>
++
++using namespace ::com::sun::star; 
++
+ static const String sThisWorkbook( RTL_CONSTASCII_USTRINGPARAM("ThisWorkbook"));
++static const rtl::OUString sStandard( RTL_CONSTASCII_USTRINGPARAM("Standard") );
+ 
+ TYPEINIT1(SbModule,SbxObject)
+ TYPEINIT1(SbMethod,SbxMethod)
+@@ -88,6 +104,7 @@ TYPEINIT1(SbProperty,SbxProperty)
+ TYPEINIT1(SbProcedureProperty,SbxProperty)
+ TYPEINIT1(SbJScriptModule,SbModule)
+ TYPEINIT1(SbJScriptMethod,SbMethod)
++TYPEINIT1(SbObjModule,SbModule)
+ 
+ SV_DECL_VARARR(SbiBreakpoints,USHORT,4,4)
+ SV_IMPL_VARARR(SbiBreakpoints,USHORT)
+@@ -1903,3 +1921,80 @@ void SyntaxHighlighter::getHighlightPort
+ 	m_pSimpleTokenizer->getHighlightPortions( nLine, rLine, portions );
+ }
+ 
++/////////////////////////////////////////////////////////////////////////
++SbObjModule::SbObjModule( const rtl::OUString& rName, const com::sun::star::script::ModuleInfo& mInfo )
++    :SbModule( rName ), pDocObject( NULL )
++{
++    m_mInfo = mInfo;
++    SetSource32( mInfo.ModuleSource );
++}
++
++BOOL
++SbObjModule::IsClass( const XubString& rName )
++{
++    GetObject();
++    return SbxObject::IsClass( rName );
++}
++
++SbxVariable*
++SbObjModule::GetObject() 
++{
++    if( !pDocObject )
++        InitObject();
++    return pDocObject;
++}
++SbxVariable*
++SbObjModule::Find( const XubString& rName, SbxClassType t )
++{
++    //OSL_TRACE("SbObjectModule find for %s", rtl::OUStringToOString(  rName, RTL_TEXTENCODING_UTF8 ).getStr() );
++    if ( !pDocObject )
++        InitObject();
++    //OSL_TRACE("!!!!try to find in derived module " );
++    SbxVariable* pVar = NULL;
++    if ( !pVar && pDocObject)
++    {
++        pVar = pDocObject->Find( rName, t );
++        if ( pVar )
++        {
++           //OSL_TRACE("found in uno (psuedo-base) object" );
++        }
++        else
++	{
++           //OSL_TRACE("NOT found in uno (psuedo-base) object" );
++	}
++    }
++    if ( !pVar )
++    {
++        pVar = SbModule::Find( rName, t );
++        if ( pVar )
++	{
++           //OSL_TRACE("! found in (normal) module " );
++	}
++    }
++
++    return pVar;
++}
++
++void
++SbObjModule::InitObject()
++{
++   // OSL_TRACE("Initialize pDocObject");
++    try
++    {
++        com::sun::star::uno::Reference< com::sun::star::script::XObjectProvider > xObjectProvider( m_mInfo.ModuleObjectProvider, com::sun::star::uno::UNO_QUERY_THROW );
++        com::sun::star::uno::Any aObject = xObjectProvider->getObject();
++        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" ) );
++        }
++    }catch( com::sun::star::uno::RuntimeException e )
++    {
++        //OSL_TRACE("Object is not exist." );
++    }
++}
+
+ 
+ /////////////////////////////////////////////////////////////////////////
+ // Implementation SbJScriptModule (Basic-Modul fuer JavaScript-Sourcen)
+diff -rup /data4/OOOBuildM12/ooo-build/build/ooh680-m12/basic/source/runtime/methods1.cxx basic/source/runtime/methods1.cxx
+--- /data4/OOOBuildM12/ooo-build/build/ooh680-m12/basic/source/runtime/methods1.cxx	2007-09-20 16:55:19.000000000 +0100
++++ basic/source/runtime/methods1.cxx	2008-03-28 10:30:34.000000000 +0000
+@@ -44,6 +44,7 @@
+ #ifndef _SBX_HXX
+ #include <basic/sbx.hxx>
+ #endif
++#include <basic/sbstar.hxx>
+ #include <svtools/zforlist.hxx>
+ #include <tools/fsys.hxx>
+ #include <tools/urlobj.hxx>
+@@ -86,6 +89,7 @@
+ #endif
+ 
+ #include <vcl/jobset.hxx>
++#include <basic/sbobjmod.hxx>
+ 
+ #include "sbintern.hxx"
+ #include "runtime.hxx"
+@@ -2611,13 +2615,13 @@ RTLFUNC(Me)
+     
+ 	SbModule* pActiveModule = pINST->GetActiveModule();
+ 	SbClassModuleObject* pClassModuleObject = PTR_CAST(SbClassModuleObject,pActiveModule);
++    SbxVariableRef refVar = rPar.Get(0);
+ 	if( pClassModuleObject == NULL )
+ 	{
+-		StarBASIC::Error( SbERR_INVALID_USAGE_OBJECT );
++        SbObjModule* pMod = PTR_CAST(SbObjModule,pActiveModule);
++        if ( pMod )
++            refVar->PutObject( pMod );
+ 	}
+ 	else
+-	{
+-		SbxVariableRef refVar = rPar.Get(0);
+ 		refVar->PutObject( pClassModuleObject );
+-	}
+ }
+diff -rup /data4/OOOBuildM12/ooo-build/build/ooh680-m12/basic/source/runtime/runtime.cxx basic/source/runtime/runtime.cxx
+--- /data4/OOOBuildM12/ooo-build/build/ooh680-m12/basic/source/runtime/runtime.cxx	2008-03-29 23:08:19.000000000 +0000
++++ basic/source/runtime/runtime.cxx	2008-03-29 00:19:02.000000000 +0000
+@@ -82,6 +82,17 @@ void StarBASIC::StaticEnableReschedule( 
+ {
+     bStaticGlobalEnableReschedule = bReschedule;
+ }
++void StarBASIC::SetVBAEnabled( BOOL bEnabled )
++{
++    bVBAEnabled = bEnabled;
++}
++
++BOOL StarBASIC::isVBAEnabled()
++{
++    if( SbiRuntime::isVBAEnabled() )
++        return TRUE;
++    return bVBAEnabled;
++}
+ 
+ 
+ struct SbiArgvStack {					// Argv stack:
+diff -rup /data4/OOOBuildM12/ooo-build/build/ooh680-m12/basic/source/sbx/sbxobj.cxx basic/source/sbx/sbxobj.cxx
+--- /data4/OOOBuildM12/ooo-build/build/ooh680-m12/basic/source/sbx/sbxobj.cxx	2007-06-27 15:31:34.000000000 +0100
++++ basic/source/sbx/sbxobj.cxx	2008-03-28 10:30:34.000000000 +0000
+@@ -187,7 +187,7 @@ void SbxObject::SFX_NOTIFY( SfxBroadcast
+ 	}
+ }
+ 
+-BOOL SbxObject::IsClass( const XubString& rName ) const
++BOOL SbxObject::IsClass( const XubString& rName )
+ {
+ 	return BOOL( aClassName.EqualsIgnoreCaseAscii( rName ) );
+ }
+diff -rup /data4/OOOBuildM12/ooo-build/build/ooh680-m12/basic/source/uno/namecont.cxx basic/source/uno/namecont.cxx
+--- /data4/OOOBuildM12/ooo-build/build/ooh680-m12/basic/source/uno/namecont.cxx	2008-02-26 17:01:46.000000000 +0000
++++ basic/source/uno/namecont.cxx	2008-03-28 10:30:34.000000000 +0000
+@@ -139,6 +139,9 @@
+ #endif
+ #include <basic/sbmod.hxx>
+ 
++#ifndef _COM_SUN_STAR_SCRIPT_MODULEINFO_HPP_
++#include <com/sun/star/script/ModuleInfo.hpp>
++#endif
+ 
+ namespace basic
+ {
+@@ -217,7 +220,7 @@ void NameContainer::replaceByName( const
+ 	throw(IllegalArgumentException, NoSuchElementException, WrappedTargetException, RuntimeException)
+ {
+ 	Type aAnyType = aElement.getValueType();
+-	if( mType != aAnyType )
++    if( mType != aAnyType && aAnyType != getCppuType( static_cast< ModuleInfo* >( NULL ) ) )
+ 		throw IllegalArgumentException();
+ 
+ 	NameContainerNameMap::iterator aIt = mHashMap.find( aName );
+@@ -259,7 +262,7 @@ void NameContainer::insertByName( const 
+ 	throw(IllegalArgumentException, ElementExistException, WrappedTargetException, RuntimeException)
+ {
+ 	Type aAnyType = aElement.getValueType();
+-	if( mType != aAnyType )
++    if( mType != aAnyType && aAnyType != getCppuType( static_cast< ModuleInfo* >( NULL ) ) )
+ 		throw IllegalArgumentException();
+ 
+ 	NameContainerNameMap::iterator aIt = mHashMap.find( aName );
+diff -rup /data4/OOOBuildM12/ooo-build/build/ooh680-m12/sfx2/source/doc/docmacromode.cxx sfx2/source/doc/docmacromode.cxx
+--- /data4/OOOBuildM12/ooo-build/build/ooh680-m12/sfx2/source/doc/docmacromode.cxx	2008-01-24 15:54:21.000000000 +0000
++++ sfx2/source/doc/docmacromode.cxx	2008-03-28 10:30:34.000000000 +0000
+@@ -45,6 +45,7 @@
+ #include <com/sun/star/task/DocumentMacroConfirmationRequest.hpp>
+ #include <com/sun/star/task/InteractionClassification.hpp>
+ #include <com/sun/star/security/XDocumentDigitalSignatures.hpp>
++#include <com/sun/star/script/ModuleInfo.hpp>
+ /** === end UNO includes === **/
+ 
+ #include <comphelper/componentcontext.hxx>
+@@ -80,8 +81,11 @@ namespace sfx2
+     using ::com::sun::star::document::XEmbeddedScripts;
+     using ::com::sun::star::uno::UNO_SET_THROW;
+     using ::com::sun::star::script::XLibraryContainer;
++    using ::com::sun::star::script::ModuleInfo;
+     using ::com::sun::star::container::XNameAccess;
++    using ::com::sun::star::container::XNameContainer;
+     using ::com::sun::star::uno::UNO_QUERY_THROW;
++    using ::com::sun::star::uno::Sequence;
+ 	/** === end UNO using === **/
+     namespace MacroExecMode = ::com::sun::star::document::MacroExecMode;
+ 
+@@ -427,7 +431,7 @@ namespace sfx2
+                     bHasMacroLib = sal_False;
+                 else
+ 			    {
+-				    ::rtl::OUString aStdLibName( RTL_CONSTASCII_USTRINGPARAM( "Standard" ) );
++				    ::rtl::OUString aStdLibName( ::rtl::OUString::intern( RTL_CONSTASCII_USTRINGPARAM( "Standard" ) ) );
+ 				    Sequence< ::rtl::OUString > aElements = xContainer->getElementNames();
+ 				    if ( aElements.getLength() )
+ 				    {
+@@ -447,8 +451,43 @@ namespace sfx2
+ 						    Any aAny = xContainer->getByName( aStdLibName );
+ 						    aAny >>= xLib;
+ 						    if ( xLib.is() )
++                            {
+ 							    bHasMacroLib = xLib->hasElements();
+-					    }
++                                if( !bHasMacroLib )
++                                    return bHasMacroLib;
++                                // VBA will introduce some empty Object Module
++                                // If all module only include
++                                // "Rem Attribute VBA_ModuleType=VBADocumentModule\nOption VBASupport"
++                                // it should be set bHasMacros as false
++                                Sequence< ::rtl::OUString > sNames = xLib->getElementNames();
++                                Reference < XNameContainer > xNameContainer( xContainer->getByName( aStdLibName ), UNO_QUERY_THROW );
++                                sal_Int32 nCount = sNames.getLength();
++                                ::rtl::OUString sName;
++                                Any aCode;
++                                ModuleInfo sModuleInfo;
++                                ::rtl::OUString sMod;
++                                ::rtl::OUString sVbaOptiona( ::rtl::OUString::intern( RTL_CONSTASCII_USTRINGPARAM( "Rem Attribute VBA_ModuleType=VBADocumentModule\nOption VBASupport 1\n" )));
++                                ::rtl::OUString sVbaOptionb( ::rtl::OUString::intern( RTL_CONSTASCII_USTRINGPARAM( "\r\n" )));
++                                sVbaOptionb = sVbaOptiona + sVbaOptionb;
++                                for ( sal_Int32 nMod = 0; nMod < nCount; nMod++ )
++                                {
++                                    sName = sNames[nMod];
++                                    if ( xNameContainer->hasByName( sName ) )
++                                        aCode = xNameContainer->getByName( sName );
++                                    if ( aCode >>= sModuleInfo )
++                                    {
++                                        sMod = sModuleInfo.ModuleSource;
++                                        if ( sMod.getLength() && !( sMod.equals( sVbaOptiona ) || sMod.equals( sVbaOptionb ) ) )
++                                            return bHasMacroLib;
++                                    }
++                                    else
++                                    {
++                                        return bHasMacroLib;
++                                    }
++                                }
++                                bHasMacroLib = sal_False;
++					        }
++                        }
+ 				    }
+ 			    }
+ 		    }
+--- sc/source/core/tool/vbaeventshelper.cxx	2008-05-12 17:34:02.000000000 +0100
++++ sc/source/core/tool/vbaeventshelper.cxx	2008-05-12 17:44:52.000000000 +0100
+@@ -204,11 +204,10 @@ VbaWindowListener::disposing(  const lan
+ 
+ String ScVbaEventsHelper::getWorkbookModuleName()
+ {
+-	String sCodeName( RTL_CONSTASCII_USTRINGPARAM("ThisWorkbook") );
++	String sCodeName; // leave blank to force a search of all modules
+ 	if ( ScExtDocOptions* pExtDocOpts = pDoc->GetExtDocOptions() )
+ 	{
+-		if ( pExtDocOpts->GetDocSettings().maGlobCodeName.Len() > 0 ) 
+-			sCodeName = pExtDocOpts->GetDocSettings().maGlobCodeName;
++		sCodeName = pDoc->GetCodeName();
+ 	}
+ 	return sCodeName;
+ }
+@@ -305,7 +304,8 @@ sal_Bool ScVbaEventsHelper::processDocBe
+     	uno::Sequence< uno::Any > aArgs( 1 );
+     	aArgs[ 0 ] <<= bCancel;
+     	const static String sBeforeClose( RTL_CONSTASCII_USTRINGPARAM("Workbook_BeforeClose") );
+-    	String sFullClose = docMacroExists( pShell, String(), sBeforeClose );
++        rtl::OUString workbookModule = getWorkbookModuleName();
++    	String sFullClose = docMacroExists( pShell, workbookModule, sBeforeClose );
+     	if ( sFullClose.Len() > 0 )
+     	{ 
+     		if ( !executeWorkBookMacro( pShell, sFullClose, aArgs, aRet ) )
+@@ -512,12 +512,11 @@ void ScVbaEventsHelper::getSheetEventNam
+ 
+ String ScVbaEventsHelper::getSheetModuleName( SCTAB nTab )
+ {
+-	ScExtDocOptions* pExtOptions = pDoc->GetExtDocOptions();
+-	String aCodeName;
+-	pDoc->GetName( nTab, aCodeName);
++	String aCodeName; // leave blank to force full search
+ 	// Use code name if that exists
+-	if ( pExtOptions )
+-		aCodeName = pExtOptions->GetCodeName( nTab );
++	if ( ScExtDocOptions* pExtOptions = pDoc->GetExtDocOptions() )
++		// for an imported excel doc we always have the codename
++		pDoc->GetCodeName( nTab, aCodeName );
+ 	return aCodeName;	
+ }
+ 
+@@ -649,7 +648,8 @@ sal_Bool ScVbaEventsHelper::processDocBe
+ 	sal_Bool bCancel = sal_False;
+ 	aArgs[ 0 ] <<= bCancel;
+ 	const static String sBeforeClose( RTL_CONSTASCII_USTRINGPARAM("Workbook_BeforePrint") );
+-	String sFullClose = docMacroExists( pShell, String(), sBeforeClose );
++	rtl::OUString workbookModule = getWorkbookModuleName(); 
++	String sFullClose = docMacroExists( pShell, workbookModule, sBeforeClose );
+ 	if ( sFullClose.Len() > 0 )
+ 	{ 
+ 		if ( !executeWorkBookMacro( pShell, sFullClose, aArgs, aRet ) )
+@@ -667,7 +667,8 @@ void ScVbaEventsHelper::processDocNewShe
+         uno::Sequence< uno::Any > aArgs(1);
+         aArgs[0] = aElement;
+         const static String sNewSheet( RTL_CONSTASCII_USTRINGPARAM("Workbook_NewSheet") );
+-        String sFullClose = docMacroExists( pShell, String(), sNewSheet );
++        rtl::OUString workbookModule = getWorkbookModuleName();
++        String sFullClose = docMacroExists( pShell, workbookModule, sNewSheet );
+         if ( sFullClose.Len() > 0 )
+         {
+             executeWorkBookMacro( pShell, sFullClose, aArgs, aRet );
+@@ -702,7 +703,8 @@ void ScVbaEventsHelper::processWindowMac
+     {
+         uno::Sequence< uno::Any > aArgs(1);
+         aArgs[0] = aElement;
+-        String sMacro = docMacroExists( pShell, String(), sFuncName );
++        rtl::OUString workbookModule = getWorkbookModuleName();
++        String sMacro = docMacroExists( pShell, workbookModule, sFuncName );
+         if ( sMacro.Len() > 0 )
+         {
+             executeWorkBookMacro( pShell, sMacro, aArgs, aRet );
+@@ -767,7 +769,7 @@ sal_Bool ScVbaEventsHelper::processDocAc
+     sal_Bool result = sal_True;
+     const static rtl::OUString sAtctivateMacro( RTL_CONSTASCII_USTRINGPARAM("Workbook_Activate") );
+     const static rtl::OUString sOnFocusEvt( RTL_CONSTASCII_USTRINGPARAM("OnFocus") );
+-    rtl::OUString sWorkbookModule;
++    rtl::OUString sWorkbookModule = getWorkbookModuleName();
+     String sFullOnFocus = docMacroExists( pShell, sWorkbookModule, sAtctivateMacro );
+     if( sFullOnFocus.Len() > 0 )
+     {
+@@ -782,7 +784,7 @@ sal_Bool ScVbaEventsHelper::processDocDe
+     sal_Bool result = sal_True;
+     const static rtl::OUString sDeatctivateMacro( RTL_CONSTASCII_USTRINGPARAM("Workbook_Deactivate") );
+     const static rtl::OUString sOnFocusEvt( RTL_CONSTASCII_USTRINGPARAM("OnUnfocus") );
+-    rtl::OUString sWorkbookModule;
++    rtl::OUString sWorkbookModule = getWorkbookModuleName();
+     String sFullUnOnfocus = docMacroExists( pShell, sWorkbookModule, sDeatctivateMacro );
+     if( sFullUnOnfocus.Len() > 0 )
+     {
+@@ -797,7 +799,8 @@ void ScVbaEventsHelper::processDocDeacti
+     uno::Any aRet;
+     uno::Sequence< uno::Any > aArgs;
+     const static String sDeactivate( RTL_CONSTASCII_USTRINGPARAM("Workbook_Deactivate") );
+-    String sDeactivateMacro = docMacroExists( pShell, String(), sDeactivate );
++    rtl::OUString sWorkbookModule = getWorkbookModuleName();
++    String sDeactivateMacro = docMacroExists( pShell, sWorkbookModule, sDeactivate );
+     if ( sDeactivateMacro.Len() > 0 )
+     {
+         executeWorkBookMacro( pShell, sDeactivateMacro, aArgs, aRet );
+@@ -853,7 +856,8 @@ sal_Bool ScVbaEventsHelper::processDocBe
+     aArgs[ 0 ] <<= bSaveAsUI;
+ 	aArgs[ 1 ] <<= bCancel;
+ 	const static String sBeforeClose( RTL_CONSTASCII_USTRINGPARAM("Workbook_BeforeSave") );
+-	String sFullClose = docMacroExists( pShell, String(), sBeforeClose );
++	rtl::OUString workbookModule = getWorkbookModuleName(); 
++	String sFullClose = docMacroExists( pShell, workbookModule, sBeforeClose );
+ 	if ( sFullClose.Len() > 0 )
+ 	{ 
+ 		if ( !executeWorkBookMacro( pShell, sFullClose, aArgs, aRet ) )
+@@ -880,8 +884,7 @@ sal_Bool ScVbaEventsHelper::processDocOp
+ 	// until ObjectModules ( and persisting of codename )  are supported if this is a
+ 	// document saved from XL then we won't be able to determine the codename for the Workbook
+ 	// Module, so... we have no choice but to search all modules for the moment 	
+-	//rtl::OUString workbookModule = getWorkbookModuleName( pShell );
+-	rtl::OUString workbookModule; // no name means all modules will be searched
++	rtl::OUString workbookModule = getWorkbookModuleName(); 
+ 	String sFullOpen = docMacroExists( pShell, workbookModule, sOpenMacro );
+ 	if ( sFullOpen.Len() > 0 )
+ 	{



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