bump product version to 7.2.5.1
[LibreOffice.git] / configmgr / source / access.hxx
blob6d4ca787f3cc40d4010b5070fc01d3ed428cd19a
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
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 #pragma once
22 #include <sal/config.h>
24 #include <set>
25 #include <vector>
26 #include "config_map.hxx"
28 #include <com/sun/star/beans/XExactName.hpp>
29 #include <com/sun/star/beans/XHierarchicalPropertySet.hpp>
30 #include <com/sun/star/beans/XHierarchicalPropertySetInfo.hpp>
31 #include <com/sun/star/beans/XMultiHierarchicalPropertySet.hpp>
32 #include <com/sun/star/beans/XMultiPropertySet.hpp>
33 #include <com/sun/star/beans/XProperty.hpp>
34 #include <com/sun/star/beans/XPropertySet.hpp>
35 #include <com/sun/star/beans/XPropertySetInfo.hpp>
36 #include <com/sun/star/container/XContainer.hpp>
37 #include <com/sun/star/container/XHierarchicalName.hpp>
38 #include <com/sun/star/container/XHierarchicalNameReplace.hpp>
39 #include <com/sun/star/container/XNameContainer.hpp>
40 #include <com/sun/star/container/XNamed.hpp>
41 #include <com/sun/star/lang/XComponent.hpp>
42 #include <com/sun/star/lang/XServiceInfo.hpp>
43 #include <com/sun/star/lang/XTypeProvider.hpp>
44 #include <com/sun/star/lang/XSingleServiceFactory.hpp>
45 #include <com/sun/star/uno/Reference.hxx>
46 #include <com/sun/star/uno/Sequence.hxx>
47 #include <cppuhelper/weak.hxx>
48 #include <osl/interlck.h>
49 #include <rtl/ref.hxx>
50 #include <sal/types.h>
52 #include "modifications.hxx"
53 #include "type.hxx"
55 namespace com::sun::star {
56 namespace beans {
57 class XHierarchicalPropertySetInfo;
58 class XPropertiesChangeListener;
59 class XPropertyChangeListener;
60 class XVetoableChangeListener;
61 struct Property;
63 namespace container { class XContainerListener; }
64 namespace lang { class XEventListener; }
65 namespace uno {
66 class Any;
67 class Type;
68 class XInterface;
70 namespace util { struct ElementChange; }
73 namespace configmgr {
75 class Broadcaster;
76 class ChildAccess;
77 class Components;
78 class Node;
79 class RootAccess;
81 class Access:
82 public cppu::OWeakObject, public css::lang::XTypeProvider,
83 public css::lang::XServiceInfo,
84 public css::lang::XComponent,
85 public css::container::XHierarchicalNameReplace,
86 public css::container::XContainer,
87 public css::beans::XExactName,
88 public css::beans::XPropertySetInfo,
89 public css::container::XHierarchicalName,
90 public css::container::XNamed,
91 public css::beans::XProperty,
92 public css::beans::XPropertySet,
93 public css::beans::XMultiPropertySet,
94 public css::beans::XHierarchicalPropertySet,
95 public css::beans::XMultiHierarchicalPropertySet,
96 public css::beans::XHierarchicalPropertySetInfo,
97 public css::container::XNameContainer,
98 public css::lang::XSingleServiceFactory
100 public:
101 oslInterlockedCount acquireCounting();
103 void releaseNondeleting();
105 bool isValue();
107 void markChildAsModified(rtl::Reference< ChildAccess > const & child);
108 void releaseChild(OUString const & name);
110 virtual std::vector<OUString> getAbsolutePath() = 0;
111 virtual std::vector<OUString> getRelativePath() = 0;
113 virtual OUString getRelativePathRepresentation() = 0;
114 virtual rtl::Reference< Node > getNode() = 0;
116 virtual bool isFinalized() = 0;
118 virtual void initBroadcaster(
119 Modifications::Node const & modifications, Broadcaster * broadcaster);
121 using OWeakObject::acquire;
122 using OWeakObject::release;
124 virtual css::uno::Sequence< css::uno::Type > SAL_CALL
125 getTypes() override;
127 virtual css::uno::Sequence< sal_Int8 > SAL_CALL
128 getImplementationId() override;
130 virtual OUString SAL_CALL getImplementationName() override;
132 virtual sal_Bool SAL_CALL supportsService(OUString const & ServiceName) override;
134 virtual css::uno::Sequence< OUString > SAL_CALL
135 getSupportedServiceNames() override;
137 virtual void SAL_CALL dispose() override;
139 virtual void SAL_CALL addEventListener(
140 css::uno::Reference< css::lang::XEventListener >
141 const & xListener) override;
143 virtual void SAL_CALL removeEventListener(
144 css::uno::Reference< css::lang::XEventListener >
145 const & aListener) override;
147 virtual css::uno::Type SAL_CALL getElementType() override;
149 virtual sal_Bool SAL_CALL hasElements() override;
151 virtual css::uno::Any SAL_CALL getByName(
152 OUString const & aName) override;
154 virtual css::uno::Sequence< OUString > SAL_CALL
155 getElementNames() override;
157 virtual sal_Bool SAL_CALL hasByName(OUString const & aName) override;
159 virtual css::uno::Any SAL_CALL getByHierarchicalName(
160 OUString const & aName) override;
162 virtual sal_Bool SAL_CALL hasByHierarchicalName(OUString const & aName) override;
164 virtual void SAL_CALL replaceByHierarchicalName(
165 OUString const & aName, css::uno::Any const & aElement) override;
167 virtual void SAL_CALL addContainerListener(
168 css::uno::Reference<
169 css::container::XContainerListener > const & xListener) override;
171 virtual void SAL_CALL removeContainerListener(
172 css::uno::Reference<
173 css::container::XContainerListener > const & xListener) override;
175 virtual OUString SAL_CALL getExactName(
176 OUString const & aApproximateName) override;
178 virtual css::uno::Sequence< css::beans::Property >
179 SAL_CALL getProperties() override;
181 virtual css::beans::Property SAL_CALL getPropertyByName(
182 OUString const & aName) override;
184 virtual sal_Bool SAL_CALL hasPropertyByName(OUString const & Name) override;
186 virtual OUString SAL_CALL getHierarchicalName() override;
188 virtual OUString SAL_CALL composeHierarchicalName(
189 OUString const & aRelativeName) override;
191 virtual OUString SAL_CALL getName() override;
193 virtual void SAL_CALL setName(OUString const & aName) override;
195 virtual css::beans::Property SAL_CALL getAsProperty() override;
197 virtual
198 css::uno::Reference< css::beans::XPropertySetInfo >
199 SAL_CALL getPropertySetInfo() override;
201 virtual void SAL_CALL setPropertyValue(
202 OUString const & aPropertyName,
203 css::uno::Any const & aValue) override;
205 virtual css::uno::Any SAL_CALL getPropertyValue(
206 OUString const & PropertyName) override;
208 virtual void SAL_CALL addPropertyChangeListener(
209 OUString const & aPropertyName,
210 css::uno::Reference<
211 css::beans::XPropertyChangeListener > const & xListener) override;
213 virtual void SAL_CALL removePropertyChangeListener(
214 OUString const & aPropertyName,
215 css::uno::Reference<
216 css::beans::XPropertyChangeListener > const & aListener) override;
218 virtual void SAL_CALL addVetoableChangeListener(
219 OUString const & PropertyName,
220 css::uno::Reference<
221 css::beans::XVetoableChangeListener > const & aListener) override;
223 virtual void SAL_CALL removeVetoableChangeListener(
224 OUString const & PropertyName,
225 css::uno::Reference<
226 css::beans::XVetoableChangeListener > const & aListener) override;
228 virtual void SAL_CALL setPropertyValues(
229 css::uno::Sequence< OUString > const & aPropertyNames,
230 css::uno::Sequence< css::uno::Any > const &
231 aValues) override;
233 virtual css::uno::Sequence< css::uno::Any > SAL_CALL
234 getPropertyValues(
235 css::uno::Sequence< OUString > const & aPropertyNames) override;
237 virtual void SAL_CALL addPropertiesChangeListener(
238 css::uno::Sequence< OUString > const & aPropertyNames,
239 css::uno::Reference<
240 css::beans::XPropertiesChangeListener > const &
241 xListener) override;
243 virtual void SAL_CALL removePropertiesChangeListener(
244 css::uno::Reference<
245 css::beans::XPropertiesChangeListener > const &
246 xListener) override;
248 virtual void SAL_CALL firePropertiesChangeEvent(
249 css::uno::Sequence< OUString > const & aPropertyNames,
250 css::uno::Reference<
251 css::beans::XPropertiesChangeListener > const &
252 xListener) override;
254 virtual
255 css::uno::Reference<
256 css::beans::XHierarchicalPropertySetInfo > SAL_CALL
257 getHierarchicalPropertySetInfo() override;
259 virtual void SAL_CALL setHierarchicalPropertyValue(
260 OUString const & aHierarchicalPropertyName,
261 css::uno::Any const & aValue) override;
263 virtual css::uno::Any SAL_CALL getHierarchicalPropertyValue(
264 OUString const & aHierarchicalPropertyName) override;
266 virtual void SAL_CALL setHierarchicalPropertyValues(
267 css::uno::Sequence< OUString > const &
268 aHierarchicalPropertyNames,
269 css::uno::Sequence< css::uno::Any > const &
270 Values) override;
272 virtual css::uno::Sequence< css::uno::Any > SAL_CALL
273 getHierarchicalPropertyValues(
274 css::uno::Sequence< OUString > const &
275 aHierarchicalPropertyNames) override;
277 virtual css::beans::Property SAL_CALL
278 getPropertyByHierarchicalName(OUString const & aHierarchicalName) override;
280 virtual sal_Bool SAL_CALL hasPropertyByHierarchicalName(
281 OUString const & aHierarchicalName) override;
283 virtual void SAL_CALL replaceByName(
284 OUString const & aName, css::uno::Any const & aElement) override;
286 virtual void SAL_CALL insertByName(
287 OUString const & aName, css::uno::Any const & aElement) override;
289 virtual void SAL_CALL removeByName(OUString const & aName) override;
291 virtual css::uno::Reference< css::uno::XInterface >
292 SAL_CALL createInstance() override;
294 virtual css::uno::Reference< css::uno::XInterface >
295 SAL_CALL createInstanceWithArguments(
296 css::uno::Sequence< css::uno::Any > const &
297 aArguments) override;
299 protected:
300 explicit Access(Components & components);
302 virtual ~Access() override;
304 virtual OUString getNameInternal() = 0;
305 virtual rtl::Reference< RootAccess > getRootAccess() = 0;
306 virtual rtl::Reference< Access > getParentAccess() = 0;
308 virtual void addTypes(std::vector< css::uno::Type > * types)
309 const = 0;
311 virtual void addSupportedServiceNames(
312 std::vector<OUString> * services) = 0;
314 virtual void initDisposeBroadcaster(Broadcaster * broadcaster);
315 virtual void clearListeners() noexcept;
317 virtual css::uno::Any SAL_CALL queryInterface(
318 css::uno::Type const & aType) override;
320 Components & getComponents() const { return components_;}
322 void checkLocalizedPropertyAccess();
324 rtl::Reference< Node > getParentNode();
325 rtl::Reference< ChildAccess > getChild(OUString const & name);
326 std::vector< rtl::Reference< ChildAccess > > getAllChildren();
328 void checkValue(
329 css::uno::Any const & value, Type type, bool nillable);
331 void insertLocalizedValueChild(
332 OUString const & name, css::uno::Any const & value,
333 Modifications * localModifications);
335 void reportChildChanges(
336 std::vector< css::util::ElementChange > * changes);
338 void commitChildChanges(bool valid, Modifications * globalModifications);
340 void initBroadcasterAndChanges(
341 Modifications::Node const & modifications, Broadcaster * broadcaster,
342 std::vector< css::util::ElementChange > * changes);
344 bool isDisposed() const { return disposed_;}
346 private:
347 Access(const Access&) = delete;
348 Access& operator=(const Access&) = delete;
350 struct ModifiedChild {
351 rtl::Reference< ChildAccess > child;
352 bool directlyModified;
354 ModifiedChild();
356 ModifiedChild(
357 rtl::Reference< ChildAccess > const & theChild,
358 bool theDirectlyModified);
361 typedef config_map< ModifiedChild > ModifiedChildren;
363 rtl::Reference< ChildAccess > getModifiedChild(
364 ModifiedChildren::iterator const & childIterator);
366 rtl::Reference< ChildAccess > getUnmodifiedChild(
367 OUString const & name);
369 rtl::Reference< ChildAccess > getSubChild(OUString const & path);
371 bool setChildProperty(
372 OUString const & name, css::uno::Any const & value,
373 Modifications * localModifications);
375 css::beans::Property asProperty();
377 bool getByNameFast(const OUString & name, css::uno::Any & value);
378 rtl::Reference< ChildAccess > createUnmodifiedChild(const OUString &name,
379 const rtl::Reference< Node > &node);
381 void checkFinalized();
383 void checkKnownProperty(OUString const & descriptor);
385 rtl::Reference< ChildAccess > getFreeSetMember( css::uno::Any const & value);
387 rtl::Reference< Access > getNotificationRoot();
389 typedef config_map< ChildAccess * > WeakChildMap;
391 typedef
392 std::multiset<
393 css::uno::Reference<
394 css::lang::XEventListener > >
395 DisposeListeners;
397 typedef
398 std::multiset<
399 css::uno::Reference<
400 css::container::XContainerListener > >
401 ContainerListeners;
403 typedef
404 std::multiset<
405 css::uno::Reference<
406 css::beans::XPropertyChangeListener > >
407 PropertyChangeListenersElement;
409 typedef config_map< PropertyChangeListenersElement >
410 PropertyChangeListeners;
412 typedef
413 std::multiset<
414 css::uno::Reference<
415 css::beans::XVetoableChangeListener > >
416 VetoableChangeListenersElement;
418 typedef config_map< VetoableChangeListenersElement >
419 VetoableChangeListeners;
421 typedef
422 std::multiset<
423 css::uno::Reference<
424 css::beans::XPropertiesChangeListener > >
425 PropertiesChangeListeners;
427 Components & components_;
428 ModifiedChildren modifiedChildren_;
429 WeakChildMap cachedChildren_;
430 DisposeListeners disposeListeners_;
431 ContainerListeners containerListeners_;
432 PropertyChangeListeners propertyChangeListeners_;
433 VetoableChangeListeners vetoableChangeListeners_;
434 PropertiesChangeListeners propertiesChangeListeners_;
435 bool disposed_;
437 std::shared_ptr<osl::Mutex> lock_;
439 #if !defined NDEBUG
440 protected:
441 enum {
442 IS_ANY = 0, IS_GROUP = 0x01, IS_SET = 0x02, IS_EXTENSIBLE = 0x04,
443 IS_GROUP_MEMBER = 0x08, IS_SET_MEMBER = 0x10, IS_UPDATE = 0x20 };
444 bool thisIs(int what);
445 #endif
450 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */