1 /************************************************************** 2 * 3 * Licensed to the Apache Software Foundation (ASF) under one 4 * or more contributor license agreements. See the NOTICE file 5 * distributed with this work for additional information 6 * regarding copyright ownership. The ASF licenses this file 7 * to you under the Apache License, Version 2.0 (the 8 * "License"); you may not use this file except in compliance 9 * with the License. You may obtain a copy of the License at 10 * 11 * http://www.apache.org/licenses/LICENSE-2.0 12 * 13 * Unless required by applicable law or agreed to in writing, 14 * software distributed under the License is distributed on an 15 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16 * KIND, either express or implied. See the License for the 17 * specific language governing permissions and limitations 18 * under the License. 19 * 20 *************************************************************/ 21 22 23 24 // MARKER(update_precomp.py): autogen include statement, do not remove 25 #include "precompiled_basctl.hxx" 26 27 #include <memory> 28 29 #include <ide_pch.hxx> 30 31 32 #include <moduldlg.hrc> 33 #include <moduldlg.hxx> 34 #include <basidesh.hrc> 35 #include <basidesh.hxx> 36 #include <bastypes.hxx> 37 #include <baside3.hxx> 38 #include <basobj.hxx> 39 #include <baside2.hrc> 40 #include <sbxitem.hxx> 41 #include <iderdll.hxx> 42 43 #ifndef _COM_SUN_STAR_IO_XINPUTSTREAMPROVIDER_HXX_ 44 #include <com/sun/star/io/XInputStreamProvider.hpp> 45 #endif 46 #ifndef _COM_SUN_STAR_SCRIPT_XLIBRYARYCONTAINER2_HPP_ 47 #include <com/sun/star/script/XLibraryContainer2.hpp> 48 #endif 49 #include <com/sun/star/script/XLibraryContainerPassword.hpp> 50 #include <com/sun/star/resource/XStringResourceManager.hpp> 51 #include <com/sun/star/lang/XMultiServiceFactory.hpp> 52 #include <comphelper/processfactory.hxx> 53 #include <xmlscript/xmldlg_imexp.hxx> 54 55 #include "localizationmgr.hxx" 56 #include <basic/sbx.hxx> 57 #include <tools/diagnose_ex.h> 58 59 using namespace ::com::sun::star; 60 using namespace ::com::sun::star::uno; 61 using namespace ::com::sun::star::lang; 62 using namespace ::com::sun::star::resource; 63 64 65 ExtBasicTreeListBox::ExtBasicTreeListBox( Window* pParent, const ResId& rRes ) 66 : BasicTreeListBox( pParent, rRes ) 67 { 68 } 69 70 71 72 ExtBasicTreeListBox::~ExtBasicTreeListBox() 73 { 74 } 75 76 sal_Bool __EXPORT ExtBasicTreeListBox::EditingEntry( SvLBoxEntry* pEntry, Selection& ) 77 { 78 sal_Bool bRet = sal_False; 79 80 if ( pEntry ) 81 { 82 sal_uInt16 nDepth = GetModel()->GetDepth( pEntry ); 83 if ( nDepth >= 2 ) 84 { 85 BasicEntryDescriptor aDesc( GetEntryDescriptor( pEntry ) ); 86 ScriptDocument aDocument( aDesc.GetDocument() ); 87 ::rtl::OUString aOULibName( aDesc.GetLibName() ); 88 Reference< script::XLibraryContainer2 > xModLibContainer( aDocument.getLibraryContainer( E_SCRIPTS ), UNO_QUERY ); 89 Reference< script::XLibraryContainer2 > xDlgLibContainer( aDocument.getLibraryContainer( E_DIALOGS ), UNO_QUERY ); 90 if ( !( ( xModLibContainer.is() && xModLibContainer->hasByName( aOULibName ) && xModLibContainer->isLibraryReadOnly( aOULibName ) ) || 91 ( xDlgLibContainer.is() && xDlgLibContainer->hasByName( aOULibName ) && xDlgLibContainer->isLibraryReadOnly( aOULibName ) ) ) ) 92 { 93 // allow editing only for libraries, which are not readonly 94 bRet = sal_True; 95 } 96 } 97 } 98 99 return bRet; 100 } 101 102 sal_Bool __EXPORT ExtBasicTreeListBox::EditedEntry( SvLBoxEntry* pEntry, const String& rNewText ) 103 { 104 sal_Bool bValid = BasicIDE::IsValidSbxName( rNewText ); 105 if ( !bValid ) 106 { 107 ErrorBox( this, WB_OK | WB_DEF_OK, String( IDEResId( RID_STR_BADSBXNAME ) ) ).Execute(); 108 return sal_False; 109 } 110 111 String aCurText( GetEntryText( pEntry ) ); 112 if ( aCurText == rNewText ) 113 // nothing to do 114 return sal_True; 115 116 BasicEntryDescriptor aDesc( GetEntryDescriptor( pEntry ) ); 117 ScriptDocument aDocument( aDesc.GetDocument() ); 118 DBG_ASSERT( aDocument.isValid(), "ExtBasicTreeListBox::EditedEntry: no document!" ); 119 if ( !aDocument.isValid() ) 120 return sal_False; 121 String aLibName( aDesc.GetLibName() ); 122 BasicEntryType eType( aDesc.GetType() ); 123 124 bool bSuccess = ( eType == OBJ_TYPE_MODULE ) 125 ? BasicIDE::RenameModule( this, aDocument, aLibName, aCurText, rNewText ) 126 : BasicIDE::RenameDialog( this, aDocument, aLibName, aCurText, rNewText ); 127 128 if ( !bSuccess ) 129 return sal_False; 130 131 BasicIDE::MarkDocumentModified( aDocument ); 132 133 BasicIDEShell* pIDEShell = IDE_DLL()->GetShell(); 134 SfxViewFrame* pViewFrame = pIDEShell ? pIDEShell->GetViewFrame() : NULL; 135 SfxDispatcher* pDispatcher = pViewFrame ? pViewFrame->GetDispatcher() : NULL; 136 if( pDispatcher ) 137 { 138 SbxItem aSbxItem( SID_BASICIDE_ARG_SBX, aDocument, aLibName, rNewText, ConvertType( eType ) ); 139 pDispatcher->Execute( SID_BASICIDE_SBXRENAMED, 140 SFX_CALLMODE_SYNCHRON, &aSbxItem, 0L ); 141 } 142 143 // OV-Bug?! 144 SetEntryText( pEntry, rNewText ); 145 SetCurEntry( pEntry ); 146 SetCurEntry( pEntry ); 147 Select( pEntry, sal_False ); 148 Select( pEntry ); // damit Handler gerufen wird => Edit updaten 149 150 return sal_True; 151 } 152 153 154 DragDropMode __EXPORT ExtBasicTreeListBox::NotifyStartDrag( TransferDataContainer&, SvLBoxEntry* pEntry ) 155 { 156 DragDropMode nMode_ = SV_DRAGDROP_NONE; 157 158 if ( pEntry ) 159 { 160 sal_uInt16 nDepth = GetModel()->GetDepth( pEntry ); 161 if ( nDepth >= 2 ) 162 { 163 nMode_ = SV_DRAGDROP_CTRL_COPY; 164 BasicEntryDescriptor aDesc( GetEntryDescriptor( pEntry ) ); 165 ScriptDocument aDocument( aDesc.GetDocument() ); 166 ::rtl::OUString aOULibName( aDesc.GetLibName() ); 167 // allow MOVE mode only for libraries, which are not readonly 168 Reference< script::XLibraryContainer2 > xModLibContainer( aDocument.getLibraryContainer( E_SCRIPTS ), UNO_QUERY ); 169 Reference< script::XLibraryContainer2 > xDlgLibContainer( aDocument.getLibraryContainer( E_DIALOGS ), UNO_QUERY ); 170 if ( !( ( xModLibContainer.is() && xModLibContainer->hasByName( aOULibName ) && xModLibContainer->isLibraryReadOnly( aOULibName ) ) || 171 ( xDlgLibContainer.is() && xDlgLibContainer->hasByName( aOULibName ) && xDlgLibContainer->isLibraryReadOnly( aOULibName ) ) ) ) 172 { 173 // Only allow copy for localized libraries 174 bool bAllowMove = true; 175 if ( xDlgLibContainer.is() && xDlgLibContainer->hasByName( aOULibName ) ) 176 { 177 // Get StringResourceManager 178 Reference< container::XNameContainer > xDialogLib( aDocument.getLibrary( E_DIALOGS, aOULibName, sal_True ) ); 179 Reference< XStringResourceManager > xSourceMgr = 180 LocalizationMgr::getStringResourceFromDialogLibrary( xDialogLib ); 181 if( xSourceMgr.is() ) 182 bAllowMove = ( xSourceMgr->getLocales().getLength() == 0 ); 183 } 184 if( bAllowMove ) 185 nMode_ |= SV_DRAGDROP_CTRL_MOVE; 186 } 187 } 188 } 189 190 return nMode_; 191 } 192 193 194 sal_Bool __EXPORT ExtBasicTreeListBox::NotifyAcceptDrop( SvLBoxEntry* pEntry ) 195 { 196 // don't drop on a BasicManager (nDepth == 0) 197 sal_uInt16 nDepth = pEntry ? GetModel()->GetDepth( pEntry ) : 0; 198 sal_Bool bValid = nDepth ? sal_True : sal_False; 199 200 // don't drop in the same library 201 SvLBoxEntry* pSelected = FirstSelected(); 202 if ( ( nDepth == 1 ) && ( pEntry == GetParent( pSelected ) ) ) 203 bValid = sal_False; 204 else if ( ( nDepth == 2 ) && ( GetParent( pEntry ) == GetParent( pSelected ) ) ) 205 bValid = sal_False; 206 207 // don't drop on a library, which is not loaded, readonly or password protected 208 // or which already has a module/dialog with this name 209 if ( bValid && ( nDepth > 0 ) ) 210 { 211 // get source module/dialog name 212 BasicEntryDescriptor aSourceDesc( GetEntryDescriptor( pSelected ) ); 213 String aSourceName( aSourceDesc.GetName() ); 214 BasicEntryType eSourceType( aSourceDesc.GetType() ); 215 216 // get target shell and target library name 217 BasicEntryDescriptor aDestDesc( GetEntryDescriptor( pEntry ) ); 218 const ScriptDocument& rDestDoc( aDestDesc.GetDocument() ); 219 String aDestLibName( aDestDesc.GetLibName() ); 220 ::rtl::OUString aOUDestLibName( aDestLibName ); 221 222 // check if module library is not loaded, readonly or password protected 223 Reference< script::XLibraryContainer2 > xModLibContainer( rDestDoc.getLibraryContainer( E_SCRIPTS ), UNO_QUERY ); 224 if ( xModLibContainer.is() && xModLibContainer->hasByName( aOUDestLibName ) ) 225 { 226 if ( !xModLibContainer->isLibraryLoaded( aOUDestLibName ) ) 227 bValid = sal_False; 228 229 if ( xModLibContainer->isLibraryReadOnly( aOUDestLibName ) ) 230 bValid = sal_False; 231 232 Reference< script::XLibraryContainerPassword > xPasswd( xModLibContainer, UNO_QUERY ); 233 if ( xPasswd.is() && xPasswd->isLibraryPasswordProtected( aOUDestLibName ) && !xPasswd->isLibraryPasswordVerified( aOUDestLibName ) ) 234 bValid = sal_False; 235 } 236 237 // check if dialog library is not loaded or readonly 238 Reference< script::XLibraryContainer2 > xDlgLibContainer( rDestDoc.getLibraryContainer( E_DIALOGS ), UNO_QUERY ); 239 if ( xDlgLibContainer.is() && xDlgLibContainer->hasByName( aOUDestLibName ) ) 240 { 241 if ( !xDlgLibContainer->isLibraryLoaded( aOUDestLibName ) ) 242 bValid = sal_False; 243 244 if ( xDlgLibContainer->isLibraryReadOnly( aOUDestLibName ) ) 245 bValid = sal_False; 246 } 247 248 // check, if module/dialog with this name is already existing in target library 249 if ( ( eSourceType == OBJ_TYPE_MODULE && rDestDoc.hasModule( aDestLibName, aSourceName ) ) || 250 ( eSourceType == OBJ_TYPE_DIALOG && rDestDoc.hasDialog( aDestLibName, aSourceName ) ) ) 251 { 252 bValid = sal_False; 253 } 254 } 255 256 return bValid; 257 } 258 259 260 sal_Bool __EXPORT ExtBasicTreeListBox::NotifyMoving( SvLBoxEntry* pTarget, SvLBoxEntry* pEntry, 261 SvLBoxEntry*& rpNewParent, sal_uLong& rNewChildPos ) 262 { 263 return NotifyCopyingMoving( pTarget, pEntry, 264 rpNewParent, rNewChildPos, sal_True ); 265 } 266 267 268 sal_Bool __EXPORT ExtBasicTreeListBox::NotifyCopying( SvLBoxEntry* pTarget, SvLBoxEntry* pEntry, 269 SvLBoxEntry*& rpNewParent, sal_uLong& rNewChildPos ) 270 { 271 // return sal_False; // Wie kopiere ich ein SBX ?! 272 return NotifyCopyingMoving( pTarget, pEntry, 273 rpNewParent, rNewChildPos, sal_False ); 274 } 275 276 277 void BasicIDEShell::CopyDialogResources( Reference< io::XInputStreamProvider >& io_xISP, 278 const ScriptDocument& rSourceDoc, const String& rSourceLibName, const ScriptDocument& rDestDoc, 279 const String& rDestLibName, const String& rDlgName ) 280 { 281 if ( !io_xISP.is() ) 282 return; 283 284 // Get StringResourceManager 285 Reference< container::XNameContainer > xSourceDialogLib( rSourceDoc.getLibrary( E_DIALOGS, rSourceLibName, sal_True ) ); 286 Reference< XStringResourceManager > xSourceMgr = 287 LocalizationMgr::getStringResourceFromDialogLibrary( xSourceDialogLib ); 288 if( !xSourceMgr.is() ) 289 return; 290 bool bSourceLocalized = ( xSourceMgr->getLocales().getLength() > 0 ); 291 292 Reference< container::XNameContainer > xDestDialogLib( rDestDoc.getLibrary( E_DIALOGS, rDestLibName, sal_True ) ); 293 Reference< XStringResourceManager > xDestMgr = 294 LocalizationMgr::getStringResourceFromDialogLibrary( xDestDialogLib ); 295 if( !xDestMgr.is() ) 296 return; 297 bool bDestLocalized = ( xDestMgr->getLocales().getLength() > 0 ); 298 299 if( !bSourceLocalized && !bDestLocalized ) 300 return; 301 302 // create dialog model 303 Reference< lang::XMultiServiceFactory > xMSF = ::comphelper::getProcessServiceFactory(); 304 Reference< container::XNameContainer > xDialogModel = Reference< container::XNameContainer >( xMSF->createInstance 305 ( ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.awt.UnoControlDialogModel" ) ) ), UNO_QUERY ); 306 Reference< io::XInputStream > xInput( io_xISP->createInputStream() ); 307 Reference< XComponentContext > xContext; 308 Reference< beans::XPropertySet > xProps( xMSF, UNO_QUERY ); 309 OSL_ASSERT( xProps.is() ); 310 OSL_VERIFY( xProps->getPropertyValue( ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("DefaultContext")) ) >>= xContext ); 311 ::xmlscript::importDialogModel( xInput, xDialogModel, xContext ); 312 313 if( xDialogModel.is() ) 314 { 315 if( bSourceLocalized && bDestLocalized ) 316 { 317 Reference< resource::XStringResourceResolver > xSourceStringResolver( xSourceMgr, UNO_QUERY ); 318 LocalizationMgr::copyResourceForDroppedDialog( xDialogModel, rDlgName, xDestMgr, xSourceStringResolver ); 319 } 320 else if( bSourceLocalized ) 321 { 322 LocalizationMgr::resetResourceForDialog( xDialogModel, xSourceMgr ); 323 } 324 else if( bDestLocalized ) 325 { 326 LocalizationMgr::setResourceIDsForDialog( xDialogModel, xDestMgr ); 327 } 328 io_xISP = ::xmlscript::exportDialogModel( xDialogModel, xContext ); 329 } 330 } 331 332 333 sal_Bool __EXPORT ExtBasicTreeListBox::NotifyCopyingMoving( SvLBoxEntry* pTarget, SvLBoxEntry* pEntry, 334 SvLBoxEntry*& rpNewParent, sal_uLong& rNewChildPos, sal_Bool bMove ) 335 { 336 (void)pEntry; 337 DBG_ASSERT( pEntry, "Kein Eintrag?" ); // Hier ASS ok, sollte nicht mit 338 DBG_ASSERT( pTarget, "Kein Ziel?" ); // NULL (ganz vorne) erreicht werden 339 sal_uInt16 nDepth = GetModel()->GetDepth( pTarget ); 340 DBG_ASSERT( nDepth, "Tiefe?" ); 341 if ( nDepth == 1 ) 342 { 343 // Target = Basic => Modul/Dialog unter das Basic haengen... 344 rpNewParent = pTarget; 345 rNewChildPos = 0; 346 } 347 else if ( nDepth >= 2 ) 348 { 349 // Target = Modul/Dialog => Modul/Dialog unter das uebergeordnete Basic haengen... 350 rpNewParent = GetParent( pTarget ); 351 rNewChildPos = GetModel()->GetRelPos( pTarget ) + 1; 352 } 353 354 // get target shell and target library name 355 BasicEntryDescriptor aDestDesc( GetEntryDescriptor( rpNewParent ) ); 356 const ScriptDocument& rDestDoc( aDestDesc.GetDocument() ); 357 String aDestLibName( aDestDesc.GetLibName() ); 358 359 // get source shell, library name and module/dialog name 360 BasicEntryDescriptor aSourceDesc( GetEntryDescriptor( FirstSelected() ) ); 361 const ScriptDocument rSourceDoc( aSourceDesc.GetDocument() ); 362 String aSourceLibName( aSourceDesc.GetLibName() ); 363 String aSourceName( aSourceDesc.GetName() ); 364 BasicEntryType eType( aSourceDesc.GetType() ); 365 366 // get dispatcher 367 BasicIDEShell* pIDEShell = IDE_DLL()->GetShell(); 368 SfxViewFrame* pViewFrame = pIDEShell ? pIDEShell->GetViewFrame() : NULL; 369 SfxDispatcher* pDispatcher = pViewFrame ? pViewFrame->GetDispatcher() : NULL; 370 371 if ( bMove ) // move 372 { 373 // remove source module/dialog window 374 if ( rSourceDoc != rDestDoc || aSourceLibName != aDestLibName ) 375 { 376 if( pDispatcher ) 377 { 378 SbxItem aSbxItem( SID_BASICIDE_ARG_SBX, rSourceDoc, aSourceLibName, aSourceName, ConvertType( eType ) ); 379 pDispatcher->Execute( SID_BASICIDE_SBXDELETED, 380 SFX_CALLMODE_SYNCHRON, &aSbxItem, 0L ); 381 } 382 } 383 384 try 385 { 386 if ( eType == OBJ_TYPE_MODULE ) // module 387 { 388 // get module 389 ::rtl::OUString aModule; 390 if ( rSourceDoc.getModule( aSourceLibName, aSourceName, aModule ) ) 391 { 392 // remove module from source library 393 if ( rSourceDoc.removeModule( aSourceLibName, aSourceName ) ) 394 { 395 BasicIDE::MarkDocumentModified( rSourceDoc ); 396 397 // insert module into target library 398 if ( rDestDoc.insertModule( aDestLibName, aSourceName, aModule ) ) 399 BasicIDE::MarkDocumentModified( rDestDoc ); 400 } 401 } 402 } 403 else if ( eType == OBJ_TYPE_DIALOG ) // dialog 404 { 405 // get dialog 406 Reference< io::XInputStreamProvider > xISP; 407 if ( rSourceDoc.getDialog( aSourceLibName, aSourceName, xISP ) ) 408 { 409 BasicIDEShell::CopyDialogResources( xISP, rSourceDoc, 410 aSourceLibName, rDestDoc, aDestLibName, aSourceName ); 411 412 // remove dialog from source library 413 if ( BasicIDE::RemoveDialog( rSourceDoc, aSourceLibName, aSourceName ) ) 414 { 415 BasicIDE::MarkDocumentModified( rSourceDoc ); 416 417 // insert dialog into target library 418 if ( rDestDoc.insertDialog( aDestLibName, aSourceName, xISP ) ) 419 BasicIDE::MarkDocumentModified( rDestDoc ); 420 } 421 } 422 } 423 } 424 catch ( uno::Exception& ) 425 { 426 DBG_UNHANDLED_EXCEPTION(); 427 } 428 } 429 else // copy 430 { 431 try 432 { 433 if ( eType == OBJ_TYPE_MODULE ) // module 434 { 435 // get module 436 ::rtl::OUString aModule; 437 if ( rSourceDoc.getModule( aSourceLibName, aSourceName, aModule ) ) 438 { 439 // insert module into target library 440 if ( rDestDoc.insertModule( aDestLibName, aSourceName, aModule ) ) 441 BasicIDE::MarkDocumentModified( rDestDoc ); 442 } 443 } 444 else if ( eType == OBJ_TYPE_DIALOG ) // dialog 445 { 446 // get dialog 447 Reference< io::XInputStreamProvider > xISP; 448 if ( rSourceDoc.getDialog( aSourceLibName, aSourceName, xISP ) ) 449 { 450 BasicIDEShell::CopyDialogResources( xISP, rSourceDoc, 451 aSourceLibName, rDestDoc, aDestLibName, aSourceName ); 452 453 // insert dialog into target library 454 if ( rDestDoc.insertDialog( aDestLibName, aSourceName, xISP ) ) 455 BasicIDE::MarkDocumentModified( rDestDoc ); 456 } 457 } 458 } 459 catch ( const Exception& ) 460 { 461 DBG_UNHANDLED_EXCEPTION(); 462 } 463 } 464 465 // create target module/dialog window 466 if ( rSourceDoc != rDestDoc || aSourceLibName != aDestLibName ) 467 { 468 if( pDispatcher ) 469 { 470 SbxItem aSbxItem( SID_BASICIDE_ARG_SBX, rDestDoc, aDestLibName, aSourceName, ConvertType( eType ) ); 471 pDispatcher->Execute( SID_BASICIDE_SBXINSERTED, 472 SFX_CALLMODE_SYNCHRON, &aSbxItem, 0L ); 473 } 474 } 475 476 return 2; // Aufklappen... 477 } 478 479 OrganizeDialog::OrganizeDialog( Window* pParent, sal_Int16 tabId, BasicEntryDescriptor& rDesc ) 480 :TabDialog( pParent, IDEResId( RID_TD_ORGANIZE ) ) 481 ,aTabCtrl( this, IDEResId( RID_TC_ORGANIZE ) ) 482 ,m_aCurEntry( rDesc ) 483 { 484 FreeResource(); 485 aTabCtrl.SetActivatePageHdl( LINK( this, OrganizeDialog, ActivatePageHdl ) ); 486 if( tabId == 0 ) 487 { 488 aTabCtrl.SetCurPageId( RID_TP_MOD ); 489 } 490 else if ( tabId == 1 ) 491 { 492 aTabCtrl.SetCurPageId( RID_TP_DLG ); 493 } 494 else 495 { 496 aTabCtrl.SetCurPageId( RID_TP_LIB ); 497 } 498 499 ActivatePageHdl( &aTabCtrl ); 500 501 BasicIDEShell* pIDEShell = IDE_DLL()->GetShell(); 502 SfxViewFrame* pViewFrame = pIDEShell ? pIDEShell->GetViewFrame() : NULL; 503 SfxDispatcher* pDispatcher = pViewFrame ? pViewFrame->GetDispatcher() : NULL; 504 if( pDispatcher ) 505 { 506 pDispatcher->Execute( SID_BASICIDE_STOREALLMODULESOURCES ); 507 } 508 } 509 510 __EXPORT OrganizeDialog::~OrganizeDialog() 511 { 512 for ( sal_uInt16 i = 0; i < aTabCtrl.GetPageCount(); i++ ) 513 delete aTabCtrl.GetTabPage( aTabCtrl.GetPageId( i ) ); 514 }; 515 516 short OrganizeDialog::Execute() 517 { 518 Window* pPrevDlgParent = Application::GetDefDialogParent(); 519 Application::SetDefDialogParent( this ); 520 short nRet = TabDialog::Execute(); 521 Application::SetDefDialogParent( pPrevDlgParent ); 522 return nRet; 523 } 524 525 526 IMPL_LINK( OrganizeDialog, ActivatePageHdl, TabControl *, pTabCtrl ) 527 { 528 sal_uInt16 nId = pTabCtrl->GetCurPageId(); 529 // Wenn TabPage noch nicht erzeugt wurde, dann erzeugen 530 if ( !pTabCtrl->GetTabPage( nId ) ) 531 { 532 TabPage* pNewTabPage = 0; 533 switch ( nId ) 534 { 535 case RID_TP_MOD: 536 { 537 pNewTabPage = new ObjectPage( pTabCtrl, IDEResId( RID_TP_MODULS ), BROWSEMODE_MODULES ); 538 ((ObjectPage*)pNewTabPage)->SetTabDlg( this ); 539 ((ObjectPage*)pNewTabPage)->SetCurrentEntry( m_aCurEntry ); 540 } 541 break; 542 case RID_TP_DLG: 543 { 544 pNewTabPage = new ObjectPage( pTabCtrl, IDEResId( RID_TP_DLGS ), BROWSEMODE_DIALOGS ); 545 ((ObjectPage*)pNewTabPage)->SetTabDlg( this ); 546 ((ObjectPage*)pNewTabPage)->SetCurrentEntry( m_aCurEntry ); 547 } 548 break; 549 case RID_TP_LIB: 550 { 551 pNewTabPage = new LibPage( pTabCtrl ); 552 ((LibPage*)pNewTabPage)->SetTabDlg( this ); 553 } 554 break; 555 default: DBG_ERROR( "PageHdl: Unbekannte ID!" ); 556 } 557 DBG_ASSERT( pNewTabPage, "Keine Page!" ); 558 pTabCtrl->SetTabPage( nId, pNewTabPage ); 559 } 560 return 0; 561 } 562 563 ObjectPage::ObjectPage( Window * pParent, const ResId& rResId, sal_uInt16 nMode ) : 564 TabPage( pParent, rResId ), 565 aLibText( this, IDEResId( RID_STR_LIB ) ), 566 aBasicBox( this, IDEResId( RID_TRLBOX ) ), 567 aEditButton( this, IDEResId( RID_PB_EDIT ) ), 568 aCloseButton( this, IDEResId( RID_PB_CLOSE ) ), 569 aNewModButton( this, IDEResId( RID_PB_NEWMOD ) ), 570 aNewDlgButton( this, IDEResId( RID_PB_NEWDLG ) ), 571 aDelButton( this, IDEResId( RID_PB_DELETE ) ) 572 { 573 FreeResource(); 574 pTabDlg = 0; 575 576 aEditButton.SetClickHdl( LINK( this, ObjectPage, ButtonHdl ) ); 577 aDelButton.SetClickHdl( LINK( this, ObjectPage, ButtonHdl ) ); 578 aCloseButton.SetClickHdl( LINK( this, ObjectPage, ButtonHdl ) ); 579 aBasicBox.SetSelectHdl( LINK( this, ObjectPage, BasicBoxHighlightHdl ) ); 580 581 if( nMode & BROWSEMODE_MODULES ) 582 { 583 aNewModButton.SetClickHdl( LINK( this, ObjectPage, ButtonHdl ) ); 584 aNewDlgButton.Hide(); 585 } 586 else if ( nMode & BROWSEMODE_DIALOGS ) 587 { 588 aNewDlgButton.SetClickHdl( LINK( this, ObjectPage, ButtonHdl ) ); 589 aNewModButton.Hide(); 590 } 591 592 aBasicBox.SetDragDropMode( SV_DRAGDROP_CTRL_MOVE | SV_DRAGDROP_CTRL_COPY ); 593 aBasicBox.EnableInplaceEditing( sal_True ); 594 aBasicBox.SetMode( nMode ); 595 aBasicBox.SetStyle( WB_BORDER | WB_TABSTOP | 596 WB_HASLINES | WB_HASLINESATROOT | 597 WB_HASBUTTONS | WB_HASBUTTONSATROOT | 598 WB_HSCROLL ); 599 aBasicBox.ScanAllEntries(); 600 601 aEditButton.GrabFocus(); 602 CheckButtons(); 603 } 604 605 void ObjectPage::SetCurrentEntry( BasicEntryDescriptor& rDesc ) 606 { 607 aBasicBox.SetCurrentEntry( rDesc ); 608 } 609 610 void __EXPORT ObjectPage::ActivatePage() 611 { 612 aBasicBox.UpdateEntries(); 613 } 614 615 void __EXPORT ObjectPage::DeactivatePage() 616 { 617 } 618 619 void ObjectPage::CheckButtons() 620 { 621 // enable/disable edit button 622 SvLBoxEntry* pCurEntry = aBasicBox.GetCurEntry(); 623 BasicEntryDescriptor aDesc( aBasicBox.GetEntryDescriptor( pCurEntry ) ); 624 ScriptDocument aDocument( aDesc.GetDocument() ); 625 ::rtl::OUString aOULibName( aDesc.GetLibName() ); 626 String aLibSubName( aDesc.GetLibSubName() ); 627 sal_Bool bVBAEnabled = aDocument.isInVBAMode(); 628 sal_uInt16 nMode = aBasicBox.GetMode(); 629 630 sal_uInt16 nDepth = pCurEntry ? aBasicBox.GetModel()->GetDepth( pCurEntry ) : 0; 631 if ( nDepth >= 2 ) 632 { 633 if( bVBAEnabled && ( nMode & BROWSEMODE_MODULES ) && ( nDepth == 2 ) ) 634 aEditButton.Disable(); 635 else 636 aEditButton.Enable(); 637 } 638 else 639 aEditButton.Disable(); 640 641 // enable/disable new module/dialog buttons 642 LibraryLocation eLocation( aDesc.GetLocation() ); 643 sal_Bool bReadOnly = sal_False; 644 if ( nDepth > 0 ) 645 { 646 Reference< script::XLibraryContainer2 > xModLibContainer( aDocument.getLibraryContainer( E_SCRIPTS ), UNO_QUERY ); 647 Reference< script::XLibraryContainer2 > xDlgLibContainer( aDocument.getLibraryContainer( E_DIALOGS ), UNO_QUERY ); 648 if ( ( xModLibContainer.is() && xModLibContainer->hasByName( aOULibName ) && xModLibContainer->isLibraryReadOnly( aOULibName ) ) || 649 ( xDlgLibContainer.is() && xDlgLibContainer->hasByName( aOULibName ) && xDlgLibContainer->isLibraryReadOnly( aOULibName ) ) ) 650 { 651 bReadOnly = sal_True; 652 } 653 } 654 if ( bReadOnly || eLocation == LIBRARY_LOCATION_SHARE ) 655 { 656 aNewModButton.Disable(); 657 aNewDlgButton.Disable(); 658 } 659 else 660 { 661 aNewModButton.Enable(); 662 aNewDlgButton.Enable(); 663 } 664 665 // enable/disable delete button 666 if ( nDepth >= 2 && !bReadOnly && eLocation != LIBRARY_LOCATION_SHARE ) 667 { 668 if( bVBAEnabled && ( nMode & BROWSEMODE_MODULES ) && ( ( nDepth == 2 ) || aLibSubName.Equals( String( IDEResId( RID_STR_DOCUMENT_OBJECTS ) ) ) ) ) 669 aDelButton.Disable(); 670 else 671 aDelButton.Enable(); 672 } 673 else 674 aDelButton.Disable(); 675 } 676 677 IMPL_LINK( ObjectPage, BasicBoxHighlightHdl, BasicTreeListBox *, pBox ) 678 { 679 if ( !pBox->IsSelected( pBox->GetHdlEntry() ) ) 680 return 0; 681 682 CheckButtons(); 683 return 0; 684 } 685 686 IMPL_LINK( ObjectPage, ButtonHdl, Button *, pButton ) 687 { 688 if ( pButton == &aEditButton ) 689 { 690 SfxAllItemSet aArgs( SFX_APP()->GetPool() ); 691 SfxRequest aRequest( SID_BASICIDE_APPEAR, SFX_CALLMODE_SYNCHRON, aArgs ); 692 SFX_APP()->ExecuteSlot( aRequest ); 693 694 BasicIDEShell* pIDEShell = IDE_DLL()->GetShell(); 695 SfxViewFrame* pViewFrame = pIDEShell ? pIDEShell->GetViewFrame() : NULL; 696 SfxDispatcher* pDispatcher = pViewFrame ? pViewFrame->GetDispatcher() : NULL; 697 SvLBoxEntry* pCurEntry = aBasicBox.GetCurEntry(); 698 DBG_ASSERT( pCurEntry, "Entry?!" ); 699 if ( aBasicBox.GetModel()->GetDepth( pCurEntry ) >= 2 ) 700 { 701 BasicEntryDescriptor aDesc( aBasicBox.GetEntryDescriptor( pCurEntry ) ); 702 if ( pDispatcher ) 703 { 704 String aModName( aDesc.GetName() ); 705 // extract the module name from the string like "Sheet1 (Example1)" 706 if( aDesc.GetLibSubName().Equals( String( IDEResId( RID_STR_DOCUMENT_OBJECTS ) ) ) ) 707 { 708 sal_uInt16 nIndex = 0; 709 aModName = aModName.GetToken( 0, ' ', nIndex ); 710 } 711 SbxItem aSbxItem( SID_BASICIDE_ARG_SBX, aDesc.GetDocument(), aDesc.GetLibName(), 712 aModName, aBasicBox.ConvertType( aDesc.GetType() ) ); 713 pDispatcher->Execute( SID_BASICIDE_SHOWSBX, SFX_CALLMODE_SYNCHRON, &aSbxItem, 0L ); 714 } 715 } 716 else // Nur Lib selektiert 717 { 718 DBG_ASSERT( aBasicBox.GetModel()->GetDepth( pCurEntry ) == 1, "Kein LibEntry?!" ); 719 ScriptDocument aDocument( ScriptDocument::getApplicationScriptDocument() ); 720 SvLBoxEntry* pParentEntry = aBasicBox.GetParent( pCurEntry ); 721 if ( pParentEntry ) 722 { 723 BasicDocumentEntry* pBasicDocumentEntry = (BasicDocumentEntry*)pParentEntry->GetUserData(); 724 if ( pBasicDocumentEntry ) 725 aDocument = pBasicDocumentEntry->GetDocument(); 726 } 727 SfxUsrAnyItem aDocItem( SID_BASICIDE_ARG_DOCUMENT_MODEL, makeAny( aDocument.getDocumentOrNull() ) ); 728 String aLibName( aBasicBox.GetEntryText( pCurEntry ) ); 729 SfxStringItem aLibNameItem( SID_BASICIDE_ARG_LIBNAME, aLibName ); 730 if ( pDispatcher ) 731 { 732 pDispatcher->Execute( SID_BASICIDE_LIBSELECTED, SFX_CALLMODE_ASYNCHRON, &aDocItem, &aLibNameItem, 0L ); 733 } 734 } 735 EndTabDialog( 1 ); 736 } 737 else if ( pButton == &aNewModButton ) 738 NewModule(); 739 else if ( pButton == &aNewDlgButton ) 740 NewDialog(); 741 else if ( pButton == &aDelButton ) 742 DeleteCurrent(); 743 else if ( pButton == &aCloseButton ) 744 EndTabDialog( 0 ); 745 746 return 0; 747 } 748 749 bool ObjectPage::GetSelection( ScriptDocument& rDocument, String& rLibName ) 750 { 751 bool bRet = false; 752 753 SvLBoxEntry* pCurEntry = aBasicBox.GetCurEntry(); 754 BasicEntryDescriptor aDesc( aBasicBox.GetEntryDescriptor( pCurEntry ) ); 755 rDocument = aDesc.GetDocument(); 756 rLibName = aDesc.GetLibName(); 757 if ( !rLibName.Len() ) 758 rLibName = String::CreateFromAscii( "Standard" ); 759 760 DBG_ASSERT( rDocument.isAlive(), "ObjectPage::GetSelection: no or dead ScriptDocument in the selection!" ); 761 if ( !rDocument.isAlive() ) 762 return false; 763 764 // check if the module library is loaded 765 sal_Bool bOK = sal_True; 766 ::rtl::OUString aOULibName( rLibName ); 767 Reference< script::XLibraryContainer > xModLibContainer( rDocument.getLibraryContainer( E_SCRIPTS ) ); 768 if ( xModLibContainer.is() && xModLibContainer->hasByName( aOULibName ) && !xModLibContainer->isLibraryLoaded( aOULibName ) ) 769 { 770 // check password 771 Reference< script::XLibraryContainerPassword > xPasswd( xModLibContainer, UNO_QUERY ); 772 if ( xPasswd.is() && xPasswd->isLibraryPasswordProtected( aOULibName ) && !xPasswd->isLibraryPasswordVerified( aOULibName ) ) 773 { 774 String aPassword; 775 bOK = QueryPassword( xModLibContainer, rLibName, aPassword ); 776 } 777 778 // load library 779 if ( bOK ) 780 xModLibContainer->loadLibrary( aOULibName ); 781 } 782 783 // check if the dialog library is loaded 784 Reference< script::XLibraryContainer > xDlgLibContainer( rDocument.getLibraryContainer( E_DIALOGS ) ); 785 if ( xDlgLibContainer.is() && xDlgLibContainer->hasByName( aOULibName ) && !xDlgLibContainer->isLibraryLoaded( aOULibName ) ) 786 { 787 // load library 788 if ( bOK ) 789 xDlgLibContainer->loadLibrary( aOULibName ); 790 } 791 792 if ( bOK ) 793 bRet = true; 794 795 return bRet; 796 } 797 798 void ObjectPage::NewModule() 799 { 800 ScriptDocument aDocument( ScriptDocument::getApplicationScriptDocument() ); 801 String aLibName; 802 803 if ( GetSelection( aDocument, aLibName ) ) 804 { 805 String aModName; 806 createModImpl( static_cast<Window*>( this ), aDocument, 807 aBasicBox, aLibName, aModName, true ); 808 } 809 } 810 811 void ObjectPage::NewDialog() 812 { 813 ScriptDocument aDocument( ScriptDocument::getApplicationScriptDocument() ); 814 String aLibName; 815 816 if ( GetSelection( aDocument, aLibName ) ) 817 { 818 aDocument.getOrCreateLibrary( E_DIALOGS, aLibName ); 819 820 std::auto_ptr< NewObjectDialog > xNewDlg( 821 new NewObjectDialog(this, NEWOBJECTMODE_DLG, true)); 822 xNewDlg->SetObjectName( aDocument.createObjectName( E_DIALOGS, aLibName ) ); 823 824 if (xNewDlg->Execute() != 0) 825 { 826 String aDlgName( xNewDlg->GetObjectName() ); 827 if (aDlgName.Len() == 0) 828 aDlgName = aDocument.createObjectName( E_DIALOGS, aLibName); 829 830 if ( aDocument.hasDialog( aLibName, aDlgName ) ) 831 { 832 ErrorBox( this, WB_OK | WB_DEF_OK, 833 String( IDEResId( RID_STR_SBXNAMEALLREADYUSED2 ) ) ).Execute(); 834 } 835 else 836 { 837 Reference< io::XInputStreamProvider > xISP; 838 if ( !aDocument.createDialog( aLibName, aDlgName, xISP ) ) 839 return; 840 841 SbxItem aSbxItem( SID_BASICIDE_ARG_SBX, aDocument, aLibName, aDlgName, BASICIDE_TYPE_DIALOG ); 842 BasicIDEShell* pIDEShell = IDE_DLL()->GetShell(); 843 SfxViewFrame* pViewFrame = pIDEShell ? pIDEShell->GetViewFrame() : NULL; 844 SfxDispatcher* pDispatcher = pViewFrame ? pViewFrame->GetDispatcher() : NULL; 845 if( pDispatcher ) 846 { 847 pDispatcher->Execute( SID_BASICIDE_SBXINSERTED, 848 SFX_CALLMODE_SYNCHRON, &aSbxItem, 0L ); 849 } 850 LibraryLocation eLocation = aDocument.getLibraryLocation( aLibName ); 851 SvLBoxEntry* pRootEntry = aBasicBox.FindRootEntry( aDocument, eLocation ); 852 if ( pRootEntry ) 853 { 854 if ( !aBasicBox.IsExpanded( pRootEntry ) ) 855 aBasicBox.Expand( pRootEntry ); 856 SvLBoxEntry* pLibEntry = aBasicBox.FindEntry( pRootEntry, aLibName, OBJ_TYPE_LIBRARY ); 857 DBG_ASSERT( pLibEntry, "Libeintrag nicht gefunden!" ); 858 if ( pLibEntry ) 859 { 860 if ( !aBasicBox.IsExpanded( pLibEntry ) ) 861 aBasicBox.Expand( pLibEntry ); 862 SvLBoxEntry* pEntry = aBasicBox.FindEntry( pLibEntry, aDlgName, OBJ_TYPE_DIALOG ); 863 if ( !pEntry ) 864 { 865 pEntry = aBasicBox.AddEntry( 866 aDlgName, 867 Image( IDEResId( RID_IMG_DIALOG ) ), 868 Image( IDEResId( RID_IMG_DIALOG_HC ) ), 869 pLibEntry, false, 870 std::auto_ptr< BasicEntry >( new BasicEntry( OBJ_TYPE_DIALOG ) ) ); 871 DBG_ASSERT( pEntry, "InsertEntry fehlgeschlagen!" ); 872 } 873 aBasicBox.SetCurEntry( pEntry ); 874 aBasicBox.Select( aBasicBox.GetCurEntry() ); // OV-Bug?! 875 } 876 } 877 } 878 } 879 } 880 } 881 882 void ObjectPage::DeleteCurrent() 883 { 884 SvLBoxEntry* pCurEntry = aBasicBox.GetCurEntry(); 885 DBG_ASSERT( pCurEntry, "Kein aktueller Eintrag!" ); 886 BasicEntryDescriptor aDesc( aBasicBox.GetEntryDescriptor( pCurEntry ) ); 887 ScriptDocument aDocument( aDesc.GetDocument() ); 888 DBG_ASSERT( aDocument.isAlive(), "ObjectPage::DeleteCurrent: no document!" ); 889 if ( !aDocument.isAlive() ) 890 return; 891 String aLibName( aDesc.GetLibName() ); 892 String aName( aDesc.GetName() ); 893 BasicEntryType eType( aDesc.GetType() ); 894 895 if ( ( eType == OBJ_TYPE_MODULE && QueryDelModule( aName, this ) ) || 896 ( eType == OBJ_TYPE_DIALOG && QueryDelDialog( aName, this ) ) ) 897 { 898 aBasicBox.GetModel()->Remove( pCurEntry ); 899 if ( aBasicBox.GetCurEntry() ) // OV-Bug ? 900 aBasicBox.Select( aBasicBox.GetCurEntry() ); 901 BasicIDEShell* pIDEShell = IDE_DLL()->GetShell(); 902 SfxViewFrame* pViewFrame = pIDEShell ? pIDEShell->GetViewFrame() : NULL; 903 SfxDispatcher* pDispatcher = pViewFrame ? pViewFrame->GetDispatcher() : NULL; 904 if( pDispatcher ) 905 { 906 SbxItem aSbxItem( SID_BASICIDE_ARG_SBX, aDocument, aLibName, aName, aBasicBox.ConvertType( eType ) ); 907 pDispatcher->Execute( SID_BASICIDE_SBXDELETED, 908 SFX_CALLMODE_SYNCHRON, &aSbxItem, 0L ); 909 } 910 911 try 912 { 913 bool bSuccess = false; 914 if ( eType == OBJ_TYPE_MODULE ) 915 bSuccess = aDocument.removeModule( aLibName, aName ); 916 else if ( eType == OBJ_TYPE_DIALOG ) 917 bSuccess = BasicIDE::RemoveDialog( aDocument, aLibName, aName ); 918 919 if ( bSuccess ) 920 BasicIDE::MarkDocumentModified( aDocument ); 921 } 922 catch ( container::NoSuchElementException& ) 923 { 924 DBG_UNHANDLED_EXCEPTION(); 925 } 926 } 927 } 928 929 930 931 void ObjectPage::EndTabDialog( sal_uInt16 nRet ) 932 { 933 DBG_ASSERT( pTabDlg, "TabDlg nicht gesetzt!" ); 934 if ( pTabDlg ) 935 pTabDlg->EndDialog( nRet ); 936 } 937 938 939 LibDialog::LibDialog( Window* pParent ) 940 : ModalDialog( pParent, IDEResId( RID_DLG_LIBS ) ), 941 aOKButton( this, IDEResId( RID_PB_OK ) ), 942 aCancelButton( this, IDEResId( RID_PB_CANCEL ) ), 943 aStorageName( this, IDEResId( RID_FT_STORAGENAME ) ), 944 aLibBox( this, IDEResId( RID_CTRL_LIBS ) ), 945 aFixedLine( this, IDEResId( RID_FL_OPTIONS ) ), 946 aReferenceBox( this, IDEResId( RID_CB_REF ) ), 947 aReplaceBox( this, IDEResId( RID_CB_REPL ) ) 948 { 949 SetText( String( IDEResId( RID_STR_APPENDLIBS ) ) ); 950 FreeResource(); 951 } 952 953 954 LibDialog::~LibDialog() 955 { 956 } 957 958 void LibDialog::SetStorageName( const String& rName ) 959 { 960 String aName( IDEResId( RID_STR_FILENAME ) ); 961 aName += rName; 962 aStorageName.SetText( aName ); 963 } 964 965 // Helper function 966 SbModule* createModImpl( Window* pWin, const ScriptDocument& rDocument, 967 BasicTreeListBox& rBasicBox, const String& rLibName, String aModName, bool bMain ) 968 { 969 OSL_ENSURE( rDocument.isAlive(), "createModImpl: invalid document!" ); 970 if ( !rDocument.isAlive() ) 971 return NULL; 972 973 SbModule* pModule = NULL; 974 975 String aLibName( rLibName ); 976 if ( !aLibName.Len() ) 977 aLibName = String::CreateFromAscii( "Standard" ); 978 rDocument.getOrCreateLibrary( E_SCRIPTS, aLibName ); 979 if ( !aModName.Len() ) 980 aModName = rDocument.createObjectName( E_SCRIPTS, aLibName ); 981 982 std::auto_ptr< NewObjectDialog > xNewDlg( 983 new NewObjectDialog( pWin, NEWOBJECTMODE_MOD, true ) ); 984 xNewDlg->SetObjectName( aModName ); 985 986 if (xNewDlg->Execute() != 0) 987 { 988 if ( xNewDlg->GetObjectName().Len() ) 989 aModName = xNewDlg->GetObjectName(); 990 991 try 992 { 993 ::rtl::OUString sModuleCode; 994 // the module has existed 995 if( rDocument.hasModule( aLibName, aModName ) ) 996 return NULL; 997 rDocument.createModule( aLibName, aModName, bMain, sModuleCode ); 998 BasicManager* pBasMgr = rDocument.getBasicManager(); 999 StarBASIC* pBasic = pBasMgr? pBasMgr->GetLib( aLibName ) : 0; 1000 if ( pBasic ) 1001 pModule = pBasic->FindModule( aModName ); 1002 SbxItem aSbxItem( SID_BASICIDE_ARG_SBX, rDocument, aLibName, aModName, BASICIDE_TYPE_MODULE ); 1003 BasicIDEShell* pIDEShell = IDE_DLL()->GetShell(); 1004 SfxViewFrame* pViewFrame = pIDEShell ? pIDEShell->GetViewFrame() : NULL; 1005 SfxDispatcher* pDispatcher = pViewFrame ? pViewFrame->GetDispatcher() : NULL; 1006 if( pDispatcher ) 1007 { 1008 pDispatcher->Execute( SID_BASICIDE_SBXINSERTED, 1009 SFX_CALLMODE_SYNCHRON, &aSbxItem, 0L ); 1010 } 1011 LibraryLocation eLocation = rDocument.getLibraryLocation( aLibName ); 1012 SvLBoxEntry* pRootEntry = rBasicBox.FindRootEntry( rDocument, eLocation ); 1013 if ( pRootEntry ) 1014 { 1015 if ( !rBasicBox.IsExpanded( pRootEntry ) ) 1016 rBasicBox.Expand( pRootEntry ); 1017 SvLBoxEntry* pLibEntry = rBasicBox.FindEntry( pRootEntry, aLibName, OBJ_TYPE_LIBRARY ); 1018 DBG_ASSERT( pLibEntry, "Libeintrag nicht gefunden!" ); 1019 if ( pLibEntry ) 1020 { 1021 if ( !rBasicBox.IsExpanded( pLibEntry ) ) 1022 rBasicBox.Expand( pLibEntry ); 1023 SvLBoxEntry* pSubRootEntry = pLibEntry; 1024 if( pBasic && rDocument.isInVBAMode() ) 1025 { 1026 // add the new module in the "Modules" entry 1027 SvLBoxEntry* pLibSubEntry = rBasicBox.FindEntry( pLibEntry, String( IDEResId( RID_STR_NORMAL_MODULES ) ) , OBJ_TYPE_NORMAL_MODULES ); 1028 if( pLibSubEntry ) 1029 { 1030 if( !rBasicBox.IsExpanded( pLibSubEntry ) ) 1031 rBasicBox.Expand( pLibSubEntry ); 1032 pSubRootEntry = pLibSubEntry; 1033 } 1034 } 1035 1036 SvLBoxEntry* pEntry = rBasicBox.FindEntry( pSubRootEntry, aModName, OBJ_TYPE_MODULE ); 1037 if ( !pEntry ) 1038 { 1039 pEntry = rBasicBox.AddEntry( 1040 aModName, 1041 Image( IDEResId( RID_IMG_MODULE ) ), 1042 Image( IDEResId( RID_IMG_MODULE_HC ) ), 1043 pSubRootEntry, false, 1044 std::auto_ptr< BasicEntry >( new BasicEntry( OBJ_TYPE_MODULE ) ) ); 1045 DBG_ASSERT( pEntry, "InsertEntry fehlgeschlagen!" ); 1046 } 1047 rBasicBox.SetCurEntry( pEntry ); 1048 rBasicBox.Select( rBasicBox.GetCurEntry() ); // OV-Bug?! 1049 } 1050 } 1051 } 1052 catch ( container::ElementExistException& ) 1053 { 1054 ErrorBox( pWin, WB_OK | WB_DEF_OK, 1055 String( IDEResId( RID_STR_SBXNAMEALLREADYUSED2 ) ) ).Execute(); 1056 } 1057 catch ( container::NoSuchElementException& ) 1058 { 1059 DBG_UNHANDLED_EXCEPTION(); 1060 } 1061 } 1062 return pModule; 1063 } 1064 1065 1066 1067 1068