1*3334a7e6SAndrew Rist /**************************************************************
2cdf0e10cSrcweir  *
3*3334a7e6SAndrew Rist  * Licensed to the Apache Software Foundation (ASF) under one
4*3334a7e6SAndrew Rist  * or more contributor license agreements.  See the NOTICE file
5*3334a7e6SAndrew Rist  * distributed with this work for additional information
6*3334a7e6SAndrew Rist  * regarding copyright ownership.  The ASF licenses this file
7*3334a7e6SAndrew Rist  * to you under the Apache License, Version 2.0 (the
8*3334a7e6SAndrew Rist  * "License"); you may not use this file except in compliance
9*3334a7e6SAndrew Rist  * with the License.  You may obtain a copy of the License at
10*3334a7e6SAndrew Rist  *
11*3334a7e6SAndrew Rist  *   http://www.apache.org/licenses/LICENSE-2.0
12*3334a7e6SAndrew Rist  *
13*3334a7e6SAndrew Rist  * Unless required by applicable law or agreed to in writing,
14*3334a7e6SAndrew Rist  * software distributed under the License is distributed on an
15*3334a7e6SAndrew Rist  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16*3334a7e6SAndrew Rist  * KIND, either express or implied.  See the License for the
17*3334a7e6SAndrew Rist  * specific language governing permissions and limitations
18*3334a7e6SAndrew Rist  * under the License.
19*3334a7e6SAndrew Rist  *
20*3334a7e6SAndrew Rist  *************************************************************/
21*3334a7e6SAndrew Rist 
22*3334a7e6SAndrew Rist 
23cdf0e10cSrcweir 
24cdf0e10cSrcweir #ifndef SVX_FORMDISPATCHINTERCEPTOR_HXX
25cdf0e10cSrcweir #define SVX_FORMDISPATCHINTERCEPTOR_HXX
26cdf0e10cSrcweir 
27cdf0e10cSrcweir /** === begin UNO includes === **/
28cdf0e10cSrcweir #include <com/sun/star/frame/XDispatchProviderInterceptor.hpp>
29cdf0e10cSrcweir #include <com/sun/star/frame/XDispatchProviderInterception.hpp>
30cdf0e10cSrcweir /** === end UNO includes === **/
31cdf0e10cSrcweir 
32cdf0e10cSrcweir #include <cppuhelper/compbase2.hxx>
33cdf0e10cSrcweir #include <comphelper/uno3.hxx>
34cdf0e10cSrcweir 
35cdf0e10cSrcweir //........................................................................
36cdf0e10cSrcweir namespace svxform
37cdf0e10cSrcweir {
38cdf0e10cSrcweir //........................................................................
39cdf0e10cSrcweir 
40cdf0e10cSrcweir 	//====================================================================
41cdf0e10cSrcweir 	//= DispatchInterceptor
42cdf0e10cSrcweir 	//====================================================================
43cdf0e10cSrcweir     class DispatchInterceptor
44cdf0e10cSrcweir     {
45cdf0e10cSrcweir     public:
DispatchInterceptor()46cdf0e10cSrcweir         DispatchInterceptor() { }
47cdf0e10cSrcweir 
48cdf0e10cSrcweir         virtual ::com::sun::star::uno::Reference< ::com::sun::star::frame::XDispatch> interceptedQueryDispatch(
49cdf0e10cSrcweir             const ::com::sun::star::util::URL& aURL, const ::rtl::OUString& aTargetFrameName, sal_Int32 nSearchFlags) throw( ::com::sun::star::uno::RuntimeException ) = 0;
50cdf0e10cSrcweir 
51cdf0e10cSrcweir         virtual ::osl::Mutex* getInterceptorMutex() = 0;
52cdf0e10cSrcweir     };
53cdf0e10cSrcweir 
54cdf0e10cSrcweir 	//====================================================================
55cdf0e10cSrcweir 	//=
56cdf0e10cSrcweir 	//====================================================================
57cdf0e10cSrcweir     typedef ::cppu::WeakComponentImplHelper2<	::com::sun::star::frame::XDispatchProviderInterceptor
58cdf0e10cSrcweir                                             ,	::com::sun::star::lang::XEventListener
59cdf0e10cSrcweir                                             >	DispatchInterceptionMultiplexer_BASE;
60cdf0e10cSrcweir 
61cdf0e10cSrcweir     class DispatchInterceptionMultiplexer : public DispatchInterceptionMultiplexer_BASE
62cdf0e10cSrcweir     {
63cdf0e10cSrcweir         ::osl::Mutex	m_aFallback;
64cdf0e10cSrcweir         ::osl::Mutex*   m_pMutex;
65cdf0e10cSrcweir 
66cdf0e10cSrcweir         // the component which's dispatches we're intercepting
67cdf0e10cSrcweir         ::com::sun::star::uno::WeakReference< ::com::sun::star::frame::XDispatchProviderInterception >
68cdf0e10cSrcweir                         m_xIntercepted;
69cdf0e10cSrcweir         sal_Bool		m_bListening;
70cdf0e10cSrcweir 
71cdf0e10cSrcweir         // the real interceptor
72cdf0e10cSrcweir         DispatchInterceptor*			m_pMaster;
73cdf0e10cSrcweir 
74cdf0e10cSrcweir         // chaining
75cdf0e10cSrcweir         ::com::sun::star::uno::Reference< ::com::sun::star::frame::XDispatchProvider>			m_xSlaveDispatcher;
76cdf0e10cSrcweir         ::com::sun::star::uno::Reference< ::com::sun::star::frame::XDispatchProvider>			m_xMasterDispatcher;
77cdf0e10cSrcweir 
78cdf0e10cSrcweir         virtual ~DispatchInterceptionMultiplexer();
79cdf0e10cSrcweir 
80cdf0e10cSrcweir     public:
getIntercepted() const81cdf0e10cSrcweir         ::com::sun::star::uno::Reference< ::com::sun::star::frame::XDispatchProviderInterception> getIntercepted() const { return m_xIntercepted; }
82cdf0e10cSrcweir 
83cdf0e10cSrcweir     public:
84cdf0e10cSrcweir         DispatchInterceptionMultiplexer(
85cdf0e10cSrcweir             const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XDispatchProviderInterception>& _rToIntercept,
86cdf0e10cSrcweir             DispatchInterceptor* _pMaster
87cdf0e10cSrcweir         );
88cdf0e10cSrcweir 
89cdf0e10cSrcweir         // UNO
90cdf0e10cSrcweir         DECLARE_UNO3_DEFAULTS(DispatchInterceptionMultiplexer, DispatchInterceptionMultiplexer_BASE);
91cdf0e10cSrcweir 
92cdf0e10cSrcweir         // ::com::sun::star::frame::XDispatchProvider
93cdf0e10cSrcweir         virtual ::com::sun::star::uno::Reference< ::com::sun::star::frame::XDispatch > SAL_CALL queryDispatch( const ::com::sun::star::util::URL& aURL, const ::rtl::OUString& aTargetFrameName, sal_Int32 nSearchFlags ) throw(::com::sun::star::uno::RuntimeException);
94cdf0e10cSrcweir         virtual ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Reference< ::com::sun::star::frame::XDispatch > > SAL_CALL queryDispatches( const ::com::sun::star::uno::Sequence< ::com::sun::star::frame::DispatchDescriptor >& aDescripts ) throw(::com::sun::star::uno::RuntimeException);
95cdf0e10cSrcweir 
96cdf0e10cSrcweir         // ::com::sun::star::frame::XDispatchProviderInterceptor
97cdf0e10cSrcweir         virtual ::com::sun::star::uno::Reference< ::com::sun::star::frame::XDispatchProvider > SAL_CALL getSlaveDispatchProvider(  ) throw(::com::sun::star::uno::RuntimeException);
98cdf0e10cSrcweir         virtual void SAL_CALL setSlaveDispatchProvider( const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XDispatchProvider >& xNewDispatchProvider ) throw(::com::sun::star::uno::RuntimeException);
99cdf0e10cSrcweir         virtual ::com::sun::star::uno::Reference< ::com::sun::star::frame::XDispatchProvider > SAL_CALL getMasterDispatchProvider(	) throw(::com::sun::star::uno::RuntimeException);
100cdf0e10cSrcweir         virtual void SAL_CALL setMasterDispatchProvider( const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XDispatchProvider >& xNewSupplier ) throw(::com::sun::star::uno::RuntimeException);
101cdf0e10cSrcweir 
102cdf0e10cSrcweir         // ::com::sun::star::lang::XEventListener
103cdf0e10cSrcweir         virtual void SAL_CALL disposing( const ::com::sun::star::lang::EventObject& Source ) throw(::com::sun::star::uno::RuntimeException);
104cdf0e10cSrcweir 
105cdf0e10cSrcweir         // OComponentHelper
106cdf0e10cSrcweir         virtual void SAL_CALL disposing();
107cdf0e10cSrcweir 
108cdf0e10cSrcweir     protected:
109cdf0e10cSrcweir         void ImplDetach();
110cdf0e10cSrcweir     };
111cdf0e10cSrcweir 
112cdf0e10cSrcweir //........................................................................
113cdf0e10cSrcweir } // namespace svxform
114cdf0e10cSrcweir //........................................................................
115cdf0e10cSrcweir 
116cdf0e10cSrcweir #endif // SVX_FORMDISPATCHINTERCEPTOR_HXX
117