ooo-build r12401 - in trunk: . patches/dev300 patches/vba



Author: noelpwer
Date: Wed Apr 30 16:31:04 2008
New Revision: 12401
URL: http://svn.gnome.org/viewvc/ooo-build?rev=12401&view=rev

Log:
2008-04-30  Noel Power  <noel power novell com>

        * patches/dev300/apply: replaced cws-ab48 with my bracket patches
        unfortunately it causes some compile errors
        * patches/vba/vbaevents-services-sources.diff: new versions of patches
        for vba fake event handling for controls
        * patches/dev300/buildfix-no-UPD-in-library-names.diff:
        * patches/vba/scp_vba_uno_service.diff:



Modified:
   trunk/ChangeLog
   trunk/patches/dev300/buildfix-no-UPD-in-library-names.diff
   trunk/patches/vba/scp_vba_uno_service.diff
   trunk/patches/vba/vbaevents-services-sources.diff

Modified: trunk/patches/dev300/buildfix-no-UPD-in-library-names.diff
==============================================================================
--- trunk/patches/dev300/buildfix-no-UPD-in-library-names.diff	(original)
+++ trunk/patches/dev300/buildfix-no-UPD-in-library-names.diff	Wed Apr 30 16:31:04 2008
@@ -26,32 +26,3 @@
  SHL1IMPLIB = i$(SHL1TARGET)
  SHL1LIBS = $(LIB1TARGET)
  SHL1VERSIONMAP=$(TARGET).map
-diff --git scp2/source/ooo/file_library_ooo.scp scp2/source/ooo/file_library_ooo.scp
-index 87cba44..7c18c29 100644
---- scp2/source/ooo/file_library_ooo.scp
-+++ scp2/source/ooo/file_library_ooo.scp
-@@ -90,9 +90,9 @@ File gid_File_Lib_Vbaevent
-     RegistryID = gid_Starregistry_Services_Rdb;
-     Dir = gid_Dir_Program;
-   #ifdef UNX
--    Name = STRING(CONCAT5(vbaevents,OFFICEUPD,DLLPOSTFIX,.uno,UNXSUFFIX));
-+    Name = STRING(CONCAT4(vbaevents,DLLPOSTFIX,.uno,UNXSUFFIX));
-   #else
--    Name = STRING(CONCAT5(vbaevents,OFFICEUPD,DLLPOSTFIX,.uno,.dll));
-+    Name = STRING(CONCAT4(vbaevents,DLLPOSTFIX,.uno,.dll));
-   #endif
- End
- #endif // ENABLE_VBA
-diff --git scripting/source/vbaevents/makefile.mk scripting/source/vbaevents/makefile.mk
-index cbf4f55..eabb67e 100644
---- scripting/source/vbaevents/makefile.mk
-+++ scripting/source/vbaevents/makefile.mk
-@@ -34,7 +34,7 @@ SLOFILES= \
- 		$(SLO)$/service.obj \
- 		$(SLO)$/eventhelper.obj
- 
--SHL1TARGET= $(TARGET)$(UPD)$(DLLPOSTFIX).uno
-+SHL1TARGET= $(TARGET)$(DLLPOSTFIX).uno
- SHL1IMPLIB=     i$(TARGET)
- 
- SHL1VERSIONMAP=$(TARGET).map

Modified: trunk/patches/vba/scp_vba_uno_service.diff
==============================================================================
--- trunk/patches/vba/scp_vba_uno_service.diff	(original)
+++ trunk/patches/vba/scp_vba_uno_service.diff	Wed Apr 30 16:31:04 2008
@@ -1,7 +1,6 @@
-diff -rup scp2/source/ooo/file_library_ooo.scp scp2/source/ooo/file_library_ooo.scp
---- scp2/source/ooo/file_library_ooo.scp	2007-02-11 08:10:05.000000000 +0000
-+++ scp2/source/ooo/file_library_ooo.scp	2007-02-12 10:56:04.000000000 +0000
-@@ -95,6 +95,20 @@ File gid_File_Lib_Basprov
+--- scp2/source/ooo/file_library_ooo.scp	2008-04-30 11:44:31.000000000 +0100
++++ scp2/source/ooo/file_library_ooo.scp	2008-04-30 11:56:14.000000000 +0100
+@@ -67,6 +67,20 @@ File gid_File_Lib_Basprov
    #endif
  End
  
@@ -12,13 +11,13 @@
 +    RegistryID = gid_Starregistry_Services_Rdb;
 +    Dir = gid_Dir_Program;
 +  #ifdef UNX
-+    Name = STRING(CONCAT5(vbaevents,OFFICEUPD,DLLPOSTFIX,.uno,UNXSUFFIX));
++    Name = STRING(CONCAT4(vbaevents,DLLPOSTFIX,.uno,UNXSUFFIX));
 +  #else
-+    Name = STRING(CONCAT5(vbaevents,OFFICEUPD,DLLPOSTFIX,.uno,.dll));
++    Name = STRING(CONCAT4(vbaevents,DLLPOSTFIX,.uno,.dll));
 +  #endif
 +End
 +#endif // ENABLE_VBA
 +
  STD_UNO_LIB_FILE( gid_File_Lib_Bib , bib)
  
- File gid_File_Lib_Brdgfctr
+ File gid_File_Lib_Cached1

Modified: trunk/patches/vba/vbaevents-services-sources.diff
==============================================================================
--- trunk/patches/vba/vbaevents-services-sources.diff	(original)
+++ trunk/patches/vba/vbaevents-services-sources.diff	Wed Apr 30 16:31:04 2008
@@ -1,5 +1,5 @@
---- /dev/null	2005-06-05 14:44:09.000000000 +0100
-+++ scripting/source/vbaevents/makefile.mk	2005-09-14 10:02:37.927118445 +0100
+--- /dev/null	2007-05-04 11:54:36.000000000 +0100
++++ scripting/source/vbaevents/makefile.mk	2008-04-28 16:07:24.000000000 +0100
 @@ -0,0 +1,58 @@
 +PRJ=..$/..
 +
@@ -37,7 +37,7 @@
 +		$(SLO)$/service.obj \
 +		$(SLO)$/eventhelper.obj
 +
-+SHL1TARGET= $(TARGET)$(UPD)$(DLLPOSTFIX).uno
++SHL1TARGET= $(TARGET)$(DLLPOSTFIX).uno
 +SHL1IMPLIB=     i$(TARGET)
 +
 +SHL1VERSIONMAP=$(TARGET).map
@@ -59,411 +59,9 @@
 +# --- Targets ------------------------------------------------------
 +
 +.INCLUDE :	target.mk
---- /dev/null	2005-06-05 14:44:09.000000000 +0100
-+++ scripting/source/vbaevents/service.cxx	2005-09-14 10:02:01.344708779 +0100
-@@ -0,0 +1,99 @@
-+#include "cppuhelper/implementationentry.hxx"
-+#include "com/sun/star/lang/XMultiServiceFactory.hpp"
-+#include "com/sun/star/registry/XRegistryKey.hpp"
-+
-+// =============================================================================
-+// component exports
-+// =============================================================================
-+using namespace ::com::sun::star;
-+using namespace ::com::sun::star::uno;
-+
-+namespace evtlstner
-+{
-+    // =============================================================================
-+    // component operations
-+    // =============================================================================
-+
-+    uno::Reference< XInterface > SAL_CALL create(
-+        Reference< XComponentContext > const & xContext )
-+        SAL_THROW( () );
-+
-+    // -----------------------------------------------------------------------------
-+
-+    ::rtl::OUString SAL_CALL getImplementationName();
-+
-+    Sequence< ::rtl::OUString > SAL_CALL getSupportedServiceNames();
-+
-+    Reference<XInterface> SAL_CALL create(
-+        Sequence<Any> const &, Reference<XComponentContext> const & );
-+} // end evtlstner
-+
-+namespace ooevtdescgen
-+{
-+    // =============================================================================
-+    // component operations
-+    // =============================================================================
-+
-+    uno::Reference< XInterface > SAL_CALL create(
-+        Reference< XComponentContext > const & xContext )
-+        SAL_THROW( () );
-+
-+    // -----------------------------------------------------------------------------
-+
-+    ::rtl::OUString SAL_CALL getImplementationName();
-+
-+    Sequence< ::rtl::OUString > SAL_CALL getSupportedServiceNames();
-+
-+    Reference<XInterface> SAL_CALL create(
-+        Sequence<Any> const &, Reference<XComponentContext> const & );
-+} // end ooevtdescgen
-+
-+
-+
-+    // =============================================================================
-+
-+    const ::cppu::ImplementationEntry s_component_entries [] =
-+    {
-+        {
-+            ::evtlstner::create, ::evtlstner::getImplementationName,
-+            ::evtlstner::getSupportedServiceNames, 
-+            ::cppu::createSingleComponentFactory,
-+            0, 0
-+        },
-+        {
-+            ::ooevtdescgen::create, ::ooevtdescgen::getImplementationName,
-+            ::ooevtdescgen::getSupportedServiceNames, 
-+            ::cppu::createSingleComponentFactory,
-+            0, 0
-+        },
-+        { 0, 0, 0, 0, 0, 0 }
-+    };
-+
-+extern "C"
-+{
-+    void SAL_CALL component_getImplementationEnvironment( 
-+        const sal_Char ** ppEnvTypeName, uno_Environment ** ppEnv )
-+    {
-+        OSL_TRACE("In component_getImplementationEnv");
-+        *ppEnvTypeName = CPPU_CURRENT_LANGUAGE_BINDING_NAME;
-+    }
-+
-+    sal_Bool SAL_CALL component_writeInfo( 
-+        lang::XMultiServiceFactory * pServiceManager, registry::XRegistryKey * pRegistryKey )
-+    {
-+        OSL_TRACE("In component_writeInfo");
-+        if ( ::cppu::component_writeInfoHelper(
-+            pServiceManager, pRegistryKey, s_component_entries ) )
-+            return sal_True;
-+        return sal_False;
-+    }
-+
-+    void * SAL_CALL component_getFactory( 
-+        const sal_Char * pImplName, lang::XMultiServiceFactory * pServiceManager,
-+        registry::XRegistryKey * pRegistryKey )
-+    {
-+        OSL_TRACE("In component_getFactory");
-+        return ::cppu::component_getFactoryHelper( 
-+            pImplName, pServiceManager, pRegistryKey, s_component_entries );
-+    }
-+}
---- /dev/null	2005-06-05 14:44:09.000000000 +0100
-+++ scripting/source/vbaevents/vbaevents.map	2005-09-14 10:02:01.346708419 +0100
-@@ -0,0 +1,9 @@
-+OOO_1.1 {
-+	global:
-+		component_getImplementationEnvironment;
-+		component_getFactory;
-+		component_writeInfo;
-+
-+	local:
-+		*;
-+};
---- /dev/null	2005-06-05 14:44:09.000000000 +0100
-+++ scripting/source/vbaevents/vbaevents.xml	2005-09-14 10:02:01.346708419 +0100
-@@ -0,0 +1,26 @@
-+<?xml version="1.0" encoding="UTF-8"?>
-+<!DOCTYPE module-description PUBLIC "-//StarOffice//DTD ComponentDescription 1.0//EN" "module-description.dtd">
-+<module-description xmlns:xlink="http://www.w3.org/1999/xlink";>
-+
-+    <module-name>vbaevents</module-name>
-+    
-+    <component-description>
-+        <author>Noel Power </author>
-+        <name>org.openoffice.vba.EventListener</name>
-+        <description>Event listener to handle ooo events and to translate them to calls to basic macros ala Button_Click etc.</description>
-+        <loader-name>com.sun.star.loader.SharedLibrary</loader-name>
-+        <language>c++</language>
-+        <status value="drafts"/>
-+        <supported-service>org.openoffice.vba.EventListener</supported-service>
-+        <type>com.sun.star.uno.XComponentContext</type>        
-+    </component-description>
-+    
-+    <project-build-dependency>cppuhelper</project-build-dependency>
-+    <project-build-dependency>cppu</project-build-dependency>
-+    <project-build-dependency>sal</project-build-dependency>
-+
-+    <runtime-module-dependency>cppuhelper3$(COM)</runtime-module-dependency>
-+    <runtime-module-dependency>cppu3</runtime-module-dependency>
-+    <runtime-module-dependency>sal3</runtime-module-dependency>
-+    
-+</module-description>
-
-diff -rup sc/source/filter/excel/makefile.mk sc/source/filter/excel/makefile.mk
---- sc/source/filter/excel/makefile.mk	2007-02-15 11:53:17.000000000 +0000
-+++ sc/source/filter/excel/makefile.mk	2007-02-15 10:49:50.000000000 +0000
-@@ -50,6 +50,11 @@ PROJECTPCHSOURCE=..\pch\filt_pch
- .INCLUDE :  sc.mk
- .INCLUDE :  $(PRJ)$/util$/makefile.pmk
- 
-+.IF "$(ENABLE_VBA)"=="YES"
-+        CDEFS+=-DENABLE_VBA
-+        INCPRE=$(INCCOM)$/vbaobj
-+.ENDIF
-+
- # --- Files --------------------------------------------------------
- 
- SLOFILES =	\
-diff -rup sc/source/filter/excel/xiescher.cxx sc/source/filter/excel/xiescher.cxx
---- sc/source/filter/excel/xiescher.cxx	2007-02-15 10:49:49.000000000 +0000
-+++ sc/source/filter/excel/xiescher.cxx	2007-02-15 11:46:04.000000000 +0000
-@@ -1555,6 +1555,8 @@ SdrObject* XclImpDffManager::ProcessObj(
-     if( XclImpDrawingObj* pDrawingObj = dynamic_cast< XclImpDrawingObj* >( xDrawObj.get() ) )
-         pDrawingObj->SetTxoData( mrObjManager.FindTxoData( rObjData.rSpHd ) );
- 
-+    if( xSdrObj.get() )
-+        xDrawObj->SetObjectName( xSdrObj->GetName() );
-     // try to create a custom SdrObject that overwrites the passed object
-     SdrObjectPtr xNewSdrObj( CreateCustomSdrObject( *xDrawObj, rAnchorRect ) );
-     if( xNewSdrObj.get() )
-diff -rup sc/source/filter/excel/xlocx.cxx sc/source/filter/excel/xlocx.cxx
---- sc/source/filter/excel/xlocx.cxx	2007-02-15 11:53:17.000000000 +0000
-+++ sc/source/filter/excel/xlocx.cxx	2007-02-15 11:50:10.000000000 +0000
-@@ -58,8 +58,30 @@
- #include <com/sun/star/drawing/XControlShape.hpp>
- #include <com/sun/star/form/XFormsSupplier.hpp>
- #include <com/sun/star/form/XFormComponent.hpp>
--#include <com/sun/star/script/ScriptEventDescriptor.hpp>
- #include <com/sun/star/script/XEventAttacherManager.hpp>
-+
-+#ifdef ENABLE_VBA
-+#include <basic/sbstar.hxx>
-+#include <basic/sbmod.hxx>
-+#include <basic/sbmeth.hxx>
-+#include <basic/sbx.hxx>
-+#include <scextopt.hxx>
-+#include <com/sun/star/awt/XControl.hpp>
-+#include <org/openoffice/vba/XVBAToOOEventDescGen.hpp>
-+#include <cppuhelper/bootstrap.hxx>
-+#include <sfx2/objsh.hxx>
-+
-+using org::openoffice::vba::XVBAToOOEventDescGen;
-+using com::sun::star::uno::XComponentContext;
-+using com::sun::star::awt::XControl;
-+using com::sun::star::uno::UNO_QUERY_THROW;
-+
-+#else // ENABLE_VBA
-+
-+#include <com/sun/star/script/ScriptEventDescriptor.hpp>
-+
-+#endif //ENABLE_VBA
-+
- #include <svx/svdpage.hxx>
- #include <svx/unoapi.hxx>
- #include "fapihelper.hxx"
-@@ -178,6 +214,10 @@ SdrObject* XclImpOcxConverter::CreateSdr
-             // reads from mxStrm into xShape, inserts the control model into the form of the sheet
-             if( ReadOCXExcelKludgeStream( mxStrm, &xShape, TRUE ) )
-                 pSdrObj = FinalizeSdrObject( rOcxCtrlObj, xShape, rAnchorRect );
-+#ifdef ENABLE_VBA
-+            Reference< XControlModel > xModel = XclControlObjHelper::GetModelFromShape( xShape );
-+            RegisterOleMacros( xModel, rOcxCtrlObj );
-+#endif //ENABLE_VBA
-         }
-         catch( Exception& )
-         {
-@@ -273,22 +313,126 @@ SdrObject* XclImpOcxConverter::FinalizeS
- void XclImpOcxConverter::RegisterTbxMacro( const XclImpTbxControlObj& rTbxCtrlObj )
- {
-     ScriptEventDescriptor aEvent;
-+#ifdef ENABLE_VBA
-+    if ( rTbxCtrlObj.FillMacroDescriptor( aEvent ) )
-+        AttachMacro( aEvent );
-+#else
-     if( (mnLastIndex >= 0) && rTbxCtrlObj.FillMacroDescriptor( aEvent ) )
-     {
-+         Reference< XEventAttacherManager > xEventMgr( GetFormComps(), UNO_QUERY );
-+         if( xEventMgr.is() )
-+         {
-+             try
-+             {
-+                xEventMgr->registerScriptEvent( mnLastIndex, aEvent );
-+             }
-+             catch( Exception& )
-+             {
-+                DBG_ERRORFILE( "XclImpOcxConverter::RegisterTbxMacro - cannot register macro" );
-+             }
-+         }
-+    }
-+#endif
-+}
-+#ifdef ENABLE_VBA
-+void XclImpOcxConverter::AttachMacro( const ScriptEventDescriptor& rEvent )
-+{
-+    if( mnLastIndex >= 0 ) 
-+    {
-         Reference< XEventAttacherManager > xEventMgr( GetFormComps(), UNO_QUERY );
-         if( xEventMgr.is() )
-         {
-             try
-             {
--                xEventMgr->registerScriptEvent( mnLastIndex, aEvent );
-+                xEventMgr->registerScriptEvent( mnLastIndex, rEvent );
-             }
-             catch( Exception& )
-             {
--                DBG_ERRORFILE( "XclImpOcxConverter::RegisterTbxMacro - cannot register macro" );
-+                DBG_ERRORFILE( "XclImpOcxConverter::AttachMacro - cannot attach macro" );
-+            }
-+        }
-+    }
-+}
-+
-+void XclImpOcxConverter::RegisterOleMacros( const Reference< XControlModel > & rxModel, const XclImpOleObj& rOcxCtrlObj )
-+{
-+    if ( rxModel.is() )
-+    {
-+        // Need to search basic for macro's named e.g. ControlButton1_Click
-+        OUString sSearchString = rOcxCtrlObj.GetObjectName();
-+        sSearchString += OUString::createFromAscii("_");
-+        ScfPropertySet aPropSet( rxModel );
-+ 
-+        if( SfxObjectShell* pDocShell = GetDocShell() )
-+        {
-+            if( StarBASIC* pBasic = pDocShell->GetBasic() )
-+            {
-+                // Seach in the CodeName ( Module ) associated with this sheet
-+                if( SbModule* pModule = dynamic_cast< SbModule* >( pBasic->Find( GetExtDocOptions().GetCodeName(rOcxCtrlObj.GetScTab() ), SbxCLASS_OBJECT ) ) )
-+                {
-+                    Reference<XComponentContext > xContext( ::cppu::defaultBootstrap_InitialComponentContext(), UNO_QUERY_THROW ); // Fatal error anyway
-+                    if ( SbxArray* pMethods = pModule->GetMethods() )
-+                    {
-+                        sal_Int32 nNumMethods = pMethods->Count();
-+                        String sLibModName = pModule->GetName();
-+                        sLibModName.Insert('.',0).Insert( pModule->GetParent()->GetName(), 0 );
-+                        // Use service to create bindings for this control.
-+                        // Bindings are created based on the handlers found. 
-+                        // Note: service just needs the extensions for the handlers 
-+                        // that we found e.g.  "_Click, _Change, _GotFocus" etc.
-+                        // Hopefully this service can be re-used to do the same foo
-+                        // for UserForms
-+                        Reference< XVBAToOOEventDescGen > xEvtDescGen( xContext->getServiceManager()->createInstanceWithContext( CREATE_OUSTRING( "org.openoffice.vba.VBAToOOEventDesc" ), xContext ), UNO_QUERY );
-+                        if ( !xEvtDescGen.is() )
-+                            return;     // bail out here
-+                        Reference< XControl > xCntrl;
-+                        String sServiceName;
-+                        // VBAToOOEventDesc expects an XControl to introspect on
-+                        // so create one ( is discarded ) 
-+                        if ( aPropSet.GetStringProperty(  sServiceName, CREATE_OUSTRING( "DefaultControl" ) ) && sServiceName.Len() )
-+                        {
-+                            xCntrl.set( xContext->getServiceManager()->createInstanceWithContext( sServiceName , xContext), UNO_QUERY );
-+                            if ( xCntrl.is() )
-+                            {
-+                                // also need the model ( contains the control name
-+                                // as well )
-+                                xCntrl->setModel( rxModel );
-+                            }
-+                        }
-+                        for ( sal_Int32 nIndex=0; nIndex<nNumMethods; ++nIndex )
-+                        {
-+                            SbMethod* pMethod = dynamic_cast< SbMethod* >( pMethods->Get( static_cast< USHORT >( nIndex ) ) );
-+                            OUString sMeth( pMethod->GetName() );
-+    			// The name of the method and the name of the
-+    			// control may match in a case insensitive way
-+                            sal_Int32 nSearchIndex = sMeth.toAsciiUpperCase().indexOf( sSearchString.toAsciiUpperCase() );
-+                            if ( nSearchIndex == 0  )
-+                            {
-+                                Sequence< OUString > sHandlerExtns(1);
-+                                sHandlerExtns[ 0 ] = sMeth.copy( rOcxCtrlObj.GetObjectName().Len() );
-+                                OUString sMacroName = sMeth.copy( 0, rOcxCtrlObj.GetObjectName().Len() );
-+                                Sequence< ScriptEventDescriptor > aDescs( xEvtDescGen->getEventDescriptions( xCntrl, sLibModName, sHandlerExtns ) );
-+                                if ( aDescs.getLength() )
-+                                {
-+                                    ScriptEventDescriptor* pEvent = aDescs.getArray();
-+                                    ScriptEventDescriptor* pEnd = pEvent + aDescs.getLength();
-+                                    sal_Int32 counter = 0;
-+                                    for ( ; pEvent < pEnd; ++pEvent )
-+                                    {
-+                                        const static OUString sMacro( RTL_CONSTASCII_USTRINGPARAM("$macro"));
-+                                        pEvent->ScriptCode = pEvent->ScriptCode.replaceAt( pEvent->ScriptCode.indexOf( sMacro ), sMacro.getLength(), sMacroName );
-+                                        AttachMacro( *pEvent );
-+                                    }
-+                                }
-+                            }
-+                        }    
-+                    }
-+                }
-             }
-         }
-     }
- }
-+#endif //ENABLE_VBA
- 
- // ----------------------------------------------------------------------------
- 
-diff -rup sc/source/filter/inc/xiescher.hxx sc/source/filter/inc/xiescher.hxx
---- sc/source/filter/inc/xiescher.hxx	2007-02-15 10:49:49.000000000 +0000
-+++ sc/source/filter/inc/xiescher.hxx	2007-02-15 11:44:42.000000000 +0000
-@@ -116,6 +116,7 @@ public:
-     inline void         SetInvalid() { mbValid = false; }
-     /** If set, the SdrObject will be created or processed, but not be inserted into the draw page. */
-     inline void         SetSkipInsertSdr() { mbInsSdr = false; }
-+    inline void         SetObjectName( const String sName ) { maObjectName = sName; }
- 
-     /** Returns the Calc sheet index of this object. */
-     inline SCTAB        GetScTab() const { return maObjId.mnScTab; }
-@@ -149,6 +150,7 @@ public:
-     void                ProcessSdrObject( SdrObject& rSdrObj ) const;
-     /** Returns associated macro name ( if set ) otherwise returns zero length string. */
-     const String        GetMacroName() const { return maMacroName; }
-+    const String        GetObjectName() const { return maObjectName; }
- 
-     /** Returns the shape identifier used in the Escher stream. */
-     inline sal_uInt32   GetShapeId() const { return mnShapeId; }
-@@ -163,6 +165,7 @@ protected:
-     sal_uInt32          mnShapeId;      /// Shape ID from Escher stream.
-     sal_uInt32          mnShapeFlags;   /// Shape flags from Escher stream.
-     sal_uInt32          mnShapeBlipId;  /// The BLIP identifier (meta file).
-+    String              maObjectName;   /// Name of the Object
-     String              maMacroName;    /// Name of an attached macro.
-     bool                mbValid;        /// true = Object is valid, do processing and insertion.
-     bool                mbAreaObj;      /// true = Width and height must be greater than 0.
-diff -rup sc/source/filter/inc/xlocx.hxx sc/source/filter/inc/xlocx.hxx
---- sc/source/filter/inc/xlocx.hxx	2007-02-15 11:53:17.000000000 +0000
-+++ sc/source/filter/inc/xlocx.hxx	2007-02-15 11:40:59.000000000 +0000
-@@ -46,6 +46,12 @@
- #include <svx/msocximex.hxx>
- #include "xiroot.hxx"
- #include "xeroot.hxx"
-+
-+#ifdef ENABLE_VBA
-+
-+#include <com/sun/star/script/ScriptEventDescriptor.hpp>
-+
-+#endif //ENABLE_VBA
- 
- // 0 = Export TBX form controls, 1 = Export OCX form controls.
- #define EXC_EXP_OCX_CTRL 0
-@@ -114,6 +119,12 @@ private:
-                             const Rectangle& rAnchorRect ) const;
-     /** Tries to register a Basic macro for the control. */
-     void                RegisterTbxMacro( const XclImpTbxControlObj& rTbxCtrlObj );
-+#ifdef ENABLE_VBA
-+    void                RegisterOleMacros( const ::com::sun::star::uno::Reference< 
-+                                               ::com::sun::star::awt::XControlModel >& rxModel,
-+                                           const XclImpOleObj& rOcxCtrlObj );
-+    void                AttachMacro( const ::com::sun::star::script::ScriptEventDescriptor& rEvent );
-+#endif //ENABLE_VBA
- 
- private:
-     SotStorageStreamRef mxStrm;             /// The 'Ctls' stream in the Excel file.
 --- /dev/null	2007-05-04 11:54:36.000000000 +0100
-+++ scripting/source/vbaevents/eventhelper.cxx	2007-06-21 20:33:01.000000000 +0100
-@@ -0,0 +1,1003 @@
++++ scripting/source/vbaevents/eventhelper.cxx	2008-04-30 17:50:07.000000000 +0100
+@@ -0,0 +1,977 @@
 +#include <comphelper/processfactory.hxx>
 +#include <comphelper/uno3.hxx>
 +#include <comphelper/proparrhlp.hxx>
@@ -489,6 +87,7 @@
 +#include <com/sun/star/drawing/XControlShape.hpp>
 +
 +#include <com/sun/star/awt/XControl.hpp>
++#include <com/sun/star/awt/XDialog.hpp>
 +#include <com/sun/star/awt/KeyEvent.hpp>
 +#include <com/sun/star/awt/MouseEvent.hpp>
 +
@@ -560,7 +159,7 @@
 +    return aNames;
 +}
 +
-+// for debug only ( conditionalize out? ) 
++#if 0
 +void dumpListeners( const Reference< beans::XIntrospection >& xIntrospection, const Reference<XInterface>& xIfc)
 +{
 +    Reference< beans::XIntrospectionAccess > xIntrospectionAccess;
@@ -630,6 +229,7 @@
 +    }
 +}
 +
++#endif
 +
 +bool isKeyEventOk( awt::KeyEvent& evt, const Sequence< Any >& params )
 +{
@@ -743,6 +343,9 @@
 +        info.sVBAName = rtl::OUString::createFromAscii("_Click");
 +        info.toVBA = NULL;
 +        actionInfos.push_back( info );
++        info.sVBAName = rtl::OUString::createFromAscii("_Change");
++        info.toVBA = NULL;
++        actionInfos.push_back( info );
 +        eventTransInfo[ rtl::OUString::createFromAscii("actionPerformed") ] = actionInfos;
 +        // changed ooo event
 +        std::list< TranslateInfo > changeInfos;
@@ -802,7 +405,7 @@
 +        eventTransInfo[ rtl::OUString::createFromAscii("mousePressed") ] = mousePressedInfos;
 +        // mouseMoved ooo event
 +        std::list< TranslateInfo > mouseMovedInfos;
-+        info.sVBAName = rtl::OUString::createFromAscii("_MouseMoved");
++        info.sVBAName = rtl::OUString::createFromAscii("_MouseMove");
 +        info.toVBA = ooMouseEvtToVBAMouseEvt;
 +        mouseMovedInfos.push_back( info );
 +        eventTransInfo[ rtl::OUString::createFromAscii("mouseMoved") ] = mouseMovedInfos;
@@ -825,7 +428,7 @@
 +class ScriptEventFactory
 +{
 +public:
-+    static Sequence< ScriptEventDescriptor > createEvents( const Reference< XInterface >& xControl, const rtl::OUString& sLibModName, const Sequence< rtl::OUString >& sMethods );   
++    static Sequence< ScriptEventDescriptor > createEvents( const Reference< XInterface >& xControl, const rtl::OUString& sCodeName );   
 +    static ScriptEventFactory& instance() { static ScriptEventFactory inst; return inst; }
 +    static rtl::OUString getControlName( const Reference< XInterface >& xControl );
 +    static Sequence< rtl::OUString > getEventListeners( const Reference< XInterface >& xControl );
@@ -834,72 +437,8 @@
 +    Reference< XComponentContext > m_xCtx;
 +};
 +
-+// Helper function
-+bool
-+eventMethodToDescriptors( const ::rtl::OUString& rEventMethod,  const Reference< XInterface >& xControl, const rtl::OUString& sLibModName, const Sequence< rtl::OUString >& sHandlerExts, Sequence< ScriptEventDescriptor >& evtDescs )
-+{
-+    // format of ControlListener is TypeName::methodname e.g.
-+    // "com.sun.star.awt.XActionListener::actionPerformed" or
-+    // "XActionListener::actionPerformed
-+
-+    ::rtl::OUString sMethodName;
-+    ::rtl::OUString sTypeName;
-+    sal_Int32 nDelimPos = rEventMethod.indexOf( DELIM );
-+    if ( nDelimPos == -1 )
-+    {
-+        return false;
-+    }
-+    sMethodName = rEventMethod.copy( nDelimPos + DELIMLEN );
-+    sTypeName = rEventMethod.copy( 0, nDelimPos );
-+            
-+    EventInfoHash& infos = getEventTransInfo();
-+
-+    // Only create an ScriptEventDescriptor for an event we can translate
-+    // or emulate
-+    EventInfoHash::const_iterator eventInfo_it = infos.find( sMethodName );
-+    EventInfoHash::const_iterator it_end = infos.end();
-+
-+    // sLibModName ( could ) include the uri bits :-) from calc
-+    rtl::OUString sPartialMacroName = sLibModName + rtl::OUString( RTL_CONSTASCII_USTRINGPARAM(".") ) + rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("$macro"));
-+
-+    if ( sMethodName.getLength() 
-+         && sTypeName.getLength()
-+         && ( infos.find( sMethodName ) != infos.end() ) )
-+    {
-+        std::list< TranslateInfo >::const_iterator txInfo =
-+            eventInfo_it->second.begin();
-+        std::list< TranslateInfo >::const_iterator txInfo_end = 
-+            eventInfo_it->second.end();
-+        for ( ; txInfo != txInfo_end; ++txInfo )
-+        {
-+            // Check if extension is support for this method, if
-+            // so create an eventdescription for that
-+            const rtl::OUString* pExt = sHandlerExts.getConstArray();
-+            sal_Int32  nCount = sHandlerExts.getLength();
-+            for ( sal_Int32 counter=0;  counter<nCount; ++counter, ++pExt )
-+            {
-+                if ( (*txInfo).sVBAName.equals( *pExt ) ) // handler for event
-+                {
-+                    sal_Int32 nIndex = evtDescs.getLength();
-+	            evtDescs.realloc( evtDescs.getLength() + 1 );
-+                    evtDescs[ nIndex ].ScriptCode =  sPartialMacroName + *pExt;
-+                    evtDescs[ nIndex ].ListenerType = sTypeName;
-+                    evtDescs[ nIndex ].EventMethod = sMethodName;
-+
-+                    // set this it VBAInterop, ensures that it doesn't
-+                    // get persisted or shown in property editors
-+                    evtDescs[ nIndex ].ScriptType = rtl::OUString::createFromAscii( "VBAInterop" );	
-+                 }
-+            }    
-+        }
-+        return true;
-+    }
-+    return false;
-+
-+}
-+
 +bool
-+eventMethodToDescriptor( const ::rtl::OUString& rEventMethod, const Reference< XInterface >& xControl, ScriptEventDescriptor& evtDesc )
++eventMethodToDescriptor( const ::rtl::OUString& rEventMethod, ScriptEventDescriptor& evtDesc, const ::rtl::OUString& sCodeName )
 +{
 +    // format of ControlListener is TypeName::methodname e.g.
 +    // "com.sun.star.awt.XActionListener::actionPerformed" or
@@ -923,10 +462,10 @@
 +         && sTypeName.getLength()
 +         && ( infos.find( sMethodName ) != infos.end() ) )
 +    {
-+        // just fill in control name, event handler will
-+        // do the rest e.g. search for this routine in the doc basic
-+        // and run it.
-+        evtDesc.ScriptCode =  ScriptEventFactory::instance().getControlName(xControl);
++        // just fill in CodeName, when the event fires the other 
++	// info is gathered from the event source to determine what
++	// event handler we try to call
++        evtDesc.ScriptCode = sCodeName;
 +        evtDesc.ListenerType = sTypeName;
 +        evtDesc.EventMethod = sMethodName;
 +
@@ -988,8 +527,10 @@
 +        Reference< beans::XIntrospection > xIntrospection( 
 +            xMFac->createInstanceWithContext( rtl::OUString( 
 +                RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.beans.Introspection"  ) ), instance().m_xCtx ), UNO_QUERY );
-+        //dumpListeners( xIntrospection, xControl );
-+        //dumpListeners( xIntrospection, xControl->getModel() );
++#if 0
++        dumpListeners( xIntrospection, xControl );
++        dumpListeners( xIntrospection, xControl->getModel() );
++#endif 
 +        Reference< beans::XIntrospectionAccess > xIntrospectionAccess;
 +	if  ( xIntrospection.is() )
 +	{
@@ -1028,37 +569,28 @@
 +}
 +
 +Sequence< ScriptEventDescriptor > 
-+ScriptEventFactory::createEvents( const Reference< XInterface >& xControl, const rtl::OUString& sLibModName, const Sequence< rtl::OUString >& sHandlerExts )
++ScriptEventFactory::createEvents( const Reference< XInterface >& xControl, const rtl::OUString& sCodeName )
 +{
 +    Sequence< rtl::OUString > aControlListeners = ScriptEventFactory::instance().getEventListeners( xControl );
 +    rtl::OUString* pSrc = aControlListeners.getArray();
 +    sal_Int32 nLength = aControlListeners.getLength();             
 +
-+    Sequence< ScriptEventDescriptor > aDest( nLength * 2 );// sensible default
-+    ScriptEventDescriptor* pDest = aDest.getArray();
-+    sal_Int32 nEvts = 0;
-+
-+  
++    Sequence< ScriptEventDescriptor > aDest( nLength );
++    sal_Int32 nEvts = 0; 
 +    for ( sal_Int32 i = 0; i< nLength; ++i, ++pSrc )
 +    {
 +        // from getListeners eventName is of form
 +        // "com.sun.star.awt.XActionListener::actionPerformed"
 +        // we need to strip "com.sun.star.awt." from that for form
 +        // controls
-+        sal_Int32 lastDotIndex = -1;
-+        ::rtl::OUString sNoNameSpaceMethod = *pSrc;
-+        if ( ( lastDotIndex = pSrc->lastIndexOf( '.' ) ) > -1 )
-+            sNoNameSpaceMethod = sNoNameSpaceMethod.copy( lastDotIndex + 1 );
-+	Sequence< ScriptEventDescriptor> evtDescs;
-+        if ( eventMethodToDescriptors( sNoNameSpaceMethod, xControl, sLibModName, sHandlerExts, evtDescs ) )
++    	ScriptEventDescriptor evtDesc;
++        if ( eventMethodToDescriptor( *pSrc, evtDesc, sCodeName ) )
 +        {
 +            sal_Int32 dIndex = nEvts;
-+            nEvts += evtDescs.getLength();
-+            ScriptEventDescriptor* pDesc = evtDescs.getArray();
++            ++nEvts;
 +            if ( nEvts > aDest.getLength() )
 +                aDest.realloc( nEvts );// should never happen
-+            for ( ; dIndex < nEvts; ++dIndex, ++pDesc )
-+                aDest[ dIndex ] = *pDesc; 
++            aDest[ dIndex ] = evtDesc;
 +        }
 +    }
 +    aDest.realloc( nEvts );
@@ -1072,21 +604,21 @@
 +class ReadOnlyEventsNameContainer : public NameContainer_BASE
 +{
 +public:
-+    ReadOnlyEventsNameContainer( const Sequence< rtl::OUString >& eventMethods, const Reference< XInterface >& xControl );
++    ReadOnlyEventsNameContainer( const Sequence< rtl::OUString >& eventMethods, const rtl::OUString& sCodeName );
 +    // XNameContainer
 +
-+    virtual void SAL_CALL insertByName( const ::rtl::OUString& aName, const Any& aElement ) throw (lang::IllegalArgumentException, container::ElementExistException, lang::WrappedTargetException, RuntimeException)
++    virtual void SAL_CALL insertByName( const ::rtl::OUString&, const Any& ) throw (lang::IllegalArgumentException, container::ElementExistException, lang::WrappedTargetException, RuntimeException)
 +    {
 +        throw RuntimeException( rtl::OUString::createFromAscii( "ReadOnly container" ), Reference< XInterface >() );
 + 
 +    }
-+    virtual void SAL_CALL removeByName( const ::rtl::OUString& Name ) throw (::com::sun::star::container::NoSuchElementException, lang::WrappedTargetException, RuntimeException)
++    virtual void SAL_CALL removeByName( const ::rtl::OUString& ) throw (::com::sun::star::container::NoSuchElementException, lang::WrappedTargetException, RuntimeException)
 +    {
 +        throw RuntimeException( rtl::OUString::createFromAscii( "ReadOnly container" ), Reference< XInterface >() );
 +    }
 +
 +    // XNameReplace
-+    virtual void SAL_CALL replaceByName( const ::rtl::OUString& aName, const Any& aElement ) throw (lang::IllegalArgumentException, container::NoSuchElementException, lang::WrappedTargetException, RuntimeException)
++    virtual void SAL_CALL replaceByName( const ::rtl::OUString&, const Any& ) throw (lang::IllegalArgumentException, container::NoSuchElementException, lang::WrappedTargetException, RuntimeException)
 +    {
 +        throw RuntimeException( rtl::OUString::createFromAscii( "ReadOnly container" ), Reference< XInterface >() );
 + 
@@ -1110,7 +642,7 @@
 +    EventSupplierHash m_hEvents;
 +};
 +
-+ReadOnlyEventsNameContainer::ReadOnlyEventsNameContainer( const Sequence< rtl::OUString >& eventMethods, const Reference< XInterface >& xControl ) 
++ReadOnlyEventsNameContainer::ReadOnlyEventsNameContainer( const Sequence< rtl::OUString >& eventMethods, const rtl::OUString& sCodeName )
 +{
 +    const rtl::OUString* pSrc = eventMethods.getConstArray();
 +    sal_Int32 nLen = eventMethods.getLength();
@@ -1118,7 +650,7 @@
 +    {
 +        Any aDesc;
 +        ScriptEventDescriptor evtDesc;
-+        if (  eventMethodToDescriptor( *pSrc, xControl, evtDesc ) )
++        if (  eventMethodToDescriptor( *pSrc, evtDesc, sCodeName ) )
 +        {
 +            aDesc <<= evtDesc; 
 +            m_hEvents[ *pSrc ] = aDesc;
@@ -1160,8 +692,8 @@
 +class ReadOnlyEventsSupplier : public EventsSupplier_BASE
 +{
 +public:
-+    ReadOnlyEventsSupplier( const Sequence< ::rtl::OUString >& eventMethods, const Reference< XInterface >& xControl )
-+    { m_xNameContainer = new ReadOnlyEventsNameContainer( eventMethods, xControl ); }
++    ReadOnlyEventsSupplier( const Sequence< ::rtl::OUString >& eventMethods, const rtl::OUString& sCodeName )
++    { m_xNameContainer = new ReadOnlyEventsNameContainer( eventMethods, sCodeName ); }
 +    
 +    // XScriptEventSupplier
 +    virtual Reference< container::XNameContainer > SAL_CALL getEvents(  ) throw (RuntimeException){ return m_xNameContainer; }
@@ -1180,6 +712,7 @@
 +    ,public ::comphelper::OPropertyArrayUsageHelper< EventListener >
 +
 +{
++    
 +public:
 +    EventListener( const Reference< XComponentContext >& rxContext );
 +    // XEventListener
@@ -1197,6 +730,12 @@
 +
 +    // XTypeProvider
 +    DECLARE_XTYPEPROVIDER()
++    virtual void SAL_CALL setFastPropertyValue( sal_Int32 nHandle, const ::com::sun::star::uno::Any& rValue ) throw(::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::beans::PropertyVetoException, ::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException)
++    {
++        OPropertyContainer::setFastPropertyValue( nHandle, rValue );
++	if ( nHandle == EVENTLSTNR_PROPERTY_ID_MODEL )
++            setShellFromModel();
++    }
 +
 +protected:
 +    // OPropertySetHelper
@@ -1206,10 +745,12 @@
 +    virtual ::cppu::IPropertyArrayHelper* createArrayHelper(  ) const;
 +
 +private:
++    void setShellFromModel();
 +    void firing_Impl( const  ScriptEvent& evt, Any *pSyncRet=NULL ) throw( RuntimeException );
 +
 +    Reference< XComponentContext > m_xContext;
 +    Reference< frame::XModel > m_xModel;
++    SfxObjectShell* mpShell;
 +    
 +};
 +
@@ -1221,9 +762,26 @@
 +
 +}
 +
++void
++EventListener::setShellFromModel()
++{
++	// reset mpShell
++	mpShell = 0;
++	SfxObjectShell* pShell = SfxObjectShell::GetFirst();
++	while ( pShell )
++	{
++		if ( pShell->GetModel() == m_xModel )
++		{
++			mpShell = pShell;
++			break;
++		}
++		pShell = SfxObjectShell::GetNext( *pShell );
++	}    
++}
++
 +//XEventListener
 +void
-+EventListener::disposing(const lang::EventObject& Source)  throw( RuntimeException )
++EventListener::disposing(const lang::EventObject&)  throw( RuntimeException )
 +{
 +}
 +
@@ -1290,15 +848,29 @@
 +// EventListener
 +
 +void
-+EventListener::firing_Impl(const ScriptEvent& evt, Any* pRet ) throw(RuntimeException)
++EventListener::firing_Impl(const ScriptEvent& evt, Any* /*pRet*/ ) throw(RuntimeException)
 +{
-+    OSL_TRACE("EventListener::firing_Impl !!!");
++	OSL_TRACE("EventListener::firing_Impl( FAKE VBA_EVENTS )");
 +    static const ::rtl::OUString vbaInterOp =
 +        ::rtl::OUString::createFromAscii("VBAInterop");
 +
 +    // let default handlers deal with non vba stuff
 +    if ( !evt.ScriptType.equals( vbaInterOp ) )
 +        return;
++    lang::EventObject aEvent;
++    evt.Arguments[ 0 ] >>= aEvent;
++	OSL_TRACE("Argument[0] is  %s", rtl::OUStringToOString( comphelper::anyToString( evt.Arguments[0] ), RTL_TEXTENCODING_UTF8 ).getStr() );
++	OSL_TRACE("Getting Control");
++    uno::Reference< awt::XControl > xControl( aEvent.Source, uno::UNO_QUERY_THROW );
++	OSL_TRACE("Getting properties");
++    uno::Reference< beans::XPropertySet > xProps( xControl->getModel(), uno::UNO_QUERY_THROW );
++
++    rtl::OUString sName = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("UserForm") );
++	OSL_TRACE("Getting Name");
++
++    uno::Reference< awt::XDialog > xDlg( aEvent.Source, uno::UNO_QUERY );
++    if ( !xDlg.is() )
++        xProps->getPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("Name") ) ) >>= sName;
 +    //dumpEvent( evt );
 +    EventInfoHash& infos = getEventTransInfo();
 +    EventInfoHash::const_iterator eventInfo_it = infos.find( evt.MethodName );
@@ -1314,24 +886,26 @@
 +    uno::Reference< script::provider::XScriptProvider > xScriptProvider;
 +    if ( xSPS.is() )
 +        xScriptProvider =  xSPS->getScriptProvider();
-+    if ( xScriptProvider.is() )
++    if ( xScriptProvider.is() && mpShell )
 +    {
 +        std::list< TranslateInfo > matchingMethods;
 +        std::list< TranslateInfo >::const_iterator txInfo =
 +            eventInfo_it->second.begin();
 +        std::list< TranslateInfo >::const_iterator txInfo_end = eventInfo_it->second.end();
-+        for ( ; txInfo != txInfo_end; ++txInfo )
++        rtl::OUString sMacroLoc = rtl::OUString::createFromAscii("Standard.").concat( evt.ScriptCode ).concat( rtl::OUString::createFromAscii(".") );
++       
++        StarBASIC* pBasic = mpShell->GetBasic();
++        SbModule* pModule = pBasic->FindModule( evt.ScriptCode );
++        for ( ; pModule && txInfo != txInfo_end; ++txInfo )
 +        {
 +            // see if we have a match for the handlerextension
 +            // where ScriptCode is methodname_handlerextension 
-+            rtl::OUString sTemp = evt.ScriptCode; 
-+            sal_Int32 lastIndexOf_ = sTemp.lastIndexOf( '_' );
-+            if ( lastIndexOf_ != -1 )
-+                sTemp = sTemp.copy( lastIndexOf_ ); 
-+            OSL_TRACE("*** trying to match %s with %s",
-+                rtl::OUStringToOString( sTemp, RTL_TEXTENCODING_UTF8 ).getStr(),
-+                rtl::OUStringToOString( (*txInfo).sVBAName, RTL_TEXTENCODING_UTF8 ).getStr() );
-+            if ( sTemp.equals( (*txInfo).sVBAName ) )
++            rtl::OUString sTemp = sName.concat( (*txInfo).sVBAName ); 
++            
++            OSL_TRACE("*** trying to invoke %s ",
++                rtl::OUStringToOString( sTemp, RTL_TEXTENCODING_UTF8 ).getStr() );
++            SbMethod* pMeth = static_cast< SbMethod* >( pModule->Find( sTemp, SbxCLASS_METHOD ) );
++            if ( pMeth )
 +            {
 +                // !! translate arguments & emulate events where necessary 
 +                Sequence< Any > aArguments;
@@ -1347,12 +921,11 @@
 +                    static rtl::OUString part2 = rtl::OUString::createFromAscii("?language=Basic&location=document"); 
 +
 +                    // create script url
-+                    rtl::OUString url = part1 + evt.ScriptCode + part2;
++                    rtl::OUString url = part1 + sMacroLoc + sTemp + part2;
 +                 
 +                    OSL_TRACE("script url = %s",
 +                        rtl::OUStringToOString( url, 
 +                            RTL_TEXTENCODING_UTF8 ).getStr() );
-+                    Any aRet; // temp
 +                    Sequence< sal_Int16 > aOutArgsIndex;
 +                    Sequence< Any > aOutArgs;
 +                    try
@@ -1380,8 +953,8 @@
 +    VBAToOOEventDescGen( const Reference< XComponentContext >& rxContext );
 +
 +    // XVBAToOOEventDescGen
-+    virtual Sequence< ScriptEventDescriptor > SAL_CALL getEventDescriptions( const Reference< XInterface >& control, const rtl::OUString& sLibModName, const Sequence< rtl::OUString >& sHandlerExts ) throw (RuntimeException);
-+    virtual Reference< XScriptEventsSupplier > SAL_CALL getEventSupplier( const Reference< XInterface >& xControl ) throw (::com::sun::star::uno::RuntimeException);
++    virtual Sequence< ScriptEventDescriptor > SAL_CALL getEventDescriptions( const Reference< XInterface >& control, const rtl::OUString& sCodeName ) throw (RuntimeException);
++    virtual Reference< XScriptEventsSupplier > SAL_CALL getEventSupplier( const Reference< XInterface >& xControl,  const rtl::OUString& sCodeName ) throw (::com::sun::star::uno::RuntimeException);
 +private:
 +    Reference< XComponentContext > m_xContext;
 +  
@@ -1390,18 +963,17 @@
 +VBAToOOEventDescGen::VBAToOOEventDescGen( const Reference< XComponentContext >& rxContext ):m_xContext( rxContext ) {}
 +
 +Sequence< ScriptEventDescriptor > SAL_CALL 
-+VBAToOOEventDescGen::getEventDescriptions( const Reference< XInterface >& xControl, const rtl::OUString& sLibModName, const Sequence< rtl::OUString >& sHandlerExts ) throw (RuntimeException)
++VBAToOOEventDescGen::getEventDescriptions( const Reference< XInterface >& xControl, const rtl::OUString& sCodeName ) throw (RuntimeException)
 +{
-+    return ScriptEventFactory::instance().createEvents( xControl, sLibModName, sHandlerExts ); 
++    return ScriptEventFactory::instance().createEvents( xControl, sCodeName ); 
 +}
 +
 +Reference< XScriptEventsSupplier > SAL_CALL 
-+VBAToOOEventDescGen::getEventSupplier( const Reference< XInterface >& xControl ) throw (::com::sun::star::uno::RuntimeException)
++VBAToOOEventDescGen::getEventSupplier( const Reference< XInterface >& xControl, const rtl::OUString& sCodeName  ) throw (::com::sun::star::uno::RuntimeException)
 +{
 +    Reference< XScriptEventsSupplier > xSupplier = 
 +        new ReadOnlyEventsSupplier( 
-+            ScriptEventFactory::instance().getEventListeners( xControl ),
-+            xControl ) ;
++            ScriptEventFactory::instance().getEventListeners( xControl ), sCodeName ) ;
 +    return xSupplier;
 +}
 +
@@ -1467,3 +1039,835 @@
 +        return Sequence< ::rtl::OUString >( &strName, 1 );
 +    }	
 +}
+--- /dev/null	2007-05-04 11:54:36.000000000 +0100
++++ scripting/source/vbaevents/service.cxx	2008-04-28 16:07:24.000000000 +0100
+@@ -0,0 +1,99 @@
++#include "cppuhelper/implementationentry.hxx"
++#include "com/sun/star/lang/XMultiServiceFactory.hpp"
++#include "com/sun/star/registry/XRegistryKey.hpp"
++
++// =============================================================================
++// component exports
++// =============================================================================
++using namespace ::com::sun::star;
++using namespace ::com::sun::star::uno;
++
++namespace evtlstner
++{
++    // =============================================================================
++    // component operations
++    // =============================================================================
++
++    uno::Reference< XInterface > SAL_CALL create(
++        Reference< XComponentContext > const & xContext )
++        SAL_THROW( () );
++
++    // -----------------------------------------------------------------------------
++
++    ::rtl::OUString SAL_CALL getImplementationName();
++
++    Sequence< ::rtl::OUString > SAL_CALL getSupportedServiceNames();
++
++    Reference<XInterface> SAL_CALL create(
++        Sequence<Any> const &, Reference<XComponentContext> const & );
++} // end evtlstner
++
++namespace ooevtdescgen
++{
++    // =============================================================================
++    // component operations
++    // =============================================================================
++
++    uno::Reference< XInterface > SAL_CALL create(
++        Reference< XComponentContext > const & xContext )
++        SAL_THROW( () );
++
++    // -----------------------------------------------------------------------------
++
++    ::rtl::OUString SAL_CALL getImplementationName();
++
++    Sequence< ::rtl::OUString > SAL_CALL getSupportedServiceNames();
++
++    Reference<XInterface> SAL_CALL create(
++        Sequence<Any> const &, Reference<XComponentContext> const & );
++} // end ooevtdescgen
++
++
++
++    // =============================================================================
++
++    const ::cppu::ImplementationEntry s_component_entries [] =
++    {
++        {
++            ::evtlstner::create, ::evtlstner::getImplementationName,
++            ::evtlstner::getSupportedServiceNames, 
++            ::cppu::createSingleComponentFactory,
++            0, 0
++        },
++        {
++            ::ooevtdescgen::create, ::ooevtdescgen::getImplementationName,
++            ::ooevtdescgen::getSupportedServiceNames, 
++            ::cppu::createSingleComponentFactory,
++            0, 0
++        },
++        { 0, 0, 0, 0, 0, 0 }
++    };
++
++extern "C"
++{
++    void SAL_CALL component_getImplementationEnvironment( 
++        const sal_Char ** ppEnvTypeName, uno_Environment ** ppEnv )
++    {
++        OSL_TRACE("In component_getImplementationEnv");
++        *ppEnvTypeName = CPPU_CURRENT_LANGUAGE_BINDING_NAME;
++    }
++
++    sal_Bool SAL_CALL component_writeInfo( 
++        lang::XMultiServiceFactory * pServiceManager, registry::XRegistryKey * pRegistryKey )
++    {
++        OSL_TRACE("In component_writeInfo");
++        if ( ::cppu::component_writeInfoHelper(
++            pServiceManager, pRegistryKey, s_component_entries ) )
++            return sal_True;
++        return sal_False;
++    }
++
++    void * SAL_CALL component_getFactory( 
++        const sal_Char * pImplName, lang::XMultiServiceFactory * pServiceManager,
++        registry::XRegistryKey * pRegistryKey )
++    {
++        OSL_TRACE("In component_getFactory");
++        return ::cppu::component_getFactoryHelper( 
++            pImplName, pServiceManager, pRegistryKey, s_component_entries );
++    }
++}
+--- /dev/null	2007-05-04 11:54:36.000000000 +0100
++++ scripting/source/vbaevents/vbaevents.map	2008-04-28 16:07:24.000000000 +0100
+@@ -0,0 +1,9 @@
++OOO_1.1 {
++	global:
++		component_getImplementationEnvironment;
++		component_getFactory;
++		component_writeInfo;
++
++	local:
++		*;
++};
+--- /dev/null	2007-05-04 11:54:36.000000000 +0100
++++ scripting/source/vbaevents/vbaevents.xml	2008-04-28 16:07:24.000000000 +0100
+@@ -0,0 +1,26 @@
++<?xml version="1.0" encoding="UTF-8"?>
++<!DOCTYPE module-description PUBLIC "-//StarOffice//DTD ComponentDescription 1.0//EN" "module-description.dtd">
++<module-description xmlns:xlink="http://www.w3.org/1999/xlink";>
++
++    <module-name>vbaevents</module-name>
++    
++    <component-description>
++        <author>Noel Power </author>
++        <name>org.openoffice.vba.EventListener</name>
++        <description>Event listener to handle ooo events and to translate them to calls to basic macros ala Button_Click etc.</description>
++        <loader-name>com.sun.star.loader.SharedLibrary</loader-name>
++        <language>c++</language>
++        <status value="drafts"/>
++        <supported-service>org.openoffice.vba.EventListener</supported-service>
++        <type>com.sun.star.uno.XComponentContext</type>        
++    </component-description>
++    
++    <project-build-dependency>cppuhelper</project-build-dependency>
++    <project-build-dependency>cppu</project-build-dependency>
++    <project-build-dependency>sal</project-build-dependency>
++
++    <runtime-module-dependency>cppuhelper3$(COM)</runtime-module-dependency>
++    <runtime-module-dependency>cppu3</runtime-module-dependency>
++    <runtime-module-dependency>sal3</runtime-module-dependency>
++    
++</module-description>
+diff -rup scripting/source/dlgprov/dlgevtatt.cxx scripting/source/dlgprov/dlgevtatt.cxx
+--- scripting/source/dlgprov/dlgevtatt.cxx	2008-04-29 13:37:12.000000000 +0100
++++ scripting/source/dlgprov/dlgevtatt.cxx	2008-04-28 22:20:38.000000000 +0100
+@@ -232,7 +232,7 @@ namespace dlgprov
+         return it->second; 
+     }
+ #ifdef FAKE_VBA_EVENT_SUPPORT
+-    Reference< XScriptEventsSupplier > DialogEventsAttacherImpl::getFakeVbaEventsSupplier( const Reference< XControl >& xControl )
++    Reference< XScriptEventsSupplier > DialogEventsAttacherImpl::getFakeVbaEventsSupplier( const Reference< XControl >& xControl, rtl::OUString& sControlName )
+             {
+         Reference< XScriptEventsSupplier > xEventsSupplier;
+                 Reference< XMultiComponentFactory > xSMgr( m_xContext->getServiceManager() );
+@@ -240,7 +240,7 @@ namespace dlgprov
+                 {
+             Reference< org::openoffice::vba::XVBAToOOEventDescGen > xVBAToOOEvtDesc( xSMgr->createInstanceWithContext( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "org.openoffice.vba.VBAToOOEventDesc" ) ), m_xContext ), UNO_QUERY );
+             if ( xVBAToOOEvtDesc.is() )
+-                xEventsSupplier.set( xVBAToOOEvtDesc->getEventSupplier( xControl ), UNO_QUERY );
++                xEventsSupplier.set( xVBAToOOEvtDesc->getEventSupplier( xControl, sControlName ), UNO_QUERY );
+ 
+             }
+         return xEventsSupplier;
+@@ -363,6 +363,20 @@ namespace dlgprov
+         // go over all objects
+         const Reference< XInterface >* pObjects = Objects.getConstArray();
+         sal_Int32 nObjCount = Objects.getLength();
++#ifdef FAKE_VBA_EVENT_SUPPORT
++        Reference< awt::XControl > xDlgControl( Objects[ nObjCount - 1 ], uno::UNO_QUERY ); // last object is the dialog	
++        rtl::OUString sDialogCodeName;
++        if ( xDlgControl.is() )
++        {
++            Reference< XPropertySet > xProps( xDlgControl->getModel(), UNO_QUERY );
++            try
++            {
++                xProps->getPropertyValue( rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Name") ) ) >>= sDialogCodeName;  
++            }
++            catch( Exception& ){}
++        }
++#endif
++	
+         for ( sal_Int32 i = 0; i < nObjCount; ++i )
+         {
+             // We know that we have to do with instances of XControl.
+@@ -377,7 +391,7 @@ namespace dlgprov
+             Reference< XScriptEventsSupplier > xEventsSupplier( xControlModel, UNO_QUERY );
+             attachEventsToControl( xControl, xEventsSupplier, Helper );
+ #ifdef FAKE_VBA_EVENT_SUPPORT
+-            xEventsSupplier.set( getFakeVbaEventsSupplier( xControl ) );
++            xEventsSupplier.set( getFakeVbaEventsSupplier( xControl, sDialogCodeName ) );
+             attachEventsToControl( xControl, xEventsSupplier, Helper );
+ #endif
+         }
+diff -rup scripting/source/dlgprov/dlgevtatt.hxx scripting/source/dlgprov/dlgevtatt.hxx
+--- scripting/source/dlgprov/dlgevtatt.hxx	2008-04-29 13:37:12.000000000 +0100
++++ scripting/source/dlgprov/dlgevtatt.hxx	2008-04-28 22:17:30.000000000 +0100
+@@ -68,6 +68,9 @@
+ #include <com/sun/star/script/XScriptEventsSupplier.hpp>
+ 
+ #include <hash_map>
++
++#define FAKE_VBA_EVENT_SUPPORT 1 
++
+ //.........................................................................
+ namespace dlgprov
+ {
+@@ -93,7 +96,7 @@ namespace dlgprov
+         ::com::sun::star::uno::Reference< ::com::sun::star::script::XEventAttacher > m_xEventAttacher;
+         ::com::sun::star::uno::Reference< ::com::sun::star::script::XScriptListener > getScriptListenerForKey( const rtl::OUString& sScriptName ) throw ( ::com::sun::star::uno::RuntimeException );
+ #ifdef FAKE_VBA_EVENT_SUPPORT
+-        ::com::sun::star::uno::Reference< ::com::sun::star::script::XScriptEventsSupplier > getFakeVbaEventsSupplier( const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XControl>& xControl );
++        ::com::sun::star::uno::Reference< ::com::sun::star::script::XScriptEventsSupplier > getFakeVbaEventsSupplier( const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XControl>& xControl, rtl::OUString& sCodeName );
+ #endif
+         void  SAL_CALL attachEventsToControl( const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XControl>& xControl, const ::com::sun::star::uno::Reference< ::com::sun::star::script::XScriptEventsSupplier >& events, const ::com::sun::star::uno::Any& Helper  );
+     public:
+diff -rup sc/inc/document.hxx sc/inc/document.hxx
+--- sc/inc/document.hxx	2008-04-29 13:37:35.000000000 +0100
++++ sc/inc/document.hxx	2008-04-28 18:04:55.000000000 +0100
+@@ -311,6 +311,7 @@ private:
+ 
+ 	com::sun::star::uno::Sequence<sal_Int8>	aProtectPass;
+ 	String              aDocName;                       // opt: Dokumentname
++	String              aDocCodeName;                       // opt: Dokumentname
+ 	ScRangePairListRef	xColNameRanges;
+ 	ScRangePairListRef	xRowNameRanges;
+ 
+@@ -463,6 +464,8 @@ public:
+ 
+ 	const String& 	GetName() const { return aDocName; }
+ 	void			SetName( const String& r ) { aDocName = r; }
++	const String& 	GetCodeName() const { return aDocCodeName; }
++	void			SetCodeName( const String& r ) { aDocCodeName = r; }
+ 
+ 	void			GetDocStat( ScDocStat& rDocStat );
+ 
+@@ -550,6 +553,8 @@ SC_DLLPUBLIC	ScDBCollection*	GetDBCollec
+ 
+ 	BOOL			HasTable( SCTAB nTab ) const;
+ 	SC_DLLPUBLIC BOOL			GetName( SCTAB nTab, String& rName ) const;
++	SC_DLLPUBLIC BOOL			GetCodeName( SCTAB nTab, String& rName ) const;
++	SC_DLLPUBLIC BOOL			SetCodeName( SCTAB nTab, String& rName );
+ 	BOOL			GetTable( const String& rName, SCTAB& rTab ) const;
+ 	inline SCTAB	GetTableCount() const { return nMaxTableNumber; }
+ 	SvNumberFormatterIndexTable* GetFormatExchangeList() const { return pFormatExchangeList; }
+diff -rup sc/inc/docuno.hxx sc/inc/docuno.hxx
+--- sc/inc/docuno.hxx	2008-03-05 17:29:55.000000000 +0000
++++ sc/inc/docuno.hxx	2008-04-28 17:52:17.000000000 +0100
+@@ -144,6 +144,8 @@ class ScTableSheetObj;
+ class SvxFmDrawPage;
+ class SvxDrawPage;
+ 
++#include <com/sun/star/document/XCodeNameQuery.hpp>
++
+ class SC_DLLPUBLIC ScModelObj : public SfxBaseModel,
+ 					public com::sun::star::sheet::XSpreadsheetDocument,
+ 					public com::sun::star::document::XActionLockable,
+@@ -157,6 +159,7 @@ class SC_DLLPUBLIC ScModelObj : public S
+ 					public com::sun::star::view::XRenderable,
+ 					public com::sun::star::document::XLinkTargetSupplier,
+ 					public com::sun::star::beans::XPropertySet,
++					public com::sun::star::document::XCodeNameQuery,
+ 					public SvxFmMSFactory,	// derived from XMultiServiceFactory
+                     public com::sun::star::lang::XServiceInfo
+ {
+@@ -369,6 +372,8 @@ public:
+ 								throw(::com::sun::star::uno::RuntimeException);
+ 	virtual ::com::sun::star::uno::Sequence< sal_Int8 > SAL_CALL getImplementationId()
+ 								throw(::com::sun::star::uno::RuntimeException);
++ 	virtual rtl::OUString SAL_CALL getCodeNameForObject( const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface >& aObj )
++								throw(::com::sun::star::uno::RuntimeException);
+ };
+ 
+ 
+diff -rup sc/inc/scextopt.hxx sc/inc/scextopt.hxx
+--- sc/inc/scextopt.hxx	2008-04-29 13:37:35.000000000 +0100
++++ sc/inc/scextopt.hxx	2008-04-28 15:44:25.000000000 +0100
+@@ -142,6 +142,8 @@ public:
+     const String&       GetCodeName( size_t nIdx ) const;
+     /** Appends a codename for a sheet. */
+     void                AppendCodeName( const String& rCodeName );
++    void                SetCodeName( const String& rCodeName, size_t nIdx );
++    void                DeleteCodeName( size_t nIdx );
+ 
+ private:
+     ::std::auto_ptr< ScExtDocOptionsImpl > mxImpl;
+diff -rup sc/inc/table.hxx sc/inc/table.hxx
+--- sc/inc/table.hxx	2008-04-29 13:37:25.000000000 +0100
++++ sc/inc/table.hxx	2008-04-28 18:04:55.000000000 +0100
+@@ -103,6 +103,7 @@ private:
+ 	ScColumn		aCol[MAXCOLCOUNT];
+ 
+ 	String			aName;
++	String			aCodeName;
+ 	String			aComment;
+ 	BOOL			bScenario;
+ 	BOOL			bLayoutRTL;
+@@ -233,6 +234,9 @@ public:
+ 	void		GetName( String& rName ) const;
+ 	void		SetName( const String& rNewName );
+ 
++	void		GetCodeName( String& rName ) const {  rName = aCodeName; }
++	void		SetCodeName( const String& rNewName ) { aCodeName = rNewName; }
++
+     const String&   GetUpperName() const;
+ 
+ 	const String&	GetPageStyle() const					{ return aPageStyle; }
+diff -rup sc/source/core/data/document.cxx sc/source/core/data/document.cxx
+--- sc/source/core/data/document.cxx	2008-04-29 13:37:25.000000000 +0100
++++ sc/source/core/data/document.cxx	2008-04-28 18:04:55.000000000 +0100
+@@ -154,6 +156,32 @@ BOOL ScDocument::GetName( SCTAB nTab, St
+ 	return FALSE;
+ }
+ 
++BOOL ScDocument::SetCodeName( SCTAB nTab, String& rName ) 
++{
++	if (VALIDTAB(nTab))
++	{
++		if (pTab[nTab])
++		{
++			pTab[nTab]->SetCodeName( rName );
++			return TRUE;
++		}
++	}
++	OSL_TRACE( "**** can't set code name %s", rtl::OUStringToOString( rName, RTL_TEXTENCODING_UTF8 ).getStr() );
++	return FALSE;
++}
++
++BOOL ScDocument::GetCodeName( SCTAB nTab, String& rName ) const
++{
++	if (VALIDTAB(nTab))
++		if (pTab[nTab])
++		{
++			pTab[nTab]->GetCodeName( rName );
++			return TRUE;
++		}
++	rName.Erase();
++	return FALSE;
++}
++
+ 
+ BOOL ScDocument::GetTable( const String& rName, SCTAB& rTab ) const
+ {
+@@ -292,6 +320,7 @@ BOOL ScDocument::InsertTab( SCTAB nPos, 
+ 		if (nPos == SC_TAB_APPEND || nPos == nTabCount)
+ 		{
+ 			pTab[nTabCount] = new ScTable(this, nTabCount, rName);
++            pTab[nTabCount]->SetCodeName( rName );
+ 			++nMaxTableNumber;
+ 			if ( bExternalDocument )
+ 				pTab[nTabCount]->SetVisible( FALSE );
+@@ -322,10 +351,16 @@ BOOL ScDocument::InsertTab( SCTAB nPos, 
+ 				for (i = 0; i <= MAXTAB; i++)
+ 					if (pTab[i])
+ 						pTab[i]->UpdateInsertTab(nPos);
++
+ 				for (i = nTabCount; i > nPos; i--)
++				{
+ 					pTab[i] = pTab[i - 1];
++				}
++
+ 				pTab[nPos] = new ScTable(this, nPos, rName);
++                pTab[nPos]->SetCodeName( rName );
+ 				++nMaxTableNumber;
++
+ 				for (i = 0; i <= MAXTAB; i++)
+ 					if (pTab[i])
+ 						pTab[i]->UpdateCompile();
+@@ -411,7 +447,10 @@ BOOL ScDocument::DeleteTab( SCTAB nTab, 
+ 									pRefUndoDoc ? pRefUndoDoc->pTab[i] : 0);
+ 				delete pTab[nTab];
+ 				for (i=nTab + 1; i < nTabCount; i++)
++				{
+ 					pTab[i - 1] = pTab[i];
++				}
++
+ 				pTab[nTabCount - 1] = NULL;
+ 				--nMaxTableNumber;
+ 				for (i = 0; i <= MAXTAB; i++)
+diff -rup sc/source/core/data/table1.cxx sc/source/core/data/table1.cxx
+--- sc/source/core/data/table1.cxx	2008-04-29 13:37:36.000000000 +0100
++++ sc/source/core/data/table1.cxx	2008-04-28 18:04:55.000000000 +0100
+@@ -129,6 +129,7 @@ extern BOOL bIsOlk, bOderSo;
+ ScTable::ScTable( ScDocument* pDoc, SCTAB nNewTab, const String& rNewName,
+ 					BOOL bColInfo, BOOL bRowInfo ) :
+ 	aName( rNewName ),
++	aCodeName( rNewName ),
+ 	bScenario( FALSE ),
+ 	bLayoutRTL( FALSE ),
+     bLoadingRTL( FALSE ),
+diff -rup sc/source/filter/excel/excimp8.cxx sc/source/filter/excel/excimp8.cxx
+--- sc/source/filter/excel/excimp8.cxx	2008-04-29 13:37:21.000000000 +0100
++++ sc/source/filter/excel/excimp8.cxx	2008-04-28 18:04:55.000000000 +0100
+@@ -152,7 +152,7 @@ using namespace com::sun::star;
+ 
+ 
+ ImportExcel8::ImportExcel8( XclImpRootData& rImpData, SvStream& rStrm ) :
+-    ImportExcel( rImpData, rStrm )
++    ImportExcel( rImpData, rStrm ), mnTab(0)
+ {
+ 	delete pFormConv;
+ 
+@@ -288,9 +288,15 @@ void ImportExcel8::Codename( BOOL bWorkb
+         if( aName.Len() )
+         {
+             if( bWorkbookGlobals )
++            {
+                 GetExtDocOptions().GetDocSettings().maGlobCodeName = aName;
++                GetDoc().SetCodeName( aName );
++            }
+             else
++            {
+                 GetExtDocOptions().AppendCodeName( aName );
++                GetDoc().SetCodeName( mnTab++, aName );
++            }
+         }
+ 	}
+ }
+diff -rup sc/source/filter/inc/excimp8.hxx sc/source/filter/inc/excimp8.hxx
+--- sc/source/filter/inc/excimp8.hxx	2008-04-29 13:37:21.000000000 +0100
++++ sc/source/filter/inc/excimp8.hxx	2008-04-28 18:04:55.000000000 +0100
+@@ -69,6 +69,7 @@ class XclImpStream;
+ 
+ class ImportExcel8 : public ImportExcel
+ {
++        SCTAB mnTab;
+ 	protected:
+         ExcScenarioList         aScenList;
+ 
+diff -rup sc/source/ui/unoobj/docuno.cxx sc/source/ui/unoobj/docuno.cxx
+--- sc/source/ui/unoobj/docuno.cxx	2008-03-05 17:33:11.000000000 +0000
++++ sc/source/ui/unoobj/docuno.cxx	2008-04-29 00:10:59.000000000 +0100
+@@ -108,6 +108,7 @@ using namespace com::sun::star;
+ //	alles ohne Which-ID, Map nur fuer PropertySetInfo
+ 
+ //!	umbenennen, sind nicht mehr nur Options
++#include <com/sun/star/script/ScriptEventDescriptor.hpp>
+ const SfxItemPropertyMap* lcl_GetDocOptPropertyMap()
+ {
+ 	static SfxItemPropertyMap aDocOptPropertyMap_Impl[] =
+@@ -336,6 +337,7 @@ uno::Any SAL_CALL ScModelObj::queryInter
+ 	SC_QUERYINTERFACE( view::XRenderable )
+ 	SC_QUERYINTERFACE( document::XLinkTargetSupplier )
+ 	SC_QUERYINTERFACE( beans::XPropertySet )
++	SC_QUERYINTERFACE( document::XCodeNameQuery )
+ 	SC_QUERYINTERFACE( lang::XMultiServiceFactory )
+ 	SC_QUERYINTERFACE( lang::XServiceInfo )
+ 
+@@ -1694,7 +1696,49 @@ uno::Sequence<rtl::OUString> SAL_CALL Sc
+ 
+ 	return concatServiceNames( aMyServices, aDrawServices );
+ }
+-
++// XCodeNameQuery
++rtl::OUString SAL_CALL 
++ScModelObj::getCodeNameForObject( const uno::Reference< uno::XInterface >& xIf ) throw( uno::RuntimeException )
++{
++    rtl::OUString sCodeName;
++    if ( pDocShell )
++    {
++        OSL_TRACE( "*** In ScModelObj::getCodeNameForObject");
++        // need to find the page ( and index )  for this control
++        uno::Reference< drawing::XDrawPagesSupplier > xSupplier( pDocShell->GetModel(), uno::UNO_QUERY_THROW );
++        uno::Reference< container::XIndexAccess > xIndex( xSupplier->getDrawPages(), uno::UNO_QUERY_THROW );
++        sal_Int32 nLen = xIndex->getCount();
++        bool bMatched = false;
++        uno::Sequence< script::ScriptEventDescriptor > aFakeEvents;
++        for ( sal_Int32 index = 0; index < nLen; ++index )
++        {
++            try
++            {
++                uno::Reference< form::XFormsSupplier >  xFormSupplier( xIndex->getByIndex( index ), uno::UNO_QUERY_THROW );
++                uno::Reference< container::XIndexAccess > xFormIndex( xFormSupplier->getForms(), uno::UNO_QUERY_THROW );
++                // get the www-standard container
++                uno::Reference< container::XIndexAccess > xFormControls( xFormIndex->getByIndex(0), uno::UNO_QUERY_THROW );
++                sal_Int32 nCntrls = xFormControls->getCount();
++                for( sal_Int32 cIndex = 0; cIndex < nCntrls; ++cIndex )
++                {
++                    uno::Reference< uno::XInterface > xControl( xFormControls->getByIndex( cIndex ), uno::UNO_QUERY_THROW );	
++                    bMatched = ( xControl == xIf );
++                    if ( bMatched )
++                    {
++                        String sName;
++                        pDocShell->GetDocument()->GetCodeName( index, sName );
++                        sCodeName = sName;
++                    }
++                }
++            }
++            catch( uno::Exception& ) {}
++            if ( bMatched )
++                break;
++        }
++    }
++    // Probably should throw here ( if !bMatched )
++     return sCodeName;
++}
+ // XServiceInfo
+ 
+ rtl::OUString SAL_CALL ScModelObj::getImplementationName() throw(uno::RuntimeException)
+diff -rup oovbaapi/org/openoffice/vba/XVBAToOOEventDescGen.idl oovbaapi/org/openoffice/vba/XVBAToOOEventDescGen.idl
+--- oovbaapi/org/openoffice/vba/XVBAToOOEventDescGen.idl	2007-04-27 08:32:41.000000000 +0100
++++ oovbaapi/org/openoffice/vba/XVBAToOOEventDescGen.idl	2008-04-28 16:14:51.000000000 +0100
+@@ -46,8 +46,8 @@
+ module org {  module openoffice {  module vba { 
+ interface XVBAToOOEventDescGen : com::sun::star::uno::XInterface
+ {
+-	sequence< com::sun::star::script::ScriptEventDescriptor >  getEventDescriptions( [in] com::sun::star::uno::XInterface xControl, [in] string sLibModName, [in] sequence< string > handlerExts );
+-	com::sun::star::script::XScriptEventsSupplier getEventSupplier( [in] com::sun::star::uno::XInterface xControl );
++	sequence< com::sun::star::script::ScriptEventDescriptor >  getEventDescriptions( [in] com::sun::star::uno::XInterface xControl, [in] string sCodeName );
++	com::sun::star::script::XScriptEventsSupplier getEventSupplier( [in] com::sun::star::uno::XInterface xControl, [in] string sCodeName );
+ };
+ 
+ }; }; };
+--- /data4/OOOBuildDEVM4-source-only/ooo-build/build/dev300-m4/offapi/com/sun/star/document/makefile.mk	2008-03-07 12:31:01.000000000 +0000
++++ offapi/com/sun/star/document/makefile.mk	2008-04-28 17:25:31.000000000 +0100
+@@ -111,7 +111,9 @@ IDLFILES=\
+     LinkUpdateModes.idl\
+     XDocumentRevisionListPersistence.idl\
+     DocumentRevisionListPersistence.idl \
+-    XDocumentLanguages.idl
++    XDocumentLanguages.idl \
++    XCodeNameQuery.idl \
++
+ 
+ # ------------------------------------------------------------------
+ 
+--- /dev/null	2007-05-04 11:54:36.000000000 +0100
++++ offapi/com/sun/star/document/XCodeNameQuery.idl	2008-04-28 17:39:33.000000000 +0100
+@@ -0,0 +1,56 @@
++/*************************************************************************
++ *
++ *  OpenOffice.org - a multi-platform office productivity suite
++ *
++ *  $RCSfile: XDocumentPropertiesSupplier.idl,v $
++ *
++ *  $Revision$
++ *
++ *  last change: $Author$ $Date$
++ *
++ *  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_document_XCodeNameQuery_idl__
++#define __com_sun_star_document_XCodeNameQuery_idl__
++
++#ifndef __com_sun_star_uno_XInterface_idl__
++#include <com/sun/star/uno/XInterface.idl>
++#endif
++
++//=============================================================================
++
++module com {   module sun {   module star {   module document {
++//=============================================================================
++interface XCodeNameQuery
++{
++	//-------------------------------------------------------------------------
++    string getCodeNameForObject( [in] com::sun::star::uno::XInterface aObj );
++};
++
++//=============================================================================
++
++}; }; }; };
++
++#endif
+diff -rup /data4/OOOBuildDEVM4-source-only/ooo-build/build/dev300-m4/forms/source/misc/InterfaceContainer.cxx forms/source/misc/InterfaceContainer.cxx
+--- /data4/OOOBuildDEVM4-source-only/ooo-build/build/dev300-m4/forms/source/misc/InterfaceContainer.cxx	2008-01-29 17:06:59.000000000 +0000
++++ forms/source/misc/InterfaceContainer.cxx	2008-04-29 00:24:31.000000000 +0100
+@@ -106,12 +106,19 @@
+ 
+ //.........................................................................
++#include <com/sun/star/frame/XModel.hpp>
++#include <com/sun/star/document/XCodeNameQuery.hpp>
++#include <org/openoffice/vba/XVBAToOOEventDescGen.hpp>
++#include <comphelper/processfactory.hxx>
++
+ namespace frm
+ {
+ //.........................................................................
+ 
++using namespace ::com::sun::star::frame;
+ using namespace ::com::sun::star::lang;
+ using namespace ::com::sun::star::uno;
+ using namespace ::com::sun::star::beans;
++using namespace ::com::sun::star::document;
+ using namespace ::com::sun::star::container;
+ using namespace ::com::sun::star::script;
+ using namespace ::com::sun::star::io;
+@@ -127,6 +134,88 @@ namespace
+ 	}
+ }
+ 
++bool
++lcl_hasVbaEvents( const Sequence< ScriptEventDescriptor >& sEvents  )
++{
++	const ScriptEventDescriptor* pDesc = sEvents.getConstArray();
++	const ScriptEventDescriptor* pEnd = ( pDesc + sEvents.getLength() );
++	for ( ; pDesc != pEnd; ++pDesc )
++	{
++		if ( pDesc->ScriptType.equals( rtl::OUString::createFromAscii( "VBAInterop" ) ) )
++			return true;
++	}
++	return false;
++}
++
++Sequence< ScriptEventDescriptor >
++lcl_stripVbaEvents( const Sequence< ScriptEventDescriptor >& sEvents )
++{
++	Sequence< ScriptEventDescriptor > sStripped( sEvents.getLength() );
++	
++	const ScriptEventDescriptor* pDesc = sEvents.getConstArray();
++	const ScriptEventDescriptor* pEnd = ( pDesc + sEvents.getLength() );
++	sal_Int32 nCopied = 0;
++	for ( ; pDesc != pEnd; ++pDesc )
++	{
++		if ( !pDesc->ScriptType.equals( rtl::OUString::createFromAscii( "VBAInterop" ) ) )
++		{
++			sStripped[ nCopied++ ] = *pDesc;
++		}
++	}
++	if ( nCopied )
++		sStripped.realloc( nCopied );
++	return sStripped;
++}
++
++void
++OInterfaceContainer::fakeVbaEventsHack(  sal_Int32 _nIndex )
++{
++	// we are dealing with form controls
++	try
++	{
++		Reference< XFormComponent > xForm( static_cast< XContainer* >(this), UNO_QUERY_THROW );
++		// grand-parent should be the model, no parent ? if not
++		// we'll ignore,  we'll get called back here  anyway )
++		Reference< XChild > xChild(  xForm->getParent(), UNO_QUERY_THROW );
++		Reference< XModel > xDocOwner( xChild->getParent(), UNO_QUERY );
++		Reference< XCodeNameQuery > xNameQuery( xDocOwner, UNO_QUERY );
++		OSL_TRACE(" Is DOC ????? %s", xDocOwner.is() ? "true" : "false" );
++		if ( xDocOwner.is() && xNameQuery.is() )
++		{
++			bool hasVBABindings = lcl_hasVbaEvents( m_xEventAttacher->getScriptEvents( _nIndex ) );  
++			if ( hasVBABindings )
++			{
++				OSL_TRACE("Has VBA bindings already, returning ");
++				return;
++			}
++			Reference< XMultiServiceFactory > xFac(  comphelper::getProcessServiceFactory(), UNO_QUERY );
++			if ( xFac.is() )
++			{
++				try
++				{
++					Reference< org::openoffice::vba::XVBAToOOEventDescGen > xDescSupplier( xFac->createInstance( rtl::OUString::createFromAscii( "org.openoffice.vba.VBAToOOEventDesc" ) ), UNO_QUERY_THROW );
++					Reference< XInterface > xIf( getByIndex( _nIndex ) , UNO_QUERY_THROW );
++					rtl::OUString sCodeName;	
++					sCodeName = xNameQuery->getCodeNameForObject( xIf );
++					Reference< XPropertySet > xProps( xIf, UNO_QUERY );
++					rtl::OUString sServiceName;
++					xProps->getPropertyValue( rtl::OUString::createFromAscii("DefaultControl" ) ) >>= sServiceName;
++
++					Sequence< ScriptEventDescriptor > vbaEvents = xDescSupplier->getEventDescriptions( xFac->createInstance( sServiceName ), sCodeName );
++					// register the vba script events
++					if ( m_xEventAttacher.is() )
++						m_xEventAttacher->registerScriptEvents( _nIndex, vbaEvents );
++				}
++				catch( Exception& e ){ OSL_TRACE("lcl_fakevbaevents - Caught Exception trying to create control eventstuff "); }
++			}
++
++		}
++	}
++	catch( Exception& e )
++	{
++	}
++
++}
+ //==================================================================
+ //= ElementDescription
+ //==================================================================
+@@ -726,6 +815,7 @@ void OInterfaceContainer::approveNewElem
+ void OInterfaceContainer::implInsert(sal_Int32 _nIndex, const Reference< XPropertySet >& _rxElement,
+ 	sal_Bool _bEvents, ElementDescription* _pApprovalResult, sal_Bool _bFire ) throw( IllegalArgumentException )
+ {
++        OSL_TRACE("OInterfaceContainer::implInsert( %d)", _nIndex );
+ 	RTL_LOGFILE_CONTEXT( aLogger, "forms::OInterfaceContainer::implInsert" );
+ 
+ 	::osl::ClearableMutexGuard aGuard( m_rMutex );
+@@ -775,6 +865,23 @@ void OInterfaceContainer::implInsert(sal
+ 	{
+ 		m_xEventAttacher->insertEntry(_nIndex);
+ 		m_xEventAttacher->attach( _nIndex, pElementMetaData->xInterface, makeAny( _rxElement ) );
++		// insert fake events?
++		Reference< XEventAttacherManager > xMgr ( pElementMetaData->xInterface, UNO_QUERY );
++		if ( xMgr.is() )
++		{ 
++			OInterfaceContainer* pIfcMgr = dynamic_cast< OInterfaceContainer* >( xMgr.get() );
++			sal_Int32 nLen = getCount();
++			for ( sal_Int32 i = 0; (i < nLen) && pIfcMgr ; ++i )
++			{	
++				// add fake events to the control at index i
++				pIfcMgr->fakeVbaEventsHack( i );
++			}	
++		}
++		else
++		{
++			// add fake events to the control at index i
++			fakeVbaEventsHack(  _nIndex );	
++		}
+ 	}
+ 
+ 	// notify derived classes
+@@ -1054,20 +1161,29 @@ void SAL_CALL OInterfaceContainer::remov
+ //------------------------------------------------------------------------
+ void SAL_CALL OInterfaceContainer::registerScriptEvent( sal_Int32 nIndex, const ScriptEventDescriptor& aScriptEvent ) throw(IllegalArgumentException, RuntimeException)
+ {
++    OSL_TRACE("*** registerScriptEvent %d", nIndex);
+     if ( m_xEventAttacher.is() )
++    {
+ 	    m_xEventAttacher->registerScriptEvent( nIndex, aScriptEvent );
++            fakeVbaEventsHack( nIndex ); // add fake vba events
++    }
+ }
+ 
+ //------------------------------------------------------------------------
+ void SAL_CALL OInterfaceContainer::registerScriptEvents( sal_Int32 nIndex, const Sequence< ScriptEventDescriptor >& aScriptEvents ) throw(IllegalArgumentException, RuntimeException)
+ {
++    OSL_TRACE("*** registerScriptEvent(s) %d", nIndex);
+     if ( m_xEventAttacher.is() )
++    {
+     	m_xEventAttacher->registerScriptEvents( nIndex, aScriptEvents );
++        fakeVbaEventsHack( nIndex ); // add fake vba events
++    }
+ }
+ 
+ //------------------------------------------------------------------------
+ void SAL_CALL OInterfaceContainer::revokeScriptEvent( sal_Int32 nIndex, const ::rtl::OUString& aListenerType, const ::rtl::OUString& aEventMethod, const ::rtl::OUString& aRemoveListenerParam ) throw(IllegalArgumentException, RuntimeException)
+ {
++    OSL_TRACE("*** revokeScriptEvent %d listenertype %s, eventMethod %s", nIndex, rtl::OUStringToOString( aListenerType, RTL_TEXTENCODING_UTF8 ).getStr(), rtl::OUStringToOString( aEventMethod, RTL_TEXTENCODING_UTF8 ).getStr());
+     if ( m_xEventAttacher.is() )
+     	m_xEventAttacher->revokeScriptEvent( nIndex, aListenerType, aEventMethod, aRemoveListenerParam );
+ }
+@@ -1096,9 +1212,16 @@ void SAL_CALL OInterfaceContainer::remov
+ //------------------------------------------------------------------------
+ Sequence< ScriptEventDescriptor > SAL_CALL OInterfaceContainer::getScriptEvents( sal_Int32 nIndex ) throw(IllegalArgumentException, RuntimeException)
+ {
++    OSL_TRACE("getScriptEvents");
+     Sequence< ScriptEventDescriptor > aReturn;
+     if ( m_xEventAttacher.is() )
++    {
+ 	    aReturn = m_xEventAttacher->getScriptEvents( nIndex );
++            if ( lcl_hasVbaEvents( aReturn ) )
++            {
++                aReturn = lcl_stripVbaEvents( aReturn );
++            }
++    }
+     return aReturn;
+ }
+ 
+--- /data4/OOOBuildDEVM4-source-only/ooo-build/build/dev300-m4/forms/source/inc/InterfaceContainer.hxx	2007-01-29 15:46:36.000000000 +0000
++++ forms/source/inc/InterfaceContainer.hxx	2008-04-28 18:13:48.000000000 +0100
+@@ -319,6 +319,9 @@ protected:
+ 	void implCheckIndex( const sal_Int32 _nIndex ) SAL_THROW( ( ::com::sun::star::lang::IndexOutOfBoundsException ) );
+ 
+ private:
++	// hack for Vba Events
++	void fakeVbaEventsHack( sal_Int32 _nIndex );
++
+ 	// the runtime event format has changed from version SO5.2 to OOo
+ 	enum EventFormat
+ 	{
+diff -rup /data4/OOOBuildDEVM4-source-only/ooo-build/build/dev300-m4/forms/source/misc/makefile.mk forms/source/misc/makefile.mk
+--- /data4/OOOBuildDEVM4-source-only/ooo-build/build/dev300-m4/forms/source/misc/makefile.mk	2005-09-09 00:01:56.000000000 +0100
++++ forms/source/misc/makefile.mk	2008-04-28 18:13:48.000000000 +0100
+@@ -48,6 +48,7 @@ ENABLE_EXCEPTIONS=TRUE
+ # --- Types -------------------------------------
+ 
+ INCPRE+=$(SOLARINCDIR)$/offuh
++INCPRE*=$(INCCOM)$/$(TARGET)
+ 
+ # --- Files -------------------------------------
+ 
+@@ -65,3 +66,12 @@ SLOFILES=	$(SLO)$/limitedformats.obj \
+ 
+ .INCLUDE : target.mk
+ 
++ALLTAR : \
++        $(MISC)$/$(TARGET).don \
++
++$(SLOFILES) : $(MISC)$/$(TARGET).don
++
++$(MISC)$/$(TARGET).don : $(SOLARBINDIR)$/oovbaapi.rdb
++        +$(CPPUMAKER) -O$(INCCOM)$/$(TARGET) -BUCR $(SOLARBINDIR)$/oovbaapi.rdb -X$(SOLARBINDIR)$/types.rdb && echo > $@
++        echo $@
++
+--- /data4/OOOBuildDEVM4-source-only/ooo-build/build/dev300-m4/sc/source/ui/vba/vbaworksheet.cxx	2008-04-29 17:54:53.000000000 +0100
++++ sc/source/ui/vba/vbaworksheet.cxx	2008-04-29 17:52:06.000000000 +0100
+@@ -771,7 +771,7 @@ ScVbaWorksheet::getServiceNames()
+ rtl::OUString SAL_CALL
+ ScVbaWorksheet::getCodeName() throw (css::uno::RuntimeException)
+ {
+-#ifdef VBA_OOBUILD_HACK 
++#if 0
+     uno::Reference <sheet::XSpreadsheetDocument> xSpreadDoc( getModel(), uno::UNO_QUERY_THROW );
+     SCTAB nTab = 0;
+     rtl::OUString aSheetName = getName();
+@@ -792,7 +792,7 @@ ScVbaWorksheet::getCodeName() throw (css
+ 	throw uno::RuntimeException( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("Not implemented") ), uno::Reference< uno::XInterface >() );
+ #endif
+ }
+-#ifdef VBA_OOBUILD_HACK 
++#if 0
+ void SAL_CALL
+ ScVbaWorksheet::setCodeName( const rtl::OUString& sCodeName ) throw (css::uno::RuntimeException)
+ {



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