LCOV - code coverage report
Current view: top level - framework/source/uielement - controlmenucontroller.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 28 133 21.1 %
Date: 2012-08-25 Functions: 12 20 60.0 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 26 274 9.5 %

           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 <sal/macros.h>
      30                 :            : #include <uielement/controlmenucontroller.hxx>
      31                 :            : 
      32                 :            : #include <threadhelp/resetableguard.hxx>
      33                 :            : #include "services.h"
      34                 :            : 
      35                 :            : #include <com/sun/star/awt/XDevice.hpp>
      36                 :            : #include <com/sun/star/beans/PropertyValue.hpp>
      37                 :            : #include <com/sun/star/awt/MenuItemStyle.hpp>
      38                 :            : #include <com/sun/star/frame/XDispatchProvider.hpp>
      39                 :            : #include <com/sun/star/style/XStyleFamiliesSupplier.hpp>
      40                 :            : #include <com/sun/star/container/XNameContainer.hpp>
      41                 :            : #include <com/sun/star/beans/XPropertySet.hpp>
      42                 :            : 
      43                 :            : #include <vcl/menu.hxx>
      44                 :            : #include <vcl/svapp.hxx>
      45                 :            : #include <vcl/i18nhelp.hxx>
      46                 :            : #include <rtl/ustrbuf.hxx>
      47                 :            : #include <rtl/strbuf.hxx>
      48                 :            : #include <svl/solar.hrc>
      49                 :            : #include <tools/rcid.h>
      50                 :            : #include <vcl/image.hxx>
      51                 :            : #include <svtools/menuoptions.hxx>
      52                 :            : #include <osl/mutex.hxx>
      53                 :            : 
      54                 :            : // Copied from svx
      55                 :            : // Function-Id's
      56                 :            : #define RID_FMSHELL_CONVERSIONMENU (RID_FORMS_START + 4)
      57                 :            : #define RID_SVXIMGLIST_FMEXPL      (RID_FORMS_START + 0)
      58                 :            : 
      59                 :            : // Forms - Ids, used to address images from image list
      60                 :            : #define SID_FMSLOTS_START                   (SID_SVX_START + 592)
      61                 :            : #define SID_MORE_FMSLOTS_START              (SID_SVX_START + 702)
      62                 :            : 
      63                 :            : #define SID_FM_CONVERTTO_EDIT               (SID_MORE_FMSLOTS_START +  32)
      64                 :            : #define SID_FM_CONVERTTO_BUTTON             (SID_MORE_FMSLOTS_START +  33)
      65                 :            : #define SID_FM_CONVERTTO_FIXEDTEXT          (SID_MORE_FMSLOTS_START +  34)
      66                 :            : #define SID_FM_CONVERTTO_LISTBOX            (SID_MORE_FMSLOTS_START +  35)
      67                 :            : #define SID_FM_CONVERTTO_CHECKBOX           (SID_MORE_FMSLOTS_START +  36)
      68                 :            : #define SID_FM_CONVERTTO_RADIOBUTTON        (SID_MORE_FMSLOTS_START +  37)
      69                 :            : #define SID_FM_CONVERTTO_GROUPBOX           (SID_MORE_FMSLOTS_START +  38)
      70                 :            : #define SID_FM_CONVERTTO_COMBOBOX           (SID_MORE_FMSLOTS_START +  39)
      71                 :            : #define SID_FM_CONVERTTO_GRID               (SID_MORE_FMSLOTS_START +  40)
      72                 :            : #define SID_FM_CONVERTTO_IMAGEBUTTON        (SID_MORE_FMSLOTS_START +  41)
      73                 :            : #define SID_FM_CONVERTTO_FILECONTROL        (SID_MORE_FMSLOTS_START +  42)
      74                 :            : #define SID_FM_CONVERTTO_DATE               (SID_MORE_FMSLOTS_START +  43)
      75                 :            : #define SID_FM_CONVERTTO_TIME               (SID_MORE_FMSLOTS_START +  44)
      76                 :            : #define SID_FM_CONVERTTO_NUMERIC            (SID_MORE_FMSLOTS_START +  45)
      77                 :            : #define SID_FM_CONVERTTO_CURRENCY           (SID_MORE_FMSLOTS_START +  46)
      78                 :            : #define SID_FM_CONVERTTO_PATTERN            (SID_MORE_FMSLOTS_START +  47)
      79                 :            : #define SID_FM_CONVERTTO_IMAGECONTROL       (SID_MORE_FMSLOTS_START +  48)
      80                 :            : #define SID_FM_CONVERTTO_FORMATTED          (SID_MORE_FMSLOTS_START +  49)
      81                 :            : #define SID_FM_CONVERTTO_SCROLLBAR          (SID_MORE_FMSLOTS_START +  68)
      82                 :            : #define SID_FM_CONVERTTO_SPINBUTTON         (SID_MORE_FMSLOTS_START +  69)
      83                 :            : 
      84                 :            : #define SID_FM_DATEFIELD                    (SID_MORE_FMSLOTS_START +   2)
      85                 :            : #define SID_FM_TIMEFIELD                    (SID_MORE_FMSLOTS_START +   3)
      86                 :            : #define SID_FM_NUMERICFIELD                 (SID_MORE_FMSLOTS_START +   4)
      87                 :            : #define SID_FM_CURRENCYFIELD                (SID_MORE_FMSLOTS_START +   5)
      88                 :            : #define SID_FM_PATTERNFIELD                 (SID_MORE_FMSLOTS_START +   6)
      89                 :            : #define SID_FM_IMAGECONTROL                 (SID_MORE_FMSLOTS_START +   8)
      90                 :            : #define SID_FM_FORMATTEDFIELD               (SID_MORE_FMSLOTS_START +  26)
      91                 :            : #define SID_FM_SCROLLBAR                    (SID_MORE_FMSLOTS_START +  66)
      92                 :            : #define SID_FM_SPINBUTTON                   (SID_MORE_FMSLOTS_START +  67)
      93                 :            : #define SID_FM_CONFIG                       (SID_FMSLOTS_START + 1)
      94                 :            : #define SID_FM_PUSHBUTTON                   (SID_FMSLOTS_START + 2)
      95                 :            : #define SID_FM_RADIOBUTTON                  (SID_FMSLOTS_START + 3)
      96                 :            : #define SID_FM_CHECKBOX                     (SID_FMSLOTS_START + 4)
      97                 :            : #define SID_FM_FIXEDTEXT                    (SID_FMSLOTS_START + 5)
      98                 :            : #define SID_FM_GROUPBOX                     (SID_FMSLOTS_START + 6)
      99                 :            : #define SID_FM_EDIT                         (SID_FMSLOTS_START + 7)
     100                 :            : #define SID_FM_LISTBOX                      (SID_FMSLOTS_START + 8)
     101                 :            : #define SID_FM_COMBOBOX                     (SID_FMSLOTS_START + 9)
     102                 :            : #define SID_FM_URLBUTTON                    (SID_FMSLOTS_START + 10)
     103                 :            : #define SID_FM_DBGRID                       (SID_FMSLOTS_START + 11)
     104                 :            : #define SID_FM_IMAGEBUTTON                  (SID_FMSLOTS_START + 12)
     105                 :            : #define SID_FM_FILECONTROL                  (SID_FMSLOTS_START + 13)
     106                 :            : 
     107                 :            : static sal_Int16 nConvertSlots[] =
     108                 :            : {
     109                 :            :     SID_FM_CONVERTTO_EDIT,
     110                 :            :     SID_FM_CONVERTTO_BUTTON,
     111                 :            :     SID_FM_CONVERTTO_FIXEDTEXT,
     112                 :            :     SID_FM_CONVERTTO_LISTBOX,
     113                 :            :     SID_FM_CONVERTTO_CHECKBOX,
     114                 :            :     SID_FM_CONVERTTO_RADIOBUTTON,
     115                 :            :     SID_FM_CONVERTTO_GROUPBOX,
     116                 :            :     SID_FM_CONVERTTO_COMBOBOX,
     117                 :            : //  SID_FM_CONVERTTO_GRID,
     118                 :            :     SID_FM_CONVERTTO_IMAGEBUTTON,
     119                 :            :     SID_FM_CONVERTTO_FILECONTROL,
     120                 :            :     SID_FM_CONVERTTO_DATE,
     121                 :            :     SID_FM_CONVERTTO_TIME,
     122                 :            :     SID_FM_CONVERTTO_NUMERIC,
     123                 :            :     SID_FM_CONVERTTO_CURRENCY,
     124                 :            :     SID_FM_CONVERTTO_PATTERN,
     125                 :            :     SID_FM_CONVERTTO_IMAGECONTROL,
     126                 :            :     SID_FM_CONVERTTO_FORMATTED,
     127                 :            :     SID_FM_CONVERTTO_SCROLLBAR,
     128                 :            :     SID_FM_CONVERTTO_SPINBUTTON
     129                 :            : };
     130                 :            : 
     131                 :            : static sal_Int16 nCreateSlots[] =
     132                 :            : {
     133                 :            :     SID_FM_EDIT,
     134                 :            :     SID_FM_PUSHBUTTON,
     135                 :            :     SID_FM_FIXEDTEXT,
     136                 :            :     SID_FM_LISTBOX,
     137                 :            :     SID_FM_CHECKBOX,
     138                 :            :     SID_FM_RADIOBUTTON,
     139                 :            :     SID_FM_GROUPBOX,
     140                 :            :     SID_FM_COMBOBOX,
     141                 :            : //  SID_FM_DBGRID,
     142                 :            :     SID_FM_IMAGEBUTTON,
     143                 :            :     SID_FM_FILECONTROL,
     144                 :            :     SID_FM_DATEFIELD,
     145                 :            :     SID_FM_TIMEFIELD,
     146                 :            :     SID_FM_NUMERICFIELD,
     147                 :            :     SID_FM_CURRENCYFIELD,
     148                 :            :     SID_FM_PATTERNFIELD,
     149                 :            :     SID_FM_IMAGECONTROL,
     150                 :            :     SID_FM_FORMATTEDFIELD,
     151                 :            :     SID_FM_SCROLLBAR,
     152                 :            :     SID_FM_SPINBUTTON
     153                 :            : };
     154                 :            : 
     155                 :            : const char* aCommands[] =
     156                 :            : {
     157                 :            :     ".uno:ConvertToEdit",
     158                 :            :     ".uno:ConvertToButton",
     159                 :            :     ".uno:ConvertToFixed",
     160                 :            :     ".uno:ConvertToList",
     161                 :            :     ".uno:ConvertToCheckBox",
     162                 :            :     ".uno:ConvertToRadio",
     163                 :            :     ".uno:ConvertToGroup",
     164                 :            :     ".uno:ConvertToCombo",
     165                 :            : //    ".uno:ConvertToGrid",
     166                 :            :     ".uno:ConvertToImageBtn",
     167                 :            :     ".uno:ConvertToFileControl",
     168                 :            :     ".uno:ConvertToDate",
     169                 :            :     ".uno:ConvertToTime",
     170                 :            :     ".uno:ConvertToNumeric",
     171                 :            :     ".uno:ConvertToCurrency",
     172                 :            :     ".uno:ConvertToPattern",
     173                 :            :     ".uno:ConvertToImageControl",
     174                 :            :     ".uno:ConvertToFormatted",
     175                 :            :     ".uno:ConvertToScrollBar",
     176                 :            :     ".uno:ConvertToSpinButton"
     177                 :            : };
     178                 :            : 
     179                 :            : //_________________________________________________________________________________________________________________
     180                 :            : //  Defines
     181                 :            : //_________________________________________________________________________________________________________________
     182                 :            : 
     183                 :            : using namespace com::sun::star::uno;
     184                 :            : using namespace com::sun::star::lang;
     185                 :            : using namespace com::sun::star::frame;
     186                 :            : using namespace com::sun::star::beans;
     187                 :            : using namespace com::sun::star::util;
     188                 :            : using namespace com::sun::star::style;
     189                 :            : using namespace com::sun::star::container;
     190                 :            : 
     191                 :            : namespace framework
     192                 :            : {
     193                 :            : 
     194 [ +  - ][ +  - ]:       2325 : DEFINE_XSERVICEINFO_MULTISERVICE        (   ControlMenuController                   ,
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
         [ +  - ][ #  # ]
                 [ #  # ]
     195                 :            :                                             OWeakObject                             ,
     196                 :            :                                             SERVICENAME_POPUPMENUCONTROLLER         ,
     197                 :            :                                             IMPLEMENTATIONNAME_CONTROLMENUCONTROLLER
     198                 :            :                                         )
     199                 :            : 
     200                 :          4 : DEFINE_INIT_SERVICE                     (   ControlMenuController, {} )
     201                 :            : 
     202                 :          4 : ControlMenuController::ControlMenuController( const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& xServiceManager ) :
     203                 :            :     svt::PopupMenuControllerBase( xServiceManager ),
     204         [ +  - ]:          4 :     m_pResPopupMenu( 0 )
     205                 :            : {
     206         [ +  - ]:          4 :     const StyleSettings& rSettings = Application::GetSettings().GetStyleSettings();
     207         [ +  - ]:          4 :     m_bShowMenuImages   = rSettings.GetUseImagesInMenus();
     208                 :            : 
     209                 :          4 : }
     210                 :            : 
     211         [ +  - ]:          4 : ControlMenuController::~ControlMenuController()
     212                 :            : {
     213         [ -  + ]:          8 : }
     214                 :            : 
     215                 :            : // private function
     216                 :          0 : void ControlMenuController::updateImagesPopupMenu( PopupMenu* pPopupMenu )
     217                 :            : {
     218 [ #  # ][ #  # ]:          0 :     ResMgr* pResMgr = ResMgr::CreateResMgr("svx", Application::GetSettings().GetUILocale());
                 [ #  # ]
     219                 :          0 :     ResId aResId( RID_SVXIMGLIST_FMEXPL, *pResMgr );
     220                 :          0 :     aResId.SetRT( RSC_IMAGELIST );
     221                 :            : 
     222 [ #  # ][ #  # ]:          0 :     if ( pResMgr->IsAvailable( aResId ))
     223                 :            :     {
     224         [ #  # ]:          0 :         ImageList aImageList( aResId );
     225         [ #  # ]:          0 :       for ( sal_uInt32 i=0; i < sizeof(nConvertSlots)/sizeof(nConvertSlots[0]); ++i )
     226                 :            :         {
     227                 :            :             // das entsprechende Image dran
     228         [ #  # ]:          0 :             if ( m_bShowMenuImages )
     229 [ #  # ][ #  # ]:          0 :                 pPopupMenu->SetItemImage( nConvertSlots[i], aImageList.GetImage(nCreateSlots[i]));
                 [ #  # ]
     230                 :            :             else
     231 [ #  # ][ #  # ]:          0 :                 pPopupMenu->SetItemImage( nConvertSlots[i], Image() );
                 [ #  # ]
     232         [ #  # ]:          0 :         }
     233                 :            :     }
     234                 :            : 
     235 [ #  # ][ #  # ]:          0 :     delete pResMgr;
     236                 :          0 : }
     237                 :            : 
     238                 :            : // private function
     239                 :          0 : void ControlMenuController::fillPopupMenu( Reference< css::awt::XPopupMenu >& rPopupMenu )
     240                 :            : {
     241                 :          0 :     VCLXPopupMenu*                                     pPopupMenu        = (VCLXPopupMenu *)VCLXMenu::GetImplementation( rPopupMenu );
     242                 :          0 :     PopupMenu*                                         pVCLPopupMenu     = 0;
     243                 :            : 
     244         [ #  # ]:          0 :     SolarMutexGuard aSolarMutexGuard;
     245                 :            : 
     246         [ #  # ]:          0 :     resetPopupMenu( rPopupMenu );
     247         [ #  # ]:          0 :     if ( pPopupMenu )
     248                 :          0 :         pVCLPopupMenu = (PopupMenu *)pPopupMenu->GetMenu();
     249                 :            : 
     250 [ #  # ][ #  # ]:          0 :     if ( pVCLPopupMenu && m_pResPopupMenu )
     251 [ #  # ][ #  # ]:          0 :         *pVCLPopupMenu = *m_pResPopupMenu;
     252                 :          0 : }
     253                 :            : 
     254                 :            : // XEventListener
     255                 :          0 : void SAL_CALL ControlMenuController::disposing( const EventObject& ) throw ( RuntimeException )
     256                 :            : {
     257         [ #  # ]:          0 :     Reference< css::awt::XMenuListener > xHolder(( OWeakObject *)this, UNO_QUERY );
     258                 :            : 
     259         [ #  # ]:          0 :     osl::ResettableMutexGuard aLock( m_aMutex );
     260                 :          0 :     m_xFrame.clear();
     261                 :          0 :     m_xDispatch.clear();
     262                 :          0 :     m_xServiceManager.clear();
     263                 :            : 
     264         [ #  # ]:          0 :     if ( m_xPopupMenu.is() )
     265 [ #  # ][ #  # ]:          0 :         m_xPopupMenu->removeMenuListener( Reference< css::awt::XMenuListener >(( OWeakObject *)this, UNO_QUERY ));
                 [ #  # ]
     266                 :          0 :     m_xPopupMenu.clear();
     267 [ #  # ][ #  # ]:          0 :     delete m_pResPopupMenu;
                 [ #  # ]
     268                 :          0 : }
     269                 :            : 
     270                 :            : // XStatusListener
     271                 :          2 : void SAL_CALL ControlMenuController::statusChanged( const FeatureStateEvent& Event ) throw ( RuntimeException )
     272                 :            : {
     273         [ +  - ]:          2 :     osl::ResettableMutexGuard aLock( m_aMutex );
     274                 :            : 
     275                 :          2 :     sal_uInt16 nMenuId = 0;
     276         [ +  + ]:         40 :     for (sal_uInt32 i=0; i < sizeof(aCommands) / sizeof (aCommands[0]); ++i)
     277                 :            :     {
     278         [ -  + ]:         38 :         if ( Event.FeatureURL.Complete.equalsAscii( aCommands[i] ))
     279                 :            :         {
     280                 :          0 :             nMenuId = nConvertSlots[i];
     281                 :          0 :             break;
     282                 :            :         }
     283                 :            :     }
     284                 :            : 
     285         [ -  + ]:          2 :     if ( nMenuId )
     286                 :            :     {
     287                 :          0 :         VCLXPopupMenu*  pPopupMenu = (VCLXPopupMenu *)VCLXMenu::GetImplementation( m_xPopupMenu );
     288                 :            : 
     289         [ #  # ]:          0 :         SolarMutexGuard aSolarMutexGuard;
     290                 :            : 
     291                 :          0 :         PopupMenu* pVCLPopupMenu = (PopupMenu *)pPopupMenu->GetMenu();
     292                 :            : 
     293 [ #  # ][ #  # ]:          0 :         if ( !Event.IsEnabled && pVCLPopupMenu->GetItemPos( nMenuId ) != MENU_ITEM_NOTFOUND )
         [ #  # ][ #  # ]
     294 [ #  # ][ #  # ]:          0 :             pVCLPopupMenu->RemoveItem( pVCLPopupMenu->GetItemPos( nMenuId ));
     295 [ #  # ][ #  # ]:          0 :         else if ( Event.IsEnabled && pVCLPopupMenu->GetItemPos( nMenuId ) == MENU_ITEM_NOTFOUND )
         [ #  # ][ #  # ]
     296                 :            :         {
     297         [ #  # ]:          0 :             sal_Int16 nSourcePos = m_pResPopupMenu->GetItemPos(nMenuId);
     298                 :          0 :             sal_Int16 nPrevInSource = nSourcePos;
     299                 :          0 :             sal_uInt16 nPrevInConversion = MENU_ITEM_NOTFOUND;
     300         [ #  # ]:          0 :             while (nPrevInSource>0)
     301                 :            :             {
     302         [ #  # ]:          0 :                 sal_Int16 nPrevId = m_pResPopupMenu->GetItemId(--nPrevInSource);
     303                 :            : 
     304                 :            :                 // do we have the source's predecessor in our conversion menu, too ?
     305         [ #  # ]:          0 :                 nPrevInConversion = pVCLPopupMenu->GetItemPos( nPrevId );
     306         [ #  # ]:          0 :                 if ( nPrevInConversion != MENU_ITEM_NOTFOUND )
     307                 :          0 :                     break;
     308                 :            :             }
     309                 :            : 
     310         [ #  # ]:          0 :           if ( MENU_ITEM_NOTFOUND == nPrevInConversion )
     311                 :            :                 // none of the items which precede the nSID-slot in the source menu are present in our conversion menu
     312                 :          0 :                 nPrevInConversion = sal::static_int_cast< sal_uInt16 >(-1); // put the item at the first position
     313                 :            : 
     314 [ #  # ][ #  # ]:          0 :             pVCLPopupMenu->InsertItem( nMenuId, m_pResPopupMenu->GetItemText( nMenuId ), m_pResPopupMenu->GetItemBits( nMenuId ), ++nPrevInConversion );
         [ #  # ][ #  # ]
     315 [ #  # ][ #  # ]:          0 :             pVCLPopupMenu->SetItemImage( nMenuId, m_pResPopupMenu->GetItemImage( nMenuId ));
                 [ #  # ]
     316 [ #  # ][ #  # ]:          0 :             pVCLPopupMenu->SetHelpId( nMenuId, m_pResPopupMenu->GetHelpId( nMenuId ));
     317         [ #  # ]:          0 :         }
     318         [ +  - ]:          2 :     }
     319                 :          2 : }
     320                 :            : 
     321                 :            : // XMenuListener
     322                 :          0 : void ControlMenuController::impl_select(const Reference< XDispatch >& /*_xDispatch*/,const ::com::sun::star::util::URL& aURL)
     323                 :            : {
     324         [ #  # ]:          0 :     UrlToDispatchMap::iterator pIter = m_aURLToDispatchMap.find( aURL.Complete );
     325 [ #  # ][ #  # ]:          0 :     if ( pIter != m_aURLToDispatchMap.end() )
     326                 :            :     {
     327         [ #  # ]:          0 :         Sequence<PropertyValue>      aArgs;
     328         [ #  # ]:          0 :         Reference< XDispatch > xDispatch = pIter->second;
     329         [ #  # ]:          0 :         if ( xDispatch.is() )
     330 [ #  # ][ #  # ]:          0 :             xDispatch->dispatch( aURL, aArgs );
                 [ #  # ]
     331                 :            :     }
     332                 :          0 : }
     333                 :            : 
     334                 :          0 : void SAL_CALL ControlMenuController::activate( const css::awt::MenuEvent& ) throw (RuntimeException)
     335                 :            : {
     336         [ #  # ]:          0 :     osl::ResettableMutexGuard aLock( m_aMutex );
     337                 :            : 
     338         [ #  # ]:          0 :     if ( m_xPopupMenu.is() )
     339                 :            :     {
     340         [ #  # ]:          0 :         SolarMutexGuard aSolarMutexGuard;
     341                 :            : 
     342                 :            :         // Check if some modes have changed so we have to update our menu images
     343         [ #  # ]:          0 :         const StyleSettings& rSettings = Application::GetSettings().GetStyleSettings();
     344         [ #  # ]:          0 :         sal_Bool bShowMenuImages    = rSettings.GetUseImagesInMenus();
     345                 :          0 :         sal_Bool bUpdateImages      = (bShowMenuImages != m_bShowMenuImages);
     346                 :            : 
     347         [ #  # ]:          0 :         if ( bUpdateImages )
     348                 :            :         {
     349                 :          0 :             m_bShowMenuImages   = bShowMenuImages;
     350                 :            : 
     351                 :          0 :             VCLXPopupMenu* pPopupMenu = (VCLXPopupMenu *)VCLXPopupMenu::GetImplementation( m_xPopupMenu );
     352         [ #  # ]:          0 :             if ( pPopupMenu )
     353                 :            :             {
     354                 :          0 :                 PopupMenu* pVCLPopupMenu = (PopupMenu *)pPopupMenu->GetMenu();
     355 [ #  # ][ #  # ]:          0 :                 if ( pVCLPopupMenu && bUpdateImages )
     356         [ #  # ]:          0 :                     updateImagesPopupMenu( pVCLPopupMenu );
     357                 :            :             }
     358         [ #  # ]:          0 :         }
     359         [ #  # ]:          0 :     }
     360                 :          0 : }
     361                 :            : 
     362                 :            : // XPopupMenuController
     363                 :          0 : void ControlMenuController::impl_setPopupMenu()
     364                 :            : {
     365         [ #  # ]:          0 :     if ( m_pResPopupMenu == 0 )
     366                 :            :     {
     367         [ #  # ]:          0 :         ResMgr* pResMgr = ResMgr::CreateResMgr("svx", Application::GetSettings().GetUILocale());
     368         [ #  # ]:          0 :         if ( pResMgr )
     369                 :            :         {
     370                 :          0 :             ResId aResId( RID_FMSHELL_CONVERSIONMENU, *pResMgr );
     371                 :          0 :             aResId.SetRT( RSC_MENU );
     372 [ #  # ][ #  # ]:          0 :             if ( pResMgr->IsAvailable( aResId ))
     373 [ #  # ][ #  # ]:          0 :                 m_pResPopupMenu = new PopupMenu( aResId );
     374                 :            : 
     375         [ #  # ]:          0 :             updateImagesPopupMenu( m_pResPopupMenu );
     376 [ #  # ][ #  # ]:          0 :             delete pResMgr;
     377                 :            :         }
     378                 :            :     } // if ( m_pResPopupMenu == 0 )
     379                 :          0 : }
     380                 :            : 
     381                 :          2 : void SAL_CALL ControlMenuController::updatePopupMenu() throw (::com::sun::star::uno::RuntimeException)
     382                 :            : {
     383         [ +  - ]:          2 :     osl::ResettableMutexGuard aLock( m_aMutex );
     384                 :            : 
     385         [ +  - ]:          2 :     throwIfDisposed();
     386                 :            : 
     387 [ -  + ][ #  # ]:          2 :     if ( m_xFrame.is() && m_xPopupMenu.is() )
                 [ -  + ]
     388                 :            :     {
     389                 :          0 :         URL aTargetURL;
     390         [ #  # ]:          0 :         Reference< XDispatchProvider > xDispatchProvider( m_xFrame, UNO_QUERY );
     391         [ #  # ]:          0 :         fillPopupMenu( m_xPopupMenu );
     392         [ #  # ]:          0 :         m_aURLToDispatchMap.free();
     393                 :            : 
     394         [ #  # ]:          0 :         for (sal_uInt32 i=0; i<sizeof(aCommands)/sizeof(aCommands[0]); ++i)
     395                 :            :         {
     396                 :          0 :             aTargetURL.Complete = rtl::OUString::createFromAscii( aCommands[i] );
     397 [ #  # ][ #  # ]:          0 :             m_xURLTransformer->parseStrict( aTargetURL );
     398                 :            : 
     399 [ #  # ][ #  # ]:          0 :             Reference< XDispatch > xDispatch = xDispatchProvider->queryDispatch( aTargetURL, ::rtl::OUString(), 0 );
     400         [ #  # ]:          0 :             if ( xDispatch.is() )
     401                 :            :             {
     402 [ #  # ][ #  # ]:          0 :                 xDispatch->addStatusListener( (static_cast< XStatusListener* >(this)), aTargetURL );
                 [ #  # ]
     403 [ #  # ][ #  # ]:          0 :                 xDispatch->removeStatusListener( (static_cast< XStatusListener* >(this)), aTargetURL );
                 [ #  # ]
     404 [ #  # ][ #  # ]:          0 :                 m_aURLToDispatchMap.insert( UrlToDispatchMap::value_type( aTargetURL.Complete, xDispatch ));
                 [ #  # ]
     405                 :            :             }
     406                 :          0 :         }
     407         [ +  - ]:          2 :     }
     408                 :          2 : }
     409                 :            : 
     410                 :            : // XInitialization
     411                 :          2 : void SAL_CALL ControlMenuController::initialize( const Sequence< Any >& aArguments ) throw ( Exception, RuntimeException )
     412                 :            : {
     413         [ +  - ]:          2 :     osl::ResettableMutexGuard aLock( m_aMutex );
     414         [ +  - ]:          2 :     svt::PopupMenuControllerBase::initialize(aArguments);
     415         [ +  - ]:          2 :     m_aBaseURL = ::rtl::OUString();
     416                 :          2 : }
     417                 :            : 
     418                 :            : }
     419                 :            : 
     420                 :            : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10