update dev300-m57
[ooovba.git] / applied_patches / 0332-vba-basic-macrochoose-dialog.diff
blob895a919e8c3b9bc39e528df1ce55a7acba47213d
1 diff -urp '--exclude=unxlngi6.pro' basctl.bk/inc/basidesh.hrc basctl/inc/basidesh.hrc
2 --- basctl.bk/inc/basidesh.hrc 2008-10-10 09:48:33.000000000 +0800
3 +++ basctl/inc/basidesh.hrc 2008-10-10 09:53:46.000000000 +0800
4 @@ -175,6 +175,10 @@
5 #define RID_STR_EXPORTPACKAGE ( RID_BASICIDE_START + 100 )
6 #define RID_STR_EXPORTBASIC ( RID_BASICIDE_START + 101 )
7 #define RID_STR_PACKAGE_BUNDLE ( RID_BASICIDE_START + 102 )
8 +#define RID_STR_DOCUMENT_OBJECTS ( RID_BASICIDE_START + 110 )
9 +#define RID_STR_USERFORMS ( RID_BASICIDE_START + 111 )
10 +#define RID_STR_NORMAL_MODULES ( RID_BASICIDE_START + 112 )
11 +#define RID_STR_CLASS_MODULES ( RID_BASICIDE_START + 113 )
13 #endif // _SVX_NOIDERESIDS
15 diff -urp '--exclude=unxlngi6.pro' basctl.bk/source/basicide/baside2.cxx basctl/source/basicide/baside2.cxx
16 --- basctl.bk/source/basicide/baside2.cxx 2008-10-10 09:48:33.000000000 +0800
17 +++ basctl/source/basicide/baside2.cxx 2008-10-10 09:53:46.000000000 +0800
18 @@ -49,6 +49,7 @@
19 #include <com/sun/star/script/XLibraryContainer2.hpp>
20 #endif
21 #include <com/sun/star/document/MacroExecMode.hpp>
22 +#include <com/sun/star/script/ModuleType.hpp>
23 #include <toolkit/helper/vclunohelper.hxx>
24 #include <sfx2/docfile.hxx>
25 #include <basic/basrdll.hxx>
26 @@ -110,6 +111,8 @@ DBG_NAME( ModulWindow )
28 TYPEINIT1( ModulWindow , IDEBaseWindow );
30 +void lcl_getObjectName( const uno::Reference< container::XNameContainer >& rLib, const String& rModName, String& rObjName );
32 void lcl_PrintHeader( Printer* pPrinter, USHORT nPages, USHORT nCurPage, const String& rTitle )
34 short nLeftMargin = LMARGPRN;
35 @@ -1347,7 +1350,39 @@ BasicEntryDescriptor ModulWindow::Create
36 ScriptDocument aDocument( GetDocument() );
37 String aLibName( GetLibName() );
38 LibraryLocation eLocation = aDocument.getLibraryLocation( aLibName );
39 - return BasicEntryDescriptor( aDocument, eLocation, aLibName, GetName(), OBJ_TYPE_MODULE );
40 + String aModName( GetName() );
41 + String aLibSubName;
42 + if( xBasic.Is() && xBasic->isVBAEnabled() && xModule.Is() )
43 + {
44 + switch( xModule->GetModuleType() )
45 + {
46 + case script::ModuleType::Document:
47 + {
48 + aLibSubName = String( IDEResId( RID_STR_DOCUMENT_OBJECTS ) );
49 + uno::Reference< container::XNameContainer > xLib = aDocument.getOrCreateLibrary( E_SCRIPTS, aLibName );
50 + if( xLib.is() )
51 + {
52 + String sObjName;
53 + lcl_getObjectName( xLib, aModName, sObjName );
54 + if( sObjName.Len() )
55 + {
56 + aModName.AppendAscii(" (").Append(sObjName).AppendAscii(")");
57 + }
58 + }
59 + break;
60 + }
61 + case script::ModuleType::Form:
62 + aLibSubName = String( IDEResId( RID_STR_USERFORMS ) );
63 + break;
64 + case script::ModuleType::Normal:
65 + aLibSubName = String( IDEResId( RID_STR_NORMAL_MODULES ) );
66 + break;
67 + case script::ModuleType::Class:
68 + aLibSubName = String( IDEResId( RID_STR_CLASS_MODULES ) );
69 + break;
70 + }
71 + }
72 + return BasicEntryDescriptor( aDocument, eLocation, aLibName, aLibSubName, aModName, OBJ_TYPE_MODULE );
75 void ModulWindow::SetReadOnly( BOOL b )
76 diff -urp '--exclude=unxlngi6.pro' basctl.bk/source/basicide/baside3.cxx basctl/source/basicide/baside3.cxx
77 --- basctl.bk/source/basicide/baside3.cxx 2008-10-10 09:48:33.000000000 +0800
78 +++ basctl/source/basicide/baside3.cxx 2008-10-10 09:53:46.000000000 +0800
79 @@ -903,8 +903,9 @@ BasicEntryDescriptor DialogWindow::Creat
81 ScriptDocument aDocument( GetDocument() );
82 String aLibName( GetLibName() );
83 + String aLibSubName;
84 LibraryLocation eLocation = aDocument.getLibraryLocation( aLibName );
85 - return BasicEntryDescriptor( aDocument, eLocation, aLibName, GetName(), OBJ_TYPE_DIALOG );
86 + return BasicEntryDescriptor( aDocument, eLocation, aLibName, aLibSubName, GetName(), OBJ_TYPE_DIALOG );
89 void DialogWindow::SetReadOnly( BOOL b )
90 diff -urp '--exclude=unxlngi6.pro' basctl.bk/source/basicide/basidesh.src basctl/source/basicide/basidesh.src
91 --- basctl.bk/source/basicide/basidesh.src 2008-10-10 09:48:33.000000000 +0800
92 +++ basctl/source/basicide/basidesh.src 2008-10-10 09:53:46.000000000 +0800
93 @@ -639,6 +639,22 @@ String RID_STR_TRANSLATION_DEFAULT
95 Text [ en-US ] = "[Default Language]" ;
97 +String RID_STR_DOCUMENT_OBJECTS
99 + Text [ en-US ] = "Document Objects" ;
101 +String RID_STR_USERFORMS
103 + Text [ en-US ] = "Forms" ;
105 +String RID_STR_NORMAL_MODULES
107 + Text [ en-US ] = "Modules" ;
109 +String RID_STR_CLASS_MODULES
111 + Text [ en-US ] = "Class Modules" ;
114 #define MN_EDIT 20
115 #define MN_VIEW 21
116 diff -urp '--exclude=unxlngi6.pro' basctl.bk/source/basicide/bastype2.cxx basctl/source/basicide/bastype2.cxx
117 --- basctl.bk/source/basicide/bastype2.cxx 2008-10-10 09:48:34.000000000 +0800
118 +++ basctl/source/basicide/bastype2.cxx 2008-10-10 09:53:46.000000000 +0800
119 @@ -53,10 +53,25 @@
120 #include <com/sun/star/frame/XModuleManager.hpp>
121 #include <comphelper/processfactory.hxx>
122 #include <comphelper/componentcontext.hxx>
123 +#include <map>
124 +#include <com/sun/star/script/ModuleType.hpp>
125 +#include <com/sun/star/script/ModuleInfo.hpp>
126 +#include <com/sun/star/container/XNameContainer.hpp>
128 using namespace ::com::sun::star::uno;
129 using namespace ::com::sun::star;
131 +void lcl_getObjectName( const uno::Reference< container::XNameContainer >& rLib, const String& rModName, String& rObjName );
133 +sal_Int32 lcl_getModuleType( const uno::Reference< container::XNameContainer >& rLib, const String& rModName )
135 + sal_Int32 nType = com::sun::star::script::ModuleType::Normal;
136 + uno::Any aElement( rLib->getByName( rModName ) );
137 + script::ModuleInfo aModuleInfo;
138 + if( aElement >>= aModuleInfo )
139 + nType = aModuleInfo.ModuleType;
140 + return nType;
143 BasicEntry::~BasicEntry()
145 @@ -91,20 +106,22 @@ BasicEntryDescriptor::BasicEntryDescript
149 -BasicEntryDescriptor::BasicEntryDescriptor( const ScriptDocument& rDocument, LibraryLocation eLocation, const String& rLibName, const String& rName, BasicEntryType eType )
150 +BasicEntryDescriptor::BasicEntryDescriptor( const ScriptDocument& rDocument, LibraryLocation eLocation, const String& rLibName, const String& rLibSubName, const String& rName, BasicEntryType eType )
151 :m_aDocument( rDocument )
152 ,m_eLocation( eLocation )
153 ,m_aLibName( rLibName )
154 + ,m_aLibSubName( rLibSubName )
155 ,m_aName( rName )
156 ,m_eType( eType )
158 OSL_ENSURE( m_aDocument.isValid(), "BasicEntryDescriptor::BasicEntryDescriptor: invalid document!" );
161 -BasicEntryDescriptor::BasicEntryDescriptor( const ScriptDocument& rDocument, LibraryLocation eLocation, const String& rLibName, const String& rName, const String& rMethodName, BasicEntryType eType )
162 +BasicEntryDescriptor::BasicEntryDescriptor( const ScriptDocument& rDocument, LibraryLocation eLocation, const String& rLibName, const String& rLibSubName, const String& rName, const String& rMethodName, BasicEntryType eType )
163 :m_aDocument( rDocument )
164 ,m_eLocation( eLocation )
165 ,m_aLibName( rLibName )
166 + ,m_aLibSubName( rLibSubName )
167 ,m_aName( rName )
168 ,m_aMethodName( rMethodName )
169 ,m_eType( eType )
170 @@ -120,6 +137,7 @@ BasicEntryDescriptor::BasicEntryDescript
171 :m_aDocument( rDesc.m_aDocument )
172 ,m_eLocation( rDesc.m_eLocation )
173 ,m_aLibName( rDesc.m_aLibName )
174 + ,m_aLibSubName( rDesc.m_aLibSubName )
175 ,m_aName( rDesc.m_aName )
176 ,m_aMethodName( rDesc.m_aMethodName )
177 ,m_eType( rDesc.m_eType )
178 @@ -131,6 +149,7 @@ BasicEntryDescriptor& BasicEntryDescript
179 m_aDocument = rDesc.m_aDocument;
180 m_eLocation = rDesc.m_eLocation;
181 m_aLibName = rDesc.m_aLibName;
182 + m_aLibSubName = rDesc.m_aLibSubName;
183 m_aName = rDesc.m_aName;
184 m_aMethodName = rDesc.m_aMethodName;
185 m_eType = rDesc.m_eType;
186 @@ -143,6 +162,7 @@ bool BasicEntryDescriptor::operator==( c
187 return m_aDocument == rDesc.m_aDocument &&
188 m_eLocation == rDesc.m_eLocation &&
189 m_aLibName == rDesc.m_aLibName &&
190 + m_aLibSubName == rDesc.m_aLibSubName &&
191 m_aName == rDesc.m_aName &&
192 m_aMethodName == rDesc.m_aMethodName &&
193 m_eType == rDesc.m_eType;
194 @@ -286,50 +306,58 @@ void BasicTreeListBox::ImpCreateLibSubEn
195 if ( xModLibContainer.is() && xModLibContainer->hasByName( aOULibName ) && xModLibContainer->isLibraryLoaded( aOULibName ) )
199 - // get a sorted list of module names
200 - Sequence< ::rtl::OUString > aModNames = rDocument.getObjectNames( E_SCRIPTS, rLibName );
201 - sal_Int32 nModCount = aModNames.getLength();
202 - const ::rtl::OUString* pModNames = aModNames.getConstArray();
204 - for ( sal_Int32 i = 0 ; i < nModCount ; i++ )
206 - String aModName = pModNames[ i ];
207 - SvLBoxEntry* pModuleEntry = FindEntry( pLibRootEntry, aModName, OBJ_TYPE_MODULE );
208 - if ( !pModuleEntry )
209 - pModuleEntry = AddEntry(
210 - aModName,
211 - Image( IDEResId( RID_IMG_MODULE ) ),
212 - Image( IDEResId( RID_IMG_MODULE_HC ) ),
213 - pLibRootEntry, false,
214 - std::auto_ptr< BasicEntry >( new BasicEntry( OBJ_TYPE_MODULE ) ) );
216 - // methods
217 - if ( nMode & BROWSEMODE_SUBS )
219 - Sequence< ::rtl::OUString > aNames = BasicIDE::GetMethodNames( rDocument, rLibName, aModName );
220 - sal_Int32 nCount = aNames.getLength();
221 - const ::rtl::OUString* pNames = aNames.getConstArray();
223 - for ( sal_Int32 j = 0 ; j < nCount ; j++ )
225 - String aName = pNames[ j ];
226 - SvLBoxEntry* pEntry = FindEntry( pModuleEntry, aName, OBJ_TYPE_METHOD );
227 - if ( !pEntry )
228 - pEntry = AddEntry(
229 - aName,
230 - Image( IDEResId( RID_IMG_MACRO ) ),
231 - Image( IDEResId( RID_IMG_MACRO_HC ) ),
232 - pModuleEntry, false,
233 - std::auto_ptr< BasicEntry >( new BasicEntry( OBJ_TYPE_METHOD ) ) );
238 + BasicManager* pBasMgr = rDocument.getBasicManager();
239 + StarBASIC* pBasic = pBasMgr ? pBasMgr->GetLib( rLibName ) : 0;
240 + sal_Bool bVBAEnabled = pBasic ? pBasic->isVBAEnabled(): sal_False;
241 + if( bVBAEnabled )
242 + ImpCreateLibSubEntriesInVBAMode( pLibRootEntry, rDocument, rLibName );
243 + else
245 + // get a sorted list of module names
246 + Sequence< ::rtl::OUString > aModNames = rDocument.getObjectNames( E_SCRIPTS, rLibName );
247 + sal_Int32 nModCount = aModNames.getLength();
248 + const ::rtl::OUString* pModNames = aModNames.getConstArray();
250 + for ( sal_Int32 i = 0 ; i < nModCount ; i++ )
252 + String aModName = pModNames[ i ];
253 + SvLBoxEntry* pModuleEntry = FindEntry( pLibRootEntry, aModName, OBJ_TYPE_MODULE );
254 + if ( !pModuleEntry )
255 + pModuleEntry = AddEntry(
256 + aModName,
257 + Image( IDEResId( RID_IMG_MODULE ) ),
258 + Image( IDEResId( RID_IMG_MODULE_HC ) ),
259 + pLibRootEntry, false,
260 + std::auto_ptr< BasicEntry >( new BasicEntry( OBJ_TYPE_MODULE ) ) );
262 + // methods
263 + if ( nMode & BROWSEMODE_SUBS )
265 + Sequence< ::rtl::OUString > aNames = BasicIDE::GetMethodNames( rDocument, rLibName, aModName );
266 + sal_Int32 nCount = aNames.getLength();
267 + const ::rtl::OUString* pNames = aNames.getConstArray();
269 + for ( sal_Int32 j = 0 ; j < nCount ; j++ )
271 + String aName = pNames[ j ];
272 + SvLBoxEntry* pEntry = FindEntry( pModuleEntry, aName, OBJ_TYPE_METHOD );
273 + if ( !pEntry )
274 + pEntry = AddEntry(
275 + aName,
276 + Image( IDEResId( RID_IMG_MACRO ) ),
277 + Image( IDEResId( RID_IMG_MACRO_HC ) ),
278 + pModuleEntry, false,
279 + std::auto_ptr< BasicEntry >( new BasicEntry( OBJ_TYPE_METHOD ) ) );
285 - catch ( const container::NoSuchElementException& )
287 + catch ( const container::NoSuchElementException& )
289 DBG_UNHANDLED_EXCEPTION();
295 @@ -368,6 +396,139 @@ void BasicTreeListBox::ImpCreateLibSubEn
299 +void BasicTreeListBox::ImpCreateLibSubEntriesInVBAMode( SvLBoxEntry* pLibRootEntry, const ScriptDocument& rDocument, const String& rLibName )
301 + ::std::map< BasicEntryType, ::rtl::OUString > aEntryMap;
302 + aEntryMap.insert( ::std::make_pair( OBJ_TYPE_DOCUMENT_OBJECTS, String( IDEResId( RID_STR_DOCUMENT_OBJECTS ) ) ) );
303 + aEntryMap.insert( ::std::make_pair( OBJ_TYPE_USERFORMS, String( IDEResId( RID_STR_USERFORMS ) ) ) );
304 + aEntryMap.insert( ::std::make_pair( OBJ_TYPE_NORMAL_MODULES, String( IDEResId( RID_STR_NORMAL_MODULES ) ) ) );
305 + aEntryMap.insert( ::std::make_pair( OBJ_TYPE_CLASS_MODULES, String( IDEResId( RID_STR_CLASS_MODULES ) ) ) );
307 + ::std::map< BasicEntryType, ::rtl::OUString >::iterator iter;
308 + for( iter = aEntryMap.begin(); iter != aEntryMap.end(); ++iter )
310 + BasicEntryType eType = iter->first;
311 + ::rtl::OUString aEntryName = iter->second;
312 + SvLBoxEntry* pLibSubRootEntry = FindEntry( pLibRootEntry, aEntryName, eType );
313 + if( pLibSubRootEntry )
315 + SetEntryBitmaps( pLibSubRootEntry, Image( IDEResId( RID_IMG_MODLIB ) ), Image( IDEResId( RID_IMG_MODLIB_HC ) ) );
316 + if ( IsExpanded( pLibSubRootEntry ) )
317 + ImpCreateLibSubSubEntriesInVBAMode( pLibSubRootEntry, rDocument, rLibName );
319 + else
321 + pLibSubRootEntry = AddEntry(
322 + aEntryName,
323 + Image( IDEResId( RID_IMG_MODLIB ) ),
324 + Image( IDEResId( RID_IMG_MODLIB_HC ) ),
325 + pLibRootEntry, true,
326 + std::auto_ptr< BasicEntry >( new BasicEntry( eType ) ) );
331 +void BasicTreeListBox::ImpCreateLibSubSubEntriesInVBAMode( SvLBoxEntry* pLibSubRootEntry, const ScriptDocument& rDocument, const String& rLibName )
333 + uno::Reference< container::XNameContainer > xLib = rDocument.getOrCreateLibrary( E_SCRIPTS, rLibName );
334 + if( !xLib.is() )
335 + return;
337 + try
339 + // get a sorted list of module names
340 + Sequence< ::rtl::OUString > aModNames = rDocument.getObjectNames( E_SCRIPTS, rLibName );
341 + sal_Int32 nModCount = aModNames.getLength();
342 + const ::rtl::OUString* pModNames = aModNames.getConstArray();
344 + BasicEntryDescriptor aDesc( GetEntryDescriptor( pLibSubRootEntry ) );
345 + BasicEntryType eCurrentType( aDesc.GetType() );
347 + for ( sal_Int32 i = 0 ; i < nModCount ; i++ )
349 + String aModName = pModNames[ i ];
350 + BasicEntryType eType = OBJ_TYPE_UNKNOWN;
351 + switch( lcl_getModuleType( xLib, aModName ) )
353 + case script::ModuleType::Document:
354 + eType = OBJ_TYPE_DOCUMENT_OBJECTS;
355 + break;
356 + case script::ModuleType::Form:
357 + eType = OBJ_TYPE_USERFORMS;
358 + break;
359 + case script::ModuleType::Normal:
360 + eType = OBJ_TYPE_NORMAL_MODULES;
361 + break;
362 + case script::ModuleType::Class:
363 + eType = OBJ_TYPE_CLASS_MODULES;
364 + break;
366 + if( eType != eCurrentType )
367 + continue;
369 + // display a nice friendly name in the ObjectModule tab,
370 + // combining the objectname and module name, e.g. Sheet1 ( Financials )
371 + String aEntryName( aModName );
372 + if( eType == OBJ_TYPE_DOCUMENT_OBJECTS )
374 + String sObjName;
375 + lcl_getObjectName( xLib, aModName, sObjName );
376 + if( sObjName.Len() )
378 + aEntryName.AppendAscii(" (").Append(sObjName).AppendAscii(")");
381 + SvLBoxEntry* pModuleEntry = FindEntry( pLibSubRootEntry, aEntryName, OBJ_TYPE_MODULE );
382 + if ( !pModuleEntry )
383 + pModuleEntry = AddEntry(
384 + aEntryName,
385 + Image( IDEResId( RID_IMG_MODULE ) ),
386 + Image( IDEResId( RID_IMG_MODULE_HC ) ),
387 + pLibSubRootEntry, false,
388 + std::auto_ptr< BasicEntry >( new BasicEntry( OBJ_TYPE_MODULE ) ) );
390 + // methods
391 + if ( nMode & BROWSEMODE_SUBS )
393 + Sequence< ::rtl::OUString > aNames = BasicIDE::GetMethodNames( rDocument, rLibName, aModName );
394 + sal_Int32 nCount = aNames.getLength();
395 + const ::rtl::OUString* pNames = aNames.getConstArray();
397 + for ( sal_Int32 j = 0 ; j < nCount ; j++ )
399 + String aName = pNames[ j ];
400 + SvLBoxEntry* pEntry = FindEntry( pModuleEntry, aName, OBJ_TYPE_METHOD );
401 + if ( !pEntry )
402 + pEntry = AddEntry(
403 + aName,
404 + Image( IDEResId( RID_IMG_MACRO ) ),
405 + Image( IDEResId( RID_IMG_MACRO_HC ) ),
406 + pModuleEntry, false,
407 + std::auto_ptr< BasicEntry >( new BasicEntry( OBJ_TYPE_METHOD ) ) );
412 + catch ( const container::NoSuchElementException& )
414 + DBG_UNHANDLED_EXCEPTION();
418 +SvLBoxEntry* BasicTreeListBox::ImpFindEntry( SvLBoxEntry* pParent, const String& rText )
420 + ULONG nRootPos = 0;
421 + SvLBoxEntry* pEntry = pParent ? FirstChild( pParent ) : GetEntry( nRootPos );
422 + while ( pEntry )
424 + if ( GetEntryText( pEntry ) == rText )
425 + return pEntry;
427 + pEntry = pParent ? NextSibling( pEntry ) : GetEntry( ++nRootPos );
429 + return 0;
432 void BasicTreeListBox::onDocumentCreated( const ScriptDocument& /*_rDocument*/ )
434 UpdateEntries();
435 @@ -480,10 +641,11 @@ long BasicTreeListBox::ExpandingHdl()
436 if ( aDocument.isAlive() )
438 String aLibName( aDesc.GetLibName() );
439 + String aLibSubName( aDesc.GetLibSubName() );
440 String aName( aDesc.GetName() );
441 String aMethodName( aDesc.GetMethodName() );
443 - if ( aLibName.Len() && !aName.Len() && !aMethodName.Len() )
444 + if ( aLibName.Len() && !aLibSubName.Len() && !aName.Len() && !aMethodName.Len() )
446 // check password, if library is password protected and not verified
447 ::rtl::OUString aOULibName( aLibName );
448 @@ -636,7 +798,7 @@ void BasicTreeListBox::SetCurrentEntry(
449 aDesc = BasicEntryDescriptor(
450 ScriptDocument::getApplicationScriptDocument(),
451 LIBRARY_LOCATION_USER, String::CreateFromAscii( "Standard" ),
452 - String::CreateFromAscii( "." ), OBJ_TYPE_UNKNOWN );
453 + String(), String::CreateFromAscii( "." ), OBJ_TYPE_UNKNOWN );
455 ScriptDocument aDocument( aDesc.GetDocument() );
456 OSL_ENSURE( aDocument.isValid(), "BasicTreeListBox::SetCurrentEntry: invalid document!" );
457 @@ -653,14 +815,24 @@ void BasicTreeListBox::SetCurrentEntry(
458 if ( pLibEntry )
460 pCurEntry = pLibEntry;
461 + String aLibSubName( aDesc.GetLibSubName() );
462 + if( aLibSubName.Len() )
464 + Expand( pLibEntry );
465 + SvLBoxEntry* pLibSubEntry = ImpFindEntry( pLibEntry, aLibSubName );
466 + if( pLibSubEntry )
468 + pCurEntry = pLibSubEntry;
471 String aName( aDesc.GetName() );
472 if ( aName.Len() )
474 - Expand( pLibEntry );
475 + Expand( pCurEntry );
476 BasicEntryType eType = OBJ_TYPE_MODULE;
477 if ( aDesc.GetType() == OBJ_TYPE_DIALOG )
478 eType = OBJ_TYPE_DIALOG;
479 - SvLBoxEntry* pEntry = FindEntry( pLibEntry, aName, eType );
480 + SvLBoxEntry* pEntry = FindEntry( pCurEntry, aName, eType );
481 if ( pEntry )
483 pCurEntry = pEntry;
484 diff -urp '--exclude=unxlngi6.pro' basctl.bk/source/basicide/bastype2.hxx basctl/source/basicide/bastype2.hxx
485 --- basctl.bk/source/basicide/bastype2.hxx 2008-10-10 09:48:34.000000000 +0800
486 +++ basctl/source/basicide/bastype2.hxx 2008-10-10 09:53:46.000000000 +0800
487 @@ -42,7 +42,7 @@
488 #include <sbxitem.hxx>
489 #include "basobj.hxx"
491 -enum BasicEntryType { OBJ_TYPE_UNKNOWN, OBJ_TYPE_DOCUMENT, OBJ_TYPE_LIBRARY, OBJ_TYPE_MODULE, OBJ_TYPE_DIALOG, OBJ_TYPE_METHOD };
492 +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 };
494 #define BROWSEMODE_MODULES 0x01
495 #define BROWSEMODE_SUBS 0x02
496 @@ -101,14 +101,15 @@ class BasicEntryDescriptor
497 ScriptDocument m_aDocument;
498 LibraryLocation m_eLocation;
499 String m_aLibName;
500 + String m_aLibSubName; // for vba entry: Document Objects, Class Modules, Forms and Normal Modules
501 String m_aName;
502 String m_aMethodName;
503 BasicEntryType m_eType;
505 public:
506 BasicEntryDescriptor();
507 - BasicEntryDescriptor( const ScriptDocument& rDocument, LibraryLocation eLocation, const String& rLibName, const String& rName, BasicEntryType eType );
508 - BasicEntryDescriptor( const ScriptDocument& rDocument, LibraryLocation eLocation, const String& rLibName, const String& rName, const String& rMethodName, BasicEntryType eType );
509 + BasicEntryDescriptor( const ScriptDocument& rDocument, LibraryLocation eLocation, const String& rLibName, const String& rLibSubName, const String& rName, BasicEntryType eType );
510 + BasicEntryDescriptor( const ScriptDocument& rDocument, LibraryLocation eLocation, const String& rLibName, const String& rLibSubName, const String& rName, const String& rMethodName, BasicEntryType eType );
511 virtual ~BasicEntryDescriptor();
513 BasicEntryDescriptor( const BasicEntryDescriptor& rDesc );
514 @@ -125,6 +126,9 @@ public:
515 const String& GetLibName() const { return m_aLibName; }
516 void SetLibName( const String& aLibName ) { m_aLibName = aLibName; }
518 + const String& GetLibSubName() const { return m_aLibSubName; }
519 + void SetLibSubName( const String& aLibSubName ) { m_aLibSubName = aLibSubName; }
521 const String& GetName() const { return m_aName; }
522 void SetName( const String& aName ) { m_aName = aName; }
524 @@ -164,6 +168,9 @@ protected:
526 void ImpCreateLibEntries( SvLBoxEntry* pShellRootEntry, const ScriptDocument& rDocument, LibraryLocation eLocation );
527 void ImpCreateLibSubEntries( SvLBoxEntry* pLibRootEntry, const ScriptDocument& rDocument, const String& rLibName );
528 + void ImpCreateLibSubEntriesInVBAMode( SvLBoxEntry* pLibRootEntry, const ScriptDocument& rDocument, const String& rLibName );
529 + void ImpCreateLibSubSubEntriesInVBAMode( SvLBoxEntry* pLibSubRootEntry, const ScriptDocument& rDocument, const String& rLibName );
530 + SvLBoxEntry* ImpFindEntry( SvLBoxEntry* pParent, const String& rText );
532 // DocumentEventListener
533 virtual void onDocumentCreated( const ScriptDocument& _rDocument );
534 diff -urp '--exclude=unxlngi6.pro' basctl.bk/source/basicide/bastype3.cxx basctl/source/basicide/bastype3.cxx
535 --- basctl.bk/source/basicide/bastype3.cxx 2008-10-10 09:48:34.000000000 +0800
536 +++ basctl/source/basicide/bastype3.cxx 2008-10-10 10:06:49.000000000 +0800
537 @@ -134,6 +134,14 @@ void __EXPORT BasicTreeListBox::Requesti
541 + else if ( eType == OBJ_TYPE_DOCUMENT_OBJECTS
542 + || eType == OBJ_TYPE_USERFORMS
543 + || eType == OBJ_TYPE_NORMAL_MODULES
544 + || eType == OBJ_TYPE_CLASS_MODULES )
546 + String aLibName( aDesc.GetLibName() );
547 + ImpCreateLibSubSubEntriesInVBAMode( pEntry, aDocument, aLibName );
549 else {
550 DBG_ERROR( "BasicTreeListBox::RequestingChilds: Unknown Type!" );
552 @@ -204,6 +212,7 @@ SbxVariable* BasicTreeListBox::FindVaria
555 SbxVariable* pVar = 0;
556 + bool bDocumentObjects = false;
557 if ( aEntries.Count() )
559 for ( USHORT n = 0; n < aEntries.Count(); n++ )
560 @@ -226,6 +235,12 @@ SbxVariable* BasicTreeListBox::FindVaria
561 case OBJ_TYPE_MODULE:
563 DBG_ASSERT( pVar && pVar->IsA( TYPE(StarBASIC) ), "FindVariable: Ungueltiges Basic" );
564 + // extract the module name from the string like "Sheet1 (Example1)"
565 + if( bDocumentObjects )
567 + sal_uInt16 nIndex = 0;
568 + aName = aName.GetToken( 0, ' ', nIndex );
570 pVar = ((StarBASIC*)pVar)->FindModule( aName );
572 break;
573 @@ -240,6 +255,15 @@ SbxVariable* BasicTreeListBox::FindVaria
574 // sbx dialogs removed
576 break;
577 + case OBJ_TYPE_DOCUMENT_OBJECTS:
578 + bDocumentObjects = true;
579 + case OBJ_TYPE_USERFORMS:
580 + case OBJ_TYPE_NORMAL_MODULES:
581 + case OBJ_TYPE_CLASS_MODULES:
583 + // skip, to find the child entry.
584 + continue;
586 default:
588 DBG_ERROR( "FindVariable: Unbekannter Typ!" );
589 @@ -260,12 +284,13 @@ BasicEntryDescriptor BasicTreeListBox::G
590 ScriptDocument aDocument( ScriptDocument::getApplicationScriptDocument() );
591 LibraryLocation eLocation = LIBRARY_LOCATION_UNKNOWN;
592 String aLibName;
593 + String aLibSubName;
594 String aName;
595 String aMethodName;
596 BasicEntryType eType = OBJ_TYPE_UNKNOWN;
598 if ( !pEntry )
599 - return BasicEntryDescriptor( aDocument, eLocation, aLibName, aName, aMethodName, eType );
600 + return BasicEntryDescriptor( aDocument, eLocation, aLibName, aLibSubName, aName, aMethodName, eType );
602 EntryArray aEntries;
604 @@ -332,6 +357,15 @@ BasicEntryDescriptor BasicTreeListBox::G
605 eType = pBE->GetType();
607 break;
608 + case OBJ_TYPE_DOCUMENT_OBJECTS:
609 + case OBJ_TYPE_USERFORMS:
610 + case OBJ_TYPE_NORMAL_MODULES:
611 + case OBJ_TYPE_CLASS_MODULES:
613 + aLibSubName = GetEntryText( pLE );
614 + eType = pBE->GetType();
616 + break;
617 default:
619 DBG_ERROR( "GetEntryDescriptor: Unbekannter Typ!" );
620 @@ -345,7 +379,7 @@ BasicEntryDescriptor BasicTreeListBox::G
624 - return BasicEntryDescriptor( aDocument, eLocation, aLibName, aName, aMethodName, eType );
625 + return BasicEntryDescriptor( aDocument, eLocation, aLibName, aLibSubName, aName, aMethodName, eType );
628 USHORT BasicTreeListBox::ConvertType( BasicEntryType eType )
629 @@ -427,6 +461,14 @@ bool BasicTreeListBox::IsValidEntry( SvL
630 bIsValid = BasicIDE::HasMethod( aDocument, aLibName, aName, aMethodName );
632 break;
633 + case OBJ_TYPE_DOCUMENT_OBJECTS:
634 + case OBJ_TYPE_USERFORMS:
635 + case OBJ_TYPE_NORMAL_MODULES:
636 + case OBJ_TYPE_CLASS_MODULES:
638 + bIsValid = true;
640 + break;
641 default: ;
644 diff -urp '--exclude=unxlngi6.pro' basctl.bk/source/basicide/macrodlg.cxx basctl/source/basicide/macrodlg.cxx
645 --- basctl.bk/source/basicide/macrodlg.cxx 2008-10-10 09:48:33.000000000 +0800
646 +++ basctl/source/basicide/macrodlg.cxx 2008-10-10 10:08:05.000000000 +0800
647 @@ -385,7 +385,15 @@ SbMethod* MacroChooser::CreateMacro()
648 SbModule* pModule = 0;
649 String aModName( aDesc.GetName() );
650 if ( aModName.Len() )
652 + // extract the module name from the string like "Sheet1 (Example1)"
653 + if( aDesc.GetLibSubName().Equals( String( IDEResId( RID_STR_DOCUMENT_OBJECTS ) ) ) )
655 + sal_uInt16 nIndex = 0;
656 + aModName = aModName.GetToken( 0, ' ', nIndex );
658 pModule = pBasic->FindModule( aModName );
659 + }
660 else if ( pBasic->GetModules()->Count() )
661 pModule = (SbModule*)pBasic->GetModules()->Get( 0 );
663 @@ -713,6 +721,12 @@ IMPL_LINK( MacroChooser, ButtonHdl, Butt
664 BasicManager* pBasMgr = aDocument.getBasicManager();
665 String aLib( aDesc.GetLibName() );
666 String aMod( aDesc.GetName() );
667 + // extract the module name from the string like "Sheet1 (Example1)"
668 + if( aDesc.GetLibSubName().Equals( String( IDEResId( RID_STR_DOCUMENT_OBJECTS ) ) ) )
670 + sal_uInt16 nIndex = 0;
671 + aMod = aMod.GetToken( 0, ' ', nIndex );
673 String aSub( aDesc.GetMethodName() );
674 SfxMacroInfoItem aInfoItem( SID_BASICIDE_ARG_MACROINFO, pBasMgr, aLib, aMod, aSub, String() );
675 if ( pButton == &aEditButton )
676 diff -urp '--exclude=unxlngi6.pro' basctl.bk/source/basicide/moduldlg.cxx basctl/source/basicide/moduldlg.cxx
677 --- basctl.bk/source/basicide/moduldlg.cxx 2008-10-10 09:48:33.000000000 +0800
678 +++ basctl/source/basicide/moduldlg.cxx 2008-10-10 10:08:44.000000000 +0800
679 @@ -87,7 +87,7 @@ BOOL __EXPORT ExtBasicTreeListBox::Editi
680 if ( pEntry )
682 USHORT nDepth = GetModel()->GetDepth( pEntry );
683 - if ( nDepth == 2 )
684 + if ( nDepth >= 2 )
686 BasicEntryDescriptor aDesc( GetEntryDescriptor( pEntry ) );
687 ScriptDocument aDocument( aDesc.GetDocument() );
688 @@ -165,7 +165,7 @@ DragDropMode __EXPORT ExtBasicTreeListBo
689 if ( pEntry )
691 USHORT nDepth = GetModel()->GetDepth( pEntry );
692 - if ( nDepth == 2 )
693 + if ( nDepth >= 2 )
695 nMode_ = SV_DRAGDROP_CTRL_COPY;
696 BasicEntryDescriptor aDesc( GetEntryDescriptor( pEntry ) );
697 @@ -213,7 +213,7 @@ BOOL __EXPORT ExtBasicTreeListBox::Notif
699 // don't drop on a library, which is not loaded, readonly or password protected
700 // or which already has a module/dialog with this name
701 - if ( bValid && ( nDepth == 1 || nDepth == 2 ) )
702 + if ( bValid && ( nDepth > 0 ) )
704 // get source module/dialog name
705 BasicEntryDescriptor aSourceDesc( GetEntryDescriptor( pSelected ) );
706 @@ -351,7 +351,7 @@ BOOL __EXPORT ExtBasicTreeListBox::Notif
707 rpNewParent = pTarget;
708 rNewChildPos = 0;
710 - else if ( nDepth == 2 )
711 + else if ( nDepth >= 2 )
713 // Target = Modul/Dialog => Modul/Dialog unter das uebergeordnete Basic haengen...
714 rpNewParent = GetParent( pTarget );
715 @@ -626,20 +626,27 @@ void ObjectPage::CheckButtons()
717 // enable/disable edit button
718 SvLBoxEntry* pCurEntry = aBasicBox.GetCurEntry();
719 + BasicEntryDescriptor aDesc( aBasicBox.GetEntryDescriptor( pCurEntry ) );
720 + ScriptDocument aDocument( aDesc.GetDocument() );
721 + ::rtl::OUString aOULibName( aDesc.GetLibName() );
722 + String aLibSubName( aDesc.GetLibSubName() );
723 + BasicManager* pBasMgr = aDocument.getBasicManager();
724 + StarBASIC* pBasic = pBasMgr ? pBasMgr->GetLib( aOULibName ) : 0;
725 + sal_Bool bVBAEnabled = pBasic ? pBasic->isVBAEnabled(): sal_False;
726 + USHORT nMode = aBasicBox.GetMode();
728 USHORT nDepth = pCurEntry ? aBasicBox.GetModel()->GetDepth( pCurEntry ) : 0;
729 - if ( nDepth == 2 )
730 + if ( ( !bVBAEnabled && ( nDepth == 2 ) )
731 + || ( bVBAEnabled && ( nMode & BROWSEMODE_MODULES ) && ( nDepth == 3 ) ) )
732 aEditButton.Enable();
733 else
734 aEditButton.Disable();
736 // enable/disable new module/dialog buttons
737 - BasicEntryDescriptor aDesc( aBasicBox.GetEntryDescriptor( pCurEntry ) );
738 LibraryLocation eLocation( aDesc.GetLocation() );
739 BOOL bReadOnly = FALSE;
740 - if ( nDepth == 1 || nDepth == 2 )
741 + if ( nDepth > 0 )
743 - ScriptDocument aDocument( aDesc.GetDocument() );
744 - ::rtl::OUString aOULibName( aDesc.GetLibName() );
745 Reference< script::XLibraryContainer2 > xModLibContainer( aDocument.getLibraryContainer( E_SCRIPTS ), UNO_QUERY );
746 Reference< script::XLibraryContainer2 > xDlgLibContainer( aDocument.getLibraryContainer( E_DIALOGS ), UNO_QUERY );
747 if ( ( xModLibContainer.is() && xModLibContainer->hasByName( aOULibName ) && xModLibContainer->isLibraryReadOnly( aOULibName ) ) ||
748 @@ -660,7 +667,8 @@ void ObjectPage::CheckButtons()
751 // enable/disable delete button
752 - if ( nDepth == 2 && !bReadOnly && eLocation != LIBRARY_LOCATION_SHARE )
753 + if ( ( ( !bVBAEnabled && nDepth == 2 ) || ( bVBAEnabled && ( nDepth == 3 ) && !aLibSubName.Equals( String( IDEResId( RID_STR_DOCUMENT_OBJECTS ) ) ) ) )
754 + && !bReadOnly && eLocation != LIBRARY_LOCATION_SHARE )
755 aDelButton.Enable();
756 else
757 aDelButton.Disable();
758 @@ -688,13 +696,20 @@ IMPL_LINK( ObjectPage, ButtonHdl, Button
759 SfxDispatcher* pDispatcher = pViewFrame ? pViewFrame->GetDispatcher() : NULL;
760 SvLBoxEntry* pCurEntry = aBasicBox.GetCurEntry();
761 DBG_ASSERT( pCurEntry, "Entry?!" );
762 - if ( aBasicBox.GetModel()->GetDepth( pCurEntry ) == 2 )
763 + if ( aBasicBox.GetModel()->GetDepth( pCurEntry ) >= 2 )
765 BasicEntryDescriptor aDesc( aBasicBox.GetEntryDescriptor( pCurEntry ) );
766 if ( pDispatcher )
768 + String aModName( aDesc.GetName() );
769 + // extract the module name from the string like "Sheet1 (Example1)"
770 + if( aDesc.GetLibSubName().Equals( String( IDEResId( RID_STR_DOCUMENT_OBJECTS ) ) ) )
772 + sal_uInt16 nIndex = 0;
773 + aModName = aModName.GetToken( 0, ' ', nIndex );
775 SbxItem aSbxItem( SID_BASICIDE_ARG_SBX, aDesc.GetDocument(), aDesc.GetLibName(),
776 - aDesc.GetName(), aBasicBox.ConvertType( aDesc.GetType() ) );
777 + aModName, aBasicBox.ConvertType( aDesc.GetType() ) );
778 pDispatcher->Execute( SID_BASICIDE_SHOWSBX, SFX_CALLMODE_SYNCHRON, &aSbxItem, 0L );
781 @@ -976,14 +991,14 @@ SbModule* createModImpl( Window* pWin, c
784 ::rtl::OUString sModuleCode;
785 + // the module has existed
786 + if( rDocument.hasModule( aLibName, aModName ) )
787 + return NULL;
788 rDocument.createModule( aLibName, aModName, bMain, sModuleCode );
789 BasicManager* pBasMgr = rDocument.getBasicManager();
790 - if ( pBasMgr )
792 - StarBASIC* pBasic = pBasMgr->GetLib( aLibName );
793 - if ( pBasic )
794 - pModule = pBasic->FindModule( aModName );
796 + StarBASIC* pBasic = pBasMgr? pBasMgr->GetLib( aLibName ) : 0;
797 + if ( pBasic )
798 + pModule = pBasic->FindModule( aModName );
799 SbxItem aSbxItem( SID_BASICIDE_ARG_SBX, rDocument, aLibName, aModName, BASICIDE_TYPE_MODULE );
800 BasicIDEShell* pIDEShell = IDE_DLL()->GetShell();
801 SfxViewFrame* pViewFrame = pIDEShell ? pIDEShell->GetViewFrame() : NULL;
802 @@ -1005,14 +1020,27 @@ SbModule* createModImpl( Window* pWin, c
804 if ( !rBasicBox.IsExpanded( pLibEntry ) )
805 rBasicBox.Expand( pLibEntry );
806 - SvLBoxEntry* pEntry = rBasicBox.FindEntry( pLibEntry, aModName, OBJ_TYPE_MODULE );
807 + SvLBoxEntry* pSubRootEntry = pLibEntry;
808 + if( pBasic && pBasic->isVBAEnabled() )
810 + // add the new module in the "Modules" entry
811 + SvLBoxEntry* pLibSubEntry = rBasicBox.FindEntry( pLibEntry, String( IDEResId( RID_STR_NORMAL_MODULES ) ) , OBJ_TYPE_NORMAL_MODULES );
812 + if( pLibSubEntry )
814 + if( !rBasicBox.IsExpanded( pLibSubEntry ) )
815 + rBasicBox.Expand( pLibSubEntry );
816 + pSubRootEntry = pLibSubEntry;
820 + SvLBoxEntry* pEntry = rBasicBox.FindEntry( pSubRootEntry, aModName, OBJ_TYPE_MODULE );
821 if ( !pEntry )
823 pEntry = rBasicBox.AddEntry(
824 aModName,
825 Image( IDEResId( RID_IMG_MODULE ) ),
826 Image( IDEResId( RID_IMG_MODULE_HC ) ),
827 - pLibEntry, false,
828 + pSubRootEntry, false,
829 std::auto_ptr< BasicEntry >( new BasicEntry( OBJ_TYPE_MODULE ) ) );
830 DBG_ASSERT( pEntry, "InsertEntry fehlgeschlagen!" );