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

Generated by: LCOV version 1.10