LCOV - code coverage report
Current view: top level - framework/inc/uielement - toolbarmanager.hxx (source / functions) Hit Total Coverage
Test: commit c8344322a7af75b84dd3ca8f78b05543a976dfd5 Lines: 0 1 0.0 %
Date: 2015-06-13 12:38:46 Functions: 0 2 0.0 %
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 INCLUDED_FRAMEWORK_INC_UIELEMENT_TOOLBARMANAGER_HXX
      21             : #define INCLUDED_FRAMEWORK_INC_UIELEMENT_TOOLBARMANAGER_HXX
      22             : 
      23             : #include <macros/generic.hxx>
      24             : #include <macros/xinterface.hxx>
      25             : #include <macros/xtypeprovider.hxx>
      26             : #include <stdtypes.h>
      27             : #include <uielement/commandinfo.hxx>
      28             : 
      29             : #include <com/sun/star/container/XIndexAccess.hpp>
      30             : #include <com/sun/star/container/XNameAccess.hpp>
      31             : #include <com/sun/star/container/XIndexContainer.hpp>
      32             : #include <com/sun/star/frame/XFrame.hpp>
      33             : #include <com/sun/star/frame/XStatusListener.hpp>
      34             : #include <com/sun/star/frame/XModuleManager.hpp>
      35             : #include <com/sun/star/frame/XUIControllerFactory.hpp>
      36             : #include <com/sun/star/frame/XSubToolbarController.hpp>
      37             : #include <com/sun/star/frame/XLayoutManager.hpp>
      38             : #include <com/sun/star/frame/XToolbarController.hpp>
      39             : #include <com/sun/star/lang/XComponent.hpp>
      40             : #include <com/sun/star/ui/XImageManager.hpp>
      41             : #include <com/sun/star/ui/XUIConfigurationManager.hpp>
      42             : #include <com/sun/star/ui/ItemStyle.hpp>
      43             : #include <com/sun/star/ui/XAcceleratorConfiguration.hpp>
      44             : #include <com/sun/star/uno/XComponentContext.hpp>
      45             : #include <com/sun/star/util/XURLTransformer.hpp>
      46             : 
      47             : #include <rtl/ustring.hxx>
      48             : #include <cppuhelper/implbase4.hxx>
      49             : #include <cppuhelper/interfacecontainer.hxx>
      50             : 
      51             : #include <tools/link.hxx>
      52             : #include <vcl/window.hxx>
      53             : #include <vcl/timer.hxx>
      54             : 
      55             : #include <unordered_map>
      56             : 
      57             : class PopupMenu;
      58             : class ToolBox;
      59             : 
      60             : namespace framework
      61             : {
      62             : 
      63             : typedef ::cppu::WeakImplHelper4<
      64             :            ::com::sun::star::frame::XFrameActionListener,
      65             :            ::com::sun::star::frame::XStatusListener,
      66             :            ::com::sun::star::lang::XComponent,
      67             :            ::com::sun::star::ui::XUIConfigurationListener
      68             :         > ToolbarManager_Base;
      69             : 
      70             : class ToolBarManager : public ToolbarManager_Base
      71             : {
      72             :     public:
      73             :         ToolBarManager( const com::sun::star::uno::Reference< com::sun::star::uno::XComponentContext >& rxContext,
      74             :                         const com::sun::star::uno::Reference< com::sun::star::frame::XFrame >& rFrame,
      75             :                         const OUString& rResourceName,
      76             :                         ToolBox* pToolBar );
      77             :         virtual ~ToolBarManager();
      78             : 
      79             :         ToolBox* GetToolBar() const;
      80             : 
      81             :         // XFrameActionListener
      82             :         virtual void SAL_CALL frameAction( const com::sun::star::frame::FrameActionEvent& Action ) throw ( ::com::sun::star::uno::RuntimeException, std::exception ) SAL_OVERRIDE;
      83             : 
      84             :         // XStatusListener
      85             :         virtual void SAL_CALL statusChanged( const ::com::sun::star::frame::FeatureStateEvent& Event ) throw ( ::com::sun::star::uno::RuntimeException, std::exception ) SAL_OVERRIDE;
      86             : 
      87             :         // XEventListener
      88             :         virtual void SAL_CALL disposing( const com::sun::star::lang::EventObject& Source ) throw ( ::com::sun::star::uno::RuntimeException, std::exception ) SAL_OVERRIDE;
      89             : 
      90             :         // XUIConfigurationListener
      91             :         virtual void SAL_CALL elementInserted( const ::com::sun::star::ui::ConfigurationEvent& Event ) throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
      92             :         virtual void SAL_CALL elementRemoved( const ::com::sun::star::ui::ConfigurationEvent& Event ) throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
      93             :         virtual void SAL_CALL elementReplaced( const ::com::sun::star::ui::ConfigurationEvent& Event ) throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
      94             : 
      95             :         // XComponent
      96             :         void SAL_CALL dispose() throw ( ::com::sun::star::uno::RuntimeException, std::exception ) SAL_OVERRIDE;
      97             :         void SAL_CALL addEventListener( const com::sun::star::uno::Reference< XEventListener >& xListener ) throw( com::sun::star::uno::RuntimeException, std::exception ) SAL_OVERRIDE;
      98             :         void SAL_CALL removeEventListener( const com::sun::star::uno::Reference< XEventListener >& xListener ) throw( com::sun::star::uno::RuntimeException, std::exception ) SAL_OVERRIDE;
      99             : 
     100             :         void CheckAndUpdateImages();
     101             :         virtual void RefreshImages();
     102             :         void FillToolbar( const ::com::sun::star::uno::Reference< ::com::sun::star::container::XIndexAccess >& rToolBarData );
     103             :         void notifyRegisteredControllers( const OUString& aUIElementName, const OUString& aCommand );
     104             :         void Destroy();
     105             : 
     106             :         enum ExecuteCommand
     107             :         {
     108             :             EXEC_CMD_CLOSETOOLBAR,
     109             :             EXEC_CMD_DOCKTOOLBAR,
     110             :             EXEC_CMD_DOCKALLTOOLBARS,
     111             :             EXEC_CMD_NONE,
     112             :             EXEC_CMD_COUNT
     113             :         };
     114             : 
     115           0 :         struct ExecuteInfo
     116             :         {
     117             :             OUString   aToolbarResName;
     118             :             ExecuteCommand  nCmd;
     119             :             ::com::sun::star::uno::Reference< ::com::sun::star::frame::XLayoutManager > xLayoutManager;
     120             :             ::com::sun::star::uno::Reference< ::com::sun::star::awt::XWindow > xWindow;
     121             :         };
     122             :         struct ControllerParams
     123             :         {
     124             :             sal_Int16 nWidth;
     125             :         };
     126             :         typedef std::vector< ControllerParams > ControllerParamsVector;
     127             : 
     128             :     protected:
     129             :         DECL_LINK_TYPED( Command, CommandEvent const *, void );
     130             :         PopupMenu * GetToolBarCustomMenu(ToolBox* pToolBar);
     131             :         DECL_LINK_TYPED(Click, ToolBox *, void);
     132             :         DECL_LINK_TYPED(DropdownClick, ToolBox *, void);
     133             :         DECL_LINK_TYPED(DoubleClick, ToolBox *, void);
     134             :         DECL_LINK_TYPED(Select, ToolBox *, void);
     135             :         DECL_LINK_TYPED( StateChanged, StateChangedType const *, void );
     136             :         DECL_LINK_TYPED( DataChanged, DataChangedEvent const *, void );
     137             :         DECL_LINK( MiscOptionsChanged, void* );
     138             : 
     139             :         DECL_LINK_TYPED( MenuButton, ToolBox *, void );
     140             :         DECL_LINK( MenuSelect, Menu * );
     141             :         DECL_LINK_TYPED( MenuDeactivate, Menu *, bool );
     142             :         DECL_LINK_TYPED(AsyncUpdateControllersHdl, Timer *, void);
     143             :         DECL_STATIC_LINK( ToolBarManager, ExecuteHdl_Impl, ExecuteInfo* );
     144             : 
     145             :         virtual bool MenuItemAllowed( sal_uInt16 ) const;
     146             : 
     147             :         void RemoveControllers();
     148             :         OUString RetrieveLabelFromCommand( const OUString& aCmdURL );
     149             :         sal_Int32 RetrievePropertiesFromCommand( const OUString& aCmdURL );
     150             :         ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue > GetPropsForCommand( const OUString& rCmdURL );
     151             :         void CreateControllers();
     152             :         void UpdateControllers();
     153             :         //for update controller via Support Visiable
     154             :         void UpdateController( ::com::sun::star::uno::Reference< ::com::sun::star::frame::XToolbarController > xController);
     155             :         //end
     156             :         void AddFrameActionListener();
     157             :         void AddImageOrientationListener();
     158             :         void UpdateImageOrientation();
     159             :         void ImplClearPopupMenu( ToolBox *pToolBar );
     160             :         void RequestImages();
     161             :         ToolBoxItemBits ConvertStyleToToolboxItemBits( sal_Int32 nStyle );
     162             :         ::com::sun::star::uno::Reference< ::com::sun::star::frame::XModel > GetModelFromFrame() const;
     163             :         bool IsPluginMode() const;
     164             :         Image QueryAddonsImage( const OUString& aCommandURL, bool bBigImages );
     165             :         long HandleClick(void ( SAL_CALL ::com::sun::star::frame::XToolbarController::*_pClick )(  ));
     166             :         void setToolBarImage(const Image& _aImage,const CommandToInfoMap::const_iterator& _pIter);
     167             :         void impl_elementChanged(bool _bRemove,const ::com::sun::star::ui::ConfigurationEvent& Event );
     168             : 
     169             :         static bool impl_RetrieveShortcutsFromConfiguration( const ::com::sun::star::uno::Reference< ::com::sun::star::ui::XAcceleratorConfiguration >& rAccelCfg, const OUString& rCommand, OUString& rShortCut );
     170             :         bool RetrieveShortcut( const OUString& rCommandURL, OUString& rShortCut );
     171             : 
     172             :     protected:
     173             :         typedef std::unordered_map< sal_uInt16, ::com::sun::star::uno::Reference< com::sun::star::frame::XStatusListener > > ToolBarControllerMap;
     174             :         typedef ::std::vector< ::com::sun::star::uno::Reference< ::com::sun::star::frame::XSubToolbarController > > SubToolBarControllerVector;
     175             :         typedef BaseHash< SubToolBarControllerVector >                                                              SubToolBarToSubToolBarControllerMap;
     176             : 
     177             :         typedef std::unordered_map< sal_uInt16, ::com::sun::star::uno::Reference< com::sun::star::container::XIndexAccess > > MenuDescriptionMap;
     178             : 
     179             :         bool m_bDisposed : 1,
     180             :              m_bSmallSymbols : 1,
     181             :              m_bModuleIdentified : 1,
     182             :              m_bAddedToTaskPaneList : 1,
     183             :              m_bFrameActionRegistered : 1,
     184             :              m_bUpdateControllers : 1,
     185             :              m_bImageOrientationRegistered : 1,
     186             :              m_bImageMirrored : 1;
     187             : 
     188             :         long m_lImageRotation;
     189             : 
     190             :         VclPtr<ToolBox> m_pToolBar;
     191             : 
     192             :         OUString m_aModuleIdentifier;
     193             :         OUString m_aResourceName;
     194             : 
     195             :         com::sun::star::uno::Reference< ::com::sun::star::util::XURLTransformer >              m_xURLTransformer;
     196             :         com::sun::star::uno::Reference< com::sun::star::frame::XFrame >                        m_xFrame;
     197             :         com::sun::star::uno::Reference< com::sun::star::container::XNameAccess >               m_xUICommandLabels;
     198             :         ToolBarControllerMap                                                                   m_aControllerMap;
     199             :         osl::Mutex m_mutex;
     200             :         ::cppu::OMultiTypeInterfaceContainerHelper                                             m_aListenerContainer;   /// container for ALL Listener
     201             :         ::com::sun::star::uno::Reference< com::sun::star::uno::XComponentContext >             m_xContext;
     202             :         ::com::sun::star::uno::Reference< ::com::sun::star::frame::XUIControllerFactory > m_xToolbarControllerFactory;
     203             :         ::com::sun::star::uno::Reference< ::com::sun::star::ui::XImageManager >                m_xModuleImageManager;
     204             :         ::com::sun::star::uno::Reference< ::com::sun::star::ui::XImageManager >                m_xDocImageManager;
     205             :         ::com::sun::star::uno::Reference< ::com::sun::star::lang::XComponent >                 m_xImageOrientationListener;
     206             :         ::com::sun::star::uno::Reference< ::com::sun::star::ui::XUIConfigurationManager >                m_xUICfgMgr;
     207             :         ::com::sun::star::uno::Reference< ::com::sun::star::ui::XUIConfigurationManager >                m_xDocUICfgMgr;
     208             : 
     209             :         CommandToInfoMap                                                                       m_aCommandMap;
     210             :         SubToolBarToSubToolBarControllerMap                                                    m_aSubToolBarControllerMap;
     211             :         Timer                                                                                  m_aAsyncUpdateControllersTimer;
     212             :         OUString                                                                               m_sIconTheme;
     213             :         MenuDescriptionMap m_aMenuMap;
     214             :         bool                                                                               m_bAcceleratorCfg;
     215             :         ::com::sun::star::uno::Reference< ::com::sun::star::ui::XAcceleratorConfiguration >    m_xDocAcceleratorManager;
     216             :         ::com::sun::star::uno::Reference< ::com::sun::star::ui::XAcceleratorConfiguration >    m_xModuleAcceleratorManager;
     217             :         ::com::sun::star::uno::Reference< ::com::sun::star::ui::XAcceleratorConfiguration >    m_xGlobalAcceleratorManager;
     218             : };
     219             : 
     220             : }
     221             : 
     222             : #endif // INCLUDED_FRAMEWORK_INC_UIELEMENT_TOOLBARMANAGER_HXX
     223             : 
     224             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.11