LCOV - code coverage report
Current view: top level - framework/source/uielement - controlmenucontroller.cxx (source / functions) Hit Total Coverage
Test: commit 10e77ab3ff6f4314137acd6e2702a6e5c1ce1fae Lines: 34 147 23.1 %
Date: 2014-11-03 Functions: 12 21 57.1 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
       2             : /*
       3             :  * This file is part of the LibreOffice project.
       4             :  *
       5             :  * This Source Code Form is subject to the terms of the Mozilla Public
       6             :  * License, v. 2.0. If a copy of the MPL was not distributed with this
       7             :  * file, You can obtain one at http://mozilla.org/MPL/2.0/.
       8             :  *
       9             :  * This file incorporates work covered by the following license notice:
      10             :  *
      11             :  *   Licensed to the Apache Software Foundation (ASF) under one or more
      12             :  *   contributor license agreements. See the NOTICE file distributed
      13             :  *   with this work for additional information regarding copyright
      14             :  *   ownership. The ASF licenses this file to you under the Apache
      15             :  *   License, Version 2.0 (the "License"); you may not use this file
      16             :  *   except in compliance with the License. You may obtain a copy of
      17             :  *   the License at http://www.apache.org/licenses/LICENSE-2.0 .
      18             :  */
      19             : 
      20             : #include <sal/config.h>
      21             : 
      22             : #include <stdtypes.h>
      23             : 
      24             : #include <com/sun/star/beans/PropertyValue.hpp>
      25             : #include <com/sun/star/lang/XServiceInfo.hpp>
      26             : #include <com/sun/star/lang/XInitialization.hpp>
      27             : #include <com/sun/star/frame/XDispatch.hpp>
      28             : #include <com/sun/star/frame/XDispatchProvider.hpp>
      29             : #include <com/sun/star/frame/XStatusListener.hpp>
      30             : #include <com/sun/star/frame/XPopupMenuController.hpp>
      31             : 
      32             : #include <cppuhelper/supportsservice.hxx>
      33             : #include <vcl/menu.hxx>
      34             : #include <vcl/svapp.hxx>
      35             : #include <vcl/settings.hxx>
      36             : #include <vcl/i18nhelp.hxx>
      37             : #include <rtl/ref.hxx>
      38             : #include <rtl/ustrbuf.hxx>
      39             : #include <svl/solar.hrc>
      40             : #include <tools/rcid.h>
      41             : #include <vcl/image.hxx>
      42             : #include <svtools/menuoptions.hxx>
      43             : #include <svtools/popupmenucontrollerbase.hxx>
      44             : #include <osl/mutex.hxx>
      45             : #include <boost/scoped_ptr.hpp>
      46             : 
      47             : // Copied from svx
      48             : // Function-Id's
      49             : #define RID_FMSHELL_CONVERSIONMENU (RID_FORMS_START + 4)
      50             : #define RID_SVXIMGLIST_FMEXPL      (RID_FORMS_START + 0)
      51             : 
      52             : // Forms - Ids, used to address images from image list
      53             : #define SID_FMSLOTS_START                   (SID_SVX_START + 592)
      54             : #define SID_MORE_FMSLOTS_START              (SID_SVX_START + 702)
      55             : 
      56             : #define SID_FM_CONVERTTO_EDIT               (SID_MORE_FMSLOTS_START +  32)
      57             : #define SID_FM_CONVERTTO_BUTTON             (SID_MORE_FMSLOTS_START +  33)
      58             : #define SID_FM_CONVERTTO_FIXEDTEXT          (SID_MORE_FMSLOTS_START +  34)
      59             : #define SID_FM_CONVERTTO_LISTBOX            (SID_MORE_FMSLOTS_START +  35)
      60             : #define SID_FM_CONVERTTO_CHECKBOX           (SID_MORE_FMSLOTS_START +  36)
      61             : #define SID_FM_CONVERTTO_RADIOBUTTON        (SID_MORE_FMSLOTS_START +  37)
      62             : #define SID_FM_CONVERTTO_GROUPBOX           (SID_MORE_FMSLOTS_START +  38)
      63             : #define SID_FM_CONVERTTO_COMBOBOX           (SID_MORE_FMSLOTS_START +  39)
      64             : #define SID_FM_CONVERTTO_IMAGEBUTTON        (SID_MORE_FMSLOTS_START +  41)
      65             : #define SID_FM_CONVERTTO_FILECONTROL        (SID_MORE_FMSLOTS_START +  42)
      66             : #define SID_FM_CONVERTTO_DATE               (SID_MORE_FMSLOTS_START +  43)
      67             : #define SID_FM_CONVERTTO_TIME               (SID_MORE_FMSLOTS_START +  44)
      68             : #define SID_FM_CONVERTTO_NUMERIC            (SID_MORE_FMSLOTS_START +  45)
      69             : #define SID_FM_CONVERTTO_CURRENCY           (SID_MORE_FMSLOTS_START +  46)
      70             : #define SID_FM_CONVERTTO_PATTERN            (SID_MORE_FMSLOTS_START +  47)
      71             : #define SID_FM_CONVERTTO_IMAGECONTROL       (SID_MORE_FMSLOTS_START +  48)
      72             : #define SID_FM_CONVERTTO_FORMATTED          (SID_MORE_FMSLOTS_START +  49)
      73             : #define SID_FM_CONVERTTO_SCROLLBAR          (SID_MORE_FMSLOTS_START +  68)
      74             : #define SID_FM_CONVERTTO_SPINBUTTON         (SID_MORE_FMSLOTS_START +  69)
      75             : 
      76             : #define SID_FM_DATEFIELD                    (SID_MORE_FMSLOTS_START +   2)
      77             : #define SID_FM_TIMEFIELD                    (SID_MORE_FMSLOTS_START +   3)
      78             : #define SID_FM_NUMERICFIELD                 (SID_MORE_FMSLOTS_START +   4)
      79             : #define SID_FM_CURRENCYFIELD                (SID_MORE_FMSLOTS_START +   5)
      80             : #define SID_FM_PATTERNFIELD                 (SID_MORE_FMSLOTS_START +   6)
      81             : #define SID_FM_IMAGECONTROL                 (SID_MORE_FMSLOTS_START +   8)
      82             : #define SID_FM_FORMATTEDFIELD               (SID_MORE_FMSLOTS_START +  26)
      83             : #define SID_FM_SCROLLBAR                    (SID_MORE_FMSLOTS_START +  66)
      84             : #define SID_FM_SPINBUTTON                   (SID_MORE_FMSLOTS_START +  67)
      85             : #define SID_FM_PUSHBUTTON                   (SID_FMSLOTS_START + 2)
      86             : #define SID_FM_RADIOBUTTON                  (SID_FMSLOTS_START + 3)
      87             : #define SID_FM_CHECKBOX                     (SID_FMSLOTS_START + 4)
      88             : #define SID_FM_FIXEDTEXT                    (SID_FMSLOTS_START + 5)
      89             : #define SID_FM_GROUPBOX                     (SID_FMSLOTS_START + 6)
      90             : #define SID_FM_EDIT                         (SID_FMSLOTS_START + 7)
      91             : #define SID_FM_LISTBOX                      (SID_FMSLOTS_START + 8)
      92             : #define SID_FM_COMBOBOX                     (SID_FMSLOTS_START + 9)
      93             : #define SID_FM_IMAGEBUTTON                  (SID_FMSLOTS_START + 12)
      94             : #define SID_FM_FILECONTROL                  (SID_FMSLOTS_START + 13)
      95             : 
      96             : static const sal_Int16 nConvertSlots[] =
      97             : {
      98             :     SID_FM_CONVERTTO_EDIT,
      99             :     SID_FM_CONVERTTO_BUTTON,
     100             :     SID_FM_CONVERTTO_FIXEDTEXT,
     101             :     SID_FM_CONVERTTO_LISTBOX,
     102             :     SID_FM_CONVERTTO_CHECKBOX,
     103             :     SID_FM_CONVERTTO_RADIOBUTTON,
     104             :     SID_FM_CONVERTTO_GROUPBOX,
     105             :     SID_FM_CONVERTTO_COMBOBOX,
     106             : //  SID_FM_CONVERTTO_GRID,
     107             :     SID_FM_CONVERTTO_IMAGEBUTTON,
     108             :     SID_FM_CONVERTTO_FILECONTROL,
     109             :     SID_FM_CONVERTTO_DATE,
     110             :     SID_FM_CONVERTTO_TIME,
     111             :     SID_FM_CONVERTTO_NUMERIC,
     112             :     SID_FM_CONVERTTO_CURRENCY,
     113             :     SID_FM_CONVERTTO_PATTERN,
     114             :     SID_FM_CONVERTTO_IMAGECONTROL,
     115             :     SID_FM_CONVERTTO_FORMATTED,
     116             :     SID_FM_CONVERTTO_SCROLLBAR,
     117             :     SID_FM_CONVERTTO_SPINBUTTON
     118             : };
     119             : 
     120             : static const sal_Int16 nCreateSlots[] =
     121             : {
     122             :     SID_FM_EDIT,
     123             :     SID_FM_PUSHBUTTON,
     124             :     SID_FM_FIXEDTEXT,
     125             :     SID_FM_LISTBOX,
     126             :     SID_FM_CHECKBOX,
     127             :     SID_FM_RADIOBUTTON,
     128             :     SID_FM_GROUPBOX,
     129             :     SID_FM_COMBOBOX,
     130             : //  SID_FM_DBGRID,
     131             :     SID_FM_IMAGEBUTTON,
     132             :     SID_FM_FILECONTROL,
     133             :     SID_FM_DATEFIELD,
     134             :     SID_FM_TIMEFIELD,
     135             :     SID_FM_NUMERICFIELD,
     136             :     SID_FM_CURRENCYFIELD,
     137             :     SID_FM_PATTERNFIELD,
     138             :     SID_FM_IMAGECONTROL,
     139             :     SID_FM_FORMATTEDFIELD,
     140             :     SID_FM_SCROLLBAR,
     141             :     SID_FM_SPINBUTTON
     142             : };
     143             : 
     144             : static const char* aCommands[] =
     145             : {
     146             :     ".uno:ConvertToEdit",
     147             :     ".uno:ConvertToButton",
     148             :     ".uno:ConvertToFixed",
     149             :     ".uno:ConvertToList",
     150             :     ".uno:ConvertToCheckBox",
     151             :     ".uno:ConvertToRadio",
     152             :     ".uno:ConvertToGroup",
     153             :     ".uno:ConvertToCombo",
     154             : //    ".uno:ConvertToGrid",
     155             :     ".uno:ConvertToImageBtn",
     156             :     ".uno:ConvertToFileControl",
     157             :     ".uno:ConvertToDate",
     158             :     ".uno:ConvertToTime",
     159             :     ".uno:ConvertToNumeric",
     160             :     ".uno:ConvertToCurrency",
     161             :     ".uno:ConvertToPattern",
     162             :     ".uno:ConvertToImageControl",
     163             :     ".uno:ConvertToFormatted",
     164             :     ".uno:ConvertToScrollBar",
     165             :     ".uno:ConvertToSpinButton"
     166             : };
     167             : 
     168             : using namespace css;
     169             : using namespace com::sun::star::uno;
     170             : using namespace com::sun::star::lang;
     171             : using namespace com::sun::star::frame;
     172             : using namespace com::sun::star::beans;
     173             : 
     174             : namespace {
     175             : 
     176             : class ControlMenuController :  public svt::PopupMenuControllerBase
     177             : {
     178             :     using svt::PopupMenuControllerBase::disposing;
     179             : 
     180             : public:
     181             :     ControlMenuController( const uno::Reference< uno::XComponentContext >& xContext );
     182             :     virtual ~ControlMenuController();
     183             : 
     184             :     // XServiceInfo
     185           4 :     virtual OUString SAL_CALL getImplementationName()
     186             :         throw (css::uno::RuntimeException, std::exception) SAL_OVERRIDE
     187             :     {
     188           4 :         return OUString("com.sun.star.comp.framework.ControlMenuController");
     189             :     }
     190             : 
     191           0 :     virtual sal_Bool SAL_CALL supportsService(OUString const & ServiceName)
     192             :         throw (css::uno::RuntimeException, std::exception) SAL_OVERRIDE
     193             :     {
     194           0 :         return cppu::supportsService(this, ServiceName);
     195             :     }
     196             : 
     197           0 :     virtual css::uno::Sequence<OUString> SAL_CALL getSupportedServiceNames()
     198             :         throw (css::uno::RuntimeException, std::exception) SAL_OVERRIDE
     199             :     {
     200           0 :         css::uno::Sequence< OUString > aSeq(1);
     201           0 :         aSeq[0] = OUString("com.sun.star.frame.PopupMenuController");
     202           0 :         return aSeq;
     203             :     }
     204             : 
     205             :     // XPopupMenuController
     206             :     virtual void SAL_CALL updatePopupMenu() throw (uno::RuntimeException, std::exception) SAL_OVERRIDE;
     207             : 
     208             :     // XInitialization
     209             :     virtual void SAL_CALL initialize( const uno::Sequence< uno::Any >& aArguments ) throw (uno::Exception, uno::RuntimeException, std::exception) SAL_OVERRIDE;
     210             : 
     211             :     // XStatusListener
     212             :     virtual void SAL_CALL statusChanged( const frame::FeatureStateEvent& Event ) throw ( uno::RuntimeException, std::exception ) SAL_OVERRIDE;
     213             : 
     214             :     // XMenuListener
     215             :     virtual void SAL_CALL itemActivated( const awt::MenuEvent& rEvent ) throw (uno::RuntimeException, std::exception) SAL_OVERRIDE;
     216             : 
     217             :     // XEventListener
     218             :     virtual void SAL_CALL disposing( const lang::EventObject& Source ) throw ( uno::RuntimeException, std::exception ) SAL_OVERRIDE;
     219             : 
     220             : private:
     221             :     virtual void impl_setPopupMenu() SAL_OVERRIDE;
     222             :     virtual void impl_select(const uno::Reference< frame::XDispatch >& _xDispatch,const util::URL& aURL) SAL_OVERRIDE;
     223             : 
     224           8 :     class UrlToDispatchMap : public ::boost::unordered_map< OUString,
     225             :                                                      uno::Reference< frame::XDispatch >,
     226             :                                                      OUStringHash,
     227             :                                                      ::std::equal_to< OUString > >
     228             :     {
     229             :         public:
     230           0 :             inline void free()
     231             :             {
     232           0 :                 UrlToDispatchMap().swap( *this );// get rid of reserved capacity
     233           0 :             }
     234             :     };
     235             : 
     236             :     void updateImagesPopupMenu( PopupMenu* pPopupMenu );
     237             :     void fillPopupMenu( uno::Reference< awt::XPopupMenu >& rPopupMenu );
     238             : 
     239             :     bool            m_bShowMenuImages : 1;
     240             :     PopupMenu*          m_pResPopupMenu;
     241             :     UrlToDispatchMap    m_aURLToDispatchMap;
     242             : };
     243             : 
     244           4 : ControlMenuController::ControlMenuController( const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext >& xContext ) :
     245             :     svt::PopupMenuControllerBase( xContext ),
     246           4 :     m_pResPopupMenu( 0 )
     247             : {
     248           4 :     const StyleSettings& rSettings = Application::GetSettings().GetStyleSettings();
     249           4 :     m_bShowMenuImages   = rSettings.GetUseImagesInMenus();
     250             : 
     251           4 : }
     252             : 
     253           8 : ControlMenuController::~ControlMenuController()
     254             : {
     255           8 : }
     256             : 
     257             : // private function
     258           0 : void ControlMenuController::updateImagesPopupMenu( PopupMenu* pPopupMenu )
     259             : {
     260           0 :     boost::scoped_ptr<ResMgr> pResMgr(ResMgr::CreateResMgr("svx", Application::GetSettings().GetUILanguageTag()));
     261           0 :     ResId aResId( RID_SVXIMGLIST_FMEXPL, *pResMgr );
     262           0 :     aResId.SetRT( RSC_IMAGELIST );
     263             : 
     264           0 :     if ( pResMgr->IsAvailable( aResId ))
     265             :     {
     266           0 :         ImageList aImageList( aResId );
     267           0 :         for ( sal_uInt32 i=0; i < sizeof(nConvertSlots)/sizeof(nConvertSlots[0]); ++i )
     268             :         {
     269             :             // das entsprechende Image dran
     270           0 :             if ( m_bShowMenuImages )
     271           0 :                 pPopupMenu->SetItemImage( nConvertSlots[i], aImageList.GetImage(nCreateSlots[i]));
     272             :             else
     273           0 :                 pPopupMenu->SetItemImage( nConvertSlots[i], Image() );
     274           0 :         }
     275           0 :     }
     276           0 : }
     277             : 
     278             : // private function
     279           0 : void ControlMenuController::fillPopupMenu( Reference< css::awt::XPopupMenu >& rPopupMenu )
     280             : {
     281           0 :     VCLXPopupMenu*                                     pPopupMenu        = static_cast<VCLXPopupMenu *>(VCLXMenu::GetImplementation( rPopupMenu ));
     282           0 :     PopupMenu*                                         pVCLPopupMenu     = 0;
     283             : 
     284           0 :     SolarMutexGuard aSolarMutexGuard;
     285             : 
     286           0 :     resetPopupMenu( rPopupMenu );
     287           0 :     if ( pPopupMenu )
     288           0 :         pVCLPopupMenu = static_cast<PopupMenu *>(pPopupMenu->GetMenu());
     289             : 
     290           0 :     if ( pVCLPopupMenu && m_pResPopupMenu )
     291           0 :         *pVCLPopupMenu = *m_pResPopupMenu;
     292           0 : }
     293             : 
     294             : // XEventListener
     295           0 : void SAL_CALL ControlMenuController::disposing( const EventObject& ) throw ( RuntimeException, std::exception )
     296             : {
     297           0 :     Reference< css::awt::XMenuListener > xHolder(( OWeakObject *)this, UNO_QUERY );
     298             : 
     299           0 :     osl::ResettableMutexGuard aLock( m_aMutex );
     300           0 :     m_xFrame.clear();
     301           0 :     m_xDispatch.clear();
     302             : 
     303           0 :     if ( m_xPopupMenu.is() )
     304           0 :         m_xPopupMenu->removeMenuListener( Reference< css::awt::XMenuListener >(( OWeakObject *)this, UNO_QUERY ));
     305           0 :     m_xPopupMenu.clear();
     306           0 :     delete m_pResPopupMenu;
     307           0 : }
     308             : 
     309             : // XStatusListener
     310           2 : void SAL_CALL ControlMenuController::statusChanged( const FeatureStateEvent& Event ) throw ( RuntimeException, std::exception )
     311             : {
     312           2 :     osl::ResettableMutexGuard aLock( m_aMutex );
     313             : 
     314           2 :     sal_uInt16 nMenuId = 0;
     315          40 :     for (sal_uInt32 i=0; i < sizeof(aCommands) / sizeof (aCommands[0]); ++i)
     316             :     {
     317          38 :         if ( Event.FeatureURL.Complete.equalsAscii( aCommands[i] ))
     318             :         {
     319           0 :             nMenuId = nConvertSlots[i];
     320           0 :             break;
     321             :         }
     322             :     }
     323             : 
     324           2 :     VCLXPopupMenu*  pPopupMenu = NULL;
     325             : 
     326           2 :     if ( nMenuId )
     327           0 :         pPopupMenu = static_cast<VCLXPopupMenu *>(VCLXMenu::GetImplementation( m_xPopupMenu ));
     328             : 
     329           2 :     if (pPopupMenu)
     330             :     {
     331           0 :         SolarMutexGuard aSolarMutexGuard;
     332             : 
     333           0 :         PopupMenu* pVCLPopupMenu = static_cast<PopupMenu *>(pPopupMenu->GetMenu());
     334             : 
     335           0 :         if ( !Event.IsEnabled && pVCLPopupMenu->GetItemPos( nMenuId ) != MENU_ITEM_NOTFOUND )
     336           0 :             pVCLPopupMenu->RemoveItem( pVCLPopupMenu->GetItemPos( nMenuId ));
     337           0 :         else if ( Event.IsEnabled && pVCLPopupMenu->GetItemPos( nMenuId ) == MENU_ITEM_NOTFOUND )
     338             :         {
     339           0 :             sal_Int16 nSourcePos = m_pResPopupMenu->GetItemPos(nMenuId);
     340           0 :             sal_Int16 nPrevInSource = nSourcePos;
     341           0 :             sal_uInt16 nPrevInConversion = MENU_ITEM_NOTFOUND;
     342           0 :             while (nPrevInSource>0)
     343             :             {
     344           0 :                 sal_Int16 nPrevId = m_pResPopupMenu->GetItemId(--nPrevInSource);
     345             : 
     346             :                 // do we have the source's predecessor in our conversion menu, too ?
     347           0 :                 nPrevInConversion = pVCLPopupMenu->GetItemPos( nPrevId );
     348           0 :                 if ( nPrevInConversion != MENU_ITEM_NOTFOUND )
     349           0 :                     break;
     350             :             }
     351             : 
     352           0 :           if ( MENU_ITEM_NOTFOUND == nPrevInConversion )
     353             :                 // none of the items which precede the nSID-slot in the source menu are present in our conversion menu
     354           0 :                 nPrevInConversion = sal::static_int_cast< sal_uInt16 >(-1); // put the item at the first position
     355             : 
     356           0 :             pVCLPopupMenu->InsertItem( nMenuId, m_pResPopupMenu->GetItemText( nMenuId ), m_pResPopupMenu->GetItemBits( nMenuId ), OString(), ++nPrevInConversion );
     357           0 :             pVCLPopupMenu->SetItemImage( nMenuId, m_pResPopupMenu->GetItemImage( nMenuId ));
     358           0 :             pVCLPopupMenu->SetHelpId( nMenuId, m_pResPopupMenu->GetHelpId( nMenuId ));
     359           0 :         }
     360           2 :     }
     361           2 : }
     362             : 
     363             : // XMenuListener
     364           0 : void ControlMenuController::impl_select(const Reference< XDispatch >& /*_xDispatch*/,const ::com::sun::star::util::URL& aURL)
     365             : {
     366           0 :     UrlToDispatchMap::iterator pIter = m_aURLToDispatchMap.find( aURL.Complete );
     367           0 :     if ( pIter != m_aURLToDispatchMap.end() )
     368             :     {
     369           0 :         Sequence<PropertyValue>      aArgs;
     370           0 :         Reference< XDispatch > xDispatch = pIter->second;
     371           0 :         if ( xDispatch.is() )
     372           0 :             xDispatch->dispatch( aURL, aArgs );
     373             :     }
     374           0 : }
     375             : 
     376           0 : void SAL_CALL ControlMenuController::itemActivated( const css::awt::MenuEvent& ) throw (RuntimeException, std::exception)
     377             : {
     378           0 :     osl::ResettableMutexGuard aLock( m_aMutex );
     379             : 
     380           0 :     if ( m_xPopupMenu.is() )
     381             :     {
     382           0 :         SolarMutexGuard aSolarMutexGuard;
     383             : 
     384             :         // Check if some modes have changed so we have to update our menu images
     385           0 :         const StyleSettings& rSettings = Application::GetSettings().GetStyleSettings();
     386           0 :         bool bShowMenuImages    = rSettings.GetUseImagesInMenus();
     387           0 :         bool bUpdateImages      = (bShowMenuImages != m_bShowMenuImages);
     388             : 
     389           0 :         if ( bUpdateImages )
     390             :         {
     391           0 :             m_bShowMenuImages   = bShowMenuImages;
     392             : 
     393           0 :             VCLXPopupMenu* pPopupMenu = static_cast<VCLXPopupMenu *>(VCLXPopupMenu::GetImplementation( m_xPopupMenu ));
     394           0 :             if ( pPopupMenu )
     395             :             {
     396           0 :                 PopupMenu* pVCLPopupMenu = static_cast<PopupMenu *>(pPopupMenu->GetMenu());
     397           0 :                 if ( pVCLPopupMenu && bUpdateImages )
     398           0 :                     updateImagesPopupMenu( pVCLPopupMenu );
     399             :             }
     400           0 :         }
     401           0 :     }
     402           0 : }
     403             : 
     404             : // XPopupMenuController
     405           0 : void ControlMenuController::impl_setPopupMenu()
     406             : {
     407           0 :     if ( m_pResPopupMenu == 0 )
     408             :     {
     409           0 :         boost::scoped_ptr<ResMgr> pResMgr(ResMgr::CreateResMgr("svx", Application::GetSettings().GetUILanguageTag()));
     410           0 :         if ( pResMgr )
     411             :         {
     412           0 :             ResId aResId( RID_FMSHELL_CONVERSIONMENU, *pResMgr );
     413           0 :             aResId.SetRT( RSC_MENU );
     414           0 :             if ( pResMgr->IsAvailable( aResId ))
     415             :             {
     416           0 :                 m_pResPopupMenu = new PopupMenu( aResId );
     417           0 :                 updateImagesPopupMenu( m_pResPopupMenu );
     418             :             }
     419           0 :         }
     420             :     } // if ( m_pResPopupMenu == 0 )
     421           0 : }
     422             : 
     423           2 : void SAL_CALL ControlMenuController::updatePopupMenu() throw (::com::sun::star::uno::RuntimeException, std::exception)
     424             : {
     425           2 :     osl::ResettableMutexGuard aLock( m_aMutex );
     426             : 
     427           2 :     throwIfDisposed();
     428             : 
     429           2 :     if ( m_xFrame.is() && m_xPopupMenu.is() )
     430             :     {
     431           0 :         css::util::URL aTargetURL;
     432           0 :         Reference< XDispatchProvider > xDispatchProvider( m_xFrame, UNO_QUERY );
     433           0 :         fillPopupMenu( m_xPopupMenu );
     434           0 :         m_aURLToDispatchMap.free();
     435             : 
     436           0 :         for (sal_uInt32 i=0; i<sizeof(aCommands)/sizeof(aCommands[0]); ++i)
     437             :         {
     438           0 :             aTargetURL.Complete = OUString::createFromAscii( aCommands[i] );
     439           0 :             m_xURLTransformer->parseStrict( aTargetURL );
     440             : 
     441           0 :             Reference< XDispatch > xDispatch = xDispatchProvider->queryDispatch( aTargetURL, OUString(), 0 );
     442           0 :             if ( xDispatch.is() )
     443             :             {
     444           0 :                 xDispatch->addStatusListener( (static_cast< XStatusListener* >(this)), aTargetURL );
     445           0 :                 xDispatch->removeStatusListener( (static_cast< XStatusListener* >(this)), aTargetURL );
     446           0 :                 m_aURLToDispatchMap.insert( UrlToDispatchMap::value_type( aTargetURL.Complete, xDispatch ));
     447             :             }
     448           0 :         }
     449           2 :     }
     450           2 : }
     451             : 
     452             : // XInitialization
     453           2 : void SAL_CALL ControlMenuController::initialize( const Sequence< Any >& aArguments ) throw ( Exception, RuntimeException, std::exception )
     454             : {
     455           2 :     osl::ResettableMutexGuard aLock( m_aMutex );
     456           2 :     svt::PopupMenuControllerBase::initialize(aArguments);
     457           2 :     m_aBaseURL = OUString();
     458           2 : }
     459             : 
     460             : }
     461             : 
     462             : extern "C" SAL_DLLPUBLIC_EXPORT css::uno::XInterface * SAL_CALL
     463           4 : com_sun_star_comp_framework_ControlMenuController_get_implementation(
     464             :     css::uno::XComponentContext *context,
     465             :     css::uno::Sequence<css::uno::Any> const &)
     466             : {
     467           4 :     return cppu::acquire(new ControlMenuController(context));
     468         951 : }
     469             : 
     470             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10