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

Generated by: LCOV version 1.10