LCOV - code coverage report
Current view: top level - framework/source/classes - menumanager.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 22 509 4.3 %
Date: 2012-08-25 Functions: 1 28 3.6 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 25 1096 2.3 %

           Branch data     Line data    Source code
       1                 :            : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
       2                 :            : /*************************************************************************
       3                 :            :  *
       4                 :            :  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
       5                 :            :  *
       6                 :            :  * Copyright 2000, 2010 Oracle and/or its affiliates.
       7                 :            :  *
       8                 :            :  * OpenOffice.org - a multi-platform office productivity suite
       9                 :            :  *
      10                 :            :  * This file is part of OpenOffice.org.
      11                 :            :  *
      12                 :            :  * OpenOffice.org is free software: you can redistribute it and/or modify
      13                 :            :  * it under the terms of the GNU Lesser General Public License version 3
      14                 :            :  * only, as published by the Free Software Foundation.
      15                 :            :  *
      16                 :            :  * OpenOffice.org is distributed in the hope that it will be useful,
      17                 :            :  * but WITHOUT ANY WARRANTY; without even the implied warranty of
      18                 :            :  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
      19                 :            :  * GNU Lesser General Public License version 3 for more details
      20                 :            :  * (a copy is included in the LICENSE file that accompanied this code).
      21                 :            :  *
      22                 :            :  * You should have received a copy of the GNU Lesser General Public License
      23                 :            :  * version 3 along with OpenOffice.org.  If not, see
      24                 :            :  * <http://www.openoffice.org/license.html>
      25                 :            :  * for a copy of the LGPLv3 License.
      26                 :            :  *
      27                 :            :  ************************************************************************/
      28                 :            : 
      29                 :            : #include <classes/menumanager.hxx>
      30                 :            : #include <framework/menuconfiguration.hxx>
      31                 :            : #include <framework/bmkmenu.hxx>
      32                 :            : #include <framework/addonmenu.hxx>
      33                 :            : #include <framework/imageproducer.hxx>
      34                 :            : #include <threadhelp/resetableguard.hxx>
      35                 :            : #include "framework/addonsoptions.hxx"
      36                 :            : #include <classes/fwkresid.hxx>
      37                 :            : #include <services.h>
      38                 :            : #include "classes/resource.hrc"
      39                 :            : 
      40                 :            : #include <com/sun/star/frame/XDispatchProvider.hpp>
      41                 :            : #include <com/sun/star/frame/XDispatch.hpp>
      42                 :            : #include <com/sun/star/util/URLTransformer.hpp>
      43                 :            : #include <com/sun/star/util/XURLTransformer.hpp>
      44                 :            : #include <com/sun/star/lang/XMultiServiceFactory.hpp>
      45                 :            : #include <com/sun/star/beans/XPropertySet.hpp>
      46                 :            : #include <com/sun/star/frame/XFramesSupplier.hpp>
      47                 :            : #include <com/sun/star/frame/XDesktop.hpp>
      48                 :            : #include <com/sun/star/container/XEnumeration.hpp>
      49                 :            : #include <com/sun/star/util/XStringWidth.hpp>
      50                 :            : 
      51                 :            : #include <comphelper/processfactory.hxx>
      52                 :            : #include <comphelper/componentcontext.hxx>
      53                 :            : 
      54                 :            : #include <comphelper/extract.hxx>
      55                 :            : #include <svtools/menuoptions.hxx>
      56                 :            : #include <unotools/historyoptions.hxx>
      57                 :            : #include <unotools/pathoptions.hxx>
      58                 :            : #include <unotools/localfilehelper.hxx>
      59                 :            : 
      60                 :            : #include <toolkit/unohlp.hxx>
      61                 :            : #include <tools/urlobj.hxx>
      62                 :            : 
      63                 :            : #include <vcl/svapp.hxx>
      64                 :            : #include <vcl/window.hxx>
      65                 :            : #include <osl/mutex.hxx>
      66                 :            : #include <vcl/svapp.hxx>
      67                 :            : #include <osl/file.hxx>
      68                 :            : #include <cppuhelper/implbase1.hxx>
      69                 :            : 
      70                 :            : using namespace ::cppu;
      71                 :            : using namespace ::com::sun::star::uno;
      72                 :            : using namespace ::com::sun::star::util;
      73                 :            : using namespace ::com::sun::star::beans;
      74                 :            : using namespace ::com::sun::star::frame;
      75                 :            : using namespace ::com::sun::star::lang;
      76                 :            : using namespace ::com::sun::star::container;
      77                 :            : 
      78                 :            : 
      79                 :            : class StringLength : public ::cppu::WeakImplHelper1< ::com::sun::star::util::XStringWidth >
      80                 :            : {
      81                 :            :     public:
      82                 :          0 :         StringLength() {}
      83         [ #  # ]:          0 :         virtual ~StringLength() {}
      84                 :            : 
      85                 :            :         // XStringWidth
      86                 :          0 :         sal_Int32 SAL_CALL queryStringWidth( const ::rtl::OUString& aString )
      87                 :            :             throw (::com::sun::star::uno::RuntimeException)
      88                 :            :         {
      89                 :          0 :             return aString.getLength();
      90                 :            :         }
      91                 :            : };
      92                 :            : 
      93                 :            : namespace framework
      94                 :            : {
      95                 :            : 
      96                 :            : // special menu ids/command ids for dynamic popup menus
      97                 :            : #define SID_SFX_START           5000
      98                 :            : #define SID_NEWDOCDIRECT        (SID_SFX_START + 537)
      99                 :            : #define SID_AUTOPILOTMENU       (SID_SFX_START + 1381)
     100                 :            : #define SID_PICKLIST            (SID_SFX_START + 510)
     101                 :            : #define SID_MDIWINDOWLIST       (SID_SFX_START + 610)
     102                 :            : #define SID_ADDONLIST           (SID_SFX_START + 1677)
     103                 :            : #define SID_HELPMENU            (SID_SFX_START + 410)
     104                 :            : 
     105                 :            : #define SFX_REFERER_USER        "private:user"
     106                 :            : 
     107                 :            : #define aSlotNewDocDirect "slot:5537"
     108                 :            : #define aSlotAutoPilot "slot:6381"
     109                 :            : 
     110                 :            : #define aSpecialFileMenu "file"
     111                 :            : #define aSpecialWindowMenu "window"
     112                 :            : #define aSlotSpecialFileMenu "slot:5510"
     113                 :            : #define aSlotSpecialWindowMenu "slot:5610"
     114                 :            : #define aSlotSpecialToolsMenu "slot:6677"
     115                 :            : 
     116                 :            : // special uno commands for picklist and window list
     117                 :            : #define aSpecialFileCommand "PickList"
     118                 :            : #define aSpecialWindowCommand "WindowList"
     119                 :            : 
     120                 :            : const char UNO_COMMAND[] = ".uno:";
     121                 :            : 
     122                 :          0 : MenuManager::MenuManager(
     123                 :            :     const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& xServiceFactory,
     124                 :            :     REFERENCE< XFRAME >& rFrame, Menu* pMenu, sal_Bool bDelete, sal_Bool bDeleteChildren )
     125                 :            : :
     126                 :          0 :     ThreadHelpBase( &Application::GetSolarMutex() ),
     127 [ #  # ][ #  # ]:          0 :     mxServiceFactory(xServiceFactory)
     128                 :            : {
     129                 :          0 :     m_bActive           = sal_False;
     130                 :          0 :     m_bDeleteMenu       = bDelete;
     131                 :          0 :     m_bDeleteChildren   = bDeleteChildren;
     132                 :          0 :     m_pVCLMenu          = pMenu;
     133         [ #  # ]:          0 :     m_xFrame            = rFrame;
     134                 :          0 :     m_bInitialized      = sal_False;
     135                 :          0 :     m_bIsBookmarkMenu   = sal_False;
     136                 :          0 :     acquire();
     137         [ #  # ]:          0 :     const StyleSettings& rSettings = Application::GetSettings().GetStyleSettings();
     138         [ #  # ]:          0 :     m_bShowMenuImages   = rSettings.GetUseImagesInMenus();
     139                 :            : 
     140         [ #  # ]:          0 :     sal_Int32 nAddonsURLPrefixLength = ADDONSPOPUPMENU_URL_PREFIX.getLength();
     141                 :            : 
     142                 :            : 
     143         [ #  # ]:          0 :     sal_uInt16 nItemCount = pMenu->GetItemCount();
     144         [ #  # ]:          0 :     m_aMenuItemHandlerVector.reserve(nItemCount);
     145                 :          0 :     ::rtl::OUString aItemCommand;
     146         [ #  # ]:          0 :     for ( sal_uInt16 i = 0; i < nItemCount; i++ )
     147                 :            :     {
     148         [ #  # ]:          0 :         sal_uInt16 nItemId = FillItemCommand(aItemCommand,pMenu, i );
     149                 :          0 :         bool bShowMenuImages( m_bShowMenuImages );
     150                 :            : 
     151                 :            :         // overwrite the show icons on menu option?
     152         [ #  # ]:          0 :         if (!bShowMenuImages)
     153                 :            :         {
     154         [ #  # ]:          0 :             MenuItemBits nBits = pMenu->GetItemBits( nItemId );
     155                 :          0 :             bShowMenuImages = ( ( nBits & MIB_ICON ) == MIB_ICON );
     156                 :            :         }
     157                 :            : 
     158         [ #  # ]:          0 :         PopupMenu* pPopupMenu = pMenu->GetPopupMenu( nItemId );
     159         [ #  # ]:          0 :         if ( pPopupMenu )
     160                 :            :         {
     161         [ #  # ]:          0 :             AddMenu(pPopupMenu,aItemCommand,nItemId,bDeleteChildren,bDeleteChildren);
     162         [ #  # ]:          0 :             if (! (( aItemCommand.getLength() > nAddonsURLPrefixLength ) &&
     163 [ #  # ][ #  # ]:          0 :                 ( aItemCommand.indexOf( ADDONSPOPUPMENU_URL_PREFIX ) == 0 )) )
         [ #  # ][ #  # ]
                 [ #  # ]
     164                 :            :             {
     165                 :            : 
     166                 :            :                 // Create addon popup menu if there exist elements and this is the tools popup menu
     167 [ #  # ][ #  # ]:          0 :                 if ( ( nItemId == SID_ADDONLIST || aItemCommand == aSlotSpecialToolsMenu )
         [ #  # ][ #  # ]
     168         [ #  # ]:          0 :                     && AddonMenuManager::HasAddonMenuElements() )
     169                 :            :                 {
     170         [ #  # ]:          0 :                     AddonMenu*  pSubMenu = AddonMenuManager::CreateAddonMenu( rFrame );
     171 [ #  # ][ #  # ]:          0 :                     if ( pSubMenu && ( pSubMenu->GetItemCount() > 0 ))
         [ #  # ][ #  # ]
     172                 :            :                     {
     173                 :          0 :                         sal_uInt16 nCount = 0;
     174 [ #  # ][ #  # ]:          0 :                         if ( pPopupMenu->GetItemType( nCount-1 ) != MENUITEM_SEPARATOR )
     175         [ #  # ]:          0 :                             pPopupMenu->InsertSeparator();
     176                 :            : 
     177                 :            :                         // Use resource to load popup menu title
     178 [ #  # ][ #  # ]:          0 :                         String aAddonsStrRes = String( FwkResId( STR_MENU_ADDONS ));
     179         [ #  # ]:          0 :                         pPopupMenu->InsertItem( ITEMID_ADDONLIST, aAddonsStrRes );
     180         [ #  # ]:          0 :                         pPopupMenu->SetPopupMenu( ITEMID_ADDONLIST, pSubMenu );
     181                 :            : 
     182                 :            :                         // Set item command for popup menu to enable it for GetImageFromURL
     183 [ #  # ][ #  # ]:          0 :                         const static ::rtl::OUString aSlotString( RTL_CONSTASCII_USTRINGPARAM( "slot:" ));
         [ #  # ][ #  # ]
     184                 :          0 :                         aItemCommand = aSlotString;
     185                 :          0 :                         aItemCommand += ::rtl::OUString::valueOf( (sal_Int32)ITEMID_ADDONLIST );
     186 [ #  # ][ #  # ]:          0 :                         pPopupMenu->SetItemCommand( ITEMID_ADDONLIST, aItemCommand );
                 [ #  # ]
     187                 :            : 
     188         [ #  # ]:          0 :                         AddMenu(pSubMenu,::rtl::OUString(),nItemId,sal_True,sal_False);
     189                 :            :                         // Set image for the addon popup menu item
     190 [ #  # ][ #  # ]:          0 :                         if ( bShowMenuImages && !pPopupMenu->GetItemImage( ITEMID_ADDONLIST ))
         [ #  # ][ #  # ]
           [ #  #  #  # ]
                 [ #  # ]
     191                 :            :                         {
     192         [ #  # ]:          0 :                             Image aImage = GetImageFromURL( rFrame, aItemCommand, false );
     193         [ #  # ]:          0 :                             if ( !!aImage )
     194 [ #  # ][ #  # ]:          0 :                                    pPopupMenu->SetItemImage( ITEMID_ADDONLIST, aImage );
     195         [ #  # ]:          0 :                         }
     196                 :            :                     }
     197                 :            :                     else
     198 [ #  # ][ #  # ]:          0 :                         delete pSubMenu;
     199                 :            :                 }
     200                 :            :             }
     201                 :            :         }
     202                 :            :         else
     203                 :            :         {
     204 [ #  # ][ #  # ]:          0 :             if ( nItemId == SID_NEWDOCDIRECT || aItemCommand == aSlotNewDocDirect )
                 [ #  # ]
     205                 :            :             {
     206         [ #  # ]:          0 :                 MenuConfiguration aMenuCfg( getServiceFactory() );
     207 [ #  # ][ #  # ]:          0 :                 BmkMenu* pSubMenu = (BmkMenu*)aMenuCfg.CreateBookmarkMenu( rFrame, BOOKMARK_NEWMENU );
     208         [ #  # ]:          0 :                 pMenu->SetPopupMenu( nItemId, pSubMenu );
     209                 :            : 
     210         [ #  # ]:          0 :                 AddMenu(pSubMenu,::rtl::OUString(),nItemId,sal_True,sal_False);
     211 [ #  # ][ #  # ]:          0 :                 if ( bShowMenuImages && !pMenu->GetItemImage( nItemId ))
         [ #  # ][ #  # ]
           [ #  #  #  # ]
                 [ #  # ]
     212                 :            :                 {
     213         [ #  # ]:          0 :                     Image aImage = GetImageFromURL( rFrame, aItemCommand, false );
     214         [ #  # ]:          0 :                     if ( !!aImage )
     215 [ #  # ][ #  # ]:          0 :                            pMenu->SetItemImage( nItemId, aImage );
     216         [ #  # ]:          0 :                 }
     217                 :            :             }
     218 [ #  # ][ #  # ]:          0 :             else if ( nItemId == SID_AUTOPILOTMENU || aItemCommand == aSlotAutoPilot )
                 [ #  # ]
     219                 :            :             {
     220         [ #  # ]:          0 :                 MenuConfiguration aMenuCfg( getServiceFactory() );
     221 [ #  # ][ #  # ]:          0 :                 BmkMenu* pSubMenu = (BmkMenu*)aMenuCfg.CreateBookmarkMenu( rFrame, BOOKMARK_WIZARDMENU );
     222         [ #  # ]:          0 :                 pMenu->SetPopupMenu( nItemId, pSubMenu );
     223                 :            : 
     224         [ #  # ]:          0 :                 AddMenu(pSubMenu,::rtl::OUString(),nItemId,sal_True,sal_False);
     225                 :            : 
     226                 :            : 
     227 [ #  # ][ #  # ]:          0 :                 if ( bShowMenuImages && !pMenu->GetItemImage( nItemId ))
         [ #  # ][ #  # ]
           [ #  #  #  # ]
                 [ #  # ]
     228                 :            :                 {
     229         [ #  # ]:          0 :                     Image aImage = GetImageFromURL( rFrame, aItemCommand, false );
     230         [ #  # ]:          0 :                     if ( !!aImage )
     231 [ #  # ][ #  # ]:          0 :                            pMenu->SetItemImage( nItemId, aImage );
     232         [ #  # ]:          0 :                 }
     233                 :            :             }
     234 [ #  # ][ #  # ]:          0 :             else if ( pMenu->GetItemType( i ) != MENUITEM_SEPARATOR )
     235                 :            :             {
     236         [ #  # ]:          0 :                 if ( bShowMenuImages )
     237                 :            :                 {
     238         [ #  # ]:          0 :                     if ( AddonMenuManager::IsAddonMenuId( nItemId ))
     239                 :            :                     {
     240                 :            :                         // Add-Ons uses a images from different places
     241         [ #  # ]:          0 :                         Image           aImage;
     242                 :          0 :                         rtl::OUString   aImageId;
     243                 :            : 
     244                 :            :                         MenuConfiguration::Attributes* pMenuAttributes =
     245         [ #  # ]:          0 :                             (MenuConfiguration::Attributes*)pMenu->GetUserValue( nItemId );
     246                 :            : 
     247 [ #  # ][ #  # ]:          0 :                         if ( pMenuAttributes && !pMenuAttributes->aImageId.isEmpty() )
                 [ #  # ]
     248                 :            :                         {
     249                 :            :                             // Retrieve image id from menu attributes
     250 [ #  # ][ #  # ]:          0 :                             aImage = GetImageFromURL( rFrame, aImageId, false );
                 [ #  # ]
     251                 :            :                         }
     252                 :            : 
     253         [ #  # ]:          0 :                         if ( !aImage )
     254                 :            :                         {
     255 [ #  # ][ #  # ]:          0 :                             aImage = GetImageFromURL( rFrame, aItemCommand, false );
                 [ #  # ]
     256         [ #  # ]:          0 :                             if ( !aImage )
     257 [ #  # ][ #  # ]:          0 :                                 aImage = AddonsOptions().GetImageFromURL( aItemCommand, false );
         [ #  # ][ #  # ]
                 [ #  # ]
     258                 :            :                         }
     259                 :            : 
     260         [ #  # ]:          0 :                         if ( !!aImage )
     261 [ #  # ][ #  # ]:          0 :                             pMenu->SetItemImage( nItemId, aImage );
     262                 :            :                     }
     263 [ #  # ][ #  # ]:          0 :                     else if ( !pMenu->GetItemImage( nItemId ))
                 [ #  # ]
     264                 :            :                     {
     265         [ #  # ]:          0 :                         Image aImage = GetImageFromURL( rFrame, aItemCommand, false );
     266         [ #  # ]:          0 :                         if ( !!aImage )
     267 [ #  # ][ #  # ]:          0 :                                pMenu->SetItemImage( nItemId, aImage );
     268                 :            :                     }
     269                 :            :                 }
     270                 :            : 
     271                 :          0 :                 REFERENCE< XDISPATCH > aXDispatchRef;
     272 [ #  # ][ #  # ]:          0 :                 m_aMenuItemHandlerVector.push_back( new MenuItemHandler( nItemId, NULL, aXDispatchRef ));
                 [ #  # ]
     273                 :            : 
     274                 :            :             }
     275                 :            :         }
     276                 :            :     }
     277                 :            : 
     278                 :            :     // retrieve label information for all menu items without item text
     279                 :            : 
     280         [ #  # ]:          0 :     SetHdl();
     281                 :          0 : }
     282                 :            : 
     283                 :            : 
     284                 :          0 : void MenuManager::SetHdl()
     285                 :            : {
     286                 :          0 :     m_pVCLMenu->SetHighlightHdl( LINK( this, MenuManager, Highlight ));
     287                 :          0 :     m_pVCLMenu->SetActivateHdl( LINK( this, MenuManager, Activate ));
     288                 :          0 :     m_pVCLMenu->SetDeactivateHdl( LINK( this, MenuManager, Deactivate ));
     289                 :          0 :     m_pVCLMenu->SetSelectHdl( LINK( this, MenuManager, Select ));
     290                 :            : 
     291         [ #  # ]:          0 :     if ( mxServiceFactory.is() )
     292 [ #  # ][ #  # ]:          0 :         m_xURLTransformer.set( URLTransformer::create(::comphelper::ComponentContext(mxServiceFactory).getUNOContext()) );
                 [ #  # ]
     293                 :          0 : }
     294                 :            : 
     295         [ #  # ]:          0 : MenuManager::~MenuManager()
     296                 :            : {
     297                 :          0 :     std::vector< MenuItemHandler* >::iterator p;
     298 [ #  # ][ #  # ]:          0 :     for ( p = m_aMenuItemHandlerVector.begin(); p != m_aMenuItemHandlerVector.end(); ++p )
     299                 :            :     {
     300                 :          0 :         MenuItemHandler* pItemHandler = *p;
     301                 :          0 :         pItemHandler->xMenuItemDispatch.clear();
     302         [ #  # ]:          0 :         if ( pItemHandler->pSubMenuManager )
     303                 :          0 :             (static_cast< ::com::sun::star::uno::XInterface* >((OWeakObject*)pItemHandler->pSubMenuManager))->release();
     304 [ #  # ][ #  # ]:          0 :         delete pItemHandler;
     305                 :            :     }
     306                 :            : 
     307         [ #  # ]:          0 :     if ( m_bDeleteMenu )
     308 [ #  # ][ #  # ]:          0 :         delete m_pVCLMenu;
     309         [ #  # ]:          0 : }
     310                 :            : 
     311                 :            : 
     312                 :          0 : MenuManager::MenuItemHandler* MenuManager::GetMenuItemHandler( sal_uInt16 nItemId )
     313                 :            : {
     314         [ #  # ]:          0 :     ResetableGuard aGuard( m_aLock );
     315                 :            : 
     316                 :          0 :     std::vector< MenuItemHandler* >::iterator p;
     317 [ #  # ][ #  # ]:          0 :     for ( p = m_aMenuItemHandlerVector.begin(); p != m_aMenuItemHandlerVector.end(); ++p )
     318                 :            :     {
     319                 :          0 :         MenuItemHandler* pItemHandler = *p;
     320         [ #  # ]:          0 :         if ( pItemHandler->nItemId == nItemId )
     321                 :          0 :             return pItemHandler;
     322                 :            :     }
     323                 :            : 
     324         [ #  # ]:          0 :     return 0;
     325                 :            : }
     326                 :            : 
     327                 :            : 
     328                 :          0 : void SAL_CALL MenuManager::statusChanged( const FEATURSTATEEVENT& Event )
     329                 :            : throw ( RuntimeException )
     330                 :            : {
     331                 :          0 :     ::rtl::OUString aFeatureURL = Event.FeatureURL.Complete;
     332                 :          0 :     MenuItemHandler* pStatusChangedMenu = NULL;
     333                 :            : 
     334                 :            :     {
     335         [ #  # ]:          0 :         ResetableGuard aGuard( m_aLock );
     336                 :            : 
     337                 :          0 :         std::vector< MenuItemHandler* >::iterator p;
     338 [ #  # ][ #  # ]:          0 :         for ( p = m_aMenuItemHandlerVector.begin(); p != m_aMenuItemHandlerVector.end(); ++p )
     339                 :            :         {
     340                 :          0 :             MenuItemHandler* pMenuItemHandler = *p;
     341         [ #  # ]:          0 :             if ( pMenuItemHandler->aMenuItemURL == aFeatureURL )
     342                 :            :             {
     343                 :          0 :                 pStatusChangedMenu = pMenuItemHandler;
     344                 :          0 :                 break;
     345                 :            :             }
     346         [ #  # ]:          0 :         }
     347                 :            :     }
     348                 :            : 
     349         [ #  # ]:          0 :     if ( pStatusChangedMenu )
     350                 :            :     {
     351         [ #  # ]:          0 :         SolarMutexGuard aSolarGuard;
     352                 :            :         {
     353         [ #  # ]:          0 :             ResetableGuard aGuard( m_aLock );
     354                 :            : 
     355                 :          0 :             sal_Bool bSetCheckmark      = sal_False;
     356                 :          0 :             sal_Bool bCheckmark         = sal_False;
     357         [ #  # ]:          0 :             sal_Bool bMenuItemEnabled   = m_pVCLMenu->IsItemEnabled( pStatusChangedMenu->nItemId );
     358                 :            : 
     359         [ #  # ]:          0 :             if ( Event.IsEnabled != bMenuItemEnabled )
     360         [ #  # ]:          0 :                 m_pVCLMenu->EnableItem( pStatusChangedMenu->nItemId, Event.IsEnabled );
     361                 :            : 
     362         [ #  # ]:          0 :             if ( Event.State >>= bCheckmark )
     363                 :          0 :                  bSetCheckmark = sal_True;
     364                 :            : 
     365         [ #  # ]:          0 :             if ( bSetCheckmark )
     366 [ #  # ][ #  # ]:          0 :                 m_pVCLMenu->CheckItem( pStatusChangedMenu->nItemId, bCheckmark );
     367                 :            :         }
     368                 :            : 
     369         [ #  # ]:          0 :         if ( Event.Requery )
     370                 :            :         {
     371                 :          0 :             URL aTargetURL;
     372                 :          0 :             aTargetURL.Complete = pStatusChangedMenu->aMenuItemURL;
     373                 :            : 
     374 [ #  # ][ #  # ]:          0 :             m_xURLTransformer->parseStrict( aTargetURL );
     375                 :            : 
     376         [ #  # ]:          0 :             REFERENCE< XDISPATCHPROVIDER > xDispatchProvider( m_xFrame, UNO_QUERY );
     377         [ #  # ]:          0 :             REFERENCE< XDISPATCH > xMenuItemDispatch = xDispatchProvider->queryDispatch(
     378         [ #  # ]:          0 :                                                             aTargetURL, ::rtl::OUString(), 0 );
     379                 :            : 
     380         [ #  # ]:          0 :             if ( xMenuItemDispatch.is() )
     381                 :            :             {
     382         [ #  # ]:          0 :                 pStatusChangedMenu->xMenuItemDispatch   = xMenuItemDispatch;
     383                 :          0 :                 pStatusChangedMenu->aMenuItemURL        = aTargetURL.Complete;
     384 [ #  # ][ #  # ]:          0 :                 xMenuItemDispatch->addStatusListener( (static_cast< XSTATUSLISTENER* >(this)), aTargetURL );
                 [ #  # ]
     385                 :          0 :             }
     386         [ #  # ]:          0 :         }
     387                 :          0 :     }
     388                 :          0 : }
     389                 :            : 
     390                 :            : 
     391                 :          0 : void MenuManager::RemoveListener()
     392                 :            : {
     393         [ #  # ]:          0 :     ResetableGuard aGuard( m_aLock );
     394 [ #  # ][ #  # ]:          0 :     ClearMenuDispatch();
         [ #  # ][ #  # ]
     395                 :          0 : }
     396                 :            : 
     397                 :          0 : void MenuManager::ClearMenuDispatch(const EVENTOBJECT& Source,bool _bRemoveOnly)
     398                 :            : {
     399                 :            :     // disposing called from parent dispatcher
     400                 :            :     // remove all listener to prepare shutdown
     401                 :            : 
     402                 :          0 :     std::vector< MenuItemHandler* >::iterator p;
     403 [ #  # ][ #  # ]:          0 :     for ( p = m_aMenuItemHandlerVector.begin(); p != m_aMenuItemHandlerVector.end(); ++p )
     404                 :            :     {
     405                 :          0 :         MenuItemHandler* pItemHandler = *p;
     406         [ #  # ]:          0 :         if ( pItemHandler->xMenuItemDispatch.is() )
     407                 :            :         {
     408                 :          0 :             URL aTargetURL;
     409                 :          0 :             aTargetURL.Complete = pItemHandler->aMenuItemURL;
     410 [ #  # ][ #  # ]:          0 :             m_xURLTransformer->parseStrict( aTargetURL );
     411                 :            : 
     412         [ #  # ]:          0 :             pItemHandler->xMenuItemDispatch->removeStatusListener(
     413 [ #  # ][ #  # ]:          0 :                 (static_cast< XSTATUSLISTENER* >(this)), aTargetURL );
     414                 :            :         }
     415                 :            : 
     416                 :          0 :         pItemHandler->xMenuItemDispatch.clear();
     417         [ #  # ]:          0 :         if ( pItemHandler->pSubMenuManager )
     418                 :            :         {
     419         [ #  # ]:          0 :             if ( _bRemoveOnly )
     420         [ #  # ]:          0 :                 pItemHandler->pSubMenuManager->RemoveListener();
     421                 :            :             else
     422         [ #  # ]:          0 :                 pItemHandler->pSubMenuManager->disposing( Source );
     423                 :            :         }
     424                 :            :     }
     425                 :          0 : }
     426                 :            : 
     427                 :            : 
     428                 :          0 : void SAL_CALL MenuManager::disposing( const EVENTOBJECT& Source ) throw ( RUNTIMEEXCEPTION )
     429                 :            : {
     430         [ #  # ]:          0 :     if ( Source.Source == m_xFrame )
     431                 :            :     {
     432         [ #  # ]:          0 :         ResetableGuard aGuard( m_aLock );
     433 [ #  # ][ #  # ]:          0 :         ClearMenuDispatch(Source,false);
     434                 :            :     }
     435                 :            :     else
     436                 :            :     {
     437                 :            :         // disposing called from menu item dispatcher, remove listener
     438                 :          0 :         MenuItemHandler* pMenuItemDisposing = NULL;
     439                 :            : 
     440                 :            :         {
     441         [ #  # ]:          0 :             ResetableGuard aGuard( m_aLock );
     442                 :            : 
     443                 :          0 :             std::vector< MenuItemHandler* >::iterator p;
     444 [ #  # ][ #  # ]:          0 :             for ( p = m_aMenuItemHandlerVector.begin(); p != m_aMenuItemHandlerVector.end(); ++p )
     445                 :            :             {
     446                 :          0 :                 MenuItemHandler* pMenuItemHandler = *p;
     447 [ #  # ][ #  # ]:          0 :                 if ( pMenuItemHandler->xMenuItemDispatch == Source.Source )
     448                 :            :                 {
     449                 :          0 :                     pMenuItemDisposing = pMenuItemHandler;
     450                 :          0 :                     break;
     451                 :            :                 }
     452                 :            :             }
     453                 :            : 
     454         [ #  # ]:          0 :             if ( pMenuItemDisposing )
     455                 :            :             {
     456                 :          0 :                 URL aTargetURL;
     457                 :          0 :                 aTargetURL.Complete = pMenuItemDisposing->aMenuItemURL;
     458                 :            : 
     459 [ #  # ][ #  # ]:          0 :                 m_xURLTransformer->parseStrict( aTargetURL );
     460                 :            : 
     461 [ #  # ][ #  # ]:          0 :                 pMenuItemDisposing->xMenuItemDispatch->removeStatusListener((static_cast< XSTATUSLISTENER* >(this)), aTargetURL );
                 [ #  # ]
     462                 :          0 :                 pMenuItemDisposing->xMenuItemDispatch.clear();
     463         [ #  # ]:          0 :             }
     464                 :            :         }
     465                 :            :     }
     466                 :          0 : }
     467                 :            : 
     468                 :            : 
     469                 :          0 : void MenuManager::UpdateSpecialFileMenu( Menu* pMenu )
     470                 :            : {
     471                 :            :     // update picklist
     472 [ #  # ][ #  # ]:          0 :     Sequence< Sequence< PropertyValue > > aHistoryList = SvtHistoryOptions().GetList( ePICKLIST );
                 [ #  # ]
     473         [ #  # ]:          0 :     ::std::vector< MenuItemHandler* > aNewPickVector;
     474 [ #  # ][ #  # ]:          0 :     Reference< XStringWidth > xStringLength( new StringLength );
                 [ #  # ]
     475                 :            : 
     476                 :          0 :     sal_uInt16  nPickItemId = START_ITEMID_PICKLIST;
     477         [ #  # ]:          0 :     int     nPickListMenuItems = ( aHistoryList.getLength() > 99 ) ? 99 : aHistoryList.getLength();
     478                 :            : 
     479         [ #  # ]:          0 :     aNewPickVector.reserve(nPickListMenuItems);
     480         [ #  # ]:          0 :     for ( int i = 0; i < nPickListMenuItems; i++ )
     481                 :            :     {
     482 [ #  # ][ #  # ]:          0 :         Sequence< PropertyValue > aPickListEntry = aHistoryList[i];
     483                 :            : 
     484                 :          0 :         REFERENCE< XDISPATCH > aXDispatchRef;
     485                 :            :         MenuItemHandler* pNewMenuItemHandler = new MenuItemHandler(
     486                 :            :                                                     nPickItemId++,
     487                 :            :                                                     NULL,
     488 [ #  # ][ #  # ]:          0 :                                                     aXDispatchRef );
     489                 :            : 
     490         [ #  # ]:          0 :         for ( int j = 0; j < aPickListEntry.getLength(); j++ )
     491                 :            :         {
     492         [ #  # ]:          0 :             Any a = aPickListEntry[j].Value;
     493                 :            : 
     494 [ #  # ][ #  # ]:          0 :             if ( aPickListEntry[j].Name == HISTORY_PROPERTYNAME_URL )
                 [ #  # ]
     495                 :          0 :                 a >>= pNewMenuItemHandler->aMenuItemURL;
     496 [ #  # ][ #  # ]:          0 :             else if ( aPickListEntry[j].Name == HISTORY_PROPERTYNAME_FILTER )
                 [ #  # ]
     497                 :          0 :                 a >>= pNewMenuItemHandler->aFilter;
     498 [ #  # ][ #  # ]:          0 :             else if ( aPickListEntry[j].Name == HISTORY_PROPERTYNAME_TITLE )
                 [ #  # ]
     499                 :          0 :                 a >>= pNewMenuItemHandler->aTitle;
     500 [ #  # ][ #  # ]:          0 :             else if ( aPickListEntry[j].Name == HISTORY_PROPERTYNAME_PASSWORD )
                 [ #  # ]
     501                 :          0 :                 a >>= pNewMenuItemHandler->aPassword;
     502                 :          0 :         }
     503                 :            : 
     504         [ #  # ]:          0 :         aNewPickVector.push_back( pNewMenuItemHandler );
     505         [ #  # ]:          0 :     }
     506                 :            : 
     507         [ #  # ]:          0 :     if ( !aNewPickVector.empty() )
     508                 :            :     {
     509                 :          0 :         URL aTargetURL;
     510         [ #  # ]:          0 :         REFERENCE< XDISPATCHPROVIDER > xDispatchProvider( m_xFrame, UNO_QUERY );
     511                 :            : 
     512                 :          0 :         REFERENCE< XDISPATCH > xMenuItemDispatch;
     513                 :            : 
     514 [ #  # ][ #  # ]:          0 :         static const ::rtl::OUString s_sDefault(RTL_CONSTASCII_USTRINGPARAM("_default"));
         [ #  # ][ #  # ]
     515                 :            :         // query for dispatcher
     516                 :          0 :         std::vector< MenuItemHandler* >::iterator p;
     517 [ #  # ][ #  # ]:          0 :         for ( p = aNewPickVector.begin(); p != aNewPickVector.end(); ++p )
     518                 :            :         {
     519                 :          0 :             MenuItemHandler* pMenuItemHandler = *p;
     520                 :            : 
     521                 :          0 :             aTargetURL.Complete = pMenuItemHandler->aMenuItemURL;
     522 [ #  # ][ #  # ]:          0 :             m_xURLTransformer->parseStrict( aTargetURL );
     523                 :            : 
     524         [ #  # ]:          0 :             if ( !xMenuItemDispatch.is() )
     525                 :            :             {
     526                 :            :                 // attention: this code assume that "_blank" can only be consumed by desktop service
     527 [ #  # ][ #  # ]:          0 :                 xMenuItemDispatch = xDispatchProvider->queryDispatch( aTargetURL, s_sDefault, 0 );
                 [ #  # ]
     528                 :            :             }
     529                 :            : 
     530         [ #  # ]:          0 :             if ( xMenuItemDispatch.is() )
     531                 :            :             {
     532         [ #  # ]:          0 :                 pMenuItemHandler->xMenuItemDispatch = xMenuItemDispatch;
     533                 :          0 :                 pMenuItemHandler->aMenuItemURL      = aTargetURL.Complete;
     534                 :            :             }
     535                 :            :         }
     536                 :            : 
     537                 :            :         {
     538         [ #  # ]:          0 :             ResetableGuard aGuard( m_aLock );
     539                 :            : 
     540                 :          0 :             int nRemoveItemCount = 0;
     541         [ #  # ]:          0 :             int nItemCount       = pMenu->GetItemCount();
     542                 :            : 
     543         [ #  # ]:          0 :             if ( nItemCount > 0 )
     544                 :            :             {
     545                 :            :                 // remove all old picklist entries from menu
     546         [ #  # ]:          0 :                 sal_uInt16 nPos = pMenu->GetItemPos( START_ITEMID_PICKLIST );
     547 [ #  # ][ #  # ]:          0 :                 for ( sal_uInt16 n = nPos; n < pMenu->GetItemCount(); )
     548                 :            :                 {
     549         [ #  # ]:          0 :                     pMenu->RemoveItem( n );
     550                 :          0 :                     ++nRemoveItemCount;
     551                 :            :                 }
     552                 :            : 
     553 [ #  # ][ #  # ]:          0 :                 if ( pMenu->GetItemType( pMenu->GetItemCount()-1 ) == MENUITEM_SEPARATOR )
                 [ #  # ]
     554 [ #  # ][ #  # ]:          0 :                     pMenu->RemoveItem( pMenu->GetItemCount()-1 );
     555                 :            : 
     556                 :            :                 // remove all old picklist entries from menu handler
     557         [ #  # ]:          0 :                 if ( nRemoveItemCount > 0 )
     558                 :            :                 {
     559         [ #  # ]:          0 :                     for( sal_uInt32 nIndex = m_aMenuItemHandlerVector.size() - nRemoveItemCount;
     560                 :          0 :                          nIndex < m_aMenuItemHandlerVector.size();  )
     561                 :            :                     {
     562 [ #  # ][ #  # ]:          0 :                         delete m_aMenuItemHandlerVector.at( nIndex );
                 [ #  # ]
     563 [ #  # ][ #  # ]:          0 :                         m_aMenuItemHandlerVector.erase( m_aMenuItemHandlerVector.begin() + nIndex );
     564                 :            :                     }
     565                 :            :                 }
     566                 :            :             }
     567                 :            : 
     568                 :            :             // append new picklist menu entries
     569         [ #  # ]:          0 :             aNewPickVector.reserve(aNewPickVector.size());
     570         [ #  # ]:          0 :             pMenu->InsertSeparator();
     571                 :          0 :             const sal_uInt32 nCount = aNewPickVector.size();
     572         [ #  # ]:          0 :             for ( sal_uInt32 i = 0; i < nCount; i++ )
     573                 :            :             {
     574                 :          0 :                 char menuShortCut[5] = "~n: ";
     575                 :            : 
     576                 :          0 :                 ::rtl::OUString aMenuShortCut;
     577         [ #  # ]:          0 :                 if ( i <= 9 )
     578                 :            :                 {
     579         [ #  # ]:          0 :                     if ( i == 9 )
     580         [ #  # ]:          0 :                         aMenuShortCut = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "1~0: " ));
     581                 :            :                     else
     582                 :            :                     {
     583                 :          0 :                         menuShortCut[1] = (char)( '1' + i );
     584         [ #  # ]:          0 :                         aMenuShortCut = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( menuShortCut ));
     585                 :            :                     }
     586                 :            :                 }
     587                 :            :                 else
     588                 :            :                 {
     589                 :          0 :                     aMenuShortCut = rtl::OUString::valueOf((sal_Int32)( i + 1 ));
     590         [ #  # ]:          0 :                     aMenuShortCut += rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( ": " ));
     591                 :            :                 }
     592                 :            : 
     593                 :            :                 // Abbreviate URL
     594         [ #  # ]:          0 :                 rtl::OUString   aURLString( aNewPickVector.at( i )->aMenuItemURL );
     595                 :          0 :                 rtl::OUString   aTipHelpText;
     596                 :          0 :                 rtl::OUString   aMenuTitle;
     597         [ #  # ]:          0 :                 INetURLObject   aURL( aURLString );
     598                 :            : 
     599         [ #  # ]:          0 :                 if ( aURL.GetProtocol() == INET_PROT_FILE )
     600                 :            :                 {
     601                 :            :                     // Do handle file URL differently => convert it to a system
     602                 :            :                     // path and abbreviate it with a special function:
     603 [ #  # ][ #  # ]:          0 :                     String aFileSystemPath( aURL.getFSysPath( INetURLObject::FSYS_DETECT ) );
     604                 :            : 
     605         [ #  # ]:          0 :                     ::rtl::OUString aSystemPath( aFileSystemPath );
     606                 :          0 :                     ::rtl::OUString aCompactedSystemPath;
     607                 :            : 
     608                 :          0 :                     aTipHelpText = aSystemPath;
     609         [ #  # ]:          0 :                     oslFileError nError = osl_abbreviateSystemPath( aSystemPath.pData, &aCompactedSystemPath.pData, 46, NULL );
     610         [ #  # ]:          0 :                     if ( !nError )
     611 [ #  # ][ #  # ]:          0 :                         aMenuTitle = String( aCompactedSystemPath );
                 [ #  # ]
     612                 :            :                     else
     613         [ #  # ]:          0 :                         aMenuTitle = aSystemPath;
     614                 :            :                 }
     615                 :            :                 else
     616                 :            :                 {
     617                 :            :                     // Use INetURLObject to abbreviate all other URLs
     618         [ #  # ]:          0 :                     String  aShortURL;
     619 [ #  # ][ #  # ]:          0 :                     aShortURL = aURL.getAbbreviated( xStringLength, 46, INetURLObject::DECODE_UNAMBIGUOUS );
     620         [ #  # ]:          0 :                     aMenuTitle += aShortURL;
     621         [ #  # ]:          0 :                     aTipHelpText = aURLString;
     622                 :            :                 }
     623                 :            : 
     624                 :          0 :                 ::rtl::OUString aTitle( aMenuShortCut + aMenuTitle );
     625                 :            : 
     626         [ #  # ]:          0 :                 MenuItemHandler* pMenuItemHandler = aNewPickVector.at( i );
     627 [ #  # ][ #  # ]:          0 :                 pMenu->InsertItem( pMenuItemHandler->nItemId, aTitle );
                 [ #  # ]
     628 [ #  # ][ #  # ]:          0 :                 pMenu->SetTipHelpText( pMenuItemHandler->nItemId, aTipHelpText );
                 [ #  # ]
     629         [ #  # ]:          0 :                 m_aMenuItemHandlerVector.push_back( pMenuItemHandler );
     630 [ #  # ][ #  # ]:          0 :             }
     631                 :          0 :         }
     632         [ #  # ]:          0 :     }
     633                 :          0 : }
     634                 :            : 
     635                 :          0 : void MenuManager::UpdateSpecialWindowMenu( Menu* pMenu,const Reference< XMultiServiceFactory >& xServiceFactory,framework::IMutex& _rMutex )
     636                 :            : {
     637                 :            :     // update window list
     638         [ #  # ]:          0 :     ::std::vector< ::rtl::OUString > aNewWindowListVector;
     639                 :            : 
     640 [ #  # ][ #  # ]:          0 :     Reference< XDesktop > xDesktop( xServiceFactory->createInstance( SERVICENAME_DESKTOP ), UNO_QUERY );
         [ #  # ][ #  # ]
     641                 :            : 
     642                 :          0 :     sal_uInt16  nActiveItemId = 0;
     643                 :          0 :     sal_uInt16  nItemId = START_ITEMID_WINDOWLIST;
     644                 :            : 
     645         [ #  # ]:          0 :     if ( xDesktop.is() )
     646                 :            :     {
     647         [ #  # ]:          0 :         Reference< XFramesSupplier > xTasksSupplier( xDesktop, UNO_QUERY );
     648 [ #  # ][ #  # ]:          0 :         Reference< XFrame > xCurrentFrame = xDesktop->getCurrentFrame();
     649 [ #  # ][ #  # ]:          0 :         Reference< XIndexAccess > xList( xTasksSupplier->getFrames(), UNO_QUERY );
                 [ #  # ]
     650 [ #  # ][ #  # ]:          0 :         sal_Int32 nCount = xList->getCount();
     651         [ #  # ]:          0 :         aNewWindowListVector.reserve(nCount);
     652         [ #  # ]:          0 :         for (sal_Int32 i=0; i<nCount; ++i )
     653                 :            :         {
     654                 :          0 :             Reference< XFrame > xFrame;
     655 [ #  # ][ #  # ]:          0 :             xList->getByIndex(i) >>= xFrame;
                 [ #  # ]
     656                 :            : 
     657         [ #  # ]:          0 :             if (xFrame.is())
     658                 :            :             {
     659 [ #  # ][ #  # ]:          0 :                 if ( xFrame == xCurrentFrame )
     660                 :          0 :                     nActiveItemId = nItemId;
     661                 :            : 
     662 [ #  # ][ #  # ]:          0 :                 Window* pWin = VCLUnoHelper::GetWindow( xFrame->getContainerWindow() );
                 [ #  # ]
     663 [ #  # ][ #  # ]:          0 :                 if ( pWin && pWin->IsVisible() )
         [ #  # ][ #  # ]
     664                 :            :                 {
     665 [ #  # ][ #  # ]:          0 :                     aNewWindowListVector.push_back( pWin->GetText() );
         [ #  # ][ #  # ]
     666                 :          0 :                     ++nItemId;
     667                 :            :                 }
     668                 :            :             }
     669                 :          0 :         }
     670                 :            :     }
     671                 :            : 
     672                 :            :     {
     673         [ #  # ]:          0 :         ResetableGuard aGuard( _rMutex );
     674                 :            : 
     675         [ #  # ]:          0 :         int nItemCount = pMenu->GetItemCount();
     676                 :            : 
     677         [ #  # ]:          0 :         if ( nItemCount > 0 )
     678                 :            :         {
     679                 :            :             // remove all old window list entries from menu
     680         [ #  # ]:          0 :             sal_uInt16 nPos = pMenu->GetItemPos( START_ITEMID_WINDOWLIST );
     681 [ #  # ][ #  # ]:          0 :             for ( sal_uInt16 n = nPos; n < pMenu->GetItemCount(); )
     682         [ #  # ]:          0 :                 pMenu->RemoveItem( n );
     683                 :            : 
     684 [ #  # ][ #  # ]:          0 :             if ( pMenu->GetItemType( pMenu->GetItemCount()-1 ) == MENUITEM_SEPARATOR )
                 [ #  # ]
     685 [ #  # ][ #  # ]:          0 :                 pMenu->RemoveItem( pMenu->GetItemCount()-1 );
     686                 :            :         }
     687                 :            : 
     688         [ #  # ]:          0 :         if ( !aNewWindowListVector.empty() )
     689                 :            :         {
     690                 :            :             // append new window list entries to menu
     691         [ #  # ]:          0 :             pMenu->InsertSeparator();
     692                 :          0 :             nItemId = START_ITEMID_WINDOWLIST;
     693                 :          0 :             const sal_uInt32 nCount = aNewWindowListVector.size();
     694         [ #  # ]:          0 :             for ( sal_uInt32 i = 0; i < nCount; i++ )
     695                 :            :             {
     696 [ #  # ][ #  # ]:          0 :                 pMenu->InsertItem( nItemId, aNewWindowListVector.at( i ), MIB_RADIOCHECK );
         [ #  # ][ #  # ]
     697         [ #  # ]:          0 :                 if ( nItemId == nActiveItemId )
     698         [ #  # ]:          0 :                     pMenu->CheckItem( nItemId );
     699                 :          0 :                 ++nItemId;
     700                 :            :             }
     701         [ #  # ]:          0 :         }
     702                 :          0 :     }
     703                 :          0 : }
     704                 :            : 
     705                 :            : 
     706                 :          0 : void MenuManager::CreatePicklistArguments( Sequence< PropertyValue >& aArgsList, const MenuItemHandler* pMenuItemHandler )
     707                 :            : {
     708                 :          0 :     int NUM_OF_PICKLIST_ARGS = 3;
     709                 :            : 
     710                 :          0 :     Any a;
     711         [ #  # ]:          0 :     aArgsList.realloc( NUM_OF_PICKLIST_ARGS );
     712                 :            : 
     713 [ #  # ][ #  # ]:          0 :     aArgsList[0].Name = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "FileName" ));
     714         [ #  # ]:          0 :     a <<= pMenuItemHandler->aMenuItemURL;
     715         [ #  # ]:          0 :     aArgsList[0].Value = a;
     716                 :            : 
     717 [ #  # ][ #  # ]:          0 :     aArgsList[1].Name = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Referer" ));
     718 [ #  # ][ #  # ]:          0 :     a <<= ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( SFX_REFERER_USER ));
     719         [ #  # ]:          0 :     aArgsList[1].Value = a;
     720                 :            : 
     721                 :          0 :     ::rtl::OUString aFilter( pMenuItemHandler->aFilter );
     722                 :            : 
     723                 :          0 :     sal_Int32 nPos = aFilter.indexOf( '|' );
     724         [ #  # ]:          0 :     if ( nPos >= 0 )
     725                 :            :     {
     726                 :          0 :         ::rtl::OUString aFilterOptions;
     727                 :            : 
     728         [ #  # ]:          0 :         if ( nPos < ( aFilter.getLength() - 1 ) )
     729                 :          0 :             aFilterOptions = aFilter.copy( nPos+1 );
     730                 :            : 
     731 [ #  # ][ #  # ]:          0 :         aArgsList[2].Name = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "FilterOptions" ));
     732         [ #  # ]:          0 :         a <<= aFilterOptions;
     733         [ #  # ]:          0 :         aArgsList[2].Value = a;
     734                 :            : 
     735                 :          0 :         aFilter = aFilter.copy( 0, nPos-1 );
     736         [ #  # ]:          0 :         aArgsList.realloc( ++NUM_OF_PICKLIST_ARGS );
     737                 :            :     }
     738                 :            : 
     739 [ #  # ][ #  # ]:          0 :     aArgsList[NUM_OF_PICKLIST_ARGS-1].Name = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "FilterName" ));
     740         [ #  # ]:          0 :     a <<= aFilter;
     741         [ #  # ]:          0 :     aArgsList[NUM_OF_PICKLIST_ARGS-1].Value = a;
     742                 :          0 : }
     743                 :            : 
     744                 :            : 
     745                 :            : //_________________________________________________________________________________________________________________
     746                 :            : // vcl handler
     747                 :            : //_________________________________________________________________________________________________________________
     748                 :            : 
     749                 :          0 : IMPL_LINK( MenuManager, Activate, Menu *, pMenu )
     750                 :            : {
     751         [ #  # ]:          0 :     if ( pMenu == m_pVCLMenu )
     752                 :            :     {
     753                 :            :         // set/unset hiding disabled menu entries
     754 [ #  # ][ #  # ]:          0 :         sal_Bool bDontHide          = SvtMenuOptions().IsEntryHidingEnabled();
                 [ #  # ]
     755         [ #  # ]:          0 :         const StyleSettings& rSettings = Application::GetSettings().GetStyleSettings();
     756         [ #  # ]:          0 :         sal_Bool bShowMenuImages    = rSettings.GetUseImagesInMenus();
     757                 :            : 
     758                 :          0 :         sal_uInt16 nFlag = pMenu->GetMenuFlags();
     759         [ #  # ]:          0 :         if ( bDontHide )
     760                 :          0 :             nFlag &= ~MENU_FLAG_HIDEDISABLEDENTRIES;
     761                 :            :         else
     762                 :          0 :             nFlag |= MENU_FLAG_HIDEDISABLEDENTRIES;
     763                 :          0 :         pMenu->SetMenuFlags( nFlag );
     764                 :            : 
     765         [ #  # ]:          0 :         if ( m_bActive )
     766                 :          0 :             return 0;
     767                 :            : 
     768                 :          0 :         m_bActive = sal_True;
     769                 :            : 
     770                 :          0 :         ::rtl::OUString aCommand( m_aMenuItemCommand );
     771         [ #  # ]:          0 :         if (m_aMenuItemCommand.matchIgnoreAsciiCaseAsciiL(RTL_CONSTASCII_STRINGPARAM(UNO_COMMAND)))
     772                 :            :         {
     773                 :            :             // Remove protocol part from command so we can use an easier comparision method
     774                 :          0 :             aCommand = aCommand.copy(RTL_CONSTASCII_LENGTH(UNO_COMMAND));
     775                 :            :         }
     776                 :            : 
     777 [ #  # ][ #  # ]:          0 :         if ( m_aMenuItemCommand == aSpecialFileMenu || m_aMenuItemCommand == aSlotSpecialFileMenu || aCommand == aSpecialFileCommand )
         [ #  # ][ #  # ]
     778         [ #  # ]:          0 :             UpdateSpecialFileMenu( pMenu );
     779 [ #  # ][ #  # ]:          0 :         else if ( m_aMenuItemCommand == aSpecialWindowMenu || m_aMenuItemCommand == aSlotSpecialWindowMenu || aCommand == aSpecialWindowCommand )
         [ #  # ][ #  # ]
     780         [ #  # ]:          0 :             UpdateSpecialWindowMenu( pMenu, getServiceFactory(), m_aLock );
     781                 :            : 
     782                 :            :         // Check if some modes have changed so we have to update our menu images
     783         [ #  # ]:          0 :         if ( bShowMenuImages != m_bShowMenuImages )
     784                 :            :         {
     785                 :            :             // The mode changed so we have to replace all images
     786                 :          0 :             m_bShowMenuImages   = bShowMenuImages;
     787         [ #  # ]:          0 :             FillMenuImages( m_xFrame, pMenu, bShowMenuImages );
     788                 :            :         }
     789                 :            : 
     790         [ #  # ]:          0 :         if ( m_bInitialized )
     791                 :          0 :             return 0;
     792                 :            :         else
     793                 :            :         {
     794                 :          0 :             URL aTargetURL;
     795                 :            : 
     796         [ #  # ]:          0 :             ResetableGuard aGuard( m_aLock );
     797                 :            : 
     798         [ #  # ]:          0 :             REFERENCE< XDISPATCHPROVIDER > xDispatchProvider( m_xFrame, UNO_QUERY );
     799         [ #  # ]:          0 :             if ( xDispatchProvider.is() )
     800                 :            :             {
     801                 :          0 :                 std::vector< MenuItemHandler* >::iterator p;
     802 [ #  # ][ #  # ]:          0 :                 for ( p = m_aMenuItemHandlerVector.begin(); p != m_aMenuItemHandlerVector.end(); ++p )
     803                 :            :                 {
     804                 :          0 :                     MenuItemHandler* pMenuItemHandler = *p;
     805   [ #  #  #  # ]:          0 :                     if ( pMenuItemHandler &&
         [ #  # ][ #  # ]
     806                 :            :                          pMenuItemHandler->pSubMenuManager == 0 &&
     807                 :          0 :                          !pMenuItemHandler->xMenuItemDispatch.is() )
     808                 :            :                     {
     809                 :            :                         // There is no dispatch mechanism for the special window list menu items,
     810                 :            :                         // because they are handled directly through XFrame->activate!!!
     811 [ #  # ][ #  # ]:          0 :                         if ( pMenuItemHandler->nItemId < START_ITEMID_WINDOWLIST ||
     812                 :            :                              pMenuItemHandler->nItemId > END_ITEMID_WINDOWLIST )
     813                 :            :                         {
     814 [ #  # ][ #  # ]:          0 :                             ::rtl::OUString aItemCommand = pMenu->GetItemCommand( pMenuItemHandler->nItemId );
     815         [ #  # ]:          0 :                             if ( aItemCommand.isEmpty() )
     816                 :            :                             {
     817 [ #  # ][ #  # ]:          0 :                                 const static ::rtl::OUString aSlotString( RTL_CONSTASCII_USTRINGPARAM( "slot:" ));
         [ #  # ][ #  # ]
     818                 :          0 :                                 aItemCommand = aSlotString;
     819                 :          0 :                                 aItemCommand += ::rtl::OUString::valueOf( (sal_Int32)pMenuItemHandler->nItemId );
     820 [ #  # ][ #  # ]:          0 :                                 pMenu->SetItemCommand( pMenuItemHandler->nItemId, aItemCommand );
                 [ #  # ]
     821                 :            :                             }
     822                 :            : 
     823                 :          0 :                             aTargetURL.Complete = aItemCommand;
     824                 :            : 
     825 [ #  # ][ #  # ]:          0 :                             m_xURLTransformer->parseStrict( aTargetURL );
     826                 :            : 
     827                 :          0 :                             REFERENCE< XDISPATCH > xMenuItemDispatch;
     828         [ #  # ]:          0 :                             if ( m_bIsBookmarkMenu )
     829 [ #  # ][ #  # ]:          0 :                                 xMenuItemDispatch = xDispatchProvider->queryDispatch( aTargetURL, pMenuItemHandler->aTargetFrame, 0 );
                 [ #  # ]
     830                 :            :                             else
     831 [ #  # ][ #  # ]:          0 :                                 xMenuItemDispatch = xDispatchProvider->queryDispatch( aTargetURL, ::rtl::OUString(), 0 );
                 [ #  # ]
     832                 :            : 
     833         [ #  # ]:          0 :                             if ( xMenuItemDispatch.is() )
     834                 :            :                             {
     835         [ #  # ]:          0 :                                 pMenuItemHandler->xMenuItemDispatch = xMenuItemDispatch;
     836                 :          0 :                                 pMenuItemHandler->aMenuItemURL      = aTargetURL.Complete;
     837 [ #  # ][ #  # ]:          0 :                                 xMenuItemDispatch->addStatusListener( (static_cast< XSTATUSLISTENER* >(this)), aTargetURL );
                 [ #  # ]
     838                 :            :                             }
     839                 :            :                             else
     840         [ #  # ]:          0 :                                 pMenu->EnableItem( pMenuItemHandler->nItemId, sal_False );
     841                 :            :                         }
     842                 :            :                     }
     843                 :            :                 }
     844         [ #  # ]:          0 :             }
     845         [ #  # ]:          0 :         }
     846                 :            :     }
     847                 :            : 
     848                 :          0 :     return 1;
     849                 :            : }
     850                 :            : 
     851                 :            : 
     852                 :          0 : IMPL_LINK( MenuManager, Deactivate, Menu *, pMenu )
     853                 :            : {
     854         [ #  # ]:          0 :     if ( pMenu == m_pVCLMenu )
     855                 :          0 :         m_bActive = sal_False;
     856                 :            : 
     857                 :          0 :     return 1;
     858                 :            : }
     859                 :            : 
     860                 :            : 
     861                 :          0 : IMPL_LINK( MenuManager, Select, Menu *, pMenu )
     862                 :            : {
     863                 :          0 :     URL                     aTargetURL;
     864         [ #  # ]:          0 :     Sequence<PropertyValue> aArgs;
     865                 :          0 :     REFERENCE< XDISPATCH >  xDispatch;
     866                 :            : 
     867                 :            :     {
     868         [ #  # ]:          0 :         ResetableGuard aGuard( m_aLock );
     869                 :            : 
     870         [ #  # ]:          0 :         sal_uInt16 nCurItemId = pMenu->GetCurItemId();
     871 [ #  # ][ #  # ]:          0 :         if ( pMenu == m_pVCLMenu &&
                 [ #  # ]
     872         [ #  # ]:          0 :              pMenu->GetItemType( nCurItemId ) != MENUITEM_SEPARATOR )
     873                 :            :         {
     874 [ #  # ][ #  # ]:          0 :             if ( nCurItemId >= START_ITEMID_WINDOWLIST &&
     875                 :            :                  nCurItemId <= END_ITEMID_WINDOWLIST )
     876                 :            :             {
     877                 :            :                 // window list menu item selected
     878                 :            : 
     879 [ #  # ][ #  # ]:          0 :                 Reference< XFramesSupplier > xDesktop( getServiceFactory()->createInstance( SERVICENAME_DESKTOP ), UNO_QUERY );
         [ #  # ][ #  # ]
     880                 :            : 
     881         [ #  # ]:          0 :                 if ( xDesktop.is() )
     882                 :            :                 {
     883                 :          0 :                     sal_uInt16 nTaskId = START_ITEMID_WINDOWLIST;
     884 [ #  # ][ #  # ]:          0 :                     Reference< XIndexAccess > xList( xDesktop->getFrames(), UNO_QUERY );
                 [ #  # ]
     885 [ #  # ][ #  # ]:          0 :                     sal_Int32 nCount = xList->getCount();
     886         [ #  # ]:          0 :                     for ( sal_Int32 i=0; i<nCount; ++i )
     887                 :            :                     {
     888                 :          0 :                         Reference< XFrame > xFrame;
     889 [ #  # ][ #  # ]:          0 :                         xList->getByIndex(i) >>= xFrame;
                 [ #  # ]
     890                 :            : 
     891 [ #  # ][ #  # ]:          0 :                         if ( xFrame.is() && nTaskId == nCurItemId )
                 [ #  # ]
     892                 :            :                         {
     893 [ #  # ][ #  # ]:          0 :                             Window* pWin = VCLUnoHelper::GetWindow( xFrame->getContainerWindow() );
                 [ #  # ]
     894         [ #  # ]:          0 :                             pWin->GrabFocus();
     895         [ #  # ]:          0 :                             pWin->ToTop( TOTOP_RESTOREWHENMIN );
     896                 :            :                             break;
     897                 :            :                         }
     898                 :            : 
     899         [ #  # ]:          0 :                         nTaskId++;
     900                 :          0 :                     }
     901                 :          0 :                 }
     902                 :            :             }
     903                 :            :             else
     904                 :            :             {
     905         [ #  # ]:          0 :                 MenuItemHandler* pMenuItemHandler = GetMenuItemHandler( nCurItemId );
     906 [ #  # ][ #  # ]:          0 :                 if ( pMenuItemHandler && pMenuItemHandler->xMenuItemDispatch.is() )
                 [ #  # ]
     907                 :            :                 {
     908                 :          0 :                     aTargetURL.Complete = pMenuItemHandler->aMenuItemURL;
     909 [ #  # ][ #  # ]:          0 :                     m_xURLTransformer->parseStrict( aTargetURL );
     910                 :            : 
     911 [ #  # ][ #  # ]:          0 :                     if ( nCurItemId >= START_ITEMID_PICKLIST &&
     912                 :            :                          nCurItemId <  START_ITEMID_WINDOWLIST )
     913                 :            :                     {
     914                 :            :                         // picklist menu item selected
     915         [ #  # ]:          0 :                         CreatePicklistArguments( aArgs, pMenuItemHandler );
     916                 :            :                     }
     917         [ #  # ]:          0 :                     else if ( m_bIsBookmarkMenu )
     918                 :            :                     {
     919                 :            :                         // bookmark menu item selected
     920         [ #  # ]:          0 :                         aArgs.realloc( 1 );
     921 [ #  # ][ #  # ]:          0 :                         aArgs[0].Name = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Referer" ));
     922 [ #  # ][ #  # ]:          0 :                         aArgs[0].Value <<= ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( SFX_REFERER_USER ));
                 [ #  # ]
     923                 :            :                     }
     924                 :            : 
     925         [ #  # ]:          0 :                     xDispatch = pMenuItemHandler->xMenuItemDispatch;
     926                 :            :                 }
     927                 :            :             }
     928         [ #  # ]:          0 :         }
     929                 :            :     }
     930                 :            : 
     931         [ #  # ]:          0 :     if ( xDispatch.is() )
     932 [ #  # ][ #  # ]:          0 :         xDispatch->dispatch( aTargetURL, aArgs );
     933                 :            : 
     934         [ #  # ]:          0 :     return 1;
     935                 :            : }
     936                 :            : 
     937                 :            : 
     938                 :          0 : IMPL_LINK_NOARG(MenuManager, Highlight)
     939                 :            : {
     940                 :          0 :     return 0;
     941                 :            : }
     942                 :            : 
     943                 :          0 : const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& MenuManager::getServiceFactory()
     944                 :            : {
     945                 :          0 :     return mxServiceFactory;
     946                 :            : }
     947                 :            : 
     948                 :          0 : void MenuManager::AddMenu(PopupMenu* _pPopupMenu,const ::rtl::OUString& _sItemCommand,sal_uInt16 _nItemId,sal_Bool _bDelete,sal_Bool _bDeleteChildren)
     949                 :            : {
     950         [ #  # ]:          0 :     MenuManager* pSubMenuManager = new MenuManager( getServiceFactory(), m_xFrame, _pPopupMenu, _bDelete, _bDeleteChildren );
     951                 :            : 
     952                 :            :     // store menu item command as we later have to know which menu is active (see Activate handler)
     953                 :          0 :     pSubMenuManager->m_aMenuItemCommand = _sItemCommand;
     954                 :            : 
     955                 :          0 :     REFERENCE< XDISPATCH > aXDispatchRef;
     956                 :            :     MenuItemHandler* pMenuItemHandler = new MenuItemHandler(
     957                 :            :                                                 _nItemId,
     958                 :            :                                                 pSubMenuManager,
     959 [ #  # ][ #  # ]:          0 :                                                 aXDispatchRef );
     960         [ #  # ]:          0 :     m_aMenuItemHandlerVector.push_back( pMenuItemHandler );
     961                 :          0 : }
     962                 :            : 
     963                 :          0 : sal_uInt16 MenuManager::FillItemCommand(::rtl::OUString& _rItemCommand,Menu* _pMenu,sal_uInt16 _nIndex) const
     964                 :            : {
     965                 :          0 :     sal_uInt16 nItemId = _pMenu->GetItemId( _nIndex );
     966                 :            : 
     967                 :          0 :     _rItemCommand = _pMenu->GetItemCommand( nItemId );
     968         [ #  # ]:          0 :     if ( _rItemCommand.isEmpty() )
     969                 :            :     {
     970 [ #  # ][ #  # ]:          0 :         const static ::rtl::OUString aSlotString( RTL_CONSTASCII_USTRINGPARAM( "slot:" ));
         [ #  # ][ #  # ]
     971                 :          0 :         _rItemCommand = aSlotString;
     972                 :          0 :         _rItemCommand += ::rtl::OUString::valueOf( (sal_Int32)nItemId );
     973         [ #  # ]:          0 :         _pMenu->SetItemCommand( nItemId, _rItemCommand );
     974                 :            :     }
     975                 :          0 :     return nItemId;
     976                 :            : }
     977                 :          6 : void MenuManager::FillMenuImages(Reference< XFrame >& _xFrame,Menu* _pMenu,sal_Bool bShowMenuImages)
     978                 :            : {
     979         [ +  - ]:          6 :     AddonsOptions       aAddonOptions;
     980                 :            : 
     981 [ +  - ][ +  + ]:        164 :     for ( sal_uInt16 nPos = 0; nPos < _pMenu->GetItemCount(); nPos++ )
     982                 :            :     {
     983         [ +  - ]:        158 :         sal_uInt16 nId = _pMenu->GetItemId( nPos );
     984 [ +  - ][ +  + ]:        158 :         if ( _pMenu->GetItemType( nPos ) != MENUITEM_SEPARATOR )
     985                 :            :         {
     986                 :        134 :             bool bTmpShowMenuImages( bShowMenuImages );
     987                 :            :             // overwrite the show icons on menu option?
     988         [ -  + ]:        134 :             if (!bTmpShowMenuImages)
     989                 :            :             {
     990         [ #  # ]:          0 :                 MenuItemBits nBits =  _pMenu->GetItemBits( nId );
     991                 :          0 :                 bTmpShowMenuImages = ( ( nBits & MIB_ICON ) == MIB_ICON );
     992                 :            :             }
     993                 :            : 
     994         [ +  - ]:        134 :             if ( bTmpShowMenuImages )
     995                 :            :             {
     996                 :        134 :                 sal_Bool        bImageSet = sal_False;
     997                 :        134 :                 ::rtl::OUString aImageId;
     998                 :            : 
     999                 :            :                 ::framework::MenuConfiguration::Attributes* pMenuAttributes =
    1000         [ +  - ]:        134 :                     (::framework::MenuConfiguration::Attributes*)_pMenu->GetUserValue( nId );
    1001                 :            : 
    1002         [ -  + ]:        134 :                 if ( pMenuAttributes )
    1003                 :          0 :                     aImageId = pMenuAttributes->aImageId; // Retrieve image id from menu attributes
    1004                 :            : 
    1005         [ -  + ]:        134 :                 if ( !aImageId.isEmpty() )
    1006                 :            :                 {
    1007         [ #  # ]:          0 :                     Image aImage = GetImageFromURL( _xFrame, aImageId, false );
    1008         [ #  # ]:          0 :                     if ( !!aImage )
    1009                 :            :                     {
    1010                 :          0 :                         bImageSet = sal_True;
    1011         [ #  # ]:          0 :                         _pMenu->SetItemImage( nId, aImage );
    1012         [ #  # ]:          0 :                     }
    1013                 :            :                 }
    1014                 :            : 
    1015         [ +  - ]:        134 :                 if ( !bImageSet )
    1016                 :            :                 {
    1017 [ +  - ][ +  - ]:        134 :                     rtl::OUString aMenuItemCommand = _pMenu->GetItemCommand( nId );
    1018         [ +  - ]:        134 :                     Image aImage = GetImageFromURL( _xFrame, aMenuItemCommand, false );
    1019         [ +  + ]:        134 :                     if ( !aImage )
    1020 [ +  - ][ +  - ]:         68 :                         aImage = aAddonOptions.GetImageFromURL( aMenuItemCommand, false );
                 [ +  - ]
    1021                 :            : 
    1022 [ +  - ][ +  - ]:        134 :                     _pMenu->SetItemImage( nId, aImage );
    1023                 :        134 :                 }
    1024                 :            :             }
    1025                 :            :             else
    1026 [ #  # ][ #  # ]:          0 :                 _pMenu->SetItemImage( nId, Image() );
                 [ #  # ]
    1027                 :            :         }
    1028         [ +  - ]:          6 :     }
    1029                 :          6 : }
    1030                 :            : }
    1031                 :            : 
    1032                 :            : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10