Branch data Line data Source code
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 : : #include "sal/config.h"
21 : :
22 : : #include <cassert>
23 : : #include <vector>
24 : :
25 : : #include "com/sun/star/beans/Property.hpp"
26 : : #include "com/sun/star/beans/PropertyAttribute.hpp"
27 : : #include "com/sun/star/beans/PropertyChangeEvent.hpp"
28 : : #include "com/sun/star/beans/PropertyVetoException.hpp"
29 : : #include "com/sun/star/beans/UnknownPropertyException.hpp"
30 : : #include "com/sun/star/beans/XExactName.hpp"
31 : : #include "com/sun/star/beans/XHierarchicalPropertySet.hpp"
32 : : #include "com/sun/star/beans/XHierarchicalPropertySetInfo.hpp"
33 : : #include "com/sun/star/beans/XMultiHierarchicalPropertySet.hpp"
34 : : #include "com/sun/star/beans/XMultiPropertySet.hpp"
35 : : #include "com/sun/star/beans/XPropertiesChangeListener.hpp"
36 : : #include "com/sun/star/beans/XProperty.hpp"
37 : : #include "com/sun/star/beans/XPropertyChangeListener.hpp"
38 : : #include "com/sun/star/beans/XPropertySet.hpp"
39 : : #include "com/sun/star/beans/XPropertySetInfo.hpp"
40 : : #include "com/sun/star/beans/XVetoableChangeListener.hpp"
41 : : #include "com/sun/star/container/ContainerEvent.hpp"
42 : : #include "com/sun/star/container/NoSuchElementException.hpp"
43 : : #include "com/sun/star/container/XContainer.hpp"
44 : : #include "com/sun/star/container/XContainerListener.hpp"
45 : : #include "com/sun/star/container/XElementAccess.hpp"
46 : : #include "com/sun/star/container/XHierarchicalName.hpp"
47 : : #include "com/sun/star/container/XHierarchicalNameAccess.hpp"
48 : : #include "com/sun/star/container/XHierarchicalNameReplace.hpp"
49 : : #include "com/sun/star/container/XNameAccess.hpp"
50 : : #include "com/sun/star/container/XNameContainer.hpp"
51 : : #include "com/sun/star/container/XNamed.hpp"
52 : : #include "com/sun/star/lang/DisposedException.hpp"
53 : : #include "com/sun/star/lang/EventObject.hpp"
54 : : #include "com/sun/star/lang/IllegalArgumentException.hpp"
55 : : #include "com/sun/star/lang/NoSupportException.hpp"
56 : : #include "com/sun/star/lang/WrappedTargetException.hpp"
57 : : #include "com/sun/star/lang/XComponent.hpp"
58 : : #include "com/sun/star/lang/XEventListener.hpp"
59 : : #include "com/sun/star/lang/XServiceInfo.hpp"
60 : : #include "com/sun/star/lang/XSingleServiceFactory.hpp"
61 : : #include "com/sun/star/lang/XTypeProvider.hpp"
62 : : #include "com/sun/star/lang/XUnoTunnel.hpp"
63 : : #include "com/sun/star/uno/Any.hxx"
64 : : #include "com/sun/star/uno/Reference.hxx"
65 : : #include "com/sun/star/uno/RuntimeException.hpp"
66 : : #include "com/sun/star/uno/Sequence.hxx"
67 : : #include "com/sun/star/uno/Type.hxx"
68 : : #include "com/sun/star/uno/TypeClass.hpp"
69 : : #include "com/sun/star/uno/XInterface.hpp"
70 : : #include "com/sun/star/uno/XWeak.hpp"
71 : : #include "com/sun/star/util/ElementChange.hpp"
72 : : #include "comphelper/sequenceasvector.hxx"
73 : : #include "cppu/unotype.hxx"
74 : : #include "cppuhelper/queryinterface.hxx"
75 : : #include "cppuhelper/weak.hxx"
76 : : #include "osl/interlck.h"
77 : : #include "osl/mutex.hxx"
78 : : #include "rtl/ref.hxx"
79 : : #include "rtl/ustrbuf.hxx"
80 : : #include "rtl/ustring.h"
81 : : #include "rtl/ustring.hxx"
82 : : #include "sal/types.h"
83 : :
84 : : #include "access.hxx"
85 : : #include "broadcaster.hxx"
86 : : #include "childaccess.hxx"
87 : : #include "components.hxx"
88 : : #include "data.hxx"
89 : : #include "groupnode.hxx"
90 : : #include "localizedpropertynode.hxx"
91 : : #include "localizedvaluenode.hxx"
92 : : #include "lock.hxx"
93 : : #include "modifications.hxx"
94 : : #include "node.hxx"
95 : : #include "nodemap.hxx"
96 : : #include "path.hxx"
97 : : #include "propertynode.hxx"
98 : : #include "rootaccess.hxx"
99 : : #include "setnode.hxx"
100 : : #include "type.hxx"
101 : :
102 : : namespace configmgr {
103 : :
104 : : namespace {
105 : :
106 : : namespace css = com::sun::star;
107 : :
108 : : }
109 : :
110 : 1368084 : oslInterlockedCount Access::acquireCounting() {
111 : 1368084 : return osl_incrementInterlockedCount(&m_refCount);
112 : : }
113 : :
114 : 1368084 : void Access::releaseNondeleting() {
115 : 1368084 : osl_decrementInterlockedCount(&m_refCount);
116 : 1368084 : }
117 : :
118 : 934572 : bool Access::isValue() {
119 [ + - ]: 934572 : rtl::Reference< Node > p(getNode());
120 [ + - ]: 934572 : switch (p->kind()) {
[ + + + ]
121 : : case Node::KIND_PROPERTY:
122 : : case Node::KIND_LOCALIZED_VALUE:
123 : 283159 : return true;
124 : : case Node::KIND_LOCALIZED_PROPERTY:
125 [ + - ][ + - ]: 11447 : return !Components::allLocales(getRootAccess()->getLocale());
[ + - ]
126 : : default:
127 : 639966 : return false;
128 [ + - ]: 934572 : }
129 : : }
130 : :
131 : 102960 : void Access::markChildAsModified(rtl::Reference< ChildAccess > const & child) {
132 : : assert(child.is() && child->getParentAccess() == this);
133 [ + - ][ + - ]: 102960 : modifiedChildren_[child->getNameInternal()] = ModifiedChild(child, true);
[ + - ]
134 : 248268 : for (rtl::Reference< Access > p(this);;) {
135 [ + - ]: 248268 : rtl::Reference< Access > parent(p->getParentAccess());
136 [ + + ]: 248268 : if (!parent.is()) {
137 : : break;
138 : : }
139 : : assert(dynamic_cast< ChildAccess * >(p.get()) != 0);
140 : 145308 : parent->modifiedChildren_.insert(
141 : : ModifiedChildren::value_type(
142 : 145308 : p->getNameInternal(),
143 [ - + ]: 435924 : ModifiedChild(dynamic_cast< ChildAccess * >(p.get()), false)));
[ + - + - ]
[ + - + - ]
[ + - ][ + - ]
144 [ + + ][ + - ]: 393576 : p = parent;
145 : 351228 : }
146 : 102960 : }
147 : :
148 : 4901342 : void Access::releaseChild(rtl::OUString const & name) {
149 : 4901342 : cachedChildren_.erase(name);
150 : 4901342 : }
151 : :
152 : 218 : void Access::initBroadcaster(
153 : : Modifications::Node const & modifications, Broadcaster * broadcaster)
154 : : {
155 : 218 : initBroadcasterAndChanges(modifications, broadcaster, 0);
156 : 218 : }
157 : :
158 : 260 : css::uno::Sequence< css::uno::Type > Access::getTypes()
159 : : throw (css::uno::RuntimeException)
160 : : {
161 : : assert(thisIs(IS_ANY));
162 [ + - ]: 260 : osl::MutexGuard g(*lock_);
163 [ + - ]: 260 : checkLocalizedPropertyAccess();
164 [ + - ]: 260 : comphelper::SequenceAsVector< css::uno::Type > types;
165 [ + - ]: 260 : types.push_back(cppu::UnoType< css::uno::XInterface >::get());
166 [ + - ][ + - ]: 260 : types.push_back(cppu::UnoType< css::uno::XWeak >::get());
167 [ + - ][ + - ]: 260 : types.push_back(cppu::UnoType< css::lang::XTypeProvider >::get());
168 [ + - ][ + - ]: 260 : types.push_back(cppu::UnoType< css::lang::XServiceInfo >::get());
169 [ + - ][ + - ]: 260 : types.push_back(cppu::UnoType< css::lang::XComponent >::get());
170 [ + - ]: 260 : types.push_back(cppu::UnoType< css::container::XContainer >::get());
171 [ + - ]: 260 : types.push_back(cppu::UnoType< css::beans::XExactName >::get());
172 [ + - ]: 260 : types.push_back(cppu::UnoType< css::container::XHierarchicalName >::get());
173 [ + - ]: 260 : types.push_back(cppu::UnoType< css::container::XNamed >::get());
174 [ + - ]: 260 : types.push_back(cppu::UnoType< css::beans::XProperty >::get());
175 [ + - ][ + - ]: 260 : types.push_back(cppu::UnoType< css::container::XElementAccess >::get());
176 [ + - ][ + - ]: 260 : types.push_back(cppu::UnoType< css::container::XNameAccess >::get());
177 [ + - ][ + - ]: 260 : if (getNode()->kind() == Node::KIND_GROUP) {
[ + - ][ + - ]
178 [ + - ]: 260 : types.push_back(cppu::UnoType< css::beans::XPropertySetInfo >::get());
179 [ + - ][ + - ]: 260 : types.push_back(cppu::UnoType< css::beans::XPropertySet >::get());
180 [ + - ][ + - ]: 260 : types.push_back(cppu::UnoType< css::beans::XMultiPropertySet >::get());
181 : : types.push_back(
182 [ + - ]: 260 : cppu::UnoType< css::beans::XHierarchicalPropertySet >::get());
183 : : types.push_back(
184 [ + - ]: 260 : cppu::UnoType< css::beans::XMultiHierarchicalPropertySet >::get());
185 : : types.push_back(
186 [ + - ]: 260 : cppu::UnoType< css::beans::XHierarchicalPropertySetInfo >::get());
187 : : }
188 [ + - ][ + - ]: 260 : if (getRootAccess()->isUpdate()) {
[ + - ]
189 [ + - ][ + - ]: 260 : types.push_back(cppu::UnoType< css::container::XNameReplace >::get());
190 : : types.push_back(
191 [ + - ]: 260 : cppu::UnoType< css::container::XHierarchicalNameReplace >::get());
192 [ + - ][ + - ]: 780 : if (getNode()->kind() != Node::KIND_GROUP ||
[ + - ][ - + ]
[ + - ][ + - ]
[ - + # # ]
193 [ + - ][ - + ]: 520 : dynamic_cast< GroupNode * >(getNode().get())->isExtensible())
[ + - ][ + - ]
[ + - ][ # # ]
194 : : {
195 : : types.push_back(
196 [ # # ][ # # ]: 0 : cppu::UnoType< css::container::XNameContainer >::get());
197 : : }
198 [ + - ][ + - ]: 260 : if (getNode()->kind() == Node::KIND_SET) {
[ + - ][ - + ]
199 : : types.push_back(
200 [ # # ][ # # ]: 0 : cppu::UnoType< css::lang::XSingleServiceFactory >::get());
201 : : }
202 : : } else {
203 : : types.push_back(
204 [ # # ][ # # ]: 0 : cppu::UnoType< css::container::XHierarchicalNameAccess >::get());
205 : : }
206 [ + - ]: 260 : addTypes(&types);
207 [ + - ][ + - ]: 260 : return types.getAsConstList();
208 : : }
209 : :
210 : 260 : css::uno::Sequence< sal_Int8 > Access::getImplementationId()
211 : : throw (css::uno::RuntimeException)
212 : : {
213 : : assert(thisIs(IS_ANY));
214 [ + - ]: 260 : osl::MutexGuard g(*lock_);
215 [ + - ]: 260 : checkLocalizedPropertyAccess();
216 [ + - ][ + - ]: 260 : return css::uno::Sequence< sal_Int8 >();
217 : : }
218 : :
219 : 0 : rtl::OUString Access::getImplementationName() throw (css::uno::RuntimeException)
220 : : {
221 : : assert(thisIs(IS_ANY));
222 [ # # ]: 0 : osl::MutexGuard g(*lock_);
223 [ # # ]: 0 : checkLocalizedPropertyAccess();
224 : : return rtl::OUString(
225 [ # # ][ # # ]: 0 : RTL_CONSTASCII_USTRINGPARAM("org.openoffice-configmgr::Access"));
226 : : }
227 : :
228 : 5096 : sal_Bool Access::supportsService(rtl::OUString const & ServiceName)
229 : : throw (css::uno::RuntimeException)
230 : : {
231 : : assert(thisIs(IS_ANY));
232 [ + - ]: 5096 : osl::MutexGuard g(*lock_);
233 [ + - ]: 5096 : checkLocalizedPropertyAccess();
234 [ + - ]: 5096 : css::uno::Sequence< rtl::OUString > names(getSupportedServiceNames());
235 [ + + ]: 35504 : for (sal_Int32 i = 0; i < names.getLength(); ++i) {
236 [ + - ][ + + ]: 32652 : if (names[i] == ServiceName) {
237 : 2244 : return true;
238 : : }
239 : : }
240 [ + - ][ + - ]: 5096 : return false;
241 : : }
242 : :
243 : 5096 : css::uno::Sequence< rtl::OUString > Access::getSupportedServiceNames()
244 : : throw (css::uno::RuntimeException)
245 : : {
246 : : assert(thisIs(IS_ANY));
247 [ + - ]: 5096 : osl::MutexGuard g(*lock_);
248 [ + - ]: 5096 : checkLocalizedPropertyAccess();
249 [ + - ]: 5096 : comphelper::SequenceAsVector< rtl::OUString > services;
250 : : services.push_back(
251 : : rtl::OUString(
252 : : RTL_CONSTASCII_USTRINGPARAM(
253 [ + - ][ + - ]: 5096 : "com.sun.star.configuration.ConfigurationAccess")));
254 [ + - ][ + + ]: 5096 : if (getRootAccess()->isUpdate()) {
[ + - ]
255 : : services.push_back(
256 : : rtl::OUString(
257 : : RTL_CONSTASCII_USTRINGPARAM(
258 [ + - ][ + - ]: 3216 : "com.sun.star.configuration.ConfigurationUpdateAccess")));
259 : : }
260 : : services.push_back(
261 : : rtl::OUString(
262 : : RTL_CONSTASCII_USTRINGPARAM(
263 [ + - ][ + - ]: 5096 : "com.sun.star.configuration.HierarchyAccess")));
264 : : services.push_back(
265 : : rtl::OUString(
266 : : RTL_CONSTASCII_USTRINGPARAM(
267 [ + - ][ + - ]: 5096 : "com.sun.star.configuration.HierarchyElement")));
268 [ + - ][ + - ]: 5096 : if (getNode()->kind() == Node::KIND_GROUP) {
[ + + ][ + - ]
269 : : services.push_back(
270 : : rtl::OUString(
271 : : RTL_CONSTASCII_USTRINGPARAM(
272 [ + - ][ + - ]: 2852 : "com.sun.star.configuration.GroupAccess")));
273 : : services.push_back(
274 : : rtl::OUString(
275 : : RTL_CONSTASCII_USTRINGPARAM(
276 [ + - ][ + - ]: 2852 : "com.sun.star.configuration.PropertyHierarchy")));
277 [ + - ][ + + ]: 2852 : if (getRootAccess()->isUpdate()) {
[ + - ]
278 : : services.push_back(
279 : : rtl::OUString(
280 : : RTL_CONSTASCII_USTRINGPARAM(
281 [ + - ][ + - ]: 2314 : "com.sun.star.configuration.GroupUpdate")));
282 : : }
283 : : } else {
284 : : services.push_back(
285 : : rtl::OUString(
286 : : RTL_CONSTASCII_USTRINGPARAM(
287 [ + - ][ + - ]: 2244 : "com.sun.star.configuration.SetAccess")));
288 : : services.push_back(
289 : : rtl::OUString(
290 : : RTL_CONSTASCII_USTRINGPARAM(
291 [ + - ][ + - ]: 2244 : "com.sun.star.configuration.SimpleSetAccess")));
292 [ + - ][ + + ]: 2244 : if (getRootAccess()->isUpdate()) {
[ + - ]
293 : : services.push_back(
294 : : rtl::OUString(
295 : : RTL_CONSTASCII_USTRINGPARAM(
296 [ + - ][ + - ]: 902 : "com.sun.star.configuration.SetUpdate")));
297 : : services.push_back(
298 : : rtl::OUString(
299 : : RTL_CONSTASCII_USTRINGPARAM(
300 [ + - ][ + - ]: 902 : "com.sun.star.configuration.SimpleSetUpdate")));
301 : : }
302 : : }
303 [ + - ]: 5096 : addSupportedServiceNames(&services);
304 [ + - ][ + - ]: 5096 : return services.getAsConstList();
305 : : }
306 : :
307 : 0 : void Access::dispose() throw (css::uno::RuntimeException) {
308 : : assert(thisIs(IS_ANY));
309 [ # # ]: 0 : Broadcaster bc;
310 : : {
311 [ # # ]: 0 : osl::MutexGuard g(*lock_);
312 [ # # ]: 0 : checkLocalizedPropertyAccess();
313 [ # # ][ # # ]: 0 : if (getParentAccess().is()) {
314 : : throw css::uno::RuntimeException(
315 : : rtl::OUString(
316 : : RTL_CONSTASCII_USTRINGPARAM(
317 : : "configmgr dispose inappropriate Access")),
318 [ # # ][ # # ]: 0 : static_cast< cppu::OWeakObject * >(this));
[ # # ]
319 : : }
320 [ # # ]: 0 : if (disposed_) {
321 : 0 : return;
322 : : }
323 [ # # ]: 0 : initDisposeBroadcaster(&bc);
324 : 0 : clearListeners();
325 [ # # ][ # # ]: 0 : disposed_ = true;
326 : : }
327 [ # # ][ # # ]: 0 : bc.send();
328 : : }
329 : :
330 : 6342 : void Access::addEventListener(
331 : : css::uno::Reference< css::lang::XEventListener > const & xListener)
332 : : throw (css::uno::RuntimeException)
333 : : {
334 : : assert(thisIs(IS_ANY));
335 : : {
336 [ + - ]: 6342 : osl::MutexGuard g(*lock_);
337 [ + - ]: 6342 : checkLocalizedPropertyAccess();
338 [ - + ]: 6342 : if (!xListener.is()) {
339 : : throw css::uno::RuntimeException(
340 : : rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("null listener")),
341 [ # # ][ # # ]: 0 : static_cast< cppu::OWeakObject * >(this));
[ # # ]
342 : : }
343 [ + - ]: 6342 : if (!disposed_) {
344 [ + - ]: 6342 : disposeListeners_.insert(xListener);
345 : 6342 : return;
346 [ + - ][ - + ]: 6342 : }
347 : : }
348 : : try {
349 [ # # ]: 6342 : xListener->disposing(
350 [ # # ][ # # ]: 0 : css::lang::EventObject(static_cast< cppu::OWeakObject * >(this)));
[ # # ][ # # ]
[ # # ]
351 : 0 : } catch (css::lang::DisposedException &) {}
352 : : }
353 : :
354 : 6333 : void Access::removeEventListener(
355 : : css::uno::Reference< css::lang::XEventListener > const & aListener)
356 : : throw (css::uno::RuntimeException)
357 : : {
358 : : assert(thisIs(IS_ANY));
359 [ + - ]: 6333 : osl::MutexGuard g(*lock_);
360 [ + - ]: 6333 : checkLocalizedPropertyAccess();
361 [ + - ]: 6333 : DisposeListeners::iterator i(disposeListeners_.find(aListener));
362 [ + - ]: 6333 : if (i != disposeListeners_.end()) {
363 [ + - ]: 6333 : disposeListeners_.erase(i);
364 [ + - ]: 6333 : }
365 : 6333 : }
366 : :
367 : 0 : css::uno::Type Access::getElementType() throw (css::uno::RuntimeException) {
368 : : assert(thisIs(IS_ANY));
369 [ # # ]: 0 : osl::MutexGuard g(*lock_);
370 [ # # ]: 0 : checkLocalizedPropertyAccess();
371 [ # # ]: 0 : rtl::Reference< Node > p(getNode());
372 [ # # ]: 0 : switch (p->kind()) {
[ # # # # ]
373 : : case Node::KIND_LOCALIZED_PROPERTY:
374 : : return mapType(
375 [ # # ][ # # ]: 0 : dynamic_cast< LocalizedPropertyNode * >(p.get())->getStaticType());
[ # # ]
376 : : case Node::KIND_GROUP:
377 : : //TODO: Should a specific type be returned for a non-extensible group
378 : : // with homogeneous members or for an extensible group that currently
379 : : // has only homegeneous members?
380 : 0 : return cppu::UnoType< cppu::UnoVoidType >::get();
381 : : case Node::KIND_SET:
382 : 0 : return cppu::UnoType< cppu::UnoVoidType >::get(); //TODO: correct?
383 : : default:
384 : : assert(false);
385 : : throw css::uno::RuntimeException(
386 : : rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("this cannot happen")),
387 [ # # ][ # # ]: 0 : static_cast< cppu::OWeakObject * >(this));
[ # # ]
388 [ # # ][ # # ]: 0 : }
389 : : }
390 : :
391 : 158 : sal_Bool Access::hasElements() throw (css::uno::RuntimeException) {
392 : : assert(thisIs(IS_ANY));
393 [ + - ]: 158 : osl::MutexGuard g(*lock_);
394 [ + - ]: 158 : checkLocalizedPropertyAccess();
395 [ + - ][ + - ]: 158 : return !getAllChildren().empty(); //TODO: optimize
396 : : }
397 : :
398 : 2042462 : css::uno::Any Access::getByName(rtl::OUString const & aName)
399 : : throw (
400 : : css::container::NoSuchElementException,
401 : : css::lang::WrappedTargetException, css::uno::RuntimeException)
402 : : {
403 : : assert(thisIs(IS_ANY));
404 [ + - ]: 2042462 : osl::MutexGuard g(*lock_);
405 [ + - ]: 2042462 : checkLocalizedPropertyAccess();
406 [ + - ]: 2042462 : rtl::Reference< ChildAccess > child(getChild(aName));
407 [ + + ]: 2042462 : if (!child.is()) {
408 : : throw css::container::NoSuchElementException(
409 [ + - ][ + - ]: 6 : aName, static_cast< cppu::OWeakObject * >(this));
410 : : }
411 [ + - ][ + - ]: 2042462 : return child->asValue();
412 : : }
413 : :
414 : 213200 : css::uno::Sequence< rtl::OUString > Access::getElementNames()
415 : : throw (css::uno::RuntimeException)
416 : : {
417 : : assert(thisIs(IS_ANY));
418 [ + - ]: 213200 : osl::MutexGuard g(*lock_);
419 [ + - ]: 213200 : checkLocalizedPropertyAccess();
420 [ + - ]: 213200 : std::vector< rtl::Reference< ChildAccess > > children(getAllChildren());
421 [ + - ]: 213200 : comphelper::SequenceAsVector< rtl::OUString > names;
422 [ + + ][ + - ]: 2537826 : for (std::vector< rtl::Reference< ChildAccess > >::iterator i(
423 : 213200 : children.begin());
424 : 1268913 : i != children.end(); ++i)
425 : : {
426 [ + - ][ + - ]: 1055713 : names.push_back((*i)->getNameInternal());
427 : : }
428 [ + - ][ + - ]: 213200 : return names.getAsConstList();
429 : : }
430 : :
431 : 556099 : sal_Bool Access::hasByName(rtl::OUString const & aName)
432 : : throw (css::uno::RuntimeException)
433 : : {
434 : : assert(thisIs(IS_ANY));
435 [ + - ]: 556099 : osl::MutexGuard g(*lock_);
436 [ + - ]: 556099 : checkLocalizedPropertyAccess();
437 [ + - ][ + - ]: 556099 : return getChild(aName).is();
438 : : }
439 : :
440 : 355507 : css::uno::Any Access::getByHierarchicalName(rtl::OUString const & aName)
441 : : throw (css::container::NoSuchElementException, css::uno::RuntimeException)
442 : : {
443 : : assert(thisIs(IS_ANY));
444 [ + - ]: 355507 : osl::MutexGuard g(*lock_);
445 [ + - ]: 355507 : checkLocalizedPropertyAccess();
446 [ + - ]: 355507 : rtl::Reference< ChildAccess > child(getSubChild(aName));
447 [ + + ]: 355507 : if (!child.is()) {
448 : : throw css::container::NoSuchElementException(
449 [ + - ][ + - ]: 96 : aName, static_cast< cppu::OWeakObject * >(this));
450 : : }
451 [ + - ][ + - ]: 355507 : return child->asValue();
452 : : }
453 : :
454 : 1275 : sal_Bool Access::hasByHierarchicalName(rtl::OUString const & aName)
455 : : throw (css::uno::RuntimeException)
456 : : {
457 : : assert(thisIs(IS_ANY));
458 [ + - ]: 1275 : osl::MutexGuard g(*lock_);
459 [ + - ]: 1275 : checkLocalizedPropertyAccess();
460 [ + - ][ + - ]: 1275 : return getSubChild(aName).is();
461 : : }
462 : :
463 : 62 : void Access::replaceByHierarchicalName(
464 : : rtl::OUString const & aName, css::uno::Any const & aElement)
465 : : throw (
466 : : css::lang::IllegalArgumentException,
467 : : css::container::NoSuchElementException,
468 : : css::lang::WrappedTargetException, css::uno::RuntimeException)
469 : : {
470 : : //TODO: Actually support sets and combine with replaceByName:
471 : : assert(thisIs(IS_UPDATE));
472 [ + - ]: 62 : Broadcaster bc;
473 : : {
474 [ + - ]: 62 : osl::MutexGuard g(*lock_);
475 [ + - ]: 62 : checkLocalizedPropertyAccess();
476 [ + - ]: 62 : rtl::Reference< ChildAccess > child(getSubChild(aName));
477 [ - + ]: 62 : if (!child.is()) {
478 : : throw css::container::NoSuchElementException(
479 [ # # ][ # # ]: 0 : aName, static_cast< cppu::OWeakObject * >(this));
480 : : }
481 [ + - ]: 62 : child->checkFinalized();
482 [ + - ]: 62 : rtl::Reference< Node > parent(child->getParentNode());
483 : : assert(parent.is());
484 [ + - ]: 62 : Modifications localMods;
485 [ + - ]: 62 : switch (parent->kind()) {
[ + - - - ]
486 : : case Node::KIND_LOCALIZED_PROPERTY:
487 : : case Node::KIND_GROUP:
488 [ + - ]: 62 : child->setProperty(aElement, &localMods);
489 : 62 : break;
490 : : case Node::KIND_SET:
491 : : throw css::lang::IllegalArgumentException(
492 : : rtl::OUString(
493 : : RTL_CONSTASCII_USTRINGPARAM(
494 : : "configmgr::Access::replaceByHierarchicalName does not"
495 : : " currently support set members")),
496 [ # # ][ # # ]: 0 : static_cast< cppu::OWeakObject * >(this), 0);
[ # # ]
497 : : case Node::KIND_ROOT:
498 : : throw css::lang::IllegalArgumentException(
499 : : (rtl::OUString(
500 : : RTL_CONSTASCII_USTRINGPARAM(
501 : : "configmgr::Access::replaceByHierarchicalName does not"
502 : : " allow changing component "))
503 : : + aName),
504 [ # # ][ # # ]: 0 : static_cast< cppu::OWeakObject * >(this), 0);
[ # # ]
505 : : default:
506 : : assert(false); // this cannot happen
507 : 0 : break;
508 : : }
509 [ + - ][ + - ]: 62 : getNotificationRoot()->initBroadcaster(localMods.getRoot(), &bc);
[ + - ][ + - ]
[ + - ][ + - ]
510 : : }
511 [ + - ]: 62 : bc.send();
512 : 62 : }
513 : :
514 : 985 : void Access::addContainerListener(
515 : : css::uno::Reference< css::container::XContainerListener > const & xListener)
516 : : throw (css::uno::RuntimeException)
517 : : {
518 : : assert(thisIs(IS_ANY));
519 : : {
520 [ + - ]: 985 : osl::MutexGuard g(*lock_);
521 [ + - ]: 985 : checkLocalizedPropertyAccess();
522 [ - + ]: 985 : if (!xListener.is()) {
523 : : throw css::uno::RuntimeException(
524 : : rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("null listener")),
525 [ # # ][ # # ]: 0 : static_cast< cppu::OWeakObject * >(this));
[ # # ]
526 : : }
527 [ + - ]: 985 : if (!disposed_) {
528 [ + - ]: 985 : containerListeners_.insert(xListener);
529 : 985 : return;
530 [ + - ][ - + ]: 985 : }
531 : : }
532 : : try {
533 [ # # ]: 985 : xListener->disposing(
534 [ # # ][ # # ]: 0 : css::lang::EventObject(static_cast< cppu::OWeakObject * >(this)));
[ # # ][ # # ]
[ # # ]
535 : 0 : } catch (css::lang::DisposedException &) {}
536 : : }
537 : :
538 : 965 : void Access::removeContainerListener(
539 : : css::uno::Reference< css::container::XContainerListener > const & xListener)
540 : : throw (css::uno::RuntimeException)
541 : : {
542 : : assert(thisIs(IS_ANY));
543 [ + - ]: 965 : osl::MutexGuard g(*lock_);
544 [ + - ]: 965 : checkLocalizedPropertyAccess();
545 [ + - ]: 965 : ContainerListeners::iterator i(containerListeners_.find(xListener));
546 [ + - ]: 965 : if (i != containerListeners_.end()) {
547 [ + - ]: 965 : containerListeners_.erase(i);
548 [ + - ]: 965 : }
549 : 965 : }
550 : :
551 : 0 : rtl::OUString Access::getExactName(rtl::OUString const & aApproximateName)
552 : : throw (css::uno::RuntimeException)
553 : : {
554 : : assert(thisIs(IS_ANY));
555 [ # # ]: 0 : osl::MutexGuard g(*lock_);
556 [ # # ]: 0 : checkLocalizedPropertyAccess();
557 [ # # ]: 0 : return aApproximateName;
558 : : }
559 : :
560 : 260 : css::uno::Sequence< css::beans::Property > Access::getProperties()
561 : : throw (css::uno::RuntimeException)
562 : : {
563 : : assert(thisIs(IS_GROUP));
564 [ + - ]: 260 : osl::MutexGuard g(*lock_);
565 [ + - ]: 260 : std::vector< rtl::Reference< ChildAccess > > children(getAllChildren());
566 [ + - ]: 260 : comphelper::SequenceAsVector< css::beans::Property > properties;
567 [ + + ][ + - ]: 5200 : for (std::vector< rtl::Reference< ChildAccess > >::iterator i(
568 : 260 : children.begin());
569 : 2600 : i != children.end(); ++i)
570 : : {
571 [ + - ][ + - ]: 2340 : properties.push_back((*i)->asProperty());
572 : : }
573 [ + - ][ + - ]: 260 : return properties.getAsConstList();
574 : : }
575 : :
576 : 14494 : css::beans::Property Access::getPropertyByName(rtl::OUString const & aName)
577 : : throw (css::beans::UnknownPropertyException, css::uno::RuntimeException)
578 : : {
579 : : assert(thisIs(IS_GROUP));
580 [ + - ]: 14494 : osl::MutexGuard g(*lock_);
581 [ + - ]: 14494 : rtl::Reference< ChildAccess > child(getChild(aName));
582 [ - + ]: 14494 : if (!child.is()) {
583 : : throw css::beans::UnknownPropertyException(
584 [ # # ][ # # ]: 0 : aName, static_cast< cppu::OWeakObject * >(this));
585 : : }
586 [ + - ][ + - ]: 14494 : return child->asProperty();
587 : : }
588 : :
589 : 0 : sal_Bool Access::hasPropertyByName(rtl::OUString const & Name)
590 : : throw (css::uno::RuntimeException)
591 : : {
592 : : assert(thisIs(IS_GROUP));
593 [ # # ]: 0 : osl::MutexGuard g(*lock_);
594 [ # # ][ # # ]: 0 : return getChild(Name).is();
595 : : }
596 : :
597 : 130 : rtl::OUString Access::getHierarchicalName() throw (css::uno::RuntimeException) {
598 : : assert(thisIs(IS_ANY));
599 [ + - ]: 130 : osl::MutexGuard g(*lock_);
600 [ + - ]: 130 : checkLocalizedPropertyAccess();
601 : : // For backwards compatibility, return an absolute path representation where
602 : : // available:
603 : 130 : rtl::OUStringBuffer path;
604 [ + - ]: 130 : rtl::Reference< RootAccess > root(getRootAccess());
605 [ + - ]: 130 : if (root.is()) {
606 [ + - ][ + - ]: 130 : path.append(root->getAbsolutePathRepresentation());
607 : : }
608 [ + - ]: 130 : rtl::OUString rel(getRelativePathRepresentation());
609 [ + - ][ + - ]: 130 : if (path.getLength() != 0 && !rel.isEmpty()) {
[ + - ]
610 [ + - ]: 130 : path.append(sal_Unicode('/'));
611 : : }
612 [ + - ]: 130 : path.append(rel);
613 [ + - ][ + - ]: 130 : return path.makeStringAndClear();
614 : : }
615 : :
616 : 0 : rtl::OUString Access::composeHierarchicalName(
617 : : rtl::OUString const & aRelativeName)
618 : : throw (
619 : : css::lang::IllegalArgumentException, css::lang::NoSupportException,
620 : : css::uno::RuntimeException)
621 : : {
622 : : assert(thisIs(IS_ANY));
623 [ # # ]: 0 : osl::MutexGuard g(*lock_);
624 [ # # ]: 0 : checkLocalizedPropertyAccess();
625 [ # # ][ # # ]: 0 : if (aRelativeName.isEmpty() || aRelativeName[0] == '/') {
[ # # ]
626 : : throw css::lang::IllegalArgumentException(
627 : : rtl::OUString(
628 : : RTL_CONSTASCII_USTRINGPARAM(
629 : : "configmgr composeHierarchicalName inappropriate relative"
630 : : " name")),
631 [ # # ][ # # ]: 0 : static_cast< cppu::OWeakObject * >(this), -1);
[ # # ]
632 : : }
633 [ # # ][ # # ]: 0 : rtl::OUStringBuffer path(getRelativePathRepresentation());
634 [ # # ]: 0 : if (path.getLength() != 0) {
635 [ # # ]: 0 : path.append(sal_Unicode('/'));
636 : : }
637 [ # # ]: 0 : path.append(aRelativeName);
638 [ # # ][ # # ]: 0 : return path.makeStringAndClear();
639 : : }
640 : :
641 : 302 : rtl::OUString Access::getName() throw (css::uno::RuntimeException) {
642 : : assert(thisIs(IS_ANY));
643 [ + - ]: 302 : osl::MutexGuard g(*lock_);
644 [ + - ]: 302 : checkLocalizedPropertyAccess();
645 [ + - ][ + - ]: 302 : return getNameInternal();
646 : : }
647 : :
648 : 0 : void Access::setName(rtl::OUString const & aName)
649 : : throw (css::uno::RuntimeException)
650 : : {
651 : : assert(thisIs(IS_ANY));
652 [ # # ]: 0 : Broadcaster bc;
653 : : {
654 [ # # ]: 0 : osl::MutexGuard g(*lock_);
655 [ # # ]: 0 : checkLocalizedPropertyAccess();
656 [ # # ]: 0 : checkFinalized();
657 [ # # ]: 0 : Modifications localMods;
658 [ # # ][ # # ]: 0 : switch (getNode()->kind()) {
[ # # ]
[ # # # ]
659 : : case Node::KIND_GROUP:
660 : : case Node::KIND_SET:
661 : : {
662 [ # # ]: 0 : rtl::Reference< Access > parent(getParentAccess());
663 [ # # ]: 0 : if (parent.is()) {
664 [ # # ]: 0 : rtl::Reference< Node > node(getNode());
665 [ # # ][ # # ]: 0 : if (! node->getTemplateName().isEmpty()) {
666 : : rtl::Reference< ChildAccess > other(
667 [ # # ]: 0 : parent->getChild(aName));
668 [ # # ]: 0 : if (other.get() == this) {
669 : : break;
670 : : }
671 [ # # ]: 0 : if (node->getMandatory() == Data::NO_LAYER &&
[ # # # # ]
[ # # ]
672 [ # # ][ # # ]: 0 : !(other.is() && other->isFinalized()))
673 : : {
674 [ # # ]: 0 : rtl::Reference< RootAccess > root(getRootAccess());
675 : : rtl::Reference< ChildAccess > childAccess(
676 [ # # ]: 0 : dynamic_cast< ChildAccess * >(this));
677 [ # # ][ # # ]: 0 : localMods.add(getRelativePath());
678 : : // unbind() modifies the parent chain that
679 : : // markChildAsModified() walks, so order is
680 : : // important:
681 [ # # ]: 0 : parent->markChildAsModified(childAccess);
682 : : //TODO: must not throw
683 : 0 : childAccess->unbind(); // must not throw
684 [ # # ]: 0 : if (other.is()) {
685 : 0 : other->unbind(); // must not throw
686 : : }
687 : 0 : childAccess->bind(root, parent, aName);
688 : : // must not throw
689 [ # # ]: 0 : parent->markChildAsModified(childAccess);
690 : : //TODO: must not throw
691 [ # # ][ # # ]: 0 : localMods.add(getRelativePath());
692 : 0 : break;
693 [ # # ]: 0 : }
694 [ # # ][ # # ]: 0 : }
695 [ # # ]: 0 : }
696 : : }
697 : : // fall through
698 : : case Node::KIND_LOCALIZED_PROPERTY:
699 : : // renaming a property could only work for an extension property,
700 : : // but a localized property is never an extension property
701 : : throw css::uno::RuntimeException(
702 : : rtl::OUString(
703 : : RTL_CONSTASCII_USTRINGPARAM(
704 : : "configmgr setName inappropriate node")),
705 [ # # ][ # # ]: 0 : static_cast< cppu::OWeakObject * >(this));
[ # # ]
706 : : default:
707 : : assert(false); // this cannot happen
708 : 0 : break;
709 : : }
710 [ # # ][ # # ]: 0 : getNotificationRoot()->initBroadcaster(localMods.getRoot(), &bc);
[ # # ][ # # ]
[ # # ]
711 : : }
712 [ # # ]: 0 : bc.send();
713 : 0 : }
714 : :
715 : 24962 : css::beans::Property Access::getAsProperty() throw (css::uno::RuntimeException)
716 : : {
717 : : assert(thisIs(IS_ANY));
718 [ + - ]: 24962 : osl::MutexGuard g(*lock_);
719 [ + - ]: 24962 : checkLocalizedPropertyAccess();
720 [ + - ][ + - ]: 24962 : return asProperty();
721 : : }
722 : :
723 : 14754 : css::uno::Reference< css::beans::XPropertySetInfo > Access::getPropertySetInfo()
724 : : throw (css::uno::RuntimeException)
725 : : {
726 : : assert(thisIs(IS_GROUP));
727 : 14754 : return this;
728 : : }
729 : :
730 : 61848 : void Access::setPropertyValue(
731 : : rtl::OUString const & aPropertyName, css::uno::Any const & aValue)
732 : : throw (
733 : : css::beans::UnknownPropertyException, css::beans::PropertyVetoException,
734 : : css::lang::IllegalArgumentException, css::lang::WrappedTargetException,
735 : : css::uno::RuntimeException)
736 : : {
737 : : assert(thisIs(IS_GROUP));
738 [ + - ]: 61848 : Broadcaster bc;
739 : : {
740 [ + - ]: 61848 : osl::MutexGuard g(*lock_);
741 [ + - ][ + - ]: 61848 : if (!getRootAccess()->isUpdate()) {
[ - + ]
742 : : throw css::uno::RuntimeException(
743 : : rtl::OUString(
744 : : RTL_CONSTASCII_USTRINGPARAM(
745 : : "configmgr setPropertyValue on non-update access")),
746 [ # # ][ # # ]: 0 : static_cast< cppu::OWeakObject * >(this));
[ # # ]
747 : : }
748 [ + - ]: 61848 : Modifications localMods;
749 [ + - ][ - + ]: 61848 : if (!setChildProperty(aPropertyName, aValue, &localMods)) {
750 : : throw css::beans::UnknownPropertyException(
751 [ # # ][ # # ]: 0 : aPropertyName, static_cast< cppu::OWeakObject * >(this));
752 : : }
753 [ + - ][ + - ]: 61848 : getNotificationRoot()->initBroadcaster(localMods.getRoot(), &bc);
[ + - ][ + - ]
[ + - ]
754 : : }
755 [ + - ]: 61848 : bc.send();
756 : 61848 : }
757 : :
758 : 195798 : css::uno::Any Access::getPropertyValue(rtl::OUString const & PropertyName)
759 : : throw (
760 : : css::beans::UnknownPropertyException, css::lang::WrappedTargetException,
761 : : css::uno::RuntimeException)
762 : : {
763 : : assert(thisIs(IS_GROUP));
764 [ + - ]: 195798 : osl::MutexGuard g(*lock_);
765 [ + - ]: 195798 : rtl::Reference< ChildAccess > child(getChild(PropertyName));
766 [ - + ]: 195798 : if (!child.is()) {
767 : : throw css::beans::UnknownPropertyException(
768 [ # # ][ # # ]: 0 : PropertyName, static_cast< cppu::OWeakObject * >(this));
769 : : }
770 [ + - ][ + - ]: 195798 : return child->asValue();
771 : : }
772 : :
773 : 9 : void Access::addPropertyChangeListener(
774 : : rtl::OUString const & aPropertyName,
775 : : css::uno::Reference< css::beans::XPropertyChangeListener > const &
776 : : xListener)
777 : : throw (
778 : : css::beans::UnknownPropertyException, css::lang::WrappedTargetException,
779 : : css::uno::RuntimeException)
780 : : {
781 : : assert(thisIs(IS_GROUP));
782 : : {
783 [ + - ]: 9 : osl::MutexGuard g(*lock_);
784 [ - + ]: 9 : if (!xListener.is()) {
785 : : throw css::uno::RuntimeException(
786 : : rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("null listener")),
787 [ # # ][ # # ]: 0 : static_cast< cppu::OWeakObject * >(this));
[ # # ]
788 : : }
789 [ + - ]: 9 : checkKnownProperty(aPropertyName);
790 [ + - ]: 9 : if (!disposed_) {
791 [ + - ][ + - ]: 9 : propertyChangeListeners_[aPropertyName].insert(xListener);
792 : 9 : return;
793 [ + - ][ - + ]: 9 : }
794 : : }
795 : : try {
796 [ # # ]: 9 : xListener->disposing(
797 [ # # ][ # # ]: 0 : css::lang::EventObject(static_cast< cppu::OWeakObject * >(this)));
[ # # ][ # # ]
[ # # ]
798 : 0 : } catch (css::lang::DisposedException &) {}
799 : : }
800 : :
801 : 0 : void Access::removePropertyChangeListener(
802 : : rtl::OUString const & aPropertyName,
803 : : css::uno::Reference< css::beans::XPropertyChangeListener > const &
804 : : aListener)
805 : : throw (
806 : : css::beans::UnknownPropertyException, css::lang::WrappedTargetException,
807 : : css::uno::RuntimeException)
808 : : {
809 : : assert(thisIs(IS_GROUP));
810 [ # # ]: 0 : osl::MutexGuard g(*lock_);
811 [ # # ]: 0 : checkKnownProperty(aPropertyName);
812 : : PropertyChangeListeners::iterator i(
813 [ # # ]: 0 : propertyChangeListeners_.find(aPropertyName));
814 [ # # ]: 0 : if (i != propertyChangeListeners_.end()) {
815 [ # # ]: 0 : PropertyChangeListenersElement::iterator j(i->second.find(aListener));
816 [ # # ]: 0 : if (j != i->second.end()) {
817 [ # # ]: 0 : i->second.erase(j);
818 [ # # ]: 0 : if (i->second.empty()) {
819 [ # # ]: 0 : propertyChangeListeners_.erase(i);
820 : : }
821 : : }
822 [ # # ]: 0 : }
823 : 0 : }
824 : :
825 : 0 : void Access::addVetoableChangeListener(
826 : : rtl::OUString const & PropertyName,
827 : : css::uno::Reference< css::beans::XVetoableChangeListener > const &
828 : : aListener)
829 : : throw (
830 : : css::beans::UnknownPropertyException, css::lang::WrappedTargetException,
831 : : css::uno::RuntimeException)
832 : : {
833 : : assert(thisIs(IS_GROUP));
834 : : {
835 [ # # ]: 0 : osl::MutexGuard g(*lock_);
836 [ # # ]: 0 : if (!aListener.is()) {
837 : : throw css::uno::RuntimeException(
838 : : rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("null listener")),
839 [ # # ][ # # ]: 0 : static_cast< cppu::OWeakObject * >(this));
[ # # ]
840 : : }
841 [ # # ]: 0 : checkKnownProperty(PropertyName);
842 [ # # ]: 0 : if (!disposed_) {
843 [ # # ][ # # ]: 0 : vetoableChangeListeners_[PropertyName].insert(aListener);
844 : : //TODO: actually call vetoableChangeListeners_
845 : 0 : return;
846 [ # # ][ # # ]: 0 : }
847 : : }
848 : : try {
849 [ # # ]: 0 : aListener->disposing(
850 [ # # ][ # # ]: 0 : css::lang::EventObject(static_cast< cppu::OWeakObject * >(this)));
[ # # ][ # # ]
[ # # ]
851 : 0 : } catch (css::lang::DisposedException &) {}
852 : : }
853 : :
854 : 0 : void Access::removeVetoableChangeListener(
855 : : rtl::OUString const & PropertyName,
856 : : css::uno::Reference< css::beans::XVetoableChangeListener > const &
857 : : aListener)
858 : : throw (
859 : : css::beans::UnknownPropertyException, css::lang::WrappedTargetException,
860 : : css::uno::RuntimeException)
861 : : {
862 : : assert(thisIs(IS_GROUP));
863 [ # # ]: 0 : osl::MutexGuard g(*lock_);
864 [ # # ]: 0 : checkKnownProperty(PropertyName);
865 : : VetoableChangeListeners::iterator i(
866 [ # # ]: 0 : vetoableChangeListeners_.find(PropertyName));
867 [ # # ]: 0 : if (i != vetoableChangeListeners_.end()) {
868 [ # # ]: 0 : VetoableChangeListenersElement::iterator j(i->second.find(aListener));
869 [ # # ]: 0 : if (j != i->second.end()) {
870 [ # # ]: 0 : i->second.erase(j);
871 [ # # ]: 0 : if (i->second.empty()) {
872 [ # # ]: 0 : vetoableChangeListeners_.erase(i);
873 : : }
874 : : }
875 [ # # ]: 0 : }
876 : 0 : }
877 : :
878 : 0 : void Access::setPropertyValues(
879 : : css::uno::Sequence< rtl::OUString > const & aPropertyNames,
880 : : css::uno::Sequence< css::uno::Any > const & aValues)
881 : : throw (
882 : : css::beans::PropertyVetoException, css::lang::IllegalArgumentException,
883 : : css::lang::WrappedTargetException, css::uno::RuntimeException)
884 : : {
885 : : assert(thisIs(IS_GROUP));
886 [ # # ]: 0 : Broadcaster bc;
887 : : {
888 [ # # ]: 0 : osl::MutexGuard g(*lock_);
889 [ # # ][ # # ]: 0 : if (!getRootAccess()->isUpdate()) {
[ # # ]
890 : : throw css::uno::RuntimeException(
891 : : rtl::OUString(
892 : : RTL_CONSTASCII_USTRINGPARAM(
893 : : "configmgr setPropertyValues on non-update access")),
894 [ # # ][ # # ]: 0 : static_cast< cppu::OWeakObject * >(this));
[ # # ]
895 : : }
896 [ # # ]: 0 : if (aPropertyNames.getLength() != aValues.getLength()) {
897 : : throw css::lang::IllegalArgumentException(
898 : : rtl::OUString(
899 : : RTL_CONSTASCII_USTRINGPARAM(
900 : : "configmgr setPropertyValues: aPropertyNames/aValues of"
901 : : " different length")),
902 [ # # ][ # # ]: 0 : static_cast< cppu::OWeakObject * >(this), -1);
[ # # ]
903 : : }
904 [ # # ]: 0 : Modifications localMods;
905 [ # # ]: 0 : for (sal_Int32 i = 0; i < aPropertyNames.getLength(); ++i) {
906 [ # # ][ # # ]: 0 : if (!setChildProperty(aPropertyNames[i], aValues[i], &localMods)) {
907 : : throw css::lang::IllegalArgumentException(
908 : : rtl::OUString(
909 : : RTL_CONSTASCII_USTRINGPARAM(
910 : : "configmgr setPropertyValues inappropriate property"
911 : : " name")),
912 [ # # ][ # # ]: 0 : static_cast< cppu::OWeakObject * >(this), -1);
[ # # ]
913 : : }
914 : : }
915 [ # # ][ # # ]: 0 : getNotificationRoot()->initBroadcaster(localMods.getRoot(), &bc);
[ # # ][ # # ]
[ # # ]
916 : : }
917 [ # # ]: 0 : bc.send();
918 : 0 : }
919 : :
920 : 0 : css::uno::Sequence< css::uno::Any > Access::getPropertyValues(
921 : : css::uno::Sequence< rtl::OUString > const & aPropertyNames)
922 : : throw (css::uno::RuntimeException)
923 : : {
924 : : assert(thisIs(IS_GROUP));
925 [ # # ]: 0 : osl::MutexGuard g(*lock_);
926 [ # # ]: 0 : css::uno::Sequence< css::uno::Any > vals(aPropertyNames.getLength());
927 [ # # ]: 0 : for (sal_Int32 i = 0; i < aPropertyNames.getLength(); ++i) {
928 [ # # ]: 0 : rtl::Reference< ChildAccess > child(getChild(aPropertyNames[i]));
929 [ # # ]: 0 : if (!child.is()) {
930 : : throw css::uno::RuntimeException(
931 : : rtl::OUString(
932 : : RTL_CONSTASCII_USTRINGPARAM(
933 : : "configmgr getPropertyValues inappropriate property"
934 : : " name")),
935 [ # # ][ # # ]: 0 : static_cast< cppu::OWeakObject * >(this));
[ # # ]
936 : : }
937 [ # # ][ # # ]: 0 : vals[i] = child->asValue();
938 : 0 : }
939 [ # # ]: 0 : return vals;
940 : : }
941 : :
942 : 0 : void Access::addPropertiesChangeListener(
943 : : css::uno::Sequence< rtl::OUString > const &,
944 : : css::uno::Reference< css::beans::XPropertiesChangeListener > const &
945 : : xListener)
946 : : throw (css::uno::RuntimeException)
947 : : {
948 : : assert(thisIs(IS_GROUP));
949 : : {
950 [ # # ]: 0 : osl::MutexGuard g(*lock_);
951 [ # # ]: 0 : if (!xListener.is()) {
952 : : throw css::uno::RuntimeException(
953 : : rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("null listener")),
954 [ # # ][ # # ]: 0 : static_cast< cppu::OWeakObject * >(this));
[ # # ]
955 : : }
956 [ # # ]: 0 : if (!disposed_) {
957 [ # # ]: 0 : propertiesChangeListeners_.insert(xListener);
958 : 0 : return;
959 [ # # ][ # # ]: 0 : }
960 : : }
961 : : try {
962 [ # # ]: 0 : xListener->disposing(
963 [ # # ][ # # ]: 0 : css::lang::EventObject(static_cast< cppu::OWeakObject * >(this)));
[ # # ][ # # ]
[ # # ]
964 : 0 : } catch (css::lang::DisposedException &) {}
965 : : }
966 : :
967 : 0 : void Access::removePropertiesChangeListener(
968 : : css::uno::Reference< css::beans::XPropertiesChangeListener > const &
969 : : xListener)
970 : : throw (css::uno::RuntimeException)
971 : : {
972 : : assert(thisIs(IS_GROUP));
973 [ # # ]: 0 : osl::MutexGuard g(*lock_);
974 : : PropertiesChangeListeners::iterator i(
975 [ # # ]: 0 : propertiesChangeListeners_.find(xListener));
976 [ # # ]: 0 : if (i != propertiesChangeListeners_.end()) {
977 [ # # ]: 0 : propertiesChangeListeners_.erase(i);
978 [ # # ]: 0 : }
979 : 0 : }
980 : :
981 : 0 : void Access::firePropertiesChangeEvent(
982 : : css::uno::Sequence< rtl::OUString > const & aPropertyNames,
983 : : css::uno::Reference< css::beans::XPropertiesChangeListener > const &
984 : : xListener)
985 : : throw (css::uno::RuntimeException)
986 : : {
987 : : assert(thisIs(IS_GROUP));
988 : : css::uno::Sequence< css::beans::PropertyChangeEvent > events(
989 [ # # ]: 0 : aPropertyNames.getLength());
990 [ # # ]: 0 : for (sal_Int32 i = 0; i < events.getLength(); ++i) {
991 [ # # ][ # # ]: 0 : events[i].Source = static_cast< cppu::OWeakObject * >(this);
992 [ # # ]: 0 : events[i].PropertyName = aPropertyNames[i];
993 [ # # ]: 0 : events[i].Further = false;
994 [ # # ]: 0 : events[i].PropertyHandle = -1;
995 : : }
996 [ # # ][ # # ]: 0 : xListener->propertiesChange(events);
[ # # ]
997 : 0 : }
998 : :
999 : : css::uno::Reference< css::beans::XHierarchicalPropertySetInfo >
1000 : 0 : Access::getHierarchicalPropertySetInfo() throw (css::uno::RuntimeException) {
1001 : : assert(thisIs(IS_GROUP));
1002 : 0 : return this;
1003 : : }
1004 : :
1005 : 0 : void Access::setHierarchicalPropertyValue(
1006 : : rtl::OUString const & aHierarchicalPropertyName,
1007 : : css::uno::Any const & aValue)
1008 : : throw (
1009 : : css::beans::UnknownPropertyException, css::beans::PropertyVetoException,
1010 : : css::lang::IllegalArgumentException, css::lang::WrappedTargetException,
1011 : : css::uno::RuntimeException)
1012 : : {
1013 : : assert(thisIs(IS_GROUP));
1014 [ # # ]: 0 : Broadcaster bc;
1015 : : {
1016 [ # # ]: 0 : osl::MutexGuard g(*lock_);
1017 [ # # ][ # # ]: 0 : if (!getRootAccess()->isUpdate()) {
[ # # ]
1018 : : throw css::uno::RuntimeException(
1019 : : rtl::OUString(
1020 : : RTL_CONSTASCII_USTRINGPARAM(
1021 : : "configmgr setHierarchicalPropertyName on non-update"
1022 : : " access")),
1023 [ # # ][ # # ]: 0 : static_cast< cppu::OWeakObject * >(this));
[ # # ]
1024 : : }
1025 : : rtl::Reference< ChildAccess > child(
1026 [ # # ]: 0 : getSubChild(aHierarchicalPropertyName));
1027 [ # # ]: 0 : if (!child.is()) {
1028 : : throw css::beans::UnknownPropertyException(
1029 : : aHierarchicalPropertyName,
1030 [ # # ][ # # ]: 0 : static_cast< cppu::OWeakObject * >(this));
1031 : : }
1032 [ # # ]: 0 : child->checkFinalized();
1033 [ # # ]: 0 : Modifications localMods;
1034 [ # # ]: 0 : child->setProperty(aValue, &localMods);
1035 [ # # ][ # # ]: 0 : getNotificationRoot()->initBroadcaster(localMods.getRoot(), &bc);
[ # # ][ # # ]
[ # # ]
1036 : : }
1037 [ # # ]: 0 : bc.send();
1038 : 0 : }
1039 : :
1040 : 0 : css::uno::Any Access::getHierarchicalPropertyValue(
1041 : : rtl::OUString const & aHierarchicalPropertyName)
1042 : : throw (
1043 : : css::beans::UnknownPropertyException,
1044 : : css::lang::IllegalArgumentException, css::lang::WrappedTargetException,
1045 : : css::uno::RuntimeException)
1046 : : {
1047 : : assert(thisIs(IS_GROUP));
1048 [ # # ]: 0 : osl::MutexGuard g(*lock_);
1049 [ # # ]: 0 : rtl::Reference< ChildAccess > child(getSubChild(aHierarchicalPropertyName));
1050 [ # # ]: 0 : if (!child.is()) {
1051 : : throw css::beans::UnknownPropertyException(
1052 : : aHierarchicalPropertyName,
1053 [ # # ][ # # ]: 0 : static_cast< cppu::OWeakObject * >(this));
1054 : : }
1055 [ # # ][ # # ]: 0 : return child->asValue();
1056 : : }
1057 : :
1058 : 0 : void Access::setHierarchicalPropertyValues(
1059 : : css::uno::Sequence< rtl::OUString > const & aHierarchicalPropertyNames,
1060 : : css::uno::Sequence< css::uno::Any > const & Values)
1061 : : throw (
1062 : : css::beans::PropertyVetoException, css::lang::IllegalArgumentException,
1063 : : css::lang::WrappedTargetException, css::uno::RuntimeException)
1064 : : {
1065 : : assert(thisIs(IS_GROUP));
1066 [ # # ]: 0 : Broadcaster bc;
1067 : : {
1068 [ # # ]: 0 : osl::MutexGuard g(*lock_);
1069 [ # # ][ # # ]: 0 : if (!getRootAccess()->isUpdate()) {
[ # # ]
1070 : : throw css::uno::RuntimeException(
1071 : : rtl::OUString(
1072 : : RTL_CONSTASCII_USTRINGPARAM(
1073 : : "configmgr setPropertyValues on non-update access")),
1074 [ # # ][ # # ]: 0 : static_cast< cppu::OWeakObject * >(this));
[ # # ]
1075 : : }
1076 [ # # ]: 0 : if (aHierarchicalPropertyNames.getLength() != Values.getLength()) {
1077 : : throw css::lang::IllegalArgumentException(
1078 : : rtl::OUString(
1079 : : RTL_CONSTASCII_USTRINGPARAM(
1080 : : "configmgr setHierarchicalPropertyValues:"
1081 : : " aHierarchicalPropertyNames/Values of different"
1082 : : " length")),
1083 [ # # ][ # # ]: 0 : static_cast< cppu::OWeakObject * >(this), -1);
[ # # ]
1084 : : }
1085 [ # # ]: 0 : Modifications localMods;
1086 [ # # ]: 0 : for (sal_Int32 i = 0; i < aHierarchicalPropertyNames.getLength(); ++i) {
1087 : : rtl::Reference< ChildAccess > child(
1088 [ # # ]: 0 : getSubChild(aHierarchicalPropertyNames[i]));
1089 [ # # ]: 0 : if (!child.is()) {
1090 : : throw css::lang::IllegalArgumentException(
1091 : : rtl::OUString(
1092 : : RTL_CONSTASCII_USTRINGPARAM(
1093 : : "configmgr setHierarchicalPropertyValues"
1094 : : " inappropriate property name")),
1095 [ # # ][ # # ]: 0 : static_cast< cppu::OWeakObject * >(this), -1);
[ # # ]
1096 : : }
1097 [ # # ]: 0 : child->checkFinalized();
1098 [ # # ]: 0 : child->setProperty(Values[i], &localMods);
1099 : 0 : }
1100 [ # # ][ # # ]: 0 : getNotificationRoot()->initBroadcaster(localMods.getRoot(), &bc);
[ # # ][ # # ]
[ # # ]
1101 : : }
1102 [ # # ]: 0 : bc.send();
1103 : 0 : }
1104 : :
1105 : 0 : css::uno::Sequence< css::uno::Any > Access::getHierarchicalPropertyValues(
1106 : : css::uno::Sequence< rtl::OUString > const & aHierarchicalPropertyNames)
1107 : : throw (
1108 : : css::lang::IllegalArgumentException, css::lang::WrappedTargetException,
1109 : : css::uno::RuntimeException)
1110 : : {
1111 : : assert(thisIs(IS_GROUP));
1112 [ # # ]: 0 : osl::MutexGuard g(*lock_);
1113 : : css::uno::Sequence< css::uno::Any > vals(
1114 [ # # ]: 0 : aHierarchicalPropertyNames.getLength());
1115 [ # # ]: 0 : for (sal_Int32 i = 0; i < aHierarchicalPropertyNames.getLength(); ++i) {
1116 : : rtl::Reference< ChildAccess > child(
1117 [ # # ]: 0 : getSubChild(aHierarchicalPropertyNames[i]));
1118 [ # # ]: 0 : if (!child.is()) {
1119 : : throw css::lang::IllegalArgumentException(
1120 : : rtl::OUString(
1121 : : RTL_CONSTASCII_USTRINGPARAM(
1122 : : "configmgr getHierarchicalPropertyValues inappropriate"
1123 : : " hierarchical property name")),
1124 [ # # ][ # # ]: 0 : static_cast< cppu::OWeakObject * >(this), -1);
[ # # ]
1125 : : }
1126 [ # # ][ # # ]: 0 : vals[i] = child->asValue();
1127 : 0 : }
1128 [ # # ]: 0 : return vals;
1129 : : }
1130 : :
1131 : 0 : css::beans::Property Access::getPropertyByHierarchicalName(
1132 : : rtl::OUString const & aHierarchicalName)
1133 : : throw (css::beans::UnknownPropertyException, css::uno::RuntimeException)
1134 : : {
1135 : : assert(thisIs(IS_GROUP));
1136 [ # # ]: 0 : osl::MutexGuard g(*lock_);
1137 [ # # ]: 0 : rtl::Reference< ChildAccess > child(getSubChild(aHierarchicalName));
1138 [ # # ]: 0 : if (!child.is()) {
1139 : : throw css::beans::UnknownPropertyException(
1140 [ # # ][ # # ]: 0 : aHierarchicalName, static_cast< cppu::OWeakObject * >(this));
1141 : : }
1142 [ # # ][ # # ]: 0 : return child->asProperty();
1143 : : }
1144 : :
1145 : 0 : sal_Bool Access::hasPropertyByHierarchicalName(
1146 : : rtl::OUString const & aHierarchicalName)
1147 : : throw (css::uno::RuntimeException)
1148 : : {
1149 : : assert(thisIs(IS_GROUP));
1150 [ # # ]: 0 : osl::MutexGuard g(*lock_);
1151 [ # # ][ # # ]: 0 : return getSubChild(aHierarchicalName).is();
1152 : : }
1153 : :
1154 : 28603 : void Access::replaceByName(
1155 : : rtl::OUString const & aName, css::uno::Any const & aElement)
1156 : : throw (
1157 : : css::lang::IllegalArgumentException,
1158 : : css::container::NoSuchElementException,
1159 : : css::lang::WrappedTargetException, css::uno::RuntimeException)
1160 : : {
1161 : : assert(thisIs(IS_UPDATE));
1162 [ + - ]: 28603 : Broadcaster bc;
1163 : : {
1164 [ + - ]: 28603 : osl::MutexGuard g(*lock_);
1165 [ + - ]: 28603 : checkLocalizedPropertyAccess();
1166 [ + - ]: 28603 : rtl::Reference< ChildAccess > child(getChild(aName));
1167 [ - + ]: 28603 : if (!child.is()) {
1168 : : throw css::container::NoSuchElementException(
1169 [ # # ][ # # ]: 0 : aName, static_cast< cppu::OWeakObject * >(this));
1170 : : }
1171 [ + - ]: 28603 : child->checkFinalized();
1172 [ + - ]: 28603 : Modifications localMods;
1173 [ + - ][ + - ]: 28603 : switch (getNode()->kind()) {
[ + - ]
[ + - - ]
1174 : : case Node::KIND_LOCALIZED_PROPERTY:
1175 : : case Node::KIND_GROUP:
1176 [ + - ]: 28603 : child->setProperty(aElement, &localMods);
1177 : 28603 : break;
1178 : : case Node::KIND_SET:
1179 : : {
1180 : : rtl::Reference< ChildAccess > freeAcc(
1181 [ # # ]: 0 : getFreeSetMember(aElement));
1182 [ # # ]: 0 : rtl::Reference< RootAccess > root(getRootAccess());
1183 [ # # ][ # # ]: 0 : localMods.add(child->getRelativePath());
1184 : 0 : child->unbind(); // must not throw
1185 : 0 : freeAcc->bind(root, this, aName); // must not throw
1186 [ # # ]: 0 : markChildAsModified(freeAcc); //TODO: must not throw
1187 : : }
1188 : 0 : break;
1189 : : default:
1190 : : assert(false); // this cannot happen
1191 : 0 : break;
1192 : : }
1193 [ + - ][ + - ]: 28603 : getNotificationRoot()->initBroadcaster(localMods.getRoot(), &bc);
[ + - ][ + - ]
[ + - ]
1194 : : }
1195 [ + - ]: 28603 : bc.send();
1196 : 28603 : }
1197 : :
1198 : 11874 : void Access::insertByName(
1199 : : rtl::OUString const & aName, css::uno::Any const & aElement)
1200 : : throw (
1201 : : css::lang::IllegalArgumentException,
1202 : : css::container::ElementExistException,
1203 : : css::lang::WrappedTargetException, css::uno::RuntimeException)
1204 : : {
1205 : : assert(thisIs(IS_EXTENSIBLE|IS_UPDATE));
1206 [ + - ]: 11874 : Broadcaster bc;
1207 : : {
1208 [ + - ]: 11874 : osl::MutexGuard g(*lock_);
1209 [ + - ]: 11874 : checkLocalizedPropertyAccess();
1210 [ + - ]: 11874 : checkFinalized();
1211 [ + - ][ + + ]: 11874 : if (getChild(aName).is()) {
1212 : : throw css::container::ElementExistException(
1213 [ + - ][ + - ]: 6 : aName, static_cast< cppu::OWeakObject * >(this));
1214 : : }
1215 [ + - ]: 11868 : Modifications localMods;
1216 [ + - ][ + - ]: 11868 : switch (getNode()->kind()) {
[ + - ]
[ - + + - ]
1217 : : case Node::KIND_LOCALIZED_PROPERTY:
1218 [ # # ]: 0 : insertLocalizedValueChild(aName, aElement, &localMods);
1219 : 0 : break;
1220 : : case Node::KIND_GROUP:
1221 : : {
1222 [ + - ]: 10030 : checkValue(aElement, TYPE_ANY, true);
1223 : : rtl::Reference< ChildAccess > child(
1224 : : new ChildAccess(
1225 : 10030 : components_, getRootAccess(), this, aName,
1226 : : new PropertyNode(
1227 [ + - ][ + - ]: 10030 : Data::NO_LAYER, TYPE_ANY, true, aElement, true)));
[ + - ][ + - ]
[ + - ][ + - ]
1228 [ + - ]: 10030 : markChildAsModified(child);
1229 [ + - ][ + - ]: 10030 : localMods.add(child->getRelativePath());
1230 : : }
1231 : 10030 : break;
1232 : : case Node::KIND_SET:
1233 : : {
1234 : : rtl::Reference< ChildAccess > freeAcc(
1235 [ + - ]: 1838 : getFreeSetMember(aElement));
1236 [ + - ]: 1838 : freeAcc->bind(getRootAccess(), this, aName); // must not throw
1237 [ + - ]: 1838 : markChildAsModified(freeAcc); //TODO: must not throw
1238 [ + - ][ + - ]: 1838 : localMods.add(freeAcc->getRelativePath());
1239 : : }
1240 : 1838 : break;
1241 : : default:
1242 : : assert(false); // this cannot happen
1243 : 0 : break;
1244 : : }
1245 [ + - ][ + - ]: 11874 : getNotificationRoot()->initBroadcaster(localMods.getRoot(), &bc);
[ + - ][ + - ]
[ + - ]
1246 : : }
1247 [ + - ]: 11874 : bc.send();
1248 : 11868 : }
1249 : :
1250 : 609 : void Access::removeByName(rtl::OUString const & aName)
1251 : : throw (
1252 : : css::container::NoSuchElementException,
1253 : : css::lang::WrappedTargetException, css::uno::RuntimeException)
1254 : : {
1255 : : assert(thisIs(IS_EXTENSIBLE|IS_UPDATE));
1256 [ + - ]: 609 : Broadcaster bc;
1257 : : {
1258 [ + - ]: 609 : osl::MutexGuard g(*lock_);
1259 [ + - ]: 609 : checkLocalizedPropertyAccess();
1260 [ + - ]: 609 : rtl::Reference< ChildAccess > child(getChild(aName));
1261 [ + + ][ + - ]: 1797 : if (!child.is() || child->isFinalized() ||
[ + - ][ - + ]
[ + + ]
1262 [ + - ][ + - ]: 1188 : child->getNode()->getMandatory() != Data::NO_LAYER)
[ + + ][ + - ]
[ # # ]
1263 : : {
1264 : : throw css::container::NoSuchElementException(
1265 [ + - ][ + - ]: 30 : aName, static_cast< cppu::OWeakObject * >(this));
1266 : : }
1267 [ + - ][ + - ]: 579 : if (getNode()->kind() == Node::KIND_GROUP) {
[ + - ][ - + ]
1268 [ # # ]: 0 : rtl::Reference< Node > p(child->getNode());
1269 [ # # ][ # # ]: 0 : if (p->kind() != Node::KIND_PROPERTY ||
[ # # ][ # # ]
1270 [ # # ][ # # ]: 0 : !dynamic_cast< PropertyNode * >(p.get())->isExtension())
1271 : : {
1272 : : throw css::container::NoSuchElementException(
1273 [ # # ][ # # ]: 0 : aName, static_cast< cppu::OWeakObject * >(this));
1274 [ # # ]: 0 : }
1275 : : }
1276 [ + - ]: 579 : Modifications localMods;
1277 [ + - ][ + - ]: 579 : localMods.add(child->getRelativePath());
1278 : : // unbind() modifies the parent chain that markChildAsModified() walks,
1279 : : // so order is important:
1280 [ + - ]: 579 : markChildAsModified(child); //TODO: must not throw
1281 : 579 : child->unbind();
1282 [ + - ][ + - ]: 609 : getNotificationRoot()->initBroadcaster(localMods.getRoot(), &bc);
[ + - ][ + - ]
[ + - ]
1283 : : }
1284 [ + - ]: 609 : bc.send();
1285 : 579 : }
1286 : :
1287 : 1838 : css::uno::Reference< css::uno::XInterface > Access::createInstance()
1288 : : throw (css::uno::Exception, css::uno::RuntimeException)
1289 : : {
1290 : : assert(thisIs(IS_SET|IS_UPDATE));
1291 : : rtl::OUString tmplName(
1292 [ + - ][ - + ]: 1838 : dynamic_cast< SetNode * >(getNode().get())->getDefaultTemplateName());
[ + - ][ + - ]
1293 : : rtl::Reference< Node > tmpl(
1294 [ + - ]: 1838 : components_.getTemplate(Data::NO_LAYER, tmplName));
1295 [ - + ]: 1838 : if (!tmpl.is()) {
1296 : : throw css::uno::Exception(
1297 : : (rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("unknown template ")) +
1298 : : tmplName),
1299 [ # # ][ # # ]: 0 : static_cast< cppu::OWeakObject * >(this));
[ # # ]
1300 : : }
1301 [ + - ]: 1838 : rtl::Reference< Node > node(tmpl->clone(true));
1302 [ + - ]: 1838 : node->setLayer(Data::NO_LAYER);
1303 : : return static_cast< cppu::OWeakObject * >(
1304 [ + - ][ + - ]: 1838 : new ChildAccess(components_, getRootAccess(), node));
[ + - ][ + - ]
[ + - ]
1305 : : }
1306 : :
1307 : 0 : css::uno::Reference< css::uno::XInterface > Access::createInstanceWithArguments(
1308 : : css::uno::Sequence< css::uno::Any > const & aArguments)
1309 : : throw (css::uno::Exception, css::uno::RuntimeException)
1310 : : {
1311 : : assert(thisIs(IS_SET|IS_UPDATE));
1312 [ # # ]: 0 : if (aArguments.getLength() != 0) {
1313 : : throw css::uno::Exception(
1314 : : rtl::OUString(
1315 : : RTL_CONSTASCII_USTRINGPARAM(
1316 : : "configuration SimpleSetUpdate createInstanceWithArguments"
1317 : : " must not specify any arguments")),
1318 [ # # ][ # # ]: 0 : static_cast< cppu::OWeakObject * >(this));
[ # # ]
1319 : : }
1320 : 0 : return createInstance();
1321 : : }
1322 : :
1323 : 5006956 : Access::Access(Components & components):
1324 [ + - ][ + - ]: 5006956 : components_(components), disposed_(false)
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ][ + - ]
1325 : : {
1326 [ + - ][ + - ]: 5006956 : lock_ = lock();
[ + - ]
1327 : 5006956 : }
1328 : :
1329 [ + - ][ - + ]: 5004751 : Access::~Access() {}
1330 : :
1331 : 0 : void Access::initDisposeBroadcaster(Broadcaster * broadcaster) {
1332 : : assert(broadcaster != 0);
1333 [ # # ]: 0 : for (DisposeListeners::iterator i(disposeListeners_.begin());
1334 : 0 : i != disposeListeners_.end(); ++i)
1335 : : {
1336 : : broadcaster->addDisposeNotification(
1337 : 0 : *i,
1338 [ # # ]: 0 : css::lang::EventObject(static_cast< cppu::OWeakObject * >(this)));
[ # # # # ]
[ # # ]
1339 : : }
1340 [ # # ]: 0 : for (ContainerListeners::iterator i(containerListeners_.begin());
1341 : 0 : i != containerListeners_.end(); ++i)
1342 : : {
1343 : : broadcaster->addDisposeNotification(
1344 [ # # ]: 0 : i->get(),
1345 [ # # ][ # # ]: 0 : css::lang::EventObject(static_cast< cppu::OWeakObject * >(this)));
[ # # ][ # # ]
[ # # ]
1346 : : }
1347 [ # # ]: 0 : for (PropertyChangeListeners::iterator i(propertyChangeListeners_.begin());
1348 : 0 : i != propertyChangeListeners_.end(); ++i)
1349 : : {
1350 [ # # ]: 0 : for (PropertyChangeListenersElement::iterator j(i->second.begin());
1351 : 0 : j != i->second.end(); ++j)
1352 : : {
1353 : : broadcaster->addDisposeNotification(
1354 [ # # ]: 0 : j->get(),
1355 : : css::lang::EventObject(
1356 [ # # ][ # # ]: 0 : static_cast< cppu::OWeakObject * >(this)));
[ # # ][ # # ]
[ # # ]
1357 : : }
1358 : : }
1359 [ # # ]: 0 : for (VetoableChangeListeners::iterator i(vetoableChangeListeners_.begin());
1360 : 0 : i != vetoableChangeListeners_.end(); ++i)
1361 : : {
1362 [ # # ]: 0 : for (VetoableChangeListenersElement::iterator j(i->second.begin());
1363 : 0 : j != i->second.end(); ++j)
1364 : : {
1365 : : broadcaster->addDisposeNotification(
1366 [ # # ]: 0 : j->get(),
1367 : : css::lang::EventObject(
1368 [ # # ][ # # ]: 0 : static_cast< cppu::OWeakObject * >(this)));
[ # # ][ # # ]
[ # # ]
1369 : : }
1370 : : }
1371 [ # # ]: 0 : for (PropertiesChangeListeners::iterator i(
1372 : 0 : propertiesChangeListeners_.begin());
1373 : 0 : i != propertiesChangeListeners_.end(); ++i)
1374 : : {
1375 : : broadcaster->addDisposeNotification(
1376 [ # # ]: 0 : i->get(),
1377 [ # # ][ # # ]: 0 : css::lang::EventObject(static_cast< cppu::OWeakObject * >(this)));
[ # # ][ # # ]
[ # # ]
1378 : : }
1379 : : //TODO: iterate over children w/ listeners (incl. unmodified ones):
1380 [ # # ]: 0 : for (ModifiedChildren::iterator i(modifiedChildren_.begin());
1381 : 0 : i != modifiedChildren_.end(); ++i)
1382 : : {
1383 [ # # ]: 0 : rtl::Reference< ChildAccess > child(getModifiedChild(i));
1384 [ # # ]: 0 : if (child.is()) {
1385 [ # # ]: 0 : child->initDisposeBroadcaster(broadcaster);
1386 : : }
1387 : 0 : }
1388 : 0 : }
1389 : :
1390 : 0 : void Access::clearListeners() throw() {
1391 : 0 : disposeListeners_.clear();
1392 : 0 : containerListeners_.clear();
1393 : 0 : propertyChangeListeners_.clear();
1394 : 0 : vetoableChangeListeners_.clear();
1395 : 0 : propertiesChangeListeners_.clear();
1396 : : //TODO: iterate over children w/ listeners (incl. unmodified ones):
1397 [ # # ]: 0 : for (ModifiedChildren::iterator i(modifiedChildren_.begin());
1398 : 0 : i != modifiedChildren_.end(); ++i)
1399 : : {
1400 [ # # ]: 0 : rtl::Reference< ChildAccess > child(getModifiedChild(i));
1401 [ # # ]: 0 : if (child.is()) {
1402 : 0 : child->clearListeners();
1403 : : }
1404 : 0 : }
1405 : 0 : }
1406 : :
1407 : 1157193 : css::uno::Any Access::queryInterface(css::uno::Type const & aType)
1408 : : throw (css::uno::RuntimeException)
1409 : : {
1410 : 1157193 : css::uno::Any res(OWeakObject::queryInterface(aType));
1411 [ + + ]: 1157193 : if (res.hasValue()) {
1412 : 42957 : return res;
1413 : : }
1414 : : res = cppu::queryInterface(
1415 : : aType, static_cast< css::lang::XTypeProvider * >(this),
1416 : : static_cast< css::lang::XServiceInfo * >(this),
1417 : : static_cast< css::lang::XComponent * >(this),
1418 : : static_cast< css::container::XHierarchicalNameAccess * >(this),
1419 : : static_cast< css::container::XContainer * >(this),
1420 : : static_cast< css::beans::XExactName * >(this),
1421 : : static_cast< css::container::XHierarchicalName * >(this),
1422 : : static_cast< css::container::XNamed * >(this),
1423 : : static_cast< css::beans::XProperty * >(this),
1424 : : static_cast< css::container::XElementAccess * >(this),
1425 [ + - ]: 1114236 : static_cast< css::container::XNameAccess * >(this));
1426 [ + + ]: 1114236 : if (res.hasValue()) {
1427 : 837390 : return res;
1428 : : }
1429 [ + - ][ + - ]: 276846 : if (getNode()->kind() == Node::KIND_GROUP) {
[ + - ][ + + ]
1430 : : res = cppu::queryInterface(
1431 : : aType, static_cast< css::beans::XPropertySetInfo * >(this),
1432 : : static_cast< css::beans::XPropertySet * >(this),
1433 : : static_cast< css::beans::XMultiPropertySet * >(this),
1434 : : static_cast< css::beans::XHierarchicalPropertySet * >(this),
1435 : : static_cast< css::beans::XMultiHierarchicalPropertySet * >(this),
1436 [ + - ]: 255299 : static_cast< css::beans::XHierarchicalPropertySetInfo * >(this));
1437 [ + + ]: 255299 : if (res.hasValue()) {
1438 : 181695 : return res;
1439 : : }
1440 : : }
1441 [ + - ][ + - ]: 95151 : if (getRootAccess()->isUpdate()) {
[ + + ]
1442 : : res = cppu::queryInterface(
1443 : : aType, static_cast< css::container::XNameReplace * >(this),
1444 [ + - ]: 87283 : static_cast< css::container::XHierarchicalNameReplace * >(this));
1445 [ + + ]: 87283 : if (res.hasValue()) {
1446 : 7464 : return res;
1447 : : }
1448 [ + - ][ + - ]: 223584 : if (getNode()->kind() != Node::KIND_GROUP ||
[ + + ][ + + ]
[ + - ][ + - ]
[ + + # # ]
1449 [ + - ][ - + ]: 143765 : dynamic_cast< GroupNode * >(getNode().get())->isExtensible())
[ + - ][ + + ]
[ + - ][ # # ]
1450 : : {
1451 : : res = cppu::queryInterface(
1452 [ + - ]: 23934 : aType, static_cast< css::container::XNameContainer * >(this));
1453 [ + + ]: 23934 : if (res.hasValue()) {
1454 : 15287 : return res;
1455 : : }
1456 : : }
1457 [ + - ][ + - ]: 64532 : if (getNode()->kind() == Node::KIND_SET) {
[ + - ][ + + ]
1458 : : res = cppu::queryInterface(
1459 [ + - ]: 8263 : aType, static_cast< css::lang::XSingleServiceFactory * >(this));
1460 : : }
1461 : : }
1462 : 1157193 : return res;
1463 : : }
1464 : :
1465 : 2051475 : Components & Access::getComponents() const {
1466 : 2051475 : return components_;
1467 : : }
1468 : :
1469 : 4461528 : void Access::checkLocalizedPropertyAccess() {
1470 [ + - ][ + - ]: 9320991 : if (getNode()->kind() == Node::KIND_LOCALIZED_PROPERTY &&
[ + + ][ - + ]
[ + - ]
[ - + # # ]
1471 [ + - ][ + - ]: 4859463 : !Components::allLocales(getRootAccess()->getLocale()))
[ + - ][ + + ]
[ + + ]
[ # # # # ]
1472 : : {
1473 : : throw css::uno::RuntimeException(
1474 : : rtl::OUString(
1475 : : RTL_CONSTASCII_USTRINGPARAM(
1476 : : "configmgr Access to specialized LocalizedPropertyNode")),
1477 [ # # ][ # # ]: 0 : static_cast< cppu::OWeakObject * >(this));
[ # # ]
1478 : : }
1479 : 4461528 : }
1480 : :
1481 : 32865 : rtl::Reference< Node > Access::getParentNode() {
1482 [ + - ]: 32865 : rtl::Reference< Access > parent(getParentAccess());
1483 [ + - ][ + - ]: 32865 : return parent.is() ? parent->getNode() : rtl::Reference< Node >();
1484 : : }
1485 : :
1486 : 4948936 : rtl::Reference< ChildAccess > Access::getChild(rtl::OUString const & name) {
1487 [ + - ][ + - ]: 4948936 : if (getNode()->kind() == Node::KIND_LOCALIZED_PROPERTY && name.match("*")) {
[ + + ][ + + ]
[ + - ][ + - ]
[ + + # # ]
1488 : 164603 : OUString locale(name.copy(1));
1489 [ - + ]: 164603 : if (locale.match("*")) {
1490 : : SAL_WARN(
1491 : : "configmgr",
1492 : : ("access best-matching localized property value via"
1493 : : " \"*<locale>\" with <locale> \"")
1494 : : << locale << "\" recursively starting with \"*\"");
1495 [ # # ]: 0 : return getChild(locale);
1496 : : }
1497 : : SAL_WARN_IF(
1498 : : locale.isEmpty(), "configmgr",
1499 : : ("access best-matching localized property value via \"*<locale>\""
1500 : : " with empty <locale>; falling back to defaults"));
1501 [ + - ]: 164603 : if (!locale.isEmpty()) {
1502 : : // Find best match using an adaption of RFC 4647 lookup matching
1503 : : // rules, removing "-" or "_" delimited segments from the end:
1504 : 164603 : for (;;) {
1505 [ + - ]: 242376 : rtl::Reference< ChildAccess > child(getChild(locale));
1506 [ + + ]: 242376 : if (child.is()) {
1507 : 86830 : return child;
1508 : : }
1509 : 155546 : sal_Int32 i = locale.getLength() - 1;
1510 [ + + ][ + + ]: 388865 : while (i > 0 && locale[i] != '-' && locale[i] != '_') {
[ + - ][ + + ]
1511 : 233319 : --i;
1512 : : }
1513 [ + + ]: 155546 : if (i <= 0) {
1514 : : break;
1515 : : }
1516 [ + + + ]: 320149 : locale = locale.copy(0, i);
1517 : 242376 : }
1518 : : // As a workaround for broken xcu data that does not use shortest
1519 : : // xml:lang attributes, look for the first entry with the same first
1520 : : // segment as the requested language tag before falling back to
1521 : : // defaults (see fdo#33638):
1522 : : assert(
1523 : : !locale.isEmpty() && locale.indexOf('-') == -1 &&
1524 : : locale.indexOf('_') == -1);
1525 : : std::vector< rtl::Reference< ChildAccess > > children(
1526 [ + - ]: 77773 : getAllChildren());
1527 [ + - ][ + + ]: 171684 : for (std::vector< rtl::Reference< ChildAccess > >::iterator i(
1528 : 77773 : children.begin());
1529 : 85842 : i != children.end(); ++i)
1530 : : {
1531 [ + - ]: 8069 : OUString name2((*i)->getNameInternal());
1532 [ - + # # : 8069 : if (name2.match(locale) &&
# # # # ]
[ - + ]
1533 : 0 : (name2.getLength() == locale.getLength() ||
1534 : 0 : name2[locale.getLength()] == '-' ||
1535 : 0 : name2[locale.getLength()] == '_'))
1536 : : {
1537 : 8069 : return *i;
1538 : : }
1539 [ + - ][ + - ]: 172672 : }
1540 : : }
1541 : : // Defaults are the "en-US" locale, the "en" locale, the empty string
1542 : : // locale, the first child (if any), or a null ChildAccess, in that
1543 : : // order:
1544 [ + - ]: 77773 : rtl::Reference< ChildAccess > child(getChild("en-US"));
1545 [ - + ]: 77773 : if (child.is()) {
1546 : 0 : return child;
1547 : : }
1548 [ + - ][ + - ]: 77773 : child = getChild("en");
1549 [ - + ]: 77773 : if (child.is()) {
1550 : 0 : return child;
1551 : : }
1552 [ + - ][ + - ]: 77773 : child = getChild(OUString());
1553 [ + + ]: 77773 : if (child.is()) {
1554 : 8069 : return child;
1555 : : }
1556 [ + - ]: 69704 : std::vector< rtl::Reference< ChildAccess > > children(getAllChildren());
1557 [ - + ]: 69704 : if (!children.empty()) {
1558 : 0 : return children.front();
1559 : : }
1560 : 164603 : return rtl::Reference< ChildAccess >();
1561 : : }
1562 [ + - ]: 4784333 : ModifiedChildren::iterator i(modifiedChildren_.find(name));
1563 : 9733269 : return i == modifiedChildren_.end()
1564 [ + - ][ + - ]: 4784333 : ? getUnmodifiedChild(name) : getModifiedChild(i);
[ + + ]
1565 : : }
1566 : :
1567 : 361095 : std::vector< rtl::Reference< ChildAccess > > Access::getAllChildren() {
1568 : 361095 : std::vector< rtl::Reference< ChildAccess > > vec;
1569 [ + - ][ + - ]: 361095 : NodeMap const & members = getNode()->getMembers();
[ + - ]
1570 [ + + ]: 1427217 : for (NodeMap::const_iterator i(members.begin()); i != members.end(); ++i) {
1571 [ + - ][ + - ]: 1066122 : if (modifiedChildren_.find(i->first) == modifiedChildren_.end()) {
1572 [ + - ][ + - ]: 1066122 : vec.push_back(getUnmodifiedChild(i->first));
1573 : : assert(vec.back().is());
1574 : : }
1575 : : }
1576 [ - + ]: 722190 : for (ModifiedChildren::iterator i(modifiedChildren_.begin());
1577 : 361095 : i != modifiedChildren_.end(); ++i)
1578 : : {
1579 [ # # ]: 0 : rtl::Reference< ChildAccess > child(getModifiedChild(i));
1580 [ # # ]: 0 : if (child.is()) {
1581 [ # # ]: 0 : vec.push_back(child);
1582 : : }
1583 : 0 : }
1584 : 361095 : return vec;
1585 : : }
1586 : :
1587 : 100543 : void Access::checkValue(css::uno::Any const & value, Type type, bool nillable) {
1588 : : bool ok;
1589 [ - + + ]: 100543 : switch (type) {
1590 : : case TYPE_NIL:
1591 : : assert(false);
1592 : : // fall through (cannot happen)
1593 : : case TYPE_ERROR:
1594 : 0 : ok = false;
1595 : 0 : break;
1596 : : case TYPE_ANY:
1597 [ - - + ]: 21731 : switch (getDynamicType(value)) {
1598 : : case TYPE_ANY:
1599 : : assert(false);
1600 : : // fall through (cannot happen)
1601 : : case TYPE_ERROR:
1602 : 0 : ok = false;
1603 : 0 : break;
1604 : : case TYPE_NIL:
1605 : 0 : ok = nillable;
1606 : 0 : break;
1607 : : default:
1608 : 21731 : ok = true;
1609 : 21731 : break;
1610 : : }
1611 : 21731 : break;
1612 : : default:
1613 [ + + ][ + - ]: 78812 : ok = value.hasValue() ? value.isExtractableTo(mapType(type)) : nillable;
[ + + ][ # # ]
1614 : 78812 : break;
1615 : : }
1616 [ - + ]: 100543 : if (!ok) {
1617 : : throw css::lang::IllegalArgumentException(
1618 : : rtl::OUString(
1619 : : RTL_CONSTASCII_USTRINGPARAM(
1620 : : "configmgr inappropriate property value")),
1621 [ # # ][ # # ]: 0 : static_cast< cppu::OWeakObject * >(this), -1);
[ # # ]
1622 : : }
1623 : 100543 : }
1624 : :
1625 : 0 : void Access::insertLocalizedValueChild(
1626 : : rtl::OUString const & name, css::uno::Any const & value,
1627 : : Modifications * localModifications)
1628 : : {
1629 : : assert(localModifications != 0);
1630 : : LocalizedPropertyNode * locprop = dynamic_cast< LocalizedPropertyNode * >(
1631 [ # # ][ # # ]: 0 : getNode().get());
[ # # ]
1632 [ # # ][ # # ]: 0 : checkValue(value, locprop->getStaticType(), locprop->isNillable());
[ # # ]
1633 : : rtl::Reference< ChildAccess > child(
1634 : : new ChildAccess(
1635 : 0 : components_, getRootAccess(), this, name,
1636 [ # # ][ # # ]: 0 : new LocalizedValueNode(Data::NO_LAYER, value)));
[ # # ][ # # ]
[ # # ][ # # ]
1637 [ # # ]: 0 : markChildAsModified(child);
1638 [ # # ][ # # ]: 0 : localModifications->add(child->getRelativePath());
1639 : 0 : }
1640 : :
1641 : 0 : void Access::reportChildChanges(
1642 : : std::vector< css::util::ElementChange > * changes)
1643 : : {
1644 : : assert(changes != 0);
1645 [ # # ]: 0 : for (ModifiedChildren::iterator i(modifiedChildren_.begin());
1646 : 0 : i != modifiedChildren_.end(); ++i)
1647 : : {
1648 [ # # ]: 0 : rtl::Reference< ChildAccess > child(getModifiedChild(i));
1649 [ # # ]: 0 : if (child.is()) {
1650 [ # # ]: 0 : child->reportChildChanges(changes);
1651 [ # # ]: 0 : changes->push_back(css::util::ElementChange());
1652 : : //TODO: changed value and/or inserted node
1653 : : } else {
1654 [ # # ]: 0 : changes->push_back(css::util::ElementChange()); //TODO: removed node
1655 : : }
1656 : 0 : }
1657 : 0 : }
1658 : :
1659 : 166725 : void Access::commitChildChanges(
1660 : : bool valid, Modifications * globalModifications)
1661 : : {
1662 : : assert(globalModifications != 0);
1663 [ + + ]: 315398 : while (!modifiedChildren_.empty()) {
1664 : 148673 : bool childValid = valid;
1665 : 148673 : ModifiedChildren::iterator i(modifiedChildren_.begin());
1666 [ + - ]: 148673 : rtl::Reference< ChildAccess > child(getModifiedChild(i));
1667 [ + + ]: 148673 : if (child.is()) {
1668 [ + - ][ + - ]: 148094 : childValid = childValid && !child->isFinalized();
[ + - ]
1669 [ + - ]: 148094 : child->commitChanges(childValid, globalModifications);
1670 : : //TODO: currently, this is called here for directly inserted
1671 : : // children as well as for children whose sub-children were
1672 : : // modified (and should never be called for directly removed
1673 : : // children); clarify what exactly should happen here for
1674 : : // directly inserted children
1675 : : }
1676 [ + - ][ + - ]: 148673 : NodeMap & members = getNode()->getMembers();
[ + - ]
1677 [ + - ]: 148673 : NodeMap::iterator j(members.find(i->first));
1678 [ + + ]: 148673 : if (child.is()) {
1679 : : // Inserted:
1680 [ + + ]: 148094 : if (j != members.end()) {
1681 : : childValid = childValid &&
1682 [ + - ][ + - ]: 136226 : j->second->getFinalized() == Data::NO_LAYER;
[ + - ]
1683 [ + - ]: 136226 : if (childValid) {
1684 [ + - ][ + - ]: 136226 : child->getNode()->setMandatory(j->second->getMandatory());
[ + - ][ + - ]
1685 : : }
1686 : : }
1687 [ + - ]: 148094 : if (childValid) {
1688 [ + - ][ + - ]: 148094 : members[i->first] = child->getNode();
[ + - ][ + - ]
1689 : : }
1690 : : } else {
1691 : : // Removed:
1692 [ + - ][ # # ]: 1158 : childValid = childValid && j != members.end() &&
1693 [ + - ]: 579 : j->second->getFinalized() == Data::NO_LAYER &&
1694 [ + - + - ]: 1737 : j->second->getMandatory() == Data::NO_LAYER;
[ + - ][ + - ]
[ + - ]
1695 [ + - ]: 579 : if (childValid) {
1696 [ + - ]: 579 : members.erase(j);
1697 : : }
1698 : : }
1699 [ + - ][ + + ]: 148673 : if (childValid && i->second.directlyModified) {
[ + + ]
1700 [ + - ]: 102960 : Path path(getAbsolutePath());
1701 [ + - ]: 102960 : path.push_back(i->first);
1702 [ + - ]: 102960 : components_.addModification(path);
1703 [ + - ]: 102960 : globalModifications->add(path);
1704 : : }
1705 [ + - ]: 148673 : i->second.child->committed();
1706 [ + - ]: 148673 : modifiedChildren_.erase(i);
1707 : 148673 : }
1708 : 166725 : }
1709 : :
1710 : 456729 : void Access::initBroadcasterAndChanges(
1711 : : Modifications::Node const & modifications, Broadcaster * broadcaster,
1712 : : std::vector< css::util::ElementChange > * allChanges)
1713 : : {
1714 : : assert(broadcaster != 0);
1715 [ + - ]: 456729 : comphelper::SequenceAsVector< css::beans::PropertyChangeEvent > propChanges;
1716 : 456729 : bool collectPropChanges = !propertiesChangeListeners_.empty();
1717 [ + + ]: 2030826 : for (Modifications::Node::Children::const_iterator i(
1718 : 456729 : modifications.children.begin());
1719 : 1015413 : i != modifications.children.end(); ++i)
1720 : : {
1721 [ + - ]: 558684 : rtl::Reference< ChildAccess > child(getChild(i->first));
1722 [ + + ]: 558684 : if (child.is()) {
1723 [ + - ][ + - ]: 557258 : switch (child->getNode()->kind()) {
[ + - ][ + +
+ + - - ]
1724 : : case Node::KIND_LOCALIZED_PROPERTY:
1725 [ + - ]: 7296 : if (!i->second.children.empty()) {
1726 [ + - ][ + - ]: 7296 : if (Components::allLocales(getRootAccess()->getLocale())) {
[ + - ][ + + ]
1727 : 3648 : child->initBroadcasterAndChanges(
1728 [ + - ]: 7296 : i->second, broadcaster, allChanges);
1729 : : //TODO: if allChanges==0, recurse only into children
1730 : : // w/ listeners
1731 : : } else {
1732 : : //TODO: filter child mods that are irrelevant for
1733 : : // locale:
1734 [ - + ]: 7296 : for (ContainerListeners::iterator j(
1735 : 3648 : containerListeners_.begin());
1736 : 3648 : j != containerListeners_.end(); ++j)
1737 : : {
1738 : : broadcaster->
1739 : : addContainerElementReplacedNotification(
1740 : 0 : *j,
1741 : : css::container::ContainerEvent(
1742 : : static_cast< cppu::OWeakObject * >(
1743 : : this),
1744 : 0 : css::uno::makeAny(i->first),
1745 [ # # ][ # # ]: 0 : css::uno::Any(), css::uno::Any()));
[ # # # # ]
[ # # ]
1746 : : //TODO: non-void Element, ReplacedElement
1747 : : }
1748 : : PropertyChangeListeners::iterator j(
1749 [ + - ]: 3648 : propertyChangeListeners_.find(i->first));
1750 [ - + ]: 3648 : if (j != propertyChangeListeners_.end()) {
1751 [ # # ]: 0 : for (PropertyChangeListenersElement::iterator k(
1752 : 0 : j->second.begin());
1753 : 0 : k != j->second.end(); ++k)
1754 : : {
1755 : : broadcaster->addPropertyChangeNotification(
1756 : 0 : *k,
1757 : : css::beans::PropertyChangeEvent(
1758 : : static_cast< cppu::OWeakObject * >(
1759 : : this),
1760 : 0 : i->first, false, -1, css::uno::Any(),
1761 [ # # ]: 0 : css::uno::Any()));
[ # # # # ]
[ # # ]
1762 : : }
1763 : : }
1764 [ + - ]: 3648 : j = propertyChangeListeners_.find(rtl::OUString());
1765 [ - + ]: 3648 : if (j != propertyChangeListeners_.end()) {
1766 [ # # ]: 0 : for (PropertyChangeListenersElement::iterator k(
1767 : 0 : j->second.begin());
1768 : 0 : k != j->second.end(); ++k)
1769 : : {
1770 : : broadcaster->addPropertyChangeNotification(
1771 : 0 : *k,
1772 : : css::beans::PropertyChangeEvent(
1773 : : static_cast< cppu::OWeakObject * >(
1774 : : this),
1775 : 0 : i->first, false, -1, css::uno::Any(),
1776 [ # # ]: 0 : css::uno::Any()));
[ # # # # ]
[ # # ]
1777 : : }
1778 : : }
1779 [ - + ]: 3648 : if (allChanges != 0) {
1780 : : allChanges->push_back(
1781 : : css::util::ElementChange(
1782 : : css::uno::makeAny(
1783 : 0 : child->getRelativePathRepresentation()),
1784 [ # # ][ # # ]: 0 : css::uno::Any(), css::uno::Any()));
[ # # ]
1785 : : //TODO: non-void Element, ReplacedElement
1786 : : }
1787 [ - + ]: 3648 : if (collectPropChanges) {
1788 : : propChanges.push_back(
1789 : : css::beans::PropertyChangeEvent(
1790 : : static_cast< cppu::OWeakObject * >(this),
1791 : 0 : i->first, false, -1, css::uno::Any(),
1792 [ # # ][ # # ]: 3648 : css::uno::Any()));
[ # # ][ # # ]
1793 : : }
1794 : : }
1795 : : }
1796 : : // else: spurious Modifications::Node not representing a change
1797 : 7296 : break;
1798 : : case Node::KIND_LOCALIZED_VALUE:
1799 : : assert(Components::allLocales(getRootAccess()->getLocale()));
1800 [ - + ]: 7296 : for (ContainerListeners::iterator j(
1801 : 3648 : containerListeners_.begin());
1802 : 3648 : j != containerListeners_.end(); ++j)
1803 : : {
1804 : : broadcaster->addContainerElementReplacedNotification(
1805 : 0 : *j,
1806 : : css::container::ContainerEvent(
1807 : : static_cast< cppu::OWeakObject * >(this),
1808 : 0 : css::uno::makeAny(i->first), child->asValue(),
1809 [ # # # # ]: 0 : css::uno::Any()));
[ # # ]
[ # # # # ]
[ # # ]
1810 : : //TODO: distinguish add/modify; non-void ReplacedElement
1811 : : }
1812 [ - + ]: 3648 : if (allChanges != 0) {
1813 : : allChanges->push_back(
1814 : : css::util::ElementChange(
1815 : : css::uno::makeAny(
1816 : 0 : child->getRelativePathRepresentation()),
1817 [ # # # # ]: 0 : child->asValue(), css::uno::Any()));
[ # # ][ # # ]
1818 : : //TODO: non-void ReplacedElement
1819 : : }
1820 : : assert(!collectPropChanges);
1821 : 3648 : break;
1822 : : case Node::KIND_PROPERTY:
1823 : : {
1824 [ - + ]: 485240 : for (ContainerListeners::iterator j(
1825 : 242620 : containerListeners_.begin());
1826 : 242620 : j != containerListeners_.end(); ++j)
1827 : : {
1828 : : broadcaster->addContainerElementReplacedNotification(
1829 : 0 : *j,
1830 : : css::container::ContainerEvent(
1831 : : static_cast< cppu::OWeakObject * >(this),
1832 : 0 : css::uno::makeAny(i->first), child->asValue(),
1833 [ # # # # ]: 0 : css::uno::Any()));
[ # # ]
[ # # # # ]
[ # # ]
1834 : : //TODO: distinguish add/remove/modify; non-void
1835 : : // ReplacedElement
1836 : : }
1837 : : PropertyChangeListeners::iterator j(
1838 [ + - ]: 242620 : propertyChangeListeners_.find(i->first));
1839 [ - + ]: 242620 : if (j != propertyChangeListeners_.end()) {
1840 [ # # ]: 0 : for (PropertyChangeListenersElement::iterator k(
1841 : 0 : j->second.begin());
1842 : 0 : k != j->second.end(); ++k)
1843 : : {
1844 : : broadcaster->addPropertyChangeNotification(
1845 : 0 : *k,
1846 : : css::beans::PropertyChangeEvent(
1847 : : static_cast< cppu::OWeakObject * >(this),
1848 : 0 : i->first, false, -1, css::uno::Any(),
1849 [ # # ]: 0 : css::uno::Any()));
[ # # # # ]
[ # # ]
1850 : : }
1851 : : }
1852 [ + - ]: 242620 : j = propertyChangeListeners_.find(rtl::OUString());
1853 [ - + ]: 242620 : if (j != propertyChangeListeners_.end()) {
1854 [ # # ]: 0 : for (PropertyChangeListenersElement::iterator k(
1855 : 0 : j->second.begin());
1856 : 0 : k != j->second.end(); ++k)
1857 : : {
1858 : : broadcaster->addPropertyChangeNotification(
1859 : 0 : *k,
1860 : : css::beans::PropertyChangeEvent(
1861 : : static_cast< cppu::OWeakObject * >(this),
1862 : 0 : i->first, false, -1, css::uno::Any(),
1863 [ # # ]: 0 : css::uno::Any()));
[ # # # # ]
[ # # ]
1864 : : }
1865 : : }
1866 [ + + ]: 242620 : if (allChanges != 0) {
1867 : : allChanges->push_back(
1868 : : css::util::ElementChange(
1869 : : css::uno::makeAny(
1870 : 48370 : child->getRelativePathRepresentation()),
1871 [ + - + - ]: 96740 : child->asValue(), css::uno::Any()));
[ + - ][ + - ]
1872 : : //TODO: non-void ReplacedElement
1873 : : }
1874 [ - + ]: 242620 : if (collectPropChanges) {
1875 : : propChanges.push_back(
1876 : : css::beans::PropertyChangeEvent(
1877 : : static_cast< cppu::OWeakObject * >(this),
1878 : 0 : i->first, false, -1, css::uno::Any(),
1879 [ # # ][ # # ]: 0 : css::uno::Any()));
[ # # ][ # # ]
1880 : : }
1881 : : }
1882 : 242620 : break;
1883 : : case Node::KIND_GROUP:
1884 : : case Node::KIND_SET:
1885 [ + + ]: 303694 : if (i->second.children.empty()) {
1886 [ + - ][ + - ]: 5104 : if (!child->getNode()->getTemplateName().isEmpty()) {
[ + - ][ + - ]
1887 [ - + ]: 10208 : for (ContainerListeners::iterator j(
1888 : 5104 : containerListeners_.begin());
1889 : 5104 : j != containerListeners_.end(); ++j)
1890 : : {
1891 : : broadcaster->
1892 : : addContainerElementInsertedNotification(
1893 : 0 : *j,
1894 : : css::container::ContainerEvent(
1895 : : static_cast< cppu::OWeakObject * >(
1896 : : this),
1897 : 0 : css::uno::makeAny(i->first),
1898 [ # # # # ]: 0 : child->asValue(), css::uno::Any()));
[ # # ]
[ # # # # ]
[ # # ]
1899 : : }
1900 [ + + ]: 5104 : if (allChanges != 0) {
1901 : : allChanges->push_back(
1902 : : css::util::ElementChange(
1903 : : css::uno::makeAny(
1904 : 100 : child->getRelativePathRepresentation()),
1905 [ + - ][ + - ]: 200 : css::uno::Any(), css::uno::Any()));
[ + - ]
1906 : : //TODO: non-void Element, ReplacedElement
1907 : : }
1908 : : }
1909 : : // else: spurious Modifications::Node not representing a
1910 : : // change
1911 : : } else {
1912 : 298590 : child->initBroadcasterAndChanges(
1913 [ + - ]: 597180 : i->second, broadcaster, allChanges);
1914 : : //TODO: if allChanges==0, recurse only into children w/
1915 : : // listeners
1916 : : }
1917 : 303694 : break;
1918 : : case Node::KIND_ROOT:
1919 : : assert(false); // this cannot happen
1920 : 557258 : break;
1921 : : }
1922 : : } else {
1923 [ + - ][ + - ]: 1426 : switch (getNode()->kind()) {
[ + - ]
[ - + + - ]
1924 : : case Node::KIND_LOCALIZED_PROPERTY:
1925 : : // Removed localized property value:
1926 : : assert(Components::allLocales(getRootAccess()->getLocale()));
1927 [ # # ]: 0 : for (ContainerListeners::iterator j(
1928 : 0 : containerListeners_.begin());
1929 : 0 : j != containerListeners_.end(); ++j)
1930 : : {
1931 : : broadcaster->addContainerElementRemovedNotification(
1932 : 0 : *j,
1933 : : css::container::ContainerEvent(
1934 : : static_cast< cppu::OWeakObject * >(this),
1935 : 0 : css::uno::makeAny(i->first), css::uno::Any(),
1936 [ # # ][ # # ]: 0 : css::uno::Any()));
[ # # # # ]
[ # # ]
1937 : : //TODO: non-void ReplacedElement
1938 : : }
1939 [ # # ]: 0 : if (allChanges != 0) {
1940 [ # # ][ # # ]: 0 : rtl::OUStringBuffer path(getRelativePathRepresentation());
1941 [ # # ]: 0 : if (path.getLength() != 0) {
1942 [ # # ]: 0 : path.append(sal_Unicode('/'));
1943 : : }
1944 : : path.append(
1945 : : Data::createSegment(
1946 : : rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("*")),
1947 [ # # ][ # # ]: 0 : i->first));
[ # # ]
1948 : : allChanges->push_back(
1949 : : css::util::ElementChange(
1950 : : css::uno::makeAny(path.makeStringAndClear()),
1951 [ # # ][ # # ]: 0 : css::uno::Any(), css::uno::Any()));
[ # # ]
1952 : : //TODO: non-void ReplacedElement
1953 : : }
1954 : : assert(!collectPropChanges);
1955 : 0 : break;
1956 : : case Node::KIND_GROUP:
1957 : : {
1958 : : // Removed (non-localized) extension property:
1959 [ - + ]: 436 : for (ContainerListeners::iterator j(
1960 : 218 : containerListeners_.begin());
1961 : 218 : j != containerListeners_.end(); ++j)
1962 : : {
1963 : : broadcaster->addContainerElementRemovedNotification(
1964 : 0 : *j,
1965 : : css::container::ContainerEvent(
1966 : : static_cast< cppu::OWeakObject * >(this),
1967 : 0 : css::uno::makeAny(i->first), css::uno::Any(),
1968 [ # # ][ # # ]: 0 : css::uno::Any()));
[ # # # # ]
[ # # ]
1969 : : //TODO: non-void ReplacedElement
1970 : : }
1971 : : PropertyChangeListeners::iterator j(
1972 [ + - ]: 218 : propertyChangeListeners_.find(i->first));
1973 [ - + ]: 218 : if (j != propertyChangeListeners_.end()) {
1974 [ # # ]: 0 : for (PropertyChangeListenersElement::iterator k(
1975 : 0 : j->second.begin());
1976 : 0 : k != j->second.end(); ++k)
1977 : : {
1978 : : broadcaster->addPropertyChangeNotification(
1979 : 0 : *k,
1980 : : css::beans::PropertyChangeEvent(
1981 : : static_cast< cppu::OWeakObject * >(this),
1982 : 0 : i->first, false, -1, css::uno::Any(),
1983 [ # # ]: 0 : css::uno::Any()));
[ # # # # ]
[ # # ]
1984 : : }
1985 : : }
1986 [ + - ]: 218 : j = propertyChangeListeners_.find(rtl::OUString());
1987 [ - + ]: 218 : if (j != propertyChangeListeners_.end()) {
1988 [ # # ]: 0 : for (PropertyChangeListenersElement::iterator k(
1989 : 0 : j->second.begin());
1990 : 0 : k != j->second.end(); ++k)
1991 : : {
1992 : : broadcaster->addPropertyChangeNotification(
1993 : 0 : *k,
1994 : : css::beans::PropertyChangeEvent(
1995 : : static_cast< cppu::OWeakObject * >(this),
1996 : 0 : i->first, false, -1, css::uno::Any(),
1997 [ # # ]: 0 : css::uno::Any()));
[ # # # # ]
[ # # ]
1998 : : }
1999 : : }
2000 [ - + ]: 218 : if (allChanges != 0) {
2001 : : rtl::OUStringBuffer path(
2002 [ # # ][ # # ]: 0 : getRelativePathRepresentation());
2003 [ # # ]: 0 : if (path.getLength() != 0) {
2004 [ # # ]: 0 : path.append(sal_Unicode('/'));
2005 : : }
2006 [ # # ]: 0 : path.append(i->first);
2007 : : allChanges->push_back(
2008 : : css::util::ElementChange(
2009 : : css::uno::makeAny(path.makeStringAndClear()),
2010 [ # # ][ # # ]: 0 : css::uno::Any(), css::uno::Any()));
[ # # ]
2011 : : //TODO: non-void ReplacedElement
2012 : : }
2013 [ - + ]: 218 : if (collectPropChanges) {
2014 : : propChanges.push_back(
2015 : : css::beans::PropertyChangeEvent(
2016 : : static_cast< cppu::OWeakObject * >(this),
2017 : 0 : i->first, false, -1, css::uno::Any(),
2018 [ # # ][ # # ]: 0 : css::uno::Any()));
[ # # ][ # # ]
2019 : : }
2020 : : }
2021 : 218 : break;
2022 : : case Node::KIND_SET:
2023 : : // Removed set member:
2024 [ + - ]: 1208 : if (i->second.children.empty()) {
2025 [ - + ]: 2416 : for (ContainerListeners::iterator j(
2026 : 1208 : containerListeners_.begin());
2027 : 1208 : j != containerListeners_.end(); ++j)
2028 : : {
2029 : : broadcaster->addContainerElementRemovedNotification(
2030 : 0 : *j,
2031 : : css::container::ContainerEvent(
2032 : : static_cast< cppu::OWeakObject * >(this),
2033 : 0 : css::uno::makeAny(i->first),
2034 [ # # ][ # # ]: 0 : css::uno::Any(), css::uno::Any()));
[ # # # # ]
[ # # ]
2035 : : //TODO: non-void ReplacedElement
2036 : : }
2037 [ + + ]: 1208 : if (allChanges != 0) {
2038 : : rtl::OUStringBuffer path(
2039 [ + - ][ + - ]: 100 : getRelativePathRepresentation());
2040 [ + - ]: 100 : if (path.getLength() != 0) {
2041 [ + - ]: 100 : path.append(sal_Unicode('/'));
2042 : : }
2043 : : path.append(
2044 : : Data::createSegment(
2045 : : rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("*")),
2046 [ + - ][ + - ]: 100 : i->first));
[ + - ]
2047 : : allChanges->push_back(
2048 : : css::util::ElementChange(
2049 : : css::uno::makeAny(path.makeStringAndClear()),
2050 [ + - ][ + - ]: 100 : css::uno::Any(), css::uno::Any()));
[ + - ]
2051 : : //TODO: non-void ReplacedElement
2052 : : }
2053 : : }
2054 : : // else: spurious Modifications::Node not representing a change
2055 : 1208 : break;
2056 : : default:
2057 : : assert(false); // this cannot happen
2058 : 0 : break;
2059 : : }
2060 : : }
2061 : 558684 : }
2062 [ - + ]: 456729 : if (!propChanges.empty()) {
2063 : : css::uno::Sequence< css::beans::PropertyChangeEvent > seq(
2064 [ # # ]: 0 : propChanges.getAsConstList());
2065 [ # # ]: 0 : for (PropertiesChangeListeners::iterator i(
2066 : 0 : propertiesChangeListeners_.begin());
2067 : 0 : i != propertiesChangeListeners_.end(); ++i)
2068 : : {
2069 [ # # ]: 0 : broadcaster->addPropertiesChangeNotification(*i, seq);
2070 [ # # ]: 0 : }
2071 : 456729 : }
2072 : 456729 : }
2073 : :
2074 : 13000 : bool Access::isDisposed() const {
2075 : 13000 : return disposed_;
2076 : : }
2077 : :
2078 : 102960 : Access::ModifiedChild::ModifiedChild() {}
2079 : :
2080 : 248268 : Access::ModifiedChild::ModifiedChild(
2081 : : rtl::Reference< ChildAccess > const & theChild, bool theDirectlyModified):
2082 : 248268 : child(theChild), directlyModified(theDirectlyModified)
2083 : 248268 : {}
2084 : :
2085 : 397088 : rtl::Reference< ChildAccess > Access::getModifiedChild(
2086 : : ModifiedChildren::iterator const & childIterator)
2087 : : {
2088 [ + - ][ + - ]: 794176 : return (childIterator->second.child->getParentAccess() == this &&
[ # # ]
2089 : 395930 : (childIterator->second.child->getNameInternal() ==
2090 [ + - ][ + + ]: 1188948 : childIterator->first))
[ # # ]
2091 [ + + + - ]: 1190106 : ? childIterator->second.child : rtl::Reference< ChildAccess >();
2092 : : }
2093 : :
2094 : 5602040 : rtl::Reference< ChildAccess > Access::getUnmodifiedChild(
2095 : : rtl::OUString const & name)
2096 : : {
2097 : : assert(modifiedChildren_.find(name) == modifiedChildren_.end());
2098 [ + - ][ + - ]: 5602040 : rtl::Reference< Node > node(getNode()->getMember(name));
[ + - ]
2099 [ + + ]: 5602040 : if (!node.is()) {
2100 : 689446 : return rtl::Reference< ChildAccess >();
2101 : : }
2102 [ + - ]: 4912594 : WeakChildMap::iterator i(cachedChildren_.find(name));
2103 [ + + ]: 4912594 : if (i != cachedChildren_.end()) {
2104 : 22820 : rtl::Reference< ChildAccess > child;
2105 [ + - ][ + - ]: 22820 : if (i->second->acquireCounting() > 1) {
2106 : 22820 : child.set(i->second); // must not throw
2107 : : }
2108 [ + - ]: 22820 : i->second->releaseNondeleting();
2109 [ + - ]: 22820 : if (child.is()) {
2110 [ + - ]: 22820 : child->setNode(node);
2111 : 22820 : return child;
2112 [ - + ]: 22820 : }
2113 : : }
2114 : : rtl::Reference< ChildAccess > child(
2115 [ + - ][ + - ]: 4889774 : new ChildAccess(components_, getRootAccess(), this, name, node));
2116 [ + - ]: 4889774 : cachedChildren_[name] = child.get();
2117 [ + - ]: 5602040 : return child;
2118 : : }
2119 : :
2120 : 356844 : rtl::Reference< ChildAccess > Access::getSubChild(rtl::OUString const & path) {
2121 : 356844 : sal_Int32 i = 0;
2122 : : // For backwards compatibility, allow absolute paths where meaningful:
2123 [ + - ][ + + ]: 356844 : if (!path.isEmpty() && path[0] == '/') {
[ + + ]
2124 : 26394 : ++i;
2125 [ + - ][ - + ]: 26394 : if (!getRootAccess().is()) {
2126 : 0 : return rtl::Reference< ChildAccess >();
2127 : : }
2128 [ + - ]: 26394 : Path abs(getAbsolutePath());
2129 [ + - ][ - + ]: 26394 : for (Path::iterator j(abs.begin()); j != abs.end(); ++j) {
2130 : 0 : rtl::OUString name1;
2131 : : bool setElement1;
2132 : 0 : rtl::OUString templateName1;
2133 : : i = Data::parseSegment(
2134 [ # # ]: 0 : path, i, &name1, &setElement1, &templateName1);
2135 [ # # ][ # # ]: 0 : if (i == -1 || (i != path.getLength() && path[i] != '/')) {
[ # # ][ # # ]
2136 : 0 : return rtl::Reference< ChildAccess >();
2137 : : }
2138 : 0 : rtl::OUString name2;
2139 : : bool setElement2;
2140 : 0 : rtl::OUString templateName2;
2141 [ # # ]: 0 : Data::parseSegment(*j, 0, &name2, &setElement2, &templateName2);
2142 [ # # ][ # # ]: 0 : if (name1 != name2 || setElement1 != setElement2 ||
[ # # ][ # # ]
[ # # ]
2143 : : (setElement1 &&
2144 [ # # ]: 0 : !Data::equalTemplateNames(templateName1, templateName2)))
2145 : : {
2146 : 0 : return rtl::Reference< ChildAccess >();
2147 : : }
2148 [ # # ]: 0 : if (i != path.getLength()) {
2149 : 0 : ++i;
2150 : : }
2151 [ # # ][ # # ]: 26394 : }
[ # # ][ # # ]
[ + - ]
2152 : : }
2153 : 834510 : for (rtl::Reference< Access > parent(this);;) {
2154 : 834510 : rtl::OUString name;
2155 : : bool setElement;
2156 : 834510 : rtl::OUString templateName;
2157 [ + - ]: 834510 : i = Data::parseSegment(path, i, &name, &setElement, &templateName);
2158 [ + - ][ + + ]: 834510 : if (i == -1 || (i != path.getLength() && path[i] != '/')) {
[ - + ][ - + ]
2159 : 0 : return rtl::Reference< ChildAccess >();
2160 : : }
2161 [ + - ]: 834510 : rtl::Reference< ChildAccess > child(parent->getChild(name));
2162 [ + + ]: 834510 : if (!child.is()) {
2163 : 202 : return rtl::Reference< ChildAccess >();
2164 : : }
2165 [ + + ]: 834308 : if (setElement) {
2166 [ + - ]: 30183 : rtl::Reference< Node > p(parent->getNode());
2167 [ + - ]: 30183 : switch (p->kind()) {
[ - + - ]
2168 : : case Node::KIND_LOCALIZED_PROPERTY:
2169 [ # # ][ # # ]: 0 : if (!Components::allLocales(getRootAccess()->getLocale()) ||
[ # # ]
[ # # # # ]
[ # # ][ # # ]
[ # # # #
# # ]
2170 : 0 : !templateName.isEmpty())
2171 : : {
2172 : 0 : return rtl::Reference< ChildAccess >();
2173 : : }
2174 : 0 : break;
2175 : : case Node::KIND_SET:
2176 [ + + ][ - + ]: 30233 : if (!templateName.isEmpty() &&
[ - + ]
2177 : 50 : !dynamic_cast< SetNode * >(p.get())->isValidTemplate(
2178 [ + - ][ - + ]: 50 : templateName))
2179 : : {
2180 : 0 : return rtl::Reference< ChildAccess >();
2181 : : }
2182 : 30183 : break;
2183 : : default:
2184 : 30183 : return rtl::Reference< ChildAccess >();
2185 [ + - ][ + - ]: 30183 : }
2186 : : }
2187 : : // For backwards compatibility, ignore a final slash after non-value
2188 : : // nodes:
2189 [ + - ][ + + ]: 834308 : if (child->isValue()) {
2190 : 294606 : return i == path.getLength()
2191 [ + - ]: 294606 : ? child : rtl::Reference< ChildAccess >();
2192 [ + + ]: 539702 : } else if (i >= path.getLength() - 1) {
2193 : 62036 : return child;
2194 : : }
2195 : 477666 : ++i;
2196 [ + - ][ + + ]: 1312176 : parent = child.get();
2197 [ + + ][ + + ]: 1669020 : }
2198 : : }
2199 : :
2200 : 61848 : bool Access::setChildProperty(
2201 : : rtl::OUString const & name, css::uno::Any const & value,
2202 : : Modifications * localModifications)
2203 : : {
2204 : : assert(localModifications != 0);
2205 [ + - ]: 61848 : rtl::Reference< ChildAccess > child(getChild(name));
2206 [ - + ]: 61848 : if (!child.is()) {
2207 : 0 : return false;
2208 : : }
2209 [ + - ]: 61848 : child->checkFinalized();
2210 [ + - ]: 61848 : child->setProperty(value, localModifications);
2211 : 61848 : return true;
2212 : : }
2213 : :
2214 : 41796 : css::beans::Property Access::asProperty() {
2215 : 41796 : css::uno::Type type;
2216 : : bool nillable;
2217 : : bool removable;
2218 [ + - ]: 41796 : rtl::Reference< Node > p(getNode());
2219 [ + - ]: 41796 : switch (p->kind()) {
[ + - - + ]
2220 : : case Node::KIND_PROPERTY:
2221 : : {
2222 [ - + ]: 16576 : PropertyNode * prop = dynamic_cast< PropertyNode * >(p.get());
2223 [ + - ][ + - ]: 16576 : type = mapType(prop->getStaticType());
2224 [ + - ]: 16576 : nillable = prop->isNillable();
2225 [ + - ]: 16576 : removable = prop->isExtension();
2226 : : }
2227 : : break;
2228 : : case Node::KIND_LOCALIZED_PROPERTY:
2229 : : {
2230 : : LocalizedPropertyNode * locprop =
2231 [ # # ]: 0 : dynamic_cast< LocalizedPropertyNode *>(p.get());
2232 [ # # ][ # # ]: 0 : if (Components::allLocales(getRootAccess()->getLocale())) {
[ # # ][ # # ]
2233 : 0 : type = cppu::UnoType< css::uno::XInterface >::get();
2234 : : //TODO: correct?
2235 : 0 : removable = false;
2236 : : } else {
2237 [ # # ][ # # ]: 0 : type = mapType(locprop->getStaticType());
2238 : 0 : removable = false; //TODO ???
2239 : : }
2240 [ # # ]: 0 : nillable = locprop->isNillable();
2241 : : }
2242 : : break;
2243 : : case Node::KIND_LOCALIZED_VALUE:
2244 : : {
2245 : : LocalizedPropertyNode * locprop =
2246 [ # # ][ # # ]: 0 : dynamic_cast< LocalizedPropertyNode * >(getParentNode().get());
[ # # ]
2247 [ # # ][ # # ]: 0 : type = mapType(locprop->getStaticType());
2248 [ # # ]: 0 : nillable = locprop->isNillable();
2249 : 0 : removable = false; //TODO ???
2250 : : }
2251 : : break;
2252 : : default:
2253 : 25220 : type = cppu::UnoType< css::uno::XInterface >::get(); //TODO: correct?
2254 : 25220 : nillable = false;
2255 [ + - ]: 25220 : rtl::Reference< Node > parent(getParentNode());
2256 [ + - ][ + - ]: 25220 : removable = parent.is() && parent->kind() == Node::KIND_SET;
[ + + ]
2257 [ + - ]: 25220 : break;
2258 : : }
2259 : : return css::beans::Property(
2260 : 41796 : getNameInternal(), -1, type,
2261 : : (css::beans::PropertyAttribute::BOUND | //TODO: correct for group/set?
2262 : : css::beans::PropertyAttribute::CONSTRAINED |
2263 : : (nillable ? css::beans::PropertyAttribute::MAYBEVOID : 0) |
2264 [ + - ][ + - ]: 83592 : (getRootAccess()->isUpdate()
2265 : : ? (removable ? css::beans::PropertyAttribute::REMOVEABLE : 0)
2266 [ + + ][ + - ]: 125388 : : css::beans::PropertyAttribute::READONLY))); //TODO: MAYBEDEFAULT
[ + + ][ + - ]
[ + - ]
2267 : : }
2268 : :
2269 : 102387 : void Access::checkFinalized() {
2270 [ - + ]: 102387 : if (isFinalized()) {
2271 : : throw css::lang::IllegalArgumentException(
2272 : : rtl::OUString(
2273 : : RTL_CONSTASCII_USTRINGPARAM(
2274 : : "configmgr modification of finalized item")),
2275 [ # # ][ # # ]: 0 : static_cast< cppu::OWeakObject * >(this), -1);
[ # # ]
2276 : : }
2277 : 102387 : }
2278 : :
2279 : 9 : void Access::checkKnownProperty(rtl::OUString const & descriptor) {
2280 [ + - ]: 9 : if (descriptor.isEmpty()) {
2281 : : return;
2282 : : }
2283 [ + - ]: 9 : rtl::Reference< ChildAccess > child(getChild(descriptor));
2284 [ + - ]: 9 : if (child.is()) {
2285 [ + - ][ + - ]: 9 : switch (child->getNode()->kind()) {
[ + - ]
[ - - - + ]
2286 : : case Node::KIND_PROPERTY:
2287 : : return;
2288 : : case Node::KIND_LOCALIZED_PROPERTY:
2289 [ # # ][ # # ]: 0 : if (!Components::allLocales(getRootAccess()->getLocale())) {
[ # # ][ # # ]
2290 : : return;
2291 : : }
2292 : 0 : break;
2293 : : case Node::KIND_LOCALIZED_VALUE:
2294 [ # # ][ # # ]: 0 : if (Components::allLocales(getRootAccess()->getLocale())) {
[ # # ][ # # ]
2295 : : return;
2296 : : }
2297 : 0 : break;
2298 : : default:
2299 : 0 : break;
2300 : : }
2301 : : }
2302 : : throw css::beans::UnknownPropertyException(
2303 [ # # ][ # # ]: 9 : descriptor, static_cast< cppu::OWeakObject * >(this));
2304 : : }
2305 : :
2306 : 1838 : rtl::Reference< ChildAccess > Access::getFreeSetMember(
2307 : : css::uno::Any const & value)
2308 : : {
2309 : 1838 : rtl::Reference< ChildAccess > freeAcc;
2310 : 1838 : css::uno::Reference< css::lang::XUnoTunnel > tunnel;
2311 [ + - ]: 1838 : value >>= tunnel;
2312 [ + - ]: 1838 : if (tunnel.is()) {
2313 : : freeAcc.set(
2314 : : reinterpret_cast< ChildAccess * >(
2315 [ + - ][ + - ]: 1838 : tunnel->getSomething(ChildAccess::getTunnelId())));
[ + - ][ + - ]
2316 : : }
2317 [ + - ][ + - ]: 5514 : if (!freeAcc.is() || freeAcc->getParentAccess().is() ||
[ + - - +
# # ][ + - ]
[ - + # # ]
2318 : 1838 : (freeAcc->isInTransaction() &&
2319 [ # # ][ # # ]: 1838 : freeAcc->getRootAccess() != getRootAccess()))
[ - + ][ - + ]
[ # # # # ]
2320 : : {
2321 : : throw css::lang::IllegalArgumentException(
2322 : : rtl::OUString(
2323 : : RTL_CONSTASCII_USTRINGPARAM(
2324 : : "configmgr inappropriate set element")),
2325 [ # # ][ # # ]: 0 : static_cast< cppu::OWeakObject * >(this), 1);
[ # # ]
2326 : : }
2327 : : assert(dynamic_cast< SetNode * >(getNode().get()) != 0);
2328 [ + - ][ + - ]: 5514 : if (!dynamic_cast< SetNode * >(getNode().get())->isValidTemplate(
[ - + ]
2329 [ + - ]: 5514 : freeAcc->getNode()->getTemplateName()))
[ + - - + ]
[ + - ][ + - ]
2330 : : {
2331 : : throw css::lang::IllegalArgumentException(
2332 : : rtl::OUString(
2333 : : RTL_CONSTASCII_USTRINGPARAM(
2334 : : "configmgr inappropriate set element")),
2335 [ # # ][ # # ]: 0 : static_cast< cppu::OWeakObject * >(this), 1);
[ # # ]
2336 : : }
2337 : 1838 : return freeAcc;
2338 : : }
2339 : :
2340 : 102960 : rtl::Reference< Access > Access::getNotificationRoot() {
2341 : 244496 : for (rtl::Reference< Access > p(this);;) {
2342 [ + - ]: 244496 : rtl::Reference< Access > parent(p->getParentAccess());
2343 [ + + ]: 244496 : if (!parent.is()) {
2344 : 205920 : return p;
2345 : : }
2346 [ + - ][ + + ]: 386032 : p = parent;
2347 : 347456 : }
2348 : : }
2349 : :
2350 : : #if !defined NDEBUG
2351 : : bool Access::thisIs(int what) {
2352 : : osl::MutexGuard g(*lock_);
2353 : : rtl::Reference< Node > p(getNode());
2354 : : Node::Kind k(p->kind());
2355 : : return (k != Node::KIND_PROPERTY && k != Node::KIND_LOCALIZED_VALUE &&
2356 : : ((what & IS_GROUP) == 0 || k == Node::KIND_GROUP) &&
2357 : : ((what & IS_SET) == 0 || k == Node::KIND_SET) &&
2358 : : ((what & IS_EXTENSIBLE) == 0 || k != Node::KIND_GROUP ||
2359 : : dynamic_cast< GroupNode * >(p.get())->isExtensible()) &&
2360 : : ((what & IS_GROUP_MEMBER) == 0 ||
2361 : : getParentNode()->kind() == Node::KIND_GROUP)) ||
2362 : : ((what & IS_SET_MEMBER) == 0 ||
2363 : : getParentNode()->kind() == Node::KIND_SET) ||
2364 : : ((what & IS_UPDATE) == 0 || getRootAccess()->isUpdate());
2365 : : }
2366 : : #endif
2367 : :
2368 : : }
2369 : :
2370 : : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|