LCOV - code coverage report
Current view: top level - basctl/source/basicide - bastype2.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 0 454 0.0 %
Date: 2012-08-25 Functions: 0 50 0.0 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 0 0 -

           Branch data     Line data    Source code
       1                 :            : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
       2                 :            : /*
       3                 :            :  * This file is part of the LibreOffice project.
       4                 :            :  *
       5                 :            :  * This Source Code Form is subject to the terms of the Mozilla Public
       6                 :            :  * License, v. 2.0. If a copy of the MPL was not distributed with this
       7                 :            :  * file, You can obtain one at http://mozilla.org/MPL/2.0/.
       8                 :            :  *
       9                 :            :  * This file incorporates work covered by the following license notice:
      10                 :            :  *
      11                 :            :  *   Licensed to the Apache Software Foundation (ASF) under one or more
      12                 :            :  *   contributor license agreements. See the NOTICE file distributed
      13                 :            :  *   with this work for additional information regarding copyright
      14                 :            :  *   ownership. The ASF licenses this file to you under the Apache
      15                 :            :  *   License, Version 2.0 (the "License"); you may not use this file
      16                 :            :  *   except in compliance with the License. You may obtain a copy of
      17                 :            :  *   the License at http://www.apache.org/licenses/LICENSE-2.0 .
      18                 :            :  */
      19                 :            : 
      20                 :            : 
      21                 :            : #include <memory>
      22                 :            : 
      23                 :            : #include "vcl/bitmap.hxx"
      24                 :            : 
      25                 :            : #include "basidesh.hxx"
      26                 :            : #include "iderdll.hxx"
      27                 :            : #include "iderdll2.hxx"
      28                 :            : #include <basidesh.hrc>
      29                 :            : #include <bastypes.hxx>
      30                 :            : #include <bastype2.hxx>
      31                 :            : #include <basobj.hxx>
      32                 :            : #include <baside2.hrc>
      33                 :            : #include <iderid.hxx>
      34                 :            : #include <tools/urlobj.hxx>
      35                 :            : #include <tools/diagnose_ex.h>
      36                 :            : #include <basic/sbx.hxx>
      37                 :            : #include <svtools/imagemgr.hxx>
      38                 :            : #include <com/sun/star/script/XLibraryContainer.hpp>
      39                 :            : #include <com/sun/star/script/XLibraryContainerPassword.hpp>
      40                 :            : #include <com/sun/star/frame/XModuleManager.hpp>
      41                 :            : #include <comphelper/processfactory.hxx>
      42                 :            : #include <comphelper/componentcontext.hxx>
      43                 :            : #include <sfx2/dispatch.hxx>
      44                 :            : 
      45                 :            : #include <map>
      46                 :            : #include <com/sun/star/script/ModuleType.hpp>
      47                 :            : #include <com/sun/star/script/vba/XVBAModuleInfo.hpp>
      48                 :            : #include <com/sun/star/container/XNameContainer.hpp>
      49                 :            : #include <com/sun/star/lang/XServiceInfo.hpp>
      50                 :            : #include <com/sun/star/container/XNamed.hpp>
      51                 :            : 
      52                 :            : using namespace ::com::sun::star::uno;
      53                 :            : using namespace ::com::sun::star;
      54                 :            : 
      55                 :          0 : void ModuleInfoHelper::getObjectName( const uno::Reference< container::XNameContainer >& rLib, const ::rtl::OUString& rModName, ::rtl::OUString& rObjName )
      56                 :            : {
      57                 :            :     try
      58                 :            :     {
      59                 :          0 :                 uno::Reference< script::vba::XVBAModuleInfo > xVBAModuleInfo( rLib, uno::UNO_QUERY );
      60                 :          0 :                 if ( xVBAModuleInfo.is() && xVBAModuleInfo->hasModuleInfo( rModName ) )
      61                 :            :                 {
      62                 :          0 :             script::ModuleInfo aModuleInfo = xVBAModuleInfo->getModuleInfo( rModName );
      63                 :          0 :             uno::Any aObject( aModuleInfo.ModuleObject );
      64                 :          0 :             uno::Reference< lang::XServiceInfo > xServiceInfo( aObject, uno::UNO_QUERY );
      65                 :          0 :             if( xServiceInfo.is() && xServiceInfo->supportsService( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "ooo.vba.excel.Worksheet" )) ) )
      66                 :            :             {
      67                 :          0 :                 uno::Reference< container::XNamed > xNamed( aObject, uno::UNO_QUERY );
      68                 :          0 :                 if( xNamed.is() )
      69                 :          0 :                     rObjName = xNamed->getName();
      70                 :          0 :             }
      71                 :          0 :         }
      72                 :            :     }
      73                 :          0 :     catch(const uno::Exception& )
      74                 :            :     {
      75                 :            :     }
      76                 :          0 : }
      77                 :            : 
      78                 :          0 : sal_Int32 ModuleInfoHelper::getModuleType(  const uno::Reference< container::XNameContainer >& rLib, const ::rtl::OUString& rModName )
      79                 :            : {
      80                 :          0 :     sal_Int32 nType = script::ModuleType::NORMAL;
      81                 :          0 :     uno::Reference< script::vba::XVBAModuleInfo > xVBAModuleInfo( rLib, uno::UNO_QUERY );
      82                 :          0 :     if ( xVBAModuleInfo.is() && xVBAModuleInfo->hasModuleInfo( rModName ) )
      83                 :            :     {
      84                 :          0 :         script::ModuleInfo aModuleInfo = xVBAModuleInfo->getModuleInfo( rModName );
      85                 :          0 :         nType = aModuleInfo.ModuleType;
      86                 :            :     }
      87                 :          0 :     return nType;
      88                 :            : }
      89                 :            : 
      90                 :          0 : BasicEntry::~BasicEntry()
      91                 :            : {
      92                 :          0 : }
      93                 :            : 
      94                 :          0 : BasicDocumentEntry::BasicDocumentEntry( const ScriptDocument& rDocument, LibraryLocation eLocation, BasicEntryType eType )
      95                 :            :     :BasicEntry( eType )
      96                 :            :     ,m_aDocument( rDocument )
      97                 :          0 :     ,m_eLocation( eLocation )
      98                 :            : {
      99                 :            :     OSL_ENSURE( m_aDocument.isValid(), "BasicDocumentEntry::BasicDocumentEntry: illegal document!" );
     100                 :          0 : }
     101                 :            : 
     102                 :          0 : BasicDocumentEntry::~BasicDocumentEntry()
     103                 :            : {
     104                 :          0 : }
     105                 :            : 
     106                 :          0 : BasicLibEntry::BasicLibEntry( const ScriptDocument& rDocument, LibraryLocation eLocation, const ::rtl::OUString& rLibName, BasicEntryType eType )
     107                 :            :     :BasicDocumentEntry( rDocument, eLocation, eType )
     108                 :          0 :     ,m_aLibName( rLibName )
     109                 :            : {
     110                 :          0 : }
     111                 :            : 
     112                 :          0 : BasicLibEntry::~BasicLibEntry()
     113                 :            : {
     114                 :          0 : }
     115                 :            : 
     116                 :          0 : BasicEntryDescriptor::BasicEntryDescriptor()
     117                 :          0 :     :m_aDocument( ScriptDocument::getApplicationScriptDocument() )
     118                 :            :     ,m_eLocation( LIBRARY_LOCATION_UNKNOWN )
     119                 :          0 :     ,m_eType( OBJ_TYPE_UNKNOWN )
     120                 :            : {
     121                 :          0 : }
     122                 :            : 
     123                 :          0 : BasicEntryDescriptor::BasicEntryDescriptor( const ScriptDocument& rDocument, LibraryLocation eLocation, const ::rtl::OUString& rLibName, const ::rtl::OUString& rLibSubName, const ::rtl::OUString& rName, BasicEntryType eType )
     124                 :            :     :m_aDocument( rDocument )
     125                 :            :     ,m_eLocation( eLocation )
     126                 :            :     ,m_aLibName( rLibName )
     127                 :            :     ,m_aLibSubName( rLibSubName )
     128                 :            :     ,m_aName( rName )
     129                 :          0 :     ,m_eType( eType )
     130                 :            : {
     131                 :            :     OSL_ENSURE( m_aDocument.isValid(), "BasicEntryDescriptor::BasicEntryDescriptor: invalid document!" );
     132                 :          0 : }
     133                 :            : 
     134                 :          0 : BasicEntryDescriptor::BasicEntryDescriptor( const ScriptDocument& rDocument, LibraryLocation eLocation, const ::rtl::OUString& rLibName, const ::rtl::OUString& rLibSubName, const ::rtl::OUString& rName, const ::rtl::OUString& rMethodName, BasicEntryType eType )
     135                 :            :     :m_aDocument( rDocument )
     136                 :            :     ,m_eLocation( eLocation )
     137                 :            :     ,m_aLibName( rLibName )
     138                 :            :     ,m_aLibSubName( rLibSubName )
     139                 :            :     ,m_aName( rName )
     140                 :            :     ,m_aMethodName( rMethodName )
     141                 :          0 :     ,m_eType( eType )
     142                 :            : {
     143                 :            :     OSL_ENSURE( m_aDocument.isValid(), "BasicEntryDescriptor::BasicEntryDescriptor: invalid document!" );
     144                 :          0 : }
     145                 :            : 
     146                 :          0 : BasicEntryDescriptor::~BasicEntryDescriptor()
     147                 :            : {
     148                 :          0 : }
     149                 :            : 
     150                 :          0 : BasicEntryDescriptor::BasicEntryDescriptor( const BasicEntryDescriptor& rDesc )
     151                 :            :     :m_aDocument( rDesc.m_aDocument )
     152                 :            :     ,m_eLocation( rDesc.m_eLocation )
     153                 :            :     ,m_aLibName( rDesc.m_aLibName )
     154                 :            :     ,m_aLibSubName( rDesc.m_aLibSubName )
     155                 :            :     ,m_aName( rDesc.m_aName )
     156                 :            :     ,m_aMethodName( rDesc.m_aMethodName )
     157                 :          0 :     ,m_eType( rDesc.m_eType )
     158                 :            : {
     159                 :          0 : }
     160                 :            : 
     161                 :          0 : BasicEntryDescriptor& BasicEntryDescriptor::operator=( const BasicEntryDescriptor& rDesc )
     162                 :            : {
     163                 :          0 :     m_aDocument = rDesc.m_aDocument;
     164                 :          0 :     m_eLocation = rDesc.m_eLocation;
     165                 :          0 :     m_aLibName = rDesc.m_aLibName;
     166                 :          0 :     m_aLibSubName = rDesc.m_aLibSubName;
     167                 :          0 :     m_aName = rDesc.m_aName;
     168                 :          0 :     m_aMethodName = rDesc.m_aMethodName;
     169                 :          0 :     m_eType = rDesc.m_eType;
     170                 :            : 
     171                 :          0 :     return *this;
     172                 :            : }
     173                 :            : 
     174                 :          0 : bool BasicEntryDescriptor::operator==( const BasicEntryDescriptor& rDesc ) const
     175                 :            : {
     176                 :          0 :     return m_aDocument == rDesc.m_aDocument &&
     177                 :            :            m_eLocation == rDesc.m_eLocation &&
     178                 :          0 :            m_aLibName == rDesc.m_aLibName &&
     179                 :          0 :            m_aLibSubName == rDesc.m_aLibSubName &&
     180                 :          0 :            m_aName == rDesc.m_aName &&
     181                 :          0 :            m_aMethodName == rDesc.m_aMethodName &&
     182                 :          0 :            m_eType == rDesc.m_eType;
     183                 :            : }
     184                 :            : 
     185                 :          0 : BasicTreeListBox::BasicTreeListBox( Window* pParent, const ResId& rRes ) :
     186                 :          0 :     SvTreeListBox( pParent, IDEResId( sal::static_int_cast<sal_uInt16>( rRes.GetId() ) ) ),
     187                 :          0 :     m_aNotifier( *this )
     188                 :            : {
     189                 :          0 :     SetNodeDefaultImages();
     190                 :          0 :     SetSelectionMode( SINGLE_SELECTION );
     191                 :          0 :     nMode = 0xFF;   // everything
     192                 :          0 : }
     193                 :            : 
     194                 :            : 
     195                 :            : 
     196                 :          0 : BasicTreeListBox::~BasicTreeListBox()
     197                 :            : {
     198                 :          0 :     m_aNotifier.dispose();
     199                 :            : 
     200                 :            :     // destroy user data
     201                 :          0 :     SvLBoxEntry* pEntry = First();
     202                 :          0 :     while ( pEntry )
     203                 :            :     {
     204                 :          0 :         delete (BasicEntry*)pEntry->GetUserData();
     205                 :          0 :         pEntry = Next( pEntry );
     206                 :            :     }
     207                 :          0 : }
     208                 :            : 
     209                 :          0 : void BasicTreeListBox::ScanEntry( const ScriptDocument& rDocument, LibraryLocation eLocation )
     210                 :            : {
     211                 :            :     OSL_ENSURE( rDocument.isAlive(), "BasicTreeListBox::ScanEntry: illegal document!" );
     212                 :          0 :     if ( !rDocument.isAlive() )
     213                 :          0 :         return;
     214                 :            : 
     215                 :            :     // can be called multiple times for updating!
     216                 :            : 
     217                 :            :     // actually test if basic's in the tree already?!
     218                 :          0 :     SetUpdateMode(false);
     219                 :            : 
     220                 :            :     // level 1: BasicManager (application, document, ...)
     221                 :          0 :     SvLBoxEntry* pDocumentRootEntry = FindRootEntry( rDocument, eLocation );
     222                 :          0 :     if ( pDocumentRootEntry && IsExpanded( pDocumentRootEntry ) )
     223                 :          0 :         ImpCreateLibEntries( pDocumentRootEntry, rDocument, eLocation );
     224                 :          0 :     if ( !pDocumentRootEntry )
     225                 :            :     {
     226                 :          0 :         ::rtl::OUString aRootName( GetRootEntryName( rDocument, eLocation ) );
     227                 :          0 :         Image aImage;
     228                 :          0 :         GetRootEntryBitmaps( rDocument, aImage );
     229                 :            :         SAL_WNODEPRECATED_DECLARATIONS_PUSH
     230                 :            :         pDocumentRootEntry = AddEntry(
     231                 :            :             aRootName,
     232                 :            :             aImage,
     233                 :            :             0, true,
     234                 :          0 :             std::auto_ptr< BasicEntry >( new BasicDocumentEntry( rDocument, eLocation ) ) );
     235                 :          0 :         SAL_WNODEPRECATED_DECLARATIONS_POP
     236                 :            :     }
     237                 :            : 
     238                 :          0 :     SetUpdateMode(true);
     239                 :            : }
     240                 :            : 
     241                 :          0 : void BasicTreeListBox::ImpCreateLibEntries( SvLBoxEntry* pDocumentRootEntry, const ScriptDocument& rDocument, LibraryLocation eLocation )
     242                 :            : {
     243                 :            :     // get a sorted list of library names
     244                 :          0 :     Sequence< ::rtl::OUString > aLibNames( rDocument.getLibraryNames() );
     245                 :          0 :     sal_Int32 nLibCount = aLibNames.getLength();
     246                 :          0 :     const ::rtl::OUString* pLibNames = aLibNames.getConstArray();
     247                 :            : 
     248                 :          0 :     for ( sal_Int32 i = 0 ; i < nLibCount ; i++ )
     249                 :            :     {
     250                 :          0 :         ::rtl::OUString aLibName = pLibNames[ i ];
     251                 :            : 
     252                 :          0 :         if ( eLocation == rDocument.getLibraryLocation( aLibName ) )
     253                 :            :         {
     254                 :            :             // check, if the module library is loaded
     255                 :          0 :             bool bModLibLoaded = false;
     256                 :          0 :             ::rtl::OUString aOULibName( aLibName );
     257                 :          0 :             Reference< script::XLibraryContainer > xModLibContainer( rDocument.getLibraryContainer( E_SCRIPTS ) );
     258                 :          0 :             if ( xModLibContainer.is() && xModLibContainer->hasByName( aOULibName ) && xModLibContainer->isLibraryLoaded( aOULibName ) )
     259                 :          0 :                 bModLibLoaded = true;
     260                 :            : 
     261                 :            :             // check, if the dialog library is loaded
     262                 :          0 :             bool bDlgLibLoaded = false;
     263                 :          0 :             Reference< script::XLibraryContainer > xDlgLibContainer( rDocument.getLibraryContainer( E_DIALOGS ) );
     264                 :          0 :             if ( xDlgLibContainer.is() && xDlgLibContainer->hasByName( aOULibName ) && xDlgLibContainer->isLibraryLoaded( aOULibName ) )
     265                 :          0 :                 bDlgLibLoaded = true;
     266                 :            : 
     267                 :          0 :             bool bLoaded = bModLibLoaded || bDlgLibLoaded;
     268                 :            : 
     269                 :            :             // if only one of the libraries is loaded, load also the other
     270                 :          0 :             if ( bLoaded )
     271                 :            :             {
     272                 :          0 :                 if ( xModLibContainer.is() && xModLibContainer->hasByName( aOULibName ) && !xModLibContainer->isLibraryLoaded( aOULibName ) )
     273                 :          0 :                     xModLibContainer->loadLibrary( aOULibName );
     274                 :            : 
     275                 :          0 :                 if ( xDlgLibContainer.is() && xDlgLibContainer->hasByName( aOULibName ) && !xDlgLibContainer->isLibraryLoaded( aOULibName ) )
     276                 :          0 :                     xDlgLibContainer->loadLibrary( aOULibName );
     277                 :            :             }
     278                 :            : 
     279                 :            :             // create tree list box entry
     280                 :            :             sal_uInt16 nId;
     281                 :          0 :             if ( ( nMode & BROWSEMODE_DIALOGS ) && !( nMode & BROWSEMODE_MODULES ) )
     282                 :          0 :                 nId = bLoaded ? RID_IMG_DLGLIB : RID_IMG_DLGLIBNOTLOADED;
     283                 :            :             else
     284                 :          0 :                 nId = bLoaded ? RID_IMG_MODLIB : RID_IMG_MODLIBNOTLOADED;
     285                 :          0 :             SvLBoxEntry* pLibRootEntry = FindEntry( pDocumentRootEntry, aLibName, OBJ_TYPE_LIBRARY );
     286                 :          0 :             if ( pLibRootEntry )
     287                 :            :             {
     288                 :          0 :                 SetEntryBitmaps( pLibRootEntry, Image( IDEResId( nId ) ) );
     289                 :          0 :                 if ( IsExpanded( pLibRootEntry ) )
     290                 :          0 :                     ImpCreateLibSubEntries( pLibRootEntry, rDocument, aLibName );
     291                 :            :             }
     292                 :            :             else
     293                 :            :             {
     294                 :            :                 pLibRootEntry = AddEntry(
     295                 :            :                     aLibName,
     296                 :            :                     Image( IDEResId( nId ) ),
     297                 :            :                     pDocumentRootEntry, true,
     298                 :          0 :                     std::auto_ptr< BasicEntry >( new BasicEntry( OBJ_TYPE_LIBRARY ) ) );
     299                 :          0 :             }
     300                 :            :         }
     301                 :          0 :     }
     302                 :          0 : }
     303                 :            : 
     304                 :          0 : void BasicTreeListBox::ImpCreateLibSubEntries( SvLBoxEntry* pLibRootEntry, const ScriptDocument& rDocument, const ::rtl::OUString& rLibName )
     305                 :            : {
     306                 :            :     // modules
     307                 :          0 :     if ( nMode & BROWSEMODE_MODULES )
     308                 :            :     {
     309                 :          0 :         Reference< script::XLibraryContainer > xModLibContainer( rDocument.getLibraryContainer( E_SCRIPTS ) );
     310                 :            : 
     311                 :          0 :         if ( xModLibContainer.is() && xModLibContainer->hasByName( rLibName ) && xModLibContainer->isLibraryLoaded( rLibName ) )
     312                 :            :         {
     313                 :            :             try
     314                 :            :             {
     315                 :          0 :                 if( rDocument.isInVBAMode() )
     316                 :          0 :                     ImpCreateLibSubEntriesInVBAMode( pLibRootEntry, rDocument, rLibName );
     317                 :            :                 else
     318                 :            :                 {
     319                 :            :                     // get a sorted list of module names
     320                 :          0 :                     Sequence< ::rtl::OUString > aModNames = rDocument.getObjectNames( E_SCRIPTS, rLibName );
     321                 :          0 :                     sal_Int32 nModCount = aModNames.getLength();
     322                 :          0 :                     const ::rtl::OUString* pModNames = aModNames.getConstArray();
     323                 :            : 
     324                 :          0 :                     for ( sal_Int32 i = 0 ; i < nModCount ; i++ )
     325                 :            :                     {
     326                 :          0 :                         ::rtl::OUString aModName = pModNames[ i ];
     327                 :          0 :                         SvLBoxEntry* pModuleEntry = FindEntry( pLibRootEntry, aModName, OBJ_TYPE_MODULE );
     328                 :          0 :                         if ( !pModuleEntry )
     329                 :            :                             pModuleEntry = AddEntry(
     330                 :            :                                 aModName,
     331                 :            :                                 Image( IDEResId( RID_IMG_MODULE ) ),
     332                 :            :                                 pLibRootEntry, false,
     333                 :          0 :                                 std::auto_ptr< BasicEntry >( new BasicEntry( OBJ_TYPE_MODULE ) ) );
     334                 :            : 
     335                 :            :                         // methods
     336                 :          0 :                         if ( nMode & BROWSEMODE_SUBS )
     337                 :            :                         {
     338                 :          0 :                             Sequence< ::rtl::OUString > aNames = BasicIDE::GetMethodNames( rDocument, rLibName, aModName );
     339                 :          0 :                             sal_Int32 nCount = aNames.getLength();
     340                 :          0 :                             const ::rtl::OUString* pNames = aNames.getConstArray();
     341                 :            : 
     342                 :          0 :                             for ( sal_Int32 j = 0 ; j < nCount ; j++ )
     343                 :            :                             {
     344                 :          0 :                                 ::rtl::OUString aName = pNames[ j ];
     345                 :          0 :                                 SvLBoxEntry* pEntry = FindEntry( pModuleEntry, aName, OBJ_TYPE_METHOD );
     346                 :          0 :                                 if ( !pEntry )
     347                 :            :                                     pEntry = AddEntry(
     348                 :            :                                         aName,
     349                 :            :                                         Image( IDEResId( RID_IMG_MACRO ) ),
     350                 :            :                                         pModuleEntry, false,
     351                 :          0 :                                         std::auto_ptr< BasicEntry >( new BasicEntry( OBJ_TYPE_METHOD ) ) );
     352                 :          0 :                             }
     353                 :            :                         }
     354                 :          0 :                     }
     355                 :            :                 }
     356                 :            :             }
     357                 :          0 :             catch ( const container::NoSuchElementException& )
     358                 :            :             {
     359                 :            :                 DBG_UNHANDLED_EXCEPTION();
     360                 :            :             }
     361                 :          0 :         }
     362                 :            :     }
     363                 :            : 
     364                 :            :     // dialogs
     365                 :          0 :     if ( nMode & BROWSEMODE_DIALOGS )
     366                 :            :     {
     367                 :          0 :          Reference< script::XLibraryContainer > xDlgLibContainer( rDocument.getLibraryContainer( E_DIALOGS ) );
     368                 :            : 
     369                 :          0 :          if ( xDlgLibContainer.is() && xDlgLibContainer->hasByName( rLibName ) && xDlgLibContainer->isLibraryLoaded( rLibName ) )
     370                 :            :          {
     371                 :            :             try
     372                 :            :             {
     373                 :            :                 // get a sorted list of dialog names
     374                 :          0 :                 Sequence< ::rtl::OUString > aDlgNames( rDocument.getObjectNames( E_DIALOGS, rLibName ) );
     375                 :          0 :                 sal_Int32 nDlgCount = aDlgNames.getLength();
     376                 :          0 :                 const ::rtl::OUString* pDlgNames = aDlgNames.getConstArray();
     377                 :            : 
     378                 :          0 :                 for ( sal_Int32 i = 0 ; i < nDlgCount ; i++ )
     379                 :            :                 {
     380                 :          0 :                     ::rtl::OUString aDlgName = pDlgNames[ i ];
     381                 :          0 :                     SvLBoxEntry* pDialogEntry = FindEntry( pLibRootEntry, aDlgName, OBJ_TYPE_DIALOG );
     382                 :          0 :                     if ( !pDialogEntry )
     383                 :            :                         pDialogEntry = AddEntry(
     384                 :            :                             aDlgName,
     385                 :            :                             Image( IDEResId( RID_IMG_DIALOG ) ),
     386                 :            :                             pLibRootEntry, false,
     387                 :          0 :                             std::auto_ptr< BasicEntry >( new BasicEntry( OBJ_TYPE_DIALOG ) ) );
     388                 :          0 :                 }
     389                 :            :             }
     390                 :          0 :             catch (const container::NoSuchElementException& )
     391                 :            :             {
     392                 :            :                 DBG_UNHANDLED_EXCEPTION();
     393                 :            :             }
     394                 :          0 :         }
     395                 :            :     }
     396                 :          0 : }
     397                 :            : 
     398                 :          0 : void BasicTreeListBox::ImpCreateLibSubEntriesInVBAMode( SvLBoxEntry* pLibRootEntry, const ScriptDocument& rDocument, const ::rtl::OUString& rLibName )
     399                 :            : {
     400                 :            : 
     401                 :          0 :     ::std::vector< std::pair< BasicEntryType, ::rtl::OUString > > aEntries;
     402                 :          0 :     aEntries.push_back( ::std::make_pair( OBJ_TYPE_DOCUMENT_OBJECTS, IDE_RESSTR(RID_STR_DOCUMENT_OBJECTS) ) );
     403                 :          0 :     aEntries.push_back( ::std::make_pair( OBJ_TYPE_USERFORMS, IDE_RESSTR(RID_STR_USERFORMS) ) );
     404                 :          0 :     aEntries.push_back( ::std::make_pair( OBJ_TYPE_NORMAL_MODULES, IDE_RESSTR(RID_STR_NORMAL_MODULES) ) );
     405                 :          0 :     aEntries.push_back( ::std::make_pair( OBJ_TYPE_CLASS_MODULES, IDE_RESSTR(RID_STR_CLASS_MODULES) ) );
     406                 :            : 
     407                 :          0 :     ::std::vector< std::pair< BasicEntryType, ::rtl::OUString > >::iterator iter;
     408                 :          0 :     for( iter = aEntries.begin(); iter != aEntries.end(); ++iter )
     409                 :            :     {
     410                 :          0 :         BasicEntryType eType = iter->first;
     411                 :          0 :         ::rtl::OUString aEntryName = iter->second;
     412                 :          0 :         SvLBoxEntry* pLibSubRootEntry = FindEntry( pLibRootEntry, aEntryName, eType );
     413                 :          0 :         if( pLibSubRootEntry )
     414                 :            :         {
     415                 :          0 :             SetEntryBitmaps( pLibSubRootEntry, Image( IDEResId( RID_IMG_MODLIB ) ) );
     416                 :          0 :             if ( IsExpanded( pLibSubRootEntry ) )
     417                 :          0 :                 ImpCreateLibSubSubEntriesInVBAMode( pLibSubRootEntry, rDocument, rLibName );
     418                 :            :         }
     419                 :            :         else
     420                 :            :         {
     421                 :            :             pLibSubRootEntry = AddEntry(
     422                 :            :                 aEntryName,
     423                 :            :                 Image( IDEResId( RID_IMG_MODLIB ) ),
     424                 :            :                 pLibRootEntry, true,
     425                 :          0 :                 std::auto_ptr< BasicEntry >( new BasicEntry( eType ) ) );
     426                 :            :         }
     427                 :          0 :     }
     428                 :          0 : }
     429                 :            : 
     430                 :          0 : void BasicTreeListBox::ImpCreateLibSubSubEntriesInVBAMode( SvLBoxEntry* pLibSubRootEntry, const ScriptDocument& rDocument, const ::rtl::OUString& rLibName )
     431                 :            : {
     432                 :          0 :     uno::Reference< container::XNameContainer > xLib = rDocument.getOrCreateLibrary( E_SCRIPTS, rLibName );
     433                 :          0 :     if( !xLib.is() )
     434                 :          0 :         return;
     435                 :            : 
     436                 :            :     try
     437                 :            :     {
     438                 :            :         // get a sorted list of module names
     439                 :          0 :         Sequence< ::rtl::OUString > aModNames = rDocument.getObjectNames( E_SCRIPTS, rLibName );
     440                 :          0 :         sal_Int32 nModCount = aModNames.getLength();
     441                 :          0 :         const ::rtl::OUString* pModNames = aModNames.getConstArray();
     442                 :            : 
     443                 :          0 :         BasicEntryDescriptor aDesc( GetEntryDescriptor( pLibSubRootEntry ) );
     444                 :          0 :         BasicEntryType eCurrentType( aDesc.GetType() );
     445                 :            : 
     446                 :          0 :         for ( sal_Int32 i = 0 ; i < nModCount ; i++ )
     447                 :            :         {
     448                 :          0 :             ::rtl::OUString aModName = pModNames[ i ];
     449                 :          0 :             BasicEntryType eType = OBJ_TYPE_UNKNOWN;
     450                 :          0 :             switch( ModuleInfoHelper::getModuleType( xLib, aModName ) )
     451                 :            :             {
     452                 :            :                 case script::ModuleType::DOCUMENT:
     453                 :          0 :                     eType = OBJ_TYPE_DOCUMENT_OBJECTS;
     454                 :          0 :                     break;
     455                 :            :                 case script::ModuleType::FORM:
     456                 :          0 :                     eType = OBJ_TYPE_USERFORMS;
     457                 :          0 :                     break;
     458                 :            :                 case script::ModuleType::NORMAL:
     459                 :          0 :                     eType = OBJ_TYPE_NORMAL_MODULES;
     460                 :          0 :                     break;
     461                 :            :                 case script::ModuleType::CLASS:
     462                 :          0 :                     eType = OBJ_TYPE_CLASS_MODULES;
     463                 :          0 :                     break;
     464                 :            :             }
     465                 :          0 :             if( eType != eCurrentType )
     466                 :          0 :                 continue;
     467                 :            : 
     468                 :            :             // display a nice friendly name in the ObjectModule tab,
     469                 :            :                // combining the objectname and module name, e.g. Sheet1 ( Financials )
     470                 :          0 :             ::rtl::OUStringBuffer aEntryNameBuf( aModName );
     471                 :          0 :             if( eType == OBJ_TYPE_DOCUMENT_OBJECTS )
     472                 :            :             {
     473                 :          0 :                 ::rtl::OUString sObjName;
     474                 :          0 :                 ModuleInfoHelper::getObjectName( xLib, aModName, sObjName );
     475                 :          0 :                 if( !sObjName.isEmpty() )
     476                 :            :                 {
     477                 :          0 :                     aEntryNameBuf.appendAscii(RTL_CONSTASCII_STRINGPARAM(" ("));
     478                 :          0 :                     aEntryNameBuf.append(sObjName);
     479                 :          0 :                     aEntryNameBuf.append(')');
     480                 :          0 :                 }
     481                 :            :             }
     482                 :          0 :             ::rtl::OUString aEntryName(aEntryNameBuf.makeStringAndClear());
     483                 :          0 :             SvLBoxEntry* pModuleEntry = FindEntry( pLibSubRootEntry, aEntryName, OBJ_TYPE_MODULE );
     484                 :          0 :             if ( !pModuleEntry )
     485                 :            :                 pModuleEntry = AddEntry(
     486                 :            :                     aEntryName,
     487                 :            :                     Image( IDEResId( RID_IMG_MODULE ) ),
     488                 :            :                     pLibSubRootEntry, false,
     489                 :          0 :                     std::auto_ptr< BasicEntry >( new BasicEntry( OBJ_TYPE_MODULE ) ) );
     490                 :            : 
     491                 :            :             // methods
     492                 :          0 :             if ( nMode & BROWSEMODE_SUBS )
     493                 :            :             {
     494                 :          0 :                 Sequence< ::rtl::OUString > aNames = BasicIDE::GetMethodNames( rDocument, rLibName, aModName );
     495                 :          0 :                 sal_Int32 nCount = aNames.getLength();
     496                 :          0 :                 const ::rtl::OUString* pNames = aNames.getConstArray();
     497                 :            : 
     498                 :          0 :                 for ( sal_Int32 j = 0 ; j < nCount ; j++ )
     499                 :            :                 {
     500                 :          0 :                     ::rtl::OUString aName = pNames[ j ];
     501                 :          0 :                     SvLBoxEntry* pEntry = FindEntry( pModuleEntry, aName, OBJ_TYPE_METHOD );
     502                 :          0 :                     if ( !pEntry )
     503                 :            :                         pEntry = AddEntry(
     504                 :            :                             aName,
     505                 :            :                             Image( IDEResId( RID_IMG_MACRO ) ),
     506                 :            :                             pModuleEntry, false,
     507                 :          0 :                             std::auto_ptr< BasicEntry >( new BasicEntry( OBJ_TYPE_METHOD ) ) );
     508                 :          0 :                 }
     509                 :            :             }
     510                 :          0 :         }
     511                 :            :     }
     512                 :          0 :     catch ( const container::NoSuchElementException& )
     513                 :            :     {
     514                 :            :         DBG_UNHANDLED_EXCEPTION();
     515                 :          0 :     }
     516                 :            : }
     517                 :            : 
     518                 :          0 : SvLBoxEntry* BasicTreeListBox::ImpFindEntry( SvLBoxEntry* pParent, const ::rtl::OUString& rText )
     519                 :            : {
     520                 :          0 :     sal_uLong nRootPos = 0;
     521                 :          0 :     SvLBoxEntry* pEntry = pParent ? FirstChild( pParent ) : GetEntry( nRootPos );
     522                 :          0 :     while ( pEntry )
     523                 :            :     {
     524                 :          0 :         if (  rText.equals(GetEntryText( pEntry )) )
     525                 :          0 :             return pEntry;
     526                 :            : 
     527                 :          0 :         pEntry = pParent ? NextSibling( pEntry ) : GetEntry( ++nRootPos );
     528                 :            :     }
     529                 :          0 :     return 0;
     530                 :            : }
     531                 :            : 
     532                 :          0 : void BasicTreeListBox::onDocumentCreated( const ScriptDocument& /*_rDocument*/ )
     533                 :            : {
     534                 :          0 :     UpdateEntries();
     535                 :          0 : }
     536                 :            : 
     537                 :          0 : void BasicTreeListBox::onDocumentOpened( const ScriptDocument& /*_rDocument*/ )
     538                 :            : {
     539                 :          0 :     UpdateEntries();
     540                 :          0 : }
     541                 :            : 
     542                 :          0 : void BasicTreeListBox::onDocumentSave( const ScriptDocument& /*_rDocument*/ )
     543                 :            : {
     544                 :            :     // not interested in
     545                 :          0 : }
     546                 :            : 
     547                 :          0 : void BasicTreeListBox::onDocumentSaveDone( const ScriptDocument& /*_rDocument*/ )
     548                 :            : {
     549                 :            :     // not interested in
     550                 :          0 : }
     551                 :            : 
     552                 :          0 : void BasicTreeListBox::onDocumentSaveAs( const ScriptDocument& /*_rDocument*/ )
     553                 :            : {
     554                 :            :     // not interested in
     555                 :          0 : }
     556                 :            : 
     557                 :          0 : void BasicTreeListBox::onDocumentSaveAsDone( const ScriptDocument& /*_rDocument*/ )
     558                 :            : {
     559                 :          0 :     UpdateEntries();
     560                 :          0 : }
     561                 :            : 
     562                 :          0 : void BasicTreeListBox::onDocumentClosed( const ScriptDocument& rDocument )
     563                 :            : {
     564                 :          0 :     UpdateEntries();
     565                 :            :     // The document is not yet actually deleted, so we need to remove its entry
     566                 :            :     // manually.
     567                 :          0 :     RemoveEntry(rDocument);
     568                 :          0 : }
     569                 :            : 
     570                 :          0 : void BasicTreeListBox::onDocumentTitleChanged( const ScriptDocument& /*_rDocument*/ )
     571                 :            : {
     572                 :            :     // not interested in
     573                 :          0 : }
     574                 :            : 
     575                 :          0 : void BasicTreeListBox::onDocumentModeChanged( const ScriptDocument& /*_rDocument*/ )
     576                 :            : {
     577                 :            :     // not interested in
     578                 :          0 : }
     579                 :            : 
     580                 :          0 : void BasicTreeListBox::UpdateEntries()
     581                 :            : {
     582                 :          0 :     BasicEntryDescriptor aCurDesc( GetEntryDescriptor( FirstSelected() ) );
     583                 :            : 
     584                 :            :     // removing the invalid entries
     585                 :          0 :     SvLBoxEntry* pLastValid = 0;
     586                 :          0 :     SvLBoxEntry* pEntry = First();
     587                 :          0 :     while ( pEntry )
     588                 :            :     {
     589                 :          0 :         if ( IsValidEntry( pEntry ) )
     590                 :          0 :             pLastValid = pEntry;
     591                 :            :         else
     592                 :          0 :             RemoveEntry(pEntry);
     593                 :          0 :         pEntry = pLastValid ? Next( pLastValid ) : First();
     594                 :            :     }
     595                 :            : 
     596                 :          0 :     ScanAllEntries();
     597                 :            : 
     598                 :          0 :     SetCurrentEntry( aCurDesc );
     599                 :          0 : }
     600                 :            : 
     601                 :            : // Removes the entry from the tree.
     602                 :          0 : void BasicTreeListBox::RemoveEntry (SvLBoxEntry* pEntry)
     603                 :            : {
     604                 :            :     // removing the associated user data
     605                 :          0 :     delete (BasicEntry*)pEntry->GetUserData();
     606                 :            :     // removing the entry
     607                 :          0 :     GetModel()->Remove( pEntry );
     608                 :          0 : }
     609                 :            : 
     610                 :            : // Removes the entry of rDocument.
     611                 :          0 : void BasicTreeListBox::RemoveEntry (ScriptDocument const& rDocument)
     612                 :            : {
     613                 :            :     // finding the entry of rDocument
     614                 :          0 :     for (SvLBoxEntry* pEntry = First(); pEntry; pEntry = Next(pEntry))
     615                 :          0 :         if (rDocument == GetEntryDescriptor(pEntry).GetDocument())
     616                 :            :         {
     617                 :          0 :             RemoveEntry(pEntry);
     618                 :          0 :             break;
     619                 :            :         }
     620                 :          0 : }
     621                 :            : 
     622                 :          0 : SvLBoxEntry* BasicTreeListBox::CloneEntry( SvLBoxEntry* pSource )
     623                 :            : {
     624                 :          0 :     SvLBoxEntry* pNew = SvTreeListBox::CloneEntry( pSource );
     625                 :          0 :     BasicEntry* pUser = (BasicEntry*)pSource->GetUserData();
     626                 :            : 
     627                 :            :     DBG_ASSERT( pUser, "User-Daten?!" );
     628                 :            :     DBG_ASSERT( pUser->GetType() != OBJ_TYPE_DOCUMENT, "BasicTreeListBox::CloneEntry: document?!" );
     629                 :            : 
     630                 :          0 :     BasicEntry* pNewUser = new BasicEntry( *pUser );
     631                 :          0 :     pNew->SetUserData( pNewUser );
     632                 :          0 :     return pNew;
     633                 :            : }
     634                 :            : 
     635                 :          0 : SvLBoxEntry* BasicTreeListBox::FindEntry( SvLBoxEntry* pParent, const ::rtl::OUString& rText, BasicEntryType eType )
     636                 :            : {
     637                 :          0 :     sal_uLong nRootPos = 0;
     638                 :          0 :     SvLBoxEntry* pEntry = pParent ? FirstChild( pParent ) : GetEntry( nRootPos );
     639                 :          0 :     while ( pEntry )
     640                 :            :     {
     641                 :          0 :         BasicEntry* pBasicEntry = (BasicEntry*)pEntry->GetUserData();
     642                 :            :         DBG_ASSERT( pBasicEntry, "FindEntry: Kein BasicEntry ?!" );
     643                 :          0 :         if ( ( pBasicEntry->GetType() == eType  ) && ( rText.equals(GetEntryText( pEntry )) ) )
     644                 :          0 :             return pEntry;
     645                 :            : 
     646                 :          0 :         pEntry = pParent ? NextSibling( pEntry ) : GetEntry( ++nRootPos );
     647                 :            :     }
     648                 :          0 :     return 0;
     649                 :            : }
     650                 :            : 
     651                 :          0 : long BasicTreeListBox::ExpandingHdl()
     652                 :            : {
     653                 :            :     // expanding or collapsing?
     654                 :          0 :     bool bOK = true;
     655                 :          0 :     if ( GetModel()->GetDepth( GetHdlEntry() ) == 1 )
     656                 :            :     {
     657                 :          0 :         SvLBoxEntry* pCurEntry = GetCurEntry();
     658                 :          0 :         BasicEntryDescriptor aDesc( GetEntryDescriptor( pCurEntry ) );
     659                 :          0 :         ScriptDocument aDocument( aDesc.GetDocument() );
     660                 :            :         OSL_ENSURE( aDocument.isAlive(), "BasicTreeListBox::ExpandingHdl: no document, or document is dead!" );
     661                 :          0 :         if ( aDocument.isAlive() )
     662                 :            :         {
     663                 :          0 :             ::rtl::OUString aLibName( aDesc.GetLibName() );
     664                 :          0 :             ::rtl::OUString aLibSubName( aDesc.GetLibSubName() );
     665                 :          0 :             ::rtl::OUString aName( aDesc.GetName() );
     666                 :          0 :             ::rtl::OUString aMethodName( aDesc.GetMethodName() );
     667                 :            : 
     668                 :          0 :             if ( !aLibName.isEmpty() && aLibSubName.isEmpty() && aName.isEmpty() && aMethodName.isEmpty() )
     669                 :            :             {
     670                 :            :                 // check password, if library is password protected and not verified
     671                 :          0 :                 Reference< script::XLibraryContainer > xModLibContainer( aDocument.getLibraryContainer( E_SCRIPTS ) );
     672                 :          0 :                 if ( xModLibContainer.is() && xModLibContainer->hasByName( aLibName ) )
     673                 :            :                 {
     674                 :          0 :                     Reference< script::XLibraryContainerPassword > xPasswd( xModLibContainer, UNO_QUERY );
     675                 :          0 :                     if ( xPasswd.is() && xPasswd->isLibraryPasswordProtected( aLibName ) && !xPasswd->isLibraryPasswordVerified( aLibName ) )
     676                 :            :                     {
     677                 :          0 :                         ::rtl::OUString aPassword;
     678                 :          0 :                         bOK = QueryPassword( xModLibContainer, aLibName, aPassword );
     679                 :          0 :                     }
     680                 :          0 :                 }
     681                 :          0 :             }
     682                 :          0 :         }
     683                 :            :     }
     684                 :          0 :     return bOK;
     685                 :            : }
     686                 :            : 
     687                 :          0 : bool BasicTreeListBox::IsEntryProtected( SvLBoxEntry* pEntry )
     688                 :            : {
     689                 :          0 :     bool bProtected = false;
     690                 :          0 :     if ( pEntry && ( GetModel()->GetDepth( pEntry ) == 1 ) )
     691                 :            :     {
     692                 :          0 :         BasicEntryDescriptor aDesc( GetEntryDescriptor( pEntry ) );
     693                 :          0 :         ScriptDocument aDocument( aDesc.GetDocument() );
     694                 :            :         OSL_ENSURE( aDocument.isAlive(), "BasicTreeListBox::IsEntryProtected: no document, or document is dead!" );
     695                 :          0 :         if ( aDocument.isAlive() )
     696                 :            :         {
     697                 :          0 :             ::rtl::OUString aOULibName( aDesc.GetLibName() );
     698                 :          0 :             Reference< script::XLibraryContainer > xModLibContainer( aDocument.getLibraryContainer( E_SCRIPTS ) );
     699                 :          0 :             if ( xModLibContainer.is() && xModLibContainer->hasByName( aOULibName ) )
     700                 :            :             {
     701                 :          0 :                 Reference< script::XLibraryContainerPassword > xPasswd( xModLibContainer, UNO_QUERY );
     702                 :          0 :                 if ( xPasswd.is() && xPasswd->isLibraryPasswordProtected( aOULibName ) && !xPasswd->isLibraryPasswordVerified( aOULibName ) )
     703                 :            :                 {
     704                 :          0 :                     bProtected = true;
     705                 :          0 :                 }
     706                 :          0 :             }
     707                 :          0 :         }
     708                 :            :     }
     709                 :          0 :     return bProtected;
     710                 :            : }
     711                 :            : 
     712                 :            : SAL_WNODEPRECATED_DECLARATIONS_PUSH
     713                 :          0 : SvLBoxEntry* BasicTreeListBox::AddEntry(
     714                 :            :                                         const ::rtl::OUString& rText,
     715                 :            :     const Image& rImage,
     716                 :            :     SvLBoxEntry* pParent,
     717                 :            :     bool bChildrenOnDemand,
     718                 :            :     std::auto_ptr< BasicEntry > aUserData
     719                 :            : )
     720                 :            : {
     721                 :            :     SvLBoxEntry* p = InsertEntry(
     722                 :            :         rText, rImage, rImage, pParent, bChildrenOnDemand, LIST_APPEND,
     723                 :          0 :         aUserData.release() ); // XXX possible leak
     724                 :          0 :     return p;
     725                 :            : }
     726                 :            : SAL_WNODEPRECATED_DECLARATIONS_POP
     727                 :            : 
     728                 :          0 : void BasicTreeListBox::SetEntryBitmaps( SvLBoxEntry * pEntry, const Image& rImage )
     729                 :            : {
     730                 :          0 :     SetExpandedEntryBmp(  pEntry, rImage );
     731                 :          0 :     SetCollapsedEntryBmp( pEntry, rImage );
     732                 :          0 : }
     733                 :            : 
     734                 :          0 : LibraryType BasicTreeListBox::GetLibraryType() const
     735                 :            : {
     736                 :          0 :     LibraryType eType = LIBRARY_TYPE_ALL;
     737                 :          0 :     if ( ( nMode & BROWSEMODE_MODULES ) && !( nMode & BROWSEMODE_DIALOGS ) )
     738                 :          0 :         eType = LIBRARY_TYPE_MODULE;
     739                 :          0 :     else if ( !( nMode & BROWSEMODE_MODULES ) && ( nMode & BROWSEMODE_DIALOGS ) )
     740                 :          0 :         eType = LIBRARY_TYPE_DIALOG;
     741                 :          0 :     return eType;
     742                 :            : }
     743                 :            : 
     744                 :          0 : ::rtl::OUString BasicTreeListBox::GetRootEntryName( const ScriptDocument& rDocument, LibraryLocation eLocation ) const
     745                 :            : {
     746                 :          0 :     return rDocument.getTitle( eLocation, GetLibraryType() );
     747                 :            : }
     748                 :            : 
     749                 :          0 : void BasicTreeListBox::GetRootEntryBitmaps( const ScriptDocument& rDocument, Image& rImage )
     750                 :            : {
     751                 :            :     OSL_ENSURE( rDocument.isValid(), "BasicTreeListBox::GetRootEntryBitmaps: illegal document!" );
     752                 :          0 :     if ( !rDocument.isValid() )
     753                 :          0 :         return;
     754                 :            : 
     755                 :          0 :     if ( rDocument.isDocument() )
     756                 :            :     {
     757                 :          0 :         ::rtl::OUString sFactoryURL;
     758                 :          0 :         ::comphelper::ComponentContext aContext( ::comphelper::getProcessServiceFactory() );
     759                 :          0 :         Reference< ::com::sun::star::frame::XModuleManager > xModuleManager;
     760                 :          0 :         if ( aContext.createComponent( "com.sun.star.frame.ModuleManager", xModuleManager ) )
     761                 :            :         {
     762                 :            :             try
     763                 :            :             {
     764                 :          0 :                 ::rtl::OUString sModule( xModuleManager->identify( rDocument.getDocument() ) );
     765                 :          0 :                 Reference< container::XNameAccess > xModuleConfig( xModuleManager, UNO_QUERY );
     766                 :          0 :                 if ( xModuleConfig.is() )
     767                 :            :                 {
     768                 :          0 :                     Sequence< beans::PropertyValue > aModuleDescr;
     769                 :          0 :                     xModuleConfig->getByName( sModule ) >>= aModuleDescr;
     770                 :          0 :                     sal_Int32 nCount = aModuleDescr.getLength();
     771                 :          0 :                     const beans::PropertyValue* pModuleDescr = aModuleDescr.getConstArray();
     772                 :          0 :                     for ( sal_Int32 i = 0; i < nCount; ++i )
     773                 :            :                     {
     774                 :          0 :                         if ( pModuleDescr[ i ].Name == "ooSetupFactoryEmptyDocumentURL" )
     775                 :            :                         {
     776                 :          0 :                             pModuleDescr[ i ].Value >>= sFactoryURL;
     777                 :          0 :                             break;
     778                 :            :                         }
     779                 :          0 :                     }
     780                 :          0 :                 }
     781                 :            :             }
     782                 :          0 :             catch( const Exception& )
     783                 :            :             {
     784                 :            :                 DBG_UNHANDLED_EXCEPTION();
     785                 :            :             }
     786                 :            :         }
     787                 :            : 
     788                 :          0 :         if ( !sFactoryURL.isEmpty() )
     789                 :            :         {
     790                 :          0 :             rImage = SvFileInformationManager::GetFileImage( INetURLObject( sFactoryURL ), false );
     791                 :            :         }
     792                 :            :         else
     793                 :            :         {
     794                 :            :             // default icon
     795                 :          0 :             rImage = Image( IDEResId( RID_IMG_DOCUMENT ) );
     796                 :          0 :         }
     797                 :            :     }
     798                 :            :     else
     799                 :            :     {
     800                 :          0 :         rImage = Image( IDEResId( RID_IMG_INSTALLATION ) );
     801                 :            :     }
     802                 :            : }
     803                 :            : 
     804                 :          0 : void BasicTreeListBox::SetCurrentEntry( BasicEntryDescriptor& rDesc )
     805                 :            : {
     806                 :          0 :     SvLBoxEntry* pCurEntry = 0;
     807                 :          0 :     BasicEntryDescriptor aDesc( rDesc );
     808                 :          0 :     if ( aDesc.GetType() == OBJ_TYPE_UNKNOWN )
     809                 :            :     {
     810                 :            :         aDesc = BasicEntryDescriptor(
     811                 :          0 :             ScriptDocument::getApplicationScriptDocument(),
     812                 :            :             LIBRARY_LOCATION_USER, "Standard",
     813                 :          0 :             ::rtl::OUString(), ".", OBJ_TYPE_UNKNOWN );
     814                 :            :     }
     815                 :          0 :     ScriptDocument aDocument( aDesc.GetDocument() );
     816                 :            :     OSL_ENSURE( aDocument.isValid(), "BasicTreeListBox::SetCurrentEntry: invalid document!" );
     817                 :          0 :     LibraryLocation eLocation( aDesc.GetLocation() );
     818                 :          0 :     SvLBoxEntry* pRootEntry = FindRootEntry( aDocument, eLocation );
     819                 :          0 :     if ( pRootEntry )
     820                 :            :     {
     821                 :          0 :         pCurEntry = pRootEntry;
     822                 :          0 :         ::rtl::OUString aLibName( aDesc.GetLibName() );
     823                 :          0 :         if ( !aLibName.isEmpty() )
     824                 :            :         {
     825                 :          0 :             Expand( pRootEntry );
     826                 :          0 :             SvLBoxEntry* pLibEntry = FindEntry( pRootEntry, aLibName, OBJ_TYPE_LIBRARY );
     827                 :          0 :             if ( pLibEntry )
     828                 :            :             {
     829                 :          0 :                 pCurEntry = pLibEntry;
     830                 :          0 :                 ::rtl::OUString aLibSubName( aDesc.GetLibSubName() );
     831                 :          0 :                 if( !aLibSubName.isEmpty() )
     832                 :            :                 {
     833                 :          0 :                     Expand( pLibEntry );
     834                 :          0 :                     SvLBoxEntry* pLibSubEntry = ImpFindEntry( pLibEntry, aLibSubName );
     835                 :          0 :                     if( pLibSubEntry )
     836                 :            :                     {
     837                 :          0 :                         pCurEntry = pLibSubEntry;
     838                 :            :                     }
     839                 :            :                 }
     840                 :          0 :                 ::rtl::OUString aName( aDesc.GetName() );
     841                 :          0 :                 if ( !aName.isEmpty() )
     842                 :            :                 {
     843                 :          0 :                     Expand( pCurEntry );
     844                 :          0 :                     BasicEntryType eType = OBJ_TYPE_MODULE;
     845                 :          0 :                     if ( aDesc.GetType() == OBJ_TYPE_DIALOG )
     846                 :          0 :                         eType = OBJ_TYPE_DIALOG;
     847                 :          0 :                     SvLBoxEntry* pEntry = FindEntry( pCurEntry, aName, eType );
     848                 :          0 :                     if ( pEntry )
     849                 :            :                     {
     850                 :          0 :                         pCurEntry = pEntry;
     851                 :          0 :                         ::rtl::OUString aMethodName( aDesc.GetMethodName() );
     852                 :          0 :                         if ( !aMethodName.isEmpty() )
     853                 :            :                         {
     854                 :          0 :                             Expand( pEntry );
     855                 :          0 :                             SvLBoxEntry* pSubEntry = FindEntry( pEntry, aMethodName, OBJ_TYPE_METHOD );
     856                 :          0 :                             if ( pSubEntry )
     857                 :            :                             {
     858                 :          0 :                                 pCurEntry = pSubEntry;
     859                 :            :                             }
     860                 :            :                             else
     861                 :            :                             {
     862                 :          0 :                                 pSubEntry = FirstChild( pEntry );
     863                 :          0 :                                 if ( pSubEntry )
     864                 :          0 :                                     pCurEntry = pSubEntry;
     865                 :            :                             }
     866                 :          0 :                         }
     867                 :            :                     }
     868                 :            :                     else
     869                 :            :                     {
     870                 :          0 :                         pEntry = FirstChild( pLibEntry );
     871                 :          0 :                         if ( pEntry )
     872                 :          0 :                             pCurEntry = pEntry;
     873                 :            :                     }
     874                 :          0 :                 }
     875                 :            :             }
     876                 :            :             else
     877                 :            :             {
     878                 :          0 :                 pLibEntry = FirstChild( pRootEntry );
     879                 :          0 :                 if ( pLibEntry )
     880                 :          0 :                     pCurEntry = pLibEntry;
     881                 :            :             }
     882                 :          0 :         }
     883                 :            :     }
     884                 :            :     else
     885                 :            :     {
     886                 :          0 :         pRootEntry = First();
     887                 :          0 :         if ( pRootEntry )
     888                 :          0 :             pCurEntry = pRootEntry;
     889                 :            :     }
     890                 :            : 
     891                 :          0 :     SetCurEntry( pCurEntry );
     892                 :          0 : }
     893                 :            : 
     894                 :          0 : void BasicTreeListBox::MouseButtonDown( const MouseEvent& rMEvt )
     895                 :            : {
     896                 :          0 :     SvTreeListBox::MouseButtonDown( rMEvt );
     897                 :          0 :     if ( rMEvt.IsLeft() && ( rMEvt.GetClicks() == 2 ) )
     898                 :            :     {
     899                 :          0 :         BasicEntryDescriptor aDesc( GetEntryDescriptor( GetCurEntry() ) );
     900                 :            : 
     901                 :          0 :         if ( aDesc.GetType() == OBJ_TYPE_METHOD )
     902                 :            :         {
     903                 :          0 :             BasicIDEShell* pIDEShell = BasicIDEGlobals::GetShell();
     904                 :          0 :             SfxViewFrame* pViewFrame = pIDEShell ? pIDEShell->GetViewFrame() : NULL;
     905                 :          0 :             SfxDispatcher* pDispatcher = pViewFrame ? pViewFrame->GetDispatcher() : NULL;
     906                 :          0 :             if( pDispatcher )
     907                 :            :             {
     908                 :          0 :                 SbxItem aSbxItem( SID_BASICIDE_ARG_SBX, aDesc.GetDocument(), aDesc.GetLibName(), aDesc.GetName(),
     909                 :          0 :                 aDesc.GetMethodName(), ConvertType( aDesc.GetType() ) );
     910                 :            :                 pDispatcher->Execute( SID_BASICIDE_SHOWSBX,
     911                 :          0 :                 SFX_CALLMODE_SYNCHRON, &aSbxItem, 0L );
     912                 :            :             }
     913                 :          0 :         }
     914                 :            :     }
     915                 :          0 : }
     916                 :            : 
     917                 :            : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10