sync master with lastest vba changes
[ooovba.git] / framework / inc / uielement / toolbarmanager.hxx
blobeb47a0606df9ca6914113a01da3171bba0640989
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: toolbarmanager.hxx,v $
10 * $Revision: 1.23 $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 #ifndef __FRAMEWORK_UIELEMENT_TOOLBARMANAGER_HXX_
32 #define __FRAMEWORK_UIELEMENT_TOOLBARMANAGER_HXX_
34 //_________________________________________________________________________________________________________________
35 // my own includes
36 //_________________________________________________________________________________________________________________
38 #include <threadhelp/threadhelpbase.hxx>
39 #include <macros/generic.hxx>
40 #include <macros/xinterface.hxx>
41 #include <macros/xtypeprovider.hxx>
42 #include <stdtypes.h>
43 #include <uielement/commandinfo.hxx>
45 //_________________________________________________________________________________________________________________
46 // interface includes
47 //_________________________________________________________________________________________________________________
48 #include <com/sun/star/frame/XFrame.hpp>
49 #include <com/sun/star/frame/XStatusListener.hpp>
50 #include <com/sun/star/lang/XComponent.hpp>
51 #include <com/sun/star/container/XIndexAccess.hpp>
52 #include <com/sun/star/container/XNameAccess.hpp>
53 #include <com/sun/star/frame/XModuleManager.hpp>
54 #include <com/sun/star/lang/XMultiServiceFactory.hpp>
55 #include <com/sun/star/frame/XUIControllerRegistration.hpp>
56 #include <com/sun/star/ui/XImageManager.hpp>
57 #include <com/sun/star/frame/XStatusListener.hpp>
58 #include <com/sun/star/frame/XSubToolbarController.hpp>
59 #include <com/sun/star/ui/ItemStyle.hpp>
61 //_________________________________________________________________________________________________________________
62 // other includes
63 //_________________________________________________________________________________________________________________
64 #include <rtl/ustring.hxx>
65 #include <cppuhelper/weak.hxx>
66 #include <cppuhelper/interfacecontainer.hxx>
68 #include <vcl/toolbox.hxx>
70 namespace com
72 namespace sun
74 namespace star
76 namespace frame
78 class XLayoutManager;
84 namespace framework
87 class ToolBar;
88 class ToolBarManager : public ::com::sun::star::frame::XFrameActionListener ,
89 public ::com::sun::star::frame::XStatusListener ,
90 public ::com::sun::star::lang::XComponent ,
91 public ::com::sun::star::lang::XTypeProvider ,
92 public ::com::sun::star::ui::XUIConfigurationListener,
93 public ThreadHelpBase ,
94 public ::cppu::OWeakObject
96 public:
97 ToolBarManager( const com::sun::star::uno::Reference< com::sun::star::lang::XMultiServiceFactory >& rServicveManager,
98 const com::sun::star::uno::Reference< com::sun::star::frame::XFrame >& rFrame,
99 const rtl::OUString& rResourceName,
100 ToolBar* pToolBar );
101 virtual ~ToolBarManager();
103 // XInterface, XTypeProvider, XServiceInfo
104 FWK_DECLARE_XINTERFACE
105 FWK_DECLARE_XTYPEPROVIDER
107 ToolBox* GetToolBar() const;
109 // XFrameActionListener
110 virtual void SAL_CALL frameAction( const com::sun::star::frame::FrameActionEvent& Action ) throw ( ::com::sun::star::uno::RuntimeException );
112 // XStatusListener
113 virtual void SAL_CALL statusChanged( const ::com::sun::star::frame::FeatureStateEvent& Event ) throw ( ::com::sun::star::uno::RuntimeException );
115 // XEventListener
116 virtual void SAL_CALL disposing( const com::sun::star::lang::EventObject& Source ) throw ( ::com::sun::star::uno::RuntimeException );
118 // XUIConfigurationListener
119 virtual void SAL_CALL elementInserted( const ::com::sun::star::ui::ConfigurationEvent& Event ) throw (::com::sun::star::uno::RuntimeException);
120 virtual void SAL_CALL elementRemoved( const ::com::sun::star::ui::ConfigurationEvent& Event ) throw (::com::sun::star::uno::RuntimeException);
121 virtual void SAL_CALL elementReplaced( const ::com::sun::star::ui::ConfigurationEvent& Event ) throw (::com::sun::star::uno::RuntimeException);
123 // XComponent
124 void SAL_CALL dispose() throw ( ::com::sun::star::uno::RuntimeException );
125 void SAL_CALL addEventListener( const com::sun::star::uno::Reference< XEventListener >& xListener ) throw( com::sun::star::uno::RuntimeException );
126 void SAL_CALL removeEventListener( const com::sun::star::uno::Reference< XEventListener >& xListener ) throw( com::sun::star::uno::RuntimeException );
128 void CheckAndUpdateImages();
129 virtual void RefreshImages();
130 void FillToolbar( const ::com::sun::star::uno::Reference< ::com::sun::star::container::XIndexAccess >& rToolBarData );
131 void notifyRegisteredControllers( const rtl::OUString& aUIElementName, const rtl::OUString& aCommand );
132 void Destroy();
134 enum ExecuteCommand
136 EXEC_CMD_CLOSETOOLBAR,
137 EXEC_CMD_DOCKTOOLBAR,
138 EXEC_CMD_DOCKALLTOOLBARS,
139 EXEC_CMD_NONE,
140 EXEC_CMD_COUNT
143 struct ExecuteInfo
145 rtl::OUString aToolbarResName;
146 ExecuteCommand nCmd;
147 ::com::sun::star::uno::Reference< ::com::sun::star::frame::XLayoutManager > xLayoutManager;
148 ::com::sun::star::uno::Reference< ::com::sun::star::awt::XWindow > xWindow;
150 struct ControllerParams
152 sal_Int16 nWidth;
154 typedef std::vector< ControllerParams > ControllerParamsVector;
156 protected:
157 //added for 33668 by shizhoubo : 2008:04
158 DECL_LINK( Command, CommandEvent * );
159 PopupMenu * GetToolBarCustomMeun(ToolBox* pToolBar);
160 //end
161 DECL_LINK( Click, ToolBox * );
162 DECL_LINK( DropdownClick, ToolBox * );
163 DECL_LINK( DoubleClick, ToolBox * );
164 DECL_LINK( Select, ToolBox * );
165 DECL_LINK( Highlight, ToolBox * );
166 DECL_LINK( Activate, ToolBox * );
167 DECL_LINK( Deactivate, ToolBox * );
168 DECL_LINK( StateChanged, StateChangedType* );
169 DECL_LINK( DataChanged, DataChangedEvent* );
171 DECL_LINK( MenuButton, ToolBox * );
172 DECL_LINK( MenuSelect, Menu * );
173 DECL_LINK( MenuDeactivate, Menu * );
174 DECL_LINK( AsyncUpdateControllersHdl, Timer * );
175 DECL_STATIC_LINK( ToolBarManager, ExecuteHdl_Impl, ExecuteInfo* );
177 virtual bool MenuItemAllowed( sal_uInt16 ) const;
179 void RemoveControllers();
180 rtl::OUString RetrieveLabelFromCommand( const rtl::OUString& aCmdURL );
181 void CreateControllers();
182 void UpdateControllers();
183 void AddFrameActionListener();
184 void AddImageOrientationListener();
185 void UpdateImageOrientation();
186 void ImplClearPopupMenu( ToolBox *pToolBar );
187 void RequestImages();
188 sal_uInt16 ConvertStyleToToolboxItemBits( sal_Int32 nStyle );
189 ::com::sun::star::uno::Reference< ::com::sun::star::frame::XModel > GetModelFromFrame() const;
190 sal_Bool IsPluginMode() const;
191 Image QueryAddonsImage( const ::rtl::OUString& aCommandURL, bool bBigImages, bool bHiContrast );
193 protected:
194 typedef ::std::hash_map< sal_uInt16, ::com::sun::star::uno::Reference< com::sun::star::frame::XStatusListener > > ToolBarControllerMap;
195 typedef ::std::vector< ::com::sun::star::uno::Reference< ::com::sun::star::frame::XSubToolbarController > > SubToolBarControllerVector;
196 typedef BaseHash< SubToolBarControllerVector > SubToolBarToSubToolBarControllerMap;
198 sal_Bool m_bDisposed : 1,
199 m_bIsHiContrast : 1,
200 m_bSmallSymbols : 1,
201 m_bModuleIdentified : 1,
202 m_bAddedToTaskPaneList : 1,
203 m_bVerticalTextEnabled : 1,
204 m_bFrameActionRegistered : 1,
205 m_bUpdateControllers : 1;
206 sal_Bool m_bImageOrientationRegistered : 1,
207 m_bImageMirrored : 1,
208 m_bCanBeCustomized : 1;
209 long m_lImageRotation;
210 ToolBar* m_pToolBar;
211 rtl::OUString m_aModuleIdentifier;
212 rtl::OUString m_aResourceName;
213 com::sun::star::uno::Reference< com::sun::star::frame::XFrame > m_xFrame;
214 com::sun::star::uno::Reference< com::sun::star::container::XNameAccess > m_xUICommandLabels;
215 ToolBarControllerMap m_aControllerMap;
216 ::cppu::OMultiTypeInterfaceContainerHelper m_aListenerContainer; /// container for ALL Listener
217 ::com::sun::star::uno::Reference< com::sun::star::lang::XMultiServiceFactory > m_xServiceManager;
218 ::com::sun::star::uno::Reference< ::com::sun::star::frame::XUIControllerRegistration > m_xToolbarControllerRegistration;
219 ::com::sun::star::uno::Reference< ::com::sun::star::ui::XImageManager > m_xModuleImageManager;
220 ::com::sun::star::uno::Reference< ::com::sun::star::ui::XImageManager > m_xDocImageManager;
221 ::com::sun::star::uno::Reference< ::com::sun::star::lang::XComponent > m_xImageOrientationListener;
222 CommandToInfoMap m_aCommandMap;
223 SubToolBarToSubToolBarControllerMap m_aSubToolBarControllerMap;
224 Timer m_aAsyncUpdateControllersTimer;
225 sal_Int16 m_nSymbolsStyle;
230 #endif // __FRAMEWORK_UIELEMENT_TOOLBARMANAGER_HXX_