fix baseline build (old cairo) - 'cairo_rectangle_int_t' does not name a type
[LibreOffice.git] / framework / inc / uielement / menubarmanager.hxx
blobb72d515be311c21729b7a41b01cef5d351e5718e
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_MENUBARMANAGER_HXX
21 #define INCLUDED_FRAMEWORK_INC_UIELEMENT_MENUBARMANAGER_HXX
23 /** Attention: stl headers must(!) be included at first. Otherwise it can make trouble
24 with solaris headers ...
26 #include <vector>
28 #include <stdtypes.h>
30 #include <com/sun/star/frame/XFrame.hpp>
31 #include <com/sun/star/frame/XDispatch.hpp>
32 #include <com/sun/star/frame/XDispatchProvider.hpp>
33 #include <com/sun/star/frame/FeatureStateEvent.hpp>
34 #include <com/sun/star/frame/XFrameActionListener.hpp>
35 #include <com/sun/star/beans/PropertyValue.hpp>
36 #include <com/sun/star/frame/XPopupMenuController.hpp>
37 #include <com/sun/star/awt/XSystemDependentMenuPeer.hpp>
38 #include <com/sun/star/container/XIndexAccess.hpp>
39 #include <com/sun/star/container/XNameAccess.hpp>
40 #include <com/sun/star/lang/XComponent.hpp>
41 #include <com/sun/star/lang/XMultiComponentFactory.hpp>
42 #include <com/sun/star/frame/XUIControllerFactory.hpp>
43 #include <com/sun/star/ui/XUIConfigurationListener.hpp>
44 #include <com/sun/star/ui/XImageManager.hpp>
45 #include <com/sun/star/ui/XAcceleratorConfiguration.hpp>
46 #include <com/sun/star/util/XURLTransformer.hpp>
47 #include <com/sun/star/lang/XMultiServiceFactory.hpp>
49 #include <rtl/ustring.hxx>
50 #include <vcl/menu.hxx>
51 #include <vcl/accel.hxx>
52 #include <vcl/timer.hxx>
53 #include <toolkit/awt/vclxmenu.hxx>
54 #include <cppuhelper/weak.hxx>
55 #include <cppuhelper/weakref.hxx>
56 #include <cppuhelper/interfacecontainer.hxx>
57 #include <framework/addonsoptions.hxx>
59 namespace framework
62 struct PopupControllerEntry
64 ::com::sun::star::uno::WeakReference< ::com::sun::star::frame::XDispatchProvider > m_xDispatchProvider;
67 typedef std::unordered_map< OUString, PopupControllerEntry, OUStringHash, std::equal_to< OUString > > PopupControllerCache;
69 class BmkMenu;
70 class AddonMenu;
71 class AddonPopupMenu;
72 class MenuBarManager : public com::sun::star::frame::XStatusListener ,
73 public com::sun::star::frame::XFrameActionListener ,
74 public com::sun::star::ui::XUIConfigurationListener ,
75 public com::sun::star::lang::XComponent ,
76 public com::sun::star::awt::XSystemDependentMenuPeer ,
77 public ::cppu::OWeakObject
79 protected:
80 MenuBarManager(
81 const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext >& xContext,
82 const ::com::sun::star::uno::Reference< com::sun::star::frame::XFrame >& rFrame,
83 const ::com::sun::star::uno::Reference< ::com::sun::star::util::XURLTransformer >& _xURLTransformer,
84 Menu* pAddonMenu,
85 bool bDelete,
86 bool bDeleteChildren,
87 bool popup);
89 public:
90 MenuBarManager(
91 const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext >& xContext,
92 const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XFrame >& rFrame,
93 const ::com::sun::star::uno::Reference< ::com::sun::star::util::XURLTransformer >& _xURLTransformer,
94 const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XDispatchProvider >& rDispatchProvider,
95 const OUString& aModuleIdentifier,
96 Menu* pMenu,
97 bool bDelete,
98 bool bDeleteChildren );
100 virtual ~MenuBarManager();
102 // XInterface
103 virtual void SAL_CALL acquire() throw() SAL_OVERRIDE;
104 virtual void SAL_CALL release() throw() SAL_OVERRIDE;
105 virtual ::com::sun::star::uno::Any SAL_CALL queryInterface( const ::com::sun::star::uno::Type & rType ) throw( ::com::sun::star::uno::RuntimeException, std::exception ) SAL_OVERRIDE;
107 // XComponent
108 virtual void SAL_CALL dispose() throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
109 virtual void SAL_CALL addEventListener( const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XEventListener >& xListener ) throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
110 virtual void SAL_CALL removeEventListener( const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XEventListener >& aListener ) throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
112 // XStatusListener
113 virtual void SAL_CALL statusChanged( const com::sun::star::frame::FeatureStateEvent& Event ) throw ( ::com::sun::star::uno::RuntimeException, std::exception ) SAL_OVERRIDE;
115 // XFrameActionListener
116 virtual void SAL_CALL frameAction( const com::sun::star::frame::FrameActionEvent& Action ) throw ( ::com::sun::star::uno::RuntimeException, std::exception ) SAL_OVERRIDE;
118 // XEventListener
119 virtual void SAL_CALL disposing( const ::com::sun::star::lang::EventObject& Source ) throw ( ::com::sun::star::uno::RuntimeException, std::exception ) SAL_OVERRIDE;
121 // XUIConfigurationListener
122 virtual void SAL_CALL elementInserted( const ::com::sun::star::ui::ConfigurationEvent& Event ) throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
123 virtual void SAL_CALL elementRemoved( const ::com::sun::star::ui::ConfigurationEvent& Event ) throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
124 virtual void SAL_CALL elementReplaced( const ::com::sun::star::ui::ConfigurationEvent& Event ) throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
126 // XSystemDependentMenuPeer
127 virtual ::com::sun::star::uno::Any SAL_CALL getMenuHandle( const ::com::sun::star::uno::Sequence< sal_Int8 >& ProcessId, sal_Int16 SystemType ) throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
129 DECL_LINK( Select, Menu * );
131 Menu* GetMenuBar() const { return m_pVCLMenu; }
133 // Configuration methods
134 static void FillMenuWithConfiguration( sal_uInt16& nId, Menu* pMenu,
135 const OUString& rModuleIdentifier,
136 const ::com::sun::star::uno::Reference< ::com::sun::star::container::XIndexAccess >& rItemContainer,
137 const ::com::sun::star::uno::Reference< ::com::sun::star::util::XURLTransformer >& rTransformer );
138 static void FillMenu( sal_uInt16& nId,
139 Menu* pMenu,
140 const OUString& rModuleIdentifier,
141 const ::com::sun::star::uno::Reference< ::com::sun::star::container::XIndexAccess >& rItemContainer,
142 const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XDispatchProvider >& rDispatchProvider );
144 void FillMenuManager( Menu* pMenu,
145 const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XFrame >& rFrame,
146 const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XDispatchProvider >& rDispatchProvider,
147 const OUString& rModuleIdentifier,
148 bool bDelete,
149 bool bDeleteChildren );
150 void SetItemContainer( const ::com::sun::star::uno::Reference< ::com::sun::star::container::XIndexAccess >& rItemContainer );
151 void GetPopupController( PopupControllerCache& rPopupController );
153 protected:
154 DECL_LINK_TYPED(Highlight, Menu *, bool);
155 DECL_LINK_TYPED( Activate, Menu *, bool );
156 DECL_LINK_TYPED( Deactivate, Menu *, bool );
157 DECL_LINK_TYPED( AsyncSettingsHdl, Timer *, void );
159 void RemoveListener();
160 void RequestImages();
161 void RetrieveImageManagers();
162 static bool MustBeHidden( PopupMenu* pPopupMenu, const ::com::sun::star::uno::Reference< ::com::sun::star::util::XURLTransformer >& rTransformer );
163 OUString RetrieveLabelFromCommand(const OUString& rCmdURL);
165 private:
167 void Destroy();
169 struct MenuItemHandler
171 MenuItemHandler( sal_uInt16 aItemId,
172 ::com::sun::star::uno::Reference< ::com::sun::star::frame::XStatusListener >& xManager,
173 ::com::sun::star::uno::Reference< ::com::sun::star::frame::XDispatch >& rDispatch ) :
174 nItemId( aItemId ),
175 bCheckHide( true ),
176 xSubMenuManager( xManager ),
177 xMenuItemDispatch( rDispatch ) {}
179 sal_uInt16 nItemId;
180 bool bCheckHide;
181 OUString aTargetFrame;
182 OUString aMenuItemURL;
183 OUString aFilter;
184 OUString aPassword;
185 OUString aTitle;
186 ::com::sun::star::uno::Reference< ::com::sun::star::frame::XStatusListener > xSubMenuManager;
187 ::com::sun::star::uno::Reference< ::com::sun::star::frame::XDispatch > xMenuItemDispatch;
188 ::com::sun::star::uno::Reference< ::com::sun::star::frame::XPopupMenuController > xPopupMenuController;
189 ::com::sun::star::uno::Reference< ::com::sun::star::awt::XPopupMenu > xPopupMenu;
190 vcl::KeyCode aKeyCode;
193 void RetrieveShortcuts( std::vector< MenuItemHandler* >& aMenuShortCuts );
194 void CreatePicklistArguments(
195 ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue >& aArgsList,
196 const MenuItemHandler* );
197 void CheckAndAddMenuExtension( Menu* pMenu );
198 static void impl_RetrieveShortcutsFromConfiguration( const ::com::sun::star::uno::Reference< ::com::sun::star::ui::XAcceleratorConfiguration >& rAccelCfg,
199 const ::com::sun::star::uno::Sequence< OUString >& rCommands,
200 std::vector< MenuItemHandler* >& aMenuShortCuts );
201 static void MergeAddonMenus( Menu* pMenuBar, const MergeMenuInstructionContainer&, const OUString& aModuleIdentifier );
203 MenuItemHandler* GetMenuItemHandler( sal_uInt16 nItemId );
204 bool CreatePopupMenuController( MenuItemHandler* pMenuItemHandler );
205 void AddMenu(MenuBarManager* pSubMenuManager,const OUString& _sItemCommand,sal_uInt16 _nItemId);
206 sal_uInt16 FillItemCommand(OUString& _rItemCommand, Menu* _pMenu,sal_uInt16 _nIndex) const;
207 void Init(const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XFrame >& rFrame,Menu* pAddonMenu,bool bDelete,bool bDeleteChildren,bool _bHandlePopUp);
208 void SetHdl();
210 bool m_bDisposed : 1,
211 m_bInitialized : 1,
212 m_bDeleteMenu : 1,
213 m_bDeleteChildren : 1,
214 m_bActive : 1,
215 m_bIsBookmarkMenu : 1,
216 m_bShowMenuImages : 1;
217 bool m_bRetrieveImages : 1,
218 m_bAcceleratorCfg : 1;
219 bool m_bModuleIdentified;
220 OUString m_aMenuItemCommand;
221 OUString m_aModuleIdentifier;
222 Menu* m_pVCLMenu;
223 ::com::sun::star::uno::Reference< ::com::sun::star::frame::XFrame > m_xFrame;
224 ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameAccess > m_xUICommandLabels;
225 ::com::sun::star::uno::Reference< ::com::sun::star::frame::XUIControllerFactory > m_xPopupMenuControllerFactory;
226 ::std::vector< MenuItemHandler* > m_aMenuItemHandlerVector;
227 osl::Mutex m_mutex;
228 ::cppu::OMultiTypeInterfaceContainerHelper m_aListenerContainer; /// container for ALL Listener
229 ::com::sun::star::uno::Reference< ::com::sun::star::frame::XDispatchProvider > m_xDispatchProvider;
230 ::com::sun::star::uno::Reference< ::com::sun::star::ui::XImageManager > m_xDocImageManager;
231 ::com::sun::star::uno::Reference< ::com::sun::star::ui::XImageManager > m_xModuleImageManager;
232 ::com::sun::star::uno::Reference< ::com::sun::star::ui::XAcceleratorConfiguration > m_xDocAcceleratorManager;
233 ::com::sun::star::uno::Reference< ::com::sun::star::ui::XAcceleratorConfiguration > m_xModuleAcceleratorManager;
234 ::com::sun::star::uno::Reference< ::com::sun::star::ui::XAcceleratorConfiguration > m_xGlobalAcceleratorManager;
235 ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext > m_xContext;
236 ::com::sun::star::uno::Reference< ::com::sun::star::util::XURLTransformer > m_xURLTransformer;
237 ::com::sun::star::uno::Reference< ::com::sun::star::container::XIndexAccess > m_xDeferedItemContainer;
238 OUString m_sIconTheme;
239 Timer m_aAsyncSettingsTimer;
242 } // namespace
244 #endif
246 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */