1*cdf0e10cSrcweir /*************************************************************************
2*cdf0e10cSrcweir  *
3*cdf0e10cSrcweir  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4*cdf0e10cSrcweir  *
5*cdf0e10cSrcweir  * Copyright 2000, 2010 Oracle and/or its affiliates.
6*cdf0e10cSrcweir  *
7*cdf0e10cSrcweir  * OpenOffice.org - a multi-platform office productivity suite
8*cdf0e10cSrcweir  *
9*cdf0e10cSrcweir  * This file is part of OpenOffice.org.
10*cdf0e10cSrcweir  *
11*cdf0e10cSrcweir  * OpenOffice.org is free software: you can redistribute it and/or modify
12*cdf0e10cSrcweir  * it under the terms of the GNU Lesser General Public License version 3
13*cdf0e10cSrcweir  * only, as published by the Free Software Foundation.
14*cdf0e10cSrcweir  *
15*cdf0e10cSrcweir  * OpenOffice.org is distributed in the hope that it will be useful,
16*cdf0e10cSrcweir  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17*cdf0e10cSrcweir  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18*cdf0e10cSrcweir  * GNU Lesser General Public License version 3 for more details
19*cdf0e10cSrcweir  * (a copy is included in the LICENSE file that accompanied this code).
20*cdf0e10cSrcweir  *
21*cdf0e10cSrcweir  * You should have received a copy of the GNU Lesser General Public License
22*cdf0e10cSrcweir  * version 3 along with OpenOffice.org.  If not, see
23*cdf0e10cSrcweir  * <http://www.openoffice.org/license.html>
24*cdf0e10cSrcweir  * for a copy of the LGPLv3 License.
25*cdf0e10cSrcweir  *
26*cdf0e10cSrcweir  ************************************************************************/
27*cdf0e10cSrcweir 
28*cdf0e10cSrcweir #ifndef __FRAMEWORK_CLASSES_MENUMANAGER_HXX_
29*cdf0e10cSrcweir #define __FRAMEWORK_CLASSES_MENUMANAGER_HXX_
30*cdf0e10cSrcweir 
31*cdf0e10cSrcweir /** Attention: stl headers must(!) be included at first. Otherwhise it can make trouble
32*cdf0e10cSrcweir                with solaris headers ...
33*cdf0e10cSrcweir */
34*cdf0e10cSrcweir #include <vector>
35*cdf0e10cSrcweir 
36*cdf0e10cSrcweir //_________________________________________________________________________________________________________________
37*cdf0e10cSrcweir //	interface includes
38*cdf0e10cSrcweir //_________________________________________________________________________________________________________________
39*cdf0e10cSrcweir #include <com/sun/star/frame/XFrame.hpp>
40*cdf0e10cSrcweir #include <com/sun/star/frame/XDispatch.hpp>
41*cdf0e10cSrcweir #include <com/sun/star/frame/FeatureStateEvent.hpp>
42*cdf0e10cSrcweir #include <com/sun/star/beans/PropertyValue.hpp>
43*cdf0e10cSrcweir #include <com/sun/star/util/XURLTransformer.hpp>
44*cdf0e10cSrcweir 
45*cdf0e10cSrcweir //_________________________________________________________________________________________________________________
46*cdf0e10cSrcweir //	other includes
47*cdf0e10cSrcweir //_________________________________________________________________________________________________________________
48*cdf0e10cSrcweir #include <rtl/ustring.hxx>
49*cdf0e10cSrcweir #include <vcl/menu.hxx>
50*cdf0e10cSrcweir #include <vcl/accel.hxx>
51*cdf0e10cSrcweir #include <cppuhelper/implbase1.hxx>
52*cdf0e10cSrcweir #include <threadhelp/threadhelpbase.hxx>
53*cdf0e10cSrcweir #include <macros/debug.hxx>
54*cdf0e10cSrcweir 
55*cdf0e10cSrcweir // #110897#
56*cdf0e10cSrcweir #include <com/sun/star/lang/XMultiServiceFactory.hpp>
57*cdf0e10cSrcweir 
58*cdf0e10cSrcweir #define	REFERENCE										::com::sun::star::uno::Reference
59*cdf0e10cSrcweir #define	XFRAME											::com::sun::star::frame::XFrame
60*cdf0e10cSrcweir #define XDISPATCH										::com::sun::star::frame::XDispatch
61*cdf0e10cSrcweir #define XDISPATCHPROVIDER								::com::sun::star::frame::XDispatchProvider
62*cdf0e10cSrcweir #define XSTATUSLISTENER									::com::sun::star::frame::XStatusListener
63*cdf0e10cSrcweir #define XEVENTLISTENER									::com::sun::star::lang::XEventListener
64*cdf0e10cSrcweir #define FEATURSTATEEVENT								::com::sun::star::frame::FeatureStateEvent
65*cdf0e10cSrcweir #define RUNTIMEEXCEPTION								::com::sun::star::uno::RuntimeException
66*cdf0e10cSrcweir #define EVENTOBJECT										::com::sun::star::lang::EventObject
67*cdf0e10cSrcweir 
68*cdf0e10cSrcweir namespace framework
69*cdf0e10cSrcweir {
70*cdf0e10cSrcweir 
71*cdf0e10cSrcweir class BmkMenu;
72*cdf0e10cSrcweir class AddonMenu;
73*cdf0e10cSrcweir class AddonPopupMenu;
74*cdf0e10cSrcweir class MenuManager : public ThreadHelpBase			,
75*cdf0e10cSrcweir 					public ::cppu::WeakImplHelper1< ::com::sun::star::frame::XStatusListener >
76*cdf0e10cSrcweir {
77*cdf0e10cSrcweir 	public:
78*cdf0e10cSrcweir 		// #110897#
79*cdf0e10cSrcweir 		MenuManager(
80*cdf0e10cSrcweir 			const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& xServiceFactory,
81*cdf0e10cSrcweir 			REFERENCE< XFRAME >& rFrame,
82*cdf0e10cSrcweir 			Menu* pMenu,
83*cdf0e10cSrcweir 			sal_Bool bDelete,
84*cdf0e10cSrcweir 			sal_Bool bDeleteChildren );
85*cdf0e10cSrcweir #if 0
86*cdf0e10cSrcweir 		MenuManager(
87*cdf0e10cSrcweir 			const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& xServiceFactory,
88*cdf0e10cSrcweir 			REFERENCE< XFRAME >& rFrame,
89*cdf0e10cSrcweir 			AddonMenu*			pAddonMenu,
90*cdf0e10cSrcweir 			sal_Bool			bDelete,
91*cdf0e10cSrcweir 			sal_Bool			bDeleteChildren );
92*cdf0e10cSrcweir #endif
93*cdf0e10cSrcweir 
94*cdf0e10cSrcweir 		virtual ~MenuManager();
95*cdf0e10cSrcweir 
96*cdf0e10cSrcweir 		// XStatusListener
97*cdf0e10cSrcweir 		virtual void SAL_CALL statusChanged( const FEATURSTATEEVENT& Event ) throw ( RUNTIMEEXCEPTION );
98*cdf0e10cSrcweir 
99*cdf0e10cSrcweir 		// XEventListener
100*cdf0e10cSrcweir 		virtual void SAL_CALL disposing( const EVENTOBJECT& Source ) throw ( RUNTIMEEXCEPTION );
101*cdf0e10cSrcweir 
102*cdf0e10cSrcweir 		DECL_LINK( Select, Menu * );
103*cdf0e10cSrcweir 
104*cdf0e10cSrcweir 		Menu*	GetMenu() const { return m_pVCLMenu; }
105*cdf0e10cSrcweir 
106*cdf0e10cSrcweir 		void	RemoveListener();
107*cdf0e10cSrcweir 
108*cdf0e10cSrcweir 		// #110897#
109*cdf0e10cSrcweir 		const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& getServiceFactory();
110*cdf0e10cSrcweir 
111*cdf0e10cSrcweir         static void UpdateSpecialWindowMenu( Menu* pMenu ,const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& xServiceFactory,IMutex& _rMutex);
112*cdf0e10cSrcweir         static void FillMenuImages(::com::sun::star::uno::Reference< com::sun::star::frame::XFrame >& xFrame,Menu* _pMenu,sal_Bool bIsHiContrast,sal_Bool bShowMenuImages);
113*cdf0e10cSrcweir 
114*cdf0e10cSrcweir 	protected:
115*cdf0e10cSrcweir 		DECL_LINK( Highlight, Menu * );
116*cdf0e10cSrcweir 		DECL_LINK( Activate, Menu * );
117*cdf0e10cSrcweir 		DECL_LINK( Deactivate, Menu * );
118*cdf0e10cSrcweir 
119*cdf0e10cSrcweir 	private:
120*cdf0e10cSrcweir 		void UpdateSpecialFileMenu( Menu* pMenu );
121*cdf0e10cSrcweir 		void UpdateSpecialWindowMenu( Menu* pMenu );
122*cdf0e10cSrcweir         void ClearMenuDispatch(const EVENTOBJECT& Source = EVENTOBJECT(),bool _bRemoveOnly = true);
123*cdf0e10cSrcweir         void SetHdl();
124*cdf0e10cSrcweir         void AddMenu(PopupMenu* _pPopupMenu,const ::rtl::OUString& _sItemCommand,sal_uInt16 _nItemId,sal_Bool _bDelete,sal_Bool _bDeleteChildren);
125*cdf0e10cSrcweir         sal_uInt16 FillItemCommand(::rtl::OUString& _rItemCommand,Menu* _pMenu,sal_uInt16 _nIndex) const;
126*cdf0e10cSrcweir 
127*cdf0e10cSrcweir 
128*cdf0e10cSrcweir 		struct MenuItemHandler
129*cdf0e10cSrcweir 		{
130*cdf0e10cSrcweir 			MenuItemHandler( sal_uInt16 aItemId, MenuManager* pManager, REFERENCE< XDISPATCH >& rDispatch ) :
131*cdf0e10cSrcweir 				nItemId( aItemId ), pSubMenuManager( pManager ), xMenuItemDispatch( rDispatch ) {}
132*cdf0e10cSrcweir 
133*cdf0e10cSrcweir 			sal_uInt16					nItemId;
134*cdf0e10cSrcweir 			::rtl::OUString			aTargetFrame;
135*cdf0e10cSrcweir 			::rtl::OUString			aMenuItemURL;
136*cdf0e10cSrcweir 			::rtl::OUString			aFilter;
137*cdf0e10cSrcweir 			::rtl::OUString			aPassword;
138*cdf0e10cSrcweir 			::rtl::OUString			aTitle;
139*cdf0e10cSrcweir 			MenuManager*			pSubMenuManager;
140*cdf0e10cSrcweir 			REFERENCE< XDISPATCH >	xMenuItemDispatch;
141*cdf0e10cSrcweir 		};
142*cdf0e10cSrcweir 
143*cdf0e10cSrcweir 		void			 CreatePicklistArguments(
144*cdf0e10cSrcweir 							::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue >& aArgsList,
145*cdf0e10cSrcweir 							const MenuItemHandler* );
146*cdf0e10cSrcweir 
147*cdf0e10cSrcweir 		MenuItemHandler* GetMenuItemHandler( sal_uInt16 nItemId );
148*cdf0e10cSrcweir 
149*cdf0e10cSrcweir 		sal_Bool							m_bInitialized;
150*cdf0e10cSrcweir 		sal_Bool							m_bDeleteMenu;
151*cdf0e10cSrcweir 		sal_Bool							m_bDeleteChildren;
152*cdf0e10cSrcweir 		sal_Bool							m_bActive;
153*cdf0e10cSrcweir 		sal_Bool							m_bIsBookmarkMenu;
154*cdf0e10cSrcweir 		sal_Bool							m_bWasHiContrast;
155*cdf0e10cSrcweir 		sal_Bool							m_bShowMenuImages;
156*cdf0e10cSrcweir 		::rtl::OUString						m_aMenuItemCommand;
157*cdf0e10cSrcweir 		Menu*								m_pVCLMenu;
158*cdf0e10cSrcweir 		REFERENCE< XFRAME >					m_xFrame;
159*cdf0e10cSrcweir 		::std::vector< MenuItemHandler* >	m_aMenuItemHandlerVector;
160*cdf0e10cSrcweir 
161*cdf0e10cSrcweir 		// #110897#
162*cdf0e10cSrcweir 		const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& mxServiceFactory;
163*cdf0e10cSrcweir         ::com::sun::star::uno::Reference< ::com::sun::star::util::XURLTransformer >             m_xURLTransformer;
164*cdf0e10cSrcweir };
165*cdf0e10cSrcweir 
166*cdf0e10cSrcweir } // namespace
167*cdf0e10cSrcweir 
168*cdf0e10cSrcweir #endif
169