1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: toolbarmanager.hxx,v $
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 //_________________________________________________________________________________________________________________
36 //_________________________________________________________________________________________________________________
38 #include <threadhelp/threadhelpbase.hxx>
39 #include <macros/generic.hxx>
40 #include <macros/xinterface.hxx>
41 #include <macros/xtypeprovider.hxx>
43 #include <uielement/commandinfo.hxx>
45 //_________________________________________________________________________________________________________________
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/container/XIndexContainer.hpp>
54 #include <com/sun/star/frame/XModuleManager.hpp>
55 #include <com/sun/star/lang/XMultiServiceFactory.hpp>
56 #include <com/sun/star/frame/XUIControllerRegistration.hpp>
57 #include <com/sun/star/ui/XImageManager.hpp>
58 #include <com/sun/star/frame/XStatusListener.hpp>
59 #include <com/sun/star/frame/XSubToolbarController.hpp>
60 #include <com/sun/star/frame/XToolbarController.hpp>
61 #include <com/sun/star/ui/ItemStyle.hpp>
62 #include <com/sun/star/util/XURLTransformer.hpp>
64 //_________________________________________________________________________________________________________________
66 //_________________________________________________________________________________________________________________
67 #include <rtl/ustring.hxx>
68 #include <cppuhelper/weak.hxx>
69 #include <cppuhelper/interfacecontainer.hxx>
71 #include <vcl/toolbox.hxx>
91 class ToolBarManager
: public ::com::sun::star::frame::XFrameActionListener
,
92 public ::com::sun::star::frame::XStatusListener
,
93 public ::com::sun::star::lang::XComponent
,
94 public ::com::sun::star::lang::XTypeProvider
,
95 public ::com::sun::star::ui::XUIConfigurationListener
,
96 public ThreadHelpBase
,
97 public ::cppu::OWeakObject
100 ToolBarManager( const com::sun::star::uno::Reference
< com::sun::star::lang::XMultiServiceFactory
>& rServicveManager
,
101 const com::sun::star::uno::Reference
< com::sun::star::frame::XFrame
>& rFrame
,
102 const rtl::OUString
& rResourceName
,
104 virtual ~ToolBarManager();
106 // XInterface, XTypeProvider, XServiceInfo
107 FWK_DECLARE_XINTERFACE
108 FWK_DECLARE_XTYPEPROVIDER
110 ToolBox
* GetToolBar() const;
112 // XFrameActionListener
113 virtual void SAL_CALL
frameAction( const com::sun::star::frame::FrameActionEvent
& Action
) throw ( ::com::sun::star::uno::RuntimeException
);
116 virtual void SAL_CALL
statusChanged( const ::com::sun::star::frame::FeatureStateEvent
& Event
) throw ( ::com::sun::star::uno::RuntimeException
);
119 virtual void SAL_CALL
disposing( const com::sun::star::lang::EventObject
& Source
) throw ( ::com::sun::star::uno::RuntimeException
);
121 // XUIConfigurationListener
122 virtual void SAL_CALL
elementInserted( const ::com::sun::star::ui::ConfigurationEvent
& Event
) throw (::com::sun::star::uno::RuntimeException
);
123 virtual void SAL_CALL
elementRemoved( const ::com::sun::star::ui::ConfigurationEvent
& Event
) throw (::com::sun::star::uno::RuntimeException
);
124 virtual void SAL_CALL
elementReplaced( const ::com::sun::star::ui::ConfigurationEvent
& Event
) throw (::com::sun::star::uno::RuntimeException
);
127 void SAL_CALL
dispose() throw ( ::com::sun::star::uno::RuntimeException
);
128 void SAL_CALL
addEventListener( const com::sun::star::uno::Reference
< XEventListener
>& xListener
) throw( com::sun::star::uno::RuntimeException
);
129 void SAL_CALL
removeEventListener( const com::sun::star::uno::Reference
< XEventListener
>& xListener
) throw( com::sun::star::uno::RuntimeException
);
131 void CheckAndUpdateImages();
132 virtual void RefreshImages();
133 void FillToolbar( const ::com::sun::star::uno::Reference
< ::com::sun::star::container::XIndexAccess
>& rToolBarData
);
134 void notifyRegisteredControllers( const rtl::OUString
& aUIElementName
, const rtl::OUString
& aCommand
);
139 EXEC_CMD_CLOSETOOLBAR
,
140 EXEC_CMD_DOCKTOOLBAR
,
141 EXEC_CMD_DOCKALLTOOLBARS
,
148 rtl::OUString aToolbarResName
;
150 ::com::sun::star::uno::Reference
< ::com::sun::star::frame::XLayoutManager
> xLayoutManager
;
151 ::com::sun::star::uno::Reference
< ::com::sun::star::awt::XWindow
> xWindow
;
153 struct ControllerParams
157 typedef std::vector
< ControllerParams
> ControllerParamsVector
;
160 //added for 33668 by shizhoubo : 2008:04
161 DECL_LINK( Command
, CommandEvent
* );
162 PopupMenu
* GetToolBarCustomMeun(ToolBox
* pToolBar
);
164 DECL_LINK( Click
, ToolBox
* );
165 DECL_LINK( DropdownClick
, ToolBox
* );
166 DECL_LINK( DoubleClick
, ToolBox
* );
167 DECL_LINK( Select
, ToolBox
* );
168 DECL_LINK( Highlight
, ToolBox
* );
169 DECL_LINK( Activate
, ToolBox
* );
170 DECL_LINK( Deactivate
, ToolBox
* );
171 DECL_LINK( StateChanged
, StateChangedType
* );
172 DECL_LINK( DataChanged
, DataChangedEvent
* );
174 DECL_LINK( MenuButton
, ToolBox
* );
175 DECL_LINK( MenuSelect
, Menu
* );
176 DECL_LINK( MenuDeactivate
, Menu
* );
177 DECL_LINK( AsyncUpdateControllersHdl
, Timer
* );
178 DECL_STATIC_LINK( ToolBarManager
, ExecuteHdl_Impl
, ExecuteInfo
* );
180 virtual bool MenuItemAllowed( sal_uInt16
) const;
182 void RemoveControllers();
183 rtl::OUString
RetrieveLabelFromCommand( const rtl::OUString
& aCmdURL
);
184 void CreateControllers();
185 void UpdateControllers();
186 void AddFrameActionListener();
187 void AddImageOrientationListener();
188 void UpdateImageOrientation();
189 void ImplClearPopupMenu( ToolBox
*pToolBar
);
190 void RequestImages();
191 sal_uInt16
ConvertStyleToToolboxItemBits( sal_Int32 nStyle
);
192 ::com::sun::star::uno::Reference
< ::com::sun::star::frame::XModel
> GetModelFromFrame() const;
193 sal_Bool
IsPluginMode() const;
194 Image
QueryAddonsImage( const ::rtl::OUString
& aCommandURL
, bool bBigImages
, bool bHiContrast
);
195 long HandleClick(void ( SAL_CALL ::com::sun::star::frame::XToolbarController::*_pClick
)( ));
196 void setToolBarImage(const Image
& _aImage
,const CommandToInfoMap::const_iterator
& _pIter
);
197 void impl_elementChanged(bool _bRemove
,const ::com::sun::star::ui::ConfigurationEvent
& Event
);
200 typedef ::std::hash_map
< sal_uInt16
, ::com::sun::star::uno::Reference
< com::sun::star::frame::XStatusListener
> > ToolBarControllerMap
;
201 typedef ::std::vector
< ::com::sun::star::uno::Reference
< ::com::sun::star::frame::XSubToolbarController
> > SubToolBarControllerVector
;
202 typedef BaseHash
< SubToolBarControllerVector
> SubToolBarToSubToolBarControllerMap
;
204 typedef ::std::hash_map
< sal_uInt16
, ::com::sun::star::uno::Reference
< com::sun::star::container::XIndexAccess
> > MenuDescriptionMap
;
205 sal_Bool m_bDisposed
: 1,
208 m_bModuleIdentified
: 1,
209 m_bAddedToTaskPaneList
: 1,
210 m_bVerticalTextEnabled
: 1,
211 m_bFrameActionRegistered
: 1,
212 m_bUpdateControllers
: 1;
213 sal_Bool m_bImageOrientationRegistered
: 1,
214 m_bImageMirrored
: 1,
215 m_bCanBeCustomized
: 1;
216 long m_lImageRotation
;
218 rtl::OUString m_aModuleIdentifier
;
219 rtl::OUString m_aResourceName
;
220 com::sun::star::uno::Reference
< ::com::sun::star::util::XURLTransformer
> m_xURLTransformer
;
221 com::sun::star::uno::Reference
< com::sun::star::frame::XFrame
> m_xFrame
;
222 com::sun::star::uno::Reference
< com::sun::star::container::XNameAccess
> m_xUICommandLabels
;
223 ToolBarControllerMap m_aControllerMap
;
224 ::cppu::OMultiTypeInterfaceContainerHelper m_aListenerContainer
; /// container for ALL Listener
225 ::com::sun::star::uno::Reference
< com::sun::star::lang::XMultiServiceFactory
> m_xServiceManager
;
226 ::com::sun::star::uno::Reference
< ::com::sun::star::frame::XUIControllerRegistration
> m_xToolbarControllerRegistration
;
227 ::com::sun::star::uno::Reference
< ::com::sun::star::ui::XImageManager
> m_xModuleImageManager
;
228 ::com::sun::star::uno::Reference
< ::com::sun::star::ui::XImageManager
> m_xDocImageManager
;
229 ::com::sun::star::uno::Reference
< ::com::sun::star::lang::XComponent
> m_xImageOrientationListener
;
230 CommandToInfoMap m_aCommandMap
;
231 SubToolBarToSubToolBarControllerMap m_aSubToolBarControllerMap
;
232 Timer m_aAsyncUpdateControllersTimer
;
233 sal_Int16 m_nSymbolsStyle
;
234 MenuDescriptionMap m_aMenuMap
;
239 #endif // __FRAMEWORK_UIELEMENT_TOOLBARMANAGER_HXX_