xref: /aoo4110/main/ucb/source/ucp/file/bc.hxx (revision b1cdbd2c)
1 /**************************************************************
2  *
3  * Licensed to the Apache Software Foundation (ASF) under one
4  * or more contributor license agreements.  See the NOTICE file
5  * distributed with this work for additional information
6  * regarding copyright ownership.  The ASF licenses this file
7  * to you under the Apache License, Version 2.0 (the
8  * "License"); you may not use this file except in compliance
9  * with the License.  You may obtain a copy of the License at
10  *
11  *   http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing,
14  * software distributed under the License is distributed on an
15  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16  * KIND, either express or implied.  See the License for the
17  * specific language governing permissions and limitations
18  * under the License.
19  *
20  *************************************************************/
21 
22 
23 
24 #ifndef _BC_HXX_
25 #define _BC_HXX_
26 
27 #include "osl/mutex.hxx"
28 #include "rtl/ustring.hxx"
29 #include <cppuhelper/weak.hxx>
30 #include <ucbhelper/macros.hxx>
31 #include <cppuhelper/interfacecontainer.h>
32 #include <com/sun/star/uno/XInterface.hpp>
33 #include <com/sun/star/lang/XTypeProvider.hpp>
34 #include <com/sun/star/lang/XComponent.hpp>
35 #include <com/sun/star/ucb/XCommandProcessor.hpp>
36 #include <com/sun/star/beans/XPropertiesChangeNotifier.hpp>
37 #include <com/sun/star/ucb/XContent.hpp>
38 #include <com/sun/star/ucb/XContentProvider.hpp>
39 #ifndef _COM_SUN_STAR_UCB_XRESULTSET_HPP_
40 #include <com/sun/star/ucb/XDynamicResultSet.hpp>
41 #endif
42 #include <com/sun/star/lang/XServiceInfo.hpp>
43 #include <com/sun/star/sdbc/XRow.hpp>
44 #include <com/sun/star/beans/PropertyChangeEvent.hpp>
45 #include <com/sun/star/beans/Property.hpp>
46 #include <com/sun/star/beans/PropertyValue.hpp>
47 #include <com/sun/star/ucb/XCommandInfo.hpp>
48 #include <com/sun/star/ucb/InsertCommandArgument.hpp>
49 #include <com/sun/star/beans/XPropertySetInfo.hpp>
50 #include <com/sun/star/beans/XPropertyContainer.hpp>
51 #include <com/sun/star/beans/XPropertySetInfoChangeNotifier.hpp>
52 #include <com/sun/star/beans/XPropertySetInfoChangeListener.hpp>
53 #include <com/sun/star/container/XChild.hpp>
54 #include <com/sun/star/ucb/XContentCreator.hpp>
55 #include <com/sun/star/io/XInputStream.hpp>
56 #include <com/sun/star/ucb/OpenCommandArgument2.hpp>
57 #include <com/sun/star/ucb/InteractiveBadTransferURLException.hpp>
58 #ifndef _COM_SUN_STAR_UCB_SHELL_HXX_
59 #include "shell.hxx"
60 #endif
61 
62 
63 namespace fileaccess {
64 
65 	class PropertyListeners;
66 	class shell;
67 	class FileProvider;
68 
69 	class BaseContent:
70 		public cppu::OWeakObject,
71 		public com::sun::star::lang::XComponent,
72 		public com::sun::star::lang::XServiceInfo,
73 		public com::sun::star::lang::XTypeProvider,
74 		public com::sun::star::ucb::XCommandProcessor,
75 		public com::sun::star::beans::XPropertiesChangeNotifier,
76 		public com::sun::star::beans::XPropertyContainer,
77 		public com::sun::star::beans::XPropertySetInfoChangeNotifier,
78 		public com::sun::star::ucb::XContentCreator,
79 		public com::sun::star::container::XChild,
80 		public com::sun::star::ucb::XContent,
81 		public fileaccess::Notifier    // implementation class
82 	{
83 	private:
84 
85 		// A special creator for inserted contents; Creates an ugly object
86 		BaseContent( shell* pMyShell,
87 					 const rtl::OUString& parentName,
88 					 sal_Bool bFolder );
89 
90 	public:
91 		BaseContent(
92 			shell* pMyShell,
93 			const com::sun::star::uno::Reference< com::sun::star::ucb::XContentIdentifier >& xContentIdentifier,
94 			const rtl::OUString& aUnqPath );
95 
96 		virtual ~BaseContent();
97 
98 		// XInterface
99 		virtual com::sun::star::uno::Any SAL_CALL
100 		queryInterface(
101 			const com::sun::star::uno::Type& aType )
102 			throw( com::sun::star::uno::RuntimeException);
103 
104 		virtual void SAL_CALL
105 		acquire(
106 			void )
107 			throw();
108 
109 		virtual void SAL_CALL
110 		release(
111 			void )
112 			throw();
113 
114 
115 		// XComponent
116 		virtual void SAL_CALL
117 		dispose(
118 			void )
119 			throw( com::sun::star::uno::RuntimeException );
120 
121 		virtual void SAL_CALL
122 		addEventListener(
123 			const com::sun::star::uno::Reference< com::sun::star::lang::XEventListener >& xListener )
124 			throw( com::sun::star::uno::RuntimeException );
125 
126 		virtual void SAL_CALL
127 		removeEventListener( const com::sun::star::uno::Reference< com::sun::star::lang::XEventListener >& aListener )
128 			throw( com::sun::star::uno::RuntimeException );
129 
130 
131 		// XTypeProvider
132 
133 		XTYPEPROVIDER_DECL()
134 
135 
136 		// XServiceInfo
137 		virtual rtl::OUString SAL_CALL
138 		getImplementationName()
139 			throw( com::sun::star::uno::RuntimeException);
140 
141 		virtual sal_Bool SAL_CALL
142 		supportsService( const rtl::OUString& ServiceName )
143 			throw( com::sun::star::uno::RuntimeException);
144 
145 		virtual com::sun::star::uno::Sequence< rtl::OUString > SAL_CALL
146 		getSupportedServiceNames()
147 			throw( com::sun::star::uno::RuntimeException );
148 
149 
150 		// XCommandProcessor
151 		virtual sal_Int32 SAL_CALL
152 		createCommandIdentifier(
153 			void )
154 			throw( com::sun::star::uno::RuntimeException );
155 
156 		virtual com::sun::star::uno::Any SAL_CALL
157 		execute(
158 			const com::sun::star::ucb::Command& aCommand,
159 			sal_Int32 CommandId,
160 			const com::sun::star::uno::Reference< com::sun::star::ucb::XCommandEnvironment >& Environment )
161 			throw( com::sun::star::uno::Exception,
162 				   com::sun::star::ucb::CommandAbortedException,
163 				   com::sun::star::uno::RuntimeException );
164 
165 		virtual void SAL_CALL
166 		abort(
167 			sal_Int32 CommandId )
168 			throw( com::sun::star::uno::RuntimeException );
169 
170 
171 		// XContent
172 		virtual com::sun::star::uno::Reference< com::sun::star::ucb::XContentIdentifier > SAL_CALL
173 		getIdentifier(
174 			void )
175 			throw( com::sun::star::uno::RuntimeException );
176 
177 		virtual rtl::OUString SAL_CALL
178 		getContentType(
179 			void )
180 			throw( com::sun::star::uno::RuntimeException );
181 
182 		virtual void SAL_CALL
183 		addContentEventListener(
184 			const com::sun::star::uno::Reference< com::sun::star::ucb::XContentEventListener >& Listener )
185 			throw( com::sun::star::uno::RuntimeException );
186 
187 		virtual void SAL_CALL
188 		removeContentEventListener(
189 			const com::sun::star::uno::Reference< com::sun::star::ucb::XContentEventListener >& Listener )
190 			throw( com::sun::star::uno::RuntimeException );
191 
192 		// XPropertiesChangeNotifier
193 
194 		virtual void SAL_CALL
195 		addPropertiesChangeListener(
196 			const com::sun::star::uno::Sequence< rtl::OUString >& PropertyNames,
197 			const com::sun::star::uno::Reference<
198 			com::sun::star::beans::XPropertiesChangeListener >& Listener )
199 			throw( com::sun::star::uno::RuntimeException );
200 
201 		virtual void SAL_CALL
202 		removePropertiesChangeListener( const com::sun::star::uno::Sequence< rtl::OUString >& PropertyNames,
203 										const com::sun::star::uno::Reference<
204 										com::sun::star::beans::XPropertiesChangeListener >& Listener )
205 			throw( com::sun::star::uno::RuntimeException );
206 
207 		// XPropertyContainer
208 
209 		virtual void SAL_CALL
210 		addProperty(
211 			const rtl::OUString& Name,
212 			sal_Int16 Attributes,
213 			const com::sun::star::uno::Any& DefaultValue )
214 			throw( com::sun::star::beans::PropertyExistException,
215 				   com::sun::star::beans::IllegalTypeException,
216 				   com::sun::star::lang::IllegalArgumentException,
217 				   com::sun::star::uno::RuntimeException);
218 
219 		virtual void SAL_CALL
220 		removeProperty(
221 			const rtl::OUString& Name )
222 			throw( com::sun::star::beans::UnknownPropertyException,
223 				   com::sun::star::beans::NotRemoveableException,
224 				   com::sun::star::uno::RuntimeException );
225 
226 		// XPropertySetInfoChangeNotifier
227 
228 		virtual void SAL_CALL
229 		addPropertySetInfoChangeListener(
230 			const com::sun::star::uno::Reference<
231 			com::sun::star::beans::XPropertySetInfoChangeListener >& Listener )
232 			throw( com::sun::star::uno::RuntimeException );
233 
234 		virtual void SAL_CALL
235 		removePropertySetInfoChangeListener(
236 			const com::sun::star::uno::Reference<
237 			com::sun::star::beans::XPropertySetInfoChangeListener >& Listener )
238 			throw( com::sun::star::uno::RuntimeException );
239 
240 
241 		// XContentCreator
242 
243 		virtual com::sun::star::uno::Sequence< com::sun::star::ucb::ContentInfo > SAL_CALL
244 		queryCreatableContentsInfo(
245 			void )
246 			throw( com::sun::star::uno::RuntimeException );
247 
248 		virtual com::sun::star::uno::Reference< com::sun::star::ucb::XContent > SAL_CALL
249 		createNewContent(
250 			const com::sun::star::ucb::ContentInfo& Info )
251 			throw( com::sun::star::uno::RuntimeException );
252 
253 
254 		// XChild
255 		virtual com::sun::star::uno::Reference< com::sun::star::uno::XInterface > SAL_CALL
256 		getParent(
257 			void ) throw( com::sun::star::uno::RuntimeException );
258 
259 		// Not supported
260 		virtual void SAL_CALL
261 		setParent( const com::sun::star::uno::Reference< com::sun::star::uno::XInterface >& Parent )
262 			throw( com::sun::star::lang::NoSupportException,
263 				   com::sun::star::uno::RuntimeException);
264 
265 
266 		// Notifier
267 
268 		ContentEventNotifier*          cDEL( void );
269 		ContentEventNotifier*          cEXC( const rtl::OUString aNewName );
270 		ContentEventNotifier*          cCEL( void );
271 		PropertySetInfoChangeNotifier* cPSL( void );
272 		PropertyChangeNotifier*        cPCL( void );
273 		rtl::OUString                  getKey( void );
274 
275 	private:
276 		// Data members
277 		shell*                                                                      m_pMyShell;
278 		com::sun::star::uno::Reference< com::sun::star::ucb::XContentIdentifier >   m_xContentIdentifier;
279 		rtl::OUString                                                               m_aUncPath;
280 
281 		enum state { NameForInsertionSet = 1,
282 					 JustInserted = 2,
283 					 Deleted = 4,
284 					 FullFeatured = 8,
285 					 Connected = 16 };
286 		sal_Bool 																	m_bFolder;
287 		sal_uInt16                                                                  m_nState;
288 
289 		osl::Mutex                         m_aMutex;
290 
291 		osl::Mutex                          m_aEventListenerMutex;
292 		cppu::OInterfaceContainerHelper*    m_pDisposeEventListeners;
293 		cppu::OInterfaceContainerHelper*    m_pContentEventListeners;
294 		cppu::OInterfaceContainerHelper*    m_pPropertySetInfoChangeListeners;
295 		PropertyListeners*                  m_pPropertyListener;
296 
297 
298 		// Private Methods
299 		com::sun::star::uno::Reference< com::sun::star::ucb::XCommandInfo > SAL_CALL
300 		getCommandInfo()
301 			throw( com::sun::star::uno::RuntimeException );
302 
303 		virtual com::sun::star::uno::Reference< com::sun::star::beans::XPropertySetInfo > SAL_CALL
304 		getPropertySetInfo(
305 			sal_Int32 nMyCommandIdentifier )
306 			throw( com::sun::star::uno::RuntimeException );
307 
308 		virtual com::sun::star::uno::Reference< com::sun::star::sdbc::XRow > SAL_CALL
309 		getPropertyValues(
310 			sal_Int32 nMyCommandIdentifier,
311 			const com::sun::star::uno::Sequence< com::sun::star::beans::Property >& PropertySet )
312 			throw( com::sun::star::uno::RuntimeException );
313 
314 		com::sun::star::uno::Sequence< com::sun::star::uno::Any > SAL_CALL
315 		setPropertyValues(
316 			sal_Int32 nMyCommandIdentifier,
317 			const com::sun::star::uno::Sequence< com::sun::star::beans::PropertyValue >& Values )
318 			throw( );
319 
320 		com::sun::star::uno::Reference< com::sun::star::ucb::XDynamicResultSet > SAL_CALL
321 		open(
322 			sal_Int32 nMyCommandIdentifier,
323 			const com::sun::star::ucb::OpenCommandArgument2& aCommandArgument )
324 			throw();
325 
326 		void SAL_CALL
327 		deleteContent( sal_Int32 nMyCommandIdentifier )
328 			throw();
329 
330 
331 		void SAL_CALL
332 		transfer( sal_Int32 nMyCommandIdentifier,
333 				  const com::sun::star::ucb::TransferInfo& aTransferInfo )
334 			throw();
335 
336 		void SAL_CALL
337 		insert( sal_Int32 nMyCommandIdentifier,
338 				const com::sun::star::ucb::InsertCommandArgument& aInsertArgument )
339 			throw();
340 
341         void SAL_CALL endTask( sal_Int32 CommandId );
342 
343         friend class ContentEventNotifier;
344 	};
345 
346 }             // end namespace fileaccess
347 
348 #endif
349 
350