LCOV - code coverage report
Current view: top level - usr/local/src/libreoffice/configmgr/source - access.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 563 1105 51.0 %
Date: 2013-07-09 Functions: 54 85 63.5 %
Legend: Lines: hit not hit

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

Generated by: LCOV version 1.10