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

Generated by: LCOV version 1.10