1f8e07b45SAndrew Rist /**************************************************************
2cdf0e10cSrcweir  *
3f8e07b45SAndrew Rist  * Licensed to the Apache Software Foundation (ASF) under one
4f8e07b45SAndrew Rist  * or more contributor license agreements.  See the NOTICE file
5f8e07b45SAndrew Rist  * distributed with this work for additional information
6f8e07b45SAndrew Rist  * regarding copyright ownership.  The ASF licenses this file
7f8e07b45SAndrew Rist  * to you under the Apache License, Version 2.0 (the
8f8e07b45SAndrew Rist  * "License"); you may not use this file except in compliance
9f8e07b45SAndrew Rist  * with the License.  You may obtain a copy of the License at
10f8e07b45SAndrew Rist  *
11f8e07b45SAndrew Rist  *   http://www.apache.org/licenses/LICENSE-2.0
12f8e07b45SAndrew Rist  *
13f8e07b45SAndrew Rist  * Unless required by applicable law or agreed to in writing,
14f8e07b45SAndrew Rist  * software distributed under the License is distributed on an
15f8e07b45SAndrew Rist  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16f8e07b45SAndrew Rist  * KIND, either express or implied.  See the License for the
17f8e07b45SAndrew Rist  * specific language governing permissions and limitations
18f8e07b45SAndrew Rist  * under the License.
19f8e07b45SAndrew Rist  *
20f8e07b45SAndrew Rist  *************************************************************/
21f8e07b45SAndrew Rist 
22f8e07b45SAndrew Rist 
23cdf0e10cSrcweir 
24cdf0e10cSrcweir #ifndef __FRAMEWORK_CLASSES_MENUMANAGER_HXX_
25cdf0e10cSrcweir #define __FRAMEWORK_CLASSES_MENUMANAGER_HXX_
26cdf0e10cSrcweir 
27*4e7d57d8Smseidel /** Attention: stl headers must(!) be included at first. Otherwise it can make trouble
28cdf0e10cSrcweir                with solaris headers ...
29cdf0e10cSrcweir */
30cdf0e10cSrcweir #include <vector>
31cdf0e10cSrcweir 
32cdf0e10cSrcweir //_________________________________________________________________________________________________________________
33cdf0e10cSrcweir //	interface includes
34cdf0e10cSrcweir //_________________________________________________________________________________________________________________
35cdf0e10cSrcweir #include <com/sun/star/frame/XFrame.hpp>
36cdf0e10cSrcweir #include <com/sun/star/frame/XDispatch.hpp>
37cdf0e10cSrcweir #include <com/sun/star/frame/FeatureStateEvent.hpp>
38cdf0e10cSrcweir #include <com/sun/star/beans/PropertyValue.hpp>
39cdf0e10cSrcweir #include <com/sun/star/util/XURLTransformer.hpp>
40cdf0e10cSrcweir 
41cdf0e10cSrcweir //_________________________________________________________________________________________________________________
42cdf0e10cSrcweir //	other includes
43cdf0e10cSrcweir //_________________________________________________________________________________________________________________
44cdf0e10cSrcweir #include <rtl/ustring.hxx>
45cdf0e10cSrcweir #include <vcl/menu.hxx>
46cdf0e10cSrcweir #include <vcl/accel.hxx>
47cdf0e10cSrcweir #include <cppuhelper/implbase1.hxx>
48cdf0e10cSrcweir #include <threadhelp/threadhelpbase.hxx>
49cdf0e10cSrcweir #include <macros/debug.hxx>
50cdf0e10cSrcweir 
51cdf0e10cSrcweir // #110897#
52cdf0e10cSrcweir #include <com/sun/star/lang/XMultiServiceFactory.hpp>
53cdf0e10cSrcweir 
54cdf0e10cSrcweir #define	REFERENCE										::com::sun::star::uno::Reference
55cdf0e10cSrcweir #define	XFRAME											::com::sun::star::frame::XFrame
56cdf0e10cSrcweir #define XDISPATCH										::com::sun::star::frame::XDispatch
57cdf0e10cSrcweir #define XDISPATCHPROVIDER								::com::sun::star::frame::XDispatchProvider
58cdf0e10cSrcweir #define XSTATUSLISTENER									::com::sun::star::frame::XStatusListener
59cdf0e10cSrcweir #define XEVENTLISTENER									::com::sun::star::lang::XEventListener
60cdf0e10cSrcweir #define FEATURSTATEEVENT								::com::sun::star::frame::FeatureStateEvent
61cdf0e10cSrcweir #define RUNTIMEEXCEPTION								::com::sun::star::uno::RuntimeException
62cdf0e10cSrcweir #define EVENTOBJECT										::com::sun::star::lang::EventObject
63cdf0e10cSrcweir 
64cdf0e10cSrcweir namespace framework
65cdf0e10cSrcweir {
66cdf0e10cSrcweir 
67cdf0e10cSrcweir class BmkMenu;
68cdf0e10cSrcweir class AddonMenu;
69cdf0e10cSrcweir class AddonPopupMenu;
70cdf0e10cSrcweir class MenuManager : public ThreadHelpBase			,
71cdf0e10cSrcweir 					public ::cppu::WeakImplHelper1< ::com::sun::star::frame::XStatusListener >
72cdf0e10cSrcweir {
73cdf0e10cSrcweir 	public:
74cdf0e10cSrcweir 		// #110897#
75cdf0e10cSrcweir 		MenuManager(
76cdf0e10cSrcweir 			const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& xServiceFactory,
77cdf0e10cSrcweir 			REFERENCE< XFRAME >& rFrame,
78cdf0e10cSrcweir 			Menu* pMenu,
79cdf0e10cSrcweir 			sal_Bool bDelete,
80cdf0e10cSrcweir 			sal_Bool bDeleteChildren );
81cdf0e10cSrcweir #if 0
82cdf0e10cSrcweir 		MenuManager(
83cdf0e10cSrcweir 			const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& xServiceFactory,
84cdf0e10cSrcweir 			REFERENCE< XFRAME >& rFrame,
85cdf0e10cSrcweir 			AddonMenu*			pAddonMenu,
86cdf0e10cSrcweir 			sal_Bool			bDelete,
87cdf0e10cSrcweir 			sal_Bool			bDeleteChildren );
88cdf0e10cSrcweir #endif
89cdf0e10cSrcweir 
90cdf0e10cSrcweir 		virtual ~MenuManager();
91cdf0e10cSrcweir 
92cdf0e10cSrcweir 		// XStatusListener
93cdf0e10cSrcweir 		virtual void SAL_CALL statusChanged( const FEATURSTATEEVENT& Event ) throw ( RUNTIMEEXCEPTION );
94cdf0e10cSrcweir 
95cdf0e10cSrcweir 		// XEventListener
96cdf0e10cSrcweir 		virtual void SAL_CALL disposing( const EVENTOBJECT& Source ) throw ( RUNTIMEEXCEPTION );
97cdf0e10cSrcweir 
98cdf0e10cSrcweir 		DECL_LINK( Select, Menu * );
99cdf0e10cSrcweir 
GetMenu() const100cdf0e10cSrcweir 		Menu*	GetMenu() const { return m_pVCLMenu; }
101cdf0e10cSrcweir 
102cdf0e10cSrcweir 		void	RemoveListener();
103cdf0e10cSrcweir 
104cdf0e10cSrcweir 		// #110897#
105cdf0e10cSrcweir 		const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& getServiceFactory();
106cdf0e10cSrcweir 
107cdf0e10cSrcweir         static void UpdateSpecialWindowMenu( Menu* pMenu ,const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& xServiceFactory,IMutex& _rMutex);
108cdf0e10cSrcweir         static void FillMenuImages(::com::sun::star::uno::Reference< com::sun::star::frame::XFrame >& xFrame,Menu* _pMenu,sal_Bool bIsHiContrast,sal_Bool bShowMenuImages);
109cdf0e10cSrcweir 
110cdf0e10cSrcweir 	protected:
111cdf0e10cSrcweir 		DECL_LINK( Highlight, Menu * );
112cdf0e10cSrcweir 		DECL_LINK( Activate, Menu * );
113cdf0e10cSrcweir 		DECL_LINK( Deactivate, Menu * );
114cdf0e10cSrcweir 
115cdf0e10cSrcweir 	private:
116cdf0e10cSrcweir 		void UpdateSpecialFileMenu( Menu* pMenu );
117cdf0e10cSrcweir 		void UpdateSpecialWindowMenu( Menu* pMenu );
118cdf0e10cSrcweir         void ClearMenuDispatch(const EVENTOBJECT& Source = EVENTOBJECT(),bool _bRemoveOnly = true);
119cdf0e10cSrcweir         void SetHdl();
120cdf0e10cSrcweir         void AddMenu(PopupMenu* _pPopupMenu,const ::rtl::OUString& _sItemCommand,sal_uInt16 _nItemId,sal_Bool _bDelete,sal_Bool _bDeleteChildren);
121cdf0e10cSrcweir         sal_uInt16 FillItemCommand(::rtl::OUString& _rItemCommand,Menu* _pMenu,sal_uInt16 _nIndex) const;
122cdf0e10cSrcweir 
123cdf0e10cSrcweir 
124cdf0e10cSrcweir 		struct MenuItemHandler
125cdf0e10cSrcweir 		{
MenuItemHandlerframework::MenuManager::MenuItemHandler126cdf0e10cSrcweir 			MenuItemHandler( sal_uInt16 aItemId, MenuManager* pManager, REFERENCE< XDISPATCH >& rDispatch ) :
127cdf0e10cSrcweir 				nItemId( aItemId ), pSubMenuManager( pManager ), xMenuItemDispatch( rDispatch ) {}
128cdf0e10cSrcweir 
129cdf0e10cSrcweir 			sal_uInt16					nItemId;
130cdf0e10cSrcweir 			::rtl::OUString			aTargetFrame;
131cdf0e10cSrcweir 			::rtl::OUString			aMenuItemURL;
132cdf0e10cSrcweir 			::rtl::OUString			aFilter;
133cdf0e10cSrcweir 			::rtl::OUString			aPassword;
134cdf0e10cSrcweir 			::rtl::OUString			aTitle;
135cdf0e10cSrcweir 			MenuManager*			pSubMenuManager;
136cdf0e10cSrcweir 			REFERENCE< XDISPATCH >	xMenuItemDispatch;
137cdf0e10cSrcweir 		};
138cdf0e10cSrcweir 
139cdf0e10cSrcweir 		void			 CreatePicklistArguments(
140cdf0e10cSrcweir 							::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue >& aArgsList,
141cdf0e10cSrcweir 							const MenuItemHandler* );
142cdf0e10cSrcweir 
143cdf0e10cSrcweir 		MenuItemHandler* GetMenuItemHandler( sal_uInt16 nItemId );
144cdf0e10cSrcweir 
145cdf0e10cSrcweir 		sal_Bool							m_bInitialized;
146cdf0e10cSrcweir 		sal_Bool							m_bDeleteMenu;
147cdf0e10cSrcweir 		sal_Bool							m_bDeleteChildren;
148cdf0e10cSrcweir 		sal_Bool							m_bActive;
149cdf0e10cSrcweir 		sal_Bool							m_bIsBookmarkMenu;
150cdf0e10cSrcweir 		sal_Bool							m_bWasHiContrast;
151cdf0e10cSrcweir 		sal_Bool							m_bShowMenuImages;
152cdf0e10cSrcweir 		::rtl::OUString						m_aMenuItemCommand;
153cdf0e10cSrcweir 		Menu*								m_pVCLMenu;
154cdf0e10cSrcweir 		REFERENCE< XFRAME >					m_xFrame;
155cdf0e10cSrcweir 		::std::vector< MenuItemHandler* >	m_aMenuItemHandlerVector;
156cdf0e10cSrcweir 
157cdf0e10cSrcweir 		// #110897#
158cdf0e10cSrcweir 		const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& mxServiceFactory;
159cdf0e10cSrcweir         ::com::sun::star::uno::Reference< ::com::sun::star::util::XURLTransformer >             m_xURLTransformer;
160cdf0e10cSrcweir };
161cdf0e10cSrcweir 
162cdf0e10cSrcweir } // namespace
163cdf0e10cSrcweir 
164cdf0e10cSrcweir #endif
165