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



Author: pflin
Date: Thu Sep 25 09:44:37 2008
New Revision: 14077
URL: http://svn.gnome.org/viewvc/ooo-build?rev=14077&view=rev

Log:
2008-09-25  Fong Lin  <pflin novell com>
	* patches/vba/vba-basic-macrochoose-dialog.diff: display a friendly tree
    in basic macro choose dialog.( need to fix some issues for "new" button ).
	* patches/dev300/apply.



Added:
   trunk/patches/vba/vba-basic-macrochoose-dialog.diff
Modified:
   trunk/ChangeLog
   trunk/patches/dev300/apply

Modified: trunk/patches/dev300/apply
==============================================================================
--- trunk/patches/dev300/apply	(original)
+++ trunk/patches/dev300/apply	Thu Sep 25 09:44:37 2008
@@ -1641,6 +1641,8 @@
 basic-ide-objectmodule.diff, Fong
 # display a friendly name for objectmodule tab
 basic-ide-module-object-name-combile.diff, Fong
+# display a friendly basic macro tree in macrochoose dialog
+vba-basic-macrochoose-dialog.diff, Fong
 # fix bug accessing default member of userform control
 range-listBox-compare.diff, n#421939
 # fix bug comparing string that can't be converted to number

Added: trunk/patches/vba/vba-basic-macrochoose-dialog.diff
==============================================================================
--- (empty file)
+++ trunk/patches/vba/vba-basic-macrochoose-dialog.diff	Thu Sep 25 09:44:37 2008
@@ -0,0 +1,640 @@
+diff -urp basicide.bk/baside2.cxx basctl/source/basicide/baside2.cxx
+--- basicide.bk/baside2.cxx	2008-09-22 11:33:04.000000000 +0800
++++ basctl/source/basicide/baside2.cxx	2008-09-25 14:56:46.000000000 +0800
+@@ -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>
+@@ -1347,7 +1348,26 @@ BasicEntryDescriptor ModulWindow::Create
+     ScriptDocument aDocument( GetDocument() );
+     String aLibName( GetLibName() );
+     LibraryLocation eLocation = aDocument.getLibraryLocation( aLibName );
+-    return BasicEntryDescriptor( aDocument, eLocation, aLibName, GetName(), OBJ_TYPE_MODULE );
++    String aLibSubName;
++    if( xBasic.Is() && xBasic->isVBAEnabled() && xModule.Is() )
++    {
++        switch( xModule->GetModuleType() )
++        {
++            case script::ModuleType::Document:
++                aLibSubName = String::CreateFromAscii("Document Objects");
++                break;
++            case script::ModuleType::Form:
++                aLibSubName = String::CreateFromAscii("Forms");
++                break;
++            case script::ModuleType::Normal:
++                aLibSubName = String::CreateFromAscii("Modules");
++                break;
++            case script::ModuleType::Class:
++                aLibSubName = String::CreateFromAscii("Class Modules");
++                break;
++        }
++    }
++    return BasicEntryDescriptor( aDocument, eLocation, aLibName, aLibSubName, GetName(), OBJ_TYPE_MODULE );
+ }
+ 
+ void ModulWindow::SetReadOnly( BOOL b )
+diff -urp basicide.bk/baside3.cxx basctl/source/basicide/baside3.cxx
+--- basicide.bk/baside3.cxx	2008-09-22 11:33:04.000000000 +0800
++++ basctl/source/basicide/baside3.cxx	2008-09-25 13:50:37.000000000 +0800
+@@ -903,8 +903,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 )
+diff -urp basicide.bk/bastype2.cxx basctl/source/basicide/bastype2.cxx
+--- basicide.bk/bastype2.cxx	2008-09-22 11:33:04.000000000 +0800
++++ basctl/source/basicide/bastype2.cxx	2008-09-25 15:51:18.000000000 +0800
+@@ -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>
+ 
+ using namespace ::com::sun::star::uno;
+ using namespace ::com::sun::star;
+ 
++static const rtl::OUString sDocumentObjects(  rtl::OUString::createFromAscii("Document Objects") );
++static const rtl::OUString sForms(  rtl::OUString::createFromAscii("Forms") );
++static const rtl::OUString sModules(  rtl::OUString::createFromAscii("Modules") );
++static const rtl::OUString sClassModules(  rtl::OUString::createFromAscii("Class Modules") );
++
++sal_Int32 lcl_getModuleType( StarBASIC* pBasic, const String& rName )
++{
++    sal_Int32 nType = com::sun::star::script::ModuleType::Unknown;
++    SbModule* pModule = (SbModule*)pBasic->FindModule( rName );
++    if( pModule )
++        nType = pModule->GetModuleType();
++    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++ )
+-				{
+-                    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 ) ) );
+-						}
+-                    }
+-				}
++		 	{
++                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
++                {
++                    // 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,129 @@ 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, sDocumentObjects ) );
++    aEntryMap.insert( ::std::make_pair( OBJ_TYPE_FORMS, sForms ) );
++    aEntryMap.insert( ::std::make_pair( OBJ_TYPE_NORMAL_MODULES, sModules ) );
++    aEntryMap.insert( ::std::make_pair( OBJ_TYPE_CLASS_MODULES, sClassModules ) );
++
++    ::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 )
++{
++    BasicManager* pBasMgr = rDocument.getBasicManager();
++    StarBASIC* pBasic = pBasMgr ? pBasMgr->GetLib( rLibName ) : 0;
++    OSL_ENSURE( pBasic, "BasicTreeListBox::ImpCreateLibSubSubEntriesInVBAMode: StartBASIC is NULL!" );
++    if( !pBasic )
++        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( pBasic, aModName ) )
++            {
++                case script::ModuleType::Document:
++                    eType = OBJ_TYPE_DOCUMENT_OBJECTS;
++                    break;
++                case script::ModuleType::Form:
++                    eType = OBJ_TYPE_FORMS;
++                    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;
++
++            SvLBoxEntry* pModuleEntry = FindEntry( pLibSubRootEntry, aModName, OBJ_TYPE_MODULE );
++            if ( !pModuleEntry )
++                pModuleEntry = AddEntry(
++                    aModName,
++                    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 +631,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 +788,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 +805,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;
+diff -urp basicide.bk/bastype2.hxx basctl/source/basicide/bastype2.hxx
+--- basicide.bk/bastype2.hxx	2008-09-22 11:33:04.000000000 +0800
++++ basctl/source/basicide/bastype2.hxx	2008-09-25 15:50:13.000000000 +0800
+@@ -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_FORMS, 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 );
+diff -urp basicide.bk/bastype3.cxx basctl/source/basicide/bastype3.cxx
+--- basicide.bk/bastype3.cxx	2008-09-22 11:33:04.000000000 +0800
++++ basctl/source/basicide/bastype3.cxx	2008-09-25 13:50:37.000000000 +0800
+@@ -134,6 +134,14 @@ void __EXPORT BasicTreeListBox::Requesti
+ 		    }
+         }
+     }
++    else if ( eType == OBJ_TYPE_DOCUMENT_OBJECTS 
++            || eType == OBJ_TYPE_FORMS
++            || 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!" );
+     }
+@@ -240,6 +248,14 @@ SbxVariable* BasicTreeListBox::FindVaria
+ 					// sbx dialogs removed
+ 				}
+ 				break;
++                case OBJ_TYPE_DOCUMENT_OBJECTS:
++                case OBJ_TYPE_FORMS:
++                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 +276,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 +349,15 @@ BasicEntryDescriptor BasicTreeListBox::G
+ 					eType = pBE->GetType();
+ 				}
+ 				break;
++                case OBJ_TYPE_DOCUMENT_OBJECTS:
++                case OBJ_TYPE_FORMS:
++                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 +371,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 +453,14 @@ bool BasicTreeListBox::IsValidEntry( SvL
+             bIsValid = BasicIDE::HasMethod( aDocument, aLibName, aName, aMethodName );
+         }
+         break;
++        case OBJ_TYPE_DOCUMENT_OBJECTS:
++        case OBJ_TYPE_FORMS:
++        case OBJ_TYPE_NORMAL_MODULES:
++        case OBJ_TYPE_CLASS_MODULES:
++        {
++            bIsValid = true;
++        }
++        break;
+ 		default: ;
+     }
+ 
+diff -urp basicide.bk/moduldlg.cxx basctl/source/basicide/moduldlg.cxx
+--- basicide.bk/moduldlg.cxx	2008-09-22 11:33:04.000000000 +0800
++++ basctl/source/basicide/moduldlg.cxx	2008-09-25 17:05:55.000000000 +0800
+@@ -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 ) );
+@@ -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,27 @@ 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 )
++	if ( ( !bVBAEnabled && ( nDepth == 2 ) ) 
++        || ( bVBAEnabled && ( nMode & BROWSEMODE_MODULES ) && ( nDepth == 3 ) ) )
+ 		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,7 +667,8 @@ void ObjectPage::CheckButtons()
+     }
+ 
+     // enable/disable delete button
+-	if ( nDepth == 2 && !bReadOnly && eLocation != LIBRARY_LOCATION_SHARE )
++	if ( ( ( !bVBAEnabled && nDepth == 2 ) || ( bVBAEnabled && ( nDepth == 3 ) && !aLibSubName.EqualsAscii("Document Objects" ) ) )
++        && !bReadOnly && eLocation != LIBRARY_LOCATION_SHARE )
+ 		aDelButton.Enable();
+ 	else
+ 		aDelButton.Disable();
+@@ -688,7 +696,7 @@ 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 )



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