ooo-build r12038 - trunk/patches/test/vba
- From: noelpwer svn gnome org
- To: svn-commits-list gnome org
- Subject: ooo-build r12038 - trunk/patches/test/vba
- Date: Fri, 28 Mar 2008 11:19:10 +0000 (GMT)
Author: noelpwer
Date: Fri Mar 28 11:19:10 2008
New Revision: 12038
URL: http://svn.gnome.org/viewvc/ooo-build?rev=12038&view=rev
Log:
snapshot of (ropey) userform hacking, additionally this combines ( modified versions ) the following patches, ModuleInfo.diff, ObjectModule.diff,
dialog-vba-fake-events.diff & vbaevents-services-sources.diff
Added:
trunk/patches/test/vba/UserFormObjectModuleEventsSuperBigPatch.diff
Added: trunk/patches/test/vba/UserFormObjectModuleEventsSuperBigPatch.diff
==============================================================================
--- (empty file)
+++ trunk/patches/test/vba/UserFormObjectModuleEventsSuperBigPatch.diff Fri Mar 28 11:19:10 2008
@@ -0,0 +1,3895 @@
+--- /dev/null 2007-05-04 11:54:36.000000000 +0100
++++ udkapi/com/sun/star/script/ModuleType.idl 2008-03-20 10:25:13.000000000 +0000
+@@ -0,0 +1,58 @@
++/*************************************************************************
++ *
++ * OpenOffice.org - a multi-platform office productivity suite
++ *
++ * $RCSfile: ModuleType.idl,v $
++ *
++ * $Revision: 1.2 $
++ *
++ * last change: $Author: rt $ $Date: 2006/05/05 10:14:46 $
++ *
++ * The Contents of this file are made available subject to
++ * the terms of GNU Lesser General Public License Version 2.1.
++ *
++ *
++ * GNU Lesser General Public License Version 2.1
++ * =============================================
++ * Copyright 2005 by Sun Microsystems, Inc.
++ * 901 San Antonio Road, Palo Alto, CA 94303, USA
++ *
++ * This library is free software; you can redistribute it and/or
++ * modify it under the terms of the GNU Lesser General Public
++ * License version 2.1, as published by the Free Software Foundation.
++ *
++ * This library is distributed in the hope that it will be useful,
++ * but WITHOUT ANY WARRANTY; without even the implied warranty of
++ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
++ * Lesser General Public License for more details.
++ *
++ * You should have received a copy of the GNU Lesser General Public
++ * License along with this library; if not, write to the Free Software
++ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
++ * MA 02111-1307 USA
++ *
++ ************************************************************************/
++
++#ifndef __com_sun_star_script_ModuleType_idl__
++#define __com_sun_star_script_ModuleType_idl__
++
++#ifndef __com_sun_star_uno_XInterface_idl__
++#include <com/sun/star/uno/XInterface.idl>
++#endif
++
++//=============================================================================
++module com { module sun { module star { module script {
++published constants ModuleType
++{
++ const long Unknown = 0;
++ const long Normal = 1;
++ const long Class = 2;
++ const long Form = 3;
++ const long Document = 4;
++};
++
++//=============================================================================
++
++}; }; }; };
++
++#endif
+--- /dev/null 2007-05-04 11:54:36.000000000 +0100
++++ udkapi/com/sun/star/script/ModuleInfo.idl 2008-03-20 15:16:05.000000000 +0000
+@@ -0,0 +1,57 @@
++/*************************************************************************
++ *
++ * OpenOffice.org - a multi-platform office productivity suite
++ *
++ * $RCSfile: ModuleInfo.idl,v $
++ *
++ * $Revision: 1.2 $
++ *
++ * last change: $Author: rt $ $Date: 2006/05/05 10:14:46 $
++ *
++ * The Contents of this file are made available subject to
++ * the terms of GNU Lesser General Public License Version 2.1.
++ *
++ *
++ * GNU Lesser General Public License Version 2.1
++ * =============================================
++ * Copyright 2005 by Sun Microsystems, Inc.
++ * 901 San Antonio Road, Palo Alto, CA 94303, USA
++ *
++ * This library is free software; you can redistribute it and/or
++ * modify it under the terms of the GNU Lesser General Public
++ * License version 2.1, as published by the Free Software Foundation.
++ *
++ * This library is distributed in the hope that it will be useful,
++ * but WITHOUT ANY WARRANTY; without even the implied warranty of
++ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
++ * Lesser General Public License for more details.
++ *
++ * You should have received a copy of the GNU Lesser General Public
++ * License along with this library; if not, write to the Free Software
++ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
++ * MA 02111-1307 USA
++ *
++ ************************************************************************/
++
++#ifndef __com_sun_star_script_ModuleInfo_idl__
++#define __com_sun_star_script_ModuleInfo_idl__
++
++#ifndef __com_sun_star_uno_XInterface_idl__
++#include <com/sun/star/uno/XInterface.idl>
++#endif
++
++//=============================================================================
++module com { module sun { module star { module script {
++struct ModuleInfo
++{
++ string ModuleName;
++ string ModuleSource;
++ com::sun::star::uno::XInterface ModuleObjectProvider;
++ short ModuleType; // string?
++};
++
++//=============================================================================
++
++}; }; }; };
++
++#endif
+--- /dev/null 2007-05-04 11:54:36.000000000 +0100
++++ udkapi/com/sun/star/script/XObjectProvider.idl 2008-03-20 10:25:13.000000000 +0000
+@@ -0,0 +1,52 @@
++/*************************************************************************
++ *
++ * OpenOffice.org - a multi-platform office productivity suite
++ *
++ * $RCSfile: XDefaultMethod.idl,v $
++ *
++ * $Revision: 1.3 $
++ *
++ * last change: $Author: vg $ $Date: 2006/11/02 16:34:45 $
++ *
++ * The Contents of this file are made available subject to
++ * the terms of GNU Lesser General Public License Version 2.1.
++ *
++ *
++ * GNU Lesser General Public License Version 2.1
++ * =============================================
++ * Copyright 2005 by Sun Microsystems, Inc.
++ * 901 San Antonio Road, Palo Alto, CA 94303, USA
++ *
++ * This library is free software; you can redistribute it and/or
++ * modify it under the terms of the GNU Lesser General Public
++ * License version 2.1, as published by the Free Software Foundation.
++ *
++ * This library is distributed in the hope that it will be useful,
++ * but WITHOUT ANY WARRANTY; without even the implied warranty of
++ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
++ * Lesser General Public License for more details.
++ *
++ * You should have received a copy of the GNU Lesser General Public
++ * License along with this library; if not, write to the Free Software
++ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
++ * MA 02111-1307 USA
++ *
++ ************************************************************************/
++
++#ifndef __com_sun_star_script_XObjectProvider_idl__
++#define __com_sun_star_script_XObjectProvider_idl__
++
++#ifndef __com_sun_star_uno_XInterface_idl__
++#include <com/sun/star/uno/XInterface.idl>
++#endif
++
++module com { module sun { module star { module script {
++//==============================================================================
++interface XObjectProvider : ::com::sun::star::uno::XInterface
++{
++ any getObject();
++
++};
++
++}; }; }; };
++#endif
+diff -rup /esata1/BUILD-related/HEAD/ooo-build/build/ooh680-m12/udkapi/com/sun/star/script/makefile.mk udkapi/com/sun/star/script/makefile.mk
+--- /esata1/BUILD-related/HEAD/ooo-build/build/ooh680-m12/udkapi/com/sun/star/script/makefile.mk 2008-03-19 10:56:58.000000000 +0000
++++ udkapi/com/sun/star/script/makefile.mk 2008-03-20 10:25:13.000000000 +0000
+@@ -89,6 +89,9 @@ IDLFILES=\
+ XScriptEventsAttacher.idl\
+ XDefaultMethod.idl\
+ XDefaultProperty.idl\
++ ModuleInfo.idl\
++ ModuleType.idl\
++ XObjectProvider.idl\
+ DateType.idl\
+
+ # ------------------------------------------------------------------
+diff -rup /esata1/BUILD-related/HEAD/ooo-build/build/ooh680-m12/svx/source/msfilter/msvbasic.cxx svx/source/msfilter/msvbasic.cxx
+--- /esata1/BUILD-related/HEAD/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-20 10:41:41.000000000 +0000
+@@ -54,6 +54,8 @@
+ #include "msvbasic.hxx"
+ #endif
+
++using namespace ::com::sun::star::script;
++
+ /*
+ A few urls which may in the future be of some use
+ http://www.virusbtn.com/vb2000/Programme/papers/bontchev.pdf
+@@ -445,7 +447,7 @@ int VBA_Impl::ReadVBAProject(const SvSto
+ *
+ */
+
+-ModuleType VBA_Impl::GetModuleType( const UniString& rModuleName )
++ModType VBA_Impl::GetModuleType( const UniString& rModuleName )
+ {
+ ModuleTypeHash::iterator iter = mhModHash.find( rModuleName );
+ ModuleTypeHash::iterator iterEnd = mhModHash.end();
+@@ -453,7 +455,7 @@ ModuleType VBA_Impl::GetModuleType( cons
+ {
+ return iter->second;
+ }
+- return Unknown;
++ return ModuleType::Unknown;
+ }
+
+ bool VBA_Impl::Open( const String &rToplevel, const String &rSublevel )
+@@ -496,7 +498,7 @@ bool VBA_Impl::Open( const String &rTopl
+ static const String sClass( RTL_CONSTASCII_USTRINGPARAM( "Class" ) );
+ static const String sBaseClass( RTL_CONSTASCII_USTRINGPARAM( "BaseClass" ) );
+ static const String sDocument( RTL_CONSTASCII_USTRINGPARAM( "Document" ) );
+- mhModHash[ sThisDoc ] = Class;
++ mhModHash[ sThisDoc ] = ModuleType::Class;
+ while ( pStp->ReadByteStringLine( tmp, meCharSet ) )
+ {
+ xub_StrLen index = tmp.Search( '=' );
+@@ -506,14 +508,14 @@ bool VBA_Impl::Open( const String &rTopl
+ String value = tmp.Copy( index + 1 );
+ if ( key == sClass )
+ {
+- mhModHash[ value ] = Class;
++ mhModHash[ value ] = ModuleType::Class;
+ OSL_TRACE("Module %s is of type Class",
+ ::rtl::OUStringToOString( value ,
+ RTL_TEXTENCODING_ASCII_US ).pData->buffer );
+ }
+ else if ( key == sBaseClass )
+ {
+- mhModHash[ value ] = Form;
++ mhModHash[ value ] = ModuleType::Form;
+ OSL_TRACE("Module %s is of type Form",
+ ::rtl::OUStringToOString( value ,
+ RTL_TEXTENCODING_ASCII_US ).pData->buffer );
+@@ -526,14 +528,14 @@ bool VBA_Impl::Open( const String &rTopl
+ // value is of form <name>/&H<identifier>, strip the identifier
+ value.Erase( value.Search( '/' ) );
+
+- mhModHash[ value ] = Document;
++ mhModHash[ value ] = ModuleType::Document;
+ OSL_TRACE("Module %s is of type Document VBA",
+ ::rtl::OUStringToOString( value ,
+ RTL_TEXTENCODING_ASCII_US ).pData->buffer );
+ }
+ else if ( key == sModule )
+ {
+- mhModHash[ value ] = Normal;
++ mhModHash[ value ] = ModuleType::Normal;
+ OSL_TRACE("Module %s is of type Normal VBA",
+ ::rtl::OUStringToOString( value ,
+ RTL_TEXTENCODING_ASCII_US ).pData->buffer );
+diff -rup /esata1/BUILD-related/HEAD/ooo-build/build/ooh680-m12/svx/source/msfilter/msvbasic.hxx svx/source/msfilter/msvbasic.hxx
+--- /esata1/BUILD-related/HEAD/ooo-build/build/ooh680-m12/svx/source/msfilter/msvbasic.hxx 2006-06-19 17:20:43.000000000 +0100
++++ svx/source/msfilter/msvbasic.hxx 2008-03-20 10:25:13.000000000 +0000
+@@ -50,11 +50,13 @@
+ #ifndef _DYNARY_HXX
+ #include <tools/dynary.hxx>
+ #endif
++#include <com/sun/star/script/ModuleType.hpp>
+ #ifndef __SGI_STL_VECTOR
+ #include <vector>
+ #endif
+ #include<map>
+
++using namespace ::com::sun::star::script::ModuleType;
+ /* class VBA:
+ * The VBA class provides a set of methods to handle Visual Basic For
+ * Applications streams, the constructor is given the root ole2 stream
+@@ -77,13 +79,13 @@ 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 };
++//enum ModuleType { Unknown = 0, Normal, Class, Form, Document };
+
+ // #117718# define map to hold types of module
+ //
+-
++typedef sal_Int32 ModType;
+ typedef ::std::map< UniString,
+- ModuleType > ModuleTypeHash;
++ ModType > ModuleTypeHash;
+
+ class VBA_Impl
+ {
+@@ -104,7 +106,7 @@ public:
+ void Output(int len, const sal_uInt8 *data);
+ //
+ // #117718# member map of module names to types of module
+- ModuleType GetModuleType( const UniString& rModuleName );
++ ModType GetModuleType( const UniString& rModuleName );
+
+ std::vector<String> maReferences;
+ private:
+diff -rup /esata1/BUILD-related/HEAD/ooo-build/build/ooh680-m12/svx/source/msfilter/svxmsbas.cxx svx/source/msfilter/svxmsbas.cxx
+--- /esata1/BUILD-related/HEAD/ooo-build/build/ooh680-m12/svx/source/msfilter/svxmsbas.cxx 2007-12-07 12:21:21.000000000 +0000
++++ svx/source/msfilter/svxmsbas.cxx 2008-03-26 12:50:56.000000000 +0000
+@@ -88,6 +88,8 @@ using namespace com::sun::star::awt;
+
+ #include <com/sun/star/container/XNameContainer.hpp>
+ #include <com/sun/star/script/XLibraryContainer.hpp>
++#include <com/sun/star/script/ModuleInfo.hpp>
++#include <com/sun/star/script/XObjectProvider.hpp>
+ using namespace com::sun::star::container;
+ using namespace com::sun::star::script;
+ using namespace com::sun::star::uno;
+@@ -319,7 +321,7 @@ BOOL SvxImportMSVBasic::ImportCode_Impl(
+ // is the same as the encoding for the names
+ // that are keys in the map used by GetModuleType method
+ const String &sOrigVBAModName = aVBA.GetStreamName( i );
+- ModuleType mType = aVBA.GetModuleType( sOrigVBAModName );
++ ModType mType = aVBA.GetModuleType( sOrigVBAModName );
+
+ rtl::OUString sClassRem( RTL_CONSTASCII_USTRINGPARAM( "Rem Attribute VBA_ModuleType=" ) );
+
+@@ -327,23 +329,23 @@ BOOL SvxImportMSVBasic::ImportCode_Impl(
+
+ switch( mType )
+ {
+- case Class:
++ case ModuleType::Class:
+ modeTypeComment = sClassRem +
+ ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "VBAClassModule\n" ) );
+ break;
+- case Form:
++ case ModuleType::Form:
+ modeTypeComment = sClassRem +
+ ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "VBAFormModule\n" ) );
+ break;
+- case Document:
++ case ModuleType::Document:
+ modeTypeComment = sClassRem +
+ ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "VBADocumentModule\n" ) );
+ break;
+- case Normal:
++ case ModuleType::Normal:
+ modeTypeComment = sClassRem +
+ ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "VBAModule\n" ) );
+ break;
+- case Unknown:
++ case ModuleType::Unknown:
+ modeTypeComment = sClassRem +
+ ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "VBAUnknown\n" ) );
+ break;
+@@ -356,7 +358,7 @@ BOOL SvxImportMSVBasic::ImportCode_Impl(
+ if ( !bAsComment )
+ {
+ modeTypeComment = modeTypeComment + sVBAOption;
+- if ( mType == Class )
++ if ( mType == ModuleType::Class )
+ modeTypeComment = modeTypeComment + sClassOption;
+
+ }
+@@ -418,12 +420,39 @@ BOOL SvxImportMSVBasic::ImportCode_Impl(
+ aSource += rtl::OUString::createFromAscii("\nEnd Sub");
+ }
+ ::rtl::OUString aModName( sModule );
+- if ( aSource.getLength() )
+ {
++ Reference< script::XObjectProvider > xVBAObjectProvider;
++ if( mType == ModuleType::Document )
++ {
++ Reference< XMultiServiceFactory> xSF(rDocSh.GetModel(), UNO_QUERY);
++ if ( xSF.is() )
++ {
++ try
++ {
++ uno::Sequence< uno::Any > aArgs(1);
++ aArgs[0] = uno::Any( aModName );
++ xVBAObjectProvider.set( xSF->createInstanceWithArguments( rtl::OUString(RTL_CONSTASCII_USTRINGPARAM( "org.openoffice.vba.VBAObjectModuleObjectProvider")), aArgs), UNO_QUERY );
++ }
++ catch( Exception& ) { }
++ }
++ }
+ aSource = modeTypeComment + aSource;
+
+ Any aSourceAny;
+- aSourceAny <<= aSource;
++ if ( !bAsComment && ( xVBAObjectProvider.is() && mType == ModuleType::Document ) || mType == ModuleType::Form )
++ {
++ script::ModuleInfo sModuleInfo;
++ sModuleInfo.ModuleName = aModName;
++ sModuleInfo.ModuleSource = aSource;
++ sModuleInfo.ModuleType = mType;
++ if ( mType == ModuleType::Form )
++ sModuleInfo.ModuleObjectProvider.set( rDocSh.GetModel(), UNO_QUERY );
++ else
++ sModuleInfo.ModuleObjectProvider.set( xVBAObjectProvider, UNO_QUERY );
++ aSourceAny <<= sModuleInfo;
++ }
++ else
++ aSourceAny <<= aSource;
+ if( xLib->hasByName( aModName ) )
+ xLib->replaceByName( aModName, aSourceAny );
+ else
+@@ -433,6 +462,8 @@ BOOL SvxImportMSVBasic::ImportCode_Impl(
+ bRet = true;
+ }
+ }
++ if( bRet )
++ rDocSh.GetBasic()->SetVBAEnabled( true );
+ SFX_APP()->LeaveBasicCall();
+ }
+ return bRet;
+diff -rup /esata1/BUILD-related/HEAD/ooo-build/build/ooh680-m12/sc/inc/document.hxx sc/inc/document.hxx
+--- /esata1/BUILD-related/HEAD/ooo-build/build/ooh680-m12/sc/inc/document.hxx 2008-03-19 10:57:03.000000000 +0000
++++ sc/inc/document.hxx 2008-03-20 10:25:13.000000000 +0000
+@@ -308,6 +308,7 @@ private:
+
+ com::sun::star::uno::Sequence<sal_Int8> aProtectPass;
+ String aDocName; // opt: Dokumentname
++ String aDocCodeName; // opt: Dokumentname
+ ScRangePairListRef xColNameRanges;
+ ScRangePairListRef xRowNameRanges;
+
+@@ -451,6 +452,8 @@ public:
+
+ const String& GetName() const { return aDocName; }
+ void SetName( const String& r ) { aDocName = r; }
++ const String& GetCodeName() const { return aDocCodeName; }
++ void SetCodeName( const String& r ) { aDocCodeName = r; }
+
+ void GetDocStat( ScDocStat& rDocStat );
+
+@@ -538,6 +541,8 @@ SC_DLLPUBLIC ScDBCollection* GetDBCollec
+
+ BOOL HasTable( SCTAB nTab ) const;
+ SC_DLLPUBLIC BOOL GetName( SCTAB nTab, String& rName ) const;
++ SC_DLLPUBLIC BOOL GetCodeName( SCTAB nTab, String& rName ) const;
++ SC_DLLPUBLIC BOOL SetCodeName( SCTAB nTab, String& rName );
+ BOOL GetTable( const String& rName, SCTAB& rTab ) const;
+ inline SCTAB GetTableCount() const { return nMaxTableNumber; }
+ SvNumberFormatterIndexTable* GetFormatExchangeList() const { return pFormatExchangeList; }
+diff -rup /esata1/BUILD-related/HEAD/ooo-build/build/ooh680-m12/sc/inc/servuno.hxx sc/inc/servuno.hxx
+--- /esata1/BUILD-related/HEAD/ooo-build/build/ooh680-m12/sc/inc/servuno.hxx 2008-03-19 10:57:00.000000000 +0000
++++ sc/inc/servuno.hxx 2008-03-25 12:39:27.000000000 +0000
+@@ -103,7 +103,9 @@ class ScDocShell;
+ #define SC_SERVICE_FORMULAPARS 38
+ #define SC_SERVICE_OPCODEMAPPER 39
+
+-#define SC_SERVICE_COUNT 40
++#define SC_SERVICE_VBAOBJECTPROVIDER 40
++#define SC_SERVICE_VBACONTROL_EVENTS 41
++#define SC_SERVICE_COUNT 42
+ #define SC_SERVICE_INVALID USHRT_MAX
+
+
+diff -rup /esata1/BUILD-related/HEAD/ooo-build/build/ooh680-m12/sc/inc/table.hxx sc/inc/table.hxx
+--- /esata1/BUILD-related/HEAD/ooo-build/build/ooh680-m12/sc/inc/table.hxx 2008-03-19 10:57:03.000000000 +0000
++++ sc/inc/table.hxx 2008-03-20 10:25:13.000000000 +0000
+@@ -104,6 +104,7 @@ private:
+ ScColumn aCol[MAXCOLCOUNT];
+
+ String aName;
++ String aCodeName;
+ String aComment;
+ BOOL bScenario;
+ BOOL bLayoutRTL;
+@@ -237,6 +238,9 @@ public:
+ void GetName( String& rName ) const;
+ void SetName( const String& rNewName );
+
++ void GetCodeName( String& rName ) const { rName = aCodeName; }
++ void SetCodeName( const String& rNewName ) { aCodeName = rNewName; }
++
+ const String& GetUpperName() const;
+
+ const String& GetPageStyle() const { return aPageStyle; }
+diff -rup /esata1/BUILD-related/HEAD/ooo-build/build/ooh680-m12/sc/source/core/data/document.cxx sc/source/core/data/document.cxx
+--- /esata1/BUILD-related/HEAD/ooo-build/build/ooh680-m12/sc/source/core/data/document.cxx 2008-03-19 10:57:00.000000000 +0000
++++ sc/source/core/data/document.cxx 2008-03-20 10:25:13.000000000 +0000
+@@ -101,6 +101,7 @@
+ #include "scextopt.hxx"
+ #include "postit.hxx"
+
++
+ struct ScDefaultAttr
+ {
+ const ScPatternAttr* pAttr;
+@@ -155,6 +156,32 @@ BOOL ScDocument::GetName( SCTAB nTab, St
+ return FALSE;
+ }
+
++BOOL ScDocument::SetCodeName( SCTAB nTab, String& rName )
++{
++ if (VALIDTAB(nTab))
++ {
++ if (pTab[nTab])
++ {
++ pTab[nTab]->SetCodeName( rName );
++ return TRUE;
++ }
++ }
++ OSL_TRACE( "**** can't set code name %s", rtl::OUStringToOString( rName, RTL_TEXTENCODING_UTF8 ).getStr() );
++ return FALSE;
++}
++
++BOOL ScDocument::GetCodeName( SCTAB nTab, String& rName ) const
++{
++ if (VALIDTAB(nTab))
++ if (pTab[nTab])
++ {
++ pTab[nTab]->GetCodeName( rName );
++ return TRUE;
++ }
++ rName.Erase();
++ return FALSE;
++}
++
+
+ BOOL ScDocument::GetTable( const String& rName, SCTAB& rTab ) const
+ {
+@@ -280,7 +307,6 @@ void ScDocument::CreateValidTabName(Stri
+ }
+ }
+
+-
+ BOOL ScDocument::InsertTab( SCTAB nPos, const String& rName,
+ BOOL bExternalDocument )
+ {
+@@ -294,12 +320,7 @@ BOOL ScDocument::InsertTab( SCTAB nPos,
+ if (nPos == SC_TAB_APPEND || nPos == nTabCount)
+ {
+ pTab[nTabCount] = new ScTable(this, nTabCount, rName);
+- // if we are mapping codenames then a new tab always has has
+- // codename = sheetname
+- if ( pExtOptions && ( pExtOptions->GetCodeNameCount() > 0 ) )
+- {
+- pExtOptions->SetCodeName( rName, nTabCount );
+- }
++ pTab[nTabCount]->SetCodeName( rName );
+ ++nMaxTableNumber;
+ if ( bExternalDocument )
+ pTab[nTabCount]->SetVisible( FALSE );
+@@ -334,24 +355,10 @@ BOOL ScDocument::InsertTab( SCTAB nPos,
+ for (i = nTabCount; i > nPos; i--)
+ {
+ pTab[i] = pTab[i - 1];
+- if ( pTab[i] && pExtOptions && ( pExtOptions->GetCodeNameCount() > 0 ) )
+- {
+- String sCodeName = pExtOptions->GetCodeName( i - 1 );
+- if ( sCodeName.Len() )
+- {
+- OSL_TRACE("Associating codeName %s with tab %d", rtl::OUStringToOString( sCodeName, RTL_TEXTENCODING_UTF8 ).getStr(), i );
+- pExtOptions->SetCodeName( sCodeName, i );
+- }
+- }
+- }
+-
+- if ( pExtOptions && ( pExtOptions->GetCodeNameCount() > 0 ) )
+- {
+- OSL_TRACE("Inserting codeName %s with tab %d", rtl::OUStringToOString( rName, RTL_TEXTENCODING_UTF8 ).getStr(),nPos );
+- pExtOptions->SetCodeName( rName, nPos );
+ }
+
+ pTab[nPos] = new ScTable(this, nPos, rName);
++ pTab[nPos]->SetCodeName( rName );
+ ++nMaxTableNumber;
+
+ for (i = 0; i <= MAXTAB; i++)
+@@ -441,22 +448,7 @@ BOOL ScDocument::DeleteTab( SCTAB nTab,
+ delete pTab[nTab];
+ for (i=nTab + 1; i < nTabCount; i++)
+ {
+- if ( pTab[i - 1 ] && pExtOptions && ( pExtOptions->GetCodeNameCount() > 0 ) )
+- {
+- String sCodeName = pExtOptions->GetCodeName( i );
+- if ( sCodeName.Len() )
+- {
+- OSL_TRACE("Associating codeName %s with tab %d", rtl::OUStringToOString( sCodeName, RTL_TEXTENCODING_UTF8 ).getStr(), i - 1 );
+- pExtOptions->SetCodeName( sCodeName, i - 1 );
+- }
+- }
+ pTab[i - 1] = pTab[i];
+-
+- }
+- if ( pTab[i - 1 ] && pExtOptions && ( pExtOptions->GetCodeNameCount() > 0 ) )
+- {
+- OSL_TRACE("Deleting codename %s as %d", rtl::OUStringToOString( pExtOptions->GetCodeName( nTabCount-1 ), RTL_TEXTENCODING_UTF8 ).getStr(), nTabCount - 1 ) ;
+- pExtOptions->DeleteCodeName( nTabCount - 1 );
+ }
+
+ pTab[nTabCount - 1] = NULL;
+diff -rup /esata1/BUILD-related/HEAD/ooo-build/build/ooh680-m12/sc/source/core/data/table1.cxx sc/source/core/data/table1.cxx
+--- /esata1/BUILD-related/HEAD/ooo-build/build/ooh680-m12/sc/source/core/data/table1.cxx 2008-03-19 10:57:03.000000000 +0000
++++ sc/source/core/data/table1.cxx 2008-03-25 14:26:21.000000000 +0000
+@@ -130,6 +130,7 @@ extern BOOL bIsOlk, bOderSo;
+ ScTable::ScTable( ScDocument* pDoc, SCTAB nNewTab, const String& rNewName,
+ BOOL bColInfo, BOOL bRowInfo ) :
+ aName( rNewName ),
++ aCodeName( rNewName ),
+ bScenario( FALSE ),
+ bLayoutRTL( FALSE ),
+ bLoadingRTL( FALSE ),
+@@ -161,7 +162,7 @@ ScTable::ScTable( ScDocument* pDoc, SCTA
+ bActiveScenario( FALSE ),
+ pViewOptions( NULL )
+ {
+-
++OSL_TRACE("!!!!ScTab created!!!");
+ if (bColInfo)
+ {
+ pColWidth = new USHORT[ MAXCOL+1 ];
+diff -rup /esata1/BUILD-related/HEAD/ooo-build/build/ooh680-m12/sc/source/filter/excel/excimp8.cxx sc/source/filter/excel/excimp8.cxx
+--- /esata1/BUILD-related/HEAD/ooo-build/build/ooh680-m12/sc/source/filter/excel/excimp8.cxx 2008-03-19 10:56:44.000000000 +0000
++++ sc/source/filter/excel/excimp8.cxx 2008-03-20 10:25:13.000000000 +0000
+@@ -148,7 +148,7 @@ using namespace com::sun::star;
+
+
+ ImportExcel8::ImportExcel8( XclImpRootData& rImpData, SvStream& rStrm ) :
+- ImportExcel( rImpData, rStrm )
++ ImportExcel( rImpData, rStrm ), mnTab(0)
+ {
+ delete pFormConv;
+
+@@ -290,9 +290,15 @@ void ImportExcel8::Codename( BOOL bWorkb
+ if( aName.Len() )
+ {
+ if( bWorkbookGlobals )
+- GetExtDocOptions().GetDocSettings().maGlobCodeName = aName;
++ {
++ //GetExtDocOptions().GetDocSettings().maGlobCodeName = aName;
++ GetDoc().SetCodeName( aName );
++ }
+ else
+- GetExtDocOptions().AppendCodeName( aName );
++ {
++ //GetExtDocOptions().AppendCodeName( aName );
++ GetDoc().SetCodeName( mnTab++, aName );
++ }
+ }
+ }
+ }
+diff -rup /esata1/BUILD-related/HEAD/ooo-build/build/ooh680-m12/sc/source/filter/inc/excimp8.hxx sc/source/filter/inc/excimp8.hxx
+--- /esata1/BUILD-related/HEAD/ooo-build/build/ooh680-m12/sc/source/filter/inc/excimp8.hxx 2008-03-19 10:56:44.000000000 +0000
++++ sc/source/filter/inc/excimp8.hxx 2008-03-20 10:25:13.000000000 +0000
+@@ -69,6 +69,7 @@ class XclImpStream;
+
+ class ImportExcel8 : public ImportExcel
+ {
++ SCTAB mnTab;
+ protected:
+ ExcScenarioList aScenList;
+
+diff -rup /esata1/BUILD-related/HEAD/ooo-build/build/ooh680-m12/sc/source/ui/docshell/docfunc.cxx sc/source/ui/docshell/docfunc.cxx
+--- /esata1/BUILD-related/HEAD/ooo-build/build/ooh680-m12/sc/source/ui/docshell/docfunc.cxx 2008-03-19 10:57:00.000000000 +0000
++++ sc/source/ui/docshell/docfunc.cxx 2008-03-25 15:32:25.000000000 +0000
+@@ -58,6 +58,13 @@
+ #include <svtools/PasswordHelper.hxx>
+ #endif
+
++#include <basic/sbstar.hxx>
++#include <com/sun/star/container/XNameContainer.hpp>
++#include <com/sun/star/script/XLibraryContainer.hpp>
++#include <com/sun/star/script/ModuleInfo.hpp>
++#include <com/sun/star/script/ModuleType.hpp>
++#include <com/sun/star/script/XObjectProvider.hpp>
++
+ #include <list>
+
+ #include "docfunc.hxx"
+@@ -101,6 +108,7 @@
+ #include "scui_def.hxx" //CHINA001
+ using namespace com::sun::star;
+
++
+ // STATIC DATA -----------------------------------------------------------
+
+ //========================================================================
+@@ -2022,6 +2030,86 @@ BOOL ScDocFunc::MoveBlock( const ScRange
+ }
+
+ //------------------------------------------------------------------------
++script::ModuleInfo lcl_InitModuleInfo( ScDocShell& rDocSh, String& sModule )
++{
++ ::rtl::OUString aModName( sModule );
++ uno::Reference< lang::XMultiServiceFactory> xSF(rDocSh.GetModel(), uno::UNO_QUERY);
++ uno::Reference< script::XObjectProvider > xVBAObjectProvider;
++ if ( xSF.is() )
++ {
++ uno::Sequence< uno::Any > aArgs(1);
++ aArgs[0] = uno::Any( aModName );
++ xVBAObjectProvider.set( xSF->createInstanceWithArguments( rtl::OUString(RTL_CONSTASCII_USTRINGPARAM( "org.openoffice.vba.VBAObjectModuleObjectProvider")), aArgs), uno::UNO_QUERY );
++ }
++ script::ModuleInfo sModuleInfo;
++ ::rtl::OUString sVbaOption( RTL_CONSTASCII_USTRINGPARAM( "Rem Attribute VBA_ModuleType=VBADocumentModule\nOption VBASupport 1\n" ));
++ sModuleInfo.ModuleName = aModName;
++ sModuleInfo.ModuleSource = sVbaOption;
++ sModuleInfo.ModuleType = script::ModuleType::Document;
++ sModuleInfo.ModuleObjectProvider.set( xVBAObjectProvider, uno::UNO_QUERY );
++ return sModuleInfo;
++}
++
++void lcl_InsertModule( ScDocShell& rDocSh, SCTAB nTab, String& sModuleName )
++{
++ SFX_APP()->EnterBasicCall();
++ script::ModuleInfo sModuleInfo = lcl_InitModuleInfo( rDocSh, sModuleName );
++ uno::Reference< script::XLibraryContainer > xLibContainer = rDocSh.GetBasicContainer();
++ DBG_ASSERT( xLibContainer.is(), "No BasicContainer!" );
++
++ uno::Reference< container::XNameContainer > xLib;
++ if( xLibContainer.is() )
++ {
++ String aLibName( RTL_CONSTASCII_USTRINGPARAM( "Standard" ) );
++ uno::Any aLibAny = xLibContainer->getByName( aLibName );
++ aLibAny >>= xLib;
++ }
++ if( xLib.is() )
++ {
++ // test Module has exist
++ // if the Module is exist. changed to another name
++ // and at this time the string like "SheetX"
++ rtl::OUString sModuleName( sModuleInfo.ModuleName );
++ sal_Int32 nNum = 1;
++ while( xLib->hasByName( sModuleName ) )
++ {
++ sModuleName = rtl::OUString::createFromAscii( "Sheet" ) + rtl::OUString::valueOf( nNum );
++ nNum += 1;
++ }
++ sModuleInfo.ModuleName = sModuleName;
++ uno::Any aSourceAny;
++ aSourceAny <<= sModuleInfo;
++ xLib->insertByName( sModuleName, aSourceAny );
++ ScDocument* pDoc = rDocSh.GetDocument();
++ String sCodeName( sModuleName );
++ pDoc->SetCodeName( nTab, sCodeName );
++ }
++ SFX_APP()->LeaveBasicCall();
++}
++
++void lcl_DeleteModule( ScDocShell& rDocSh, String& sModuleName )
++{
++ SFX_APP()->EnterBasicCall();
++ uno::Reference< script::XLibraryContainer > xLibContainer = rDocSh.GetBasicContainer();
++ DBG_ASSERT( xLibContainer.is(), "No BasicContainer!" );
++
++ uno::Reference< container::XNameContainer > xLib;
++ if( xLibContainer.is() )
++ {
++ String aLibName( RTL_CONSTASCII_USTRINGPARAM( "Standard" ) );
++ uno::Any aLibAny = xLibContainer->getByName( aLibName );
++ aLibAny >>= xLib;
++ }
++ if( xLib.is() )
++ {
++ if( xLib->hasByName( sModuleName ) )
++ {
++ xLib->removeByName( sModuleName );
++ }
++ }
++ SFX_APP()->LeaveBasicCall();
++}
++
+
+ BOOL ScDocFunc::InsertTable( SCTAB nTab, const String& rName, BOOL bRecord, BOOL bApi )
+ {
+@@ -2031,8 +2119,12 @@ BOOL ScDocFunc::InsertTable( SCTAB nTab,
+ ScDocShellModificator aModificator( rDocShell );
+
+ ScDocument* pDoc = rDocShell.GetDocument();
++ StarBASIC* pStarBASIC = rDocShell.GetBasic();
++ BOOL bVbaEnabled = pStarBASIC->isVBAEnabled();
+ if (bRecord && !pDoc->IsUndoEnabled())
+ bRecord = FALSE;
++ if ( bVbaEnabled )
++ bRecord = FALSE;
+ if (bRecord)
+ pDoc->BeginDrawUndo(); // InsertTab erzeugt ein SdrUndoNewPage
+
+@@ -2047,6 +2139,11 @@ BOOL ScDocFunc::InsertTable( SCTAB nTab,
+ rDocShell.GetUndoManager()->AddUndoAction(
+ new ScUndoInsertTab( &rDocShell, nTab, bAppend, rName));
+ // Views updaten:
++ if( bVbaEnabled )
++ {
++ String sCodeName( rName );
++ lcl_InsertModule( rDocShell, nTab, sCodeName );
++ }
+ rDocShell.Broadcast( ScTablesHint( SC_TAB_INSERTED, nTab ) );
+
+ rDocShell.PostPaintExtras();
+@@ -2068,8 +2165,12 @@ BOOL ScDocFunc::DeleteTable( SCTAB nTab,
+
+ BOOL bSuccess = FALSE;
+ ScDocument* pDoc = rDocShell.GetDocument();
++ StarBASIC* pStarBASIC = rDocShell.GetBasic();
++ BOOL bVbaEnabled = pStarBASIC->isVBAEnabled();
+ if (bRecord && !pDoc->IsUndoEnabled())
+ bRecord = FALSE;
++ if ( bVbaEnabled )
++ bRecord = FALSE;
+ BOOL bWasLinked = pDoc->IsLinked(nTab);
+ ScDocument* pUndoDoc = NULL;
+ ScRefUndoData* pUndoData = NULL;
+@@ -2110,6 +2211,8 @@ BOOL ScDocFunc::DeleteTable( SCTAB nTab,
+ pUndoData = new ScRefUndoData( pDoc );
+ }
+
++ String sCodeName;
++ BOOL bHasCodeName = pDoc->GetCodeName( nTab, sCodeName );
+ if (pDoc->DeleteTab( nTab, pUndoDoc ))
+ {
+ if (bRecord)
+@@ -2120,6 +2223,13 @@ BOOL ScDocFunc::DeleteTable( SCTAB nTab,
+ new ScUndoDeleteTab( &rDocShell, theTabs, pUndoDoc, pUndoData ));
+ }
+ // Views updaten:
++ if( bVbaEnabled )
++ {
++ if( bHasCodeName )
++ {
++ lcl_DeleteModule( rDocShell, sCodeName );
++ }
++ }
+ rDocShell.Broadcast( ScTablesHint( SC_TAB_DELETED, nTab ) );
+
+ if (bWasLinked)
+diff -rup /esata1/BUILD-related/HEAD/ooo-build/build/ooh680-m12/sc/source/ui/unoobj/makefile.mk sc/source/ui/unoobj/makefile.mk
+--- /esata1/BUILD-related/HEAD/ooo-build/build/ooh680-m12/sc/source/ui/unoobj/makefile.mk 2008-03-19 10:57:00.000000000 +0000
++++ sc/source/ui/unoobj/makefile.mk 2008-03-20 10:25:13.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 /esata1/BUILD-related/HEAD/ooo-build/build/ooh680-m12/sc/source/ui/unoobj/servuno.cxx sc/source/ui/unoobj/servuno.cxx
+--- /esata1/BUILD-related/HEAD/ooo-build/build/ooh680-m12/sc/source/ui/unoobj/servuno.cxx 2008-03-19 10:57:00.000000000 +0000
++++ sc/source/ui/unoobj/servuno.cxx 2008-03-25 13:46:23.000000000 +0000
+@@ -46,10 +46,19 @@
+ #include <svx/unonrule.hxx>
+ #endif
+
++#include <com/sun/star/script/XEventAttacherManager.hpp>
++#include <com/sun/star/form/XFormsSupplier.hpp>
++#include <org/openoffice/vba/XVBAToOOEventDescGen.hpp>
++#include <org/openoffice/vba/XFakeVBAEventDescriptorSupplier.hpp>
++#include <comphelper/processfactory.hxx>
++
+ #ifndef _COM_SUN_STAR_SHEET_XSPREADSHEETDOCUMENT_HPP_
+ #include <com/sun/star/sheet/XSpreadsheetDocument.hpp>
+ #endif
+
++#include <com/sun/star/drawing/XDrawPagesSupplier.hpp>
++#include <com/sun/star/drawing/XControlShape.hpp>
++
+ #include "servuno.hxx"
+ #include "unonames.hxx"
+ #include "cellsuno.hxx"
+@@ -77,8 +86,160 @@
+ #include <svx/xmlgrhlp.hxx>
+ #endif
+
++#include "scextopt.hxx"
++#include <com/sun/star/script/XObjectProvider.hpp>
++#include <comphelper/processfactory.hxx>
++
+ using namespace ::com::sun::star;
+
++typedef ::cppu::WeakImplHelper1< org::openoffice::vba::XFakeVBAEventDescriptorSupplier > Initialization_BASE;
++
++class ScFakeVBACntrlEvtSupport : public Initialization_BASE
++{
++ ScDocShell* mpDoc;
++ ScFakeVBACntrlEvtSupport();
++ uno::Sequence< script::ScriptEventDescriptor > getFakeEvents( const uno::Reference< uno::XInterface >& xIf, sal_Int32 pageIndex )
++ {
++ rtl::OUString sServiceName;
++ uno::Reference< beans::XPropertySet > xProps( xIf, uno::UNO_QUERY );
++ xProps->getPropertyValue( rtl::OUString::createFromAscii("DefaultControl" ) ) >>= sServiceName;
++ OSL_TRACE("Control serviceName is %s", rtl::OUStringToOString( sServiceName, RTL_TEXTENCODING_UTF8 ).getStr() );
++ xProps.set( ::comphelper::getProcessServiceFactory(), uno::UNO_QUERY_THROW );
++ uno::Reference<uno::XComponentContext > xContext( xProps->getPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "DefaultContext" ))), uno::UNO_QUERY_THROW );
++ uno::Reference< org::openoffice::vba::XVBAToOOEventDescGen > xEvtDescGen( xContext->getServiceManager()->createInstanceWithContext( rtl::OUString::createFromAscii( "org.openoffice.vba.VBAToOOEventDesc" ), xContext ), uno::UNO_QUERY_THROW );
++ uno::Sequence< rtl::OUString > sHandlerExtns;
++ String sLibModName;
++ mpDoc->GetDocument()->GetCodeName( pageIndex, sLibModName );
++
++ if( !sLibModName.Len() )
++ mpDoc->GetDocument()->GetName( pageIndex, sLibModName );
++
++ uno::Sequence< script::ScriptEventDescriptor > aFakeEvents = xEvtDescGen->getEventDescriptions( xContext->getServiceManager()->createInstanceWithContext( sServiceName, xContext ), sLibModName, sHandlerExtns ) ;
++ return aFakeEvents;
++ }
++public:
++ ScFakeVBACntrlEvtSupport( ScDocShell* pDoc ) : mpDoc( pDoc )
++ {
++ OSL_TRACE("*** In ScFakeVBACntrlEvtSupport ");
++ }
++ virtual uno::Sequence< com::sun::star::script::ScriptEventDescriptor > SAL_CALL getEventDescriptions( const uno::Reference< uno::XInterface >& xIf ) throw ( uno::RuntimeException )
++ {
++ OSL_TRACE( "*** In ScFakeVBACntrlEvtSupport::getEventDescriptions");
++ // need to find the page ( and index ) for this control
++ uno::Reference< drawing::XDrawPagesSupplier > xSupplier( mpDoc->GetModel(), uno::UNO_QUERY_THROW );
++
++ uno::Reference< container::XIndexAccess > xIndex( xSupplier->getDrawPages(), uno::UNO_QUERY_THROW );
++
++ sal_Int32 nLen = xIndex->getCount();
++ bool bMatched = false;
++ uno::Sequence< script::ScriptEventDescriptor > aFakeEvents;
++ for ( sal_Int32 index = 0; index < nLen; ++index )
++ {
++ uno::Reference< form::XFormsSupplier > xFormSupplier( xIndex->getByIndex( index ), uno::UNO_QUERY_THROW );
++ uno::Reference< container::XIndexAccess > xFormIndex( xFormSupplier->getForms(), uno::UNO_QUERY_THROW );
++ // get the www-standard container
++ uno::Reference< container::XIndexAccess > xFormControls( xFormIndex->getByIndex(0), uno::UNO_QUERY_THROW );
++ sal_Int32 nCntrls = xFormControls->getCount();
++ for( sal_Int32 cIndex = 0; cIndex < nCntrls; ++cIndex )
++ {
++ uno::Reference< uno::XInterface > xControl( xFormControls->getByIndex( cIndex ), uno::UNO_QUERY_THROW );
++ bMatched = ( xControl == xIf );
++ if ( bMatched )
++ {
++ aFakeEvents = getFakeEvents( xIf, index );
++ break;
++ }
++ }
++ if ( bMatched )
++ break;
++ }
++ // Probably should throw here
++ return aFakeEvents;
++ }
++};
++
++class ScVbaObjectProvider : public ::cppu::WeakImplHelper2< script::XObjectProvider, lang::XInitialization >
++{
++ ScDocShell* mpDocShell;
++ uno::Any aObj;
++ String msName;
++public:
++ ScVbaObjectProvider( const rtl::OUString& sName, ScDocShell* pDocShell ) : mpDocShell( pDocShell ), msName(sName) {}
++ ScVbaObjectProvider( ScDocShell* pDocShell ) : mpDocShell( pDocShell ) {}
++ virtual void SAL_CALL initialize( const uno::Sequence< uno::Any >& aArguments ) throw (uno::Exception, uno::RuntimeException)
++ {
++ OSL_TRACE("ScVbaObjectProvider::initialize ");
++ if(aArguments.getLength() != 1)
++ {
++ throw lang::IllegalArgumentException(rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("give a string instanciating this component!") ), static_cast< script::XObjectProvider * >(this), 0 );
++ }
++ rtl::OUString sName;
++ aArguments[0] >>= sName;
++ msName = sName;
++ }
++ virtual uno::Any SAL_CALL getObject() throw (uno::RuntimeException)
++ {
++ if ( !aObj.hasValue() )
++ {
++ BOOL bWorkbook = FALSE;
++ uno::Type aType;
++ uno::Reference<lang::XMultiServiceFactory> xSF(comphelper::getProcessServiceFactory());
++ uno::Reference<beans::XPropertySet> xProps(xSF, uno::UNO_QUERY);
++ if( xProps.is() )
++ {
++ ScDocument* pDoc = mpDocShell->GetDocument();
++ if ( !pDoc )
++ throw uno::RuntimeException( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("")), uno::Reference< uno::XInterface >() );
++ String sGlobCodeName = pDoc->GetCodeName();
++ uno::Reference< uno::XInterface > xIf;
++
++ uno::Sequence< uno::Any > aArgs(2);
++ aArgs[0] = uno::Any( uno::Reference< uno::XInterface >() );
++ aArgs[1] = uno::Any( mpDocShell->GetModel() );
++ uno::Reference< uno::XInterface > xWorkbook( xSF->createInstanceWithArguments( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("org.openoffice.excel.Workbook") ), aArgs ), uno::UNO_QUERY );
++ if( sGlobCodeName == msName )
++ {
++ xIf.set( xWorkbook, uno::UNO_QUERY );
++ bWorkbook = TRUE;
++ }
++ else
++ {
++ String sCodeName;
++ SCTAB nCount = pDoc->GetTableCount();
++ for( SCTAB i = 0; i < nCount; i++ )
++ {
++ pDoc->GetCodeName( i, sCodeName );
++ if( sCodeName == msName )
++ {
++ String sSheetName;
++ if( pDoc->GetName( i, sSheetName ) )
++ {
++ uno::Reference< frame::XModel > xModel( mpDocShell->GetModel() );
++ uno::Reference <sheet::XSpreadsheetDocument> xSpreadDoc( xModel, uno::UNO_QUERY_THROW );
++ uno::Reference<sheet::XSpreadsheets > xSheets( xSpreadDoc->getSheets(), uno::UNO_QUERY_THROW );
++ uno::Reference< container::XIndexAccess > xIndexAccess( xSheets, uno::UNO_QUERY_THROW );
++ uno::Reference< sheet::XSpreadsheet > xSheet( xIndexAccess->getByIndex( i ), uno::UNO_QUERY_THROW );
++ uno::Sequence< uno::Any > aArgs(3);
++ aArgs[0] = uno::Any( xWorkbook );
++ aArgs[1] = uno::Any( xModel );
++ aArgs[2] = uno::Any( rtl::OUString( sSheetName ) );
++ uno::Reference< uno::XInterface > xWorksheet( xSF->createInstanceWithArguments( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("org.openoffice.excel.Worksheet") ), aArgs ), uno::UNO_QUERY );
++ xIf.set( xWorksheet, uno::UNO_QUERY );
++ bWorkbook = FALSE;
++ break;
++ }
++ }
++ }
++ }
++ if( xIf.is() )
++ {
++ aObj <<= xIf;
++ }
++ }
++ }
++ return aObj;
++ }
++};
+
+ //------------------------------------------------------------------------
+
+@@ -128,7 +289,10 @@ 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
++ "org.openoffice.vba.controlevents", // SC_SERVICE_VBACONTROL_EVENTS
++
+ };
+
+ //
+@@ -180,7 +344,9 @@ 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
++ "", // SC_SERVICE_VBACONTROL_EVENTS
+ };
+
+
+@@ -373,6 +539,12 @@ 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;
++ case SC_SERVICE_VBACONTROL_EVENTS:
++ xRet.set(static_cast<org::openoffice::vba::XFakeVBAEventDescriptorSupplier*>(new ScFakeVBACntrlEvtSupport( pDocShell ) ));
++ break;
+ }
+ return xRet;
+ }
+--- /dev/null 2007-05-04 11:54:36.000000000 +0100
++++ sc/source/ui/vba/vbauserform.hxx 2008-03-27 23:24:11.000000000 +0000
+@@ -0,0 +1,72 @@
++/*************************************************************************
++ *
++ * OpenOffice.org - a multi-platform office productivity suite
++ *
++ * $RCSfile: vbashape.hxx,v $
++ *
++ * $Revision: 1.2 $
++ *
++ * last change: $Author: vg $ $Date: 2007/12/07 11:02:09 $
++ *
++ * 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 SC_VBA_USERFORM_HXX
++#define SC_VBA_USERFORM_HXX
++
++#include <cppuhelper/implbase1.hxx>
++#include <org/openoffice/msforms/XUserForm.hpp>
++#include <com/sun/star/awt/XDialog.hpp>
++
++#include "vbahelperinterface.hxx"
++#include "vbacontrol.hxx"
++
++//typedef InheritedHelperInterfaceImpl1< oo::msforms::XUserForm > ScVbaUserForm_BASE;
++typedef cppu::ImplInheritanceHelper1< ScVbaControl, oo::msforms::XUserForm > ScVbaUserForm_BASE;
++
++class ScVbaUserForm : public ScVbaUserForm_BASE
++{
++private:
++ css::uno::Reference< css::awt::XDialog > m_xDialog;
++ ScDocShell* m_pDocShell;
++protected:
++public:
++ ScVbaUserForm( css::uno::Sequence< css::uno::Any > const& aArgs, css::uno::Reference< css::uno::XComponentContext >const& xContext ) throw ( css::lang::IllegalArgumentException );
++ virtual ~ScVbaUserForm();
++ // XUserForm
++ virtual void SAL_CALL Show( ) throw (css::uno::RuntimeException);
++ // XIntrospection
++ virtual css::uno::Reference< css::beans::XIntrospectionAccess > SAL_CALL getIntrospection( ) throw (css::uno::RuntimeException);
++ virtual css::uno::Any SAL_CALL invoke( const ::rtl::OUString& aFunctionName, const css::uno::Sequence< css::uno::Any >& aParams, css::uno::Sequence< ::sal_Int16 >& aOutParamIndex, css::uno::Sequence< css::uno::Any >& aOutParam ) throw (css::lang::IllegalArgumentException, css::script::CannotConvertException, css::reflection::InvocationTargetException, css::uno::RuntimeException);
++ virtual void SAL_CALL setValue( const ::rtl::OUString& aPropertyName, const css::uno::Any& aValue ) throw (css::beans::UnknownPropertyException, css::script::CannotConvertException, css::reflection::InvocationTargetException, css::uno::RuntimeException);
++ virtual css::uno::Any SAL_CALL getValue( const ::rtl::OUString& aPropertyName ) throw (css::beans::UnknownPropertyException, css::uno::RuntimeException);
++ virtual ::sal_Bool SAL_CALL hasMethod( const ::rtl::OUString& aName ) throw (css::uno::RuntimeException);
++ virtual ::sal_Bool SAL_CALL hasProperty( const ::rtl::OUString& aName ) throw (css::uno::RuntimeException);
++ virtual ::rtl::OUString SAL_CALL getCaption() throw (::com::sun::star::uno::RuntimeException);
++ virtual void SAL_CALL setCaption( const ::rtl::OUString& _caption ) throw (::com::sun::star::uno::RuntimeException);
++ //XHelperInterface
++ virtual rtl::OUString& getServiceImplName();
++ virtual css::uno::Sequence<rtl::OUString> getServiceNames();
++};
++#endif
+--- /dev/null 2007-05-04 11:54:36.000000000 +0100
++++ sc/source/ui/vba/vbauserform.cxx 2008-03-27 23:35:23.000000000 +0000
+@@ -0,0 +1,215 @@
++/*************************************************************************
++ *
++ * OpenOffice.org - a multi-platform office productivity suite
++ *
++ * $RCSfile: vbashape.cxx,v $
++ *
++ * $Revision: 1.3 $
++ *
++ * last change: $Author: kz $ $Date: 2007/12/14 12:41:26 $
++ *
++ * 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
++ *
++ ************************************************************************/
++#include "helperdecl.hxx"
++#include "vbauserform.hxx"
++#include <com/sun/star/awt/XControl.hpp>
++#include <basic/sbx.hxx>
++#include <basic/sbstar.hxx>
++#include <basic/sbmeth.hxx>
++#include "unonames.hxx"
++
++using namespace ::org::openoffice;
++using namespace ::com::sun::star;
++
++#define VBA_LEFT "Left"
++#define VBA_TOP "Top"
++class UserFormGeometryHelper : public AbstractGeometryAttributes
++{
++
++ uno::Reference< beans::XPropertySet > mxModel;
++public:
++ UserFormGeometryHelper( const css::uno::Reference< css::uno::XComponentContext >& xContext, const css::uno::Reference< awt::XControl >& xControl )
++ {
++ mxModel.set( xControl->getModel(), uno::UNO_QUERY_THROW );
++ }
++ virtual double getLeft()
++ {
++ sal_Int32 nLeft = 0;
++ mxModel->getPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( VBA_LEFT ) ) ) >>= nLeft;
++ return Millimeter::getInPoints( nLeft );
++ }
++ virtual void setLeft( double nLeft )
++ {
++ mxModel->setPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( VBA_LEFT ) ), uno::makeAny( Millimeter::getInHundredthsOfOneMillimeter( nLeft ) ) );
++ }
++ virtual double getTop()
++ {
++ sal_Int32 nTop = 0;
++ mxModel->getPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( VBA_TOP ) ) ) >>= nTop;
++ return Millimeter::getInPoints( nTop );
++ }
++ virtual void setTop( double nTop )
++ {
++ mxModel->setPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( VBA_TOP ) ), uno::makeAny( Millimeter::getInHundredthsOfOneMillimeter( nTop ) ) );
++ }
++ virtual double getHeight()
++ {
++ sal_Int32 nHeight = 0;
++ mxModel->getPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( SC_UNONAME_CELLHGT ) ) ) >>= nHeight;
++ return Millimeter::getInPoints( nHeight );
++ }
++ virtual void setHeight( double nHeight )
++ {
++ mxModel->setPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( SC_UNONAME_CELLHGT ) ), uno::makeAny( Millimeter::getInHundredthsOfOneMillimeter( nHeight ) ) );
++ }
++ virtual double getWidth()
++ {
++ sal_Int32 nWidth = 0;
++ mxModel->getPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( SC_UNONAME_CELLWID ) ) ) >>= nWidth;
++ return Millimeter::getInPoints( nWidth );
++ }
++ virtual void setWidth( double nWidth)
++ {
++ mxModel->setPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( SC_UNONAME_CELLWID ) ), uno::makeAny( Millimeter::getInHundredthsOfOneMillimeter( nWidth ) ) );
++ }
++
++
++};
++// some little notes
++// XDialog implementation has the following interesting bits
++// a Controls property ( which is an array of the container controls )
++// each item in the controls array is a XControl, where the model is
++// basically a property bag
++// additionally the XDialog instance has itself a model
++// this model has a ControlModels ( array of models ) property
++// the models in ControlModels can be accessed by name
++// also the XDialog is a XControl ( to access the model above
++
++//ScVbaUserForm::ScVbaUserForm( uno::Sequence< uno::Any > const& aArgs, uno::Reference< uno::XComponentContext >const& xContext ) throw ( lang::IllegalArgumentException ) : ScVbaUserForm_BASE( getXSomethingFromArgs< vba::XHelperInterface >( aArgs, 0 ), xContext ), m_xDialog( getXSomethingFromArgs< awt::XDialog >( aArgs, 1 ) ), m_pDocShell( 0 )
++ScVbaUserForm::ScVbaUserForm( uno::Sequence< uno::Any > const& aArgs, uno::Reference< uno::XComponentContext >const& xContext ) throw ( lang::IllegalArgumentException ) : ScVbaUserForm_BASE( xContext, getXSomethingFromArgs< uno::XInterface >( aArgs, 1 ) ), m_pDocShell( 0 )
++{
++ OSL_TRACE("ScVbaUserForm::ScVbaUserForm()");
++ m_xDialog.set( m_xControl, uno::UNO_QUERY_THROW );
++ uno::Reference< frame::XModel > xModel = getXSomethingFromArgs< frame::XModel >( aArgs, 2 );
++ uno::Reference< awt::XControl > xControl( m_xDialog, uno::UNO_QUERY_THROW );
++ m_pDocShell = getDocShell( xModel );
++ m_xProps.set( xControl->getModel(), uno::UNO_QUERY_THROW );
++ mpGeometryHelper.reset( new UserFormGeometryHelper( xContext, xControl ) );
++}
++
++ScVbaUserForm::~ScVbaUserForm()
++{
++}
++
++void SAL_CALL
++ScVbaUserForm::Show( ) throw (uno::RuntimeException)
++{
++ OSL_TRACE("ScVbaUserForm::Show( )");
++ if ( m_xDialog.is() )
++ m_xDialog->execute();
++}
++
++rtl::OUString SAL_CALL
++ScVbaUserForm::getCaption() throw (::com::sun::star::uno::RuntimeException)
++{
++ rtl::OUString sCaption;
++ m_xProps->getPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("Title") ) ) >>= sCaption;
++ return sCaption;
++}
++void
++ScVbaUserForm::setCaption( const ::rtl::OUString& _caption ) throw (::com::sun::star::uno::RuntimeException)
++{
++ m_xProps->setPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("Title") ), uno::makeAny( _caption ) );
++}
++rtl::OUString&
++ScVbaUserForm::getServiceImplName()
++{
++ static rtl::OUString sImplName( RTL_CONSTASCII_USTRINGPARAM("ScVbaUserForm") );
++ return sImplName;
++}
++
++uno::Sequence< rtl::OUString >
++ScVbaUserForm::getServiceNames()
++{
++ static uno::Sequence< rtl::OUString > aServiceNames;
++ if ( aServiceNames.getLength() == 0 )
++ {
++ aServiceNames.realloc( 1 );
++ aServiceNames[ 0 ] = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("org.openoffice.excel.UserForm" ) );
++ }
++ return aServiceNames;
++}
++
++uno::Reference< beans::XIntrospectionAccess > SAL_CALL
++ScVbaUserForm::getIntrospection( ) throw (uno::RuntimeException)
++{
++ return uno::Reference< beans::XIntrospectionAccess >();
++}
++
++uno::Any SAL_CALL
++ScVbaUserForm::invoke( const ::rtl::OUString& /*aFunctionName*/, const uno::Sequence< uno::Any >& /*aParams*/, uno::Sequence< ::sal_Int16 >& /*aOutParamIndex*/, uno::Sequence< uno::Any >& /*aOutParam*/ ) throw (lang::IllegalArgumentException, script::CannotConvertException, reflection::InvocationTargetException, uno::RuntimeException)
++{
++ throw uno::RuntimeException(); // unsupported operation
++}
++
++void SAL_CALL
++ScVbaUserForm::setValue( const ::rtl::OUString& /*aPropertyName*/, const uno::Any& /*aValue*/ ) throw (beans::UnknownPropertyException, script::CannotConvertException, reflection::InvocationTargetException, uno::RuntimeException)
++{
++ throw uno::RuntimeException();
++}
++
++uno::Any SAL_CALL
++ScVbaUserForm::getValue( const ::rtl::OUString& aPropertyName ) throw (beans::UnknownPropertyException, uno::RuntimeException)
++{
++ uno::Reference< awt::XControl > xControl( m_xDialog, uno::UNO_QUERY_THROW );
++ uno::Reference< container::XNameAccess > xNameAccess( xControl->getModel(), uno::UNO_QUERY_THROW );
++ // need to create control here
++ return xNameAccess->getByName( aPropertyName );
++}
++
++::sal_Bool SAL_CALL
++ScVbaUserForm::hasMethod( const ::rtl::OUString& /*aName*/ ) throw (uno::RuntimeException)
++{
++ return sal_False;
++}
++
++::sal_Bool SAL_CALL
++ScVbaUserForm::hasProperty( const ::rtl::OUString& aName ) throw (uno::RuntimeException)
++{
++ uno::Reference< awt::XControl > xControl( m_xDialog, uno::UNO_QUERY_THROW );
++ uno::Reference< container::XNameAccess > xNameAccess( xControl->getModel(), uno::UNO_QUERY_THROW );
++ return xNameAccess->hasByName( aName );
++}
++
++namespace userform
++{
++namespace sdecl = comphelper::service_decl;
++sdecl::vba_service_class_<ScVbaUserForm, sdecl::with_args<true> > serviceImpl;
++extern sdecl::ServiceDecl const serviceDecl(
++ serviceImpl,
++ "ScVbaUserForm",
++ "org.openoffice.excel.UserForm" );
++}
++
+diff -rup /esata1/BUILD-related/HEAD/ooo-build/build/ooh680-m12/sc/source/ui/vba/makefile.mk sc/source/ui/vba/makefile.mk
+--- /esata1/BUILD-related/HEAD/ooo-build/build/ooh680-m12/sc/source/ui/vba/makefile.mk 2008-03-19 10:56:58.000000000 +0000
++++ sc/source/ui/vba/makefile.mk 2008-03-20 14:00:09.000000000 +0000
+@@ -121,6 +121,7 @@ SLOFILES= \
+ $(SLO)$/vbacommandbarcontrols.obj \
+ $(SLO)$/vbacommandbar.obj \
+ $(SLO)$/vbacommandbars.obj \
++ $(SLO)$/vbauserform.obj \
+ $(SLO)$/service.obj \
+
+
+diff -rup /esata1/BUILD-related/HEAD/ooo-build/build/ooh680-m12/sc/source/ui/vba/service.cxx sc/source/ui/vba/service.cxx
+--- /esata1/BUILD-related/HEAD/ooo-build/build/ooh680-m12/sc/source/ui/vba/service.cxx 2007-12-07 10:42:52.000000000 +0000
++++ sc/source/ui/vba/service.cxx 2008-03-20 14:02:25.000000000 +0000
+@@ -62,7 +62,10 @@ namespace globals
+ {
+ extern sdecl::ServiceDecl const serviceDecl;
+ }
+-
++namespace userform
++{
++extern sdecl::ServiceDecl const serviceDecl;
++}
+
+
+ extern "C"
+@@ -81,7 +84,7 @@ extern "C"
+
+ // Component registration
+ if ( component_writeInfoHelper( pServiceManager, pRegistryKey,
+- range::serviceDecl, workbook::serviceDecl, worksheet::serviceDecl, globals::serviceDecl ) )
++ range::serviceDecl, workbook::serviceDecl, worksheet::serviceDecl, globals::serviceDecl, userform::serviceDecl ) )
+ {
+ // Singleton registration
+ try
+@@ -109,7 +112,7 @@ extern "C"
+ {
+ OSL_TRACE("In component_getFactory for %s", pImplName );
+ void* pRet = component_getFactoryHelper(
+- pImplName, pServiceManager, pRegistryKey, range::serviceDecl, workbook::serviceDecl, worksheet::serviceDecl, globals::serviceDecl );
++ pImplName, pServiceManager, pRegistryKey, range::serviceDecl, workbook::serviceDecl, worksheet::serviceDecl, globals::serviceDecl, userform::serviceDecl );
+ OSL_TRACE("Ret is 0x%x", pRet);
+ return pRet;
+ }
+diff -rup /esata1/BUILD-related/HEAD/ooo-build/build/ooh680-m12/sc/source/ui/vba/vbacombobox.cxx sc/source/ui/vba/vbacombobox.cxx
+--- /esata1/BUILD-related/HEAD/ooo-build/build/ooh680-m12/sc/source/ui/vba/vbacombobox.cxx 2007-12-07 10:48:18.000000000 +0000
++++ sc/source/ui/vba/vbacombobox.cxx 2008-03-27 15:49:59.000000000 +0000
+@@ -48,12 +48,6 @@ ScVbaComboBox::ScVbaComboBox( const uno:
+ m_xProps->getPropertyValue( CONTROLSOURCEPROP ) >>= sSourceName;
+ }
+
+-ScVbaComboBox::ScVbaComboBox( const uno::Reference< uno::XComponentContext >& xContext, const uno::Reference< beans::XPropertySet >& xPropSet, const css::uno::Reference< css::drawing::XControlShape > xControlShape ) : ComboBoxImpl_BASE( xContext, xPropSet, xControlShape )
+-{
+- m_xProps->getPropertyValue( CONTROLSOURCEPROP ) >>= sSourceName;
+-}
+-
+-
+ // Attributes
+ uno::Any SAL_CALL
+ ScVbaComboBox::getValue() throw (uno::RuntimeException)
+diff -rup /esata1/BUILD-related/HEAD/ooo-build/build/ooh680-m12/sc/source/ui/vba/vbacombobox.hxx sc/source/ui/vba/vbacombobox.hxx
+--- /esata1/BUILD-related/HEAD/ooo-build/build/ooh680-m12/sc/source/ui/vba/vbacombobox.hxx 2007-12-07 10:48:31.000000000 +0000
++++ sc/source/ui/vba/vbacombobox.hxx 2008-03-27 15:50:16.000000000 +0000
+@@ -59,10 +59,6 @@ class ScVbaComboBox : public ComboBoxImp
+ public:
+ ScVbaComboBox( const css::uno::Reference< css::uno::XComponentContext >& xContext,
+ const css::uno::Reference< css::drawing::XControlShape >& xControlShape );
+- ScVbaComboBox( const css::uno::Reference< css::uno::XComponentContext >& xContext,
+- const css::uno::Reference< css::beans::XPropertySet >& xProps,
+- const css::uno::Reference< css::drawing::XControlShape> xControlShape );
+-
+
+ // Attributes
+ virtual css::uno::Any SAL_CALL getValue() throw (css::uno::RuntimeException);
+diff -rup /esata1/BUILD-related/HEAD/ooo-build/build/ooh680-m12/sc/source/ui/vba/vbacontrol.cxx sc/source/ui/vba/vbacontrol.cxx
+--- /esata1/BUILD-related/HEAD/ooo-build/build/ooh680-m12/sc/source/ui/vba/vbacontrol.cxx 2007-12-07 10:49:52.000000000 +0000
++++ sc/source/ui/vba/vbacontrol.cxx 2008-03-27 21:01:52.000000000 +0000
+@@ -54,12 +54,14 @@
+ using namespace com::sun::star;
+ using namespace org::openoffice;
+
+-sal_Int32 pt2mm( double pt );
+-double mm2pt( sal_Int32 mm );
+-
+ uno::Reference< css::awt::XWindowPeer >
+-ScVbaControl::getWindowPeer( const uno::Reference< ::drawing::XControlShape >& xControlShape ) throw (uno::RuntimeException)
++ScVbaControl::getWindowPeer() throw (uno::RuntimeException)
+ {
++ // #FIXME why don't we already have the XModel instead of getting it
++ // directly from the controlmodel, probablye we thought there was a reason
++ // at some stage.
++ uno::Reference< drawing::XControlShape > xControlShape( m_xControl, uno::UNO_QUERY );
++
+ uno::Reference< awt::XControlModel > xControlModel( xControlShape->getControl(), uno::UNO_QUERY_THROW );
+ //init m_xWindowPeer
+ uno::Reference< container::XChild > xChild( xControlModel, uno::UNO_QUERY_THROW );
+@@ -67,17 +69,18 @@ ScVbaControl::getWindowPeer( const uno::
+ xChild.set( xChild->getParent(), uno::UNO_QUERY_THROW );
+ uno::Reference< frame::XModel > xModel( xChild->getParent(), uno::UNO_QUERY_THROW );
+ uno::Reference< view::XControlAccess > xControlAccess( xModel->getCurrentController(), uno::UNO_QUERY_THROW );
+- uno::Reference< awt::XControl > xControl;
++ uno::Reference< css::awt::XWindowPeer > xWinPeer;
+ try
+ {
+- xControl.set( xControlAccess->getControl( xControlModel ), uno::UNO_QUERY );
++ uno::Reference< awt::XControl > xControl( xControlAccess->getControl( xControlModel ), uno::UNO_QUERY );
++ xWinPeer = xControl->getPeer();
+ }
+ catch( uno::Exception )
+ {
+ throw uno::RuntimeException( rtl::OUString::createFromAscii( "The Control does not exsit" ),
+ uno::Reference< uno::XInterface >() );
+ }
+- return xControl->getPeer();
++ return xWinPeer;
+ }
+
+ //ScVbaControlListener
+@@ -111,69 +114,39 @@ ScVbaControlListener::disposing( const l
+
+ //ScVbaControl
+
+-ScVbaControl::ScVbaControl( const uno::Reference< uno::XComponentContext >& xContext, const uno::Reference< ::drawing::XControlShape >& xControlShape ) : m_xContext( xContext ), m_xControlShape( xControlShape )
++ScVbaControl::ScVbaControl( const uno::Reference< uno::XComponentContext >& xContext, const uno::Reference< ::uno::XInterface >& xControl ) : ControlImpl_BASE( uno::Reference< vba::XHelperInterface >(), xContext ), m_xContext( xContext ), m_xControl( xControl )
+ {
+- //init m_xProps
+- uno::Reference< awt::XControlModel > xControlModel( xControlShape->getControl(), uno::UNO_QUERY_THROW );
+- uno::Reference< beans::XPropertySet > xProps( xControlModel, uno::UNO_QUERY_THROW );
+- m_xProps.set( xProps, uno::UNO_QUERY_THROW );
+ //add listener
+ m_xEventListener.set( new ScVbaControlListener( this ) );
+- uno::Reference< lang::XComponent > xComponent( m_xControlShape, uno::UNO_QUERY_THROW );
++ uno::Reference< lang::XComponent > xComponent( m_xControl, uno::UNO_QUERY_THROW );
+ xComponent->addEventListener( m_xEventListener );
++
++ //init m_xProps
++ uno::Reference< drawing::XControlShape > xControlShape( m_xControl, uno::UNO_QUERY ) ;
++ if ( xControlShape.is() ) // form control
++ {
++ m_xProps.set( xControlShape->getControl(), uno::UNO_QUERY_THROW );
++ mpGeometryHelper.reset( new ConcreteXShapeGeometryAttributes( xContext, uno::Reference< drawing::XShape >( m_xControl, uno::UNO_QUERY_THROW ) ) );
++ }
+ }
+
+ ScVbaControl::~ScVbaControl()
+ {
+- if( m_xControlShape.is() )
++ if( m_xControl.is() )
+ {
+- uno::Reference< lang::XComponent > xComponent( m_xControlShape, uno::UNO_QUERY_THROW );
++ uno::Reference< lang::XComponent > xComponent( m_xControl, uno::UNO_QUERY_THROW );
+ xComponent->removeEventListener( m_xEventListener );
+ }
+ }
+
+ void ScVbaControl::removeResouce() throw( uno::RuntimeException )
+ {
+- uno::Reference< lang::XComponent > xComponent( m_xControlShape, uno::UNO_QUERY_THROW );
++ uno::Reference< lang::XComponent > xComponent( m_xControl, uno::UNO_QUERY_THROW );
+ xComponent->removeEventListener( m_xEventListener );
+- m_xControlShape = NULL;
++ m_xControl= NULL;
+ m_xProps = NULL;
+ }
+
+-
+-ScVbaControl::ScVbaControl( const uno::Reference< uno::XComponentContext >& xContext,
+- const uno::Reference< beans::XPropertySet >& xProps,
+- const uno::Reference< drawing::XControlShape > xControlShape ) : m_xContext( xContext ),
+- m_xProps( xProps ), m_xControlShape( xControlShape )
+-{
+- m_xEventListener.set( new ScVbaControlListener( this ) );
+- uno::Reference< lang::XComponent > xComponent( m_xControlShape, uno::UNO_QUERY_THROW );
+- xComponent->addEventListener( m_xEventListener );
+-}
+-
+-void ScVbaControl::SetControl( const uno::Reference< uno::XComponentContext > xContext, const uno::Reference< ::drawing::XControlShape > xControlShape )
+-{
+- m_xEventListener.set( new ScVbaControlListener( this ) );
+- uno::Reference< lang::XComponent > xComponent( m_xControlShape, uno::UNO_QUERY_THROW );
+- m_xContext.set( xContext, uno::UNO_QUERY_THROW );
+- m_xControlShape.set( xControlShape, uno::UNO_QUERY_THROW );
+- //init m_xProps
+- uno::Reference< awt::XControlModel > xControlModel( xControlShape->getControl(), uno::UNO_QUERY_THROW );
+- uno::Reference< beans::XPropertySet > xProps( xControlModel, uno::UNO_QUERY_THROW );
+- m_xProps = xProps;
+-}
+-
+-void ScVbaControl::SetControl( const uno::Reference< uno::XComponentContext > xContext,
+- const uno::Reference< beans::XPropertySet > xProps,
+- const uno::Reference< drawing::XControlShape > xControlShape )
+-{
+- m_xEventListener.set( new ScVbaControlListener( this ) );
+- uno::Reference< lang::XComponent > xComponent( m_xControlShape, uno::UNO_QUERY_THROW );
+- m_xContext.set( xContext, uno::UNO_QUERY_THROW );
+- m_xProps.set( xProps, uno::UNO_QUERY_THROW );
+- m_xControlShape.set( xControlShape, uno::UNO_QUERY_THROW );
+-}
+-
+ //In design model has different behavior
+ sal_Bool SAL_CALL ScVbaControl::getEnabled() throw (uno::RuntimeException)
+ {
+@@ -194,74 +167,56 @@ void SAL_CALL ScVbaControl::setEnabled(
+
+ sal_Bool SAL_CALL ScVbaControl::getVisible() throw (uno::RuntimeException)
+ {
+- uno::Reference< awt::XWindow2 > xWindow2( getWindowPeer( m_xControlShape ), uno::UNO_QUERY_THROW );
++ uno::Reference< awt::XWindow2 > xWindow2( getWindowPeer(), uno::UNO_QUERY_THROW );
+ return xWindow2->isVisible();
+ }
+
+ void SAL_CALL ScVbaControl::setVisible( sal_Bool bVisible ) throw (uno::RuntimeException)
+ {
+- uno::Reference< awt::XWindow2 > xWindow2( getWindowPeer( m_xControlShape ), uno::UNO_QUERY_THROW );
++ uno::Reference< awt::XWindow2 > xWindow2( getWindowPeer(), uno::UNO_QUERY_THROW );
+ xWindow2->setVisible( bVisible );
+ }
+ double SAL_CALL ScVbaControl::getHeight() throw (uno::RuntimeException)
+ {
+- uno::Reference< drawing::XShape > xShape( m_xControlShape, uno::UNO_QUERY_THROW );
+- return mm2pt( xShape->getSize().Height ) / 100;
++ return mpGeometryHelper->getHeight();
+ }
+ void SAL_CALL ScVbaControl::setHeight( double _height ) throw (uno::RuntimeException)
+ {
+- uno::Reference< drawing::XShape > xShape( m_xControlShape, uno::UNO_QUERY_THROW );
+- awt::Size aSize( xShape->getSize() );
+- aSize.Height = pt2mm( _height ) * 100;
+- xShape->setSize( aSize );
++ mpGeometryHelper->setHeight( _height );
+ }
+
+ double SAL_CALL ScVbaControl::getWidth() throw (uno::RuntimeException)
+ {
+- uno::Reference< drawing::XShape > xShape( m_xControlShape, uno::UNO_QUERY_THROW );
+- return mm2pt( xShape->getSize().Width ) / 100;
++ return mpGeometryHelper->getWidth();
+ }
+ void SAL_CALL ScVbaControl::setWidth( double _width ) throw (uno::RuntimeException)
+ {
+- uno::Reference< drawing::XShape > xShape( m_xControlShape, uno::UNO_QUERY_THROW );
+- awt::Size aSize( xShape->getSize() );
+- aSize.Width = pt2mm( _width ) * 100;
+- xShape->setSize( aSize );
++ mpGeometryHelper->setWidth( _width );
+ }
+
+ double SAL_CALL
+ ScVbaControl::getLeft() throw (uno::RuntimeException)
+ {
+- uno::Reference< drawing::XShape > xShape( m_xControlShape, uno::UNO_QUERY_THROW );
+- return mm2pt( xShape->getPosition().X / 100 );
++ return mpGeometryHelper->getLeft();
+ }
+
+ void SAL_CALL
+ ScVbaControl::setLeft( double _left ) throw (uno::RuntimeException)
+ {
+- awt::Point oldPosition;
+- uno::Reference< drawing::XShape > xShape( m_xControlShape, uno::UNO_QUERY_THROW );
+- oldPosition = xShape->getPosition();
+- oldPosition.X = pt2mm( _left ) * 100;
+- xShape->setPosition( oldPosition );
++ mpGeometryHelper->setLeft( _left );
+
+ }
+
+ double SAL_CALL
+ ScVbaControl::getTop() throw (uno::RuntimeException)
+ {
+- uno::Reference< drawing::XShape > xShape( m_xControlShape, uno::UNO_QUERY_THROW );
+- return mm2pt( xShape->getPosition().Y / 100 );
++ return mpGeometryHelper->getTop();
+ }
+
+ void SAL_CALL
+ ScVbaControl::setTop( double _top ) throw (uno::RuntimeException)
+ {
+- awt::Point oldPosition;
+- uno::Reference< drawing::XShape > xShape( m_xControlShape, uno::UNO_QUERY_THROW );
+- oldPosition = xShape->getPosition();
+- oldPosition.Y = pt2mm( _top ) * 100;;
+- xShape->setPosition( oldPosition );
++ mpGeometryHelper->setTop( _top );
+ }
+
+ //ScVbaControlFactory
+@@ -273,32 +228,6 @@ ScVbaControlFactory::ScVbaControlFactory
+ m_xProps.set( xProps, uno::UNO_QUERY_THROW );
+ }
+
+-ScVbaControlFactory::ScVbaControlFactory( const uno::Reference< uno::XComponentContext >& xContext, const uno::Reference< beans::XPropertySet >& xProps, const uno::Reference< drawing::XControlShape > xControlShape ): m_xContext( xContext ), m_xProps( xProps ), m_xControlShape( xControlShape )
+-{
+-}
+-
+-ScVbaControl* ScVbaControlFactory::createControl( const sal_Int16 nClassId ) throw (uno::RuntimeException)
+-{
+- switch( nClassId )
+- {
+- case form::FormComponentType::COMBOBOX:
+- return new ScVbaComboBox( m_xContext, m_xProps, m_xControlShape );
+- case form::FormComponentType::COMMANDBUTTON:
+- return new ScVbaButton( m_xContext, m_xControlShape );
+- case form::FormComponentType::FIXEDTEXT:
+- return new ScVbaLabel( m_xContext, m_xControlShape );
+- case form::FormComponentType::TEXTFIELD:
+- return new ScVbaTextBox( m_xContext, m_xControlShape );
+- case form::FormComponentType::RADIOBUTTON:
+- return new ScVbaRadioButton( m_xContext, m_xControlShape );
+- case form::FormComponentType::LISTBOX:
+- return new ScVbaListBox( m_xContext, m_xControlShape );
+- default:
+- throw uno::RuntimeException( rtl::OUString::createFromAscii(
+- "Donot surpport this Control Type." ), uno::Reference< uno::XInterface >() );
+- }
+-}
+-
+ ScVbaControl* ScVbaControlFactory::createControl() throw (uno::RuntimeException)
+ {
+ sal_Int32 nClassId = -1;
+@@ -323,3 +252,25 @@ ScVbaControl* ScVbaControlFactory::creat
+ "Donot surpport this Control Type." ), uno::Reference< uno::XInterface >() );
+ }
+ }
++
++
++rtl::OUString&
++ScVbaControl::getServiceImplName()
++{
++ static rtl::OUString sImplName( RTL_CONSTASCII_USTRINGPARAM("ScVbaContro") );
++ return sImplName;
++}
++
++uno::Sequence< rtl::OUString >
++ScVbaControl::getServiceNames()
++{
++ static uno::Sequence< rtl::OUString > aServiceNames;
++ if ( aServiceNames.getLength() == 0 )
++ {
++ aServiceNames.realloc( 1 );
++ aServiceNames[ 0 ] = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("org.openoffice.excel.Control" ) );
++ }
++ return aServiceNames;
++}
++
++
+diff -rup /esata1/BUILD-related/HEAD/ooo-build/build/ooh680-m12/sc/source/ui/vba/vbacontrol.hxx sc/source/ui/vba/vbacontrol.hxx
+--- /esata1/BUILD-related/HEAD/ooo-build/build/ooh680-m12/sc/source/ui/vba/vbacontrol.hxx 2007-12-07 10:50:07.000000000 +0000
++++ sc/source/ui/vba/vbacontrol.hxx 2008-03-27 21:50:16.000000000 +0000
+@@ -44,35 +44,24 @@
+ #include <org/openoffice/msforms/XControl.hpp>
+
+ #include "vbahelper.hxx"
++#include "vbahelperinterface.hxx"
+
+-typedef ::cppu::WeakImplHelper1< oo::msforms::XControl > ControlImpl_BASE;
++//typedef ::cppu::WeakImplHelper1< oo::msforms::XControl > ControlImpl_BASE;
++typedef InheritedHelperInterfaceImpl1< oo::msforms::XControl > ControlImpl_BASE;
+
+ class ScVbaControl : public ControlImpl_BASE
+ {
+-/* this will cause error when the sheet is invisible.
+ private:
+- css::uno::Reference< css::awt::XWindowPeer > m_xWindowPeer;
+-*/
+-private:
+- css::uno::Reference< css::awt::XWindowPeer > getWindowPeer( const css::uno::Reference< css::drawing::XControlShape >& xControlShape ) throw (css::uno::RuntimeException);
++ virtual css::uno::Reference< css::awt::XWindowPeer > getWindowPeer() throw (css::uno::RuntimeException);
+ com::sun::star::uno::Reference< com::sun::star::lang::XEventListener > m_xEventListener;
+ protected:
++ std::auto_ptr< oo::AbstractGeometryAttributes > mpGeometryHelper;
+ css::uno::Reference< css::uno::XComponentContext > m_xContext;
+ css::uno::Reference< css::beans::XPropertySet > m_xProps;
+- css::uno::Reference< css::drawing::XControlShape > m_xControlShape;
+-protected:
+- ScVbaControl(){ m_xContext = 0; m_xProps = 0; m_xControlShape = 0; }
+- void SetControl( const css::uno::Reference< css::uno::XComponentContext > xContext,
+- const css::uno::Reference< css::drawing::XControlShape > xControlShape );
+- void SetControl( const css::uno::Reference< css::uno::XComponentContext > xContext,
+- const css::uno::Reference< css::beans::XPropertySet > xProps,
+- const css::uno::Reference< css::drawing::XControlShape > xControlShape );
++ css::uno::Reference< css::uno::XInterface > m_xControl;
+ public:
+ ScVbaControl( const css::uno::Reference< css::uno::XComponentContext >& xContext,
+- const css::uno::Reference< css::drawing::XControlShape >& xControlShape );
+- ScVbaControl( const css::uno::Reference< css::uno::XComponentContext >& xContext,
+- const css::uno::Reference< css::beans::XPropertySet >& xProps,
+- const css::uno::Reference< css::drawing::XControlShape > xControlShape );
++ const css::uno::Reference< css::uno::XInterface >& xControlShape );
+ virtual ~ScVbaControl();
+ // XControl
+ virtual sal_Bool SAL_CALL getEnabled() throw (css::uno::RuntimeException);
+@@ -90,6 +79,9 @@ public:
+
+ //remove resouce because org.openoffice.excel.XControl is a wrapper of com.sun.star.drawing.XControlShape
+ virtual void removeResouce() throw( css::uno::RuntimeException );
++ //XHelperInterface
++ virtual rtl::OUString& getServiceImplName();
++ virtual css::uno::Sequence<rtl::OUString> getServiceNames();
+ };
+
+
+@@ -98,10 +90,6 @@ class ScVbaControlFactory
+ public:
+ ScVbaControlFactory( const css::uno::Reference< css::uno::XComponentContext >& xContext,
+ const css::uno::Reference< css::drawing::XControlShape >& xControlShape );
+- ScVbaControlFactory( const css::uno::Reference< css::uno::XComponentContext >& xContext,
+- const css::uno::Reference< css::beans::XPropertySet >& xProps,
+- const css::uno::Reference< css::drawing::XControlShape > xControlShape );
+- ScVbaControl* createControl( const sal_Int16 nClassID ) throw ( css::uno::RuntimeException );
+ ScVbaControl* createControl() throw ( css::uno::RuntimeException );
+ private:
+ css::uno::Reference< css::uno::XComponentContext > m_xContext;
+diff -rup /esata1/BUILD-related/HEAD/ooo-build/build/ooh680-m12/sc/source/ui/vba/vbahelper.cxx sc/source/ui/vba/vbahelper.cxx
+--- /esata1/BUILD-related/HEAD/ooo-build/build/ooh680-m12/sc/source/ui/vba/vbahelper.cxx 2008-03-19 10:56:34.000000000 +0000
++++ sc/source/ui/vba/vbahelper.cxx 2008-03-27 17:25:21.000000000 +0000
+@@ -62,6 +62,7 @@
+ #include "tabvwsh.hxx"
+ #include "transobj.hxx"
+ #include "scmod.hxx"
++#include "vbashape.hxx"
+
+ using namespace ::com::sun::star;
+ using namespace ::org::openoffice;
+@@ -770,5 +771,10 @@ double PixelsToPoints( css::uno::Referen
+ return (fPixels/fConvertFactor)/POINTTO100THMILLIMETERFACTOR;
+ }
+
++ConcreteXShapeGeometryAttributes::ConcreteXShapeGeometryAttributes( const css::uno::Reference< css::uno::XComponentContext >& xContext, const css::uno::Reference< css::drawing::XShape >& xShape )
++{
++ m_xShape = new ScVbaShape( xContext, xShape );
++}
++
+ } // openoffice
+ } //org
+diff -rup /esata1/BUILD-related/HEAD/ooo-build/build/ooh680-m12/sc/source/ui/vba/vbahelper.hxx sc/source/ui/vba/vbahelper.hxx
+--- /esata1/BUILD-related/HEAD/ooo-build/build/ooh680-m12/sc/source/ui/vba/vbahelper.hxx 2008-03-19 10:56:34.000000000 +0000
++++ sc/source/ui/vba/vbahelper.hxx 2008-03-27 21:48:03.000000000 +0000
+@@ -45,6 +45,7 @@
+ #include <com/sun/star/frame/XModel.hpp>
+ #include <docsh.hxx>
+ #include <sfx2/dispatch.hxx>
++#include <org/openoffice/msforms/XShape.hpp>
+
+ namespace css = ::com::sun::star;
+
+@@ -145,6 +146,62 @@ public:
+ return points;
+ }
+ };
++
++class AbstractGeometryAttributes // probably should replace the ShapeHelper below
++{
++public:
++ virtual double getLeft() = 0;
++ virtual void setLeft( double ) = 0;
++ virtual double getTop() = 0;
++ virtual void setTop( double ) = 0;
++ virtual double getHeight() = 0;
++ virtual void setHeight( double ) = 0;
++ virtual double getWidth() = 0;
++ virtual void setWidth( double ) = 0;
++};
++
++class ConcreteXShapeGeometryAttributes : public AbstractGeometryAttributes
++{
++public:
++ css::uno::Reference< org::openoffice::msforms::XShape > m_xShape;
++ ConcreteXShapeGeometryAttributes( const css::uno::Reference< css::uno::XComponentContext >& xContext, const css::uno::Reference< css::drawing::XShape >& xShape );
++ virtual double getLeft()
++ {
++ return m_xShape->getLeft();
++ }
++ virtual void setLeft( double nLeft )
++ {
++ m_xShape->setLeft( nLeft );
++ }
++ virtual double getTop()
++ {
++ return m_xShape->getTop();
++ }
++ virtual void setTop( double nTop )
++ {
++ m_xShape->setTop( nTop );
++ }
++
++ virtual double getHeight()
++ {
++ return m_xShape->getHeight();
++ }
++ virtual void setHeight( double nHeight )
++ {
++ m_xShape->setHeight( nHeight );
++ }
++ virtual double getWidth()
++ {
++ return m_xShape->getWidth();
++ }
++ virtual void setWidth( double nWidth)
++ {
++ m_xShape->setHeight( nWidth );
++ }
++
++
++};
++
+ class ShapeHelper
+ {
+ protected:
+diff -rup /esata1/BUILD-related/HEAD/ooo-build/build/ooh680-m12/sc/source/ui/vba/vbalistbox.cxx sc/source/ui/vba/vbalistbox.cxx
+--- /esata1/BUILD-related/HEAD/ooo-build/build/ooh680-m12/sc/source/ui/vba/vbalistbox.cxx 2007-12-10 09:31:13.000000000 +0000
++++ sc/source/ui/vba/vbalistbox.cxx 2008-03-27 15:50:26.000000000 +0000
+@@ -52,12 +52,6 @@ ScVbaListBox::ScVbaListBox( const uno::R
+ m_xProps->getPropertyValue( CONTROLSOURCEPROP ) >>= sSourceName;
+ }
+
+-ScVbaListBox::ScVbaListBox( const uno::Reference< uno::XComponentContext >& xContext, const uno::Reference< beans::XPropertySet >& xPropSet, const css::uno::Reference< css::drawing::XControlShape > xControlShape ) : ListBoxImpl_BASE( xContext, xPropSet, xControlShape )
+-{
+- m_xProps->getPropertyValue( CONTROLSOURCEPROP ) >>= sSourceName;
+-}
+-
+-
+ // Attributes
+ uno::Any SAL_CALL
+ ScVbaListBox::getValue() throw (uno::RuntimeException)
+diff -rup /esata1/BUILD-related/HEAD/ooo-build/build/ooh680-m12/sc/source/ui/vba/vbalistbox.hxx sc/source/ui/vba/vbalistbox.hxx
+--- /esata1/BUILD-related/HEAD/ooo-build/build/ooh680-m12/sc/source/ui/vba/vbalistbox.hxx 2007-12-07 10:55:31.000000000 +0000
++++ sc/source/ui/vba/vbalistbox.hxx 2008-03-27 15:50:39.000000000 +0000
+@@ -56,10 +56,6 @@ class ScVbaListBox : public ListBoxImpl_
+ public:
+ ScVbaListBox( const css::uno::Reference< css::uno::XComponentContext >& xContext,
+ const css::uno::Reference< css::drawing::XControlShape >& xControlShape );
+- ScVbaListBox( const css::uno::Reference< css::uno::XComponentContext >& xContext,
+- const css::uno::Reference< css::beans::XPropertySet >& xProps,
+- const css::uno::Reference< css::drawing::XControlShape> xControlShape );
+-
+
+ // Attributes
+ virtual css::uno::Any SAL_CALL getValue() throw (css::uno::RuntimeException);
+diff -rup /esata1/BUILD-related/HEAD/ooo-build/build/ooh680-m12/sc/source/ui/vba/vbashape.hxx sc/source/ui/vba/vbashape.hxx
+--- /esata1/BUILD-related/HEAD/ooo-build/build/ooh680-m12/sc/source/ui/vba/vbashape.hxx 2008-03-19 10:56:34.000000000 +0000
++++ sc/source/ui/vba/vbashape.hxx 2008-03-27 17:05:15.000000000 +0000
+@@ -52,6 +52,7 @@ typedef InheritedHelperInterfaceImpl< Li
+
+ class ScVbaShape : public ScVbaShape_BASE
+ {
++friend class ConcreteXShapeHelper; // perhaps an accessor would be better
+ private:
+ protected:
+ css::uno::Reference< css::drawing::XShape > m_xShape;
+diff -rup /esata1/BUILD-related/HEAD/ooo-build/build/ooh680-m12/sc/source/ui/vba/vbaworksheet.cxx sc/source/ui/vba/vbaworksheet.cxx
+--- /esata1/BUILD-related/HEAD/ooo-build/build/ooh680-m12/sc/source/ui/vba/vbaworksheet.cxx 2008-03-19 10:56:34.000000000 +0000
++++ sc/source/ui/vba/vbaworksheet.cxx 2008-03-27 14:57:30.000000000 +0000
+@@ -61,6 +61,7 @@
+ #include <com/sun/star/drawing/XDrawPageSupplier.hpp>
+ #include <com/sun/star/drawing/XControlShape.hpp>
+ #include <com/sun/star/form/FormComponentType.hpp>
++#include <com/sun/star/form/XFormsSupplier.hpp>
+
+ #include <comphelper/processfactory.hxx>
+
+@@ -421,6 +422,7 @@ ScVbaWorksheet::Delete() throw (uno::Run
+ uno::Reference<sheet::XSpreadsheets> xSheets = xSpreadDoc->getSheets();
+ uno::Reference<container::XNameContainer> xNameContainer(xSheets,uno::UNO_QUERY_THROW);
+ xNameContainer->removeByName(aSheetName);
++ mxSheet.clear();
+ }
+ }
+
+@@ -661,29 +663,10 @@ ScVbaWorksheet::setValue( const ::rtl::O
+ uno::Any SAL_CALL
+ ScVbaWorksheet::getValue( const ::rtl::OUString& aPropertyName ) throw (beans::UnknownPropertyException, uno::RuntimeException)
+ {
+-/* uno::Any aProp = getControl( aPropertyName );
+-
+- if ( !aProp.hasValue() )
+- throw beans::UnknownPropertyException(); // unsupported operation
+- // #TODO we need a factory here when we support
+- // more control types
+- sal_Int32 nClassId = -1;
+- uno::Reference< beans::XPropertySet > xProps( aProp, uno::UNO_QUERY_THROW );
+- const static rtl::OUString sClassId( RTL_CONSTASCII_USTRINGPARAM("ClassId") );
+- xProps->getPropertyValue( sClassId ) >>= nClassId;
+- ScVbaControlFactory controlFactory( m_xContext, xProps, xControlShape );
+- uno::Reference< vba::XControl > xControl( controlFactory.createControl( nClassId ) );
+- if ( nClassId == form::FormComponentType::COMBOBOX )
+- {
+- uno::Reference< msforms::XComboBox > xCbx( new ScVbaComboBox( m_xContext, xProps ) );
+- return uno::makeAny( xCbx );
+- }
+-*/
+ uno::Reference< drawing::XControlShape > xControlShape( getControlShape( aPropertyName ), uno::UNO_QUERY_THROW );
+ ScVbaControlFactory controlFactory( mxContext, xControlShape );
+ uno::Reference< msforms::XControl > xControl( controlFactory.createControl() );
+ return uno::makeAny( xControl );
+-// return aProp;
+ }
+
+ ::sal_Bool SAL_CALL
+@@ -691,84 +674,65 @@ ScVbaWorksheet::hasMethod( const ::rtl::
+ {
+ return sal_False;
+ }
+-::sal_Bool SAL_CALL
+-ScVbaWorksheet::hasProperty( const ::rtl::OUString& aName ) throw (uno::RuntimeException)
++
++uno::Reference< container::XNameAccess >
++ScVbaWorksheet::getFormControls()
+ {
++ uno::Reference< container::XNameAccess > xFormControls;
+ try
+ {
+- if ( getControl( aName ).hasValue() )
+- return sal_True;
+- }
+- catch( uno::Exception& )
++ uno::Reference< sheet::XSpreadsheet > xSpreadsheet( getSheet(), uno::UNO_QUERY_THROW );
++ uno::Reference< drawing::XDrawPageSupplier > xDrawPageSupplier( xSpreadsheet, uno::UNO_QUERY_THROW );
++ uno::Reference< form::XFormsSupplier > xFormSupplier( xDrawPageSupplier->getDrawPage(), uno::UNO_QUERY_THROW );
++ uno::Reference< container::XIndexAccess > xIndexAccess( xFormSupplier->getForms(), uno::UNO_QUERY_THROW );
++ // get the www-standard container ( maybe we should access the
++ // 'www-standard' by name rather than index, this seems an
++ // implementation detail
++ xFormControls.set( xIndexAccess->getByIndex(0), uno::UNO_QUERY_THROW );
++
++ }
++ catch( uno::Exception & )
+ {
+ }
+- return sal_False;
++ return xFormControls;
++
+ }
+-uno::Any
+-ScVbaWorksheet::getControl( const ::rtl::OUString& sName )
++::sal_Bool SAL_CALL
++ScVbaWorksheet::hasProperty( const ::rtl::OUString& aName ) throw (uno::RuntimeException)
+ {
+- uno::Reference< sheet::XScenarioEnhanced > xIf( getSheet(), uno::UNO_QUERY_THROW );
+- ScTableSheetObj* pTab= static_cast< ScTableSheetObj* >( xIf.get() );
+- ScDocShell* pShell = NULL;
+- if ( pTab )
+- pShell = pTab->GetDocShell();
+- if ( pShell )
+- {
+- ScDrawLayer* pDrawLayer = pShell->MakeDrawLayer();
+- SCTAB nTab = 0;
+- // make GetTab_Impl() public or this class a friend
+- const ScRangeList& rRanges = pTab->GetRangeList();
+- const ScRange* pFirst = rRanges.GetObject(0);
+- if (pFirst)
+- nTab = pFirst->aStart.Tab();
+-
+- SdrPage* pPage = pDrawLayer->GetPage(static_cast<sal_uInt16>(nTab));
+- if ( pPage )
+- {
+- ULONG nCount = pPage->GetObjCount();
+- for ( ULONG index=0; index<nCount; ++index )
+- {
+- SdrObject* pObj = pPage->GetObj( index );
+- if ( pObj )
+- {
+-
+- SdrUnoObj* pUnoObj = PTR_CAST(SdrUnoObj, pObj);
+- if ( pUnoObj )
+- {
+- uno::Reference< container::XNamed > xNamed( pUnoObj->GetUnoControlModel(), uno::UNO_QUERY_THROW );
+- if ( sName.equals( xNamed->getName() ) )
+- return uno::makeAny( xNamed );
+- }
+- }
+- }
+- }
+- }
+-
+- return uno::Any();
++ uno::Reference< container::XNameAccess > xFormControls( getFormControls() );
++ if ( xFormControls.is() )
++ return xFormControls->hasByName( aName );
++ return sal_False;
+ }
+
+ uno::Any
+ ScVbaWorksheet::getControlShape( const ::rtl::OUString& sName )
+ {
+- //uno::Reference< sheet::XScenarioEnhanced > xIf( getSheet(), uno::UNO_QUERY_THROW );
+- uno::Reference< sheet::XSpreadsheet > xSpreadsheet( getSheet(), uno::UNO_QUERY_THROW );
+- uno::Reference< drawing::XDrawPageSupplier > xDrawPageSupplier( xSpreadsheet, uno::UNO_QUERY_THROW );
+- uno::Reference< drawing::XDrawPage > xDrawPage( xDrawPageSupplier->getDrawPage(), uno::UNO_QUERY_THROW );
+- uno::Reference< container::XIndexAccess > xIndexAccess( xDrawPage, uno::UNO_QUERY_THROW );
++ // ideally we would get an XControl object but it appears an XControl
++ // implementation only exists for a Control implementation optained from the
++ // view ( e.g. in basic you would get this from
++ // thiscomponent.currentcontroller.getControl( controlModel ) )
++ // and the thing to realise is that it is only possible to get an XControl
++ // for a currently displayed control :-( often we would want to modify
++ // a control not on the active sheet. But.. you can always access the
++ // XControlShape from the DrawPage whether that is the active drawpage or not
++
++ uno::Reference< drawing::XDrawPageSupplier > xDrawPageSupplier( getSheet(), uno::UNO_QUERY_THROW );
++ uno::Reference< container::XIndexAccess > xIndexAccess( xDrawPageSupplier->getDrawPage(), uno::UNO_QUERY_THROW );
++
+ sal_Int32 nCount = xIndexAccess->getCount();
+ for( int index = 0; index < nCount; index++ )
+ {
+ uno::Any aUnoObj = xIndexAccess->getByIndex( index );
+ uno::Reference< drawing::XControlShape > xControlShape( aUnoObj, uno::UNO_QUERY_THROW );
+- uno::Reference< awt::XControlModel > xControlModel( xControlShape->getControl() );
+- uno::Reference< container::XNamed > xNamed( xControlModel, uno::UNO_QUERY_THROW );
++ uno::Reference< container::XNamed > xNamed( xControlShape->getControl(), uno::UNO_QUERY_THROW );
+ if( sName.equals( xNamed->getName() ))
+ {
+ return aUnoObj;
+ }
+-
+ }
+- return uno::Any();
++ return uno::Any();
+ }
+
+
+diff -rup /esata1/BUILD-related/HEAD/ooo-build/build/ooh680-m12/sc/source/ui/vba/vbaworksheet.hxx sc/source/ui/vba/vbaworksheet.hxx
+--- /esata1/BUILD-related/HEAD/ooo-build/build/ooh680-m12/sc/source/ui/vba/vbaworksheet.hxx 2008-03-19 10:56:34.000000000 +0000
++++ sc/source/ui/vba/vbaworksheet.hxx 2008-03-27 12:28:28.000000000 +0000
+@@ -62,7 +62,7 @@ class ScVbaWorksheet : public WorksheetI
+ css::uno::Reference< oo::excel::XWorksheet > getSheetAtOffset(SCTAB offset) throw (css::uno::RuntimeException);
+ css::uno::Reference< oo::excel::XRange > getSheetRange() throw (css::uno::RuntimeException);
+
+- css::uno::Any getControl( const rtl::OUString& sName );
++ css::uno::Reference< css::container::XNameAccess > getFormControls();
+ css::uno::Any getControlShape( const rtl::OUString& sName );
+ protected:
+
+diff -rup /esata1/BUILD-related/HEAD/ooo-build/build/ooh680-m12/sc/source/ui/view/viewfun2.cxx sc/source/ui/view/viewfun2.cxx
+--- /esata1/BUILD-related/HEAD/ooo-build/build/ooh680-m12/sc/source/ui/view/viewfun2.cxx 2008-03-19 10:56:43.000000000 +0000
++++ sc/source/ui/view/viewfun2.cxx 2008-03-20 10:25:13.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"
+@@ -2091,15 +2096,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;
+@@ -2166,9 +2198,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)] ) );
+ }
+ }
+@@ -2196,6 +2237,7 @@ BOOL ScViewFunc::DeleteTables(const SvSh
+ pDocSh->PostPaintExtras();
+ pDocSh->SetDocumentModified();
+
++
+ SfxApplication* pSfxApp = SFX_APP(); // Navigator
+ pSfxApp->Broadcast( SfxSimpleHint( SC_HINT_TABLES_CHANGED ) );
+ pSfxApp->Broadcast( SfxSimpleHint( SC_HINT_DBAREAS_CHANGED ) );
+diff -rup /esata1/BUILD-related/HEAD/ooo-build/build/ooh680-m12/basctl/source/basicide/basides1.cxx basctl/source/basicide/basides1.cxx
+--- /esata1/BUILD-related/HEAD/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-20 18:10:19.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 /esata1/BUILD-related/HEAD/ooo-build/build/ooh680-m12/basctl/source/basicide/basides2.cxx basctl/source/basicide/basides2.cxx
+--- /esata1/BUILD-related/HEAD/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-20 10:25:13.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 /esata1/BUILD-related/HEAD/ooo-build/build/ooh680-m12/basctl/source/basicide/basidesh.cxx basctl/source/basicide/basidesh.cxx
+--- /esata1/BUILD-related/HEAD/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-25 11:09:33.000000000 +0000
+@@ -97,6 +97,9 @@
+ #ifndef _COM_SUN_STAR_CONTAINER_XNAMECONTAINER_HPP_
+ #include <com/sun/star/container/XNameContainer.hpp>
+ #endif
++#include <com/sun/star/container/XContainer.hpp>
++#include <com/sun/star/container/XContainerListener.hpp>
++#include <com/sun/star/script/XLibraryContainer.hpp>
+
+ #include <svx/xmlsecctrl.hxx>
+
+@@ -104,6 +107,71 @@ using namespace ::com::sun::star::uno;
+ using namespace ::com::sun::star;
+ using ::rtl::OUString;
+
++static const rtl::OUString sStandardLibName( rtl::OUString::createFromAscii("Standard") );
++
++typedef ::cppu::WeakImplHelper1< container::XContainerListener > ContainerListenerBASE;
++
++class ContainerListenerImpl : public ContainerListenerBASE
++{
++ BasicIDEShell* mpShell;
++public:
++
++ ContainerListenerImpl( BasicIDEShell* pShell ) : mpShell( pShell ) {}
++
++ ~ContainerListenerImpl()
++ {
++ }
++
++ void addContainerListener( const ScriptDocument& rScriptDocument )
++ {
++ uno::Reference< container::XContainer > xContainer( rScriptDocument.getLibrary( E_SCRIPTS, sStandardLibName, FALSE ), uno::UNO_QUERY );
++ if ( rScriptDocument.isDocument() && xContainer.is() )
++ {
++ uno::Reference< container::XContainerListener > xContainerListener( this );
++ try
++ {
++ xContainer->addContainerListener( xContainerListener );
++ }
++ catch( uno::Exception& ) {}
++ }
++ }
++ void removeContainerListener( const ScriptDocument& rScriptDocument )
++ {
++ uno::Reference< container::XContainer > xContainer( rScriptDocument.getLibrary( E_SCRIPTS, sStandardLibName, FALSE ), uno::UNO_QUERY );
++ if ( rScriptDocument.isDocument(), xContainer.is() )
++ {
++ uno::Reference< container::XContainerListener > xContainerListener( this );
++ try
++ {
++ xContainer->removeContainerListener( xContainerListener );
++ }
++ catch( uno::Exception& ) {}
++ }
++ }
++
++ // XEventListener
++ virtual void SAL_CALL disposing( const lang::EventObject& ) throw( uno::RuntimeException ) {}
++
++ // XContainerListener
++ virtual void SAL_CALL elementInserted( const container::ContainerEvent& Event ) throw( uno::RuntimeException )
++ {
++ rtl::OUString sModuleName;
++ if( mpShell && ( Event.Accessor >>= sModuleName ) )
++ mpShell->FindBasWin( mpShell->m_aCurDocument, sStandardLibName, sModuleName, TRUE, FALSE );
++ }
++ virtual void SAL_CALL elementReplaced( const container::ContainerEvent& ) throw( com::sun::star::uno::RuntimeException ) { }
++ virtual void SAL_CALL elementRemoved( const container::ContainerEvent& Event ) throw( com::sun::star::uno::RuntimeException )
++ {
++ rtl::OUString sModuleName;
++ if( mpShell && ( Event.Accessor >>= sModuleName ) )
++ {
++ IDEBaseWindow* pWin = mpShell->FindWindow( mpShell->m_aCurDocument, sStandardLibName, sModuleName, BASICIDE_TYPE_MODULE, TRUE );
++ if( pWin )
++ mpShell->RemoveWindow( pWin, FALSE, TRUE );
++ }
++ }
++
++};
+
+ TYPEINIT1( BasicIDEShell, SfxViewShell );
+
+@@ -141,6 +209,7 @@ BasicIDEShell::BasicIDEShell( SfxViewFra
+ m_bAppBasicModified( FALSE ),
+ m_aNotifier( *this )
+ {
++ m_xLibListener = new ContainerListenerImpl( this );
+ Init();
+ GnBasicIDEShellCount++;
+ }
+@@ -156,6 +225,7 @@ BasicIDEShell::BasicIDEShell( SfxViewFra
+ m_aNotifier( *this )
+ {
+ DBG_ERROR( "Zweite Ansicht auf Debugger nicht moeglich!" );
++ m_xLibListener = new ContainerListenerImpl( this );
+ GnBasicIDEShellCount++;
+ }
+
+@@ -170,6 +240,7 @@ BasicIDEShell::BasicIDEShell( SfxViewFra
+ m_aNotifier( *this )
+ {
+ Init();
++ m_xLibListener = new ContainerListenerImpl( this );
+ GnBasicIDEShellCount++;
+ }
+
+@@ -258,6 +329,12 @@ __EXPORT BasicIDEShell::~BasicIDEShell()
+ delete pTabBar;
+ delete pObjectCatalog;
+ DestroyModulWindowLayout();
++
++ ContainerListenerImpl* pListener = dynamic_cast< ContainerListenerImpl* >( m_xLibListener.get() );
++ // Destroy all ContainerListeners for Basic Container.
++ if ( pListener )
++ pListener->removeContainerListener( m_aCurDocument );
++
+ // MI: Das gab einen GPF im SDT beim Schliessen da dann der ViewFrame die
+ // ObjSh loslaesst. Es wusste auch keiner mehr wozu das gut war.
+ // GetViewFrame()->GetObjectShell()->Broadcast( SfxSimpleHint( SFX_HINT_DYING ) );
+@@ -275,6 +352,7 @@ sal_Bool BasicIDEShell::HasBasic() const
+
+ void BasicIDEShell::onDocumentCreated( const ScriptDocument& /*_rDocument*/ )
+ {
++ // _rDocument is not a valid ScriptDocument.
+ UpdateWindows();
+ }
+
+@@ -303,6 +381,8 @@ void BasicIDEShell::onDocumentSaveAsDone
+ // not interested in
+ }
+
++//============================================================================
++
+ void BasicIDEShell::onDocumentClosed( const ScriptDocument& _rDocument )
+ {
+ if ( !_rDocument.isValid() )
+@@ -402,7 +482,6 @@ void BasicIDEShell::StoreAllWindowData(
+ }
+ }
+
+-
+ USHORT __EXPORT BasicIDEShell::PrepareClose( BOOL bUI, BOOL bForBrowsing )
+ {
+ (void)bForBrowsing;
+@@ -600,7 +679,6 @@ void BasicIDEShell::ShowObjectDialog( BO
+ }
+
+
+-
+ void __EXPORT BasicIDEShell::SFX_NOTIFY( SfxBroadcaster& rBC, const TypeId&,
+ const SfxHint& rHint, const TypeId& )
+ {
+@@ -983,7 +1061,15 @@ void BasicIDEShell::SetCurLib( const Scr
+ {
+ if ( !bCheck || ( rDocument != m_aCurDocument || aLibName != m_aCurLibName ) )
+ {
++ ContainerListenerImpl* pListener = dynamic_cast< ContainerListenerImpl* >( m_xLibListener.get() );
++ if ( pListener )
++ pListener->removeContainerListener( m_aCurDocument );
++
+ m_aCurDocument = rDocument;
++
++ if ( pListener )
++ pListener->addContainerListener( m_aCurDocument );
++
+ m_aCurLibName = aLibName;
+ if ( bUpdateWindows )
+ UpdateWindows();
+diff -rup /esata1/BUILD-related/HEAD/ooo-build/build/ooh680-m12/basctl/source/basicide/scriptdocument.cxx basctl/source/basicide/scriptdocument.cxx
+--- /esata1/BUILD-related/HEAD/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-20 11:00:13.000000000 +0000
+@@ -61,6 +61,7 @@
+ #include <com/sun/star/frame/XModel2.hpp>
+ #include <com/sun/star/awt/XWindow2.hpp>
+ #include <com/sun/star/document/XEmbeddedScripts.hpp>
++#include <com/sun/star/script/ModuleInfo.hpp>
+ /** === end UNO includes === **/
+
+ #include <sfx2/objsh.hxx>
+@@ -146,6 +147,7 @@ namespace basctl
+ using ::com::sun::star::uno::RuntimeException;
+ using ::com::sun::star::document::XEventBroadcaster;
+ using ::com::sun::star::document::XEmbeddedScripts;
++ using ::com::sun::star::script::ModuleInfo;
+ /** === end UNO using === **/
+ namespace MacroExecMode = ::com::sun::star::document::MacroExecMode;
+ namespace FrameSearchFlag = ::com::sun::star::frame::FrameSearchFlag;
+@@ -678,6 +680,15 @@ namespace basctl
+ }
+
+ // insert element by new name in container
++ if ( _eType == E_SCRIPTS )
++ {
++ ModuleInfo sModuleInfo;
++ if ( aElement >>= sModuleInfo )
++ {
++ sModuleInfo.ModuleName = _rNewName;
++ aElement <<= sModuleInfo;
++ }
++ }
+ xLib->insertByName( _rNewName, aElement );
+ return true;
+ }
+@@ -1433,7 +1444,15 @@ namespace basctl
+ Any aCode;
+ if ( !m_pImpl->getModuleOrDialog( E_SCRIPTS, _rLibName, _rModName, aCode ) )
+ return false;
+- OSL_VERIFY( aCode >>= _out_rModuleSource );
++ ModuleInfo sModuleInfo;
++ if ( aCode >>= sModuleInfo )
++ {
++ _out_rModuleSource = sModuleInfo.ModuleSource;
++ }
++ else
++ {
++ OSL_VERIFY( aCode >>= _out_rModuleSource );
++ }
+ return true;
+ }
+
+diff -rup /esata1/BUILD-related/HEAD/ooo-build/build/ooh680-m12/basctl/source/inc/basidesh.hxx basctl/source/inc/basidesh.hxx
+--- /esata1/BUILD-related/HEAD/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-20 15:54:09.000000000 +0000
+@@ -62,7 +62,7 @@
+ #ifndef _COM_SUN_STAR_IO_XINPUTSTREAMPROVIDER_HXX_
+ #include <com/sun/star/io/XInputStreamProvider.hpp>
+ #endif
+-
++#include <com/sun/star/container/XContainerListener.hpp>
+
+ //----------------------------------------------------------------------------
+
+@@ -90,13 +90,15 @@ DECLARE_TABLE( IDEWindowTable, IDEBaseWi
+ typedef Table IDEWindowTable;
+ #endif
+
++namespace css = ::com::sun::star;
++
+ class BasicIDEShell :public SfxViewShell
+ ,public ::basctl::DocumentEventListener
+ {
+ friend class JavaDebuggingListenerImpl;
+ friend class LocalizationMgr;
+ friend class BasicIDE;
+-
++friend class ContainerListenerImpl;
+ ObjectCatalog* pObjectCatalog;
+
+ IDEWindowTable aIDEWindowTable;
+@@ -116,6 +118,7 @@ friend class BasicIDE;
+ BOOL m_bAppBasicModified;
+ ::basctl::DocumentEventNotifier
+ m_aNotifier;
++ css::uno::Reference< css::container::XContainerListener > m_xLibListener;
+
+ #if _SOLAR__PRIVATE
+ void Init();
+diff -rup /esata1/BUILD-related/HEAD/ooo-build/build/ooh680-m12/basic/inc/basic/sbdef.hxx basic/inc/basic/sbdef.hxx
+--- /esata1/BUILD-related/HEAD/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-20 14:07:06.000000000 +0000
+@@ -100,6 +100,8 @@ void setBasicWatchMode( bool bOn );
+
+ #define SBXID_BASIC 0x6273 // sb: StarBASIC
+ #define SBXID_BASICMOD 0x6d62 // bm: StarBASIC-Modul
++#define SBXID_DOCUMENTMOD 0x6d63 // Special document Module
++#define SBXID_USERFORMMOD 0x6d64 // Special userform Module
+ #define SBXID_BASICPROP 0x7262 // pr: StarBASIC-Property
+ #define SBXID_BASICMETHOD 0x6d65 // me: StarBASIC-Methode
+ #define SBXID_JSCRIPTMOD 0x6a62 // jm: JavaScript-Modul
+diff -rup /esata1/BUILD-related/HEAD/ooo-build/build/ooh680-m12/basic/inc/basic/sbstar.hxx basic/inc/basic/sbstar.hxx
+--- /esata1/BUILD-related/HEAD/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-20 10:25:13.000000000 +0000
+@@ -51,6 +51,7 @@
+
+ #include <basic/sbdef.hxx>
+ #include <basic/sberrors.hxx>
++#include <com/sun/star/script/ModuleInfo.hpp>
+
+ class SbModule; // fertiges Modul
+ class SbiInstance; // Laufzeit-Instanz
+@@ -82,6 +83,7 @@ class StarBASIC : public SbxObject
+ BOOL bNoRtl; // TRUE: RTL nicht durchsuchen
+ BOOL bBreak; // TRUE: Break, sonst Step
+ BOOL bDocBasic;
++ BOOL bVBAEnabled;
+ BasicLibInfo* pLibInfo; // Infoblock fuer Basic-Manager
+ SbLanguageMode eLanguageMode; // LanguageMode des Basic-Objekts
+ protected:
+@@ -124,7 +126,8 @@ public:
+
+ // Compiler-Interface
+ SbModule* MakeModule( const String& rName, const String& rSrc );
+- SbModule* MakeModule32( const String& rName, const ::rtl::OUString& rSrc );
++ SbModule* MakeModule32( const String& rName, const ::rtl::OUString& rSrc );
++ SbModule* MakeObjModule( const String& rName, const com::sun::star::script::ModuleInfo& mInfo );
+ BOOL Compile( SbModule* );
+ BOOL Disassemble( SbModule*, String& rText );
+ static void Stop();
+@@ -196,6 +199,8 @@ public:
+ ( const String& rName, USHORT& rStatus );
+ static SbMethod* GetActiveMethod( USHORT nLevel = 0 );
+ static SbModule* GetActiveModule();
++ void SetVBAEnabled( BOOL bEnabled );
++ BOOL isVBAEnabled();
+
+ // #60175 TRUE: SFX-Resource wird bei Basic-Fehlern nicht angezogen
+ static void StaticSuppressSfxResource( BOOL bSuppress );
+diff -rup /esata1/BUILD-related/HEAD/ooo-build/build/ooh680-m12/basic/inc/basic/sbxobj.hxx basic/inc/basic/sbxobj.hxx
+--- /esata1/BUILD-related/HEAD/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-20 10:25:13.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 /esata1/BUILD-related/HEAD/ooo-build/build/ooh680-m12/basic/source/basmgr/basmgr.cxx basic/source/basmgr/basmgr.cxx
+--- /esata1/BUILD-related/HEAD/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-20 15:18:11.000000000 +0000
+@@ -102,6 +102,8 @@
+ #include <com/sun/star/script/XStarBasicDialogInfo.hpp>
+ #include <com/sun/star/script/XStarBasicLibraryInfo.hpp>
+ #include <com/sun/star/script/XLibraryContainerPassword.hpp>
++#include <com/sun/star/script/ModuleInfo.hpp>
++#include <com/sun/star/script/ModuleType.hpp>
+
+ #include <cppuhelper/implbase1.hxx>
+
+@@ -145,6 +147,7 @@ static const char* szScriptLanguage = "S
+ static const String BasicStreamName( String::CreateFromAscii(szBasicStorage) );
+ static const String ManagerStreamName( String::CreateFromAscii(szManagerStream) );
+
++//enum ModuleType { Unknown = 0, Normal, Class, Form, Document };
+
+ #define DEFINE_CONST_UNICODE(CONSTASCII) UniString(RTL_CONSTASCII_USTRINGPARAM(CONSTASCII))
+
+@@ -280,9 +283,22 @@ void BasMgrContainerListenerImpl::addLib
+ {
+ OUString aModuleName = pNames[ j ];
+ Any aElement = xLibNameAccess->getByName( aModuleName );
++ ModuleInfo mInfo;
+ OUString aMod;
+- aElement >>= aMod;
+- pLib->MakeModule32( aModuleName, aMod );
++ sal_Int16 mType;
++ if ( aElement >>= mInfo )
++ {
++ aMod = mInfo.ModuleSource;
++ mType = mInfo.ModuleType;
++ OSL_TRACE("#1 - aMod");
++ //pLib->MakeModule32( aModuleName, aMod, SBXID_DOCUMENTMOD );
++ pLib->MakeObjModule( aModuleName, mInfo );
++ }
++ else
++ {
++ aElement >>= aMod;
++ pLib->MakeModule32( aModuleName, aMod );
++ }
+ }
+ }
+
+@@ -319,8 +335,16 @@ void SAL_CALL BasMgrContainerListenerImp
+ }
+ else
+ {
++ ModuleInfo mInfo;
+ OUString aMod;
+- Event.Element >>= aMod;
++ sal_Int16 mType;
++ if( Event.Element >>= mInfo )
++ {
++ aMod = mInfo.ModuleSource;
++ mType = mInfo.ModuleType;
++ }
++ else
++ Event.Element >>= aMod;
+
+ StarBASIC* pLib = mpMgr->GetLib( maLibName );
+ DBG_ASSERT( pLib, "BasMgrContainerListenerImpl::elementInserted: Unknown lib!");
+@@ -329,7 +353,15 @@ void SAL_CALL BasMgrContainerListenerImp
+ SbModule* pMod = pLib->FindModule( aName );
+ if( !pMod )
+ {
+- pLib->MakeModule32( aName, aMod );
++ if ( mType == ::com::sun::star::script::ModuleType::Document )
++ {
++ //pLib->MakeModule32( aName, aMod, SBXID_DOCUMENTMOD );
++ pLib->MakeObjModule( aName, mInfo );
++ }
++ else
++ {
++ pLib->MakeModule32( aName, aMod );
++ }
+ pLib->SetModified( FALSE );
+ }
+ }
+@@ -356,12 +388,27 @@ void SAL_CALL BasMgrContainerListenerImp
+ if( pLib )
+ {
+ SbModule* pMod = pLib->FindModule( aName );
++ ModuleInfo mInfo;
+ OUString aMod;
++ sal_Int16 mType;
+ Event.Element >>= aMod;
+ if( pMod )
+ pMod->SetSource32( aMod );
+ else
+- pLib->MakeModule32( aName, aMod );
++ {
++ if( Event.Element >>= mInfo )
++ {
++ aMod = mInfo.ModuleSource;
++ mType = mInfo.ModuleType;
++ //pLib->MakeModule32( aName, aMod, SBXID_DOCUMENTMOD );
++ pLib->MakeObjModule( aName, mInfo );
++ }
++ else
++ {
++ Event.Element >>= aMod;
++ pLib->MakeModule32( aName, aMod );
++ }
++ }
+
+ pLib->SetModified( FALSE );
+ }
+diff -rup /esata1/BUILD-related/HEAD/ooo-build/build/ooh680-m12/basic/source/classes/eventatt.cxx basic/source/classes/eventatt.cxx
+--- /esata1/BUILD-related/HEAD/ooo-build/build/ooh680-m12/basic/source/classes/eventatt.cxx 2008-03-19 10:56:33.000000000 +0000
++++ basic/source/classes/eventatt.cxx 2008-03-26 11:36:15.000000000 +0000
+@@ -505,7 +505,6 @@ void RTL_Impl_CreateUnoDialog( StarBASIC
+ {
+ static OUString aResourceResolverPropName = OUString::createFromAscii( "ResourceResolver" );
+
+- (void)pBasic;
+ (void)bWrite;
+
+ Reference< XMultiServiceFactory > xMSF( comphelper::getProcessServiceFactory() );
+@@ -576,7 +575,7 @@ void RTL_Impl_CreateUnoDialog( StarBASIC
+ }
+
+ // Find dialog library for dialog, direct access is not possible here
+- StarBASIC* pStartedBasic = pINST->GetBasic();
++ StarBASIC* pStartedBasic = pINST ? pBasic : pINST->GetBasic();
+ SbxObject* pParentBasic = pStartedBasic ? pStartedBasic->GetParent() : NULL;
+ SbxObject* pParentParentBasic = pParentBasic ? pParentBasic->GetParent() : NULL;
+
+diff -rup /esata1/BUILD-related/HEAD/ooo-build/build/ooh680-m12/basic/source/classes/sb.cxx basic/source/classes/sb.cxx
+--- /esata1/BUILD-related/HEAD/ooo-build/build/ooh680-m12/basic/source/classes/sb.cxx 2008-03-19 10:56:58.000000000 +0000
++++ basic/source/classes/sb.cxx 2008-03-20 15:18:11.000000000 +0000
+@@ -70,6 +70,7 @@
+ #include "disas.hxx"
+ #include "runtime.hxx"
+ #include <basic/sbuno.hxx>
++#include <basic/sbobjmod.hxx>
+ #include "stdobj.hxx"
+ #include "filefmt.hxx"
+ #include "sb.hrc"
+@@ -79,6 +80,10 @@
+ #include <vos/mutex.hxx>
+ #endif
+
++#include <com/sun/star/script/ModuleType.hpp>
++#include <com/sun/star/script/ModuleInfo.hpp>
++using namespace ::com::sun::star::script;
++
+ // #pragma SW_SEGMENT_CLASS( SBASIC, SBASIC_CODE )
+
+ SV_IMPL_VARARR(SbTextPortions,SbTextPortion)
+@@ -667,6 +672,7 @@ StarBASIC::StarBASIC( StarBASIC* p, BOOL
+ SetParent( p );
+ pLibInfo = NULL;
+ bNoRtl = bBreak = FALSE;
++ bVBAEnabled = FALSE;
+ pModules = new SbxArray;
+
+ if( !GetSbData()->nInst++ )
+@@ -769,13 +775,36 @@ SbModule* StarBASIC::MakeModule( const S
+
+ SbModule* StarBASIC::MakeModule32( const String& rName, const ::rtl::OUString& rSrc )
+ {
+- SbModule* p = new SbModule( rName );
++ SbModule* p = new SbModule( rName );
+ p->SetSource32( rSrc );
+ p->SetParent( this );
+ pModules->Insert( p, pModules->Count() );
+ SetModified( TRUE );
+ return p;
+ }
++SbModule* StarBASIC::MakeObjModule( const String& rName, const ModuleInfo& mInfo )
++{
++
++ SbObjModule* p = NULL;
++ switch ( mInfo.ModuleType )
++ {
++ case ModuleType::Document:
++ p = new SbObjModule( rName, mInfo );
++ break;
++ case ModuleType::Form:
++ p = new SbUserFormModule( rName, mInfo );
++ break;
++ default:
++ break; //
++ }
++ if ( p )
++ {
++ pModules->Insert( p, pModules->Count() );
++ SetModified( TRUE );
++ p->SetParent( this );
++ }
++ return p;
++}
+
+ void StarBASIC::Insert( SbxVariable* pVar )
+ {
+@@ -948,6 +977,9 @@ SbxVariable* StarBASIC::Find( const Stri
+ }
+ pNamed = p;
+ }
++ if ( p->GetSbxId() == SBXID_DOCUMENTMOD
++ || p->GetSbxId() == SBXID_USERFORMMOD )
++ continue;
+ // Sonst testen, ob das Element vorhanden ist
+ // GBLSEARCH-Flag rausnehmen (wg. Rekursion)
+ USHORT nGblFlag = p->GetFlags() & SBX_GBLSEARCH;
+diff -rup /esata1/BUILD-related/HEAD/ooo-build/build/ooh680-m12/basic/source/classes/sbxmod.cxx basic/source/classes/sbxmod.cxx
+--- /esata1/BUILD-related/HEAD/ooo-build/build/ooh680-m12/basic/source/classes/sbxmod.cxx 2008-03-19 10:56:58.000000000 +0000
++++ basic/source/classes/sbxmod.cxx 2008-03-26 16:06:20.000000000 +0000
+@@ -62,6 +62,9 @@
+ #include "sbunoobj.hxx"
+ #include <basic/hilight.hxx>
+ #include <basic/basrdll.hxx>
++#include <basic/sbobjmod.hxx>
++#include <com/sun/star/script/XObjectProvider.hpp>
++#include <com/sun/star/lang/XServiceInfo.hpp>
+
+ #ifndef _VOS_MUTEX_HXX_
+ #include <vos/mutex.hxx>
+@@ -80,7 +83,18 @@
+
+ #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/frame/XModel.hpp>
++#include <cppuhelper/implbase1.hxx>
++#include <comphelper/anytostring.hxx>
++
++using namespace ::com::sun::star;
++
+ static const String sThisWorkbook( RTL_CONSTASCII_USTRINGPARAM("ThisWorkbook"));
++static const rtl::OUString sStandard( RTL_CONSTASCII_USTRINGPARAM("Standard") );
+
+ TYPEINIT1(SbModule,SbxObject)
+ TYPEINIT1(SbMethod,SbxMethod)
+@@ -88,6 +102,8 @@ TYPEINIT1(SbProperty,SbxProperty)
+ TYPEINIT1(SbProcedureProperty,SbxProperty)
+ TYPEINIT1(SbJScriptModule,SbModule)
+ TYPEINIT1(SbJScriptMethod,SbMethod)
++TYPEINIT1(SbObjModule,SbModule)
++TYPEINIT1(SbUserFormModule,SbModule)
+
+ SV_DECL_VARARR(SbiBreakpoints,USHORT,4,4)
+ SV_IMPL_VARARR(SbiBreakpoints,USHORT)
+@@ -1903,6 +1919,275 @@ void SyntaxHighlighter::getHighlightPort
+ m_pSimpleTokenizer->getHighlightPortions( nLine, rLine, portions );
+ }
+
++/////////////////////////////////////////////////////////////////////////
++SbObjModule::SbObjModule( const rtl::OUString& rName, const com::sun::star::script::ModuleInfo& mInfo )
++ :SbModule( rName ), pDocObject( NULL )
++{
++ m_mInfo = mInfo;
++ SetSource32( mInfo.ModuleSource );
++}
++
++BOOL
++SbObjModule::IsClass( const XubString& rName )
++{
++ GetObject();
++ return SbxObject::IsClass( rName );
++}
++
++SbxVariable*
++SbObjModule::GetObject()
++{
++ if( !pDocObject )
++ InitObject();
++ return pDocObject;
++}
++SbxVariable*
++SbObjModule::Find( const XubString& rName, SbxClassType t )
++{
++ OSL_TRACE("SbObjectModule find for %s", rtl::OUStringToOString( rName, RTL_TEXTENCODING_UTF8 ).getStr() );
++ if ( !pDocObject )
++ InitObject();
++ OSL_TRACE("!!!!try to find in derived module " );
++ SbxVariable* pVar = NULL;
++ if ( !pVar && pDocObject)
++ {
++ pVar = pDocObject->Find( rName, t );
++ if ( pVar )
++ {
++ OSL_TRACE("found in uno (psuedo-base) object" );
++ }
++ else
++ OSL_TRACE("NOT found in uno (psuedo-base) object" );
++ }
++ if ( !pVar )
++ {
++ pVar = SbModule::Find( rName, t );
++ if ( pVar )
++ OSL_TRACE("! found in (normal) module " );
++ }
++
++ return pVar;
++}
++
++void
++SbObjModule::InitObject()
++{
++ OSL_TRACE("Initialize pDocObject");
++ try
++ {
++ com::sun::star::uno::Reference< com::sun::star::script::XObjectProvider > xObjectProvider( m_mInfo.ModuleObjectProvider, com::sun::star::uno::UNO_QUERY_THROW );
++ com::sun::star::uno::Any aObject = xObjectProvider->getObject();
++ pDocObject = new SbUnoObject( GetName(), aObject );
++ com::sun::star::uno::Reference< com::sun::star::lang::XServiceInfo > xServiceInfo( aObject, com::sun::star::uno::UNO_QUERY_THROW );
++ if( xServiceInfo->supportsService( rtl::OUString::createFromAscii( "org.openoffice.excel.Worksheet" ) ) )
++ {
++ SetClassName( rtl::OUString::createFromAscii( "Worksheet" ) );
++ }
++ else if( xServiceInfo->supportsService( rtl::OUString::createFromAscii( "org.openoffice.excel.Workbook" ) ) )
++ {
++ SetClassName( rtl::OUString::createFromAscii( "Workbook" ) );
++ }
++ }catch( com::sun::star::uno::RuntimeException e )
++ {
++ OSL_TRACE("Object is not exist." );
++ }
++}
++
++typedef ::cppu::WeakImplHelper1< lang::XEventListener > EventListener_BASE;
++
++class FormObjEventListenerImpl : public EventListener_BASE
++{
++ SbUserFormModule* mpUserForm;
++ uno::Reference< lang::XComponent > mxComponent;
++ bool mbDisposed;
++ FormObjEventListenerImpl();// not defined
++ FormObjEventListenerImpl(const FormObjEventListenerImpl&);// not defined
++public:
++ FormObjEventListenerImpl( SbUserFormModule* pUserForm, const uno::Reference< lang::XComponent >& xComponent ) : mpUserForm( pUserForm ), mxComponent( xComponent) , mbDisposed( false )
++ {
++ if ( mxComponent.is() );
++ {
++ mxComponent->addEventListener( this );
++ }
++ }
++
++ ~FormObjEventListenerImpl()
++ {
++ removeListener();
++ }
++ void removeListener()
++ {
++ try
++ {
++ if ( mxComponent.is() && !mbDisposed )
++ {
++ mxComponent->removeEventListener( this );
++ mxComponent = NULL;
++ }
++ }
++ catch( uno::Exception& ) {}
++ }
++ virtual void SAL_CALL disposing( const lang::EventObject& Source ) throw (uno::RuntimeException)
++ {
++ mbDisposed = true;
++ uno::Any aSource;
++ aSource <<= Source;
++ mxComponent = NULL;
++ if ( mpUserForm )
++ mpUserForm->ResetApiObj();
++ }
++};
++
++
++static const char pHideStr[] = "Hide";
++USHORT SbUserFormModule::nHideHash = 0;
++
++SbUserFormModule::SbUserFormModule( const rtl::OUString& rName, const com::sun::star::script::ModuleInfo& mInfo )
++ :SbObjModule( rName, mInfo ), m_bUnloaded( true )
++{
++ if ( !nHideHash )
++ nHideHash = MakeHashCode( String::CreateFromAscii( pHideStr ) );
++ SbxVariable* p = Make( String::CreateFromAscii( pHideStr ), SbxCLASS_METHOD, SbxEMPTY );;
++ p->SetFlag( SBX_DONTSTORE );
++}
++
++void SbUserFormModule::SFX_NOTIFY( SfxBroadcaster& rCst, const TypeId& rId1, const SfxHint& rHint, const TypeId& rId2 )
++{
++ const SbxHint* p = PTR_CAST(SbxHint,&rHint);
++ if( p )
++ {
++ ULONG nId = p->GetId();
++ BOOL bRead = BOOL( nId == SBX_HINT_DATAWANTED );
++ BOOL bWrite = BOOL( nId == SBX_HINT_DATACHANGED );
++ SbxVariable* pVar = p->GetVar();
++ XubString aVarName( pVar->GetName() );
++
++ if( bRead || bWrite )
++ {
++ if( pVar->GetHashCode() == nHideHash && aVarName.EqualsIgnoreCaseAscii( pHideStr ) )
++ Hide();
++ else
++ return SbObjModule::SFX_NOTIFY( rCst, rId1, rHint, rId2 );
++ }
++ else
++ SbObjModule::SFX_NOTIFY( rCst, rId1, rHint, rId2 );
++ }
++}
++
++ void SbUserFormModule::ResetApiObj( bool bUnload )
++{
++ // trigger terminate event
++ pDocObject = NULL;
++ m_xDialog = NULL;
++ if ( bUnload )
++ {
++ triggerTerminateEvent();
++ m_bUnloaded = true;
++ }
++}
++
++void SbUserFormModule::triggerInitializeEvent( void )
++
++{
++ static String aInitMethodName( RTL_CONSTASCII_USTRINGPARAM("Userform_Initialize") );
++
++ // Search method
++ SbxVariable* pMeth = SbObjModule::Find( aInitMethodName, SbxCLASS_METHOD );
++ if( pMeth )
++ {
++ SbxValues aVals;
++ pMeth->Get( aVals );
++ }
++}
++
++void SbUserFormModule::triggerTerminateEvent( void )
++{
++ static String aTermMethodName( RTL_CONSTASCII_USTRINGPARAM("Userform_Terminate") );
++
++ // Search method
++ SbxVariable* pMeth = SbObjModule::Find( aTermMethodName, SbxCLASS_METHOD );
++ if( pMeth )
++ {
++ SbxValues aVals;
++ pMeth->Get( aVals );
++ }
++}
++
++void SbUserFormModule::Unload()
++{
++ if ( m_xDialog.is() )
++ m_xDialog->endExecute();
++}
++
++// it makes sense to support Hide here rather than at the api
++// object only because we do an awful simulation of Hide for the Userform.
++// In MSO Hide doesn't dispose the userform, it merely makes it inactive
++// and no longer displayes it. But openoffice doesn't (yet) support hide
++// so we simulate it by terminating the dialog ( via endExecute ) but..
++// we don't want to call the terminate handler, hence the hackfest below
++void SbUserFormModule::Hide()
++{
++ GetObject(); // if the object is unloaded, then we need to load
++ FormObjEventListenerImpl* pFormListener = dynamic_cast< FormObjEventListenerImpl* >( m_DialogListener.get() );
++ if ( pFormListener )
++ pFormListener->removeListener();
++ // need to take a local reference because we will reset it in ResetApiObj
++ uno::Reference< awt::XDialog > xDialog = m_xDialog;
++ if ( xDialog.is() )
++ {
++ ResetApiObj( false );
++ xDialog->endExecute();
++ }
++}
++
++void SbUserFormModule::InitObject()
++{
++ try
++ {
++
++ uno::Reference< frame::XModel > xModel( m_mInfo.ModuleObjectProvider, uno::UNO_QUERY_THROW );
++ if ( xModel.is() )
++ {
++ uno::Reference< lang::XMultiServiceFactory > xFactory = comphelper::getProcessServiceFactory();
++ uno::Sequence< uno::Any > aArgs(1);
++ aArgs[ 0 ] <<= xModel;
++ rtl::OUString sDialogUrl( RTL_CONSTASCII_USTRINGPARAM("vnd.sun.star.script:" ) );
++ sDialogUrl = sDialogUrl.concat( sStandard ).concat( rtl::OUString( '.') ).concat( m_mInfo.ModuleName ).concat( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("?location=document") ) );
++
++ uno::Reference< awt::XDialogProvider > xProvider( xFactory->createInstanceWithArguments( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.awt.DialogProvider")), aArgs ), uno::UNO_QUERY_THROW );
++ m_xDialog = xProvider->createDialog( sDialogUrl );
++
++ // create vba api object
++ aArgs.realloc( 3 );
++ aArgs[ 0 ] = uno::Any();
++ aArgs[ 1 ] <<= m_xDialog;
++ aArgs[ 2 ] <<= xModel;
++ pDocObject = new SbUnoObject( GetName(), uno::makeAny( xFactory->createInstanceWithArguments( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("org.openoffice.excel.UserForm")), aArgs ) ) );
++ uno::Reference< lang::XComponent > xComponent( aArgs[ 1 ], uno::UNO_QUERY_THROW );
++ // remove old listener if it exists
++ FormObjEventListenerImpl* pFormListener = dynamic_cast< FormObjEventListenerImpl* >( m_DialogListener.get() );
++ if ( pFormListener )
++ pFormListener->removeListener();
++ m_DialogListener = new FormObjEventListenerImpl( this, xComponent );
++
++ // trigger initialise event
++ if ( m_bUnloaded )
++ triggerInitializeEvent();
++
++ m_bUnloaded = false;
++ }
++ }
++ catch( uno::Exception& e )
++ {
++ }
++
++}
++
++SbxVariable*
++SbUserFormModule::Find( const XubString& rName, SbxClassType t )
++{
++ return SbObjModule::Find( rName, t );
++}
+
+ /////////////////////////////////////////////////////////////////////////
+ // Implementation SbJScriptModule (Basic-Modul fuer JavaScript-Sourcen)
+diff -rup /esata1/BUILD-related/HEAD/ooo-build/build/ooh680-m12/basic/source/runtime/methods1.cxx basic/source/runtime/methods1.cxx
+--- /esata1/BUILD-related/HEAD/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-25 23:39:30.000000000 +0000
+@@ -60,6 +60,9 @@
+ #ifndef _SBX_HXX
+ #include <basic/sbx.hxx>
+ #endif
++#ifndef _SBSTAR_HXX
++#include <basic/sbstar.hxx>
++#endif
+ #ifndef _ZFORLIST_HXX //autogen
+ #include <svtools/zforlist.hxx>
+ #endif
+@@ -86,6 +89,7 @@
+ #endif
+
+ #include <vcl/jobset.hxx>
++#include <basic/sbobjmod.hxx>
+
+ #include "sbintern.hxx"
+ #include "runtime.hxx"
+@@ -2611,13 +2615,22 @@ RTLFUNC(Me)
+
+ SbModule* pActiveModule = pINST->GetActiveModule();
+ SbClassModuleObject* pClassModuleObject = PTR_CAST(SbClassModuleObject,pActiveModule);
++ SbxVariableRef refVar = rPar.Get(0);
+ if( pClassModuleObject == NULL )
+ {
+- StarBASIC::Error( SbERR_INVALID_USAGE_OBJECT );
++ SbObjModule* pMod = PTR_CAST(SbObjModule,pActiveModule);
++ if ( pMod == NULL )
++ {
++ SbUserFormModule* pFormMod = PTR_CAST(SbUserFormModule,pActiveModule);
++ if ( !pFormMod )
++ StarBASIC::Error( SbERR_INVALID_USAGE_OBJECT );
++ else
++ refVar->PutObject( pFormMod );
++
++ }
++ else
++ refVar->PutObject( pMod );
+ }
+ else
+- {
+- SbxVariableRef refVar = rPar.Get(0);
+ refVar->PutObject( pClassModuleObject );
+- }
+ }
+diff -rup /esata1/BUILD-related/HEAD/ooo-build/build/ooh680-m12/basic/source/runtime/methods.cxx basic/source/runtime/methods.cxx
+--- /esata1/BUILD-related/HEAD/ooo-build/build/ooh680-m12/basic/source/runtime/methods.cxx 2008-03-19 10:56:58.000000000 +0000
++++ basic/source/runtime/methods.cxx 2008-03-26 16:11:22.000000000 +0000
+@@ -152,6 +152,8 @@ using namespace com::sun::star::io;
+ #include <io.h>
+ #endif
+
++#include <basic/sbobjmod.hxx>
++
+ static void FilterWhiteSpace( String& rStr )
+ {
+ rStr.EraseAllChars( ' ' );
+@@ -4407,7 +4409,12 @@ RTLFUNC(Unload)
+
+ // Diesen Call einfach an das Object weitereichen
+ SbxBase* pObj = (SbxObject*)rPar.Get(1)->GetObject();
+- if( pObj && pObj->IsA( TYPE( SbxObject ) ) )
++ if( pObj && pObj->IsA( TYPE( SbUserFormModule ) ) )
++ {
++ SbUserFormModule* pFormModule = ( SbUserFormModule* )pObj;
++ pFormModule->Unload();
++ }
++ else if( pObj && pObj->IsA( TYPE( SbxObject ) ) )
+ {
+ SbxVariable* pVar = ((SbxObject*)pObj)->
+ Find( String( RTL_CONSTASCII_USTRINGPARAM("Unload") ), SbxCLASS_METHOD );
+diff -rup /esata1/BUILD-related/HEAD/ooo-build/build/ooh680-m12/basic/source/runtime/runtime.cxx basic/source/runtime/runtime.cxx
+--- /esata1/BUILD-related/HEAD/ooo-build/build/ooh680-m12/basic/source/runtime/runtime.cxx 2008-03-19 10:56:58.000000000 +0000
++++ basic/source/runtime/runtime.cxx 2008-03-26 15:54:36.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 /esata1/BUILD-related/HEAD/ooo-build/build/ooh680-m12/basic/source/sbx/sbxobj.cxx basic/source/sbx/sbxobj.cxx
+--- /esata1/BUILD-related/HEAD/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-20 10:25:13.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 /esata1/BUILD-related/HEAD/ooo-build/build/ooh680-m12/basic/source/uno/namecont.cxx basic/source/uno/namecont.cxx
+--- /esata1/BUILD-related/HEAD/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-20 15:18:11.000000000 +0000
+@@ -139,6 +139,9 @@
+ #endif
+ #include <basic/sbmod.hxx>
+
++#ifndef _COM_SUN_STAR_SCRIPT_MODULEINFO_HPP_
++#include <com/sun/star/script/ModuleInfo.hpp>
++#endif
+
+ namespace basic
+ {
+@@ -217,7 +220,7 @@ void NameContainer::replaceByName( const
+ throw(IllegalArgumentException, NoSuchElementException, WrappedTargetException, RuntimeException)
+ {
+ Type aAnyType = aElement.getValueType();
+- if( mType != aAnyType )
++ if( mType != aAnyType && aAnyType != getCppuType( static_cast< ModuleInfo* >( NULL ) ) )
+ throw IllegalArgumentException();
+
+ NameContainerNameMap::iterator aIt = mHashMap.find( aName );
+@@ -259,7 +262,7 @@ void NameContainer::insertByName( const
+ throw(IllegalArgumentException, ElementExistException, WrappedTargetException, RuntimeException)
+ {
+ Type aAnyType = aElement.getValueType();
+- if( mType != aAnyType )
++ if( mType != aAnyType && aAnyType != getCppuType( static_cast< ModuleInfo* >( NULL ) ) )
+ throw IllegalArgumentException();
+
+ NameContainerNameMap::iterator aIt = mHashMap.find( aName );
+diff -rup /esata1/BUILD-related/HEAD/ooo-build/build/ooh680-m12/sfx2/source/doc/docmacromode.cxx sfx2/source/doc/docmacromode.cxx
+--- /esata1/BUILD-related/HEAD/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-25 12:38:22.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;
++ }
++ }
+ }
+ }
+ }
+diff -rup /esata1/BUILD-related/HEAD/ooo-build/build/ooh680-m12/oovbaapi/org/openoffice/msforms/makefile.mk oovbaapi/org/openoffice/msforms/makefile.mk
+--- /esata1/BUILD-related/HEAD/ooo-build/build/ooh680-m12/oovbaapi/org/openoffice/msforms/makefile.mk 2008-03-19 10:56:58.000000000 +0000
++++ oovbaapi/org/openoffice/msforms/makefile.mk 2008-03-20 13:59:37.000000000 +0000
+@@ -60,6 +60,7 @@ IDLFILES=\
+ XPictureFormat.idl \
+ XShapeRange.idl \
+ XTextBoxShape.idl \
++ XUserForm.idl \
+ XListBox.idl
+
+ # ------------------------------------------------------------------
+--- /dev/null 2007-05-04 11:54:36.000000000 +0100
++++ oovbaapi/org/openoffice/msforms/XUserForm.idl 2008-03-27 22:43:22.000000000 +0000
+@@ -0,0 +1,54 @@
++/*************************************************************************
++ *
++ * OpenOffice.org - a multi-platform office productivity suite
++ *
++ * $RCSfile: XShape.idl,v $
++ *
++ * $Revision: 1.2 $
++ *
++ * last change: $Author: vg $ $Date: 2007/12/07 12:15:54 $
++ *
++ * 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 __org_openoffice_msforms_XUserForm_idl__
++#define __org_openoffice_msforms_XUserForm_idl__
++
++#ifndef __org_openoffice_vba_XHelperInterface_idl__
++#include <org/openoffice/vba/XHelperInterface.idl>
++#endif
++#ifndef __com_sun_star_script_XInvocation_idl__
++#include <com/sun/star/script/XInvocation.idl>
++#endif
++module org { module openoffice { module msforms {
++interface XUserForm
++{
++ //interface ::org::openoffice::vba::XHelperInterface;
++ interface ::com::sun::star::script::XInvocation;
++ [attribute] string Caption;
++ void Show();
++};
++}; }; };
++
++#endif
+--- /esata1/BUILD-related/HEAD/ooo-build/build/ooh680-m12/oovbaapi/org/openoffice/msforms/XControl.idl 2007-12-07 12:14:42.000000000 +0000
++++ oovbaapi/org/openoffice/msforms/XControl.idl 2008-03-28 10:24:19.000000000 +0000
+@@ -42,12 +42,16 @@
+
+ //=============================================================================
+
+-module org { module openoffice { module msforms {
++#ifndef __org_openoffice_vba_XHelperInterface_idl__
++#include <org/openoffice/vba/XHelperInterface.idl>
++#endif
+
++module org { module openoffice { module msforms {
+
+ //=============================================================================
+-interface XControl: com::sun::star::uno::XInterface
++interface XControl
+ {
++ interface ::org::openoffice::vba::XHelperInterface;
+ [attribute] boolean Enabled;
+ [attribute] boolean Visible;
+ //Size. there are some defferent between Mso and OOo.
+diff -rup /esata1/BUILD-related/HEAD/ooo-build/build/ooh680-m12/forms/source/inc/InterfaceContainer.hxx forms/source/inc/InterfaceContainer.hxx
+--- /esata1/BUILD-related/HEAD/ooo-build/build/ooh680-m12/forms/source/inc/InterfaceContainer.hxx 2007-01-29 15:46:36.000000000 +0000
++++ forms/source/inc/InterfaceContainer.hxx 2008-03-25 12:59:07.000000000 +0000
+@@ -319,6 +319,9 @@ protected:
+ void implCheckIndex( const sal_Int32 _nIndex ) SAL_THROW( ( ::com::sun::star::lang::IndexOutOfBoundsException ) );
+
+ private:
++ // hack for Vba Events
++ void fakeVbaEventsHack( sal_Int32 _nIndex );
++
+ // the runtime event format has changed from version SO5.2 to OOo
+ enum EventFormat
+ {
+diff -rup /esata1/BUILD-related/HEAD/ooo-build/build/ooh680-m12/forms/source/misc/InterfaceContainer.cxx forms/source/misc/InterfaceContainer.cxx
+--- /esata1/BUILD-related/HEAD/ooo-build/build/ooh680-m12/forms/source/misc/InterfaceContainer.cxx 2006-12-01 16:55:25.000000000 +0000
++++ forms/source/misc/InterfaceContainer.cxx 2008-03-25 12:59:07.000000000 +0000
+@@ -105,11 +105,14 @@
+ #include <rtl/logfile.hxx>
+ #endif
+
++#include <com/sun/star/frame/XModel.hpp>
++#include <org/openoffice/vba/XFakeVBAEventDescriptorSupplier.hpp>
+ //.........................................................................
+ namespace frm
+ {
+ //.........................................................................
+
++using namespace ::com::sun::star::frame;
+ using namespace ::com::sun::star::lang;
+ using namespace ::com::sun::star::uno;
+ using namespace ::com::sun::star::beans;
+@@ -127,6 +130,83 @@ namespace
+ }
+ }
+
++bool
++lcl_hasVbaEvents( const Sequence< ScriptEventDescriptor >& sEvents )
++{
++ const ScriptEventDescriptor* pDesc = sEvents.getConstArray();
++ const ScriptEventDescriptor* pEnd = ( pDesc + sEvents.getLength() );
++ for ( ; pDesc != pEnd; ++pDesc )
++ {
++ if ( pDesc->ScriptType.equals( rtl::OUString::createFromAscii( "VBAInterop" ) ) )
++ return true;
++ }
++ return false;
++}
++
++Sequence< ScriptEventDescriptor >
++lcl_stripVbaEvents( const Sequence< ScriptEventDescriptor >& sEvents )
++{
++ Sequence< ScriptEventDescriptor > sStripped( sEvents.getLength() );
++
++ const ScriptEventDescriptor* pDesc = sEvents.getConstArray();
++ const ScriptEventDescriptor* pEnd = ( pDesc + sEvents.getLength() );
++ sal_Int32 nCopied = 0;
++ for ( ; pDesc != pEnd; ++pDesc )
++ {
++ if ( !pDesc->ScriptType.equals( rtl::OUString::createFromAscii( "VBAInterop" ) ) )
++ {
++ sStripped[ nCopied++ ] = *pDesc;
++ }
++ }
++ if ( nCopied )
++ sStripped.realloc( nCopied );
++ return sStripped;
++}
++
++void
++OInterfaceContainer::fakeVbaEventsHack( sal_Int32 _nIndex )
++{
++ // we are dealing with form controls
++ try
++ {
++ Reference< XFormComponent > xForm( static_cast< XContainer* >(this), UNO_QUERY_THROW );
++ // grand-parent should be the model, no parent ? if not
++ // we'll ignore, we'll get called back here anyway )
++ Reference< XChild > xChild( xForm->getParent(), UNO_QUERY_THROW );
++ Reference< XModel > xDocOwner( xChild->getParent(), UNO_QUERY );
++ OSL_TRACE(" Is DOC ????? %s", xDocOwner.is() ? "true" : "false" );
++ if ( xDocOwner.is() )
++ {
++ bool hasVBABindings = lcl_hasVbaEvents( m_xEventAttacher->getScriptEvents( _nIndex ) );
++ if ( hasVBABindings )
++ {
++ OSL_TRACE("Has VBA bindings already, returning ");
++ return;
++ }
++ Reference< XMultiServiceFactory > xFac( xDocOwner, UNO_QUERY );
++ if ( xFac.is() )
++ {
++ try
++ {
++ Reference< org::openoffice::vba::XFakeVBAEventDescriptorSupplier > xDescSupplier( xFac->createInstance( rtl::OUString::createFromAscii( "org.openoffice.vba.controlevents" ) ), UNO_QUERY_THROW );
++ Reference< XInterface > xIf( getByIndex( _nIndex ) , UNO_QUERY_THROW );
++ Sequence< ScriptEventDescriptor > vbaEvents = xDescSupplier->getEventDescriptions( xIf );
++ // register the vba script events
++ if ( m_xEventAttacher.is() )
++ {
++ m_xEventAttacher->registerScriptEvents( _nIndex, vbaEvents );
++ }
++ }
++ catch( Exception& e ){ OSL_TRACE("lcl_fakevbaevents - Caught Exception trying to create control eventstuff "); }
++ }
++
++ }
++ }
++ catch( Exception& e )
++ {
++ }
++
++}
+ //==================================================================
+ //= ElementDescription
+ //==================================================================
+@@ -726,6 +806,7 @@ void OInterfaceContainer::approveNewElem
+ void OInterfaceContainer::implInsert(sal_Int32 _nIndex, const Reference< XPropertySet >& _rxElement,
+ sal_Bool _bEvents, ElementDescription* _pApprovalResult, sal_Bool _bFire ) throw( IllegalArgumentException )
+ {
++ OSL_TRACE("OInterfaceContainer::implInsert( %d)", _nIndex );
+ RTL_LOGFILE_CONTEXT( aLogger, "forms::OInterfaceContainer::implInsert" );
+
+ ::osl::ClearableMutexGuard aGuard( m_rMutex );
+@@ -775,6 +856,23 @@ void OInterfaceContainer::implInsert(sal
+ {
+ m_xEventAttacher->insertEntry(_nIndex);
+ m_xEventAttacher->attach( _nIndex, pElementMetaData->xInterface, makeAny( _rxElement ) );
++ // insert fake events?
++ Reference< XEventAttacherManager > xMgr ( pElementMetaData->xInterface, UNO_QUERY );
++ if ( xMgr.is() )
++ {
++ OInterfaceContainer* pIfcMgr = dynamic_cast< OInterfaceContainer* >( xMgr.get() );
++ sal_Int32 nLen = getCount();
++ for ( sal_Int32 i = 0; (i < nLen) && pIfcMgr ; ++i )
++ {
++ // add fake events to the control at index i
++ pIfcMgr->fakeVbaEventsHack( i );
++ }
++ }
++ else
++ {
++ // add fake events to the control at index i
++ fakeVbaEventsHack( _nIndex );
++ }
+ }
+
+ // notify derived classes
+@@ -1054,20 +1152,29 @@ void SAL_CALL OInterfaceContainer::remov
+ //------------------------------------------------------------------------
+ void SAL_CALL OInterfaceContainer::registerScriptEvent( sal_Int32 nIndex, const ScriptEventDescriptor& aScriptEvent ) throw(IllegalArgumentException, RuntimeException)
+ {
++ OSL_TRACE("*** registerScriptEvent %d", nIndex);
+ if ( m_xEventAttacher.is() )
++ {
+ m_xEventAttacher->registerScriptEvent( nIndex, aScriptEvent );
++ fakeVbaEventsHack( nIndex ); // add fake vba events
++ }
+ }
+
+ //------------------------------------------------------------------------
+ void SAL_CALL OInterfaceContainer::registerScriptEvents( sal_Int32 nIndex, const Sequence< ScriptEventDescriptor >& aScriptEvents ) throw(IllegalArgumentException, RuntimeException)
+ {
++ OSL_TRACE("*** registerScriptEvent(s) %d", nIndex);
+ if ( m_xEventAttacher.is() )
++ {
+ m_xEventAttacher->registerScriptEvents( nIndex, aScriptEvents );
++ fakeVbaEventsHack( nIndex ); // add fake vba events
++ }
+ }
+
+ //------------------------------------------------------------------------
+ void SAL_CALL OInterfaceContainer::revokeScriptEvent( sal_Int32 nIndex, const ::rtl::OUString& aListenerType, const ::rtl::OUString& aEventMethod, const ::rtl::OUString& aRemoveListenerParam ) throw(IllegalArgumentException, RuntimeException)
+ {
++ OSL_TRACE("*** revokeScriptEvent %d listenertype %s, eventMethod %s", nIndex, rtl::OUStringToOString( aListenerType, RTL_TEXTENCODING_UTF8 ).getStr(), rtl::OUStringToOString( aEventMethod, RTL_TEXTENCODING_UTF8 ).getStr());
+ if ( m_xEventAttacher.is() )
+ m_xEventAttacher->revokeScriptEvent( nIndex, aListenerType, aEventMethod, aRemoveListenerParam );
+ }
+@@ -1096,9 +1203,16 @@ void SAL_CALL OInterfaceContainer::remov
+ //------------------------------------------------------------------------
+ Sequence< ScriptEventDescriptor > SAL_CALL OInterfaceContainer::getScriptEvents( sal_Int32 nIndex ) throw(IllegalArgumentException, RuntimeException)
+ {
++ OSL_TRACE("getScriptEvents");
+ Sequence< ScriptEventDescriptor > aReturn;
+ if ( m_xEventAttacher.is() )
++ {
+ aReturn = m_xEventAttacher->getScriptEvents( nIndex );
++ if ( lcl_hasVbaEvents( aReturn ) )
++ {
++ aReturn = lcl_stripVbaEvents( aReturn );
++ }
++ }
+ return aReturn;
+ }
+
+diff -rup /esata1/BUILD-related/HEAD/ooo-build/build/ooh680-m12/forms/source/misc/makefile.mk forms/source/misc/makefile.mk
+--- /esata1/BUILD-related/HEAD/ooo-build/build/ooh680-m12/forms/source/misc/makefile.mk 2005-09-09 00:01:56.000000000 +0100
++++ forms/source/misc/makefile.mk 2008-03-25 12:59:07.000000000 +0000
+@@ -48,6 +48,7 @@ ENABLE_EXCEPTIONS=TRUE
+ # --- Types -------------------------------------
+
+ INCPRE+=$(SOLARINCDIR)$/offuh
++INCPRE*=$(INCCOM)$/$(TARGET)
+
+ # --- Files -------------------------------------
+
+@@ -65,3 +66,12 @@ SLOFILES= $(SLO)$/limitedformats.obj \
+
+ .INCLUDE : target.mk
+
++ALLTAR : \
++ $(MISC)$/$(TARGET).don \
++
++$(SLOFILES) : $(MISC)$/$(TARGET).don
++
++$(MISC)$/$(TARGET).don : $(SOLARBINDIR)$/oovbaapi.rdb
++ +$(CPPUMAKER) -O$(INCCOM)$/$(TARGET) -BUCR $(SOLARBINDIR)$/oovbaapi.rdb -X$(SOLARBINDIR)$/types.rdb && echo > $@
++ echo $@
++
+diff -rup /esata1/BUILD-related/HEAD/ooo-build/build/ooh680-m12/scripting/source/vbaevents/eventhelper.cxx scripting/source/vbaevents/eventhelper.cxx
+--- /esata1/BUILD-related/HEAD/ooo-build/build/ooh680-m12/scripting/source/vbaevents/eventhelper.cxx 2008-03-19 10:56:58.000000000 +0000
++++ scripting/source/vbaevents/eventhelper.cxx 2008-03-26 09:32:15.000000000 +0000
+@@ -94,7 +94,7 @@ Sequence< ::rtl::OUString> getEventMetho
+ return aNames;
+ }
+
+-// for debug only ( conditionalize out? )
++#if 0
+ void dumpListeners( const Reference< beans::XIntrospection >& xIntrospection, const Reference<XInterface>& xIfc)
+ {
+ Reference< beans::XIntrospectionAccess > xIntrospectionAccess;
+@@ -164,6 +164,7 @@ void dumpEvent( const ScriptEvent& evt )
+ }
+ }
+
++#endif
+
+ bool isKeyEventOk( awt::KeyEvent& evt, const Sequence< Any >& params )
+ {
+@@ -393,41 +394,17 @@ eventMethodToDescriptors( const ::rtl::O
+ EventInfoHash::const_iterator eventInfo_it = infos.find( sMethodName );
+ EventInfoHash::const_iterator it_end = infos.end();
+
+- // sLibModName ( could ) include the uri bits :-) from calc
+- rtl::OUString sPartialMacroName = sLibModName + rtl::OUString( RTL_CONSTASCII_USTRINGPARAM(".") ) + rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("$macro"));
+-
+- if ( sMethodName.getLength()
+- && sTypeName.getLength()
+- && ( infos.find( sMethodName ) != infos.end() ) )
++ if ( infos.find( sMethodName ) != infos.end() )
+ {
+- std::list< TranslateInfo >::const_iterator txInfo =
+- eventInfo_it->second.begin();
+- std::list< TranslateInfo >::const_iterator txInfo_end =
+- eventInfo_it->second.end();
+- for ( ; txInfo != txInfo_end; ++txInfo )
+- {
+- // Check if extension is support for this method, if
+- // so create an eventdescription for that
+- const rtl::OUString* pExt = sHandlerExts.getConstArray();
+- sal_Int32 nCount = sHandlerExts.getLength();
+- for ( sal_Int32 counter=0; counter<nCount; ++counter, ++pExt )
+- {
+- if ( (*txInfo).sVBAName.equals( *pExt ) ) // handler for event
+- {
+- sal_Int32 nIndex = evtDescs.getLength();
+- evtDescs.realloc( evtDescs.getLength() + 1 );
+- evtDescs[ nIndex ].ScriptCode = sPartialMacroName + *pExt;
+- evtDescs[ nIndex ].ListenerType = sTypeName;
+- evtDescs[ nIndex ].EventMethod = sMethodName;
+-
+- // set this it VBAInterop, ensures that it doesn't
+- // get persisted or shown in property editors
+- evtDescs[ nIndex ].ScriptType = rtl::OUString::createFromAscii( "VBAInterop" );
+- }
+- }
+- }
++ sal_Int32 nIndex = evtDescs.getLength();
++ evtDescs.realloc( evtDescs.getLength() + 1 );
++ evtDescs[ nIndex ].ScriptType = rtl::OUString::createFromAscii( "VBAInterop" );
++ evtDescs[ nIndex ].ScriptCode = sLibModName; // codeName
++ evtDescs[ nIndex ].ListenerType = sTypeName;
++ evtDescs[ nIndex ].EventMethod = sMethodName;
+ return true;
+ }
++
+ return false;
+
+ }
+@@ -522,8 +499,10 @@ ScriptEventFactory::getEventListeners( c
+ Reference< beans::XIntrospection > xIntrospection(
+ xMFac->createInstanceWithContext( rtl::OUString(
+ RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.beans.Introspection" ) ), instance().m_xCtx ), UNO_QUERY );
+- //dumpListeners( xIntrospection, xControl );
+- //dumpListeners( xIntrospection, xControl->getModel() );
++#if 0
++ dumpListeners( xIntrospection, xControl );
++ dumpListeners( xIntrospection, xControl->getModel() );
++#endif
+ Reference< beans::XIntrospectionAccess > xIntrospectionAccess;
+ if ( xIntrospection.is() )
+ {
+@@ -583,7 +562,8 @@ ScriptEventFactory::createEvents( const
+ ::rtl::OUString sNoNameSpaceMethod = *pSrc;
+ if ( ( lastDotIndex = pSrc->lastIndexOf( '.' ) ) > -1 )
+ sNoNameSpaceMethod = sNoNameSpaceMethod.copy( lastDotIndex + 1 );
+- Sequence< ScriptEventDescriptor> evtDescs;
++
++ Sequence< ScriptEventDescriptor > evtDescs;
+ if ( eventMethodToDescriptors( sNoNameSpaceMethod, xControl, sLibModName, sHandlerExts, evtDescs ) )
+ {
+ sal_Int32 dIndex = nEvts;
+@@ -826,13 +806,23 @@ EventListener::getPropertySetInfo( ) th
+ void
+ EventListener::firing_Impl(const ScriptEvent& evt, Any* pRet ) throw(RuntimeException)
+ {
+- OSL_TRACE("EventListener::firing_Impl !!!");
++ OSL_TRACE("EventListener::firing_Impl( FAKE VBA_EVENTS )");
+ static const ::rtl::OUString vbaInterOp =
+ ::rtl::OUString::createFromAscii("VBAInterop");
+
+ // let default handlers deal with non vba stuff
+ if ( !evt.ScriptType.equals( vbaInterOp ) )
+ return;
++ lang::EventObject aEvent;
++ evt.Arguments[ 0 ] >>= aEvent;
++ OSL_TRACE("Argument[0] is %s", rtl::OUStringToOString( comphelper::anyToString( evt.Arguments[0] ), RTL_TEXTENCODING_UTF8 ).getStr() );
++ OSL_TRACE("Getting Control");
++ uno::Reference< awt::XControl > xControl( aEvent.Source, uno::UNO_QUERY_THROW );
++ OSL_TRACE("Getting properties");
++ uno::Reference< beans::XPropertySet > xProps( xControl->getModel(), uno::UNO_QUERY_THROW );
++ rtl::OUString sName;
++ OSL_TRACE("Getting Name");
++ xProps->getPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("Name") ) ) >>= sName;
+ //dumpEvent( evt );
+ EventInfoHash& infos = getEventTransInfo();
+ EventInfoHash::const_iterator eventInfo_it = infos.find( evt.MethodName );
+@@ -858,14 +848,11 @@ EventListener::firing_Impl(const ScriptE
+ {
+ // see if we have a match for the handlerextension
+ // where ScriptCode is methodname_handlerextension
+- rtl::OUString sTemp = evt.ScriptCode;
+- sal_Int32 lastIndexOf_ = sTemp.lastIndexOf( '_' );
+- if ( lastIndexOf_ != -1 )
+- sTemp = sTemp.copy( lastIndexOf_ );
+- OSL_TRACE("*** trying to match %s with %s",
+- rtl::OUStringToOString( sTemp, RTL_TEXTENCODING_UTF8 ).getStr(),
+- rtl::OUStringToOString( (*txInfo).sVBAName, RTL_TEXTENCODING_UTF8 ).getStr() );
+- if ( sTemp.equals( (*txInfo).sVBAName ) )
++ rtl::OUString sTemp = rtl::OUString::createFromAscii("Standard.").concat( evt.ScriptCode ).concat( rtl::OUString::createFromAscii(".") ).concat( sName ).concat( (*txInfo).sVBAName );
++
++ OSL_TRACE("*** trying to invoke %s ",
++ rtl::OUStringToOString( sTemp, RTL_TEXTENCODING_UTF8 ).getStr() );
++ //if ( sTemp.equals( (*txInfo).sVBAName ) )
+ {
+ // !! translate arguments & emulate events where necessary
+ Sequence< Any > aArguments;
+@@ -881,7 +868,7 @@ EventListener::firing_Impl(const ScriptE
+ static rtl::OUString part2 = rtl::OUString::createFromAscii("?language=Basic&location=document");
+
+ // create script url
+- rtl::OUString url = part1 + evt.ScriptCode + part2;
++ rtl::OUString url = part1 + sTemp + part2;
+
+ OSL_TRACE("script url = %s",
+ rtl::OUStringToOString( url,
+@@ -893,16 +880,7 @@ EventListener::firing_Impl(const ScriptE
+ {
+ uno::Reference< script::provider::XScript > xScript = xScriptProvider->getScript( url );
+ if ( xScript.is() )
+- {
+- uno::Reference< beans::XPropertySet > xProps( xScript, uno::UNO_QUERY );
+- if ( xProps.is() )
+- {
+- Sequence< Any > aCallerHack(1);
+- aCallerHack[ 0 ] = uno::makeAny( rtl::OUString::createFromAscii("Error") );
+- xProps->setPropertyValue( rtl::OUString::createFromAscii( "Caller" ), uno::makeAny( aCallerHack ) );
+- }
+- xScript->invoke( aArguments, aOutArgsIndex, aOutArgs );
+- }
++ xScript->invoke( aArguments, aOutArgsIndex, aOutArgs );
+ }
+ catch ( uno::Exception& e )
+ {
+--- /dev/null 2007-05-04 11:54:36.000000000 +0100
++++ basic/inc/basic/sbobjmod.hxx 2008-03-26 16:06:26.000000000 +0000
+@@ -0,0 +1,95 @@
++/*************************************************************************
++ *
++ * OpenOffice.org - a multi-platform office productivity suite
++ *
++ * $RCSfile: sbobjmod.hxx,v $
++ *
++ * $Revision: 1.4 $
++ *
++ * last change: $Author: $ $Date: 2007/08/27 16:31:39 $
++ *
++ * The Contents of this file are made available subject to
++ * the terms of GNU Lesser General Public License Version 2.1.
++ *
++ *
++ * GNU Lesser General Public License Version 2.1
++ * =============================================
++ * Copyright 2005 by Sun Microsystems, Inc.
++ * 901 San Antonio Road, Palo Alto, CA 94303, USA
++ *
++ * This library is free software; you can redistribute it and/or
++ * modify it under the terms of the GNU Lesser General Public
++ * License version 2.1, as published by the Free Software Foundation.
++ *
++ * This library is distributed in the hope that it will be useful,
++ * but WITHOUT ANY WARRANTY; without even the implied warranty of
++ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
++ * Lesser General Public License for more details.
++ *
++ * You should have received a copy of the GNU Lesser General Public
++ * License along with this library; if not, write to the Free Software
++ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
++ * MA 02111-1307 USA
++ *
++ ************************************************************************/
++
++#ifndef _SB_OBJMOD_HXX
++#define _SB_OBJMOD_HXX
++
++#include <basic/sbmod.hxx>
++#include <basic/sbstar.hxx>
++#include <com/sun/star/script/ModuleInfo.hpp>
++#include <com/sun/star/lang/XEventListener.hpp>
++#include <com/sun/star/awt/XDialog.hpp>
++
++namespace css = ::com::sun::star;
++
++// Basic-Module for excel object.
++
++class SbObjModule : public SbModule
++{
++protected:
++ com::sun::star::script::ModuleInfo m_mInfo;
++ SbxObjectRef pDocObject; // a vba api object.
++ virtual void InitObject();
++public:
++ TYPEINFO();
++ SBX_DECL_PERSIST_NODATA(SBXCR_SBX,SBXID_DOCUMENTMOD,2);
++ SbObjModule( const rtl::OUString& rName, const com::sun::star::script::ModuleInfo& mInfo );
++ virtual SbxVariable* Find( const XubString& rName, SbxClassType t );
++ SbxVariable* GetObject();
++ virtual BOOL IsClass( const String& );
++};
++
++class SbUserFormModule : public SbObjModule
++{
++ css::uno::Reference<css::lang::XEventListener> m_DialogListener;
++ css::uno::Reference<css::awt::XDialog> m_xDialog;
++ String sFormName;
++
++ bool m_bUnloaded;
++ static USHORT nHideHash;
++protected:
++ virtual void InitObject();
++public:
++ TYPEINFO();
++ SBX_DECL_PERSIST_NODATA(SBXCR_SBX,SBXID_USERFORMMOD,2);
++ SbUserFormModule( const rtl::OUString& rName, const com::sun::star::script::ModuleInfo& mInfo );
++ virtual SbxVariable* Find( const XubString& rName, SbxClassType t );
++ virtual void SFX_NOTIFY( SfxBroadcaster&, const TypeId&, const SfxHint& rHint, const TypeId& );
++ void ResetApiObj( bool bUnloaded = true );
++ void Hide();
++ void Unload();
++ void triggerInitializeEvent();
++ void triggerTerminateEvent();
++};
++
++SV_DECL_IMPL_REF(SbUserFormModule);
++#ifndef __SB_SBOBJMODULEREF_HXX
++#define __SB_SBOBJMODULEREF_HXX
++
++SV_DECL_IMPL_REF(SbObjModule);
++
++#endif
++#endif
++
+diff -rup /esata1/BUILD-related/HEAD/ooo-build/build/ooh680-m12/oovbaapi/org/openoffice/vba/XVBAToOOEventDescGen.idl oovbaapi/org/openoffice/vba/XVBAToOOEventDescGen.idl
+--- /esata1/BUILD-related/HEAD/ooo-build/build/ooh680-m12/oovbaapi/org/openoffice/vba/XVBAToOOEventDescGen.idl 2007-04-27 08:32:41.000000000 +0100
++++ oovbaapi/org/openoffice/vba/XVBAToOOEventDescGen.idl 2008-03-25 12:59:07.000000000 +0000
+@@ -50,5 +50,10 @@ interface XVBAToOOEventDescGen : com::su
+ com::sun::star::script::XScriptEventsSupplier getEventSupplier( [in] com::sun::star::uno::XInterface xControl );
+ };
+
++interface XFakeVBAEventDescriptorSupplier : com::sun::star::uno::XInterface
++{
++ sequence< com::sun::star::script::ScriptEventDescriptor > getEventDescriptions( [in] com::sun::star::uno::XInterface xControl );
++};
++
+ }; }; };
+ #endif
+--- /data4/OOOBuildM12/ooo-build/build/ooh680-m12/sc/source/ui/docshell/vbaevents.cxx 2008-03-27 09:30:52.000000000 +0000
++++ sc/source/ui/docshell/vbaevents.cxx 2008-03-26 23:09:37.000000000 +0000
+@@ -60,11 +60,7 @@ const static rtl::OUString sUrlPart2 = r
+ rtl::OUString sCodeName = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("ThisWorkbook") );
+ if ( pShell )
+ {
+- if ( ScExtDocOptions* pExtDocOpts = pShell->GetDocument()->GetExtDocOptions() )
+- {
+- if ( pExtDocOpts->GetDocSettings().maGlobCodeName.Len() > 0 )
+- sCodeName = pExtDocOpts->GetDocSettings().maGlobCodeName;
+- }
++ pShell->GetDocument()->GetCodeName();
+ }
+ return sCodeName;
+ }
+@@ -316,12 +312,8 @@ uno::Any createRange( const uno::Any& aR
+
+ String getSheetModuleName( ScDocShell* pShell, SCTAB nTab )
+ {
+- ScExtDocOptions* pExtOptions = pShell->GetDocument()->GetExtDocOptions();
+ String aCodeName;
+- pShell->GetDocument()->GetName( nTab, aCodeName);
+- // Use code name if that exists
+- if ( pExtOptions )
+- aCodeName = pExtOptions->GetCodeName( nTab );
++ pShell->GetDocument()->GetCodeName( nTab, aCodeName);
+ return aCodeName;
+ }
+
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]