1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
20 #ifndef INCLUDED_UCB_SOURCE_CORE_UCBSTORE_HXX
21 #define INCLUDED_UCB_SOURCE_CORE_UCBSTORE_HXX
23 #include <com/sun/star/lang/XTypeProvider.hpp>
24 #include <com/sun/star/lang/XServiceInfo.hpp>
25 #include <com/sun/star/lang/XMultiServiceFactory.hpp>
26 #include <com/sun/star/container/XNamed.hpp>
27 #include <com/sun/star/container/XNameAccess.hpp>
28 #include <com/sun/star/ucb/XPropertySetRegistryFactory.hpp>
29 #include <com/sun/star/ucb/XPropertySetRegistry.hpp>
30 #include <com/sun/star/ucb/XPersistentPropertySet.hpp>
31 #include <com/sun/star/beans/XPropertyContainer.hpp>
32 #include <com/sun/star/beans/XPropertySetInfoChangeNotifier.hpp>
33 #include <com/sun/star/beans/XPropertyAccess.hpp>
34 #include <com/sun/star/lang/XComponent.hpp>
35 #include <com/sun/star/lang/XInitialization.hpp>
36 #include <cppuhelper/weak.hxx>
37 #include <ucbhelper/macros.hxx>
38 #include <cppuhelper/implbase3.hxx>
39 #include <cppuhelper/implbase7.hxx>
42 #define STORE_SERVICE_NAME "com.sun.star.ucb.Store"
43 #define PROPSET_REG_SERVICE_NAME "com.sun.star.ucb.PropertySetRegistry"
44 #define PERS_PROPSET_SERVICE_NAME "com.sun.star.ucb.PersistentPropertySet"
50 class UcbStore
: public cppu::WeakImplHelper3
<
51 css::lang::XServiceInfo
,
52 css::ucb::XPropertySetRegistryFactory
,
53 css::lang::XInitialization
>
55 com::sun::star::uno::Reference
<
56 com::sun::star::uno::XComponentContext
> m_xContext
;
57 UcbStore_Impl
* m_pImpl
;
61 const com::sun::star::uno::Reference
<
62 com::sun::star::uno::XComponentContext
>& xContext
);
66 virtual OUString SAL_CALL
getImplementationName()
67 throw( css::uno::RuntimeException
, std::exception
) SAL_OVERRIDE
;
68 virtual sal_Bool SAL_CALL
supportsService( const OUString
& ServiceName
)
69 throw( css::uno::RuntimeException
, std::exception
) SAL_OVERRIDE
;
70 virtual css::uno::Sequence
< OUString
> SAL_CALL
getSupportedServiceNames()
71 throw( css::uno::RuntimeException
, std::exception
) SAL_OVERRIDE
;
73 static OUString
getImplementationName_Static();
74 static css::uno::Sequence
< OUString
> getSupportedServiceNames_Static();
76 static css::uno::Reference
< css::lang::XSingleServiceFactory
>
77 createServiceFactory( const css::uno::Reference
<
78 css::lang::XMultiServiceFactory
>& rxServiceMgr
);
80 // XPropertySetRegistryFactory
81 virtual com::sun::star::uno::Reference
<
82 com::sun::star::ucb::XPropertySetRegistry
> SAL_CALL
83 createPropertySetRegistry( const OUString
& URL
)
84 throw( com::sun::star::uno::RuntimeException
, std::exception
) SAL_OVERRIDE
;
88 initialize( const ::com::sun::star::uno::Sequence
<
89 ::com::sun::star::uno::Any
>& aArguments
)
90 throw( ::com::sun::star::uno::Exception
,
91 ::com::sun::star::uno::RuntimeException
, std::exception
) SAL_OVERRIDE
;
93 const ::com::sun::star::uno::Sequence
< ::com::sun::star::uno::Any
>&
99 struct PropertySetRegistry_Impl
;
100 class PersistentPropertySet
;
102 class PropertySetRegistry
: public cppu::WeakImplHelper3
<
103 css::lang::XServiceInfo
,
104 css::ucb::XPropertySetRegistry
,
105 css::container::XNameAccess
>
107 friend class PersistentPropertySet
;
109 com::sun::star::uno::Reference
<
110 com::sun::star::uno::XComponentContext
> m_xContext
;
111 PropertySetRegistry_Impl
* m_pImpl
;
114 com::sun::star::uno::Reference
< com::sun::star::lang::XMultiServiceFactory
>
117 void add ( PersistentPropertySet
* pSet
);
118 void remove( PersistentPropertySet
* pSet
);
120 void renamePropertySet( const OUString
& rOldKey
,
121 const OUString
& rNewKey
);
125 const com::sun::star::uno::Reference
<
126 com::sun::star::uno::XComponentContext
>& xContext
,
127 const ::com::sun::star::uno::Sequence
<
128 ::com::sun::star::uno::Any
>& rInitArgs
);
129 virtual ~PropertySetRegistry();
133 virtual OUString SAL_CALL
getImplementationName()
134 throw( css::uno::RuntimeException
, std::exception
) SAL_OVERRIDE
;
135 virtual sal_Bool SAL_CALL
supportsService( const OUString
& ServiceName
)
136 throw( css::uno::RuntimeException
, std::exception
) SAL_OVERRIDE
;
137 virtual css::uno::Sequence
< OUString
> SAL_CALL
getSupportedServiceNames()
138 throw( css::uno::RuntimeException
, std::exception
) SAL_OVERRIDE
;
140 static OUString
getImplementationName_Static();
141 static css::uno::Sequence
< OUString
> getSupportedServiceNames_Static();
143 // XPropertySetRegistry
144 virtual com::sun::star::uno::Reference
<
145 com::sun::star::ucb::XPersistentPropertySet
> SAL_CALL
146 openPropertySet( const OUString
& key
, sal_Bool create
)
147 throw( com::sun::star::uno::RuntimeException
, std::exception
) SAL_OVERRIDE
;
148 virtual void SAL_CALL
149 removePropertySet( const OUString
& key
)
150 throw( com::sun::star::uno::RuntimeException
, std::exception
) SAL_OVERRIDE
;
152 // XElementAccess ( XNameAccess is derived from it )
153 virtual com::sun::star::uno::Type SAL_CALL
155 throw( com::sun::star::uno::RuntimeException
, std::exception
) SAL_OVERRIDE
;
156 virtual sal_Bool SAL_CALL
158 throw( com::sun::star::uno::RuntimeException
, std::exception
) SAL_OVERRIDE
;
161 virtual com::sun::star::uno::Any SAL_CALL
162 getByName( const OUString
& aName
)
163 throw( com::sun::star::container::NoSuchElementException
,
164 com::sun::star::lang::WrappedTargetException
,
165 com::sun::star::uno::RuntimeException
, std::exception
) SAL_OVERRIDE
;
166 virtual com::sun::star::uno::Sequence
< OUString
> SAL_CALL
168 throw( com::sun::star::uno::RuntimeException
, std::exception
) SAL_OVERRIDE
;
169 virtual sal_Bool SAL_CALL
170 hasByName( const OUString
& aName
)
171 throw( com::sun::star::uno::RuntimeException
, std::exception
) SAL_OVERRIDE
;
173 // Non-interface methods
174 com::sun::star::uno::Reference
< com::sun::star::uno::XInterface
>
175 getRootConfigReadAccess();
176 com::sun::star::uno::Reference
< com::sun::star::uno::XInterface
>
177 getConfigWriteAccess( const OUString
& rPath
);
182 struct PersistentPropertySet_Impl
;
184 class PersistentPropertySet
: public cppu::WeakImplHelper7
<
185 css::lang::XServiceInfo
,
186 css::lang::XComponent
,
187 css::ucb::XPersistentPropertySet
,
188 css::container::XNamed
,
189 css::beans::XPropertyContainer
,
190 css::beans::XPropertySetInfoChangeNotifier
,
191 css::beans::XPropertyAccess
>
193 css::uno::Reference
< css::uno::XComponentContext
> m_xContext
;
194 PersistentPropertySet_Impl
* m_pImpl
;
197 void notifyPropertyChangeEvent(
198 const com::sun::star::beans::PropertyChangeEvent
& rEvent
) const;
199 void notifyPropertySetInfoChange(
200 const com::sun::star::beans::PropertySetInfoChangeEvent
& evt
) const;
203 PersistentPropertySet(
204 const com::sun::star::uno::Reference
<
205 com::sun::star::uno::XComponentContext
>& xContext
,
206 PropertySetRegistry
& rCreator
,
207 const OUString
& rKey
);
208 virtual ~PersistentPropertySet();
211 virtual OUString SAL_CALL
getImplementationName()
212 throw( css::uno::RuntimeException
, std::exception
) SAL_OVERRIDE
;
213 virtual sal_Bool SAL_CALL
supportsService( const OUString
& ServiceName
)
214 throw( css::uno::RuntimeException
, std::exception
) SAL_OVERRIDE
;
215 virtual css::uno::Sequence
< OUString
> SAL_CALL
getSupportedServiceNames()
216 throw( css::uno::RuntimeException
, std::exception
) SAL_OVERRIDE
;
218 static OUString
getImplementationName_Static();
219 static css::uno::Sequence
< OUString
> getSupportedServiceNames_Static();
222 virtual void SAL_CALL
224 throw( com::sun::star::uno::RuntimeException
, std::exception
) SAL_OVERRIDE
;
225 virtual void SAL_CALL
226 addEventListener( const com::sun::star::uno::Reference
<
227 com::sun::star::lang::XEventListener
>& Listener
)
228 throw( com::sun::star::uno::RuntimeException
, std::exception
) SAL_OVERRIDE
;
229 virtual void SAL_CALL
230 removeEventListener( const com::sun::star::uno::Reference
<
231 com::sun::star::lang::XEventListener
>& Listener
)
232 throw( com::sun::star::uno::RuntimeException
, std::exception
) SAL_OVERRIDE
;
235 virtual com::sun::star::uno::Reference
<
236 com::sun::star::beans::XPropertySetInfo
> SAL_CALL
238 throw( com::sun::star::uno::RuntimeException
, std::exception
) SAL_OVERRIDE
;
239 virtual void SAL_CALL
240 setPropertyValue( const OUString
& aPropertyName
,
241 const com::sun::star::uno::Any
& aValue
)
242 throw( com::sun::star::beans::UnknownPropertyException
,
243 com::sun::star::beans::PropertyVetoException
,
244 com::sun::star::lang::IllegalArgumentException
,
245 com::sun::star::lang::WrappedTargetException
,
246 com::sun::star::uno::RuntimeException
, std::exception
) SAL_OVERRIDE
;
247 virtual com::sun::star::uno::Any SAL_CALL
248 getPropertyValue( const OUString
& PropertyName
)
249 throw( com::sun::star::beans::UnknownPropertyException
,
250 com::sun::star::lang::WrappedTargetException
,
251 com::sun::star::uno::RuntimeException
, std::exception
) SAL_OVERRIDE
;
252 virtual void SAL_CALL
253 addPropertyChangeListener( const OUString
& aPropertyName
,
254 const com::sun::star::uno::Reference
<
255 com::sun::star::beans::XPropertyChangeListener
>& xListener
)
256 throw( com::sun::star::beans::UnknownPropertyException
,
257 com::sun::star::lang::WrappedTargetException
,
258 com::sun::star::uno::RuntimeException
, std::exception
) SAL_OVERRIDE
;
259 virtual void SAL_CALL
260 removePropertyChangeListener( const OUString
& aPropertyName
,
261 const com::sun::star::uno::Reference
<
262 com::sun::star::beans::XPropertyChangeListener
>& aListener
)
263 throw( com::sun::star::beans::UnknownPropertyException
,
264 com::sun::star::lang::WrappedTargetException
,
265 com::sun::star::uno::RuntimeException
, std::exception
) SAL_OVERRIDE
;
266 virtual void SAL_CALL
267 addVetoableChangeListener( const OUString
& PropertyName
,
268 const com::sun::star::uno::Reference
<
269 com::sun::star::beans::XVetoableChangeListener
>& aListener
)
270 throw( com::sun::star::beans::UnknownPropertyException
,
271 com::sun::star::lang::WrappedTargetException
,
272 com::sun::star::uno::RuntimeException
, std::exception
) SAL_OVERRIDE
;
273 virtual void SAL_CALL
274 removeVetoableChangeListener( const OUString
& PropertyName
,
275 const com::sun::star::uno::Reference
<
276 com::sun::star::beans::XVetoableChangeListener
>& aListener
)
277 throw( com::sun::star::beans::UnknownPropertyException
,
278 com::sun::star::lang::WrappedTargetException
,
279 com::sun::star::uno::RuntimeException
, std::exception
) SAL_OVERRIDE
;
281 // XPersistentPropertySet
282 virtual com::sun::star::uno::Reference
<
283 com::sun::star::ucb::XPropertySetRegistry
> SAL_CALL
285 throw( com::sun::star::uno::RuntimeException
, std::exception
) SAL_OVERRIDE
;
286 virtual OUString SAL_CALL
288 throw( com::sun::star::uno::RuntimeException
, std::exception
) SAL_OVERRIDE
;
291 virtual OUString SAL_CALL
293 throw( ::com::sun::star::uno::RuntimeException
, std::exception
) SAL_OVERRIDE
;
294 virtual void SAL_CALL
295 setName( const OUString
& aName
)
296 throw( ::com::sun::star::uno::RuntimeException
, std::exception
) SAL_OVERRIDE
;
298 // XPropertyContainer
299 virtual void SAL_CALL
300 addProperty( const OUString
& Name
,
301 sal_Int16 Attributes
,
302 const com::sun::star::uno::Any
& DefaultValue
)
303 throw( com::sun::star::beans::PropertyExistException
,
304 com::sun::star::beans::IllegalTypeException
,
305 com::sun::star::lang::IllegalArgumentException
,
306 com::sun::star::uno::RuntimeException
, std::exception
) SAL_OVERRIDE
;
307 virtual void SAL_CALL
308 removeProperty( const OUString
& Name
)
309 throw( com::sun::star::beans::UnknownPropertyException
,
310 com::sun::star::beans::NotRemoveableException
,
311 com::sun::star::uno::RuntimeException
, std::exception
) SAL_OVERRIDE
;
313 // XPropertySetInfoChangeNotifier
314 virtual void SAL_CALL
315 addPropertySetInfoChangeListener( const com::sun::star::uno::Reference
<
316 com::sun::star::beans::XPropertySetInfoChangeListener
>& Listener
)
317 throw( com::sun::star::uno::RuntimeException
, std::exception
) SAL_OVERRIDE
;
318 virtual void SAL_CALL
319 removePropertySetInfoChangeListener( const com::sun::star::uno::Reference
<
320 com::sun::star::beans::XPropertySetInfoChangeListener
>& Listener
)
321 throw( com::sun::star::uno::RuntimeException
, std::exception
) SAL_OVERRIDE
;
324 virtual com::sun::star::uno::Sequence
<
325 com::sun::star::beans::PropertyValue
> SAL_CALL
327 throw( com::sun::star::uno::RuntimeException
, std::exception
) SAL_OVERRIDE
;
328 virtual void SAL_CALL
329 setPropertyValues( const com::sun::star::uno::Sequence
<
330 com::sun::star::beans::PropertyValue
>& aProps
)
331 throw( com::sun::star::beans::UnknownPropertyException
,
332 com::sun::star::beans::PropertyVetoException
,
333 com::sun::star::lang::IllegalArgumentException
,
334 com::sun::star::lang::WrappedTargetException
,
335 com::sun::star::uno::RuntimeException
, std::exception
) SAL_OVERRIDE
;
337 // Non-interface methods.
338 PropertySetRegistry
& getPropertySetRegistry();
339 const OUString
& getFullKey();
342 #endif // INCLUDED_UCB_SOURCE_CORE_UCBSTORE_HXX
344 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */