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

Generated by: LCOV version 1.10