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#pragma once
21
22#include <com/sun/star/lang/XServiceInfo.hpp>
23#include <com/sun/star/lang/XMultiServiceFactory.hpp>
24#include <com/sun/star/container/XNamed.hpp>
25#include <com/sun/star/container/XNameAccess.hpp>
26#include <com/sun/star/ucb/XPropertySetRegistryFactory.hpp>
27#include <com/sun/star/ucb/XPropertySetRegistry.hpp>
28#include <com/sun/star/ucb/XPersistentPropertySet.hpp>
29#include <com/sun/star/uno/XComponentContext.hpp>
30#include <com/sun/star/beans/XPropertyContainer.hpp>
31#include <com/sun/star/beans/XPropertySetInfoChangeNotifier.hpp>
32#include <com/sun/star/beans/XPropertyAccess.hpp>
33#include <com/sun/star/lang/XComponent.hpp>
34#include <com/sun/star/lang/XInitialization.hpp>
38#include <rtl/ref.hxx>
39#include <unordered_map>
40
41
43 css::lang::XServiceInfo,
44 css::ucb::XPropertySetRegistryFactory,
45 css::lang::XInitialization >;
46
47class UcbStore : public UcbStore_Base
48{
49 css::uno::Reference< css::uno::XComponentContext > m_xContext;
50 css::uno::Sequence< css::uno::Any > m_aInitArgs;
51 css::uno::Reference< css::ucb::XPropertySetRegistry > m_xTheRegistry;
52
53public:
54 explicit UcbStore( const css::uno::Reference< css::uno::XComponentContext >& xContext );
55 virtual ~UcbStore() override;
56
57 // XServiceInfo
58 virtual OUString SAL_CALL getImplementationName() override;
59 virtual sal_Bool SAL_CALL supportsService( const OUString& ServiceName ) override;
60 virtual css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames() override;
61
62 // XPropertySetRegistryFactory
63 virtual css::uno::Reference< css::ucb::XPropertySetRegistry > SAL_CALL
64 createPropertySetRegistry( const OUString& URL ) override;
65
66 // XInitialization
67 virtual void SAL_CALL
68 initialize( const css::uno::Sequence< css::uno::Any >& aArguments ) override;
69};
70
71
73
74// PropertySetMap_Impl.
75typedef std::unordered_map< OUString, PersistentPropertySet*> PropertySetMap_Impl;
76
77class PropertySetRegistry : public cppu::WeakImplHelper <
78 css::lang::XServiceInfo,
79 css::ucb::XPropertySetRegistry,
80 css::container::XNameAccess >
81{
83
84 css::uno::Reference< css::uno::XComponentContext > m_xContext;
85 const css::uno::Sequence< css::uno::Any > m_aInitArgs;
87 css::uno::Reference< css::lang::XMultiServiceFactory > m_xConfigProvider;
88 css::uno::Reference< css::uno::XInterface > m_xRootReadAccess;
89 css::uno::Reference< css::uno::XInterface > m_xRootWriteAccess;
90 std::mutex m_aMutex;
93
94private:
95 css::uno::Reference< css::lang::XMultiServiceFactory >
96 getConfigProvider(std::unique_lock<std::mutex>& l);
97
98 void add ( std::unique_lock<std::mutex>& rCreatorGuard, PersistentPropertySet* pSet );
99 void remove( PersistentPropertySet* pSet );
100
101 void renamePropertySet( const OUString& rOldKey,
102 const OUString& rNewKey );
103
104public:
106 const css::uno::Reference< css::uno::XComponentContext >& xContext,
107 const css::uno::Sequence< css::uno::Any >& rInitArgs);
108 virtual ~PropertySetRegistry() override;
109
110
111 // XServiceInfo
112 virtual OUString SAL_CALL getImplementationName() override;
113 virtual sal_Bool SAL_CALL supportsService( const OUString& ServiceName ) override;
114 virtual css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames() override;
115
116 // XPropertySetRegistry
117 virtual css::uno::Reference< css::ucb::XPersistentPropertySet > SAL_CALL
118 openPropertySet( const OUString& key, sal_Bool create ) override;
119 virtual void SAL_CALL
120 removePropertySet( const OUString& key ) override;
121
122 // XElementAccess ( XNameAccess is derived from it )
123 virtual css::uno::Type SAL_CALL
124 getElementType() override;
125 virtual sal_Bool SAL_CALL
126 hasElements() override;
127
128 // XNameAccess
129 virtual css::uno::Any SAL_CALL
130 getByName( const OUString& aName ) override;
131 virtual css::uno::Sequence< OUString > SAL_CALL
132 getElementNames() override;
133 virtual sal_Bool SAL_CALL
134 hasByName( const OUString& aName ) override;
135
136 // Non-interface methods
137 css::uno::Reference< css::uno::XInterface >
139 css::uno::Reference< css::uno::XInterface >
140 getConfigWriteAccess( const OUString& rPath );
141private:
142 css::uno::Reference< css::uno::XInterface >
143 getRootConfigReadAccessImpl(std::unique_lock<std::mutex>& l);
144 css::uno::Reference< css::uno::XInterface >
145 getConfigWriteAccessImpl( std::unique_lock<std::mutex>& l, const OUString& rPath );
146};
147
148
151
152class PersistentPropertySet : public cppu::WeakImplHelper <
153 css::lang::XServiceInfo,
154 css::lang::XComponent,
155 css::ucb::XPersistentPropertySet,
156 css::container::XNamed,
157 css::beans::XPropertyContainer,
158 css::beans::XPropertySetInfoChangeNotifier,
159 css::beans::XPropertyAccess >
160{
163 OUString m_aKey;
164 OUString m_aFullKey;
165 mutable std::mutex m_aMutex;
169
170private:
172 std::unique_lock<std::mutex>& rGuard,
173 const css::beans::PropertyChangeEvent& rEvent ) const;
175 std::unique_lock<std::mutex>& rGuard,
176 const css::beans::PropertySetInfoChangeEvent& evt ) const;
177
178public:
180 std::unique_lock<std::mutex>& rCreatorGuard,
181 PropertySetRegistry& rCreator,
182 OUString aKey );
183 virtual ~PersistentPropertySet() override;
184
185 // XServiceInfo
186 virtual OUString SAL_CALL getImplementationName() override;
187 virtual sal_Bool SAL_CALL supportsService( const OUString& ServiceName ) override;
188 virtual css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames() override;
189
190 // XComponent
191 virtual void SAL_CALL
192 dispose() override;
193 virtual void SAL_CALL
194 addEventListener( const css::uno::Reference< css::lang::XEventListener >& Listener ) override;
195 virtual void SAL_CALL
196 removeEventListener( const css::uno::Reference< css::lang::XEventListener >& Listener ) override;
197
198 // XPropertySet
199 virtual css::uno::Reference< css::beans::XPropertySetInfo > SAL_CALL
200 getPropertySetInfo() override;
201 virtual void SAL_CALL
202 setPropertyValue( const OUString& aPropertyName,
203 const css::uno::Any& aValue ) override;
204 virtual css::uno::Any SAL_CALL
205 getPropertyValue( const OUString& PropertyName ) override;
206 virtual void SAL_CALL
207 addPropertyChangeListener( const OUString& aPropertyName,
208 const css::uno::Reference< css::beans::XPropertyChangeListener >& xListener ) override;
209 virtual void SAL_CALL
210 removePropertyChangeListener( const OUString& aPropertyName,
211 const css::uno::Reference< css::beans::XPropertyChangeListener >& aListener ) override;
212 virtual void SAL_CALL
213 addVetoableChangeListener( const OUString& PropertyName,
214 const css::uno::Reference< css::beans::XVetoableChangeListener >& aListener ) override;
215 virtual void SAL_CALL
216 removeVetoableChangeListener( const OUString& PropertyName,
217 const css::uno::Reference< css::beans::XVetoableChangeListener >& aListener ) override;
218
219 // XPersistentPropertySet
220 virtual css::uno::Reference< css::ucb::XPropertySetRegistry > SAL_CALL
221 getRegistry() override;
222 virtual OUString SAL_CALL
223 getKey() override;
224
225 // XNamed
226 virtual OUString SAL_CALL
227 getName() override;
228 virtual void SAL_CALL
229 setName( const OUString& aName ) override;
230
231 // XPropertyContainer
232 virtual void SAL_CALL
233 addProperty( const OUString& Name,
234 sal_Int16 Attributes,
235 const css::uno::Any& DefaultValue ) override;
236 virtual void SAL_CALL
237 removeProperty( const OUString& Name ) override;
238
239 // XPropertySetInfoChangeNotifier
240 virtual void SAL_CALL
241 addPropertySetInfoChangeListener( const css::uno::Reference< css::beans::XPropertySetInfoChangeListener >& Listener ) override;
242 virtual void SAL_CALL
243 removePropertySetInfoChangeListener( const css::uno::Reference< css::beans::XPropertySetInfoChangeListener >& Listener ) override;
244
245 // XPropertyAccess
246 virtual css::uno::Sequence< css::beans::PropertyValue > SAL_CALL
247 getPropertyValues() override;
248 virtual void SAL_CALL
249 setPropertyValues( const css::uno::Sequence< css::beans::PropertyValue >& aProps ) override;
250
251 // Non-interface methods.
253 OUString getFullKey();
254private:
255 const OUString& getFullKeyImpl(std::unique_lock<std::mutex>&);
256};
257
258/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
virtual void SAL_CALL dispose() override
Definition: ucbstore.cxx:1046
comphelper::OInterfaceContainerHelper4< css::beans::XPropertySetInfoChangeListener > m_aPropSetChangeListeners
Definition: ucbstore.hxx:167
virtual void SAL_CALL removeProperty(const OUString &Name) override
Definition: ucbstore.cxx:1473
void notifyPropertyChangeEvent(std::unique_lock< std::mutex > &rGuard, const css::beans::PropertyChangeEvent &rEvent) const
Definition: ucbstore.cxx:1874
comphelper::OInterfaceContainerHelper4< css::lang::XEventListener > m_aDisposeEventListeners
Definition: ucbstore.hxx:166
virtual void SAL_CALL setPropertyValue(const OUString &aPropertyName, const css::uno::Any &aValue) override
Definition: ucbstore.cxx:1110
PropertyListeners_Impl m_aPropertyChangeListeners
Definition: ucbstore.hxx:168
virtual void SAL_CALL addPropertyChangeListener(const OUString &aPropertyName, const css::uno::Reference< css::beans::XPropertyChangeListener > &xListener) override
Definition: ucbstore.cxx:1227
virtual void SAL_CALL setPropertyValues(const css::uno::Sequence< css::beans::PropertyValue > &aProps) override
Definition: ucbstore.cxx:1763
virtual void SAL_CALL removeVetoableChangeListener(const OUString &PropertyName, const css::uno::Reference< css::beans::XVetoableChangeListener > &aListener) override
Definition: ucbstore.cxx:1266
virtual css::uno::Any SAL_CALL getPropertyValue(const OUString &PropertyName) override
Definition: ucbstore.cxx:1201
virtual void SAL_CALL removePropertySetInfoChangeListener(const css::uno::Reference< css::beans::XPropertySetInfoChangeListener > &Listener) override
Definition: ucbstore.cxx:1622
PropertySetRegistry & getPropertySetRegistry()
Definition: ucbstore.cxx:1923
void notifyPropertySetInfoChange(std::unique_lock< std::mutex > &rGuard, const css::beans::PropertySetInfoChangeEvent &evt) const
Definition: ucbstore.cxx:1896
virtual OUString SAL_CALL getKey() override
Definition: ucbstore.cxx:1286
virtual sal_Bool SAL_CALL supportsService(const OUString &ServiceName) override
Definition: ucbstore.cxx:1031
virtual css::uno::Reference< css::ucb::XPropertySetRegistry > SAL_CALL getRegistry() override
Definition: ucbstore.cxx:1279
virtual void SAL_CALL addPropertySetInfoChangeListener(const css::uno::Reference< css::beans::XPropertySetInfoChangeListener > &Listener) override
Definition: ucbstore.cxx:1612
virtual void SAL_CALL setName(const OUString &aName) override
Definition: ucbstore.cxx:1304
virtual css::uno::Reference< css::beans::XPropertySetInfo > SAL_CALL getPropertySetInfo() override
Definition: ucbstore.cxx:1097
virtual void SAL_CALL removeEventListener(const css::uno::Reference< css::lang::XEventListener > &Listener) override
Definition: ucbstore.cxx:1083
rtl::Reference< PropertySetInfo_Impl > m_pInfo
Definition: ucbstore.hxx:162
virtual css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames() override
Definition: ucbstore.cxx:1036
rtl::Reference< PropertySetRegistry > m_pCreator
Definition: ucbstore.hxx:161
PersistentPropertySet(std::unique_lock< std::mutex > &rCreatorGuard, PropertySetRegistry &rCreator, OUString aKey)
Definition: ucbstore.cxx:1006
virtual OUString SAL_CALL getImplementationName() override
Definition: ucbstore.cxx:1026
virtual void SAL_CALL addProperty(const OUString &Name, sal_Int16 Attributes, const css::uno::Any &DefaultValue) override
Definition: ucbstore.cxx:1315
virtual css::uno::Sequence< css::beans::PropertyValue > SAL_CALL getPropertyValues() override
Definition: ucbstore.cxx:1634
virtual ~PersistentPropertySet() override
Definition: ucbstore.cxx:1018
virtual void SAL_CALL removePropertyChangeListener(const OUString &aPropertyName, const css::uno::Reference< css::beans::XPropertyChangeListener > &aListener) override
Definition: ucbstore.cxx:1240
virtual void SAL_CALL addEventListener(const css::uno::Reference< css::lang::XEventListener > &Listener) override
Definition: ucbstore.cxx:1073
virtual OUString SAL_CALL getName() override
Definition: ucbstore.cxx:1296
const OUString & getFullKeyImpl(std::unique_lock< std::mutex > &)
Definition: ucbstore.cxx:1911
virtual void SAL_CALL addVetoableChangeListener(const OUString &PropertyName, const css::uno::Reference< css::beans::XVetoableChangeListener > &aListener) override
Definition: ucbstore.cxx:1256
css::uno::Reference< css::uno::XComponentContext > m_xContext
Definition: ucbstore.hxx:84
virtual void SAL_CALL removePropertySet(const OUString &key) override
Definition: ucbstore.cxx:363
css::uno::Reference< css::uno::XInterface > getRootConfigReadAccessImpl(std::unique_lock< std::mutex > &l)
Definition: ucbstore.cxx:862
css::uno::Reference< css::uno::XInterface > getConfigWriteAccessImpl(std::unique_lock< std::mutex > &l, const OUString &rPath)
Definition: ucbstore.cxx:922
css::uno::Reference< css::lang::XMultiServiceFactory > getConfigProvider(std::unique_lock< std::mutex > &l)
Definition: ucbstore.cxx:824
css::uno::Reference< css::uno::XInterface > getRootConfigReadAccess()
Definition: ucbstore.cxx:856
virtual css::uno::Reference< css::ucb::XPersistentPropertySet > SAL_CALL openPropertySet(const OUString &key, sal_Bool create) override
Definition: ucbstore.cxx:240
css::uno::Reference< css::uno::XInterface > getConfigWriteAccess(const OUString &rPath)
Definition: ucbstore.cxx:915
const css::uno::Sequence< css::uno::Any > m_aInitArgs
Definition: ucbstore.hxx:85
PropertySetMap_Impl m_aPropSets
Definition: ucbstore.hxx:86
virtual css::uno::Type SAL_CALL getElementType() override
Definition: ucbstore.cxx:422
virtual css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames() override
Definition: ucbstore.cxx:229
virtual OUString SAL_CALL getImplementationName() override
Definition: ucbstore.cxx:219
virtual sal_Bool SAL_CALL supportsService(const OUString &ServiceName) override
Definition: ucbstore.cxx:224
virtual css::uno::Any SAL_CALL getByName(const OUString &aName) override
Definition: ucbstore.cxx:444
bool m_bTriedToGetRootReadAccess
Definition: ucbstore.hxx:91
std::mutex m_aMutex
Definition: ucbstore.hxx:90
PropertySetRegistry(const css::uno::Reference< css::uno::XComponentContext > &xContext, const css::uno::Sequence< css::uno::Any > &rInitArgs)
Definition: ucbstore.cxx:199
css::uno::Reference< css::lang::XMultiServiceFactory > m_xConfigProvider
Definition: ucbstore.hxx:87
void renamePropertySet(const OUString &rOldKey, const OUString &rNewKey)
Definition: ucbstore.cxx:529
virtual sal_Bool SAL_CALL hasByName(const OUString &aName) override
Definition: ucbstore.cxx:483
void remove(PersistentPropertySet *pSet)
Definition: ucbstore.cxx:509
virtual sal_Bool SAL_CALL hasElements() override
Definition: ucbstore.cxx:429
void add(std::unique_lock< std::mutex > &rCreatorGuard, PersistentPropertySet *pSet)
Definition: ucbstore.cxx:496
css::uno::Reference< css::uno::XInterface > m_xRootWriteAccess
Definition: ucbstore.hxx:89
bool m_bTriedToGetRootWriteAccess
Definition: ucbstore.hxx:92
css::uno::Reference< css::uno::XInterface > m_xRootReadAccess
Definition: ucbstore.hxx:88
virtual ~PropertySetRegistry() override
Definition: ucbstore.cxx:211
virtual css::uno::Sequence< OUString > SAL_CALL getElementNames() override
Definition: ucbstore.cxx:470
css::uno::Reference< css::uno::XComponentContext > m_xContext
Definition: ucbstore.hxx:49
UcbStore(const css::uno::Reference< css::uno::XComponentContext > &xContext)
Definition: ucbstore.cxx:129
virtual OUString SAL_CALL getImplementationName() override
Definition: ucbstore.cxx:140
virtual css::uno::Reference< css::ucb::XPropertySetRegistry > SAL_CALL createPropertySetRegistry(const OUString &URL) override
Definition: ucbstore.cxx:168
css::uno::Reference< css::ucb::XPropertySetRegistry > m_xTheRegistry
Definition: ucbstore.hxx:51
virtual ~UcbStore() override
Definition: ucbstore.cxx:136
virtual css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames() override
Definition: ucbstore.cxx:148
css::uno::Sequence< css::uno::Any > m_aInitArgs
Definition: ucbstore.hxx:50
virtual sal_Bool SAL_CALL supportsService(const OUString &ServiceName) override
Definition: ucbstore.cxx:144
virtual void SAL_CALL initialize(const css::uno::Sequence< css::uno::Any > &aArguments) override
Definition: ucbstore.cxx:188
unsigned char sal_Bool
std::unordered_map< OUString, PersistentPropertySet * > PropertySetMap_Impl
Definition: ucbstore.hxx:72
comphelper::OMultiTypeInterfaceContainerHelperVar4< OUString, css::beans::XPropertyChangeListener > PropertyListeners_Impl
Definition: ucbstore.hxx:149