CppunitTest_sc_tiledrendering2: move to tiledrendering folder
[LibreOffice.git] / configmgr / source / access.hxx
blob6a30875591f86ad5c0e349a94940f960c835fc0d
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 <o3tl/sorted_vector.hxx>
27 #include "config_map.hxx"
29 #include <com/sun/star/beans/XExactName.hpp>
30 #include <com/sun/star/beans/XHierarchicalPropertySet.hpp>
31 #include <com/sun/star/beans/XHierarchicalPropertySetInfo.hpp>
32 #include <com/sun/star/beans/XMultiHierarchicalPropertySet.hpp>
33 #include <com/sun/star/beans/XMultiPropertySet.hpp>
34 #include <com/sun/star/beans/XProperty.hpp>
35 #include <com/sun/star/beans/XPropertySet.hpp>
36 #include <com/sun/star/beans/XPropertySetInfo.hpp>
37 #include <com/sun/star/container/XContainer.hpp>
38 #include <com/sun/star/container/XHierarchicalName.hpp>
39 #include <com/sun/star/container/XHierarchicalNameAccess.hpp>
40 #include <com/sun/star/configuration/XDocumentation.hpp>
41 #include <com/sun/star/container/XHierarchicalNameReplace.hpp>
42 #include <com/sun/star/container/XNameContainer.hpp>
43 #include <com/sun/star/container/XNamed.hpp>
44 #include <com/sun/star/lang/XComponent.hpp>
45 #include <com/sun/star/lang/XServiceInfo.hpp>
46 #include <com/sun/star/lang/XTypeProvider.hpp>
47 #include <com/sun/star/lang/XSingleServiceFactory.hpp>
48 #include <com/sun/star/uno/Reference.hxx>
49 #include <com/sun/star/uno/Sequence.hxx>
50 #include <cppuhelper/weak.hxx>
51 #include <osl/interlck.h>
52 #include <rtl/ref.hxx>
53 #include <sal/types.h>
55 #include "modifications.hxx"
56 #include "type.hxx"
58 namespace com::sun::star {
59 namespace beans {
60 class XHierarchicalPropertySetInfo;
61 class XPropertiesChangeListener;
62 class XPropertyChangeListener;
63 class XVetoableChangeListener;
64 struct Property;
66 namespace container { class XContainerListener; }
67 namespace lang { class XEventListener; }
68 namespace uno {
69 class Any;
70 class Type;
71 class XInterface;
73 namespace util { struct ElementChange; }
76 namespace configmgr {
78 class Broadcaster;
79 class ChildAccess;
80 class Components;
81 class Node;
82 class RootAccess;
84 class Access:
85 public cppu::OWeakObject, public css::lang::XTypeProvider,
86 public css::lang::XServiceInfo,
87 public css::lang::XComponent,
88 public css::configuration::XDocumentation,
89 public css::container::XHierarchicalNameReplace,
90 public css::container::XContainer,
91 public css::beans::XExactName,
92 public css::beans::XPropertySetInfo,
93 public css::container::XHierarchicalName,
94 public css::container::XNamed,
95 public css::beans::XProperty,
96 public css::beans::XPropertySet,
97 public css::beans::XMultiPropertySet,
98 public css::beans::XHierarchicalPropertySet,
99 public css::beans::XMultiHierarchicalPropertySet,
100 public css::beans::XHierarchicalPropertySetInfo,
101 public css::container::XNameContainer,
102 public css::lang::XSingleServiceFactory
104 public:
105 oslInterlockedCount acquireCounting();
107 void releaseNondeleting();
109 bool isValue();
111 void markChildAsModified(rtl::Reference< ChildAccess > const & child);
112 void releaseChild(OUString const & name);
114 virtual std::vector<OUString> getAbsolutePath() = 0;
115 virtual std::vector<OUString> getRelativePath() = 0;
117 virtual OUString getRelativePathRepresentation() = 0;
118 virtual const rtl::Reference< Node > & getNode() = 0;
120 virtual bool isFinalized() = 0;
122 virtual void initBroadcaster(
123 Modifications::Node const & modifications, Broadcaster * broadcaster);
125 using OWeakObject::acquire;
126 using OWeakObject::release;
128 virtual css::uno::Sequence< css::uno::Type > SAL_CALL
129 getTypes() override;
131 virtual css::uno::Sequence< sal_Int8 > SAL_CALL
132 getImplementationId() override;
134 virtual OUString SAL_CALL getImplementationName() override;
136 virtual sal_Bool SAL_CALL supportsService(OUString const & ServiceName) override;
138 virtual css::uno::Sequence< OUString > SAL_CALL
139 getSupportedServiceNames() override;
141 virtual void SAL_CALL dispose() override;
143 virtual void SAL_CALL addEventListener(
144 css::uno::Reference< css::lang::XEventListener >
145 const & xListener) override;
147 virtual void SAL_CALL removeEventListener(
148 css::uno::Reference< css::lang::XEventListener >
149 const & aListener) override;
151 virtual css::uno::Type SAL_CALL getElementType() override;
153 virtual sal_Bool SAL_CALL hasElements() override;
155 virtual css::uno::Any SAL_CALL getByName(
156 OUString const & aName) override;
158 virtual css::uno::Sequence< OUString > SAL_CALL
159 getElementNames() override;
161 virtual sal_Bool SAL_CALL hasByName(OUString const & aName) override;
163 virtual css::uno::Any SAL_CALL getByHierarchicalName(
164 OUString const & aName) override;
166 virtual OUString SAL_CALL getDescriptionByHierarchicalName(
167 OUString const & aName) override;
169 virtual css::uno::Type SAL_CALL getTypeByHierarchicalName(
170 OUString const & aName) override;
172 virtual sal_Bool SAL_CALL getModifiedByHierarchicalName(
173 OUString const & aName) override;
175 virtual sal_Bool SAL_CALL hasByHierarchicalName(OUString const & aName) override;
177 virtual void SAL_CALL replaceByHierarchicalName(
178 OUString const & aName, css::uno::Any const & aElement) override;
180 virtual void SAL_CALL addContainerListener(
181 css::uno::Reference<
182 css::container::XContainerListener > const & xListener) override;
184 virtual void SAL_CALL removeContainerListener(
185 css::uno::Reference<
186 css::container::XContainerListener > const & xListener) override;
188 virtual OUString SAL_CALL getExactName(
189 OUString const & aApproximateName) override;
191 virtual css::uno::Sequence< css::beans::Property >
192 SAL_CALL getProperties() override;
194 virtual css::beans::Property SAL_CALL getPropertyByName(
195 OUString const & aName) override;
197 virtual sal_Bool SAL_CALL hasPropertyByName(OUString const & Name) override;
199 virtual OUString SAL_CALL getHierarchicalName() override;
201 virtual OUString SAL_CALL composeHierarchicalName(
202 OUString const & aRelativeName) override;
204 virtual OUString SAL_CALL getName() override;
206 virtual void SAL_CALL setName(OUString const & aName) override;
208 virtual css::beans::Property SAL_CALL getAsProperty() override;
210 virtual
211 css::uno::Reference< css::beans::XPropertySetInfo >
212 SAL_CALL getPropertySetInfo() override;
214 virtual void SAL_CALL setPropertyValue(
215 OUString const & aPropertyName,
216 css::uno::Any const & aValue) override;
218 virtual css::uno::Any SAL_CALL getPropertyValue(
219 OUString const & PropertyName) override;
221 virtual void SAL_CALL addPropertyChangeListener(
222 OUString const & aPropertyName,
223 css::uno::Reference<
224 css::beans::XPropertyChangeListener > const & xListener) override;
226 virtual void SAL_CALL removePropertyChangeListener(
227 OUString const & aPropertyName,
228 css::uno::Reference<
229 css::beans::XPropertyChangeListener > const & aListener) override;
231 virtual void SAL_CALL addVetoableChangeListener(
232 OUString const & PropertyName,
233 css::uno::Reference<
234 css::beans::XVetoableChangeListener > const & aListener) override;
236 virtual void SAL_CALL removeVetoableChangeListener(
237 OUString const & PropertyName,
238 css::uno::Reference<
239 css::beans::XVetoableChangeListener > const & aListener) override;
241 virtual void SAL_CALL setPropertyValues(
242 css::uno::Sequence< OUString > const & aPropertyNames,
243 css::uno::Sequence< css::uno::Any > const &
244 aValues) override;
246 virtual css::uno::Sequence< css::uno::Any > SAL_CALL
247 getPropertyValues(
248 css::uno::Sequence< OUString > const & aPropertyNames) override;
250 virtual void SAL_CALL addPropertiesChangeListener(
251 css::uno::Sequence< OUString > const & aPropertyNames,
252 css::uno::Reference<
253 css::beans::XPropertiesChangeListener > const &
254 xListener) override;
256 virtual void SAL_CALL removePropertiesChangeListener(
257 css::uno::Reference<
258 css::beans::XPropertiesChangeListener > const &
259 xListener) override;
261 virtual void SAL_CALL firePropertiesChangeEvent(
262 css::uno::Sequence< OUString > const & aPropertyNames,
263 css::uno::Reference<
264 css::beans::XPropertiesChangeListener > const &
265 xListener) override;
267 virtual
268 css::uno::Reference<
269 css::beans::XHierarchicalPropertySetInfo > SAL_CALL
270 getHierarchicalPropertySetInfo() override;
272 virtual void SAL_CALL setHierarchicalPropertyValue(
273 OUString const & aHierarchicalPropertyName,
274 css::uno::Any const & aValue) override;
276 virtual css::uno::Any SAL_CALL getHierarchicalPropertyValue(
277 OUString const & aHierarchicalPropertyName) override;
279 virtual void SAL_CALL setHierarchicalPropertyValues(
280 css::uno::Sequence< OUString > const &
281 aHierarchicalPropertyNames,
282 css::uno::Sequence< css::uno::Any > const &
283 Values) override;
285 virtual css::uno::Sequence< css::uno::Any > SAL_CALL
286 getHierarchicalPropertyValues(
287 css::uno::Sequence< OUString > const &
288 aHierarchicalPropertyNames) override;
290 virtual css::beans::Property SAL_CALL
291 getPropertyByHierarchicalName(OUString const & aHierarchicalName) override;
293 virtual sal_Bool SAL_CALL hasPropertyByHierarchicalName(
294 OUString const & aHierarchicalName) override;
296 virtual void SAL_CALL replaceByName(
297 OUString const & aName, css::uno::Any const & aElement) override;
299 virtual void SAL_CALL insertByName(
300 OUString const & aName, css::uno::Any const & aElement) override;
302 virtual void SAL_CALL removeByName(OUString const & aName) override;
304 virtual css::uno::Reference< css::uno::XInterface >
305 SAL_CALL createInstance() override;
307 virtual css::uno::Reference< css::uno::XInterface >
308 SAL_CALL createInstanceWithArguments(
309 css::uno::Sequence< css::uno::Any > const &
310 aArguments) override;
312 protected:
313 explicit Access(Components & components);
315 virtual ~Access() override;
317 virtual const OUString & getNameInternal() = 0;
318 virtual rtl::Reference< RootAccess > getRootAccess() = 0;
319 virtual rtl::Reference< Access > getParentAccess() = 0;
321 virtual void addTypes(std::vector< css::uno::Type > * types)
322 const = 0;
324 virtual void addSupportedServiceNames(
325 std::vector<OUString> * services) = 0;
327 virtual void initDisposeBroadcaster(Broadcaster * broadcaster);
328 virtual void clearListeners() noexcept;
330 virtual css::uno::Any SAL_CALL queryInterface(
331 css::uno::Type const & aType) override;
333 Components & getComponents() const { return components_;}
335 void checkLocalizedPropertyAccess();
337 rtl::Reference< Node > getParentNode();
338 rtl::Reference< ChildAccess > getChild(OUString const & name);
339 void forAllChildren(const std::function<bool(ChildAccess&)> & f);
340 bool isAllChildrenEmpty();
342 void checkValue(
343 css::uno::Any const & value, Type type, bool nillable);
345 void insertLocalizedValueChild(
346 OUString const & name, css::uno::Any const & value,
347 Modifications * localModifications);
349 void reportChildChanges(
350 std::vector< css::util::ElementChange > * changes);
352 void commitChildChanges(bool valid, Modifications * globalModifications);
354 void initBroadcasterAndChanges(
355 Modifications::Node const & modifications, Broadcaster * broadcaster,
356 std::vector< css::util::ElementChange > * changes);
358 bool isDisposed() const { return disposed_;}
360 private:
361 Access(const Access&) = delete;
362 Access& operator=(const Access&) = delete;
364 struct ModifiedChild {
365 rtl::Reference< ChildAccess > child;
366 bool directlyModified;
368 ModifiedChild();
370 ModifiedChild(
371 rtl::Reference< ChildAccess > theChild,
372 bool theDirectlyModified);
375 typedef config_map< ModifiedChild > ModifiedChildren;
377 rtl::Reference< ChildAccess > getModifiedChild(
378 ModifiedChildren::iterator const & childIterator);
380 rtl::Reference< ChildAccess > getUnmodifiedChild(
381 OUString const & name);
383 rtl::Reference< ChildAccess > getSubChild(OUString const & path);
385 bool setChildProperty(
386 OUString const & name, css::uno::Any const & value,
387 Modifications * localModifications);
389 css::beans::Property asProperty();
391 bool getByNameFast(const OUString & name, css::uno::Any & value);
392 rtl::Reference< ChildAccess > createUnmodifiedChild(const OUString &name,
393 const rtl::Reference< Node > &node);
395 void checkFinalized();
397 void checkKnownProperty(OUString const & descriptor);
399 rtl::Reference< ChildAccess > getFreeSetMember( css::uno::Any const & value);
401 rtl::Reference< Access > getNotificationRoot();
403 typedef config_map< ChildAccess * > WeakChildMap;
405 typedef
406 o3tl::sorted_vector<
407 css::uno::Reference<
408 css::lang::XEventListener > >
409 DisposeListeners;
411 typedef
412 o3tl::sorted_vector<
413 css::uno::Reference<
414 css::container::XContainerListener > >
415 ContainerListeners;
417 typedef
418 o3tl::sorted_vector<
419 css::uno::Reference<
420 css::beans::XPropertyChangeListener > >
421 PropertyChangeListenersElement;
423 typedef config_map< PropertyChangeListenersElement >
424 PropertyChangeListeners;
426 typedef
427 o3tl::sorted_vector<
428 css::uno::Reference<
429 css::beans::XVetoableChangeListener > >
430 VetoableChangeListenersElement;
432 typedef config_map< VetoableChangeListenersElement >
433 VetoableChangeListeners;
435 typedef
436 o3tl::sorted_vector<
437 css::uno::Reference<
438 css::beans::XPropertiesChangeListener > >
439 PropertiesChangeListeners;
441 Components & components_;
442 ModifiedChildren modifiedChildren_;
443 WeakChildMap cachedChildren_;
444 DisposeListeners disposeListeners_;
445 ContainerListeners containerListeners_;
446 PropertyChangeListeners propertyChangeListeners_;
447 VetoableChangeListeners vetoableChangeListeners_;
448 PropertiesChangeListeners propertiesChangeListeners_;
449 bool disposed_;
451 std::shared_ptr<osl::Mutex> lock_;
453 #if !defined NDEBUG
454 protected:
455 enum {
456 IS_ANY = 0, IS_GROUP = 0x01, IS_SET = 0x02, IS_EXTENSIBLE = 0x04,
457 IS_GROUP_MEMBER = 0x08, IS_SET_MEMBER = 0x10, IS_UPDATE = 0x20 };
458 bool thisIs(int what);
459 #endif
464 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */