fix baseline build (old cairo) - 'cairo_rectangle_int_t' does not name a type
[LibreOffice.git] / framework / inc / uielement / toolbarmanager.hxx
blob78fb5a03f0c675d6a56658d04a5649353210456c
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
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/.
9 * This file incorporates work covered by the following license notice:
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 .
20 #ifndef INCLUDED_FRAMEWORK_INC_UIELEMENT_TOOLBARMANAGER_HXX
21 #define INCLUDED_FRAMEWORK_INC_UIELEMENT_TOOLBARMANAGER_HXX
23 #include <macros/generic.hxx>
24 #include <macros/xinterface.hxx>
25 #include <macros/xtypeprovider.hxx>
26 #include <stdtypes.h>
27 #include <uielement/commandinfo.hxx>
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>
47 #include <rtl/ustring.hxx>
48 #include <cppuhelper/implbase4.hxx>
49 #include <cppuhelper/interfacecontainer.hxx>
51 #include <tools/link.hxx>
52 #include <vcl/window.hxx>
53 #include <vcl/timer.hxx>
55 #include <unordered_map>
57 class PopupMenu;
58 class ToolBox;
60 namespace framework
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;
70 class ToolBarManager : public ToolbarManager_Base
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();
79 ToolBox* GetToolBar() const;
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;
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;
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;
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;
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;
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();
106 enum ExecuteCommand
108 EXEC_CMD_CLOSETOOLBAR,
109 EXEC_CMD_DOCKTOOLBAR,
110 EXEC_CMD_DOCKALLTOOLBARS,
111 EXEC_CMD_NONE,
112 EXEC_CMD_COUNT
115 struct ExecuteInfo
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;
122 struct ControllerParams
124 sal_Int16 nWidth;
126 typedef std::vector< ControllerParams > ControllerParamsVector;
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(Activate, ToolBox *, void);
136 DECL_LINK_TYPED(Deactivate, ToolBox *, void);
137 DECL_LINK_TYPED( StateChanged, StateChangedType const *, void );
138 DECL_LINK_TYPED( DataChanged, DataChangedEvent const *, void );
139 DECL_LINK( MiscOptionsChanged, void* );
141 DECL_LINK_TYPED( MenuButton, ToolBox *, void );
142 DECL_LINK( MenuSelect, Menu * );
143 DECL_LINK_TYPED( MenuDeactivate, Menu *, bool );
144 DECL_LINK_TYPED(AsyncUpdateControllersHdl, Timer *, void);
145 DECL_STATIC_LINK( ToolBarManager, ExecuteHdl_Impl, ExecuteInfo* );
147 virtual bool MenuItemAllowed( sal_uInt16 ) const;
149 void RemoveControllers();
150 OUString RetrieveLabelFromCommand( const OUString& aCmdURL );
151 sal_Int32 RetrievePropertiesFromCommand( const OUString& aCmdURL );
152 ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue > GetPropsForCommand( const OUString& rCmdURL );
153 void CreateControllers();
154 void UpdateControllers();
155 //for update controller via Support Visiable
156 void UpdateController( ::com::sun::star::uno::Reference< ::com::sun::star::frame::XToolbarController > xController);
157 //end
158 void AddFrameActionListener();
159 void AddImageOrientationListener();
160 void UpdateImageOrientation();
161 void ImplClearPopupMenu( ToolBox *pToolBar );
162 void RequestImages();
163 ToolBoxItemBits ConvertStyleToToolboxItemBits( sal_Int32 nStyle );
164 ::com::sun::star::uno::Reference< ::com::sun::star::frame::XModel > GetModelFromFrame() const;
165 bool IsPluginMode() const;
166 Image QueryAddonsImage( const OUString& aCommandURL, bool bBigImages );
167 long HandleClick(void ( SAL_CALL ::com::sun::star::frame::XToolbarController::*_pClick )( ));
168 void setToolBarImage(const Image& _aImage,const CommandToInfoMap::const_iterator& _pIter);
169 void impl_elementChanged(bool _bRemove,const ::com::sun::star::ui::ConfigurationEvent& Event );
171 static bool impl_RetrieveShortcutsFromConfiguration( const ::com::sun::star::uno::Reference< ::com::sun::star::ui::XAcceleratorConfiguration >& rAccelCfg, const OUString& rCommand, OUString& rShortCut );
172 bool RetrieveShortcut( const OUString& rCommandURL, OUString& rShortCut );
174 protected:
175 typedef std::unordered_map< sal_uInt16, ::com::sun::star::uno::Reference< com::sun::star::frame::XStatusListener > > ToolBarControllerMap;
176 typedef ::std::vector< ::com::sun::star::uno::Reference< ::com::sun::star::frame::XSubToolbarController > > SubToolBarControllerVector;
177 typedef BaseHash< SubToolBarControllerVector > SubToolBarToSubToolBarControllerMap;
179 typedef std::unordered_map< sal_uInt16, ::com::sun::star::uno::Reference< com::sun::star::container::XIndexAccess > > MenuDescriptionMap;
181 bool m_bDisposed : 1,
182 m_bSmallSymbols : 1,
183 m_bModuleIdentified : 1,
184 m_bAddedToTaskPaneList : 1,
185 m_bFrameActionRegistered : 1,
186 m_bUpdateControllers : 1,
187 m_bImageOrientationRegistered : 1,
188 m_bImageMirrored : 1;
190 long m_lImageRotation;
192 VclPtr<ToolBox> m_pToolBar;
194 OUString m_aModuleIdentifier;
195 OUString m_aResourceName;
197 com::sun::star::uno::Reference< ::com::sun::star::util::XURLTransformer > m_xURLTransformer;
198 com::sun::star::uno::Reference< com::sun::star::frame::XFrame > m_xFrame;
199 com::sun::star::uno::Reference< com::sun::star::container::XNameAccess > m_xUICommandLabels;
200 ToolBarControllerMap m_aControllerMap;
201 osl::Mutex m_mutex;
202 ::cppu::OMultiTypeInterfaceContainerHelper m_aListenerContainer; /// container for ALL Listener
203 ::com::sun::star::uno::Reference< com::sun::star::uno::XComponentContext > m_xContext;
204 ::com::sun::star::uno::Reference< ::com::sun::star::frame::XUIControllerFactory > m_xToolbarControllerFactory;
205 ::com::sun::star::uno::Reference< ::com::sun::star::ui::XImageManager > m_xModuleImageManager;
206 ::com::sun::star::uno::Reference< ::com::sun::star::ui::XImageManager > m_xDocImageManager;
207 ::com::sun::star::uno::Reference< ::com::sun::star::lang::XComponent > m_xImageOrientationListener;
208 ::com::sun::star::uno::Reference< ::com::sun::star::ui::XUIConfigurationManager > m_xUICfgMgr;
209 ::com::sun::star::uno::Reference< ::com::sun::star::ui::XUIConfigurationManager > m_xDocUICfgMgr;
211 CommandToInfoMap m_aCommandMap;
212 SubToolBarToSubToolBarControllerMap m_aSubToolBarControllerMap;
213 Timer m_aAsyncUpdateControllersTimer;
214 OUString m_sIconTheme;
215 MenuDescriptionMap m_aMenuMap;
216 bool m_bAcceleratorCfg;
217 ::com::sun::star::uno::Reference< ::com::sun::star::ui::XAcceleratorConfiguration > m_xDocAcceleratorManager;
218 ::com::sun::star::uno::Reference< ::com::sun::star::ui::XAcceleratorConfiguration > m_xModuleAcceleratorManager;
219 ::com::sun::star::uno::Reference< ::com::sun::star::ui::XAcceleratorConfiguration > m_xGlobalAcceleratorManager;
224 #endif // INCLUDED_FRAMEWORK_INC_UIELEMENT_TOOLBARMANAGER_HXX
226 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */