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_DISPATCH_POPUPMENUDISPATCHER_HXX_
25cdf0e10cSrcweir #define __FRAMEWORK_DISPATCH_POPUPMENUDISPATCHER_HXX_
26cdf0e10cSrcweir 
27cdf0e10cSrcweir //_________________________________________________________________________________________________________________
28cdf0e10cSrcweir //	my own includes
29cdf0e10cSrcweir //_________________________________________________________________________________________________________________
30cdf0e10cSrcweir 
31cdf0e10cSrcweir #include <services/frame.hxx>
32cdf0e10cSrcweir /*
33cdf0e10cSrcweir #include <macros/generic.hxx>
34cdf0e10cSrcweir */
35cdf0e10cSrcweir #include <macros/xinterface.hxx>
36cdf0e10cSrcweir #include <macros/xtypeprovider.hxx>
37cdf0e10cSrcweir #include <macros/xserviceinfo.hxx>
38cdf0e10cSrcweir /*
39cdf0e10cSrcweir #include <macros/debug.hxx>
40cdf0e10cSrcweir */
41cdf0e10cSrcweir #include <threadhelp/threadhelpbase.hxx>
42cdf0e10cSrcweir #include <general.h>
43cdf0e10cSrcweir #include <stdtypes.h>
44cdf0e10cSrcweir 
45cdf0e10cSrcweir //_________________________________________________________________________________________________________________
46cdf0e10cSrcweir //	interface includes
47cdf0e10cSrcweir //_________________________________________________________________________________________________________________
48cdf0e10cSrcweir #include <com/sun/star/lang/XTypeProvider.hpp>
49cdf0e10cSrcweir #include <com/sun/star/frame/XDispatch.hpp>
50cdf0e10cSrcweir #include <com/sun/star/frame/XDispatchProvider.hpp>
51cdf0e10cSrcweir #include <com/sun/star/util/URL.hpp>
52cdf0e10cSrcweir #include <com/sun/star/frame/DispatchDescriptor.hpp>
53cdf0e10cSrcweir #include <com/sun/star/beans/PropertyValue.hpp>
54cdf0e10cSrcweir #include <com/sun/star/frame/XStatusListener.hpp>
55cdf0e10cSrcweir #include <com/sun/star/frame/XFrameLoader.hpp>
56cdf0e10cSrcweir #include <com/sun/star/frame/XLoadEventListener.hpp>
57cdf0e10cSrcweir #include <com/sun/star/frame/XDesktop.hpp>
58cdf0e10cSrcweir #include <com/sun/star/frame/FeatureStateEvent.hpp>
59cdf0e10cSrcweir #include <com/sun/star/frame/XFrameActionListener.hpp>
60cdf0e10cSrcweir #include <com/sun/star/lang/XInitialization.hpp>
61cdf0e10cSrcweir #include <com/sun/star/container/XNameAccess.hpp>
62cdf0e10cSrcweir #ifndef _COM_SUN_STAR_URI_XURLREFERENCEFACTORY_HPP_
63cdf0e10cSrcweir #include <com/sun/star/uri/XUriReferenceFactory.hpp>
64cdf0e10cSrcweir #endif
65cdf0e10cSrcweir #ifndef _COM_SUN_STAR_URI_XURLREFERENCE_HPP_
66cdf0e10cSrcweir #include <com/sun/star/uri/XUriReference.hpp>
67cdf0e10cSrcweir #endif
68cdf0e10cSrcweir 
69cdf0e10cSrcweir //_________________________________________________________________________________________________________________
70cdf0e10cSrcweir //	other includes
71cdf0e10cSrcweir //_________________________________________________________________________________________________________________
72cdf0e10cSrcweir #include <cppuhelper/weak.hxx>
73cdf0e10cSrcweir #include <cppuhelper/weakref.hxx>
74cdf0e10cSrcweir #include <cppuhelper/interfacecontainer.h>
75cdf0e10cSrcweir 
76cdf0e10cSrcweir //_________________________________________________________________________________________________________________
77cdf0e10cSrcweir //	namespace
78cdf0e10cSrcweir //_________________________________________________________________________________________________________________
79cdf0e10cSrcweir 
80cdf0e10cSrcweir namespace framework{
81cdf0e10cSrcweir 
82cdf0e10cSrcweir 
83cdf0e10cSrcweir //_________________________________________________________________________________________________________________
84cdf0e10cSrcweir //	exported const
85cdf0e10cSrcweir //_________________________________________________________________________________________________________________
86cdf0e10cSrcweir 
87cdf0e10cSrcweir //_________________________________________________________________________________________________________________
88cdf0e10cSrcweir //	exported definitions
89cdf0e10cSrcweir //_________________________________________________________________________________________________________________
90cdf0e10cSrcweir 
91cdf0e10cSrcweir /*-************************************************************************************************************//**
92cdf0e10cSrcweir 	We must save informations about our listener and URL for listening.
93cdf0e10cSrcweir 	We implement this as a hashtable for strings.
94cdf0e10cSrcweir *//*-*************************************************************************************************************/
95cdf0e10cSrcweir 
96cdf0e10cSrcweir typedef ::cppu::OMultiTypeInterfaceContainerHelperVar<	::rtl::OUString			,
975758ad8cSAriel Constenla-Haile 														rtl::OUStringHash,
98cdf0e10cSrcweir 														std::equal_to< ::rtl::OUString > > IMPL_ListenerHashContainer;
99cdf0e10cSrcweir 
100cdf0e10cSrcweir 
101cdf0e10cSrcweir /*-************************************************************************************************************//**
102cdf0e10cSrcweir 	@short			helper for desktop only(!) to create new tasks on demand for dispatches
103cdf0e10cSrcweir 	@descr			Use this class as member only! Never use it as baseclass.
104*b12a77c9Smseidel 					XInterface will be ambiguous and we hold a weakcss::uno::Reference to our OWNER - not to our SUPERCLASS!
105cdf0e10cSrcweir 
106cdf0e10cSrcweir 	@implements		XInterface
107cdf0e10cSrcweir 					XDispatch
108cdf0e10cSrcweir 					XLoadEventListener
109cdf0e10cSrcweir 					XFrameActionListener
110cdf0e10cSrcweir 					XEventListener
111cdf0e10cSrcweir 	@base			ThreadHelpBase
112cdf0e10cSrcweir 					OWeakObject
113cdf0e10cSrcweir 
114cdf0e10cSrcweir 	@devstatus		ready to use
115cdf0e10cSrcweir *//*-*************************************************************************************************************/
116cdf0e10cSrcweir class PopupMenuDispatcher :   // interfaces
117cdf0e10cSrcweir 								public css::lang::XTypeProvider			,
118cdf0e10cSrcweir                                 public css::lang::XServiceInfo          ,
119cdf0e10cSrcweir                                 public css::frame::XDispatchProvider    ,
120cdf0e10cSrcweir 								public css::frame::XDispatch			,
121cdf0e10cSrcweir 								public css::frame::XFrameActionListener	,
122cdf0e10cSrcweir                                 public css::lang::XInitialization       ,
123cdf0e10cSrcweir 								// baseclasses
12407a3d7f1SPedro Giffuni 								// Order is necessary for right initialization!
125cdf0e10cSrcweir 								public ThreadHelpBase					,
126cdf0e10cSrcweir 								public cppu::OWeakObject
127cdf0e10cSrcweir {
128cdf0e10cSrcweir 	//-------------------------------------------------------------------------------------------------------------
129cdf0e10cSrcweir 	//	public methods
130cdf0e10cSrcweir 	//-------------------------------------------------------------------------------------------------------------
131cdf0e10cSrcweir 	public:
132cdf0e10cSrcweir 
133cdf0e10cSrcweir         //	constructor / destructor
134cdf0e10cSrcweir         PopupMenuDispatcher( const css::uno::Reference< css::lang::XMultiServiceFactory >& xFactory );
135cdf0e10cSrcweir 
136cdf0e10cSrcweir         // XInterface, XTypeProvider, XServiceInfo
137cdf0e10cSrcweir         FWK_DECLARE_XINTERFACE
138cdf0e10cSrcweir         FWK_DECLARE_XTYPEPROVIDER
139cdf0e10cSrcweir         DECLARE_XSERVICEINFO
140cdf0e10cSrcweir 
141cdf0e10cSrcweir         // XInitialization
142cdf0e10cSrcweir         virtual void SAL_CALL initialize( const css::uno::Sequence< css::uno::Any >& lArguments ) throw( css::uno::Exception       ,
143cdf0e10cSrcweir                                                                                                          css::uno::RuntimeException);
144cdf0e10cSrcweir         // XDispatchProvider
145cdf0e10cSrcweir         virtual ::com::sun::star::uno::Reference< ::com::sun::star::frame::XDispatch > SAL_CALL queryDispatch(
146cdf0e10cSrcweir             const ::com::sun::star::util::URL&  aURL        ,
147cdf0e10cSrcweir             const ::rtl::OUString& sTarget     ,
148cdf0e10cSrcweir             sal_Int32              nFlags      )
149cdf0e10cSrcweir         throw( ::com::sun::star::uno::RuntimeException );
150cdf0e10cSrcweir 
151cdf0e10cSrcweir         virtual css::uno::Sequence< css::uno::Reference< css::frame::XDispatch > > SAL_CALL queryDispatches(
152cdf0e10cSrcweir             const css::uno::Sequence< css::frame::DispatchDescriptor >& lDescriptor )
153cdf0e10cSrcweir         throw( css::uno::RuntimeException );
154cdf0e10cSrcweir 
155cdf0e10cSrcweir 		//	XDispatch
156cdf0e10cSrcweir 		virtual void SAL_CALL dispatch(	const css::util::URL&                                  aURL,
157cdf0e10cSrcweir 										const css::uno::Sequence< css::beans::PropertyValue >& seqProperties ) throw( css::uno::RuntimeException );
158cdf0e10cSrcweir 
159cdf0e10cSrcweir 		virtual void SAL_CALL addStatusListener( const css::uno::Reference< css::frame::XStatusListener >& xControl,
160cdf0e10cSrcweir 												 const css::util::URL&                                     aURL	) throw( css::uno::RuntimeException );
161cdf0e10cSrcweir 
162cdf0e10cSrcweir     	virtual void SAL_CALL removeStatusListener(	const css::uno::Reference< css::frame::XStatusListener >& xControl,
163cdf0e10cSrcweir 													const css::util::URL&                                     aURL	) throw( css::uno::RuntimeException );
164cdf0e10cSrcweir 
165cdf0e10cSrcweir 
166cdf0e10cSrcweir 		//	 XFrameActionListener
167cdf0e10cSrcweir 		virtual void SAL_CALL frameAction( const css::frame::FrameActionEvent& aEvent ) throw ( css::uno::RuntimeException );
168cdf0e10cSrcweir 
169cdf0e10cSrcweir 		//	 XEventListener
170cdf0e10cSrcweir         void SAL_CALL disposing( const css::lang::EventObject& aEvent ) throw( css::uno::RuntimeException );
171cdf0e10cSrcweir 
172cdf0e10cSrcweir 	//	protected methods
173cdf0e10cSrcweir 	protected:
174cdf0e10cSrcweir         virtual ~PopupMenuDispatcher();
175cdf0e10cSrcweir 
176cdf0e10cSrcweir         void impl_RetrievePopupControllerQuery();
177cdf0e10cSrcweir         void impl_CreateUriRefFactory();
178cdf0e10cSrcweir 
179cdf0e10cSrcweir 	//	private methods
180cdf0e10cSrcweir 
181cdf0e10cSrcweir 	//	variables
182cdf0e10cSrcweir 	private:
183cdf0e10cSrcweir 		css::uno::WeakReference< css::frame::XFrame >			m_xWeakFrame		;	/// css::uno::WeakReference to frame (Don't use a hard css::uno::Reference. Owner can't delete us then!)
184cdf0e10cSrcweir         css::uno::Reference< css::container::XNameAccess >      m_xPopupCtrlQuery   ;   /// reference to query for popup controller
185cdf0e10cSrcweir         css::uno::Reference< css::uri::XUriReferenceFactory >   m_xUriRefFactory    ;   /// reference to the uri reference factory
186cdf0e10cSrcweir 		css::uno::Reference< css::lang::XMultiServiceFactory >	m_xFactory			;	/// factory shared with our owner to create new services!
187cdf0e10cSrcweir 		IMPL_ListenerHashContainer								m_aListenerContainer;	/// hash table for listener at specified URLs
188cdf0e10cSrcweir 		sal_Bool												m_bAlreadyDisposed	;	/// Protection against multiple disposing calls.
189cdf0e10cSrcweir 		sal_Bool												m_bActivateListener ;	/// dispatcher is listener for frame activation
190cdf0e10cSrcweir 
191cdf0e10cSrcweir }; //  class PopupMenuDispatcher
192cdf0e10cSrcweir 
193cdf0e10cSrcweir }		//	namespace framework
194cdf0e10cSrcweir 
195cdf0e10cSrcweir #endif  //  #ifndef __FRAMEWORK_DISPATCH_POPUPMENUDISPATCHER_HXX_
196