xref: /trunk/main/ucb/source/core/ucbstore.hxx (revision 6df1ea1f)
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 _UCBSTORE_HXX
25 #define _UCBSTORE_HXX
26 
27 #include <com/sun/star/lang/XTypeProvider.hpp>
28 #include <com/sun/star/lang/XServiceInfo.hpp>
29 #include <com/sun/star/lang/XMultiServiceFactory.hpp>
30 #include <com/sun/star/container/XNamed.hpp>
31 #include <com/sun/star/container/XNameAccess.hpp>
32 #include <com/sun/star/ucb/XPropertySetRegistryFactory.hpp>
33 #include <com/sun/star/ucb/XPropertySetRegistry.hpp>
34 #include <com/sun/star/ucb/XPersistentPropertySet.hpp>
35 #include <com/sun/star/beans/XPropertyContainer.hpp>
36 #include <com/sun/star/beans/XPropertySetInfoChangeNotifier.hpp>
37 #include <com/sun/star/beans/XPropertyAccess.hpp>
38 #include <com/sun/star/lang/XComponent.hpp>
39 #include <com/sun/star/lang/XInitialization.hpp>
40 #include <cppuhelper/weak.hxx>
41 #include <ucbhelper/macros.hxx>
42 
43 //=========================================================================
44 
45 #define STORE_SERVICE_NAME 			"com.sun.star.ucb.Store"
46 #define PROPSET_REG_SERVICE_NAME	"com.sun.star.ucb.PropertySetRegistry"
47 #define PERS_PROPSET_SERVICE_NAME	"com.sun.star.ucb.PersistentPropertySet"
48 
49 //=========================================================================
50 
51 struct UcbStore_Impl;
52 
53 class UcbStore :
54 				public cppu::OWeakObject,
55 				public com::sun::star::lang::XTypeProvider,
56 				public com::sun::star::lang::XServiceInfo,
57 				public com::sun::star::ucb::XPropertySetRegistryFactory,
58 				public com::sun::star::lang::XInitialization
59 {
60 	com::sun::star::uno::Reference<
61 				com::sun::star::lang::XMultiServiceFactory > m_xSMgr;
62 	UcbStore_Impl* m_pImpl;
63 
64 public:
65 	UcbStore(
66 		const com::sun::star::uno::Reference<
67 				com::sun::star::lang::XMultiServiceFactory >& rXSMgr );
68 	virtual ~UcbStore();
69 
70 	// XInterface
71 	XINTERFACE_DECL()
72 
73 	// XTypeProvider
74 	XTYPEPROVIDER_DECL()
75 
76     // XServiceInfo
77 	XSERVICEINFO_DECL()
78 
79 	// XPropertySetRegistryFactory
80     virtual com::sun::star::uno::Reference<
81 				com::sun::star::ucb::XPropertySetRegistry > SAL_CALL
82 	createPropertySetRegistry( const rtl::OUString& URL )
83 		throw( com::sun::star::uno::RuntimeException );
84 
85 	// XInitialization
86     virtual void SAL_CALL
87 	initialize( const ::com::sun::star::uno::Sequence<
88 						::com::sun::star::uno::Any >& aArguments )
89 		throw( ::com::sun::star::uno::Exception,
90 			   ::com::sun::star::uno::RuntimeException );
91 
92 	const ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Any >&
93 	getInitArgs() const;
94 };
95 
96 //=========================================================================
97 
98 struct PropertySetRegistry_Impl;
99 class PersistentPropertySet;
100 
101 class PropertySetRegistry :
102 				public cppu::OWeakObject,
103 				public com::sun::star::lang::XTypeProvider,
104 				public com::sun::star::lang::XServiceInfo,
105 				public com::sun::star::ucb::XPropertySetRegistry,
106 				public com::sun::star::container::XNameAccess
107 {
108 	friend class PersistentPropertySet;
109 
110 	com::sun::star::uno::Reference<
111 				com::sun::star::lang::XMultiServiceFactory > m_xSMgr;
112 	PropertySetRegistry_Impl* m_pImpl;
113 
114 private:
115 	com::sun::star::uno::Reference< com::sun::star::lang::XMultiServiceFactory >
116 	getConfigProvider();
117 
118 	void add   ( PersistentPropertySet* pSet );
119 	void remove( PersistentPropertySet* pSet );
120 
121 	void renamePropertySet( const rtl::OUString& rOldKey,
122 							const rtl::OUString& rNewKey );
123 
124 public:
125 	PropertySetRegistry(
126 		const com::sun::star::uno::Reference<
127 				com::sun::star::lang::XMultiServiceFactory >& rXSMgr,
128 		const ::com::sun::star::uno::Sequence<
129                                                 ::com::sun::star::uno::Any >& rInitArgs);
130 	virtual ~PropertySetRegistry();
131 
132 	// XInterface
133 	XINTERFACE_DECL()
134 
135 	// XTypeProvider
136 	XTYPEPROVIDER_DECL()
137 
138     // XServiceInfo
139 	XSERVICEINFO_NOFACTORY_DECL()
140 
141 	// XPropertySetRegistry
142     virtual com::sun::star::uno::Reference<
143 				com::sun::star::ucb::XPersistentPropertySet > SAL_CALL
144 	openPropertySet( const rtl::OUString& key, sal_Bool create )
145 		throw( com::sun::star::uno::RuntimeException );
146     virtual void SAL_CALL
147 	removePropertySet( const rtl::OUString& key )
148 		throw( com::sun::star::uno::RuntimeException );
149 
150 	// XElementAccess ( XNameAccess is derived from it )
151     virtual com::sun::star::uno::Type SAL_CALL
152 	getElementType()
153 		throw( com::sun::star::uno::RuntimeException );
154     virtual sal_Bool SAL_CALL
155 	hasElements()
156 		throw( com::sun::star::uno::RuntimeException );
157 
158     // XNameAccess
159     virtual com::sun::star::uno::Any SAL_CALL
160 	getByName( const rtl::OUString& aName )
161 		throw( com::sun::star::container::NoSuchElementException,
162 			   com::sun::star::lang::WrappedTargetException,
163 			   com::sun::star::uno::RuntimeException );
164     virtual com::sun::star::uno::Sequence< rtl::OUString > SAL_CALL
165 	getElementNames()
166 		throw( com::sun::star::uno::RuntimeException );
167     virtual sal_Bool SAL_CALL
168 	hasByName( const rtl::OUString& aName )
169 		throw( com::sun::star::uno::RuntimeException );
170 
171 	// Non-interface methods
172 	com::sun::star::uno::Reference< com::sun::star::uno::XInterface >
173 	getRootConfigReadAccess();
174 	com::sun::star::uno::Reference< com::sun::star::uno::XInterface >
175 	getConfigWriteAccess( const rtl::OUString& rPath );
176 };
177 
178 //=========================================================================
179 
180 struct PersistentPropertySet_Impl;
181 
182 class PersistentPropertySet :
183 				public cppu::OWeakObject,
184 				public com::sun::star::lang::XTypeProvider,
185 				public com::sun::star::lang::XServiceInfo,
186 				public com::sun::star::lang::XComponent,
187 				public com::sun::star::ucb::XPersistentPropertySet,
188 				public com::sun::star::container::XNamed,
189 				public com::sun::star::beans::XPropertyContainer,
190 				public com::sun::star::beans::XPropertySetInfoChangeNotifier,
191 				public com::sun::star::beans::XPropertyAccess
192 {
193 	com::sun::star::uno::Reference<
194 			com::sun::star::lang::XMultiServiceFactory > m_xSMgr;
195 	PersistentPropertySet_Impl* m_pImpl;
196 
197 private:
198 	void notifyPropertyChangeEvent(
199 		const com::sun::star::beans::PropertyChangeEvent& rEvent ) const;
200 	void notifyPropertySetInfoChange(
201 		const com::sun::star::beans::PropertySetInfoChangeEvent& evt ) const;
202 
203 public:
204 	PersistentPropertySet(
205 		const com::sun::star::uno::Reference<
206 				com::sun::star::lang::XMultiServiceFactory >& rXSMgr,
207 		PropertySetRegistry& rCreator,
208 		const rtl::OUString& rKey );
209 	virtual ~PersistentPropertySet();
210 
211 	// XInterface
212 	XINTERFACE_DECL()
213 
214 	// XTypeProvider
215 	XTYPEPROVIDER_DECL()
216 
217     // XServiceInfo
218 	XSERVICEINFO_NOFACTORY_DECL()
219 
220 	// XComponent
221     virtual void SAL_CALL
222 	dispose()
223 		throw( com::sun::star::uno::RuntimeException );
224     virtual void SAL_CALL
225 	addEventListener( const com::sun::star::uno::Reference<
226 							com::sun::star::lang::XEventListener >& Listener )
227 		throw( com::sun::star::uno::RuntimeException );
228     virtual void SAL_CALL
229 	removeEventListener( const com::sun::star::uno::Reference<
230 							com::sun::star::lang::XEventListener >& Listener )
231 		throw( com::sun::star::uno::RuntimeException );
232 
233 	// XPropertySet
234     virtual com::sun::star::uno::Reference<
235 				com::sun::star::beans::XPropertySetInfo > SAL_CALL
236 	getPropertySetInfo()
237 		throw( com::sun::star::uno::RuntimeException );
238     virtual void SAL_CALL
239 	setPropertyValue( const rtl::OUString& aPropertyName,
240 					  const com::sun::star::uno::Any& aValue )
241 		throw( com::sun::star::beans::UnknownPropertyException,
242 			   com::sun::star::beans::PropertyVetoException,
243 			   com::sun::star::lang::IllegalArgumentException,
244 			   com::sun::star::lang::WrappedTargetException,
245 			   com::sun::star::uno::RuntimeException );
246     virtual com::sun::star::uno::Any SAL_CALL
247 	getPropertyValue( const rtl::OUString& PropertyName )
248 		throw( com::sun::star::beans::UnknownPropertyException,
249 			   com::sun::star::lang::WrappedTargetException,
250 			   com::sun::star::uno::RuntimeException );
251     virtual void SAL_CALL
252 	addPropertyChangeListener( const rtl::OUString& aPropertyName,
253 							   const com::sun::star::uno::Reference<
254 							   	com::sun::star::beans::XPropertyChangeListener >& xListener )
255 		throw( com::sun::star::beans::UnknownPropertyException,
256 			   com::sun::star::lang::WrappedTargetException,
257 			   com::sun::star::uno::RuntimeException );
258     virtual void SAL_CALL
259 	removePropertyChangeListener( const rtl::OUString& aPropertyName,
260 								  const com::sun::star::uno::Reference<
261 								  	com::sun::star::beans::XPropertyChangeListener >& aListener )
262 		throw( com::sun::star::beans::UnknownPropertyException,
263 			   com::sun::star::lang::WrappedTargetException,
264 			   com::sun::star::uno::RuntimeException );
265     virtual void SAL_CALL
266 	addVetoableChangeListener( const rtl::OUString& PropertyName,
267 							   const com::sun::star::uno::Reference<
268 							   	com::sun::star::beans::XVetoableChangeListener >& aListener )
269 		throw( com::sun::star::beans::UnknownPropertyException,
270 			   com::sun::star::lang::WrappedTargetException,
271 			   com::sun::star::uno::RuntimeException );
272     virtual void SAL_CALL
273 	removeVetoableChangeListener( const rtl::OUString& PropertyName,
274 								  const com::sun::star::uno::Reference<
275 								  	com::sun::star::beans::XVetoableChangeListener >& aListener )
276 		throw( com::sun::star::beans::UnknownPropertyException,
277 			   com::sun::star::lang::WrappedTargetException,
278 			   com::sun::star::uno::RuntimeException );
279 
280 	// XPersistentPropertySet
281     virtual com::sun::star::uno::Reference<
282 				com::sun::star::ucb::XPropertySetRegistry > SAL_CALL
283 	getRegistry()
284 		throw( com::sun::star::uno::RuntimeException );
285     virtual rtl::OUString SAL_CALL
286 	getKey()
287 		throw( com::sun::star::uno::RuntimeException );
288 
289 	// XNamed
290     virtual rtl::OUString SAL_CALL
291 	getName()
292 		throw( ::com::sun::star::uno::RuntimeException );
293     virtual void SAL_CALL
294 	setName( const ::rtl::OUString& aName )
295 		throw( ::com::sun::star::uno::RuntimeException );
296 
297 	// XPropertyContainer
298 	virtual void SAL_CALL
299 	addProperty( const rtl::OUString& Name,
300 				 sal_Int16 Attributes,
301 				 const com::sun::star::uno::Any& DefaultValue )
302 		throw( com::sun::star::beans::PropertyExistException,
303 			   com::sun::star::beans::IllegalTypeException,
304 			   com::sun::star::lang::IllegalArgumentException,
305 			   com::sun::star::uno::RuntimeException );
306     virtual void SAL_CALL
307 	removeProperty( const rtl::OUString& Name )
308 		throw( com::sun::star::beans::UnknownPropertyException,
309 			   com::sun::star::beans::NotRemoveableException,
310 			   com::sun::star::uno::RuntimeException );
311 
312 	// XPropertySetInfoChangeNotifier
313     virtual void SAL_CALL
314 	addPropertySetInfoChangeListener( const com::sun::star::uno::Reference<
315 			com::sun::star::beans::XPropertySetInfoChangeListener >& Listener )
316 		throw( com::sun::star::uno::RuntimeException );
317     virtual void SAL_CALL
318 	removePropertySetInfoChangeListener( const com::sun::star::uno::Reference<
319 			com::sun::star::beans::XPropertySetInfoChangeListener >& Listener )
320 		throw( com::sun::star::uno::RuntimeException );
321 
322 	// XPropertyAccess
323     virtual com::sun::star::uno::Sequence<
324 				com::sun::star::beans::PropertyValue > SAL_CALL
325 	getPropertyValues()
326 		throw( com::sun::star::uno::RuntimeException );
327     virtual void SAL_CALL
328 	setPropertyValues( const com::sun::star::uno::Sequence<
329 							com::sun::star::beans::PropertyValue >& aProps )
330 		throw( com::sun::star::beans::UnknownPropertyException,
331 			   com::sun::star::beans::PropertyVetoException,
332 			   com::sun::star::lang::IllegalArgumentException,
333 			   com::sun::star::lang::WrappedTargetException,
334 			   com::sun::star::uno::RuntimeException );
335 
336 	// Non-interface methods.
337 	PropertySetRegistry& getPropertySetRegistry();
338 	const rtl::OUString& getFullKey();
339 };
340 
341 #endif /* !_UCBSTORE_HXX */
342