LibreOffice Module ucb (master)  1
ucbstore.hxx
Go to the documentation of this file.
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3  * This file is part of the LibreOffice project.
4  *
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/.
8  *
9  * This file incorporates work covered by the following license notice:
10  *
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 .
18  */
19 
20 #ifndef INCLUDED_UCB_SOURCE_CORE_UCBSTORE_HXX
21 #define INCLUDED_UCB_SOURCE_CORE_UCBSTORE_HXX
22 
23 #include <com/sun/star/lang/XServiceInfo.hpp>
24 #include <com/sun/star/lang/XMultiServiceFactory.hpp>
25 #include <com/sun/star/lang/XSingleServiceFactory.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/uno/XComponentContext.hpp>
32 #include <com/sun/star/beans/XPropertyContainer.hpp>
33 #include <com/sun/star/beans/XPropertySetInfoChangeNotifier.hpp>
34 #include <com/sun/star/beans/XPropertyAccess.hpp>
35 #include <com/sun/star/lang/XComponent.hpp>
36 #include <com/sun/star/lang/XInitialization.hpp>
37 #include <cppuhelper/implbase.hxx>
38 #include <memory>
39 
40 
41 #define STORE_SERVICE_NAME "com.sun.star.ucb.Store"
42 #define PROPSET_REG_SERVICE_NAME "com.sun.star.ucb.PropertySetRegistry"
43 #define PERS_PROPSET_SERVICE_NAME "com.sun.star.ucb.PersistentPropertySet"
44 
45 
46 struct UcbStore_Impl;
47 
48 class UcbStore : public cppu::WeakImplHelper <
49  css::lang::XServiceInfo,
50  css::ucb::XPropertySetRegistryFactory,
51  css::lang::XInitialization >
52 {
53  css::uno::Reference< css::uno::XComponentContext > m_xContext;
54  std::unique_ptr<UcbStore_Impl> m_pImpl;
55 
56 public:
57  explicit UcbStore( const css::uno::Reference< css::uno::XComponentContext >& xContext );
58  virtual ~UcbStore() override;
59 
60  // XServiceInfo
61  virtual OUString SAL_CALL getImplementationName() override;
62  virtual sal_Bool SAL_CALL supportsService( const OUString& ServiceName ) override;
63  virtual css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames() override;
64 
65  static OUString getImplementationName_Static();
66  static css::uno::Sequence< OUString > getSupportedServiceNames_Static();
67 
68  static css::uno::Reference< css::lang::XSingleServiceFactory >
69  createServiceFactory( const css::uno::Reference<
70  css::lang::XMultiServiceFactory >& rxServiceMgr );
71 
72  // XPropertySetRegistryFactory
73  virtual css::uno::Reference< css::ucb::XPropertySetRegistry > SAL_CALL
74  createPropertySetRegistry( const OUString& URL ) override;
75 
76  // XInitialization
77  virtual void SAL_CALL
78  initialize( const css::uno::Sequence< css::uno::Any >& aArguments ) override;
79 };
80 
81 
84 
85 class PropertySetRegistry : public cppu::WeakImplHelper <
86  css::lang::XServiceInfo,
87  css::ucb::XPropertySetRegistry,
88  css::container::XNameAccess >
89 {
90  friend class PersistentPropertySet;
91 
92  css::uno::Reference< css::uno::XComponentContext > m_xContext;
93  std::unique_ptr<PropertySetRegistry_Impl> m_pImpl;
94 
95 private:
96  css::uno::Reference< css::lang::XMultiServiceFactory >
98 
99  void add ( PersistentPropertySet* pSet );
100  void remove( PersistentPropertySet* pSet );
101 
102  void renamePropertySet( const OUString& rOldKey,
103  const OUString& rNewKey );
104 
105 public:
107  const css::uno::Reference< css::uno::XComponentContext >& xContext,
108  const css::uno::Sequence< css::uno::Any >& rInitArgs);
109  virtual ~PropertySetRegistry() override;
110 
111 
112  // XServiceInfo
113  virtual OUString SAL_CALL getImplementationName() override;
114  virtual sal_Bool SAL_CALL supportsService( const OUString& ServiceName ) override;
115  virtual css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames() override;
116 
117  // XPropertySetRegistry
118  virtual css::uno::Reference< css::ucb::XPersistentPropertySet > SAL_CALL
119  openPropertySet( const OUString& key, sal_Bool create ) override;
120  virtual void SAL_CALL
121  removePropertySet( const OUString& key ) override;
122 
123  // XElementAccess ( XNameAccess is derived from it )
124  virtual css::uno::Type SAL_CALL
125  getElementType() override;
126  virtual sal_Bool SAL_CALL
127  hasElements() override;
128 
129  // XNameAccess
130  virtual css::uno::Any SAL_CALL
131  getByName( const OUString& aName ) override;
132  virtual css::uno::Sequence< OUString > SAL_CALL
133  getElementNames() override;
134  virtual sal_Bool SAL_CALL
135  hasByName( const OUString& aName ) override;
136 
137  // Non-interface methods
138  css::uno::Reference< css::uno::XInterface >
140  css::uno::Reference< css::uno::XInterface >
141  getConfigWriteAccess( const OUString& rPath );
142 };
143 
144 
146 
147 class PersistentPropertySet : public cppu::WeakImplHelper <
148  css::lang::XServiceInfo,
149  css::lang::XComponent,
150  css::ucb::XPersistentPropertySet,
151  css::container::XNamed,
152  css::beans::XPropertyContainer,
153  css::beans::XPropertySetInfoChangeNotifier,
154  css::beans::XPropertyAccess >
155 {
156  std::unique_ptr<PersistentPropertySet_Impl> m_pImpl;
157 
158 private:
160  const css::beans::PropertyChangeEvent& rEvent ) const;
162  const css::beans::PropertySetInfoChangeEvent& evt ) const;
163 
164 public:
166  PropertySetRegistry& rCreator,
167  const OUString& rKey );
168  virtual ~PersistentPropertySet() override;
169 
170  // XServiceInfo
171  virtual OUString SAL_CALL getImplementationName() override;
172  virtual sal_Bool SAL_CALL supportsService( const OUString& ServiceName ) override;
173  virtual css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames() override;
174 
175  // XComponent
176  virtual void SAL_CALL
177  dispose() override;
178  virtual void SAL_CALL
179  addEventListener( const css::uno::Reference< css::lang::XEventListener >& Listener ) override;
180  virtual void SAL_CALL
181  removeEventListener( const css::uno::Reference< css::lang::XEventListener >& Listener ) override;
182 
183  // XPropertySet
184  virtual css::uno::Reference< css::beans::XPropertySetInfo > SAL_CALL
185  getPropertySetInfo() override;
186  virtual void SAL_CALL
187  setPropertyValue( const OUString& aPropertyName,
188  const css::uno::Any& aValue ) override;
189  virtual css::uno::Any SAL_CALL
190  getPropertyValue( const OUString& PropertyName ) override;
191  virtual void SAL_CALL
192  addPropertyChangeListener( const OUString& aPropertyName,
193  const css::uno::Reference< css::beans::XPropertyChangeListener >& xListener ) override;
194  virtual void SAL_CALL
195  removePropertyChangeListener( const OUString& aPropertyName,
196  const css::uno::Reference< css::beans::XPropertyChangeListener >& aListener ) override;
197  virtual void SAL_CALL
198  addVetoableChangeListener( const OUString& PropertyName,
199  const css::uno::Reference< css::beans::XVetoableChangeListener >& aListener ) override;
200  virtual void SAL_CALL
201  removeVetoableChangeListener( const OUString& PropertyName,
202  const css::uno::Reference< css::beans::XVetoableChangeListener >& aListener ) override;
203 
204  // XPersistentPropertySet
205  virtual css::uno::Reference< css::ucb::XPropertySetRegistry > SAL_CALL
206  getRegistry() override;
207  virtual OUString SAL_CALL
208  getKey() override;
209 
210  // XNamed
211  virtual OUString SAL_CALL
212  getName() override;
213  virtual void SAL_CALL
214  setName( const OUString& aName ) override;
215 
216  // XPropertyContainer
217  virtual void SAL_CALL
218  addProperty( const OUString& Name,
219  sal_Int16 Attributes,
220  const css::uno::Any& DefaultValue ) override;
221  virtual void SAL_CALL
222  removeProperty( const OUString& Name ) override;
223 
224  // XPropertySetInfoChangeNotifier
225  virtual void SAL_CALL
226  addPropertySetInfoChangeListener( const css::uno::Reference< css::beans::XPropertySetInfoChangeListener >& Listener ) override;
227  virtual void SAL_CALL
228  removePropertySetInfoChangeListener( const css::uno::Reference< css::beans::XPropertySetInfoChangeListener >& Listener ) override;
229 
230  // XPropertyAccess
231  virtual css::uno::Sequence< css::beans::PropertyValue > SAL_CALL
232  getPropertyValues() override;
233  virtual void SAL_CALL
234  setPropertyValues( const css::uno::Sequence< css::beans::PropertyValue >& aProps ) override;
235 
236  // Non-interface methods.
238  const OUString& getFullKey();
239 };
240 
241 #endif // INCLUDED_UCB_SOURCE_CORE_UCBSTORE_HXX
242 
243 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
virtual OUString SAL_CALL getName() override
Definition: ucbstore.cxx:1373
virtual css::uno::Sequence< OUString > SAL_CALL getElementNames() override
Definition: ucbstore.cxx:514
virtual void SAL_CALL addVetoableChangeListener(const OUString &PropertyName, const css::uno::Reference< css::beans::XVetoableChangeListener > &aListener) override
Definition: ucbstore.cxx:1333
PropertySetRegistry(const css::uno::Reference< css::uno::XComponentContext > &xContext, const css::uno::Sequence< css::uno::Any > &rInitArgs)
Definition: ucbstore.cxx:240
std::unique_ptr< UcbStore_Impl > m_pImpl
Definition: ucbstore.hxx:54
virtual css::uno::Reference< css::ucb::XPropertySetRegistry > SAL_CALL getRegistry() override
Definition: ucbstore.cxx:1356
virtual css::uno::Type SAL_CALL getElementType() override
Definition: ucbstore.cxx:462
std::unique_ptr< PropertySetRegistry_Impl > m_pImpl
Definition: ucbstore.hxx:93
PersistentPropertySet(PropertySetRegistry &rCreator, const OUString &rKey)
Definition: ucbstore.cxx:1074
virtual ~PropertySetRegistry() override
Definition: ucbstore.cxx:250
virtual OUString SAL_CALL getImplementationName() override
Definition: ucbstore.cxx:1093
void renamePropertySet(const OUString &rOldKey, const OUString &rNewKey)
Definition: ucbstore.cxx:576
virtual OUString SAL_CALL getImplementationName() override
virtual css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames() override
virtual void SAL_CALL removePropertySet(const OUString &key) override
Definition: ucbstore.cxx:403
static css::uno::Reference< css::lang::XSingleServiceFactory > createServiceFactory(const css::uno::Reference< css::lang::XMultiServiceFactory > &rxServiceMgr)
virtual css::uno::Sequence< css::beans::PropertyValue > SAL_CALL getPropertyValues() override
Definition: ucbstore.cxx:1719
virtual void SAL_CALL setPropertyValue(const OUString &aPropertyName, const css::uno::Any &aValue) override
Definition: ucbstore.cxx:1181
virtual ~PersistentPropertySet() override
Definition: ucbstore.cxx:1085
virtual OUString SAL_CALL getImplementationName() override
Definition: ucbstore.cxx:258
css::uno::Reference< css::uno::XComponentContext > m_xContext
Definition: ucbstore.hxx:53
css::uno::Reference< css::uno::XInterface > getConfigWriteAccess(const OUString &rPath)
Definition: ucbstore.cxx:968
UcbStore(const css::uno::Reference< css::uno::XComponentContext > &xContext)
Definition: ucbstore.cxx:147
virtual css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames() override
Definition: ucbstore.cxx:1104
virtual ~UcbStore() override
Definition: ucbstore.cxx:155
virtual sal_Bool SAL_CALL supportsService(const OUString &ServiceName) override
Definition: ucbstore.cxx:1098
virtual void SAL_CALL initialize(const css::uno::Sequence< css::uno::Any > &aArguments) override
Definition: ucbstore.cxx:207
virtual sal_Bool SAL_CALL supportsService(const OUString &ServiceName) override
static css::uno::Sequence< OUString > getSupportedServiceNames_Static()
Definition: ucbstore.cxx:170
virtual sal_Bool SAL_CALL hasElements() override
Definition: ucbstore.cxx:469
virtual void SAL_CALL removePropertySetInfoChangeListener(const css::uno::Reference< css::beans::XPropertySetInfoChangeListener > &Listener) override
Definition: ucbstore.cxx:1707
virtual void SAL_CALL addPropertySetInfoChangeListener(const css::uno::Reference< css::beans::XPropertySetInfoChangeListener > &Listener) override
Definition: ucbstore.cxx:1695
virtual css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames() override
Definition: ucbstore.cxx:268
void add(PersistentPropertySet *pSet)
Definition: ucbstore.cxx:544
void notifyPropertySetInfoChange(const css::beans::PropertySetInfoChangeEvent &evt) const
Definition: ucbstore.cxx:1999
const OUString & getFullKey()
Definition: ucbstore.cxx:2018
unsigned char sal_Bool
virtual css::uno::Any SAL_CALL getByName(const OUString &aName) override
Definition: ucbstore.cxx:486
virtual void SAL_CALL removeVetoableChangeListener(const OUString &PropertyName, const css::uno::Reference< css::beans::XVetoableChangeListener > &aListener) override
Definition: ucbstore.cxx:1343
virtual sal_Bool SAL_CALL supportsService(const OUString &ServiceName) override
Definition: ucbstore.cxx:263
css::uno::Reference< css::uno::XInterface > getRootConfigReadAccess()
Definition: ucbstore.cxx:913
virtual void SAL_CALL addEventListener(const css::uno::Reference< css::lang::XEventListener > &Listener) override
Definition: ucbstore.cxx:1142
virtual void SAL_CALL dispose() override
Definition: ucbstore.cxx:1114
css::uno::Reference< css::lang::XMultiServiceFactory > getConfigProvider()
Definition: ucbstore.cxx:877
virtual void SAL_CALL setName(const OUString &aName) override
Definition: ucbstore.cxx:1381
virtual sal_Bool SAL_CALL hasByName(const OUString &aName) override
Definition: ucbstore.cxx:529
void notifyPropertyChangeEvent(const css::beans::PropertyChangeEvent &rEvent) const
Definition: ucbstore.cxx:1961
virtual void SAL_CALL removePropertyChangeListener(const OUString &aPropertyName, const css::uno::Reference< css::beans::XPropertyChangeListener > &aListener) override
Definition: ucbstore.cxx:1318
virtual css::uno::Reference< css::ucb::XPersistentPropertySet > SAL_CALL openPropertySet(const OUString &key, sal_Bool create) override
Definition: ucbstore.cxx:279
std::unique_ptr< PersistentPropertySet_Impl > m_pImpl
Definition: ucbstore.hxx:156
virtual void SAL_CALL setPropertyValues(const css::uno::Sequence< css::beans::PropertyValue > &aProps) override
Definition: ucbstore.cxx:1847
virtual void SAL_CALL removeProperty(const OUString &Name) override
Definition: ucbstore.cxx:1551
virtual css::uno::Reference< css::beans::XPropertySetInfo > SAL_CALL getPropertySetInfo() override
Definition: ucbstore.cxx:1168
virtual css::uno::Any SAL_CALL getPropertyValue(const OUString &PropertyName) override
Definition: ucbstore.cxx:1276
virtual void SAL_CALL removeEventListener(const css::uno::Reference< css::lang::XEventListener > &Listener) override
Definition: ucbstore.cxx:1154
virtual OUString SAL_CALL getKey() override
Definition: ucbstore.cxx:1363
css::uno::Reference< css::uno::XComponentContext > m_xContext
Definition: ucbstore.hxx:92
static OUString getImplementationName_Static()
virtual void SAL_CALL addPropertyChangeListener(const OUString &aPropertyName, const css::uno::Reference< css::beans::XPropertyChangeListener > &xListener) override
Definition: ucbstore.cxx:1302
virtual css::uno::Reference< css::ucb::XPropertySetRegistry > SAL_CALL createPropertySetRegistry(const OUString &URL) override
Definition: ucbstore.cxx:187
PropertySetRegistry & getPropertySetRegistry()
Definition: ucbstore.cxx:2036
virtual void SAL_CALL addProperty(const OUString &Name, sal_Int16 Attributes, const css::uno::Any &DefaultValue) override
Definition: ucbstore.cxx:1392