ooo-build r14025 - in trunk: . patches/test



Author: pflin
Date: Tue Sep 23 08:04:52 2008
New Revision: 14025
URL: http://svn.gnome.org/viewvc/ooo-build?rev=14025&view=rev

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



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

Added: trunk/patches/test/vba-basic-macrochoose-dialog.diff
==============================================================================
--- (empty file)
+++ trunk/patches/test/vba-basic-macrochoose-dialog.diff	Tue Sep 23 08:04:52 2008
@@ -0,0 +1,309 @@
+--- basctl/source/basicide/bastype2.hxx.orig	2008-09-23 15:42:34.000000000 +0800
++++ basctl/source/basicide/bastype2.hxx	2008-09-23 15:47:02.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
+@@ -164,6 +164,8 @@ 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 );
+ 
+     // DocumentEventListener
+     virtual void onDocumentCreated( const ScriptDocument& _rDocument );
+--- basctl/source/basicide/bastype2.cxx.orig	2008-09-23 15:42:50.000000000 +0800
++++ basctl/source/basicide/bastype2.cxx	2008-09-23 15:54:35.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()
+ {
+@@ -285,18 +300,25 @@ void BasicTreeListBox::ImpCreateLibSubEn
+ 
+         if ( xModLibContainer.is() && xModLibContainer->hasByName( aOULibName ) && xModLibContainer->isLibraryLoaded( aOULibName ) )
+         {
+-            try
+-		    {
++            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
++            {
++                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 )
++                    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 ) ),
+@@ -304,17 +326,17 @@ void BasicTreeListBox::ImpCreateLibSubEn
+                             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 );
++		 				// 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,
+@@ -322,14 +344,15 @@ void BasicTreeListBox::ImpCreateLibSubEn
+                                     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 +391,115 @@ 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();
++    }
++}
++
+ void BasicTreeListBox::onDocumentCreated( const ScriptDocument& /*_rDocument*/ )
+ {
+     UpdateEntries();
+--- basctl/source/basicide/bastype3.cxx.orig	2008-09-23 15:43:07.000000000 +0800
++++ basctl/source/basicide/bastype3.cxx	2008-09-23 15:10:49.000000000 +0800
+@@ -134,6 +134,22 @@ 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 )
++    {
++        SvLBoxEntry* pLibRootEntry = GetParent( pEntry );
++        if( pLibRootEntry )
++        {
++            BasicEntryDescriptor aLibDesc( GetEntryDescriptor( pLibRootEntry ) );
++            if( aLibDesc.GetType() == OBJ_TYPE_LIBRARY )
++            {
++                String aLibName( aLibDesc.GetLibName() );
++                ImpCreateLibSubSubEntriesInVBAMode( pEntry, aDocument, aLibName );
++            }
++        }
++    }
+ 	else {
+ 		DBG_ERROR( "BasicTreeListBox::RequestingChilds: Unknown Type!" );
+     }
+@@ -240,6 +256,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!" );
+@@ -330,6 +354,15 @@ BasicEntryDescriptor BasicTreeListBox::G
+ 				{
+ 					aName = GetEntryText( pLE );
+ 					eType = pBE->GetType();
++				}
++				break;
++                case OBJ_TYPE_DOCUMENT_OBJECTS:
++                case OBJ_TYPE_FORMS:
++                case OBJ_TYPE_NORMAL_MODULES:
++                case OBJ_TYPE_CLASS_MODULES:
++				{
++					aName = GetEntryText( pLE );
++					eType = pBE->GetType();
+ 				}
+ 				break;
+ 				default:



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