ooo-build r12696 - in trunk: . patches/dev300 patches/vba
- From: noelpwer svn gnome org
- To: svn-commits-list gnome org
- Subject: ooo-build r12696 - in trunk: . patches/dev300 patches/vba
- Date: Thu, 29 May 2008 08:53:29 +0000 (UTC)
Author: noelpwer
Date: Thu May 29 08:53:29 2008
New Revision: 12696
URL: http://svn.gnome.org/viewvc/ooo-build?rev=12696&view=rev
Log:
2008-05-29 Noel Power <noel power novell com>
* patches/dev300/apply: initial ( applying version of ObjectModule )
* patches/vba/ObjectModule.diff:
* patches/vba/vba-allow-ranges-for-cell-functions.diff: context changes
Modified:
trunk/ChangeLog
trunk/patches/dev300/apply
trunk/patches/vba/ObjectModule.diff
trunk/patches/vba/vba-allow-ranges-for-cell-functions.diff
Modified: trunk/patches/dev300/apply
==============================================================================
--- trunk/patches/dev300/apply (original)
+++ trunk/patches/dev300/apply Thu May 29 08:53:29 2008
@@ -1557,7 +1557,7 @@
vba-negnumber-inparam-withoutbrackets.diff, n#294302
# hack for when resolving a symbol in the module ThisWorkbook
-vba-symbol-searchhack-for-thisworkbook.diff
+#vba-symbol-searchhack-for-thisworkbook.diff
vba-allow-ranges-for-cell-functions.diff
# in the basic IDE if the curson in within a macro
@@ -1617,10 +1617,10 @@
#make properties available for non class modules
#also allow paramaters to be supported for Get properties
vba-support-properties-inmodules.diff
+# object module support... getting there
+ObjectModule.diff
[ VBAUntested ]
SectionOwner => noelpwer
-# getting there
-ObjectModule.diff
# total hack at the moment, getting smaller
UserFormObjectModuleEventsSuperBigPatch.diff
# start LCL hacks
Modified: trunk/patches/vba/ObjectModule.diff
==============================================================================
--- trunk/patches/vba/ObjectModule.diff (original)
+++ trunk/patches/vba/ObjectModule.diff Thu May 29 08:53:29 2008
@@ -1,409 +1,998 @@
---- /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__
+diff --git basctl/source/basicide/basides1.cxx basctl/source/basicide/basides1.cxx
+index aed5958..3d79067 100644
+--- basctl/source/basicide/basides1.cxx
++++ basctl/source/basicide/basides1.cxx
+@@ -1201,10 +1201,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 --git basctl/source/basicide/basides2.cxx basctl/source/basicide/basides2.cxx
+index 76dcea0..90cec19 100644
+--- basctl/source/basicide/basides2.cxx
++++ basctl/source/basicide/basides2.cxx
+@@ -251,9 +251,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
+@@ -268,7 +271,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 --git basctl/source/basicide/basidesh.cxx basctl/source/basicide/basidesh.cxx
+index 666c4aa..2e854f8 100644
+--- basctl/source/basicide/basidesh.cxx
++++ basctl/source/basicide/basidesh.cxx
+@@ -80,6 +80,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>
+
+@@ -87,6 +90,71 @@ using namespace ::com::sun::star::uno;
+ using namespace ::com::sun::star;
+ using ::rtl::OUString;
+
++static const rtl::OUString sStandardLibName( rtl::OUString::createFromAscii("Standard") );
+
-+#ifndef __com_sun_star_uno_XInterface_idl__
-+#include <com/sun/star/uno/XInterface.idl>
-+#endif
++typedef ::cppu::WeakImplHelper1< container::XContainerListener > ContainerListenerBASE;
+
-+//=============================================================================
-+module com { module sun { module star { module script {
-+published constants ModuleType
++class ContainerListenerImpl : public ContainerListenerBASE
+{
-+ const long Unknown = 0;
-+ const long Normal = 1;
-+ const long Class = 2;
-+ const long Form = 3;
-+ const long Document = 4;
-+};
++ BasicIDEShell* mpShell;
++public:
+
-+//=============================================================================
++ ContainerListenerImpl( BasicIDEShell* pShell ) : mpShell( pShell ) {}
+
-+}; }; }; };
++ ~ContainerListenerImpl()
++ {
++ }
+
-+#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
-+ *
-+ ************************************************************************/
++ 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& ) {}
++ }
++ }
+
-+#ifndef __com_sun_star_script_ModuleInfo_idl__
-+#define __com_sun_star_script_ModuleInfo_idl__
++ // XEventListener
++ virtual void SAL_CALL disposing( const lang::EventObject& ) throw( uno::RuntimeException ) {}
+
-+#ifndef __com_sun_star_uno_XInterface_idl__
-+#include <com/sun/star/uno/XInterface.idl>
-+#endif
++ // 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 );
++ }
++ }
+
-+//=============================================================================
-+module com { module sun { module star { module script {
-+struct ModuleInfo
-+{
-+ string ModuleName;
-+ string ModuleSource;
-+ com::sun::star::uno::XInterface ModuleObjectProvider;
-+ short ModuleType; // string?
+};
+
+ TYPEINIT1( BasicIDEShell, SfxViewShell );
+
+@@ -124,6 +192,7 @@ BasicIDEShell::BasicIDEShell( SfxViewFra
+ m_bAppBasicModified( FALSE ),
+ m_aNotifier( *this )
+ {
++ m_xLibListener = new ContainerListenerImpl( this );
+ Init();
+ GnBasicIDEShellCount++;
+ }
+@@ -139,6 +208,7 @@ BasicIDEShell::BasicIDEShell( SfxViewFra
+ m_aNotifier( *this )
+ {
+ DBG_ERROR( "Zweite Ansicht auf Debugger nicht moeglich!" );
++ m_xLibListener = new ContainerListenerImpl( this );
+ GnBasicIDEShellCount++;
+ }
+
+@@ -153,6 +223,7 @@ BasicIDEShell::BasicIDEShell( SfxViewFra
+ m_aNotifier( *this )
+ {
+ Init();
++ m_xLibListener = new ContainerListenerImpl( this );
+ GnBasicIDEShellCount++;
+ }
+
+@@ -243,6 +314,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 ) );
+@@ -968,7 +1045,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;
+
-+#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
-+ *
-+ ************************************************************************/
++ if ( pListener )
++ pListener->addContainerListener( m_aCurDocument );
+
-+#ifndef __com_sun_star_script_XObjectProvider_idl__
-+#define __com_sun_star_script_XObjectProvider_idl__
+ m_aCurLibName = aLibName;
+ if ( bUpdateWindows )
+ UpdateWindows();
+diff --git basctl/source/basicide/scriptdocument.cxx basctl/source/basicide/scriptdocument.cxx
+index 5d22053..0483cce 100644
+--- basctl/source/basicide/scriptdocument.cxx
++++ basctl/source/basicide/scriptdocument.cxx
+@@ -56,6 +56,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>
+@@ -141,6 +142,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;
+@@ -673,6 +675,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;
+ }
+@@ -1431,7 +1442,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 --git basctl/source/inc/basidesh.hxx basctl/source/inc/basidesh.hxx
+index 109fedd..fa4cbe9 100644
+--- basctl/source/inc/basidesh.hxx
++++ basctl/source/inc/basidesh.hxx
+@@ -48,7 +48,7 @@
+ #ifndef _COM_SUN_STAR_IO_XINPUTSTREAMPROVIDER_HXX_
+ #include <com/sun/star/io/XInputStreamProvider.hpp>
+ #endif
+-
++#include <com/sun/star/container/XContainerListener.hpp>
+
+ //----------------------------------------------------------------------------
+
+@@ -76,13 +76,15 @@ DECLARE_TABLE( IDEWindowTable, IDEBaseWi
+ typedef Table IDEWindowTable;
+ #endif
+
++namespace css = ::com::sun::star;
+
-+#ifndef __com_sun_star_uno_XInterface_idl__
-+#include <com/sun/star/uno/XInterface.idl>
-+#endif
+ class BasicIDEShell :public SfxViewShell
+ ,public ::basctl::DocumentEventListener
+ {
+ friend class JavaDebuggingListenerImpl;
+ friend class LocalizationMgr;
+ friend class BasicIDE;
+-
++friend class ContainerListenerImpl;
+ ObjectCatalog* pObjectCatalog;
+
+ IDEWindowTable aIDEWindowTable;
+@@ -102,6 +104,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 --git basic/inc/basic/sbmod.hxx basic/inc/basic/sbmod.hxx
+index 122a664..e676a49 100644
+--- basic/inc/basic/sbmod.hxx
++++ basic/inc/basic/sbmod.hxx
+@@ -37,7 +37,7 @@
+ #ifndef _RTL_USTRING_HXX
+ #include <rtl/ustring.hxx>
+ #endif
+-
++#include <com/sun/star/script/ModuleType.hpp>
+ class SbMethod;
+ class SbProperty;
+ class SbiRuntime;
+@@ -67,6 +67,9 @@ protected:
+ SbiBreakpoints* pBreaks; // Breakpoints
+ SbClassData* pClassData;
+ bool mbVBACompat;
++ INT32 mnType;
++ SbxObjectRef pDocObject; // an impl object ( used by Document Modules )
++ bool bIsProxyModule;
+
+ void StartDefinitions();
+ SbMethod* GetMethod( const String&, SbxDataType );
+@@ -91,7 +94,7 @@ protected:
+ public:
+ SBX_DECL_PERSIST_NODATA(SBXCR_SBX,SBXID_BASICMOD,2);
+ TYPEINFO();
+- SbModule( const String& );
++ SbModule( const String&, bool bCompat = false );
+ virtual void SetParent( SbxObject* );
+ virtual void Clear();
+
+@@ -127,8 +130,12 @@ public:
+ BOOL LoadBinaryData( SvStream& );
+ BOOL ExceedsLegacyModuleSize();
+ void fixUpMethodStart( bool bCvtToLegacy, SbiImage* pImg = NULL ) const;
+- bool IsVBACompat() { return mbVBACompat; }
+ bool HasExeCode();
++ bool IsVBACompat();
++ void SetVBACompat( bool bCompat );
++ INT32 GetModuleType() { return mnType; }
++ void SetModuleType( INT32 nType ) { mnType = nType; }
++ bool GetIsProxyModule() { return bIsProxyModule; }
+ };
+
+ #ifndef __SB_SBMODULEREF_HXX
+diff --git basic/inc/basic/sbstar.hxx basic/inc/basic/sbstar.hxx
+index ebd10ae..3c7e149 100644
+--- basic/inc/basic/sbstar.hxx
++++ basic/inc/basic/sbstar.hxx
+@@ -40,6 +40,7 @@
+
+ #include <basic/sbdef.hxx>
+ #include <basic/sberrors.hxx>
++#include <com/sun/star/script/ModuleInfo.hpp>
+
+ class SbModule; // fertiges Modul
+ class SbiInstance; // Laufzeit-Instanz
+@@ -71,6 +72,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:
+@@ -113,7 +115,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* MakeModule32( const com::sun::star::script::ModuleInfo& mInfo );
+ BOOL Compile( SbModule* );
+ BOOL Disassemble( SbModule*, String& rText );
+ static void Stop();
+@@ -185,6 +188,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 --git basic/source/basmgr/basmgr.cxx basic/source/basmgr/basmgr.cxx
+index 54f6426..b5394ae 100644
+--- basic/source/basmgr/basmgr.cxx
++++ basic/source/basmgr/basmgr.cxx
+@@ -67,6 +67,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>
+
+@@ -110,6 +112,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))
+
+@@ -244,9 +247,18 @@ void BasMgrContainerListenerImpl::addLib
+ {
+ OUString aModuleName = pNames[ j ];
+ Any aElement = xLibNameAccess->getByName( aModuleName );
+- OUString aMod;
+- aElement >>= aMod;
+- pLib->MakeModule32( aModuleName, aMod );
++ ModuleInfo mInfo;
++ if ( aElement >>= mInfo )
++ {
++ OSL_TRACE("#addLibraryModulesImpl - aMod");
++ pLib->MakeModule32( mInfo );
++ }
++ else
++ {
++ OUString aMod;
++ aElement >>= aMod;
++ pLib->MakeModule32( aModuleName, aMod );
++ }
+ }
+ }
+
+@@ -283,8 +295,6 @@ void SAL_CALL BasMgrContainerListenerImp
+ }
+ else
+ {
+- OUString aMod;
+- Event.Element >>= aMod;
+
+ StarBASIC* pLib = mpMgr->GetLib( maLibName );
+ DBG_ASSERT( pLib, "BasMgrContainerListenerImpl::elementInserted: Unknown lib!");
+@@ -293,7 +303,17 @@ void SAL_CALL BasMgrContainerListenerImp
+ SbModule* pMod = pLib->FindModule( aName );
+ if( !pMod )
+ {
+- pLib->MakeModule32( aName, aMod );
++ ModuleInfo mInfo;
++ if( Event.Element >>= mInfo )
++ {
++ pLib->MakeModule32( mInfo );
++ }
++ else
++ {
++ OUString aMod;
++ Event.Element >>= aMod;
++ pLib->MakeModule32( aName, aMod );
++ }
+ pLib->SetModified( FALSE );
+ }
+ }
+@@ -319,13 +339,23 @@ void SAL_CALL BasMgrContainerListenerImp
+ StarBASIC* pLib = mpMgr->GetLib( maLibName );
+ if( pLib )
+ {
+- SbModule* pMod = pLib->FindModule( aName );
+- OUString aMod;
+- Event.Element >>= aMod;
+- if( pMod )
+- pMod->SetSource32( aMod );
+- else
+- pLib->MakeModule32( aName, aMod );
++ ModuleInfo mInfo;
++ if( Event.Element >>= mInfo )
++ {
++ OSL_TRACE("#elementReplaced Mod");
++ pLib->MakeModule32( mInfo );
++ }
++ else
++ {
++ SbModule* pMod = pLib->FindModule( aName );
++
++ OUString aMod;
++ Event.Element >>= aMod;
++ if( pMod )
++ pMod->SetSource32( aMod );
++ else
++ pLib->MakeModule32( aName, aMod );
++ }
+
+ pLib->SetModified( FALSE );
+ }
+diff --git basic/source/classes/sb.cxx basic/source/classes/sb.cxx
+index f65c6ca..5226d3f 100644
+--- basic/source/classes/sb.cxx
++++ basic/source/classes/sb.cxx
+@@ -52,12 +52,17 @@
+ #include "disas.hxx"
+ #include "runtime.hxx"
+ #include <basic/sbuno.hxx>
++#include <basic/sbobjmod.hxx>
+ #include "stdobj.hxx"
+ #include "filefmt.hxx"
+ #include "sb.hrc"
+ #include <basrid.hxx>
+ #include <vos/mutex.hxx>
+
++#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)
+@@ -249,6 +254,8 @@ SbxObject* SbiFactory::CreateObject( con
+ else
+ if( rClass.EqualsIgnoreCaseAscii( "Collection" ) )
+ {
++ // Only variables qualified by the Module Name e.g. Sheet1.foo
++ // should work for Documant && Class type Modules
+ String aCollectionName( RTL_CONSTASCII_USTRINGPARAM("Collection") );
+ return new BasicCollection( aCollectionName );
+ }
+@@ -446,6 +453,7 @@ SbClassModuleObject::SbClassModuleObject
+ }
+ }
+ }
++ SetModuleType( com::sun::star::script::ModuleType::Class );
+ }
+
+ SbClassModuleObject::~SbClassModuleObject()
+@@ -581,6 +589,7 @@ StarBASIC::StarBASIC( StarBASIC* p, BOOL
+ SetParent( p );
+ pLibInfo = NULL;
+ bNoRtl = bBreak = FALSE;
++ bVBAEnabled = FALSE;
+ pModules = new SbxArray;
+
+ if( !GetSbData()->nInst++ )
+@@ -683,12 +692,38 @@ SbModule* StarBASIC::MakeModule( const S
+
+ SbModule* StarBASIC::MakeModule32( const String& rName, const ::rtl::OUString& rSrc )
+ {
+- SbModule* p = new SbModule( rName );
+- p->SetSource32( rSrc );
++ ModuleInfo mInfo;
++ mInfo.ModuleSource = rSrc;
++ mInfo.ModuleType = ModuleType::Normal;
++ mInfo.ModuleName = rName;
++ return MakeModule32( mInfo );
++}
++SbModule* StarBASIC::MakeModule32( const ModuleInfo& mInfo )
++{
++
++ OSL_TRACE("create module %s type mInfo %d", rtl::OUStringToOString( mInfo.ModuleName, RTL_TEXTENCODING_UTF8 ).getStr(), mInfo.ModuleType );
++ SbModule* p = NULL;
++ switch ( mInfo.ModuleType )
++ {
++ case ModuleType::Document:
++ // In theory we should be able to create Object modules
++ // in ordinary basic ( in vba mode thought these are create
++ // by the application/basic and not by the user )
++ p = new SbObjModule( mInfo, isVBAEnabled() );
++ break;
++ case ModuleType::Class:
++ p = new SbModule( mInfo.ModuleName, isVBAEnabled() );
++ p->SetModuleType( com::sun::star::script::ModuleType::Class );
++ break;
++ default:
++ p = new SbModule( mInfo.ModuleName, isVBAEnabled() );
++
++ }
++ p->SetSource32( mInfo.ModuleSource );
+ p->SetParent( this );
+ pModules->Insert( p, pModules->Count() );
+ SetModified( TRUE );
+- return p;
++ return p;
+ }
+
+ void StarBASIC::Insert( SbxVariable* pVar )
+@@ -862,6 +897,12 @@ SbxVariable* StarBASIC::Find( const Stri
+ }
+ pNamed = p;
+ }
++ // Only variables qualified by the Module Name e.g. Sheet1.foo
++ // should work for Documant && Class type Modules
++ INT32 nType = p->GetModuleType();
++ //if ( nType == com::sun::star::script::ModuleType::Class || nType == com::sun::star::script::ModuleType::Document )
++ if ( nType == com::sun::star::script::ModuleType::Document )
++ continue;
+ // Sonst testen, ob das Element vorhanden ist
+ // GBLSEARCH-Flag rausnehmen (wg. Rekursion)
+ USHORT nGblFlag = p->GetFlags() & SBX_GBLSEARCH;
+diff --git basic/source/classes/sbxmod.cxx basic/source/classes/sbxmod.cxx
+index de94bf3..388f437 100644
+--- basic/source/classes/sbxmod.cxx
++++ basic/source/classes/sbxmod.cxx
+@@ -51,6 +51,8 @@
+ #include <basic/hilight.hxx>
+ #include <basic/basrdll.hxx>
+ #include <vos/mutex.hxx>
++#include <basic/sbobjmod.hxx>
++#include <com/sun/star/lang/XServiceInfo.hpp>
+
+ // for the bsearch
+ #ifdef WNT
+@@ -65,6 +67,17 @@
+
+ #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;
+
+ TYPEINIT1(SbModule,SbxObject)
+ TYPEINIT1(SbMethod,SbxMethod)
+@@ -72,6 +85,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)
+@@ -80,7 +94,7 @@ SV_IMPL_VARARR(SbiBreakpoints,USHORT)
+ SV_IMPL_VARARR(HighlightPortions, HighlightPortion)
+
+ // ##########################################################################
+-// ACHTUNG!!! Alle Woerter dieser Tabelle müKLEIN geschrieben werden!!!
++// ACHTUNG!!! Alle Woerter dieser Tabelle mÃssen KLEIN geschrieben werden!!!
+ // ##########################################################################
+ static const char* strListBasicKeyWords[] = {
+ "access",
+@@ -221,12 +235,13 @@ extern "C" int CDECL compare_strings( co
+ // Ein BASIC-Modul hat EXTSEARCH gesetzt, damit die im Modul enthaltenen
+ // Elemente von anderen Modulen aus gefunden werden koennen.
+
+-SbModule::SbModule( const String& rName )
++SbModule::SbModule( const String& rName, bool bVBACompat )
+ : SbxObject( String( RTL_CONSTASCII_USTRINGPARAM("StarBASICModule") ) ),
+- pImage( NULL ), pBreaks( NULL ), pClassData( NULL ), mbVBACompat( false )
++ pImage( NULL ), pBreaks( NULL ), pClassData( NULL ), mbVBACompat( bVBACompat ), pDocObject( NULL ), bIsProxyModule( false )
+ {
+ SetName( rName );
+ SetFlag( SBX_EXTSEARCH | SBX_GBLSEARCH );
++ SetModuleType( com::sun::star::script::ModuleType::Normal );
+ }
+
+ SbModule::~SbModule()
+@@ -401,7 +416,10 @@ void SbModule::Clear()
+
+ SbxVariable* SbModule::Find( const XubString& rName, SbxClassType t )
+ {
++ // make sure a search in an uninstatiated class module will fail
+ SbxVariable* pRes = SbxObject::Find( rName, t );
++ if ( bIsProxyModule )
++ return NULL;
+ if( !pRes && pImage )
+ {
+ SbiInstance* pInst = pINST;
+@@ -561,6 +579,7 @@ void SbModule::SetSource32( const ::rtl:
+ aOUSource = r;
+ StartDefinitions();
+ SbiTokenizer aTok( r );
++ aTok.SetCompatible( IsVBACompat() );
+ while( !aTok.IsEof() )
+ {
+ SbiToken eEndTok = NIL;
+@@ -585,14 +604,6 @@ void SbModule::SetSource32( const ::rtl:
+ {
+ eEndTok = ENDPROPERTY; break;
+ }
+- if( eCurTok == OPTION )
+- {
+- eCurTok = aTok.Next();
+- mbVBACompat = ( eCurTok == VBASUPPORT ) && ( aTok.Next() == NUMBER ) && ( aTok.GetDbl()== 1 );
+- if( eCurTok == COMPATIBLE
+- || mbVBACompat )
+- aTok.SetCompatible( true );
+- }
+ }
+ eLastTok = eCurTok;
+ }
+@@ -731,10 +742,19 @@ void ClearUnoObjectsInRTL_Impl( StarBASI
+ if( ((StarBASIC*)p) != pBasic )
+ ClearUnoObjectsInRTL_Impl_Rek( (StarBASIC*)p );
+ }
++bool SbModule::IsVBACompat()
++{
++ return mbVBACompat;
++}
+
++void SbModule::SetVBACompat( bool bCompat )
++{
++ mbVBACompat = bCompat;
++}
+ // Ausfuehren eines BASIC-Unterprogramms
+ USHORT SbModule::Run( SbMethod* pMeth )
+ {
++ OSL_TRACE("About to run %s, vba compatmode is %d", rtl::OUStringToOString( pMeth->GetName(), RTL_TEXTENCODING_UTF8 ).getStr(), mbVBACompat );
+ static USHORT nMaxCallLevel = 0;
+ static String aMSOMacroRuntimeLibName = String::CreateFromAscii( "Launcher" );
+ static String aMSOMacroRuntimeAppSymbol = String::CreateFromAscii( "Application" );
+@@ -826,10 +846,10 @@ USHORT SbModule::Run( SbMethod* pMeth )
+ if( pRt->pNext )
+ pRt->pNext->block();
+ pINST->pRun = pRt;
+- if ( SbiRuntime ::isVBAEnabled() )
++ if ( mbVBACompat )
+ {
+ pINST->EnableCompatibility( TRUE );
+- pRt->SetVBAEnabled( true );
++ //pRt->SetVBAEnabled( true ); // can we get rid of this
+ }
+ while( pRt->Step() ) {}
+ if( pRt->pNext )
+@@ -1404,7 +1424,6 @@ BOOL SbModule::LoadBinaryData( SvStream&
+ return bRet;
+ }
+
+-
+ BOOL SbModule::LoadCompleted()
+ {
+ SbxArray* p = GetMethods();
+@@ -2223,3 +2242,44 @@ SbProcedureProperty::~SbProcedurePropert
+ {}
+
+
++/////////////////////////////////////////////////////////////////////////
++SbObjModule::SbObjModule( const com::sun::star::script::ModuleInfo& mInfo, bool bIsVbaCompatible )
++ : SbModule( mInfo.ModuleName, bIsVbaCompatible )
++{
++ SetModuleType( mInfo.ModuleType );
++ try
++ {
++ com::sun::star::uno::Any aObject( mInfo.ModuleObject );
++ pDocObject = new SbUnoObject( GetName(), aObject );
++ com::sun::star::uno::Reference< com::sun::star::lang::XServiceInfo > xServiceInfo( aObject, com::sun::star::uno::UNO_QUERY_THROW );
++ if( xServiceInfo->supportsService( rtl::OUString::createFromAscii( "org.openoffice.excel.Worksheet" ) ) )
++ {
++ SetClassName( rtl::OUString::createFromAscii( "Worksheet" ) );
++ }
++ else if( xServiceInfo->supportsService( rtl::OUString::createFromAscii( "org.openoffice.excel.Workbook" ) ) )
++ {
++ SetClassName( rtl::OUString::createFromAscii( "Workbook" ) );
++ }
++ }
++ catch( com::sun::star::uno::RuntimeException e )
++ {
++ OSL_TRACE("***** Failed to initialise API Object." );
++ }
++}
+
-+module com { module sun { module star { module script {
-+//==============================================================================
-+interface XObjectProvider : ::com::sun::star::uno::XInterface
++SbxVariable*
++SbObjModule::GetObject()
+{
-+ 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
++ return pDocObject;
++}
++SbxVariable*
++SbObjModule::Find( const XubString& rName, SbxClassType t )
++{
++ //OSL_TRACE("SbObjectModule find for %s", rtl::OUStringToOString( rName, RTL_TEXTENCODING_UTF8 ).getStr() );
++ SbxVariable* pVar = NULL;
++ if ( !pVar && pDocObject)
++ pVar = pDocObject->Find( rName, t );
++ if ( !pVar )
++ pVar = SbModule::Find( rName, t );
++ return pVar;
++}
+diff --git basic/source/comp/codegen.cxx basic/source/comp/codegen.cxx
+index 9f88fb6..46e0450 100644
+--- basic/source/comp/codegen.cxx
++++ basic/source/comp/codegen.cxx
+@@ -130,12 +130,12 @@ void SbiCodeGen::Save()
+ // OPTION EXPLICIT-Flag uebernehmen
+ if( pParser->bExplicit )
+ p->SetFlag( SBIMG_EXPLICIT );
+- if( pParser->IsVBASupportOn() )
+- p->SetFlag( SBIMG_VBASUPPORT );
+
+ int nIfaceCount = 0;
+- if( pParser->bClassModule )
++ if( rMod.mnType == com::sun::star::script::ModuleType::Class )
+ {
++ OSL_TRACE("COdeGen::save() classmodule processing");
++ rMod.bIsProxyModule = true;
+ p->SetFlag( SBIMG_CLASSMODULE );
+ pCLASSFAC->AddClassModule( &rMod );
-+using namespace ::com::sun::star::script;
+@@ -158,6 +158,10 @@ void SbiCodeGen::Save()
+ else
+ {
+ pCLASSFAC->RemoveClassModule( &rMod );
++ // A Document module's type cannot be changed
++ if ( rMod.mnType != com::sun::star::script::ModuleType::Document )
++ rMod.mnType = com::sun::star::script::ModuleType::Normal;
++ rMod.bIsProxyModule = false;
+ }
+ if( pParser->bText )
+ p->SetFlag( SBIMG_COMPARETEXT );
+@@ -240,6 +244,8 @@ void SbiCodeGen::Save()
+ if( nPass == 1 )
+ aPropName = aPropName.Copy( aIfaceName.Len() + 1 );
+ SbProcedureProperty* pProcedureProperty = NULL;
++ OSL_TRACE("*** getProcedureProperty for thing %s",
++ rtl::OUStringToOString( aPropName,RTL_TEXTENCODING_UTF8 ).getStr() );
+ pProcedureProperty = rMod.GetProcedureProperty( aPropName, ePropType );
+ }
+ if( nPass == 1 )
+diff --git basic/source/comp/parser.cxx basic/source/comp/parser.cxx
+index 931b6c7..7bc712e 100644
+--- basic/source/comp/parser.cxx
++++ basic/source/comp/parser.cxx
+@@ -144,7 +144,8 @@ SbiParser::SbiParser( StarBASIC* pb, SbM
+ bNewGblDefs =
+ bSingleLineIf =
+ bExplicit = FALSE;
+- bClassModule = FALSE;
++ bClassModule = ( pm->GetModuleType() == com::sun::star::script::ModuleType::Class );
++ OSL_TRACE("Parser - %s, bClassModule %d", rtl::OUStringToOString( pm->GetName(), RTL_TEXTENCODING_UTF8 ).getStr(), bClassModule );
+ pPool = &aPublics;
+ for( short i = 0; i < 26; i++ )
+ eDefTypes[ i ] = SbxVARIANT; // Kein expliziter Defaulttyp
+@@ -157,6 +158,10 @@ SbiParser::SbiParser( StarBASIC* pb, SbM
+
+ rTypeArray = new SbxArray; // Array fuer Benutzerdefinierte Typen
+ rEnumArray = new SbxArray; // Array for Enum types
++ bVBASupportOn = pm->IsVBACompat();
++ if ( bVBASupportOn )
++ EnableCompatibility();
+
- /*
- 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;
+@@ -751,8 +756,9 @@ void SbiParser::Option()
- /* 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 };
+ case CLASSMODULE:
+ bClassModule = TRUE;
++ aGen.GetModule().SetModuleType( com::sun::star::script::ModuleType::Class );
+ break;
+- case VBASUPPORT:
++ case VBASUPPORT: // Option VBASupport used to override the module mode ( in fact this must reset the mode
+ if( Next() == NUMBER )
+ {
+ if ( nVal == 1 || nVal == 0 )
+@@ -760,6 +766,10 @@ void SbiParser::Option()
+ bVBASupportOn = ( nVal == 1 );
+ if ( bVBASupportOn )
+ EnableCompatibility();
++ // if the module setting is different
++ // reset it to what the Option tells us
++ if ( bVBASupportOn != aGen.GetModule().IsVBACompat() )
++ aGen.GetModule().SetVBACompat( bVBASupportOn );
+ break;
+ }
+ }
+diff --git basic/source/inc/codegen.hxx basic/source/inc/codegen.hxx
+index ad11d02..a054af7 100644
+--- basic/source/inc/codegen.hxx
++++ basic/source/inc/codegen.hxx
+@@ -56,6 +56,7 @@ public:
+ void GenStmnt(); // evtl. Statement-Opcode erzeugen
+ UINT32 GetPC();
+ UINT32 GetOffset() { return GetPC() + 1; }
++ SbModule& GetModule() { return rMod; }
+ void Save();
+
+ // #29955 for-Schleifen-Ebene pflegen
+diff --git basic/source/inc/image.hxx basic/source/inc/image.hxx
+index 8a454cf..c371a85 100644
+--- basic/source/inc/image.hxx
++++ basic/source/inc/image.hxx
+@@ -109,6 +109,5 @@ public:
+ #define SBIMG_COMPARETEXT 0x0002 // OPTION COMPARE TEXT ist aktiv
+ #define SBIMG_INITCODE 0x0004 // Init-Code vorhanden
+ #define SBIMG_CLASSMODULE 0x0008 // OPTION ClassModule is active
+-#define SBIMG_VBASUPPORT 0x0020 // OPTION VBASupport is 1
- // #117718# define map to hold types of module
- //
--
-+typedef sal_Int32 ModType;
- typedef ::std::map< UniString,
-- ModuleType > ModuleTypeHash;
-+ ModType > ModuleTypeHash;
+ #endif
+diff --git basic/source/runtime/methods1.cxx basic/source/runtime/methods1.cxx
+index 313bf17..c891643 100644
+--- basic/source/runtime/methods1.cxx
++++ basic/source/runtime/methods1.cxx
+@@ -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>
+@@ -64,6 +65,7 @@
+ #endif
- 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 );
+ #include <vcl/jobset.hxx>
++#include <basic/sbobjmod.hxx>
- 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 "sbintern.hxx"
+ #include "runtime.hxx"
+@@ -2585,13 +2587,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 --git basic/source/runtime/runtime.cxx basic/source/runtime/runtime.cxx
+index 020b7e2..9de19fd 100644
+--- basic/source/runtime/runtime.cxx
++++ basic/source/runtime/runtime.cxx
+@@ -53,7 +53,8 @@ bool SbiRuntime::isVBAEnabled()
+ bool result = false;
+ SbiInstance* pInst = pINST;
+ if ( pInst && pINST->pRun )
+- result = pInst->pRun->GetImageFlag( SBIMG_VBASUPPORT );
++ //result = pInst->pRun->GetImageFlag( SBIMG_VBASUPPORT );
++ result = pInst->pRun->bVBAEnabled;
+ return result;
+ }
- #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 );
+@@ -64,6 +65,24 @@ void StarBASIC::StaticEnableReschedule(
+ {
+ bStaticGlobalEnableReschedule = bReschedule;
+ }
++void StarBASIC::SetVBAEnabled( BOOL bEnabled )
++{
++ if ( bDocBasic )
++ {
++ bVBAEnabled = bEnabled;
++ }
++}
++
++BOOL StarBASIC::isVBAEnabled()
++{
++ if ( bDocBasic )
++ {
++ if( SbiRuntime::isVBAEnabled() )
++ return TRUE;
++ return bVBAEnabled;
++ }
++ return FALSE;
++}
- rtl::OUString sClassRem( RTL_CONSTASCII_USTRINGPARAM( "Rem Attribute VBA_ModuleType=" ) );
-@@ -292,23 +294,23 @@ BOOL SvxImportMSVBasic::ImportCode_Impl(
+ struct SbiArgvStack { // Argv stack:
+@@ -519,6 +538,7 @@ SbiRuntime::SbiRuntime( SbModule* pm, Sb
+ nForLvl = 0;
+ nOps = 0;
+ refExprStk = new SbxArray;
++ SetVBAEnabled( pMod->IsVBACompat() );
+ #if defined GCC
+ SetParameters( pe ? pe->GetParameters() : (class SbxArray *)NULL );
+ #else
+@@ -526,7 +546,6 @@ SbiRuntime::SbiRuntime( SbModule* pm, Sb
+ #endif
+ pRefSaveList = NULL;
+ pItemStoreList = NULL;
+- bVBAEnabled = isVBAEnabled();
+ }
- 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;
+ SbiRuntime::~SbiRuntime()
+diff --git basic/source/uno/namecont.cxx basic/source/uno/namecont.cxx
+index 93ea95d..e5f37c7 100644
+--- basic/source/uno/namecont.cxx
++++ basic/source/uno/namecont.cxx
+@@ -72,6 +72,9 @@
+ #include <cppuhelper/exc_hlp.hxx>
+ #include <basic/sbmod.hxx>
- }
-@@ -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;
++#ifndef _COM_SUN_STAR_SCRIPT_MODULEINFO_HPP_
++#include <com/sun/star/script/ModuleInfo.hpp>
++#endif
- 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
+ namespace basic
+ {
+@@ -150,7 +153,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 );
+@@ -192,7 +195,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 --git sc/inc/servuno.hxx sc/inc/servuno.hxx
+index c93cdb3..73fdec1 100644
+--- sc/inc/servuno.hxx
++++ sc/inc/servuno.hxx
@@ -93,8 +93,8 @@ class ScDocShell;
#define SC_SERVICE_FORMULAPARS 38
@@ -415,150 +1004,94 @@
#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)
+diff --git sc/source/filter/excel/excimp8.cxx sc/source/filter/excel/excimp8.cxx
+index c7dac08..9fd0be4 100644
+--- sc/source/filter/excel/excimp8.cxx
++++ sc/source/filter/excel/excimp8.cxx
+@@ -281,6 +281,7 @@ bool lcl_hasVBAEnabled()
+
+ void ImportExcel8::ReadBasic( void )
+ {
++ //bHasBasic = TRUE;
+ bHasBasic = TRUE;
+
+ SfxObjectShell* pShell = GetDocShell();
+@@ -308,6 +309,10 @@ void ImportExcel8::EndSheet( void )
+
+ void ImportExcel8::PostDocLoad( void )
+ {
++ // delay reading basic until sheet object ( codenames etc. ) are read
++
++ if ( bHasBasic )
++ ReadBasic();
+ // #i11776# filtered ranges before outlines and hidden rows
+ if( pExcRoot->pAutoFilterBuffer )
+ pExcRoot->pAutoFilterBuffer->Apply();
+diff --git sc/source/filter/excel/read.cxx sc/source/filter/excel/read.cxx
+index d65e496..403c0e2 100644
+--- sc/source/filter/excel/read.cxx
++++ sc/source/filter/excel/read.cxx
+@@ -946,7 +946,8 @@ FltError ImportExcel8::Read( void )
+ case 0x22: Rec1904(); break; // 1904 [ 2345 ]
+ case 0x56: Builtinfmtcnt(); break; // BUILTINFMTCNT[ 34 ]
+ case 0x8D: Hideobj(); break; // HIDEOBJ [ 345 ]
+- case 0xD3: ReadBasic(); break;
++ case 0xD3: /*ReadBasic()*/bHasBasic = true; break;
++// case 0xD3: ReadBasic(); break;
+ case 0xDE: Olesize(); break;
+ case 0x01BA: Codename( TRUE ); break;
+
+diff --git sc/source/filter/excel/xiescher.cxx sc/source/filter/excel/xiescher.cxx
+index 2b96bbf..be29bd4 100644
+--- sc/source/filter/excel/xiescher.cxx
++++ sc/source/filter/excel/xiescher.cxx
+@@ -825,8 +825,17 @@ OUString XclImpTbxControlObj::GetService
+
+ bool XclImpTbxControlObj::FillMacroDescriptor( ScriptEventDescriptor& rEvent ) const
+ {
+- if( GetMacroName().Len() > 0 )
+- {
++ // *FIXME needs a ResolveMacro method
++ String sTmp = GetMacroName();
++ if( sTmp.Len() > 0 )
+ {
-+ 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 @@
++ if ( ( sTmp.Search( '.' ) == STRING_NOTFOUND) )
++ if( SfxObjectShell* pDocShell = GetDocShell() )
++ if( StarBASIC* pBasic = pDocShell->GetBasic() )
++ if( SbMethod* pMethod = dynamic_cast< SbMethod* >( pBasic->Find( sTmp, SbxCLASS_METHOD ) ) )
++ if( SbModule* pModule = pMethod->GetModule() )
++ sTmp.Insert( '.', 0 ).Insert( pModule->GetName(), 0 );
++
+ // type of action is dependent on control type
+ rEvent.ListenerType = XclControlObjHelper::GetTbxListenerType( GetObjType() );
+ rEvent.EventMethod = XclControlObjHelper::GetTbxEventMethod( GetObjType() );
+@@ -834,7 +843,7 @@ bool XclImpTbxControlObj::FillMacroDescr
+ {
+ // set the macro name
+ rEvent.ScriptType = XclControlObjHelper::GetTbxScriptType();
+- rEvent.ScriptCode = XclControlObjHelper::GetScMacroName( GetMacroName() );
++ rEvent.ScriptCode = XclControlObjHelper::GetScMacroName( sTmp );
+ return true;
+ }
+ }
+diff --git sc/source/ui/docshell/docfunc.cxx sc/source/ui/docshell/docfunc.cxx
+index c0253ae..79e8eed 100644
+--- sc/source/ui/docshell/docfunc.cxx
++++ sc/source/ui/docshell/docfunc.cxx
+@@ -51,6 +51,12 @@
+ #include <svtools/zforlist.hxx>
#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 @@
+@@ -94,6 +100,7 @@
#include "scui_def.hxx" //CHINA001
using namespace com::sun::star;
@@ -566,7 +1099,7 @@
// STATIC DATA -----------------------------------------------------------
//========================================================================
-@@ -2022,6 +2030,86 @@ BOOL ScDocFunc::MoveBlock( const ScRange
+@@ -2016,6 +2023,85 @@ BOOL ScDocFunc::MoveBlock( const ScRange
}
//------------------------------------------------------------------------
@@ -574,19 +1107,19 @@
+{
+ ::rtl::OUString aModName( sModule );
+ uno::Reference< lang::XMultiServiceFactory> xSF(rDocSh.GetModel(), uno::UNO_QUERY);
-+ uno::Reference< script::XObjectProvider > xVBAObjectProvider;
++ ::rtl::OUString sVbaOption( RTL_CONSTASCII_USTRINGPARAM( "Rem Attribute VBA_ModuleType=VBADocumentModule\nOption VBASupport 1\n" ));
++ script::ModuleInfo sModuleInfo;
++ sModuleInfo.ModuleName = aModName;
++ sModuleInfo.ModuleSource = sVbaOption;
++ sModuleInfo.ModuleType = script::ModuleType::Document;
++ uno::Reference< container::XNameAccess > xVBACodeNamedObjectAccess;
+ if ( xSF.is() )
+ {
+ uno::Sequence< uno::Any > aArgs(1);
+ aArgs[0] = uno::Any( aModName );
-+ xVBAObjectProvider.set( xSF->createInstanceWithArguments( rtl::OUString(RTL_CONSTASCII_USTRINGPARAM( "org.openoffice.vba.VBAObjectModuleObjectProvider")), aArgs), uno::UNO_QUERY );
++ xVBACodeNamedObjectAccess.set( xSF->createInstanceWithArguments( rtl::OUString(RTL_CONSTASCII_USTRINGPARAM( "org.openoffice.vba.VBAObjectModuleObjectProvider")), aArgs), uno::UNO_QUERY );
++ sModuleInfo.ModuleObject.set( xVBACodeNamedObjectAccess->getByName( aModName ), uno::UNO_QUERY );
+ }
-+ 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;
+}
+
@@ -609,9 +1142,8 @@
+ // 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 ) )
++ while( xLib->hasByName( sModuleInfo.ModuleName ) )
+ {
+ sModuleName = rtl::OUString::createFromAscii( "Sheet" ) + rtl::OUString::valueOf( nNum );
+ nNum += 1;
@@ -653,7 +1185,7 @@
BOOL ScDocFunc::InsertTable( SCTAB nTab, const String& rName, BOOL bRecord, BOOL bApi )
{
-@@ -2031,8 +2119,12 @@ BOOL ScDocFunc::InsertTable( SCTAB nTab,
+@@ -2025,8 +2111,12 @@ BOOL ScDocFunc::InsertTable( SCTAB nTab,
ScDocShellModificator aModificator( rDocShell );
ScDocument* pDoc = rDocShell.GetDocument();
@@ -666,7 +1198,7 @@
if (bRecord)
pDoc->BeginDrawUndo(); // InsertTab erzeugt ein SdrUndoNewPage
-@@ -2047,6 +2139,11 @@ BOOL ScDocFunc::InsertTable( SCTAB nTab,
+@@ -2041,6 +2131,11 @@ BOOL ScDocFunc::InsertTable( SCTAB nTab,
rDocShell.GetUndoManager()->AddUndoAction(
new ScUndoInsertTab( &rDocShell, nTab, bAppend, rName));
// Views updaten:
@@ -678,7 +1210,7 @@
rDocShell.Broadcast( ScTablesHint( SC_TAB_INSERTED, nTab ) );
rDocShell.PostPaintExtras();
-@@ -2068,8 +2165,12 @@ BOOL ScDocFunc::DeleteTable( SCTAB nTab,
+@@ -2062,8 +2157,12 @@ BOOL ScDocFunc::DeleteTable( SCTAB nTab,
BOOL bSuccess = FALSE;
ScDocument* pDoc = rDocShell.GetDocument();
@@ -691,7 +1223,7 @@
BOOL bWasLinked = pDoc->IsLinked(nTab);
ScDocument* pUndoDoc = NULL;
ScRefUndoData* pUndoData = NULL;
-@@ -2110,6 +2211,8 @@ BOOL ScDocFunc::DeleteTable( SCTAB nTab,
+@@ -2104,6 +2203,8 @@ BOOL ScDocFunc::DeleteTable( SCTAB nTab,
pUndoData = new ScRefUndoData( pDoc );
}
@@ -700,7 +1232,7 @@
if (pDoc->DeleteTab( nTab, pUndoDoc ))
{
if (bRecord)
-@@ -2120,6 +2223,13 @@ BOOL ScDocFunc::DeleteTable( SCTAB nTab,
+@@ -2114,6 +2215,13 @@ BOOL ScDocFunc::DeleteTable( SCTAB nTab,
new ScUndoDeleteTab( &rDocShell, theTabs, pUndoDoc, pUndoData ));
}
// Views updaten:
@@ -714,669 +1246,484 @@
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();
+diff --git sc/source/ui/unoobj/servuno.cxx sc/source/ui/unoobj/servuno.cxx
+index 9a3edb8..b1a8a85 100644
+--- sc/source/ui/unoobj/servuno.cxx
++++ sc/source/ui/unoobj/servuno.cxx
+@@ -38,6 +38,7 @@
+ #include <svx/unofill.hxx>
+ #include <svx/unonrule.hxx>
+ #include <com/sun/star/sheet/XSpreadsheetDocument.hpp>
++#include <com/sun/star/container/XNameAccess.hpp>
+
+ #include "servuno.hxx"
+ #include "unonames.hxx"
+@@ -61,8 +62,103 @@
+ #include <svx/xmleohlp.hxx>
+ #include <svx/xmlgrhlp.hxx>
++#include <comphelper/processfactory.hxx>
+
- 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
++class ScVbaObjectForCodeNameProvider : public ::cppu::WeakImplHelper1< container::XNameAccess >
+{
-+ BasicIDEShell* mpShell;
++ uno::Any maWorkbook;
++ uno::Any maCachedObject;
++ uno::Reference<lang::XMultiServiceFactory> mxSF;
++ ScDocShell* mpDocShell;
+public:
-+
-+ ContainerListenerImpl( BasicIDEShell* pShell ) : mpShell( pShell ) {}
-+
-+ ~ContainerListenerImpl()
-+ {
-+ }
-+
-+ void addContainerListener( const ScriptDocument& rScriptDocument )
++ ScVbaObjectForCodeNameProvider( ScDocShell* pDocShell ) : mpDocShell( pDocShell )
+ {
-+ uno::Reference< container::XContainer > xContainer( rScriptDocument.getLibrary( E_SCRIPTS, sStandardLibName, FALSE ), uno::UNO_QUERY );
-+ if ( rScriptDocument.isDocument() && xContainer.is() )
++ mxSF.set(comphelper::getProcessServiceFactory());
++ uno::Reference<beans::XPropertySet> xProps(mxSF, uno::UNO_QUERY);
++ if( xProps.is() )
+ {
-+ uno::Reference< container::XContainerListener > xContainerListener( this );
-+ try
-+ {
-+ xContainer->addContainerListener( xContainerListener );
-+ }
-+ catch( uno::Exception& ) {}
++ ScDocument* pDoc = mpDocShell->GetDocument();
++ if ( !pDoc )
++ throw uno::RuntimeException( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("")), uno::Reference< uno::XInterface >() );
++
++ uno::Sequence< uno::Any > aArgs(2);
++ aArgs[0] = uno::Any( uno::Reference< uno::XInterface >() );
++ aArgs[1] = uno::Any( mpDocShell->GetModel() );
++ maWorkbook <<= mxSF->createInstanceWithArguments( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("org.openoffice.excel.Workbook") ), aArgs );
+ }
+ }
-+ void removeContainerListener( const ScriptDocument& rScriptDocument )
++
++ virtual ::sal_Bool SAL_CALL hasByName( const ::rtl::OUString& aName ) throw (::com::sun::star::uno::RuntimeException )
+ {
-+ uno::Reference< container::XContainer > xContainer( rScriptDocument.getLibrary( E_SCRIPTS, sStandardLibName, FALSE ), uno::UNO_QUERY );
-+ if ( rScriptDocument.isDocument(), xContainer.is() )
++ maCachedObject = uno::Any(); // clear cached object
++ String sName = aName;
++ ScDocument* pDoc = mpDocShell->GetDocument();
++ if ( !pDoc )
++ throw uno::RuntimeException();
++ if ( sName == pDoc->GetCodeName() )
++ maCachedObject = maWorkbook;
++ else
+ {
-+ uno::Reference< container::XContainerListener > xContainerListener( this );
-+ try
++ String sCodeName;
++ SCTAB nCount = pDoc->GetTableCount();
++ for( SCTAB i = 0; i < nCount; i++ )
+ {
-+ xContainer->removeContainerListener( xContainerListener );
++ pDoc->GetCodeName( i, sCodeName );
++ if( sCodeName == sName )
++ {
++ 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] = maWorkbook;
++ aArgs[1] = uno::Any( xModel );
++ aArgs[2] = uno::Any( rtl::OUString( sSheetName ) );
++ maCachedObject <<= mxSF->createInstanceWithArguments( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("org.openoffice.excel.Worksheet") ), aArgs );
++ break;
++ }
++ }
+ }
-+ catch( uno::Exception& ) {}
+ }
-+ }
-+
-+ // XEventListener
-+ virtual void SAL_CALL disposing( const lang::EventObject& ) throw( uno::RuntimeException ) {}
++ return maCachedObject.hasValue();
+
-+ // 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 )
++ ::com::sun::star::uno::Any SAL_CALL getByName( const ::rtl::OUString& aName ) throw (::com::sun::star::container::NoSuchElementException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException)
+ {
-+ rtl::OUString sModuleName;
-+ if( mpShell && ( Event.Accessor >>= sModuleName ) )
++ OSL_TRACE("ScVbaObjectForCodeNameProvider::getByName( %s )",
++ rtl::OUStringToOString( aName, RTL_TEXTENCODING_UTF8 ).getStr() );
++ if ( !hasByName( aName ) )
++ throw ::com::sun::star::container::NoSuchElementException();
++ return maCachedObject;
++ }
++ virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL getElementNames( ) throw (::com::sun::star::uno::RuntimeException)
++ {
++ ScDocument* pDoc = mpDocShell->GetDocument();
++ if ( !pDoc )
++ throw uno::RuntimeException();
++ SCTAB nCount = pDoc->GetTableCount();
++ uno::Sequence< rtl::OUString > aNames( nCount + 1 );
++ SCTAB index = 0;
++ String sCodeName;
++ for( ; index < nCount; ++index )
+ {
-+ IDEBaseWindow* pWin = mpShell->FindWindow( mpShell->m_aCurDocument, sStandardLibName, sModuleName, BASICIDE_TYPE_MODULE, TRUE );
-+ if( pWin )
-+ mpShell->RemoveWindow( pWin, FALSE, TRUE );
++ pDoc->GetCodeName( index, sCodeName );
++ aNames[ index ] = sCodeName;
+ }
++ aNames[ index ] = pDoc->GetCodeName();
++ return aNames;
+ }
++ // XElemenAccess
++ virtual ::com::sun::star::uno::Type SAL_CALL getElementType( ) throw (::com::sun::star::uno::RuntimeException){ return uno::Type(); }
++ virtual ::sal_Bool SAL_CALL hasElements( ) throw (::com::sun::star::uno::RuntimeException ) { return sal_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++;
- }
+@@ -112,7 +208,8 @@ static const sal_Char* __FAR_DATA aProvN
-@@ -170,6 +240,7 @@ BasicIDEShell::BasicIDEShell( SfxViewFra
- m_aNotifier( *this )
- {
- Init();
-+ m_xLibListener = new ContainerListenerImpl( this );
- GnBasicIDEShellCount++;
- }
+ 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
+ };
-@@ -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
+ //
+@@ -164,7 +261,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
+ };
- void BasicIDEShell::onDocumentCreated( const ScriptDocument& /*_rDocument*/ )
- {
-+ // _rDocument is not a valid ScriptDocument.
- UpdateWindows();
- }
-@@ -303,6 +381,8 @@ void BasicIDEShell::onDocumentSaveAsDone
- // not interested in
+@@ -357,6 +455,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<container::XNameAccess*>(new ScVbaObjectForCodeNameProvider( pDocShell )));
++ break;
+ }
+ return xRet;
}
+diff --git sc/source/ui/view/viewfun2.cxx sc/source/ui/view/viewfun2.cxx
+index 674b835..dcbb8c6 100644
+--- sc/source/ui/view/viewfun2.cxx
++++ sc/source/ui/view/viewfun2.cxx
+@@ -57,6 +57,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;
+
- void BasicIDEShell::onDocumentClosed( const ScriptDocument& _rDocument )
- {
- if ( !_rDocument.isValid() )
-@@ -402,7 +482,6 @@ void BasicIDEShell::StoreAllWindowData(
- }
- }
+ #include "viewfunc.hxx"
--
- USHORT __EXPORT BasicIDEShell::PrepareClose( BOOL bUI, BOOL bForBrowsing )
- {
- (void)bForBrowsing;
-@@ -600,7 +679,6 @@ void BasicIDEShell::ShowObjectDialog( BO
+ #include "sc.hrc"
+@@ -2092,15 +2097,42 @@ BOOL ScViewFunc::DeleteTable( SCTAB nTab
+ return bSuccess;
}
-
--
- 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;
++void lcl_DeleteModule( ScDocShell* rDocSh, String& sModuleName )
++{
++ SFX_APP()->EnterBasicCall();
++ uno::Reference< script::XLibraryContainer > xLibContainer = rDocSh->GetBasicContainer();
++ DBG_ASSERT( xLibContainer.is(), "No BasicContainer!" );
+
-+ if ( pListener )
-+ pListener->addContainerListener( m_aCurDocument );
++ 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();
++}
+
- 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 === **/
+ 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;
- #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
- }
+ while ( nNewTab > 0 && !pDoc->IsVisible( nNewTab ) )
+ --nNewTab;
+@@ -2167,9 +2199,18 @@ BOOL ScViewFunc::DeleteTables(const SvSh
- // insert element by new name in container
-+ if ( _eType == E_SCRIPTS )
+ 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 )
+ {
-+ ModuleInfo sModuleInfo;
-+ if ( aElement >>= sModuleInfo )
++ if( bHasCodeName )
+ {
-+ sModuleInfo.ModuleName = _rNewName;
-+ aElement <<= sModuleInfo;
++ lcl_DeleteModule( pDocSh, sCodeName );
+ }
+ }
- 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
+ pDocSh->Broadcast( ScTablesHint( SC_TAB_DELETED, TheTabs[sal::static_int_cast<USHORT>(i)] ) );
+ }
+ }
+@@ -2197,6 +2238,7 @@ BOOL ScViewFunc::DeleteTables(const SvSh
+ pDocSh->PostPaintExtras();
+ pDocSh->SetDocumentModified();
-+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>
+ SfxApplication* pSfxApp = SFX_APP(); // Navigator
+ pSfxApp->Broadcast( SfxSimpleHint( SC_HINT_TABLES_CHANGED ) );
+ pSfxApp->Broadcast( SfxSimpleHint( SC_HINT_DBAREAS_CHANGED ) );
+diff --git svx/source/msfilter/msvbasic.cxx svx/source/msfilter/msvbasic.cxx
+index 2e4f500..2eff354 100644
+--- svx/source/msfilter/msvbasic.cxx
++++ svx/source/msfilter/msvbasic.cxx
+@@ -41,6 +41,8 @@
+ #include <rtl/tencinfo.h> //rtl_getTextEncodingFromWindowsCodePage
+ #include "msvbasic.hxx"
- 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:
++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
+@@ -432,7 +434,7 @@ int VBA_Impl::ReadVBAProject(const SvSto
+ *
+ */
- // 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();
+-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();
+@@ -440,7 +442,7 @@ ModuleType VBA_Impl::GetModuleType( cons
+ {
+ return iter->second;
+ }
+- return Unknown;
++ return ModuleType::Unknown;
+ }
- // #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>
+ bool VBA_Impl::Open( const String &rToplevel, const String &rSublevel )
+@@ -483,7 +485,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( '=' );
+@@ -493,14 +495,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 );
+@@ -513,14 +515,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 );
+diff --git svx/source/msfilter/msvbasic.hxx svx/source/msfilter/msvbasic.hxx
+index 8492062..a0536ae 100644
+--- svx/source/msfilter/msvbasic.hxx
++++ svx/source/msfilter/msvbasic.hxx
+@@ -45,6 +45,8 @@
+ #include <vector>
+ #endif
+ #include<map>
+#include <com/sun/star/script/ModuleType.hpp>
++using namespace ::com::sun::star::script::ModuleType;
- #include <cppuhelper/implbase1.hxx>
+ /* 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 };
-@@ -145,6 +147,7 @@ static const char* szScriptLanguage = "S
- static const String BasicStreamName( String::CreateFromAscii(szBasicStorage) );
- static const String ManagerStreamName( String::CreateFromAscii(szManagerStream) );
+ // #117718# define map to hold types of module
+ //
+-
++typedef sal_Int32 ModType;
+ typedef ::std::map< UniString,
+- ModuleType > ModuleTypeHash;
++ ModType > ModuleTypeHash;
-+//enum ModuleType { Unknown = 0, Normal, Class, Form, Document };
+ 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 );
- #define DEFINE_CONST_UNICODE(CONSTASCII) UniString(RTL_CONSTASCII_USTRINGPARAM(CONSTASCII))
+ std::vector<String> maReferences;
+ private:
+diff --git svx/source/msfilter/svxmsbas.cxx svx/source/msfilter/svxmsbas.cxx
+index 20840a8..27d8054 100644
+--- svx/source/msfilter/svxmsbas.cxx
++++ svx/source/msfilter/svxmsbas.cxx
+@@ -53,6 +53,7 @@ using namespace com::sun::star::awt;
-@@ -280,9 +283,22 @@ void BasMgrContainerListenerImpl::addLib
+ #include <com/sun/star/container/XNameContainer.hpp>
+ #include <com/sun/star/script/XLibraryContainer.hpp>
++#include <com/sun/star/script/ModuleInfo.hpp>
+ using namespace com::sun::star::container;
+ using namespace com::sun::star::script;
+ using namespace com::sun::star::uno;
+@@ -251,6 +252,20 @@ BOOL SvxImportMSVBasic::ImportCode_Impl(
+ }
+ if( xLib.is() )
{
- 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 )
++ Reference< container::XNameAccess > xVBAObjectForCodeName;
++ if ( !bAsComment )
+ {
-+ 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 )
++ rDocSh.GetBasic()->SetVBAEnabled( true );
++ Reference< XMultiServiceFactory> xSF(rDocSh.GetModel(), UNO_QUERY);
++ if ( xSF.is() )
+ {
-+ //pLib->MakeModule32( aName, aMod, SBXID_DOCUMENTMOD );
-+ pLib->MakeObjModule( aName, mInfo );
-+ }
-+ else
-+ {
-+ pLib->MakeModule32( aName, aMod );
++ try
++ {
++ xVBAObjectForCodeName.set( xSF->createInstance( rtl::OUString(RTL_CONSTASCII_USTRINGPARAM( "org.openoffice.vba.VBAObjectModuleObjectProvider"))), UNO_QUERY );
++ }
++ catch( Exception& ) { }
+ }
- 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 )
+ for( UINT16 i=0; i<nStreamCount;i++)
+ {
+ StringArray aDecompressed = aVBA.Decompress(i);
+@@ -284,7 +299,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 );
- 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;
+ rtl::OUString sClassRem( RTL_CONSTASCII_USTRINGPARAM( "Rem Attribute VBA_ModuleType=" ) );
- if( !GetSbData()->nInst++ )
-@@ -769,13 +775,33 @@ SbModule* StarBASIC::MakeModule( const S
+@@ -292,23 +307,23 @@ BOOL SvxImportMSVBasic::ImportCode_Impl(
- 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;
-+}
+ 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;
+@@ -318,10 +333,10 @@ BOOL SvxImportMSVBasic::ImportCode_Impl(
+ }
+ static ::rtl::OUString sVBAOption( RTL_CONSTASCII_USTRINGPARAM( "Option VBASupport 1\n" ) );
+ static ::rtl::OUString sClassOption( RTL_CONSTASCII_USTRINGPARAM( "Option ClassModule\n" ) );
+- if ( !bAsComment )
++ if ( !bAsComment && !rDocSh.GetBasic()->isVBAEnabled() )
+ {
+ modeTypeComment = modeTypeComment + sVBAOption;
+- if ( mType == Class )
++ if ( mType == ModuleType::Class )
+ modeTypeComment = modeTypeComment + sClassOption;
- 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 @@
+@@ -383,12 +398,24 @@ BOOL SvxImportMSVBasic::ImportCode_Impl(
+ aSource += rtl::OUString::createFromAscii("\nEnd Sub");
+ }
+ ::rtl::OUString aModName( sModule );
+- if ( aSource.getLength() )
+ {
+ aSource = modeTypeComment + aSource;
+
+ Any aSourceAny;
+- aSourceAny <<= aSource;
++ OSL_TRACE("erm %d", mType );
++ if ( xVBAObjectForCodeName.is() && ( mType == ModuleType::Document || mType == ModuleType::Class ) )
++ {
++ OSL_TRACE("vba processing %d", mType );
++ script::ModuleInfo sModuleInfo;
++ sModuleInfo.ModuleName = aModName;
++ sModuleInfo.ModuleSource = aSource;
++ sModuleInfo.ModuleType = mType;
++ if ( mType != ModuleType::Class )
++ sModuleInfo.ModuleObject.set( xVBAObjectForCodeName->getByName( aModName ), UNO_QUERY );
++ aSourceAny <<= sModuleInfo;
++ }
++ else
++ aSourceAny <<= aSource;
+ if( xLib->hasByName( aModName ) )
+ xLib->replaceByName( aModName, aSourceAny );
+ else
+@@ -398,6 +425,7 @@ BOOL SvxImportMSVBasic::ImportCode_Impl(
+ bRet = true;
+ }
+ }
++ if( bRet )
+ SFX_APP()->LeaveBasicCall();
+ }
+ return bRet;
+diff --git udkapi/com/sun/star/script/ModuleInfo.idl udkapi/com/sun/star/script/ModuleInfo.idl
+new file mode 100644
+index 0000000..00204f9
+--- /dev/null
++++ udkapi/com/sun/star/script/ModuleInfo.idl
+@@ -0,0 +1,57 @@
+/*************************************************************************
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
-+ * $RCSfile: sbobjmod.hxx,v $
++ * $RCSfile: ModuleInfo.idl,v $
+ *
-+ * $Revision: 1.4 $
++ * $Revision: 1.2 $
+ *
-+ * last change: $Author: $ $Date: 2007/08/27 16:31:39 $
++ * 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.
@@ -1403,464 +1750,102 @@
+ *
+ ************************************************************************/
+
-+#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;
++#ifndef __com_sun_star_script_ModuleInfo_idl__
++#define __com_sun_star_script_ModuleInfo_idl__
+
-+// Basic-Module for excel object.
++#ifndef __com_sun_star_uno_XInterface_idl__
++#include <com/sun/star/uno/XInterface.idl>
++#endif
+
-+class SbObjModule : public SbModule
++//=============================================================================
++module com { module sun { module star { module script {
++struct ModuleInfo
+{
-+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& );
++ string ModuleName;
++ string ModuleSource;
++ com::sun::star::uno::XInterface ModuleObject;
++ short ModuleType; // 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;
+diff --git udkapi/com/sun/star/script/ModuleType.idl udkapi/com/sun/star/script/ModuleType.idl
+new file mode 100644
+index 0000000..3295c52
+--- /dev/null
++++ udkapi/com/sun/star/script/ModuleType.idl
+@@ -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
++ *
++ ************************************************************************/
+
- 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 );
-+}
++#ifndef __com_sun_star_script_ModuleType_idl__
++#define __com_sun_star_script_ModuleType_idl__
+
-+BOOL
-+SbObjModule::IsClass( const XubString& rName )
-+{
-+ GetObject();
-+ return SbxObject::IsClass( rName );
-+}
++#ifndef __com_sun_star_uno_XInterface_idl__
++#include <com/sun/star/uno/XInterface.idl>
++#endif
+
-+SbxVariable*
-+SbObjModule::GetObject()
-+{
-+ if( !pDocObject )
-+ InitObject();
-+ return pDocObject;
-+}
-+SbxVariable*
-+SbObjModule::Find( const XubString& rName, SbxClassType t )
++//=============================================================================
++module com { module sun { module star { module script {
++published constants ModuleType
+{
-+ //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 " );
-+ }
-+ }
++ const long Unknown = 0;
++ const long Normal = 1;
++ const long Class = 2;
++ const long Form = 3;
++ const long Document = 4;
++};
+
-+ 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
+diff --git udkapi/com/sun/star/script/makefile.mk udkapi/com/sun/star/script/makefile.mk
+index 745df3e..69e06dd 100644
+--- udkapi/com/sun/star/script/makefile.mk
++++ udkapi/com/sun/star/script/makefile.mk
+@@ -85,6 +85,8 @@ IDLFILES=\
+ XScriptEventsAttacher.idl\
+ XDefaultMethod.idl\
+ XDefaultProperty.idl\
++ ModuleInfo.idl\
++ ModuleType.idl\
- 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 )
- {
Modified: trunk/patches/vba/vba-allow-ranges-for-cell-functions.diff
==============================================================================
--- trunk/patches/vba/vba-allow-ranges-for-cell-functions.diff (original)
+++ trunk/patches/vba/vba-allow-ranges-for-cell-functions.diff Thu May 29 08:53:29 2008
@@ -148,10 +148,9 @@
break;
--- basic/inc/basic/sbmod.hxx 2007-09-11 10:28:53.000000000 +0100
+++ basic/inc/basic/sbmod.hxx 2007-09-11 12:45:24.000000000 +0100
-@@ -76,6 +76,7 @@ protected:
+@@ -76,5 +76,6 @@ protected:
SbiBreakpoints* pBreaks; // Breakpoints
SbClassData* pClassData;
- bool bThisWorkBook; // Should really subclass the module
+ bool mbVBACompat;
void StartDefinitions();
@@ -170,8 +169,8 @@
SbModule::SbModule( const String& rName )
: SbxObject( String( RTL_CONSTASCII_USTRINGPARAM("StarBASICModule") ) ),
-- pImage( NULL ), pBreaks( NULL ), pClassData( NULL ), bThisWorkBook( false )
-+ pImage( NULL ), pBreaks( NULL ), pClassData( NULL ), bThisWorkBook( false ), mbVBACompat( false )
+- pImage( NULL ), pBreaks( NULL ), pClassData( NULL )
++ pImage( NULL ), pBreaks( NULL ), pClassData( NULL ), mbVBACompat( false )
{
SetName( rName );
SetFlag( SBX_EXTSEARCH | SBX_GBLSEARCH );
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]