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 DBA_INTERCEPT_HXX
29 #define DBA_INTERCEPT_HXX
30 
31 #ifndef _OSL_MUTEX_HXX_
32 #include <osl/mutex.hxx>
33 #endif
34 #ifndef _CPPUHELPER_IMPLBASE4_HXX_
35 #include <cppuhelper/implbase4.hxx>
36 #endif
37 #ifndef _CPPUHELPER_INTERFACECONTAINER_HXX_
38 #include <cppuhelper/interfacecontainer.hxx>
39 #endif
40 #ifndef  _COM_SUN_STAR_FRAME_XDISPATCHPROVIDERINTERCEPTOR_HPP_
41 #include <com/sun/star/frame/XDispatchProviderInterceptor.hpp>
42 #endif
43 #ifndef _COM_SUN_STAR_FRAME_XINTERCEPTORINFO_HPP_
44 #include <com/sun/star/frame/XInterceptorInfo.hpp>
45 #endif
46 #ifndef _COM_SUN_STAR_DOCUMENT_XEVENTLISTENER_HPP_
47 #include <com/sun/star/document/XEventListener.hpp>
48 #endif
49 #ifndef _COM_SUN_STAR_FRAME_XDISPATCH_HPP_
50 #include <com/sun/star/frame/XDispatch.hpp>
51 #endif
52 #ifndef _DBA_COREDATAACCESS_DOCUMENTDEFINITION_HXX_
53 #include "documentdefinition.hxx"
54 #endif
55 #include <vcl/svapp.hxx>
56 
57 namespace dbaccess
58 {
59 
60 
61 class OInterceptor : public ::cppu::WeakImplHelper4< ::com::sun::star::frame::XDispatchProviderInterceptor,
62 				   									::com::sun::star::frame::XInterceptorInfo,
63 				   									::com::sun::star::frame::XDispatch,
64 													::com::sun::star::document::XEventListener>
65 {
66     DECL_LINK( OnDispatch, void* _aURL  );
67 protected:
68 	virtual ~OInterceptor();
69 public:
70 
71 	OInterceptor( ODocumentDefinition* _pContentHolder,sal_Bool _bAllowEditDoc );
72 
73 	void SAL_CALL dispose() throw(::com::sun::star::uno::RuntimeException);
74 
75 	//XDispatch
76 	virtual void SAL_CALL
77 	dispatch(
78 		const ::com::sun::star::util::URL& URL,
79 		const ::com::sun::star::uno::Sequence<
80 		::com::sun::star::beans::PropertyValue >& Arguments )
81 		throw (::com::sun::star::uno::RuntimeException);
82 
83     virtual void SAL_CALL
84 	addStatusListener(
85 		const ::com::sun::star::uno::Reference<
86 		::com::sun::star::frame::XStatusListener >& Control,
87 		const ::com::sun::star::util::URL& URL )
88 		throw (
89 			::com::sun::star::uno::RuntimeException
90 		);
91 
92     virtual void SAL_CALL
93 	removeStatusListener(
94 		const ::com::sun::star::uno::Reference<
95 		::com::sun::star::frame::XStatusListener >& Control,
96 		const ::com::sun::star::util::URL& URL )
97 		throw (
98 			::com::sun::star::uno::RuntimeException
99 		);
100 
101 	//XInterceptorInfo
102 	virtual ::com::sun::star::uno::Sequence< ::rtl::OUString >
103 	SAL_CALL getInterceptedURLs(  )
104 		throw (
105 			::com::sun::star::uno::RuntimeException
106 		);
107 
108 	//XDispatchProvider ( inherited by XDispatchProviderInterceptor )
109     virtual ::com::sun::star::uno::Reference<
110 	::com::sun::star::frame::XDispatch > SAL_CALL
111 	queryDispatch(
112 		const ::com::sun::star::util::URL& URL,
113 		const ::rtl::OUString& TargetFrameName,
114 		sal_Int32 SearchFlags )
115 		throw (
116 			::com::sun::star::uno::RuntimeException
117 		);
118 
119     virtual ::com::sun::star::uno::Sequence<
120 	::com::sun::star::uno::Reference<
121 	::com::sun::star::frame::XDispatch > > SAL_CALL
122 	queryDispatches(
123 		const ::com::sun::star::uno::Sequence<
124 		::com::sun::star::frame::DispatchDescriptor >& Requests )
125 		throw (
126 			::com::sun::star::uno::RuntimeException
127 		);
128 
129 
130 	//XDispatchProviderInterceptor
131     virtual ::com::sun::star::uno::Reference<
132 	::com::sun::star::frame::XDispatchProvider > SAL_CALL
133 	getSlaveDispatchProvider(  )
134 		throw (
135 			::com::sun::star::uno::RuntimeException
136 		);
137 
138     virtual void SAL_CALL
139 	setSlaveDispatchProvider(
140 		const ::com::sun::star::uno::Reference<
141 		::com::sun::star::frame::XDispatchProvider >& NewDispatchProvider )
142 		throw (
143 			::com::sun::star::uno::RuntimeException
144 		);
145 
146     virtual ::com::sun::star::uno::Reference<
147 	::com::sun::star::frame::XDispatchProvider > SAL_CALL
148 	getMasterDispatchProvider(  )
149 		throw (
150 			::com::sun::star::uno::RuntimeException
151 		);
152 
153     virtual void SAL_CALL
154 	setMasterDispatchProvider(
155 		const ::com::sun::star::uno::Reference<
156 		::com::sun::star::frame::XDispatchProvider >& NewSupplier )
157 		throw (
158 			::com::sun::star::uno::RuntimeException
159 		);
160 
161 	// XEventListener
162 	virtual void SAL_CALL notifyEvent( const ::com::sun::star::document::EventObject& Event ) throw (::com::sun::star::uno::RuntimeException);
163 	virtual void SAL_CALL disposing( const ::com::sun::star::lang::EventObject& Source ) throw (::com::sun::star::uno::RuntimeException);
164 
165 
166 private:
167 
168 	osl::Mutex   m_aMutex;
169 
170 	ODocumentDefinition*   m_pContentHolder;
171 
172 	::com::sun::star::uno::Reference< ::com::sun::star::frame::XDispatchProvider > m_xSlaveDispatchProvider;
173 	::com::sun::star::uno::Reference< ::com::sun::star::frame::XDispatchProvider > m_xMasterDispatchProvider;
174 
175 	::com::sun::star::uno::Sequence< ::rtl::OUString > m_aInterceptedURL;
176 
177 	cppu::OInterfaceContainerHelper*    m_pDisposeEventListeners;
178 	PropertyChangeListenerContainer*    m_pStatCL;
179 	sal_Bool							m_bAllowEditDoc;
180 };
181 
182 
183 //........................................................................
184 }	// namespace dbaccess
185 //........................................................................
186 
187 
188 #endif //DBA_INTERCEPT_HXX
189 
190 
191