xref: /trunk/main/embedserv/source/inc/intercept.hxx (revision cdf0e10c4e3984b49a9502b011690b615761d4a3)
1 /*************************************************************************
2  *
3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4  *
5  * Copyright 2000, 2010 Oracle and/or its affiliates.
6  *
7  * OpenOffice.org - a multi-platform office productivity suite
8  *
9  * This file is part of OpenOffice.org.
10  *
11  * OpenOffice.org is free software: you can redistribute it and/or modify
12  * it under the terms of the GNU Lesser General Public License version 3
13  * only, as published by the Free Software Foundation.
14  *
15  * OpenOffice.org is distributed in the hope that it will be useful,
16  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18  * GNU Lesser General Public License version 3 for more details
19  * (a copy is included in the LICENSE file that accompanied this code).
20  *
21  * You should have received a copy of the GNU Lesser General Public License
22  * version 3 along with OpenOffice.org.  If not, see
23  * <http://www.openoffice.org/license.html>
24  * for a copy of the LGPLv3 License.
25  *
26  ************************************************************************/
27 
28 #ifndef _INTERCEPT_HXX_
29 #define _INTERCEPT_HXX_
30 
31 #include <osl/mutex.hxx>
32 #include <cppuhelper/implbase3.hxx>
33 #include <cppuhelper/interfacecontainer.hxx>
34 #include <com/sun/star/frame/XDispatchProviderInterceptor.hpp>
35 #include <com/sun/star/frame/XInterceptorInfo.hpp>
36 #include <com/sun/star/frame/XDispatch.hpp>
37 
38 #include <rtl/ref.hxx>
39 #include "embeddocaccess.hxx"
40 
41 
42 class StatusChangeListenerContainer;
43 class EmbedDocument_Impl;
44 class DocumentHolder;
45 
46 class Interceptor
47     : public ::cppu::WeakImplHelper3<
48                    ::com::sun::star::frame::XDispatchProviderInterceptor,
49                    ::com::sun::star::frame::XInterceptorInfo,
50                    ::com::sun::star::frame::XDispatch>
51 {
52 public:
53 
54     Interceptor(
55         const ::rtl::Reference< EmbeddedDocumentInstanceAccess_Impl >& xOleAccess,
56         DocumentHolder* pDocH,
57         sal_Bool bLink );
58 
59     ~Interceptor();
60 
61     void DisconnectDocHolder();
62 
63     void generateFeatureStateEvent();
64 
65     // overwritten to release the statuslistner.
66 
67 
68     // XComponent
69     virtual void SAL_CALL
70     addEventListener(
71         const com::sun::star::uno::Reference< com::sun::star::lang::XEventListener >& xListener )
72         throw( com::sun::star::uno::RuntimeException );
73 
74     virtual void SAL_CALL
75     removeEventListener( const com::sun::star::uno::Reference< com::sun::star::lang::XEventListener >& aListener )
76         throw( com::sun::star::uno::RuntimeException );
77 
78     void SAL_CALL
79     dispose() throw(::com::sun::star::uno::RuntimeException);
80 
81 
82 
83     //XDispatch
84     virtual void SAL_CALL
85     dispatch(
86         const ::com::sun::star::util::URL& URL,
87         const ::com::sun::star::uno::Sequence<
88         ::com::sun::star::beans::PropertyValue >& Arguments )
89         throw (::com::sun::star::uno::RuntimeException);
90 
91     virtual void SAL_CALL
92     addStatusListener(
93         const ::com::sun::star::uno::Reference<
94         ::com::sun::star::frame::XStatusListener >& Control,
95         const ::com::sun::star::util::URL& URL )
96         throw (
97             ::com::sun::star::uno::RuntimeException
98         );
99 
100     virtual void SAL_CALL
101     removeStatusListener(
102         const ::com::sun::star::uno::Reference<
103         ::com::sun::star::frame::XStatusListener >& Control,
104         const ::com::sun::star::util::URL& URL )
105         throw (
106             ::com::sun::star::uno::RuntimeException
107         );
108 
109     //XInterceptorInfo
110     virtual ::com::sun::star::uno::Sequence< ::rtl::OUString >
111     SAL_CALL getInterceptedURLs(  )
112         throw (
113             ::com::sun::star::uno::RuntimeException
114         );
115 
116 
117     //XDispatchProvider ( inherited by XDispatchProviderInterceptor )
118     virtual ::com::sun::star::uno::Reference<
119     ::com::sun::star::frame::XDispatch > SAL_CALL
120     queryDispatch(
121         const ::com::sun::star::util::URL& URL,
122         const ::rtl::OUString& TargetFrameName,
123         sal_Int32 SearchFlags )
124         throw (
125             ::com::sun::star::uno::RuntimeException
126         );
127 
128     virtual ::com::sun::star::uno::Sequence<
129     ::com::sun::star::uno::Reference<
130     ::com::sun::star::frame::XDispatch > > SAL_CALL
131     queryDispatches(
132         const ::com::sun::star::uno::Sequence<
133         ::com::sun::star::frame::DispatchDescriptor >& Requests )
134         throw (
135             ::com::sun::star::uno::RuntimeException
136         );
137 
138 
139     //XDispatchProviderInterceptor
140     virtual ::com::sun::star::uno::Reference<
141     ::com::sun::star::frame::XDispatchProvider > SAL_CALL
142     getSlaveDispatchProvider(  )
143         throw (
144             ::com::sun::star::uno::RuntimeException
145         );
146 
147     virtual void SAL_CALL
148     setSlaveDispatchProvider(
149         const ::com::sun::star::uno::Reference<
150         ::com::sun::star::frame::XDispatchProvider >& NewDispatchProvider )
151         throw (
152             ::com::sun::star::uno::RuntimeException
153         );
154 
155     virtual ::com::sun::star::uno::Reference<
156     ::com::sun::star::frame::XDispatchProvider > SAL_CALL
157     getMasterDispatchProvider(  )
158         throw (
159             ::com::sun::star::uno::RuntimeException
160         );
161 
162     virtual void SAL_CALL
163     setMasterDispatchProvider(
164         const ::com::sun::star::uno::Reference<
165         ::com::sun::star::frame::XDispatchProvider >& NewSupplier )
166         throw (
167             ::com::sun::star::uno::RuntimeException
168         );
169 
170 
171 private:
172 
173     osl::Mutex   m_aMutex;
174 
175     ::rtl::Reference< EmbeddedDocumentInstanceAccess_Impl > m_xOleAccess;
176 
177     ::com::sun::star::uno::WeakReference< ::com::sun::star::uno::XInterface > m_xDocHLocker;
178     DocumentHolder*       m_pDocH;
179 
180     ::com::sun::star::uno::Reference<
181     ::com::sun::star::frame::XDispatchProvider > m_xSlaveDispatchProvider;
182 
183     ::com::sun::star::uno::Reference<
184     ::com::sun::star::frame::XDispatchProvider > m_xMasterDispatchProvider;
185 
186     static ::com::sun::star::uno::Sequence< ::rtl::OUString >
187     m_aInterceptedURL;
188 
189     cppu::OInterfaceContainerHelper*    m_pDisposeEventListeners;
190     StatusChangeListenerContainer*    m_pStatCL;
191 
192     sal_Bool m_bLink;
193 };
194 
195 #endif
196