[ooo-build-commit] .: patches/dev300 patches/vba

Noel Power noelp at kemper.freedesktop.org
Tue Apr 6 06:57:01 PDT 2010


 patches/dev300/apply                      |    3 
 patches/vba/cws-vbasupportdev300-m13.diff |48656 ++++++++++++++++++++++++++++++
 patches/vba/cws-vbasupportdev300.diff     |12955 ++++---
 3 files changed, 55659 insertions(+), 5955 deletions(-)

New commits:
commit 513441333ea70563b99ef83a64aeb0dc9679a5e0
Author: Noel Power <noel.power at novell.com>
Date:   Tue Apr 6 14:55:33 2010 +0100

    update vbasupportdev300 for m14
    
    * patches/dev300/apply:
    * patches/vba/cws-vbasupportdev300-m13.diff:
    * patches/vba/cws-vbasupportdev300.diff:

diff --git a/patches/dev300/apply b/patches/dev300/apply
index a97ef58..f8299f1 100644
--- a/patches/dev300/apply
+++ b/patches/dev300/apply
@@ -1800,6 +1800,9 @@ cws-npower12.diff
 
 [ VBAObjects ]
 SectionOwner => noelpwer
+[ VBAObjects < ooo320-m14 ]
+cws-vbasupportdev300-m13.diff
+[ VBAObjects >= ooo320-m14 ]
 cws-vbasupportdev300.diff
 
 eventhelper-closecrash-fix.diff, n#438606, i#106270
diff --git a/patches/vba/cws-vbasupportdev300-m13.diff b/patches/vba/cws-vbasupportdev300-m13.diff
new file mode 100644
index 0000000..dfc18c5
--- /dev/null
+++ b/patches/vba/cws-vbasupportdev300-m13.diff
@@ -0,0 +1,48656 @@
+--- basctl/inc/basidesh.hrc.old	2009-10-08 16:18:20.000000000 +0200
++++ basctl/inc/basidesh.hrc	2010-03-03 16:59:34.000000000 +0100
+@@ -184,6 +184,10 @@
+ #define	RID_STR_DLGIMP_MISMATCH_OMIT	( RID_BASICIDE_START + 115 )
+ #define	RID_STR_DLGIMP_MISMATCH_TITLE	( RID_BASICIDE_START + 116 )
+ #define	RID_STR_DLGIMP_MISMATCH_TEXT	( RID_BASICIDE_START + 117 )
++#define RID_STR_DOCUMENT_OBJECTS        ( RID_BASICIDE_START + 118 )
++#define RID_STR_USERFORMS               ( RID_BASICIDE_START + 119 )
++#define RID_STR_NORMAL_MODULES          ( RID_BASICIDE_START + 120 )
++#define RID_STR_CLASS_MODULES           ( RID_BASICIDE_START + 121 )
+ 
+ #endif	// _SVX_NOIDERESIDS
+ 
+--- basctl/source/basicide/baside2.cxx.old	2009-10-08 16:18:20.000000000 +0200
++++ basctl/source/basicide/baside2.cxx	2010-03-03 16:59:34.000000000 +0100
+@@ -49,6 +49,7 @@
+ #include <com/sun/star/script/XLibraryContainer2.hpp>
+ #endif
+ #include <com/sun/star/document/MacroExecMode.hpp>
++#include <com/sun/star/script/ModuleType.hpp>
+ #include <toolkit/helper/vclunohelper.hxx>
+ #include <sfx2/docfile.hxx>
+ #include <basic/basrdll.hxx>
+@@ -110,6 +111,8 @@ DBG_NAME( ModulWindow )
+ 
+ TYPEINIT1( ModulWindow , IDEBaseWindow );
+ 
++void lcl_getObjectName( const uno::Reference< container::XNameContainer >& rLib, const String& rModName, String& rObjName );
++
+ void lcl_PrintHeader( Printer* pPrinter, USHORT nPages, USHORT nCurPage, const String& rTitle )
+ {
+     short nLeftMargin 	= LMARGPRN;
+@@ -331,6 +334,8 @@ BOOL ModulWindow::BasicExecute()
+             DBG_ASSERT( xModule.Is(), "Kein Modul!" );
+             AddStatus( BASWIN_RUNNINGBASIC );
+             USHORT nStart, nEnd, nCurMethodStart = 0;
++			TextSelection aSel = GetEditView()->GetSelection();
++			nCurMethodStart = ( aSel.GetStart().GetPara() + 1 );
+             SbMethod* pMethod = 0;
+             // erstes Macro, sonst blind "Main" (ExtSearch?)
+             for ( USHORT nMacro = 0; nMacro < xModule->GetMethods()->Count(); nMacro++ )
+@@ -338,16 +343,16 @@ BOOL ModulWindow::BasicExecute()
+                 SbMethod* pM = (SbMethod*)xModule->GetMethods()->Get( nMacro );
+                 DBG_ASSERT( pM, "Method?" );
+                 pM->GetLineRange( nStart, nEnd );
+-                if ( !pMethod || ( nStart < nCurMethodStart ) )
++				if (  nCurMethodStart >= nStart && nCurMethodStart <= nEnd ) 
+                 {
+                     pMethod = pM;
+-                    nCurMethodStart = nStart;
++					break;
+                 }
+             }
+             if ( !pMethod )
+-                pMethod = (SbMethod*)xModule->Find( String( RTL_CONSTASCII_USTRINGPARAM( "Main" ) ), SbxCLASS_METHOD );
++				return ( BasicIDE::ChooseMacro( uno::Reference< frame::XModel >(), FALSE, rtl::OUString() ).getLength() > 0 ) ? TRUE : FALSE;
+ 
+-            if ( pMethod )
++			else
+             {
+                 pMethod->SetDebugFlags( aStatus.nBasicFlags );
+                 BasicDLL::SetDebugMode( TRUE );
+@@ -1359,7 +1364,39 @@ BasicEntryDescriptor ModulWindow::Create
+     ScriptDocument aDocument( GetDocument() );
+     String aLibName( GetLibName() );
+     LibraryLocation eLocation = aDocument.getLibraryLocation( aLibName );
+-    return BasicEntryDescriptor( aDocument, eLocation, aLibName, GetName(), OBJ_TYPE_MODULE );
++    String aModName( GetName() );
++    String aLibSubName;
++    if( xBasic.Is() && xBasic->isVBAEnabled() && xModule.Is() )
++    {
++        switch( xModule->GetModuleType() )
++        {
++            case script::ModuleType::Document:
++            {
++                aLibSubName = String( IDEResId( RID_STR_DOCUMENT_OBJECTS ) );
++                uno::Reference< container::XNameContainer > xLib = aDocument.getOrCreateLibrary( E_SCRIPTS, aLibName );
++                if( xLib.is() )
++                {
++                    String sObjName;
++                    lcl_getObjectName( xLib, aModName, sObjName );
++                    if( sObjName.Len() )
++                    {
++                        aModName.AppendAscii(" (").Append(sObjName).AppendAscii(")");
++                    }
++                }
++                break;
++            }    
++            case script::ModuleType::Form:
++                aLibSubName = String( IDEResId( RID_STR_USERFORMS ) );
++                break;
++            case script::ModuleType::Normal:
++                aLibSubName = String( IDEResId( RID_STR_NORMAL_MODULES ) );
++                break;
++            case script::ModuleType::Class:
++                aLibSubName = String( IDEResId( RID_STR_CLASS_MODULES ) );
++                break;
++        }
++    }
++    return BasicEntryDescriptor( aDocument, eLocation, aLibName, aLibSubName, aModName, OBJ_TYPE_MODULE );
+ }
+ 
+ void ModulWindow::SetReadOnly( BOOL b )
+--- basctl/source/basicide/baside3.cxx.old	2009-10-08 16:18:20.000000000 +0200
++++ basctl/source/basicide/baside3.cxx	2010-03-03 16:59:34.000000000 +0100
+@@ -85,6 +85,7 @@
+ #include <com/sun/star/resource/XStringResourceResolver.hpp>
+ #include <com/sun/star/resource/StringResourceWithLocation.hpp>
+ #include <com/sun/star/task/XInteractionHandler.hpp>
++#include <com/sun/star/script/XVBACompat.hpp>
+ 
+ using namespace comphelper;
+ using namespace	::com::sun::star;
+@@ -115,8 +116,16 @@ DialogWindow::DialogWindow( Window* pPar
+ {
+     InitSettings( TRUE, TRUE, TRUE );
+ 
+-    pEditor = new DlgEditor();
++	pEditor = new DlgEditor( rDocument.getDocument() );
+     pEditor->SetWindow( this );
++	// set vba mode on DialogModel ( allows it to work in 100thmm instead of MAP_APPFONT )
++	if ( rDocument.getDocument().is() )
++	{
++		uno::Reference< script::XVBACompat > xDocVBAMode( rDocument.getLibraryContainer( E_SCRIPTS ), uno::UNO_QUERY );
++		uno::Reference< script::XVBACompat > xDialogModelVBAMode( xDialogModel, uno::UNO_QUERY );
++		if ( xDocVBAMode.is()  &&  xDialogModelVBAMode.is() )
++			xDialogModelVBAMode->setVBACompatModeOn( xDocVBAMode->getVBACompatModeOn() );
++	}
+     pEditor->SetDialog( xDialogModel );
+ 
+     // Undo einrichten
+@@ -731,7 +740,7 @@ BOOL DialogWindow::SaveDialog()
+         Reference< beans::XPropertySet > xProps( ::comphelper::getProcessServiceFactory(), UNO_QUERY );
+         OSL_ASSERT( xProps.is() );
+         OSL_VERIFY( xProps->getPropertyValue( ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("DefaultContext")) ) >>= xContext );
+-        Reference< XInputStreamProvider > xISP = ::xmlscript::exportDialogModel( xDialogModel, xContext );
++		Reference< XInputStreamProvider > xISP = ::xmlscript::exportDialogModel( xDialogModel, xContext, GetDocument().getDocument() );
+         Reference< XInputStream > xInput( xISP->createInputStream() );
+ 
+         Reference< XSimpleFileAccess > xSFI( xMSF->createInstance
+@@ -1013,7 +1022,7 @@ BOOL implImportDialog( Window* pWin, con
+             Reference< beans::XPropertySet > xProps( xMSF, UNO_QUERY );
+             OSL_ASSERT( xProps.is() );
+             OSL_VERIFY( xProps->getPropertyValue( ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("DefaultContext")) ) >>= xContext );
+-            ::xmlscript::importDialogModel( xInput, xDialogModel, xContext );
++            ::xmlscript::importDialogModel( xInput, xDialogModel, xContext, rDocument.getDocument() );
+ 
+             String aXmlDlgName;
+             Reference< beans::XPropertySet > xDialogModelPropSet( xDialogModel, UNO_QUERY );
+@@ -1239,7 +1248,7 @@ BOOL implImportDialog( Window* pWin, con
+                 }
+             }
+ 
+-            Reference< XInputStreamProvider > xISP = ::xmlscript::exportDialogModel( xDialogModel, xContext );
++            Reference< XInputStreamProvider > xISP = ::xmlscript::exportDialogModel( xDialogModel, xContext, rDocument.getDocument() );
+             bool bSuccess = rDocument.insertDialog( aLibName, aNewDlgName, xISP );
+             if( bSuccess )
+             {
+@@ -1300,8 +1309,9 @@ BasicEntryDescriptor DialogWindow::Creat
+ {
+     ScriptDocument aDocument( GetDocument() );
+     String aLibName( GetLibName() );
++    String aLibSubName;
+     LibraryLocation eLocation = aDocument.getLibraryLocation( aLibName );
+-    return BasicEntryDescriptor( aDocument, eLocation, aLibName, GetName(), OBJ_TYPE_DIALOG );
++    return BasicEntryDescriptor( aDocument, eLocation, aLibName, aLibSubName, GetName(), OBJ_TYPE_DIALOG );
+ }
+ 
+ void DialogWindow::SetReadOnly( BOOL b )
+@@ -1348,7 +1358,7 @@ void DialogWindow::StoreData()
+                     Reference< beans::XPropertySet > xProps( ::comphelper::getProcessServiceFactory(), UNO_QUERY );
+                     OSL_ASSERT( xProps.is() );
+                     OSL_VERIFY( xProps->getPropertyValue( ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("DefaultContext")) ) >>= xContext );
+-                    Reference< XInputStreamProvider > xISP = ::xmlscript::exportDialogModel( xDialogModel, xContext );
++					Reference< XInputStreamProvider > xISP = ::xmlscript::exportDialogModel( xDialogModel, xContext, GetDocument().getDocument() );
+                     xLib->replaceByName( ::rtl::OUString( GetName() ), makeAny( xISP ) );
+                 }
+             }
+--- basctl/source/basicide/basides1.cxx.old	2009-10-07 15:07:22.000000000 +0200
++++ basctl/source/basicide/basides1.cxx	2010-03-03 16:59:34.000000000 +0100
+@@ -1201,10 +1201,16 @@ IDEBaseWindow* BasicIDEShell::FindWindow
+                 // return any non-suspended window
+                 return pWin;
+             }
+-            else if ( pWin->IsDocument( rDocument ) && pWin->GetLibName() == rLibName && pWin->GetName() == rName &&
++            else if ( pWin->IsDocument( rDocument ) )
++            {
++                OSL_TRACE("FindWindow pWin->GetLibName() %s rLibName %s",
++			rtl::OUStringToOString( pWin->GetLibName(), RTL_TEXTENCODING_UTF8 ).getStr(),
++			rtl::OUStringToOString( rLibName, RTL_TEXTENCODING_UTF8 ).getStr() );
++                OSL_TRACE("pWin->pWin->IsA( TYPE( ModulWindow ) %d && nType %d = BASICIDE_TYPE_MODULE %d", pWin->IsA( TYPE( ModulWindow ) ), nType, BASICIDE_TYPE_MODULE );
++                OSL_TRACE("pWin->pWin->IsA( TYPE( DialogWindow ) %d && nType %d = BASICIDE_TYPE_DIALOG %d", pWin->IsA( TYPE( DialogWindow ) ), nType, BASICIDE_TYPE_DIALOG );
++		if (  pWin->GetLibName() == rLibName && pWin->GetName() == rName &&
+                       ( ( pWin->IsA( TYPE( ModulWindow ) )  && nType == BASICIDE_TYPE_MODULE ) ||
+                         ( pWin->IsA( TYPE( DialogWindow ) ) && nType == BASICIDE_TYPE_DIALOG ) ) )
+-            {
+                 return pWin;
+             }
+         }
+--- basctl/source/basicide/basides2.cxx.old	2009-10-07 15:07:22.000000000 +0200
++++ basctl/source/basicide/basides2.cxx	2010-03-03 16:59:34.000000000 +0100
+@@ -55,11 +55,38 @@
+ #include <tools/diagnose_ex.h>
+ #include <sfx2/sfxdefs.hxx>
+ #include <sfx2/signaturestate.hxx>
++#include <com/sun/star/script/ModuleInfo.hpp>
++#include <com/sun/star/container/XNameContainer.hpp>
++#include <com/sun/star/container/XNamed.hpp>
++#include <com/sun/star/lang/XServiceInfo.hpp>
+ 
+ using namespace ::com::sun::star;
+ using namespace ::com::sun::star::uno;
+ namespace css = ::com::sun::star;
+ 
++void lcl_getObjectName( const uno::Reference< container::XNameContainer >& rLib, const String& rModName, String& rObjName )
++{
++    try
++    {
++		uno::Any aElement( rLib->getByName( rModName ) );
++		script::ModuleInfo aModuleInfo;
++		if( aElement >>= aModuleInfo )
++		{
++			uno::Any aObject( aModuleInfo.ModuleObject );
++			uno::Reference< lang::XServiceInfo > xServiceInfo( aObject, uno::UNO_QUERY );
++			if( xServiceInfo.is() && xServiceInfo->supportsService( rtl::OUString::createFromAscii( "ooo.vba.excel.Worksheet" ) ) )
++			{
++				uno::Reference< container::XNamed > xNamed( aObject, uno::UNO_QUERY );
++				if( xNamed.is() )
++					rObjName = xNamed->getName();
++			}
++		}
++    }
++    catch( uno::Exception& )
++    {
++    }
++}
++
+ IMPL_LINK_INLINE_START( BasicIDEShell, ObjectDialogCancelHdl, ObjectCatalog *, EMPTYARG )
+ {
+     ShowObjectDialog( FALSE, TRUE );
+@@ -232,7 +259,7 @@ ModulWindow* BasicIDEShell::CreateBasWin
+     if ( !aLibName.Len() )
+         aLibName = String::CreateFromAscii( "Standard" );
+ 
+-    rDocument.getOrCreateLibrary( E_SCRIPTS, aLibName );
++    uno::Reference< container::XNameContainer > xLib = rDocument.getOrCreateLibrary( E_SCRIPTS, aLibName );
+ 
+     if ( !aModName.Len() )
+         aModName = rDocument.createObjectName( E_SCRIPTS, aLibName );
+@@ -251,9 +278,12 @@ ModulWindow* BasicIDEShell::CreateBasWin
+ 
+         if ( bSuccess )
+         {
+-            // new module window
+-            pWin = new ModulWindow( pModulLayout, rDocument, aLibName, aModName, aModule );
+-            nKey = InsertWindowInTable( pWin );
++			pWin = FindBasWin( rDocument, aLibName, aModName, FALSE, TRUE );
++            if( !pWin )
++			{    // new module window
++			    pWin = new ModulWindow( pModulLayout, rDocument, aLibName, aModName, aModule );
++			    nKey = InsertWindowInTable( pWin );
++            }
+         }
+     }
+     else
+@@ -268,7 +298,21 @@ ModulWindow* BasicIDEShell::CreateBasWin
+         }
+         DBG_ASSERT( nKey, "CreateBasWin: Kein Key- Fenster nicht gefunden!" );
+     }
+-    pTabBar->InsertPage( (USHORT)nKey, aModName );
++    if( nKey )
++	{
++		if( xLib.is() )
++		{
++			// display a nice friendly name in the ObjectModule tab,
++			// combining the objectname and module name, e.g. Sheet1 ( Financials )
++			String sObjName;
++			lcl_getObjectName( xLib, rModName, sObjName );
++			if( sObjName.Len() )
++			{
++				aModName.AppendAscii(" (").Append(sObjName).AppendAscii(")");
++			}
++		}
++		pTabBar->InsertPage( (USHORT)nKey, aModName );
++	}	
+     pTabBar->Sort();
+     pWin->GrabScrollBars( &aHScrollBar, &aVScrollBar );
+     if ( !pCurWin )
+--- basctl/source/basicide/basides3.cxx.old	2009-10-08 16:18:20.000000000 +0200
++++ basctl/source/basicide/basides3.cxx	2010-03-03 16:59:34.000000000 +0100
+@@ -99,7 +99,7 @@ DialogWindow* BasicIDEShell::CreateDlgWi
+                 Reference< beans::XPropertySet > xProps( xMSF, UNO_QUERY );
+                 OSL_ASSERT( xProps.is() );
+                 OSL_VERIFY( xProps->getPropertyValue( ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("DefaultContext")) ) >>= xContext );
+-                ::xmlscript::importDialogModel( xInput, xDialogModel, xContext );
++				::xmlscript::importDialogModel( xInput, xDialogModel, xContext, rDocument.getDocument() );
+                 LocalizationMgr::setStringResourceAtDialog( rDocument, rLibName, aDlgName, xDialogModel );
+ 
+                 // new dialog window
+--- basctl/source/basicide/basidesh.cxx.old	2009-10-07 15:07:22.000000000 +0200
++++ basctl/source/basicide/basidesh.cxx	2010-03-03 16:59:34.000000000 +0100
+@@ -80,6 +80,9 @@
+ #include <com/sun/star/script/XLibraryContainer.hpp>
+ #include <com/sun/star/script/XLibraryContainerPassword.hpp>
+ #include <com/sun/star/container/XNameContainer.hpp>
++#include <com/sun/star/container/XContainer.hpp>
++#include <com/sun/star/container/XContainerListener.hpp>
++#include <com/sun/star/script/XLibraryContainer.hpp>
+ 
+ #include <svx/xmlsecctrl.hxx>
+ 
+@@ -87,6 +90,71 @@ using namespace ::com::sun::star::uno;
+ using namespace ::com::sun::star;
+ using ::rtl::OUString;
+ 
++static const rtl::OUString sStandardLibName(  rtl::OUString::createFromAscii("Standard") );
++
++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 );
+ 
+@@ -124,6 +192,7 @@ BasicIDEShell::BasicIDEShell( SfxViewFra
+         m_bAppBasicModified( FALSE ),
+         m_aNotifier( *this )
+ {
++    m_xLibListener = new ContainerListenerImpl( this );
+     Init();
+     GnBasicIDEShellCount++;
+ }
+@@ -215,6 +284,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 ) );
+@@ -921,7 +996,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();
+--- basctl/source/basicide/basidesh.src.old	2009-10-08 16:18:20.000000000 +0200
++++ basctl/source/basicide/basidesh.src	2010-03-03 16:59:34.000000000 +0100
+@@ -639,6 +639,22 @@ String RID_STR_TRANSLATION_DEFAULT
+ {
+     Text [ en-US ] = "[Default Language]" ;
+ };
++String RID_STR_DOCUMENT_OBJECTS
++{
++    Text [ en-US ] = "Document Objects" ;
++};
++String RID_STR_USERFORMS
++{
++    Text [ en-US ] = "Forms" ;
++};
++String RID_STR_NORMAL_MODULES
++{
++    Text [ en-US ] = "Modules" ;
++};
++String RID_STR_CLASS_MODULES
++{
++    Text [ en-US ] = "Class Modules" ;
++};
+ 
+ 
+ String RID_STR_DLGIMP_CLASH_RENAME
+--- basctl/source/basicide/bastype2.cxx.old	2009-10-07 15:07:22.000000000 +0200
++++ basctl/source/basicide/bastype2.cxx	2010-03-03 16:59:34.000000000 +0100
+@@ -53,10 +53,25 @@
+ #include <com/sun/star/frame/XModuleManager.hpp>
+ #include <comphelper/processfactory.hxx>
+ #include <comphelper/componentcontext.hxx>
++#include <map>
++#include <com/sun/star/script/ModuleType.hpp>
++#include <com/sun/star/script/ModuleInfo.hpp>
++#include <com/sun/star/container/XNameContainer.hpp>
+ 
+ using namespace ::com::sun::star::uno;
+ using namespace ::com::sun::star;
+ 
++void lcl_getObjectName( const uno::Reference< container::XNameContainer >& rLib, const String& rModName, String& rObjName );
++
++sal_Int32 lcl_getModuleType(  const uno::Reference< container::XNameContainer >& rLib, const String& rModName )
++{
++    sal_Int32 nType = com::sun::star::script::ModuleType::Normal;
++    uno::Any aElement( rLib->getByName( rModName ) );
++    script::ModuleInfo aModuleInfo;
++    if( aElement >>= aModuleInfo )
++        nType = aModuleInfo.ModuleType;
++    return nType;    
++}
+ 
+ BasicEntry::~BasicEntry()
+ {
+@@ -91,20 +106,22 @@ BasicEntryDescriptor::BasicEntryDescript
+ {
+ }
+ 
+-BasicEntryDescriptor::BasicEntryDescriptor( const ScriptDocument& rDocument, LibraryLocation eLocation, const String& rLibName, const String& rName, BasicEntryType eType )
++BasicEntryDescriptor::BasicEntryDescriptor( const ScriptDocument& rDocument, LibraryLocation eLocation, const String& rLibName, const String& rLibSubName, const String& rName, BasicEntryType eType )
+     :m_aDocument( rDocument )
+     ,m_eLocation( eLocation )
+     ,m_aLibName( rLibName )
++    ,m_aLibSubName( rLibSubName )
+     ,m_aName( rName )
+     ,m_eType( eType )
+ {
+     OSL_ENSURE( m_aDocument.isValid(), "BasicEntryDescriptor::BasicEntryDescriptor: invalid document!" );
+ }
+ 
+-BasicEntryDescriptor::BasicEntryDescriptor( const ScriptDocument& rDocument, LibraryLocation eLocation, const String& rLibName, const String& rName, const String& rMethodName, BasicEntryType eType )
++BasicEntryDescriptor::BasicEntryDescriptor( const ScriptDocument& rDocument, LibraryLocation eLocation, const String& rLibName, const String& rLibSubName, const String& rName, const String& rMethodName, BasicEntryType eType )
+     :m_aDocument( rDocument )
+     ,m_eLocation( eLocation )
+     ,m_aLibName( rLibName )
++    ,m_aLibSubName( rLibSubName )
+     ,m_aName( rName )
+     ,m_aMethodName( rMethodName )
+     ,m_eType( eType )
+@@ -120,6 +137,7 @@ BasicEntryDescriptor::BasicEntryDescript
+     :m_aDocument( rDesc.m_aDocument )
+     ,m_eLocation( rDesc.m_eLocation )
+     ,m_aLibName( rDesc.m_aLibName )
++    ,m_aLibSubName( rDesc.m_aLibSubName )
+     ,m_aName( rDesc.m_aName )
+     ,m_aMethodName( rDesc.m_aMethodName )
+     ,m_eType( rDesc.m_eType )
+@@ -131,6 +149,7 @@ BasicEntryDescriptor& BasicEntryDescript
+     m_aDocument = rDesc.m_aDocument;
+     m_eLocation = rDesc.m_eLocation;
+     m_aLibName = rDesc.m_aLibName;
++    m_aLibSubName = rDesc.m_aLibSubName;
+     m_aName = rDesc.m_aName;
+     m_aMethodName = rDesc.m_aMethodName;
+     m_eType = rDesc.m_eType;
+@@ -143,6 +162,7 @@ bool BasicEntryDescriptor::operator==( c
+     return m_aDocument == rDesc.m_aDocument &&
+            m_eLocation == rDesc.m_eLocation &&
+            m_aLibName == rDesc.m_aLibName &&
++           m_aLibSubName == rDesc.m_aLibSubName &&
+            m_aName == rDesc.m_aName &&
+            m_aMethodName == rDesc.m_aMethodName &&
+            m_eType == rDesc.m_eType;
+@@ -286,50 +306,58 @@ void BasicTreeListBox::ImpCreateLibSubEn
+         if ( xModLibContainer.is() && xModLibContainer->hasByName( aOULibName ) && xModLibContainer->isLibraryLoaded( aOULibName ) )
+         {
+             try
+-            {
+-                // get a sorted list of module names
+-                Sequence< ::rtl::OUString > aModNames = rDocument.getObjectNames( E_SCRIPTS, rLibName );
+-                sal_Int32 nModCount = aModNames.getLength();
+-                const ::rtl::OUString* pModNames = aModNames.getConstArray();
+-
+-                for ( sal_Int32 i = 0 ; i < nModCount ; i++ )
++		 	{
++                BasicManager* pBasMgr = rDocument.getBasicManager();
++                StarBASIC* pBasic = pBasMgr ? pBasMgr->GetLib( rLibName ) : 0;
++                sal_Bool bVBAEnabled = pBasic ? pBasic->isVBAEnabled(): sal_False;
++                if( bVBAEnabled )
++                    ImpCreateLibSubEntriesInVBAMode( pLibRootEntry, rDocument, rLibName );
++                else
+                 {
+-                    String aModName = pModNames[ i ];
+-                    SvLBoxEntry* pModuleEntry = FindEntry( pLibRootEntry, aModName, OBJ_TYPE_MODULE );
+-                    if ( !pModuleEntry )
+-                        pModuleEntry = AddEntry(
+-                            aModName,
+-                            Image( IDEResId( RID_IMG_MODULE ) ),
+-                            Image( IDEResId( RID_IMG_MODULE_HC ) ),
+-                            pLibRootEntry, false,
+-                            std::auto_ptr< BasicEntry >( new BasicEntry( OBJ_TYPE_MODULE ) ) );
+-
+-                    // methods
+-                    if ( nMode & BROWSEMODE_SUBS )
+-                    {
+-                        Sequence< ::rtl::OUString > aNames = BasicIDE::GetMethodNames( rDocument, rLibName, aModName );
+-                        sal_Int32 nCount = aNames.getLength();
+-                        const ::rtl::OUString* pNames = aNames.getConstArray();
+-
+-                        for ( sal_Int32 j = 0 ; j < nCount ; j++ )
+-                        {
+-                            String aName = pNames[ j ];
+-                            SvLBoxEntry* pEntry = FindEntry( pModuleEntry, aName, OBJ_TYPE_METHOD );
+-                            if ( !pEntry )
+-                                pEntry = AddEntry(
+-                                    aName,
+-                                    Image( IDEResId( RID_IMG_MACRO ) ),
+-                                    Image( IDEResId( RID_IMG_MACRO_HC ) ),
+-                                    pModuleEntry, false,
+-                                    std::auto_ptr< BasicEntry >( new BasicEntry( OBJ_TYPE_METHOD ) ) );
++                    // get a sorted list of module names
++                    Sequence< ::rtl::OUString > aModNames = rDocument.getObjectNames( E_SCRIPTS, rLibName );
++                    sal_Int32 nModCount = aModNames.getLength();
++		            const ::rtl::OUString* pModNames = aModNames.getConstArray();
++
++                    for ( sal_Int32 i = 0 ; i < nModCount ; i++ )
++		 			{
++                        String aModName = pModNames[ i ];
++                        SvLBoxEntry* pModuleEntry = FindEntry( pLibRootEntry, aModName, OBJ_TYPE_MODULE );
++                        if ( !pModuleEntry )
++                            pModuleEntry = AddEntry(
++                                aModName,
++                                Image( IDEResId( RID_IMG_MODULE ) ),
++                                Image( IDEResId( RID_IMG_MODULE_HC ) ),
++                                pLibRootEntry, false,
++                                std::auto_ptr< BasicEntry >( new BasicEntry( OBJ_TYPE_MODULE ) ) );
++
++		 				// methods
++		 				if ( nMode & BROWSEMODE_SUBS )
++		 				{
++                            Sequence< ::rtl::OUString > aNames = BasicIDE::GetMethodNames( rDocument, rLibName, aModName );
++		 					sal_Int32 nCount = aNames.getLength();
++		 					const ::rtl::OUString* pNames = aNames.getConstArray();
++
++		 					for ( sal_Int32 j = 0 ; j < nCount ; j++ )
++		 					{
++		 						String aName = pNames[ j ];
++		 						SvLBoxEntry* pEntry = FindEntry( pModuleEntry, aName, OBJ_TYPE_METHOD );
++                                if ( !pEntry )
++                                    pEntry = AddEntry(
++                                        aName,
++                                        Image( IDEResId( RID_IMG_MACRO ) ),
++                                        Image( IDEResId( RID_IMG_MACRO_HC ) ),
++                                        pModuleEntry, false,
++                                        std::auto_ptr< BasicEntry >( new BasicEntry( OBJ_TYPE_METHOD ) ) );
++		 					}
+                         }
+-                    }
++		 			}
+                 }
+             }
+-            catch ( const container::NoSuchElementException& )
+-            {
++		 	catch ( const container::NoSuchElementException& )
++		 	{
+                 DBG_UNHANDLED_EXCEPTION();
+-            }
++		 	}
+         }   
+     }
+ 
+@@ -368,6 +396,139 @@ void BasicTreeListBox::ImpCreateLibSubEn
+     }
+ }
+ 
++void BasicTreeListBox::ImpCreateLibSubEntriesInVBAMode( SvLBoxEntry* pLibRootEntry, const ScriptDocument& rDocument, const String& rLibName )
++{
++    ::std::map< BasicEntryType, ::rtl::OUString > aEntryMap;
++    aEntryMap.insert( ::std::make_pair( OBJ_TYPE_DOCUMENT_OBJECTS, String( IDEResId( RID_STR_DOCUMENT_OBJECTS ) ) ) );
++    aEntryMap.insert( ::std::make_pair( OBJ_TYPE_USERFORMS,  String( IDEResId( RID_STR_USERFORMS ) ) ) );
++    aEntryMap.insert( ::std::make_pair( OBJ_TYPE_NORMAL_MODULES, String( IDEResId( RID_STR_NORMAL_MODULES ) ) ) );
++    aEntryMap.insert( ::std::make_pair( OBJ_TYPE_CLASS_MODULES,  String( IDEResId( RID_STR_CLASS_MODULES ) ) ) );
++
++    ::std::map< BasicEntryType, ::rtl::OUString >::iterator iter;
++    for( iter = aEntryMap.begin(); iter != aEntryMap.end(); ++iter )
++    {
++        BasicEntryType eType = iter->first;
++        ::rtl::OUString aEntryName = iter->second;
++        SvLBoxEntry* pLibSubRootEntry = FindEntry( pLibRootEntry, aEntryName, eType );
++        if( pLibSubRootEntry )
++        {
++            SetEntryBitmaps( pLibSubRootEntry, Image( IDEResId( RID_IMG_MODLIB ) ), Image( IDEResId( RID_IMG_MODLIB_HC ) ) );
++            if ( IsExpanded( pLibSubRootEntry ) )
++			    ImpCreateLibSubSubEntriesInVBAMode( pLibSubRootEntry, rDocument, rLibName );
++        }
++        else
++        {
++            pLibSubRootEntry = AddEntry(
++                aEntryName,
++                Image( IDEResId( RID_IMG_MODLIB ) ),
++                Image( IDEResId( RID_IMG_MODLIB_HC ) ),
++                pLibRootEntry, true,
++                std::auto_ptr< BasicEntry >( new BasicEntry( eType ) ) );
++        }
++    }
++}
++
++void BasicTreeListBox::ImpCreateLibSubSubEntriesInVBAMode( SvLBoxEntry* pLibSubRootEntry, const ScriptDocument& rDocument, const String& rLibName )
++{
++    uno::Reference< container::XNameContainer > xLib = rDocument.getOrCreateLibrary( E_SCRIPTS, rLibName );
++    if( !xLib.is() )
++        return;
++
++    try
++	{
++        // get a sorted list of module names
++        Sequence< ::rtl::OUString > aModNames = rDocument.getObjectNames( E_SCRIPTS, rLibName );
++        sal_Int32 nModCount = aModNames.getLength();
++    	const ::rtl::OUString* pModNames = aModNames.getConstArray();
++
++        BasicEntryDescriptor aDesc( GetEntryDescriptor( pLibSubRootEntry ) );
++        BasicEntryType eCurrentType( aDesc.GetType() );
++
++        for ( sal_Int32 i = 0 ; i < nModCount ; i++ )
++		{
++            String aModName = pModNames[ i ];
++            BasicEntryType eType = OBJ_TYPE_UNKNOWN;
++            switch( lcl_getModuleType( xLib, aModName ) )
++            {
++                case script::ModuleType::Document:
++                    eType = OBJ_TYPE_DOCUMENT_OBJECTS;
++                    break;
++                case script::ModuleType::Form:
++                    eType = OBJ_TYPE_USERFORMS;
++                    break;
++                case script::ModuleType::Normal:
++                    eType = OBJ_TYPE_NORMAL_MODULES;
++                    break;
++                case script::ModuleType::Class:
++                    eType = OBJ_TYPE_CLASS_MODULES;
++                    break;
++            }
++            if( eType != eCurrentType )
++                continue;
++
++			// display a nice friendly name in the ObjectModule tab,
++           	// combining the objectname and module name, e.g. Sheet1 ( Financials )
++            String aEntryName( aModName );
++            if( eType == OBJ_TYPE_DOCUMENT_OBJECTS )
++            {
++	       	    String sObjName;
++            	lcl_getObjectName( xLib, aModName, sObjName );
++		    	if( sObjName.Len() )
++        	   	{
++		        	aEntryName.AppendAscii(" (").Append(sObjName).AppendAscii(")");
++            	}
++            }
++            SvLBoxEntry* pModuleEntry = FindEntry( pLibSubRootEntry, aEntryName, OBJ_TYPE_MODULE );
++            if ( !pModuleEntry )
++                pModuleEntry = AddEntry(
++                    aEntryName,
++                    Image( IDEResId( RID_IMG_MODULE ) ),
++                    Image( IDEResId( RID_IMG_MODULE_HC ) ),
++                    pLibSubRootEntry, false,
++                    std::auto_ptr< BasicEntry >( new BasicEntry( OBJ_TYPE_MODULE ) ) );
++
++			// methods
++			if ( nMode & BROWSEMODE_SUBS )
++			{
++                Sequence< ::rtl::OUString > aNames = BasicIDE::GetMethodNames( rDocument, rLibName, aModName );
++				sal_Int32 nCount = aNames.getLength();
++				const ::rtl::OUString* pNames = aNames.getConstArray();
++
++				for ( sal_Int32 j = 0 ; j < nCount ; j++ )
++				{
++					String aName = pNames[ j ];
++					SvLBoxEntry* pEntry = FindEntry( pModuleEntry, aName, OBJ_TYPE_METHOD );
++                    if ( !pEntry )
++                        pEntry = AddEntry(
++                            aName,
++                            Image( IDEResId( RID_IMG_MACRO ) ),
++                            Image( IDEResId( RID_IMG_MACRO_HC ) ),
++                            pModuleEntry, false,
++                            std::auto_ptr< BasicEntry >( new BasicEntry( OBJ_TYPE_METHOD ) ) );
++    			}
++            }
++	    }
++    }
++    catch ( const container::NoSuchElementException& )
++	{
++        DBG_UNHANDLED_EXCEPTION();
++    }
++}
++
++SvLBoxEntry* BasicTreeListBox::ImpFindEntry( SvLBoxEntry* pParent, const String& rText )
++{
++	ULONG nRootPos = 0;
++	SvLBoxEntry* pEntry = pParent ? FirstChild( pParent ) : GetEntry( nRootPos );
++	while ( pEntry )
++	{
++		if (  GetEntryText( pEntry ) == rText ) 
++			return pEntry;
++
++		pEntry = pParent ? NextSibling( pEntry ) : GetEntry( ++nRootPos );
++	}
++	return 0;
++}
++
+ void BasicTreeListBox::onDocumentCreated( const ScriptDocument& /*_rDocument*/ )
+ {
+     UpdateEntries();
+@@ -480,10 +641,11 @@ long BasicTreeListBox::ExpandingHdl()
+         if ( aDocument.isAlive() )
+         {
+             String aLibName( aDesc.GetLibName() );
++            String aLibSubName( aDesc.GetLibSubName() );
+             String aName( aDesc.GetName() );
+             String aMethodName( aDesc.GetMethodName() );
+ 
+-            if ( aLibName.Len() && !aName.Len() && !aMethodName.Len() )
++            if ( aLibName.Len() && !aLibSubName.Len() && !aName.Len() && !aMethodName.Len() )
+             {
+                 // check password, if library is password protected and not verified
+                 ::rtl::OUString aOULibName( aLibName );
+@@ -636,7 +798,7 @@ void BasicTreeListBox::SetCurrentEntry(
+         aDesc = BasicEntryDescriptor(
+             ScriptDocument::getApplicationScriptDocument(),
+             LIBRARY_LOCATION_USER, String::CreateFromAscii( "Standard" ), 
+-            String::CreateFromAscii( "." ), OBJ_TYPE_UNKNOWN );
++            String(), String::CreateFromAscii( "." ), OBJ_TYPE_UNKNOWN );
+     }
+     ScriptDocument aDocument( aDesc.GetDocument() );
+     OSL_ENSURE( aDocument.isValid(), "BasicTreeListBox::SetCurrentEntry: invalid document!" );
+@@ -653,14 +815,24 @@ void BasicTreeListBox::SetCurrentEntry(
+             if ( pLibEntry )
+             {
+                 pCurEntry = pLibEntry;
++                String aLibSubName( aDesc.GetLibSubName() );
++                if( aLibSubName.Len() )
++                {
++                    Expand( pLibEntry );
++                    SvLBoxEntry* pLibSubEntry = ImpFindEntry( pLibEntry, aLibSubName );
++                    if( pLibSubEntry )
++                    {
++                        pCurEntry = pLibSubEntry;
++                    }
++                }
+                 String aName( aDesc.GetName() );
+                 if ( aName.Len() )
+                 {
+-                    Expand( pLibEntry );
++                    Expand( pCurEntry );
+                     BasicEntryType eType = OBJ_TYPE_MODULE;
+                     if ( aDesc.GetType() == OBJ_TYPE_DIALOG )
+                         eType = OBJ_TYPE_DIALOG;
+-                    SvLBoxEntry* pEntry = FindEntry( pLibEntry, aName, eType );
++                    SvLBoxEntry* pEntry = FindEntry( pCurEntry, aName, eType );
+                     if ( pEntry )
+                     {
+                         pCurEntry = pEntry;
+--- basctl/source/basicide/bastype2.hxx.old	2009-10-07 15:07:22.000000000 +0200
++++ basctl/source/basicide/bastype2.hxx	2010-03-03 16:59:34.000000000 +0100
+@@ -42,7 +42,7 @@
+ #include <sbxitem.hxx>
+ #include "basobj.hxx"
+ 
+-enum BasicEntryType { OBJ_TYPE_UNKNOWN, OBJ_TYPE_DOCUMENT, OBJ_TYPE_LIBRARY, OBJ_TYPE_MODULE, OBJ_TYPE_DIALOG, OBJ_TYPE_METHOD };
++enum BasicEntryType { OBJ_TYPE_UNKNOWN, OBJ_TYPE_DOCUMENT, OBJ_TYPE_LIBRARY, OBJ_TYPE_MODULE, OBJ_TYPE_DIALOG, OBJ_TYPE_METHOD, OBJ_TYPE_DOCUMENT_OBJECTS, OBJ_TYPE_USERFORMS, OBJ_TYPE_NORMAL_MODULES, OBJ_TYPE_CLASS_MODULES };
+ 
+ #define BROWSEMODE_MODULES		0x01
+ #define BROWSEMODE_SUBS			0x02
+@@ -101,14 +101,15 @@ class BasicEntryDescriptor
+     ScriptDocument          m_aDocument;
+     LibraryLocation         m_eLocation;
+     String                  m_aLibName;
++    String                  m_aLibSubName;  // for vba entry:  Document Objects, Class Modules, Forms and Normal Modules
+     String                  m_aName;
+     String                  m_aMethodName;
+     BasicEntryType          m_eType;
+ 
+ public:
+                             BasicEntryDescriptor();
+-                            BasicEntryDescriptor( const ScriptDocument& rDocument, LibraryLocation eLocation, const String& rLibName, const String& rName, BasicEntryType eType );
+-                            BasicEntryDescriptor( const ScriptDocument& rDocument, LibraryLocation eLocation, const String& rLibName, const String& rName, const String& rMethodName, BasicEntryType eType );
++	                        BasicEntryDescriptor( const ScriptDocument& rDocument, LibraryLocation eLocation, const String& rLibName, const String& rLibSubName, const String& rName, BasicEntryType eType );
++	                        BasicEntryDescriptor( const ScriptDocument& rDocument, LibraryLocation eLocation, const String& rLibName, const String& rLibSubName, const String& rName, const String& rMethodName, BasicEntryType eType );
+     virtual                 ~BasicEntryDescriptor();
+ 
+                             BasicEntryDescriptor( const BasicEntryDescriptor& rDesc );
+@@ -125,6 +126,9 @@ public:
+     const String&           GetLibName() const { return m_aLibName; }
+     void                    SetLibName( const String& aLibName ) { m_aLibName = aLibName; }
+ 
++    const String&           GetLibSubName() const { return m_aLibSubName; }
++    void                    SetLibSubName( const String& aLibSubName ) { m_aLibSubName = aLibSubName; }
++
+     const String&           GetName() const { return m_aName; }
+     void                    SetName( const String& aName ) { m_aName = aName; }
+ 
+@@ -164,6 +168,9 @@ protected:
+ 
+     void                    ImpCreateLibEntries( SvLBoxEntry* pShellRootEntry, const ScriptDocument& rDocument, LibraryLocation eLocation );
+     void 					ImpCreateLibSubEntries( SvLBoxEntry* pLibRootEntry, const ScriptDocument& rDocument, const String& rLibName );
++	void 					ImpCreateLibSubEntriesInVBAMode( SvLBoxEntry* pLibRootEntry, const ScriptDocument& rDocument, const String& rLibName );
++	void 					ImpCreateLibSubSubEntriesInVBAMode( SvLBoxEntry* pLibSubRootEntry, const ScriptDocument& rDocument, const String& rLibName );
++    SvLBoxEntry*            ImpFindEntry( SvLBoxEntry* pParent, const String& rText );
+ 
+     // DocumentEventListener
+     virtual void onDocumentCreated( const ScriptDocument& _rDocument );
+--- basctl/source/basicide/bastype3.cxx.old	2009-10-07 15:07:22.000000000 +0200
++++ basctl/source/basicide/bastype3.cxx	2010-03-03 16:59:34.000000000 +0100
+@@ -134,6 +134,14 @@ void __EXPORT BasicTreeListBox::Requesti
+             }
+         }
+     }
++    else if ( eType == OBJ_TYPE_DOCUMENT_OBJECTS 
++            || eType == OBJ_TYPE_USERFORMS
++            || eType == OBJ_TYPE_NORMAL_MODULES
++            || eType == OBJ_TYPE_CLASS_MODULES )
++    {
++        String aLibName( aDesc.GetLibName() );
++        ImpCreateLibSubSubEntriesInVBAMode( pEntry, aDocument, aLibName );
++    }
+     else {
+         DBG_ERROR( "BasicTreeListBox::RequestingChilds: Unknown Type!" );
+     }
+@@ -204,6 +212,7 @@ SbxVariable* BasicTreeListBox::FindVaria
+     }
+ 
+     SbxVariable* pVar = 0;
++    bool bDocumentObjects = false;
+     if ( aEntries.Count() )
+     {
+         for ( USHORT n = 0; n < aEntries.Count(); n++ )
+@@ -226,6 +235,12 @@ SbxVariable* BasicTreeListBox::FindVaria
+                 case OBJ_TYPE_MODULE:
+                 {
+                     DBG_ASSERT( pVar && pVar->IsA( TYPE(StarBASIC) ), "FindVariable: Ungueltiges Basic" );
++                    // extract the module name from the string like "Sheet1 (Example1)"
++                    if( bDocumentObjects )
++                    {
++                        sal_uInt16 nIndex = 0;
++                        aName = aName.GetToken( 0, ' ', nIndex );
++                    }
+                     pVar = ((StarBASIC*)pVar)->FindModule( aName );
+                 }
+                 break;
+@@ -240,6 +255,15 @@ SbxVariable* BasicTreeListBox::FindVaria
+                     // sbx dialogs removed
+                 }
+                 break;
++                case OBJ_TYPE_DOCUMENT_OBJECTS:
++                    bDocumentObjects = true;
++                case OBJ_TYPE_USERFORMS:
++                case OBJ_TYPE_NORMAL_MODULES:
++                case OBJ_TYPE_CLASS_MODULES:
++                {
++                    // skip, to find the child entry.
++                    continue;
++                }
+                 default:
+                 {
+                     DBG_ERROR( "FindVariable: Unbekannter Typ!" );
+@@ -260,12 +284,13 @@ BasicEntryDescriptor BasicTreeListBox::G
+     ScriptDocument aDocument( ScriptDocument::getApplicationScriptDocument() );
+     LibraryLocation eLocation = LIBRARY_LOCATION_UNKNOWN;
+     String aLibName;
++	String aLibSubName;
+     String aName;
+     String aMethodName;
+     BasicEntryType eType = OBJ_TYPE_UNKNOWN;
+ 
+     if ( !pEntry )
+-        return BasicEntryDescriptor( aDocument, eLocation, aLibName, aName, aMethodName, eType );
++        return BasicEntryDescriptor( aDocument, eLocation, aLibName, aLibSubName, aName, aMethodName, eType );
+ 
+     EntryArray aEntries;
+ 
+@@ -332,6 +357,15 @@ BasicEntryDescriptor BasicTreeListBox::G
+                     eType = pBE->GetType();
+                 }
+                 break;
++                case OBJ_TYPE_DOCUMENT_OBJECTS:
++                case OBJ_TYPE_USERFORMS:
++                case OBJ_TYPE_NORMAL_MODULES:
++                case OBJ_TYPE_CLASS_MODULES:
++				{
++					aLibSubName = GetEntryText( pLE );
++					eType = pBE->GetType();
++				}
++				break;
+                 default:
+                 {
+                     DBG_ERROR( "GetEntryDescriptor: Unbekannter Typ!" );
+@@ -345,7 +379,7 @@ BasicEntryDescriptor BasicTreeListBox::G
+         }
+     }
+ 
+-    return BasicEntryDescriptor( aDocument, eLocation, aLibName, aName, aMethodName, eType );
++    return BasicEntryDescriptor( aDocument, eLocation, aLibName, aLibSubName, aName, aMethodName, eType );
+ }
+ 
+ USHORT BasicTreeListBox::ConvertType( BasicEntryType eType )
+@@ -427,6 +461,14 @@ bool BasicTreeListBox::IsValidEntry( SvL
+             bIsValid = BasicIDE::HasMethod( aDocument, aLibName, aName, aMethodName );
+         }
+         break;
++        case OBJ_TYPE_DOCUMENT_OBJECTS:
++        case OBJ_TYPE_USERFORMS:
++        case OBJ_TYPE_NORMAL_MODULES:
++        case OBJ_TYPE_CLASS_MODULES:
++        {
++            bIsValid = true;
++        }
++        break;
+         default: ;
+     }
+ 
+--- basctl/source/basicide/bastypes.cxx.old	2009-10-08 16:18:20.000000000 +0200
++++ basctl/source/basicide/bastypes.cxx	2010-03-03 16:59:34.000000000 +0100
+@@ -60,6 +60,7 @@
+ #include <com/sun/star/script/XLibraryContainer2.hpp>
+ #endif
+ #include <com/sun/star/script/XLibraryContainerPassword.hpp>
++#include <com/sun/star/script/ModuleType.hpp>
+ 
+ using namespace ::com::sun::star::uno;
+ using namespace ::com::sun::star;
+@@ -594,8 +595,30 @@ void __EXPORT BasicIDETabBar::Command( c
+                 aPopup.EnableItem( SID_BASICIDE_RENAMECURRENT, FALSE );
+                 aPopup.RemoveDisabledEntries();
+             }
++			
++			// disable to delete or remove object modules in IDE
++			BasicManager* pBasMgr = aDocument.getBasicManager();
++			if ( pBasMgr )
++			{
++				StarBASIC* pBasic = pBasMgr->GetLib( aOULibName );
++				if( pBasic )
++				{
++					IDEWindowTable& aIDEWindowTable = pIDEShell->GetIDEWindowTable();
++					IDEBaseWindow* pWin = aIDEWindowTable.Get( GetCurPageId() );
++					if( pWin && pWin->ISA( ModulWindow ) )
++					{
++						SbModule* pActiveModule = (SbModule*)pBasic->FindModule( pWin->GetName() );
++						if( pActiveModule && ( pActiveModule->GetModuleType() == script::ModuleType::Document ) )
++						{
++							aPopup.EnableItem( SID_BASICIDE_DELETECURRENT, FALSE );
++							aPopup.EnableItem( SID_BASICIDE_RENAMECURRENT, FALSE );
++						}
++					}
++				}
++			}
+         }
+ 
++
+         SfxViewFrame* pViewFrame = pIDEShell ? pIDEShell->GetViewFrame() : NULL;
+         SfxDispatcher* pDispatcher = pViewFrame ? pViewFrame->GetDispatcher() : NULL;
+         if ( pDispatcher )
+--- basctl/source/basicide/macrodlg.cxx.old	2009-10-07 15:07:22.000000000 +0200
++++ basctl/source/basicide/macrodlg.cxx	2010-03-03 16:59:34.000000000 +0100
+@@ -385,7 +385,15 @@ SbMethod* MacroChooser::CreateMacro()
+         SbModule* pModule = 0;
+         String aModName( aDesc.GetName() );
+         if ( aModName.Len() )
++        {
++            // extract the module name from the string like "Sheet1 (Example1)"
++            if( aDesc.GetLibSubName().Equals( String( IDEResId( RID_STR_DOCUMENT_OBJECTS ) ) ) )
++            {
++                sal_uInt16 nIndex = 0;
++                aModName = aModName.GetToken( 0, ' ', nIndex );
++            }
+             pModule = pBasic->FindModule( aModName );
++        }    
+         else if ( pBasic->GetModules()->Count() )
+             pModule = (SbModule*)pBasic->GetModules()->Get( 0 );
+ 
+@@ -713,6 +721,12 @@ IMPL_LINK( MacroChooser, ButtonHdl, Butt
+         BasicManager* pBasMgr = aDocument.getBasicManager();
+         String aLib( aDesc.GetLibName() );
+         String aMod( aDesc.GetName() );
++        // extract the module name from the string like "Sheet1 (Example1)"
++        if( aDesc.GetLibSubName().Equals( String( IDEResId( RID_STR_DOCUMENT_OBJECTS ) ) ) )
++        {
++            sal_uInt16 nIndex = 0;
++            aMod = aMod.GetToken( 0, ' ', nIndex );
++        }
+         String aSub( aDesc.GetMethodName() );
+         SfxMacroInfoItem aInfoItem( SID_BASICIDE_ARG_MACROINFO, pBasMgr, aLib, aMod, aSub, String() );
+         if ( pButton == &aEditButton )
+--- basctl/source/basicide/moduldlg.cxx.old	2009-10-07 15:07:22.000000000 +0200
++++ basctl/source/basicide/moduldlg.cxx	2010-03-03 16:59:34.000000000 +0100
+@@ -87,7 +87,7 @@ BOOL __EXPORT ExtBasicTreeListBox::Editi
+     if ( pEntry )
+     {
+         USHORT nDepth = GetModel()->GetDepth( pEntry );
+-        if ( nDepth == 2 )
++        if ( nDepth >= 2 )
+         {
+             BasicEntryDescriptor aDesc( GetEntryDescriptor( pEntry ) );
+             ScriptDocument aDocument( aDesc.GetDocument() );
+@@ -165,7 +165,7 @@ DragDropMode __EXPORT ExtBasicTreeListBo
+     if ( pEntry )
+     {
+         USHORT nDepth = GetModel()->GetDepth( pEntry );
+-        if ( nDepth == 2 )
++        if ( nDepth >= 2 )
+         {
+             nMode_ = SV_DRAGDROP_CTRL_COPY;
+             BasicEntryDescriptor aDesc( GetEntryDescriptor( pEntry ) );
+@@ -213,7 +213,7 @@ BOOL __EXPORT ExtBasicTreeListBox::Notif
+ 
+     // don't drop on a library, which is not loaded, readonly or password protected
+     // or which already has a module/dialog with this name
+-    if ( bValid && ( nDepth == 1 || nDepth == 2 ) )
++    if ( bValid && ( nDepth > 0 ) )
+     {
+         // get source module/dialog name
+         BasicEntryDescriptor aSourceDesc( GetEntryDescriptor( pSelected ) );
+@@ -315,7 +315,7 @@ void BasicIDEShell::CopyDialogResources(
+     Reference< beans::XPropertySet > xProps( xMSF, UNO_QUERY );
+     OSL_ASSERT( xProps.is() );
+     OSL_VERIFY( xProps->getPropertyValue( ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("DefaultContext")) ) >>= xContext );
+-    ::xmlscript::importDialogModel( xInput, xDialogModel, xContext );
++	::xmlscript::importDialogModel( xInput, xDialogModel, xContext, rSourceDoc.getDocument() );
+ 
+     if( xDialogModel.is() )
+     {
+@@ -332,7 +332,7 @@ void BasicIDEShell::CopyDialogResources(
+         {
+             LocalizationMgr::setResourceIDsForDialog( xDialogModel, xDestMgr );
+         }
+-        io_xISP = ::xmlscript::exportDialogModel( xDialogModel, xContext );
++		io_xISP = ::xmlscript::exportDialogModel( xDialogModel, xContext, rDestDoc.getDocument() );
+     }
+ }
+ 
+@@ -351,7 +351,7 @@ BOOL __EXPORT ExtBasicTreeListBox::Notif
+         rpNewParent = pTarget;
+         rNewChildPos = 0;
+     }
+-    else if ( nDepth == 2 )
++	else if ( nDepth >= 2 )
+     {
+         // Target = Modul/Dialog => Modul/Dialog unter das uebergeordnete Basic haengen...
+         rpNewParent = GetParent( pTarget );
+@@ -626,20 +626,31 @@ void ObjectPage::CheckButtons()
+ {
+     // enable/disable edit button
+     SvLBoxEntry* pCurEntry = aBasicBox.GetCurEntry();
++    BasicEntryDescriptor aDesc( aBasicBox.GetEntryDescriptor( pCurEntry ) );
++    ScriptDocument aDocument( aDesc.GetDocument() );
++    ::rtl::OUString aOULibName( aDesc.GetLibName() );
++    String aLibSubName( aDesc.GetLibSubName() );
++    BasicManager* pBasMgr = aDocument.getBasicManager();
++    StarBASIC* pBasic = pBasMgr ? pBasMgr->GetLib( aOULibName ) : 0;
++    sal_Bool bVBAEnabled = pBasic ? pBasic->isVBAEnabled(): sal_False;
++    USHORT nMode = aBasicBox.GetMode();
++
+     USHORT nDepth = pCurEntry ? aBasicBox.GetModel()->GetDepth( pCurEntry ) : 0;
+-    if ( nDepth == 2 )
+-        aEditButton.Enable();
++	if ( nDepth >= 2 )
++    {
++        if( bVBAEnabled && ( nMode & BROWSEMODE_MODULES ) && ( nDepth == 2 ) )
++            aEditButton.Disable();
++        else
++		    aEditButton.Enable();
++    }    
+     else
+         aEditButton.Disable();
+ 
+     // enable/disable new module/dialog buttons
+-    BasicEntryDescriptor aDesc( aBasicBox.GetEntryDescriptor( pCurEntry ) );
+     LibraryLocation eLocation( aDesc.GetLocation() );
+     BOOL bReadOnly = FALSE;
+-    if ( nDepth == 1 || nDepth == 2 )
++    if ( nDepth > 0 )
+     {
+-        ScriptDocument aDocument( aDesc.GetDocument() );
+-        ::rtl::OUString aOULibName( aDesc.GetLibName() );
+         Reference< script::XLibraryContainer2 > xModLibContainer( aDocument.getLibraryContainer( E_SCRIPTS ), UNO_QUERY );
+         Reference< script::XLibraryContainer2 > xDlgLibContainer( aDocument.getLibraryContainer( E_DIALOGS ), UNO_QUERY );
+         if ( ( xModLibContainer.is() && xModLibContainer->hasByName( aOULibName ) && xModLibContainer->isLibraryReadOnly( aOULibName ) ) ||
+@@ -660,8 +671,13 @@ void ObjectPage::CheckButtons()
+     }
+ 
+     // enable/disable delete button
+-    if ( nDepth == 2 && !bReadOnly && eLocation != LIBRARY_LOCATION_SHARE )
+-        aDelButton.Enable();
++    if ( nDepth >= 2 && !bReadOnly && eLocation != LIBRARY_LOCATION_SHARE )
++    {
++        if( bVBAEnabled && ( nMode & BROWSEMODE_MODULES ) && ( ( nDepth == 2 ) || aLibSubName.Equals( String( IDEResId( RID_STR_DOCUMENT_OBJECTS ) ) ) ) )
++            aDelButton.Disable();
++        else
++            aDelButton.Enable();
++    }
+     else
+         aDelButton.Disable();
+ }
+@@ -688,13 +704,20 @@ IMPL_LINK( ObjectPage, ButtonHdl, Button
+         SfxDispatcher* pDispatcher = pViewFrame ? pViewFrame->GetDispatcher() : NULL;
+         SvLBoxEntry* pCurEntry = aBasicBox.GetCurEntry();
+         DBG_ASSERT( pCurEntry, "Entry?!" );
+-        if ( aBasicBox.GetModel()->GetDepth( pCurEntry ) == 2 )
++		if ( aBasicBox.GetModel()->GetDepth( pCurEntry ) >= 2 )
+         {
+             BasicEntryDescriptor aDesc( aBasicBox.GetEntryDescriptor( pCurEntry ) );
+             if ( pDispatcher )
+             {
++                String aModName( aDesc.GetName() );
++                // extract the module name from the string like "Sheet1 (Example1)"
++                if( aDesc.GetLibSubName().Equals( String( IDEResId( RID_STR_DOCUMENT_OBJECTS ) ) ) )
++                {
++                    sal_uInt16 nIndex = 0;
++                    aModName = aModName.GetToken( 0, ' ', nIndex );
++                }
+                 SbxItem aSbxItem( SID_BASICIDE_ARG_SBX, aDesc.GetDocument(), aDesc.GetLibName(), 
+-                                  aDesc.GetName(), aBasicBox.ConvertType( aDesc.GetType() ) );
++                                  aModName, aBasicBox.ConvertType( aDesc.GetType() ) );
+                 pDispatcher->Execute( SID_BASICIDE_SHOWSBX, SFX_CALLMODE_SYNCHRON, &aSbxItem, 0L );
+             }
+         }
+@@ -976,14 +999,14 @@ SbModule* createModImpl( Window* pWin, c
+         try
+         {
+             ::rtl::OUString sModuleCode;
++            // the module has existed
++            if( rDocument.hasModule( aLibName, aModName ) )
++                return NULL;
+             rDocument.createModule( aLibName, aModName, bMain, sModuleCode );
+             BasicManager* pBasMgr = rDocument.getBasicManager();
+-            if ( pBasMgr )
+-            {
+-                StarBASIC* pBasic = pBasMgr->GetLib( aLibName );
+-                if ( pBasic )
+-                    pModule = pBasic->FindModule( aModName );
+-            }
++            StarBASIC* pBasic = pBasMgr? pBasMgr->GetLib( aLibName ) : 0;
++            if ( pBasic )
++                pModule = pBasic->FindModule( aModName );
+             SbxItem aSbxItem( SID_BASICIDE_ARG_SBX, rDocument, aLibName, aModName, BASICIDE_TYPE_MODULE );					
+             BasicIDEShell* pIDEShell = IDE_DLL()->GetShell();
+             SfxViewFrame* pViewFrame = pIDEShell ? pIDEShell->GetViewFrame() : NULL;
+@@ -1005,14 +1028,27 @@ SbModule* createModImpl( Window* pWin, c
+                 {
+                     if ( !rBasicBox.IsExpanded( pLibEntry ) )
+                         rBasicBox.Expand( pLibEntry );
+-                    SvLBoxEntry* pEntry = rBasicBox.FindEntry( pLibEntry, aModName, OBJ_TYPE_MODULE );
++                    SvLBoxEntry* pSubRootEntry = pLibEntry;
++                    if( pBasic && pBasic->isVBAEnabled() )
++                    {
++                        // add the new module in the "Modules" entry
++                        SvLBoxEntry* pLibSubEntry = rBasicBox.FindEntry( pLibEntry, String( IDEResId( RID_STR_NORMAL_MODULES ) ) , OBJ_TYPE_NORMAL_MODULES );
++                        if( pLibSubEntry )
++                        {
++                            if( !rBasicBox.IsExpanded( pLibSubEntry ) )
++                                rBasicBox.Expand( pLibSubEntry );
++                            pSubRootEntry = pLibSubEntry;    
++                        }
++                    }
++                    
++                    SvLBoxEntry* pEntry = rBasicBox.FindEntry( pSubRootEntry, aModName, OBJ_TYPE_MODULE );
+                     if ( !pEntry )
+                     {
+                         pEntry = rBasicBox.AddEntry(
+                             aModName,
+                             Image( IDEResId( RID_IMG_MODULE ) ),
+                             Image( IDEResId( RID_IMG_MODULE_HC ) ),
+-                            pLibEntry, false,
++                            pSubRootEntry, false,
+                             std::auto_ptr< BasicEntry >( new BasicEntry( OBJ_TYPE_MODULE ) ) );
+                         DBG_ASSERT( pEntry, "InsertEntry fehlgeschlagen!" );
+                     }
+--- basctl/source/basicide/scriptdocument.cxx.old	2009-10-07 15:07:22.000000000 +0200
++++ basctl/source/basicide/scriptdocument.cxx	2010-03-03 16:59:34.000000000 +0100
+@@ -56,6 +56,7 @@
+ #include <com/sun/star/frame/XModel2.hpp>
+ #include <com/sun/star/awt/XWindow2.hpp>
+ #include <com/sun/star/document/XEmbeddedScripts.hpp>
++#include <com/sun/star/script/ModuleInfo.hpp>
+ /** === end UNO includes === **/
+ 
+ #include <sfx2/objsh.hxx>
+@@ -142,6 +143,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;
+@@ -661,7 +663,7 @@ namespace basctl
+                 if ( !_rxExistingDialogModel.is() )
+                 {
+                     Reference< XInputStream > xInput( xISP->createInputStream(), UNO_QUERY_THROW );
+-                    ::xmlscript::importDialogModel( xInput, xDialogModel, aContext.getUNOContext() );
++    			    ::xmlscript::importDialogModel( xInput, xDialogModel, aContext.getUNOContext(), getDocument() );
+                 }
+ 
+                 // set new name as property
+@@ -669,11 +671,20 @@ namespace basctl
+                 xDlgPSet->setPropertyValue( DLGED_PROP_NAME, makeAny( _rNewName ) );
+ 
+                 // export dialog model
+-                xISP = ::xmlscript::exportDialogModel( xDialogModel, aContext.getUNOContext() );
++			    xISP = ::xmlscript::exportDialogModel( xDialogModel, aContext.getUNOContext(), getDocument() );
+                 aElement <<= xISP;
+             }
+ 
+             // 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;
+         }
+@@ -738,8 +749,16 @@ namespace basctl
+             Reference< XNameContainer > xLib( getOrCreateLibrary( E_SCRIPTS, _rLibName ), UNO_QUERY_THROW );
+             if ( !xLib->hasByName( _rModName ) )
+                 return false;
+-
+-            xLib->replaceByName( _rModName, makeAny( _rModuleCode ) );
++            ModuleInfo mInfo;
++            Any aMod;
++            if ( xLib->getByName( _rModName ) >>= mInfo )
++            {
++                mInfo.ModuleSource = _rModuleCode;
++                aMod <<= mInfo;
++            }
++            else
++                aMod <<= _rModuleCode;
++            xLib->replaceByName( _rModName, aMod );
+             return true;
+         }
+         catch( const Exception& )
+@@ -772,7 +791,7 @@ namespace basctl
+             xDlgPSet->setPropertyValue( DLGED_PROP_NAME, makeAny( _rDialogName ) );
+ 
+             // export dialog model
+-            _out_rDialogProvider = ::xmlscript::exportDialogModel( xDialogModel, aContext.getUNOContext() );
++            _out_rDialogProvider = ::xmlscript::exportDialogModel( xDialogModel, aContext.getUNOContext(), getDocument() );
+ 
+             // insert dialog into library
+             xLib->insertByName( _rDialogName, makeAny( _out_rDialogProvider ) );
+@@ -1392,7 +1411,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;
+     }
+ 
+--- basctl/source/dlged/dlged.cxx.old	2009-10-07 15:07:22.000000000 +0200
++++ basctl/source/dlged/dlged.cxx	2010-03-03 16:59:34.000000000 +0100
+@@ -208,7 +208,7 @@ BOOL DlgEditor::RemarkDialog()
+ 
+ //----------------------------------------------------------------------------
+ 
+-DlgEditor::DlgEditor()
++DlgEditor::DlgEditor( const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XModel >& xModel )
+     :pHScroll(NULL)
+     ,pVScroll(NULL)
+     ,pDlgEdModel(NULL)
+@@ -230,6 +230,7 @@ DlgEditor::DlgEditor()
+     ,bCreateOK(TRUE)
+     ,bDialogModelChanged(FALSE)
+     ,mnPaintGuard(0)
++	,m_xDocument( xModel )
+ {
+     pDlgEdModel = new DlgEdModel();
+     pDlgEdModel->GetItemPool().FreezeIdRanges();
+@@ -838,7 +839,7 @@ void DlgEditor::Copy()
+     Reference< beans::XPropertySet > xProps( ::comphelper::getProcessServiceFactory(), UNO_QUERY );
+     OSL_ASSERT( xProps.is() );
+     OSL_VERIFY( xProps->getPropertyValue( OUString(RTL_CONSTASCII_USTRINGPARAM("DefaultContext")) ) >>= xContext );
+-    Reference< XInputStreamProvider > xISP = ::xmlscript::exportDialogModel( xClipDialogModel, xContext );
++	Reference< XInputStreamProvider > xISP = ::xmlscript::exportDialogModel( xClipDialogModel, xContext, m_xDocument );
+     Reference< XInputStream > xStream( xISP->createInputStream() );
+     Sequence< sal_Int8 > DialogModelBytes;
+     implCopyStreamToByteSequence( xStream, DialogModelBytes );
+@@ -871,7 +872,7 @@ void DlgEditor::Copy()
+             uno::Reference< resource::XStringResourceManager >
+                 xStringResourceManager( xStringResourcePersistence, uno::UNO_QUERY );
+             LocalizationMgr::resetResourceForDialog( xClipDialogModel, xStringResourceManager );
+-            Reference< XInputStreamProvider > xISP2 = ::xmlscript::exportDialogModel( xClipDialogModel, xContext );
++			Reference< XInputStreamProvider > xISP2 = ::xmlscript::exportDialogModel( xClipDialogModel, xContext, m_xDocument );
+             Reference< XInputStream > xStream2( xISP2->createInputStream() );
+             Sequence< sal_Int8 > NoResourceDialogModelBytes;
+             implCopyStreamToByteSequence( xStream2, NoResourceDialogModelBytes );
+@@ -1017,7 +1018,7 @@ void DlgEditor::Paste()
+                     Reference< beans::XPropertySet > xProps( xMSF, UNO_QUERY );
+                     OSL_ASSERT( xProps.is() );
+                     OSL_VERIFY( xProps->getPropertyValue( OUString(RTL_CONSTASCII_USTRINGPARAM("DefaultContext")) ) >>= xContext );
+-                    ::xmlscript::importDialogModel( ::xmlscript::createInputStream( *((::rtl::ByteSequence*)(&DialogModelBytes)) ) , xClipDialogModel, xContext );
++					::xmlscript::importDialogModel( ::xmlscript::createInputStream( *((::rtl::ByteSequence*)(&DialogModelBytes)) ) , xClipDialogModel, xContext, m_xDocument );
+                 }
+ 
+                 // get control models from clipboard dialog model
+--- basctl/source/dlged/dlgedobj.cxx.old	2009-10-08 16:18:20.000000000 +0200
++++ basctl/source/dlged/dlgedobj.cxx	2010-03-03 16:59:34.000000000 +0100
+@@ -77,6 +77,22 @@ TYPEINIT1(DlgEdObj, SdrUnoObj);
+ DBG_NAME(DlgEdObj);
+ 
+ //----------------------------------------------------------------------------
++MapMode lcl_getMapModeForForm( DlgEdForm* pForm )
++{
++	MapMode aMode( MAP_APPFONT ); //Default
++	try
++	{
++		uno::Reference< beans::XPropertySet > xProps( pForm ? pForm->GetUnoControlModel() : NULL, uno::UNO_QUERY_THROW );
++		sal_Bool bVBAForm = sal_False;
++		xProps->getPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("VBAForm") ) ) >>= bVBAForm;	
++		if ( bVBAForm )
++			aMode = MapMode( MAP_100TH_MM );
++	}
++	catch ( Exception& )
++	{
++	}
++	return aMode;
++}
+ 
+ DlgEdObj::DlgEdObj()
+           :SdrUnoObj(String(), sal_False)
+@@ -197,8 +213,9 @@ bool DlgEdObj::TransformSdrToControlCoor
+     }
+     
+     // convert pixel to logic units
+-    aPos = pDevice->PixelToLogic( aPos, MapMode( MAP_APPFONT ) );
+-    aSize = pDevice->PixelToLogic( aSize, MapMode( MAP_APPFONT ) );
++    MapMode aConvMode = lcl_getMapModeForForm( pForm );
++    aPos = pDevice->PixelToLogic( aPos, aConvMode );
++    aSize = pDevice->PixelToLogic( aSize, aConvMode );
+ 
+     // set out parameters
+     nXOut = aPos.Width();
+@@ -245,10 +262,10 @@ bool DlgEdObj::TransformSdrToFormCoordin
+         aSize.Width() -= aDeviceInfo.LeftInset + aDeviceInfo.RightInset;
+         aSize.Height() -= aDeviceInfo.TopInset + aDeviceInfo.BottomInset;
+     }
+-
++    MapMode aConvMode = lcl_getMapModeForForm( pForm );
+     // convert pixel to logic units
+-    aPos = pDevice->PixelToLogic( aPos, MapMode( MAP_APPFONT ) );
+-    aSize = pDevice->PixelToLogic( aSize, MapMode( MAP_APPFONT ) );
++    aPos = pDevice->PixelToLogic( aPos, aConvMode );
++    aSize = pDevice->PixelToLogic( aSize, aConvMode );
+ 
+     // set out parameters
+     nXOut = aPos.Width();
+@@ -290,9 +307,10 @@ bool DlgEdObj::TransformControlToSdrCoor
+     DBG_ASSERT( pDevice, "DlgEdObj::TransformControlToSdrCoordinates: missing default device!" );
+     if ( !pDevice )
+         return false;
+-    aPos = pDevice->LogicToPixel( aPos, MapMode( MAP_APPFONT ) );
+-    aSize = pDevice->LogicToPixel( aSize, MapMode( MAP_APPFONT ) );
+-    aFormPos = pDevice->LogicToPixel( aFormPos, MapMode( MAP_APPFONT ) );
++    MapMode aConvMode = lcl_getMapModeForForm( pForm );
++    aPos = pDevice->LogicToPixel( aPos, aConvMode );
++    aSize = pDevice->LogicToPixel( aSize, aConvMode );
++    aFormPos = pDevice->LogicToPixel( aFormPos, aConvMode );
+ 
+     // add form position
+     aPos.Width() += aFormPos.Width();
+@@ -336,14 +354,16 @@ bool DlgEdObj::TransformFormToSdrCoordin
+     DBG_ASSERT( pDevice, "DlgEdObj::TransformFormToSdrCoordinates: missing default device!" );
+     if ( !pDevice )
+         return false;
+-    aPos = pDevice->LogicToPixel( aPos, MapMode( MAP_APPFONT ) );
+-    aSize = pDevice->LogicToPixel( aSize, MapMode( MAP_APPFONT ) );
+ 
+     // take window borders into account
+     DlgEdForm* pForm = NULL;
+     if ( !lcl_getDlgEdForm( this, pForm ) )
+         return false;
+ 
++    MapMode aConvMode = lcl_getMapModeForForm( pForm );
++    aPos = pDevice->LogicToPixel( aPos, aConvMode );
++    aSize = pDevice->LogicToPixel( aSize, aConvMode );
++
+     // take window borders into account
+     Reference< beans::XPropertySet > xPSetForm( pForm->GetUnoControlModel(), UNO_QUERY );
+     DBG_ASSERT( xPSetForm.is(), "DlgEdObj::TransformFormToSdrCoordinates: no form property set!" );
+--- basctl/source/inc/basidesh.hxx.old	2009-10-08 16:18:20.000000000 +0200
++++ basctl/source/inc/basidesh.hxx	2010-03-03 16:59:34.000000000 +0100
+@@ -49,6 +49,7 @@
+ #include <com/sun/star/io/XInputStreamProvider.hpp>
+ #endif
+ 
++#include <com/sun/star/container/XContainerListener.hpp>
+ 
+ //----------------------------------------------------------------------------
+ 
+@@ -108,6 +109,8 @@ friend bool BasicIDE::RemoveDialog( cons
+     BOOL                m_bAppBasicModified;
+     ::basctl::DocumentEventNotifier
+                         m_aNotifier;
++friend class ContainerListenerImpl;
++    ::com::sun::star::uno::Reference< ::com::sun::star::container::XContainerListener > m_xLibListener;
+ 
+ #if _SOLAR__PRIVATE
+     void				Init();
+--- basctl/source/inc/dlged.hxx.old	2009-10-07 15:07:22.000000000 +0200
++++ basctl/source/inc/dlged.hxx	2010-03-03 16:59:34.000000000 +0100
+@@ -35,6 +35,7 @@
+ #include <com/sun/star/awt/XControlContainer.hpp>
+ #include <com/sun/star/datatransfer/DataFlavor.hpp>
+ #include <com/sun/star/util/XNumberFormatsSupplier.hpp>
++#include <com/sun/star/frame/XModel.hpp>
+ #include <tools/link.hxx>
+ #include <tools/gen.hxx> 
+ #include <vcl/timer.hxx>
+@@ -129,9 +130,11 @@ protected:
+     BOOL				bDialogModelChanged;
+     Timer               aMarkTimer;
+     long				mnPaintGuard;
++	::com::sun::star::uno::Reference< ::com::sun::star::frame::XModel > m_xDocument;
+ 
++	DlgEditor(); // not implemented
+ public:
+-    DlgEditor();
++	DlgEditor( const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XModel >& xModel );
+     ~DlgEditor();
+ 
+     void			SetWindow( Window* pWindow );
+--- basic/inc/basic/basmgr.hxx.old	2010-03-03 16:59:33.000000000 +0100
++++ basic/inc/basic/basmgr.hxx	2010-03-03 16:59:34.000000000 +0100
+@@ -239,7 +239,7 @@ public:
+             takes the names of modules whose size exceeds the legacy limit
+     */
+     bool            LegacyPsswdBinaryLimitExceeded( ::com::sun::star::uno::Sequence< rtl::OUString >& _out_rModuleNames );
+-
++    bool HasExeCode( const String& );
+ private:
+     BOOL		    IsReference( USHORT nLib );
+ 
+--- basic/inc/basic/sberrors.hxx.old	2009-10-08 16:17:52.000000000 +0200
++++ basic/inc/basic/sberrors.hxx	2010-03-03 16:59:34.000000000 +0100
+@@ -290,6 +290,8 @@ typedef ULONG SbError;
+ #define	ERRCODE_BASIC_LOOP_NOT_INIT			((LAST_SBX_ERROR_ID+109UL) | ERRCODE_AREA_SBX | \
+                                             ERRCODE_CLASS_COMPILER)				// For loop not initialized
+ 
++#define	ERRCODE_BASIC_COMPAT				((LAST_SBX_ERROR_ID+103UL)| ERRCODE_AREA_SBX | ERRCODE_CLASS_RUNTIME)
++
+ // Map old codes to new codes
+ #define	SbERR_SYNTAX						ERRCODE_BASIC_SYNTAX
+ #define	SbERR_NO_GOSUB						ERRCODE_BASIC_NO_GOSUB
+@@ -413,6 +415,7 @@ typedef ULONG SbError;
+ #define	SbERR_PROG_TOO_LARGE                ERRCODE_BASIC_PROG_TOO_LARGE
+ #define	SbERR_NO_STRINGS_ARRAYS             ERRCODE_BASIC_NO_STRINGS_ARRAYS
+ #define	SbERR_BASIC_EXCEPTION               ERRCODE_BASIC_EXCEPTION
++#define	SbERR_BASIC_COMPAT                  ERRCODE_BASIC_COMPAT
+ #define	SbERR_BASIC_ARRAY_FIX				ERRCODE_BASIC_ARRAY_FIX
+ #define	SbERR_BASIC_STRING_OVERFLOW			ERRCODE_BASIC_STRING_OVERFLOW
+ #define	SbERR_BASIC_EXPR_TOO_COMPLEX		ERRCODE_BASIC_EXPR_TOO_COMPLEX
+--- basic/inc/basic/sbmeth.hxx.old	2009-10-07 15:06:56.000000000 +0200
++++ basic/inc/basic/sbmeth.hxx	2010-03-03 16:59:34.000000000 +0100
+@@ -49,6 +49,7 @@ class SbMethod : public SbxMethod
+     friend class SbIfaceMapperMethod;
+ 
+     SbMethodImpl* mpSbMethodImpl;			// Impl data
++	SbxVariable* mCaller;                   // caller
+     SbModule* pMod;
+     USHORT    nDebugFlags;
+     USHORT	  nLine1, nLine2;
+@@ -75,7 +76,7 @@ public:
+     void 	  GetLineRange( USHORT&, USHORT& );
+ 
+     // Schnittstelle zum Ausfuehren einer Methode aus den Applikationen
+-    virtual ErrCode Call( SbxValue* pRet = NULL );
++	virtual ErrCode Call( SbxValue* pRet = NULL,  SbxVariable* pCaller = NULL );
+     virtual void Broadcast( ULONG nHintId );
+ };
+ 
+--- basic/inc/basic/sbmod.hxx.old	2009-10-08 16:17:52.000000000 +0200
++++ basic/inc/basic/sbmod.hxx	2010-03-03 16:59:34.000000000 +0100
+@@ -37,7 +37,8 @@
+ #ifndef _RTL_USTRING_HXX
+ #include <rtl/ustring.hxx>
+ #endif
+-
++#include <com/sun/star/script/ModuleType.hpp>
++#include <vector>
+ class SbMethod;
+ class SbProperty;
+ class SbiRuntime;
+@@ -59,6 +60,9 @@ class SbModule : public SbxObject
+     friend class	SbClassModuleObject;
+ 
+     SbModuleImpl*	mpSbModuleImpl;		// Impl data
++	std::vector< String > mModuleVariableNames;
++	SbModule();
++	SbModule(const SbModule&);
+ 
+ protected:
+     ::rtl::OUString     aOUSource;
+@@ -66,6 +70,10 @@ protected:
+     SbiImage*           pImage;        // the Image
+     SbiBreakpoints*     pBreaks;       // Breakpoints
+     SbClassData*        pClassData;
++	bool mbVBACompat;
++	INT32 mnType; 
++	SbxObjectRef pDocObject; // an impl object ( used by Document Modules )
++	bool 	bIsProxyModule;
+ 
+     void			StartDefinitions();
+     SbMethod*		GetMethod( const String&, SbxDataType );
+@@ -90,7 +98,7 @@ protected:
+ public:
+     SBX_DECL_PERSIST_NODATA(SBXCR_SBX,SBXID_BASICMOD,2);
+     TYPEINFO();
+-                    SbModule( const String& );
++					SbModule( const String&, bool bCompat = false );
+     virtual void	SetParent( SbxObject* );
+     virtual void 	Clear();
+ 
+@@ -126,6 +134,14 @@ public:
+     BOOL LoadBinaryData( SvStream& );
+     BOOL ExceedsLegacyModuleSize();
+     void fixUpMethodStart( bool bCvtToLegacy, SbiImage* pImg = NULL ) const;
++        bool HasExeCode();
++        bool IsVBACompat();
++        void SetVBACompat( bool bCompat );
++        INT32 GetModuleType() { return mnType; }
++        void SetModuleType( INT32 nType ) { mnType = nType; }
++	bool GetIsProxyModule() { return bIsProxyModule; }
++        void AddVarName( const String& aName );
++        void RemoveVars();
+ };
+ 
+ #ifndef __SB_SBMODULEREF_HXX
+--- basic/inc/basic/sbobjmod.hxx.old	2010-03-03 16:59:34.000000000 +0100
++++ basic/inc/basic/sbobjmod.hxx	2010-03-03 16:59:34.000000000 +0100
+@@ -0,0 +1,96 @@
++/*************************************************************************
++ *
++ *  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>
++#include <com/sun/star/frame/XModel.hpp>
++
++namespace css = ::com::sun::star;
++
++// Basic-Module for excel object.
++
++class SbObjModule : public SbModule
++{
++    SbObjModule( const SbObjModule& );
++    SbObjModule();
++public:
++    TYPEINFO();
++    SbObjModule( const com::sun::star::script::ModuleInfo& mInfo, bool bIsVbaCompatible );
++    virtual SbxVariable* Find( const XubString& rName, SbxClassType t );
++    SbxVariable* GetObject();
++    void SetUnoObject( const com::sun::star::uno::Any& aObj )throw ( com::sun::star::uno::RuntimeException ) ;
++};
++
++class SbUserFormModule : public SbObjModule
++{
++    css::uno::Reference<css::lang::XEventListener> m_DialogListener;
++    css::uno::Reference<css::awt::XDialog> m_xDialog;
++    css::uno::Reference<css::frame::XModel> m_xModel;
++    String sFormName;
++    bool mbInit;
++    SbUserFormModule( const SbUserFormModule& );
++    SbUserFormModule();
++
++protected:
++    virtual void InitObject();
++public:
++    TYPEINFO();
++    SbUserFormModule( const com::sun::star::script::ModuleInfo& mInfo, bool bIsVBACompat );
++    virtual SbxVariable* Find( const XubString& rName, SbxClassType t );
++    void ResetApiObj();
++    void Unload();
++    void load();
++    void triggerMethod( const String& );
++    void triggerMethod( const String&, css::uno::Sequence< css::uno::Any >&  );
++    void triggerActivateEvent();
++    void triggerDeActivateEvent();
++    void triggerInitializeEvent();
++    void triggerTerminateEvent();
++};
++
++#ifndef __SB_SBOBJMODULEREF_HXX
++#define __SB_SBOBJMODULEREF_HXX
++
++SV_DECL_IMPL_REF(SbObjModule);
++
++#endif
++#endif
++
+--- basic/inc/basic/sbstar.hxx.old	2010-03-03 16:59:33.000000000 +0100
++++ basic/inc/basic/sbstar.hxx	2010-03-03 16:59:34.000000000 +0100
+@@ -40,6 +40,7 @@
+ 
+ #include <basic/sbdef.hxx>
+ #include <basic/sberrors.hxx>
++#include <com/sun/star/script/ModuleInfo.hpp>
+ 
+ class SbModule;                     // completed module
+ class SbiInstance;                  // runtime instance
+@@ -72,6 +73,7 @@ class StarBASIC : public SbxObject
+     BOOL			bNoRtl;                 // if TRUE: do not search RTL
+     BOOL			bBreak;                 // if TRUE: Break, otherwise Step
+     BOOL			bDocBasic;
++	BOOL			bVBAEnabled;
+     BasicLibInfo*	pLibInfo;			// Info block for basic manager
+     SbLanguageMode	eLanguageMode;		// LanguageMode of the basic object
+ 	BOOL			bQuit;
+@@ -119,7 +121,8 @@ public:
+ 
+     // Compiler-Interface
+     SbModule*   	MakeModule( const String& rName, const String& rSrc );
+-    SbModule*   	MakeModule32( const String& rName, const ::rtl::OUString& rSrc );
++    SbModule*       MakeModule32( const String& rName, const ::rtl::OUString& rSrc );
++    SbModule*       MakeModule32( const com::sun::star::script::ModuleInfo& mInfo );
+     BOOL			Compile( SbModule* );
+     BOOL 			Disassemble( SbModule*, String& rText );
+     static void 	Stop();
+@@ -192,6 +195,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 is not displayed on basic errors
+     static void StaticSuppressSfxResource( BOOL bSuppress );
+--- basic/inc/basic/sbuno.hxx.old	2009-10-08 16:17:52.000000000 +0200
++++ basic/inc/basic/sbuno.hxx	2010-03-03 16:59:34.000000000 +0100
+@@ -41,6 +41,7 @@ SbxObjectRef GetSbUnoObject( const Strin
+ 
+ // Force creation of all properties for debugging
+ void createAllObjectProperties( SbxObject* pObj );
++void SetSbUnoObjectDfltPropName( SbxObject* pObj );
+ 
+ ::com::sun::star::uno::Any sbxToUnoValue( SbxVariable* pVar );
+ 
+--- basic/prj/build.lst.old	2009-10-08 16:17:52.000000000 +0200
++++ basic/prj/build.lst	2010-03-03 16:59:34.000000000 +0100
+@@ -1,4 +1,4 @@
+-sb	basic	:    l10n offuh svtools xmlscript framework NULL
++sb	basic	:    l10n offuh svtools xmlscript framework oovbaapi NULL
+ sb	basic									usr1	-	all	sb_mkout NULL
+ sb	basic\inc								nmake	-	all	sb_inc NULL
+ sb	basic\source\app						nmake	-	all	sb_app sb_class sb_inc NULL
+--- basic/prj/d.lst.old	2009-10-07 15:06:56.000000000 +0200
++++ basic/prj/d.lst	2010-03-03 16:59:34.000000000 +0100
+@@ -7,6 +7,8 @@ mkdir: %COMMON_DEST%\res%_EXT%
+ ..\%__SRC%\lib\*.dylib %_DEST%\lib%_EXT%\*.dylib
+ ..\%__SRC%\lib\*.a %_DEST%\lib%_EXT%\*.a
+ ..\%__SRC%\slb\sb.lib %_DEST%\lib%_EXT%\xsb.lib
++..\%__SRC%\lib\vbahelp*.* %_DEST%\lib%_EXT%\vba*.*
++
+ ..\%__SRC%\srs\classes.srs %_DEST%\res%_EXT%\basic.srs
+ ..\%COMMON_OUTDIR%\srs\classes_srs.hid %COMMON_DEST%\res%_EXT%\basic_srs.hid
+ ..\%__SRC%\bin\sb?????.dll %_DEST%\bin%_EXT%\sb?????.dll
+@@ -56,4 +58,8 @@ mkdir: %_DEST%\inc%_EXT%\basic
+ ..\inc\basic\sbxmstrm.hxx %_DEST%\inc%_EXT%\basic\sbxmstrm.hxx
+ 
+ ..\inc\basic\basicmanagerrepository.hxx %_DEST%\inc%_EXT%\basic\basicmanagerrepository.hxx
++..\inc\basic\vbacollectionimpl.hxx %_DEST%\inc%_EXT%\basic\vbacollectionimpl.hxx
++..\inc\basic\vbahelper.hxx %_DEST%\inc%_EXT%\basic\vbahelper.hxx
++..\inc\basic\helperdecl.hxx %_DEST%\inc%_EXT%\basic\helperdecl.hxx
++..\inc\basic\vbahelperinterface.hxx %_DEST%\inc%_EXT%\basic\vbahelperinterface.hxx
+ ..\inc\modsizeexceeded.hxx %_DEST%\inc%_EXT%\basic\modsizeexceeded.hxx
+--- basic/source/basmgr/basmgr.cxx.old	2010-03-03 16:59:33.000000000 +0100
++++ basic/source/basmgr/basmgr.cxx	2010-03-03 16:59:34.000000000 +0100
+@@ -44,6 +44,7 @@
+ #include <tools/debug.hxx>
+ #include <tools/diagnose_ex.h>
+ #include <basic/sbmod.hxx>
++#include <basic/sbobjmod.hxx>
+ 
+ #include <basic/sbuno.hxx>
+ #include <basic/basmgr.hxx>
+@@ -68,6 +69,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>
+ 
+@@ -244,9 +247,18 @@ void BasMgrContainerListenerImpl::addLib
+         {
+             ::rtl::OUString aModuleName = pNames[ j ];
+             Any aElement = xLibNameAccess->getByName( aModuleName );
+-            ::rtl::OUString aMod;
+-            aElement >>= aMod;
+-            pLib->MakeModule32( aModuleName, aMod );
++            ModuleInfo mInfo;
++            if ( aElement >>= mInfo )
++            {
++                OSL_TRACE("#addLibraryModulesImpl - aMod");
++                pLib->MakeModule32( mInfo );
++            }
++            else
++            {
++			    ::rtl::OUString aMod;
++			    aElement >>= aMod;
++			    pLib->MakeModule32( aModuleName, aMod );
++            }
+         }
+     }
+ 
+@@ -283,8 +295,6 @@ void SAL_CALL BasMgrContainerListenerImp
+     }
+     else
+     {
+-        ::rtl::OUString aMod;
+-        Event.Element >>= aMod;
+ 
+         StarBASIC* pLib = mpMgr->GetLib( maLibName );
+         DBG_ASSERT( pLib, "BasMgrContainerListenerImpl::elementInserted: Unknown lib!");
+@@ -293,7 +303,17 @@ void SAL_CALL BasMgrContainerListenerImp
+             SbModule* pMod = pLib->FindModule( aName );
+             if( !pMod )
+             {
+-                pLib->MakeModule32( aName, aMod );
++                ModuleInfo mInfo;
++                if( Event.Element >>= mInfo )
++                {
++                    pLib->MakeModule32( mInfo );
++                }
++                else
++                {
++        		    ::rtl::OUString aMod;
++        		    Event.Element >>= aMod;
++			        pLib->MakeModule32( aName, aMod );
++                }
+                 pLib->SetModified( FALSE );
+             }
+         }
+@@ -317,15 +337,35 @@ void SAL_CALL BasMgrContainerListenerImp
+     DBG_ASSERT( !bLibContainer, "library container fired elementReplaced()");
+ 
+     StarBASIC* pLib = mpMgr->GetLib( maLibName );
++    
+     if( pLib )
+     {
+-        SbModule* pMod = pLib->FindModule( aName );
++	    SbModule* pMod = pLib->FindModule( aName );
+         ::rtl::OUString aMod;
+-        Event.Element >>= aMod;
++        ModuleInfo mInfo;
++        if( Event.Element >>= mInfo )
++			aMod = mInfo.ModuleSource;
++        else 
++            Event.Element >>= aMod;
+         if( pMod )
++		{
+             pMod->SetSource32( aMod );
++			if ( mInfo.ModuleType == ModuleType::Document )
++			{
++				SbObjModule* pObjModule = dynamic_cast< SbObjModule* >( pMod );
++				if ( pObjModule )	
++					pObjModule->SetUnoObject( makeAny( mInfo.ModuleObject ) );
++			}
++		}
+         else
+-            pLib->MakeModule32( aName, aMod );
++			// Probably we should have an assert for
++			// unknow module type, e.g. either we are using
++			// the ModuleInfo structure ( vba ) for *all* modules
++			// or not ( normal )
++			if ( mInfo.ModuleType == ModuleType::Unknown )
++				pLib->MakeModule32( aName, aMod );
++			else
++				pLib->MakeModule32( mInfo );
+ 
+         pLib->SetModified( FALSE );
+     }
+@@ -1122,6 +1162,25 @@ void BasicManager::LegacyDeleteBasicMana
+     _rpManager = NULL;
+ }
+ 
++
++bool BasicManager::HasExeCode( const String& sLib )
++{
++	StarBASIC* pLib = GetLib(sLib);	
++	if ( pLib )
++	{
++		SbxArray* pMods = pLib->GetModules();
++		USHORT nMods = pMods ? pMods->Count() : 0;
++		for( USHORT i = 0; i < nMods; i++ )
++		{
++			SbModule* p = (SbModule*) pMods->Get( i );
++			if ( p )
++				if ( p->HasExeCode() )
++					return true;
++		}
++	}
++	return false;
++}
++
+ void BasicManager::Init()
+ {
+     DBG_CHKTHIS( BasicManager, 0 );
+--- basic/source/classes/errobject.cxx.old	2010-03-03 16:59:34.000000000 +0100
++++ basic/source/classes/errobject.cxx	2010-03-03 16:59:34.000000000 +0100
+@@ -0,0 +1,181 @@
++// MARKER(update_precomp.py): autogen include statement, do not remove
++#include "precompiled_basic.hxx"
++#include "errobject.hxx"
++
++#include <cppuhelper/implbase2.hxx>
++#include <com/sun/star/script/XDefaultProperty.hpp>
++#include "sbintern.hxx"
++#include "runtime.hxx"
++
++using namespace ::com::sun::star;
++using namespace ::ooo;
++
++typedef ::cppu::WeakImplHelper2< vba::XErrObject, script::XDefaultProperty > ErrObjectImpl_BASE;
++
++class ErrObject : public ErrObjectImpl_BASE
++{	
++	rtl::OUString m_sHelpFile;
++	rtl::OUString m_sSource;
++        rtl::OUString m_sDescription; 
++	sal_Int32 m_nNumber;
++	sal_Int32 m_nHelpContext;
++	
++public:
++	ErrObject();
++	~ErrObject();
++	// Attributes
++	virtual ::sal_Int32 SAL_CALL getNumber() throw (uno::RuntimeException);
++	virtual void SAL_CALL setNumber( ::sal_Int32 _number ) throw (uno::RuntimeException);
++	virtual ::sal_Int32 SAL_CALL getHelpContext() throw (uno::RuntimeException);
++	virtual void SAL_CALL setHelpContext( ::sal_Int32 _helpcontext ) throw (uno::RuntimeException);
++	virtual ::rtl::OUString SAL_CALL getHelpFile() throw (uno::RuntimeException);
++	virtual void SAL_CALL setHelpFile( const ::rtl::OUString& _helpfile ) throw (uno::RuntimeException);
++	virtual ::rtl::OUString SAL_CALL getDescription() throw (uno::RuntimeException);
++	virtual void SAL_CALL setDescription( const ::rtl::OUString& _description ) throw (uno::RuntimeException);
++	virtual ::rtl::OUString SAL_CALL getSource() throw (uno::RuntimeException);
++	virtual void SAL_CALL setSource( const ::rtl::OUString& _source ) throw (uno::RuntimeException);
++	
++	// Methods
++	virtual void SAL_CALL Clear(  ) throw (uno::RuntimeException);
++	virtual void SAL_CALL Raise( const uno::Any& Number, const uno::Any& Source, const uno::Any& Description, const uno::Any& HelpFile, const uno::Any& HelpContext ) throw (uno::RuntimeException);
++	// XDefaultProperty	
++	virtual ::rtl::OUString SAL_CALL getDefaultPropertyName(  ) throw (uno::RuntimeException);
++};
++
++
++ErrObject::~ErrObject()
++{
++}
++
++ErrObject::ErrObject() : m_nNumber(0), m_nHelpContext(0)
++{
++}
++
++sal_Int32 SAL_CALL
++ErrObject::getNumber() throw (uno::RuntimeException)
++{
++	return m_nNumber;
++}
++
++void SAL_CALL 
++ErrObject::setNumber( ::sal_Int32 _number ) throw (uno::RuntimeException)
++{
++	m_nNumber = _number;
++
++	
++}
++
++::sal_Int32 SAL_CALL 
++ErrObject::getHelpContext() throw (uno::RuntimeException)
++{
++	return m_nHelpContext;
++}
++void SAL_CALL 
++ErrObject::setHelpContext( ::sal_Int32 _helpcontext ) throw (uno::RuntimeException)
++{
++	m_nHelpContext = _helpcontext;
++}
++
++::rtl::OUString SAL_CALL 
++ErrObject::getHelpFile() throw (uno::RuntimeException)
++{
++	return m_sHelpFile;
++}
++
++void SAL_CALL 
++ErrObject::setHelpFile( const ::rtl::OUString& _helpfile ) throw (uno::RuntimeException)
++{
++	m_sHelpFile = _helpfile;
++}
++
++::rtl::OUString SAL_CALL 
++ErrObject::getDescription() throw (uno::RuntimeException)
++{
++	return m_sDescription;
++}
++
++void SAL_CALL 
++ErrObject::setDescription( const ::rtl::OUString& _description ) throw (uno::RuntimeException)
++{
++	m_sDescription = _description;
++}
++
++::rtl::OUString SAL_CALL 
++ErrObject::getSource() throw (uno::RuntimeException)
++{
++	return m_sSource;
++}
++
++void SAL_CALL 
++ErrObject::setSource( const ::rtl::OUString& _source ) throw (uno::RuntimeException)
++{
++	m_sSource = _source;
++}
++	
++// Methods
++void SAL_CALL 
++ErrObject::Clear(  ) throw (uno::RuntimeException)
++{
++	m_sHelpFile = rtl::OUString();
++	m_sSource = m_sHelpFile;
++	m_sDescription = m_sSource;
++	m_nNumber = 0;	
++	m_nHelpContext = 0;	
++}
++
++void SAL_CALL 
++ErrObject::Raise( const uno::Any& Number, const uno::Any& Source, const uno::Any& Description, const uno::Any& HelpFile, const uno::Any& HelpContext ) throw (uno::RuntimeException)
++{
++	if ( !Number.hasValue() )
++		throw uno::RuntimeException( rtl::OUString::createFromAscii("Missing Required Paramater"), uno::Reference< uno::XInterface >() );
++	Description >>= m_sDescription;
++	Source >>= m_sSource;
++	HelpFile >>= m_sHelpFile;
++	HelpContext >>= m_nHelpContext;
++	Number >>= m_nNumber;
++	if ( m_nNumber )
++	{
++		SbError n = StarBASIC::GetSfxFromVBError( m_nNumber );
++		if ( !n )
++			n = m_nNumber; // force orig number, probably should have a specific table of vb ( localized ) errors
++		pINST->Error( n, m_sDescription );
++	}
++}
++
++// XDefaultProperty	
++::rtl::OUString SAL_CALL 
++ErrObject::getDefaultPropertyName(  ) throw (uno::RuntimeException)
++{
++	static rtl::OUString sDfltPropName( RTL_CONSTASCII_USTRINGPARAM("Number") );
++	return sDfltPropName;
++}
++
++// SbxErrObject
++SbxErrObject::SbxErrObject( const String& rName, const Any& rUnoObj ): SbUnoObject( rName, rUnoObj )
++{
++	OSL_TRACE("SbxErrObject::SbxErrObject ctor");
++	rUnoObj >>= m_xErr;
++	if ( m_xErr.is() )
++		SetDfltProperty( uno::Reference< script::XDefaultProperty >( m_xErr, uno::UNO_QUERY_THROW )->getDefaultPropertyName() ) ;
++}
++
++SbxErrObject::~SbxErrObject()
++{
++	OSL_TRACE("SbxErrObject::~SbxErrObject dtor");
++}
++
++uno::Reference< vba::XErrObject > 
++SbxErrObject::getUnoErrObject()
++{
++	SbxVariable* pVar = getErrObject();
++	SbxErrObject* pGlobErr = static_cast< SbxErrObject* >(  pVar );
++	return pGlobErr->m_xErr;	
++}
++
++SbxVariableRef
++SbxErrObject::getErrObject()
++{
++	static SbxVariableRef pGlobErr = new SbxErrObject( String(  RTL_CONSTASCII_USTRINGPARAM("Err")), uno::makeAny( uno::Reference< vba::XErrObject >( new ErrObject() ) ) );
++	return pGlobErr;
++}
++
+--- basic/source/classes/eventatt.cxx.old	2009-12-17 14:34:39.000000000 +0100
++++ basic/source/classes/eventatt.cxx	2010-03-03 16:59:34.000000000 +0100
+@@ -58,7 +58,10 @@
+ #include <com/sun/star/awt/XDialogProvider.hpp>
+ 
+ #include <com/sun/star/frame/XModel.hpp>
+-
++#include <com/sun/star/frame/XDesktop.hpp>
++#include <com/sun/star/container/XEnumerationAccess.hpp>
++#include <basic/basicmanagerrepository.hxx>
++#include <basic/basmgr.hxx>
+ //==================================================================================================
+ 
+ #include <xmlscript/xmldlg_imexp.hxx>
+@@ -453,6 +456,43 @@ Any implFindDialogLibForDialog( const An
+     return aRetDlgLibAny;
+ }
+ 
++Any implFindDialogLibForDialogBasic( const Any& aAnyISP, SbxObject* pBasic, StarBASIC*& pFoundBasic )
++{
++	Any aDlgLibAny;
++	// Find dialog library for dialog, direct access is not possible here
++    StarBASIC* pStartedBasic = (StarBASIC*)pBasic;
++	SbxObject* pParentBasic = pStartedBasic ? pStartedBasic->GetParent() : NULL;
++	SbxObject* pParentParentBasic = pParentBasic ? pParentBasic->GetParent() : NULL;
++
++	SbxObject* pSearchBasic1 = NULL;
++	SbxObject* pSearchBasic2 = NULL;
++	if( pParentParentBasic )
++	{
++		pSearchBasic1 = pParentBasic;
++		pSearchBasic2 = pParentParentBasic;
++	}
++	else
++	{
++		pSearchBasic1 = pStartedBasic;
++		pSearchBasic2 = pParentBasic;
++	}
++	if( pSearchBasic1 )
++	{
++		aDlgLibAny = implFindDialogLibForDialog( aAnyISP, pSearchBasic1 );
++
++		if ( aDlgLibAny.hasValue() )
++			pFoundBasic = (StarBASIC*)pSearchBasic1;
++
++		else if( pSearchBasic2 )
++		{
++			aDlgLibAny = implFindDialogLibForDialog( aAnyISP, pSearchBasic2 );
++			if ( aDlgLibAny.hasValue() )
++				pFoundBasic = (StarBASIC*)pSearchBasic2;
++		}
++	}
++	return aDlgLibAny;
++}
++
+ static ::rtl::OUString aDecorationPropName =
+     ::rtl::OUString::createFromAscii( "Decoration" );
+ static ::rtl::OUString aTitlePropName =
+@@ -532,39 +572,51 @@ void RTL_Impl_CreateUnoDialog( StarBASIC
+         {}
+     }
+ 
+-    // Find dialog library for dialog, direct access is not possible here
+-    StarBASIC* pStartedBasic = pINST->GetBasic();
+-    SbxObject* pParentBasic = pStartedBasic ? pStartedBasic->GetParent() : NULL;
+-    SbxObject* pParentParentBasic = pParentBasic ? pParentBasic->GetParent() : NULL;
+-
+-    SbxObject* pSearchBasic1 = NULL;
+-    SbxObject* pSearchBasic2 = NULL;
+-    if( pParentParentBasic )
+-    {
+-        pSearchBasic1 = pParentBasic;
+-        pSearchBasic2 = pParentParentBasic;
+-    }
+-    else
+-    {
+-        pSearchBasic1 = pStartedBasic;
+-        pSearchBasic2 = pParentBasic;
+-    }
+-
+     Any aDlgLibAny;
+-    if( pSearchBasic1 )
+-    {
+-        aDlgLibAny = implFindDialogLibForDialog( aAnyISP, pSearchBasic1 );
+-        if( pSearchBasic2 && aDlgLibAny.getValueType().getTypeClass() == TypeClass_VOID )
+-            aDlgLibAny = implFindDialogLibForDialog( aAnyISP, pSearchBasic2 );
+-    }
+-
+-
++	bool bDocDialog = false;
++	StarBASIC* pFoundBasic = NULL;
+     OSL_TRACE("About to try get a hold of ThisComponent");
+-    Reference< frame::XModel > xModel = getModelFromBasic( pStartedBasic ) ;
+-    Reference< XScriptListener > xScriptListener = new BasicScriptListener_Impl( pStartedBasic, xModel );
++    Reference< frame::XModel > xModel = getModelFromBasic( pINST->GetBasic() ) ;
++		aDlgLibAny = implFindDialogLibForDialogBasic( aAnyISP, pINST->GetBasic(), pFoundBasic );
++		// If we found the dialog then it belongs to the Search basic
++		if ( !pFoundBasic )
++		{
++			Reference< frame::XDesktop > xDesktop( xMSF->createInstance
++		( ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.frame.Desktop" ) ) ),
++			UNO_QUERY );
++			Reference< container::XEnumeration > xModels;
++			if ( xDesktop.is() )
++			{
++				Reference< container::XEnumerationAccess > xComponents( xDesktop->getComponents(), UNO_QUERY );
++				if ( xComponents.is() )
++					xModels.set( xComponents->createEnumeration(), UNO_QUERY );
++				if ( xModels.is() )
++				{
++					while ( xModels->hasMoreElements() )
++					{
++						Reference< frame::XModel > xNextModel( xModels->nextElement(), UNO_QUERY );
++						if ( xNextModel.is() )
++						{
++							BasicManager* pMgr = basic::BasicManagerRepository::getDocumentBasicManager( xNextModel );	
++							if ( pMgr )
++								aDlgLibAny = implFindDialogLibForDialogBasic( aAnyISP, pMgr->GetLib(0), pFoundBasic );
++							if ( aDlgLibAny.hasValue() )
++							{
++								bDocDialog = true;
++								xModel = xNextModel;
++								break;
++							} 
++						}
++					}
++				}
++			}
++		}
++	if ( pFoundBasic )
++		bDocDialog = pFoundBasic->IsDocBasic();
++       Reference< XScriptListener > xScriptListener = new BasicScriptListener_Impl( pINST->GetBasic(), xModel );
+ 
+     Sequence< Any > aArgs( 4 );
+-    aArgs[ 0 ] <<= xModel;
++	aArgs[ 0 ] <<= bDocDialog ? xModel : uno::Reference< uno::XInterface >();
+     aArgs[ 1 ] <<= xInput;
+     aArgs[ 2 ] = aDlgLibAny;
+     aArgs[ 3 ] <<= xScriptListener;
+--- basic/source/classes/makefile.mk.old	2009-10-07 15:06:56.000000000 +0200
++++ basic/source/classes/makefile.mk	2010-03-03 16:59:34.000000000 +0100
+@@ -41,18 +41,28 @@ ENABLE_EXCEPTIONS=TRUE
+ 
+ .INCLUDE :  settings.mk
+ 
++ALLTAR .SEQUENTIAL : \
++        $(MISC)$/$(TARGET).don \
++        $(MISC)$/$(TARGET).slo
++
++$(MISC)$/$(TARGET).don : $(SOLARBINDIR)$/oovbaapi.rdb
++        +$(CPPUMAKER) -O$(OUT)$/inc -BUCR $(SOLARBINDIR)$/oovbaapi.rdb -X$(SOLARBINDIR)$/types.rdb && echo > $@
++        echo $@
++
++$(MISC)$/$(TARGET).slo : $(SLOTARGET)
++        echo $@
++
+ # --- Allgemein -----------------------------------------------------------
+ 
+-COMMON_SLOFILES=	\
++SLOFILES=	\
+     $(SLO)$/sb.obj       \
+     $(SLO)$/sbxmod.obj	\
+     $(SLO)$/image.obj	\
+     $(SLO)$/sbintern.obj	\
+     $(SLO)$/sbunoobj.obj	\
+     $(SLO)$/propacc.obj	\
+-    $(SLO)$/disas.obj
+-
+-SLOFILES=	$(COMMON_SLOFILES)	\
++	$(SLO)$/disas.obj \
++	$(SLO)$/errobject.obj \
+     $(SLO)$/eventatt.obj
+ 
+ OBJFILES=	\
+--- basic/source/classes/sb.cxx.old	2010-03-03 16:59:33.000000000 +0100
++++ basic/source/classes/sb.cxx	2010-03-03 16:59:34.000000000 +0100
+@@ -52,12 +52,17 @@
+ #include "disas.hxx"
+ #include "runtime.hxx"
+ #include <basic/sbuno.hxx>
++#include <basic/sbobjmod.hxx>
+ #include "stdobj.hxx"
+ #include "filefmt.hxx"
+ #include "sb.hrc"
+ #include <basrid.hxx>
+ #include <vos/mutex.hxx>
+ 
++#include <com/sun/star/script/ModuleType.hpp>
++#include <com/sun/star/script/ModuleInfo.hpp>
++using namespace ::com::sun::star::script;
++
+ // #pragma SW_SEGMENT_CLASS( SBASIC, SBASIC_CODE )
+ 
+ SV_IMPL_VARARR(SbTextPortions,SbTextPortion)
+@@ -218,6 +223,7 @@ const SFX_VB_ErrorItem __FAR_DATA SFX_VB
+     { 1004, SbERR_METHOD_FAILED },
+     { 1005, SbERR_SETPROP_FAILED },
+     { 1006, SbERR_GETPROP_FAILED },
++	{ 1007, SbERR_BASIC_COMPAT },
+     { 0xFFFF, 0xFFFFFFFFL }		// End mark
+ };
+ 
+@@ -263,6 +269,8 @@ SbxObject* SbiFactory::CreateObject( con
+     else
+     if( rClass.EqualsIgnoreCaseAscii( "Collection" ) )
+     {
++			// Only variables qualified by the Module Name e.g. Sheet1.foo
++			// should work for Documant && Class type Modules
+         String aCollectionName( RTL_CONSTASCII_USTRINGPARAM("Collection") );
+         return new BasicCollection( aCollectionName );
+     }
+@@ -488,6 +496,7 @@ SbClassModuleObject::SbClassModuleObject
+             }
+         }
+     }
++	SetModuleType( com::sun::star::script::ModuleType::Class );
+ }
+ 
+ SbClassModuleObject::~SbClassModuleObject()
+@@ -503,72 +512,7 @@ SbClassModuleObject::~SbClassModuleObjec
+ void SbClassModuleObject::SFX_NOTIFY( SfxBroadcaster& rBC, const TypeId& rBCType,
+                            const SfxHint& rHint, const TypeId& rHintType )
+ {
+-    bool bDone = false;
+-
+-    const SbxHint* pHint = PTR_CAST(SbxHint,&rHint);
+-    if( pHint )
+-    {
+-        SbxVariable* pVar = pHint->GetVar();
+-        SbProcedureProperty* pProcProperty = PTR_CAST( SbProcedureProperty, pVar );
+-        if( pProcProperty )
+-        {
+-            bDone = true;
+-
+-            if( pHint->GetId() == SBX_HINT_DATAWANTED )
+-            {

... etc. - the rest is truncated


More information about the ooo-build-commit mailing list