LCOV - code coverage report
Current view: top level - framework/inc/uielement - menubarmanager.hxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 4 5 80.0 %
Date: 2012-08-25 Functions: 3 6 50.0 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 0 0 -

           Branch data     Line data    Source code
       1                 :            : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
       2                 :            : /*************************************************************************
       3                 :            :  *
       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                 :            : #ifndef __FRAMEWORK_UIELEMENT_MENUBARMANAGER_HXX_
      30                 :            : #define __FRAMEWORK_UIELEMENT_MENUBARMANAGER_HXX_
      31                 :            : 
      32                 :            : /** Attention: stl headers must(!) be included at first. Otherwhise it can make trouble
      33                 :            :                with solaris headers ...
      34                 :            : */
      35                 :            : #include <vector>
      36                 :            : 
      37                 :            : #include <threadhelp/threadhelpbase.hxx>
      38                 :            : #include <macros/debug.hxx>
      39                 :            : #include <stdtypes.h>
      40                 :            : 
      41                 :            : #include <com/sun/star/frame/XFrame.hpp>
      42                 :            : #include <com/sun/star/frame/XDispatch.hpp>
      43                 :            : #include <com/sun/star/frame/XDispatchProvider.hpp>
      44                 :            : #include <com/sun/star/frame/FeatureStateEvent.hpp>
      45                 :            : #include <com/sun/star/frame/XFrameActionListener.hpp>
      46                 :            : #include <com/sun/star/beans/PropertyValue.hpp>
      47                 :            : #include <com/sun/star/frame/XPopupMenuController.hpp>
      48                 :            : #include <com/sun/star/awt/XSystemDependentMenuPeer.hpp>
      49                 :            : #include <com/sun/star/container/XIndexAccess.hpp>
      50                 :            : #include <com/sun/star/container/XNameAccess.hpp>
      51                 :            : #include <com/sun/star/lang/XComponent.hpp>
      52                 :            : #include <com/sun/star/lang/XMultiComponentFactory.hpp>
      53                 :            : #include <com/sun/star/frame/XUIControllerRegistration.hpp>
      54                 :            : #include <com/sun/star/ui/XUIConfigurationListener.hpp>
      55                 :            : #include <com/sun/star/ui/XImageManager.hpp>
      56                 :            : #include <com/sun/star/ui/XAcceleratorConfiguration.hpp>
      57                 :            : #include <com/sun/star/util/XURLTransformer.hpp>
      58                 :            : #include <com/sun/star/lang/XMultiServiceFactory.hpp>
      59                 :            : 
      60                 :            : #include <rtl/ustring.hxx>
      61                 :            : #include <vcl/menu.hxx>
      62                 :            : #include <vcl/accel.hxx>
      63                 :            : #include <vcl/timer.hxx>
      64                 :            : #include <toolkit/awt/vclxmenu.hxx>
      65                 :            : #include <cppuhelper/weak.hxx>
      66                 :            : #include <cppuhelper/interfacecontainer.hxx>
      67                 :            : #include <framework/addonsoptions.hxx>
      68                 :            : 
      69                 :            : namespace framework
      70                 :            : {
      71                 :            : 
      72                 :          0 : struct PopupControllerEntry
      73                 :            : {
      74                 :            :     ::com::sun::star::uno::WeakReference< ::com::sun::star::frame::XDispatchProvider > m_xDispatchProvider;
      75                 :            : };
      76                 :            : 
      77                 :            : typedef boost::unordered_map< rtl::OUString, PopupControllerEntry, OUStringHashCode, ::std::equal_to< rtl::OUString > > PopupControllerCache;
      78                 :            : 
      79                 :            : class BmkMenu;
      80                 :            : class AddonMenu;
      81                 :            : class AddonPopupMenu;
      82                 :            : class MenuBarManager : public com::sun::star::frame::XStatusListener                ,
      83                 :            :                        public com::sun::star::frame::XFrameActionListener           ,
      84                 :            :                        public com::sun::star::ui::XUIConfigurationListener          ,
      85                 :            :                        public com::sun::star::lang::XComponent                      ,
      86                 :            :                        public com::sun::star::awt::XSystemDependentMenuPeer         ,
      87                 :            :                        public ThreadHelpBase                                        ,
      88                 :            :                        public ::cppu::OWeakObject
      89                 :            : {
      90                 :            :     protected:
      91                 :            :         MenuBarManager(
      92                 :            :             const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& xServiceFactory,
      93                 :            :             const ::com::sun::star::uno::Reference< com::sun::star::frame::XFrame >& rFrame,
      94                 :            :             const ::com::sun::star::uno::Reference< ::com::sun::star::util::XURLTransformer >& _xURLTransformer,
      95                 :            :             AddonMenu*          pAddonMenu,
      96                 :            :             sal_Bool            bDelete,
      97                 :            :             sal_Bool            bDeleteChildren );
      98                 :            : 
      99                 :            :         MenuBarManager(
     100                 :            :             const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& xServiceFactory,
     101                 :            :             const ::com::sun::star::uno::Reference< com::sun::star::frame::XFrame >& rFrame,
     102                 :            :             const ::com::sun::star::uno::Reference< ::com::sun::star::util::XURLTransformer >& _xURLTransformer,
     103                 :            :             AddonPopupMenu*     pAddonMenu,
     104                 :            :             sal_Bool            bDelete,
     105                 :            :             sal_Bool            bDeleteChildren );
     106                 :            : 
     107                 :            :     public:
     108                 :            :         MenuBarManager(
     109                 :            :             const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& xServiceFactory,
     110                 :            :             const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XFrame >& rFrame,
     111                 :            :             const ::com::sun::star::uno::Reference< ::com::sun::star::util::XURLTransformer >& _xURLTransformer,
     112                 :            :             const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XDispatchProvider >& rDispatchProvider,
     113                 :            :             const rtl::OUString& aModuleIdentifier,
     114                 :            :             Menu* pMenu,
     115                 :            :             sal_Bool bDelete,
     116                 :            :             sal_Bool bDeleteChildren );
     117                 :            : 
     118                 :            :         const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& getServiceFactory();
     119                 :            : 
     120                 :            :         virtual ~MenuBarManager();
     121                 :            : 
     122                 :            :         // XInterface
     123                 :            :         virtual void SAL_CALL acquire() throw();
     124                 :            :         virtual void SAL_CALL release() throw();
     125                 :            :         virtual ::com::sun::star::uno::Any SAL_CALL queryInterface( const ::com::sun::star::uno::Type & rType ) throw( ::com::sun::star::uno::RuntimeException );
     126                 :            : 
     127                 :            :         // XComponent
     128                 :            :         virtual void SAL_CALL dispose() throw (::com::sun::star::uno::RuntimeException);
     129                 :            :         virtual void SAL_CALL addEventListener( const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XEventListener >& xListener ) throw (::com::sun::star::uno::RuntimeException);
     130                 :            :         virtual void SAL_CALL removeEventListener( const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XEventListener >& aListener ) throw (::com::sun::star::uno::RuntimeException);
     131                 :            : 
     132                 :            :         // XStatusListener
     133                 :            :         virtual void SAL_CALL statusChanged( const com::sun::star::frame::FeatureStateEvent& Event ) throw ( ::com::sun::star::uno::RuntimeException );
     134                 :            : 
     135                 :            :         // XFrameActionListener
     136                 :            :         virtual void SAL_CALL frameAction( const com::sun::star::frame::FrameActionEvent& Action ) throw ( ::com::sun::star::uno::RuntimeException );
     137                 :            : 
     138                 :            :         // XEventListener
     139                 :            :         virtual void SAL_CALL disposing( const ::com::sun::star::lang::EventObject& Source ) throw ( ::com::sun::star::uno::RuntimeException );
     140                 :            : 
     141                 :            :         // XUIConfigurationListener
     142                 :            :         virtual void SAL_CALL elementInserted( const ::com::sun::star::ui::ConfigurationEvent& Event ) throw (::com::sun::star::uno::RuntimeException);
     143                 :            :         virtual void SAL_CALL elementRemoved( const ::com::sun::star::ui::ConfigurationEvent& Event ) throw (::com::sun::star::uno::RuntimeException);
     144                 :            :         virtual void SAL_CALL elementReplaced( const ::com::sun::star::ui::ConfigurationEvent& Event ) throw (::com::sun::star::uno::RuntimeException);
     145                 :            : 
     146                 :            :         // XSystemDependentMenuPeer
     147                 :            :         virtual ::com::sun::star::uno::Any SAL_CALL getMenuHandle( const ::com::sun::star::uno::Sequence< sal_Int8 >& ProcessId, sal_Int16 SystemType ) throw (::com::sun::star::uno::RuntimeException);
     148                 :            : 
     149                 :            :         DECL_LINK( Select, Menu * );
     150                 :            : 
     151                 :       1290 :         Menu*   GetMenuBar() const { return m_pVCLMenu; }
     152                 :            : 
     153                 :            :         // Configuration methods
     154                 :            :         static void FillMenuWithConfiguration( sal_uInt16& nId, Menu* pMenu,
     155                 :            :                                                const ::rtl::OUString& rModuleIdentifier,
     156                 :            :                                                const ::com::sun::star::uno::Reference< ::com::sun::star::container::XIndexAccess >& rItemContainer,
     157                 :            :                                                const ::com::sun::star::uno::Reference< ::com::sun::star::util::XURLTransformer >& rTransformer );
     158                 :            :         static void FillMenu( sal_uInt16& nId,
     159                 :            :                               Menu* pMenu,
     160                 :            :                               const ::rtl::OUString& rModuleIdentifier,
     161                 :            :                               const ::com::sun::star::uno::Reference< ::com::sun::star::container::XIndexAccess >& rItemContainer,
     162                 :            :                               const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XDispatchProvider >& rDispatchProvider );
     163                 :            : 
     164                 :            :         void FillMenuManager( Menu* pMenu,
     165                 :            :                               const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XFrame >& rFrame,
     166                 :            :                               const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XDispatchProvider >& rDispatchProvider,
     167                 :            :                               const rtl::OUString& rModuleIdentifier,
     168                 :            :                               sal_Bool bDelete,
     169                 :            :                               sal_Bool bDeleteChildren );
     170                 :            :         void SetItemContainer( const ::com::sun::star::uno::Reference< ::com::sun::star::container::XIndexAccess >& rItemContainer );
     171                 :            :         void GetPopupController( PopupControllerCache& rPopupController );
     172                 :            : 
     173                 :            :     protected:
     174                 :            :         DECL_LINK(Highlight, void *);
     175                 :            :         DECL_LINK( Activate, Menu * );
     176                 :            :         DECL_LINK( Deactivate, Menu * );
     177                 :            :         DECL_LINK( AsyncSettingsHdl, Timer * );
     178                 :            : 
     179                 :            :         void RemoveListener();
     180                 :            :         void RequestImages();
     181                 :            :         void RetrieveImageManagers();
     182                 :            :         static sal_Bool MustBeHidden( PopupMenu* pPopupMenu, const ::com::sun::star::uno::Reference< ::com::sun::star::util::XURLTransformer >& rTransformer );
     183                 :            :         String RetrieveLabelFromCommand( const String& aCmdURL );
     184                 :            : 
     185                 :            :     private:
     186                 :            : 
     187                 :            : 
     188                 :            : 
     189                 :            :         void Destroy();
     190                 :            : 
     191                 :     334248 :         struct MenuItemHandler
     192                 :            :         {
     193                 :     334248 :             MenuItemHandler( sal_uInt16             aItemId,
     194                 :            :                              ::com::sun::star::uno::Reference< ::com::sun::star::frame::XStatusListener >& xManager,
     195                 :            :                              ::com::sun::star::uno::Reference< ::com::sun::star::frame::XDispatch >& rDispatch ) :
     196                 :            :                              nItemId( aItemId ),
     197                 :            :                              bCheckHide( sal_True ),
     198                 :            :                              xSubMenuManager( xManager ),
     199                 :     334248 :                              xMenuItemDispatch( rDispatch ) {}
     200                 :            : 
     201                 :            :             sal_uInt16                                                                                      nItemId;
     202                 :            :             sal_Bool                                                                                    bCheckHide;
     203                 :            :             ::rtl::OUString                                                                             aTargetFrame;
     204                 :            :             ::rtl::OUString                                                                             aMenuItemURL;
     205                 :            :             ::rtl::OUString                                                                             aFilter;
     206                 :            :             ::rtl::OUString                                                                             aPassword;
     207                 :            :             ::rtl::OUString                                                                             aTitle;
     208                 :            :             ::com::sun::star::uno::Reference< ::com::sun::star::frame::XStatusListener >                xSubMenuManager;
     209                 :            :             ::com::sun::star::uno::Reference< ::com::sun::star::frame::XDispatch >                      xMenuItemDispatch;
     210                 :            :             ::com::sun::star::uno::Reference< ::com::sun::star::frame::XPopupMenuController >           xPopupMenuController;
     211                 :            :             ::com::sun::star::uno::Reference< ::com::sun::star::awt::XPopupMenu >                       xPopupMenu;
     212                 :            :             KeyCode                                                                                     aKeyCode;
     213                 :            :         };
     214                 :            : 
     215                 :            :         void             RetrieveShortcuts( std::vector< MenuItemHandler* >& aMenuShortCuts );
     216                 :            :         void             CreatePicklistArguments(
     217                 :            :                             ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue >& aArgsList,
     218                 :            :                             const MenuItemHandler* );
     219                 :            :         void             CheckAndAddMenuExtension( Menu* pMenu );
     220                 :            :         static void      impl_RetrieveShortcutsFromConfiguration( const ::com::sun::star::uno::Reference< ::com::sun::star::ui::XAcceleratorConfiguration >& rAccelCfg,
     221                 :            :                                                                   const ::com::sun::star::uno::Sequence< rtl::OUString >& rCommands,
     222                 :            :                                                                   std::vector< MenuItemHandler* >& aMenuShortCuts );
     223                 :            :         static void      MergeAddonMenus( Menu* pMenuBar, const MergeMenuInstructionContainer&, const ::rtl::OUString& aModuleIdentifier );
     224                 :            : 
     225                 :            :         MenuItemHandler* GetMenuItemHandler( sal_uInt16 nItemId );
     226                 :            :         sal_Bool         CreatePopupMenuController( MenuItemHandler* pMenuItemHandler );
     227                 :            :         void             AddMenu(MenuBarManager* pSubMenuManager,const ::rtl::OUString& _sItemCommand,sal_uInt16 _nItemId);
     228                 :            :         sal_uInt16           FillItemCommand(::rtl::OUString& _rItemCommand,Menu* _pMenu,sal_uInt16 _nIndex) const;
     229                 :            :         void             Init(const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XFrame >& rFrame,AddonMenu* pAddonMenu,sal_Bool bDelete,sal_Bool bDeleteChildren,bool _bHandlePopUp = false);
     230                 :            :         void             SetHdl();
     231                 :            : 
     232                 :            :         sal_Bool                                                                               m_bDisposed : 1,
     233                 :            :                                                                                                m_bInitialized : 1,
     234                 :            :                                                                                                m_bDeleteMenu : 1,
     235                 :            :                                                                                                m_bDeleteChildren : 1,
     236                 :            :                                                                                                m_bActive : 1,
     237                 :            :                                                                                                m_bIsBookmarkMenu : 1,
     238                 :            :                                                                                                m_bShowMenuImages : 1;
     239                 :            :         sal_Bool                                                                               m_bRetrieveImages : 1,
     240                 :            :                                                                                                m_bAcceleratorCfg : 1;
     241                 :            :         sal_Bool                                                                               m_bModuleIdentified;
     242                 :            :         ::rtl::OUString                                                                        m_aMenuItemCommand;
     243                 :            :         ::rtl::OUString                                                                        m_aModuleIdentifier;
     244                 :            :         Menu*                                                                                  m_pVCLMenu;
     245                 :            :         ::com::sun::star::uno::Reference< ::com::sun::star::frame::XFrame >                    m_xFrame;
     246                 :            :         ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameAccess >           m_xUICommandLabels;
     247                 :            :         ::com::sun::star::uno::Reference< ::com::sun::star::frame::XUIControllerRegistration > m_xPopupMenuControllerRegistration;
     248                 :            :         ::std::vector< MenuItemHandler* >                                                      m_aMenuItemHandlerVector;
     249                 :            :         ::cppu::OMultiTypeInterfaceContainerHelper                                             m_aListenerContainer;   /// container for ALL Listener
     250                 :            :         ::com::sun::star::uno::Reference< ::com::sun::star::frame::XDispatchProvider >         m_xDispatchProvider;
     251                 :            :         ::com::sun::star::uno::Reference< ::com::sun::star::ui::XImageManager >                m_xDocImageManager;
     252                 :            :         ::com::sun::star::uno::Reference< ::com::sun::star::ui::XImageManager >                m_xModuleImageManager;
     253                 :            :         ::com::sun::star::uno::Reference< ::com::sun::star::ui::XAcceleratorConfiguration >    m_xDocAcceleratorManager;
     254                 :            :         ::com::sun::star::uno::Reference< ::com::sun::star::ui::XAcceleratorConfiguration >    m_xModuleAcceleratorManager;
     255                 :            :         ::com::sun::star::uno::Reference< ::com::sun::star::ui::XAcceleratorConfiguration >    m_xGlobalAcceleratorManager;
     256                 :            :         ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >       mxServiceFactory;
     257                 :            :         ::com::sun::star::uno::Reference< ::com::sun::star::util::XURLTransformer >            m_xURLTransformer;
     258                 :            :         ::com::sun::star::uno::Reference< ::com::sun::star::container::XIndexAccess >          m_xDeferedItemContainer;
     259                 :            :         sal_Int16                                                                              m_nSymbolsStyle;
     260                 :            :         Timer                                                                                  m_aAsyncSettingsTimer;
     261                 :            : };
     262                 :            : 
     263                 :            : } // namespace
     264                 :            : 
     265                 :            : #endif
     266                 :            : 
     267                 :            : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10