1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: propsetaccessimpl.cxx,v $
10 * $Revision: 1.24.10.5 $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 // MARKER(update_precomp.py): autogen include statement, do not remove
32 #include "precompiled_configmgr.hxx"
34 #include "propsetaccessimpl.hxx"
35 #include "propertyinfohelper.hxx"
36 #include "apinodeaccess.hxx"
37 #include "apinodeupdate.hxx"
38 #include "noderef.hxx"
39 #include "valueref.hxx"
40 #include "anynoderef.hxx"
41 #include "nodechange.hxx"
42 #include "configgroup.hxx"
43 #include "confignotifier.hxx"
44 #include "broadcaster.hxx"
45 #include "apitypes.hxx"
46 #include "attributes.hxx"
47 #include <com/sun/star/lang/DisposedException.hpp>
48 #include <com/sun/star/beans/XPropertySetInfo.hpp>
49 #include <com/sun/star/beans/PropertyAttribute.hpp>
50 #include <osl/diagnose.h>
51 #include <cppuhelper/implbase1.hxx>
53 #ifndef INCLUDED_ALGORITHM
55 #define INCLUDED_ALGORITHM
62 //-----------------------------------------------------------------------------------
63 namespace lang
= css::lang
;
64 namespace beans
= css::beans
;
66 //-----------------------------------------------------------------------------------
68 //-----------------------------------------------------------------------------------
70 class CollectProperties
: configuration::NodeVisitor
72 std::vector
< beans::Property
> m_aProperties
;
75 CollectProperties(sal_Bool _bReadonly
)
76 : m_bReadonly(_bReadonly
)
78 CollectProperties(sal_Bool _bReadonly
, sal_Int32 _nCount
)
79 : m_bReadonly(_bReadonly
)
80 { m_aProperties
.reserve(_nCount
); }
82 uno::Sequence
<beans::Property
> forChildren(rtl::Reference
< configuration::Tree
> const& _aPropertyTree
, configuration::NodeRef
const& _rNode
)
84 OSL_ENSURE( _rNode
.isValid() && _aPropertyTree
->isValidNode(_rNode
.getOffset()), "Node to retrieve properties from does not match tree");
86 _aPropertyTree
->dispatchToChildren(_rNode
, *this);
87 return makeSequence(m_aProperties
);
91 void reset() { m_aProperties
.clear(); }
93 node::Attributes
adjustAttributes(node::Attributes nNodeAttr
);
95 Result
handle(rtl::Reference
< configuration::Tree
> const& _aTree
, configuration::NodeRef
const& _rValue
);
96 Result
handle(rtl::Reference
< configuration::Tree
> const& _aTree
, configuration::ValueRef
const& _rValue
);
99 //-----------------------------------------------------------------------------------
100 node::Attributes
CollectProperties::adjustAttributes(node::Attributes nNodeAttr
)
102 if (m_bReadonly
) nNodeAttr
.markReadonly();
107 //-----------------------------------------------------------------------------------
108 CollectProperties::Result
CollectProperties::handle(rtl::Reference
< configuration::Tree
> const& _aTree
, configuration::ValueRef
const& _rValue
)
111 m_aProperties
.push_back(
112 helperMakeProperty( _rValue
.m_sNodeName
,
113 adjustAttributes(_aTree
->getAttributes(_rValue
)),
114 _aTree
->getUnoType(_rValue
),
115 _aTree
->hasNodeDefault(_rValue
)
122 //-----------------------------------------------------------------------------------
123 CollectProperties::Result
CollectProperties::handle(rtl::Reference
< configuration::Tree
> const& _aTree
, configuration::NodeRef
const& _rNode
)
126 OSL_ENSURE( configuration::isStructuralNode(_aTree
,_rNode
),
127 "Unexpected value element node. Cannot get proper type for this node as property" );
129 m_aProperties
.push_back(
130 helperMakeProperty( _aTree
->getSimpleNodeName(_rNode
.getOffset()),
131 adjustAttributes(_aTree
->getAttributes(_rNode
)),
132 getUnoInterfaceType(),
133 _aTree
->hasNodeDefault(_rNode
)
140 //-----------------------------------------------------------------------------------
141 // yet another helper class (more robust, but can't well be extended to be a HierarchicalPropertySetInfo though)
142 //-----------------------------------------------------------------------------------
144 class NodePropertySetInfo
145 :public ::cppu::WeakImplHelper1
< beans::XPropertySetInfo
>
147 uno::Sequence
< beans::Property
> const m_aProperties
;
150 NodePropertySetInfo(uno::Sequence
< beans::Property
> const& _aProperties
) throw(uno::RuntimeException
)
151 : m_aProperties(_aProperties
)
155 static NodePropertySetInfo
* create(NodeGroupInfoAccess
& _rNode
, sal_Bool _bReadonly
) throw(uno::RuntimeException
);
156 beans::Property
const* begin() const throw() { return m_aProperties
.getConstArray(); }
157 beans::Property
const* end() const throw() { return m_aProperties
.getConstArray() + m_aProperties
.getLength(); }
159 beans::Property
const* find(const rtl::OUString
& _rPropertyName
) const throw(uno::RuntimeException
);
162 virtual uno::Sequence
< beans::Property
> SAL_CALL
getProperties() throw(uno::RuntimeException
);
163 virtual beans::Property SAL_CALL
getPropertyByName(const rtl::OUString
& _rPropertyName
) throw(beans::UnknownPropertyException
, uno::RuntimeException
);
164 virtual sal_Bool SAL_CALL
hasPropertyByName(const rtl::OUString
& _rPropertyName
) throw(uno::RuntimeException
);
167 //-----------------------------------------------------------------------------------
168 //-----------------------------------------------------------------------------------
169 NodePropertySetInfo
* NodePropertySetInfo::create(NodeGroupInfoAccess
& _rNode
, sal_Bool _bReadonly
) throw(uno::RuntimeException
)
173 rtl::Reference
< configuration::Tree
> aTree( _rNode
.getTree() );
174 OSL_ENSURE( !configuration::isEmpty(aTree
.get()), "WARNING: Getting Tree information requires a valid tree");
175 if (configuration::isEmpty(aTree
.get())) return NULL
;
177 configuration::NodeRef
aNode( _rNode
.getNodeRef() );
178 OSL_ENSURE( aNode
.isValid() && aTree
->isValidNode(aNode
.getOffset()), "ERROR: Tree does not match node");
180 uno::Sequence
< beans::Property
> aProperties
= CollectProperties(_bReadonly
).forChildren(aTree
,aNode
);
181 OSL_ENSURE( aProperties
.getLength() > 0, "ERROR: PropertySet (Configuration group) has no Properties");
183 return new NodePropertySetInfo( aProperties
);
186 //-----------------------------------------------------------------------------------
187 struct MatchName
// : std::unary_function< beans::Property, bool >
190 MatchName(rtl::OUString
const& _sName
) throw(uno::RuntimeException
)
195 bool operator()(beans::Property
const& _aProperty
) const
197 return !!(_aProperty
.Name
== this->sName
);
201 beans::Property
const* NodePropertySetInfo::find(const rtl::OUString
& _rPropertyName
) const throw(uno::RuntimeException
)
203 beans::Property
const* const first
= this->begin();
204 beans::Property
const* const last
= this->end();
206 return std::find_if(first
,last
,MatchName(_rPropertyName
));
209 //-----------------------------------------------------------------------------------
210 uno::Sequence
< beans::Property
> SAL_CALL
NodePropertySetInfo::getProperties() throw(uno::RuntimeException
)
212 return m_aProperties
;
214 //-----------------------------------------------------------------------------------
215 beans::Property SAL_CALL
NodePropertySetInfo::getPropertyByName(const rtl::OUString
& _rPropertyName
)
216 throw(beans::UnknownPropertyException
, uno::RuntimeException
)
220 beans::Property
const* pFound
= find(_rPropertyName
);
222 if (pFound
== this->end())
224 rtl::OUString sMessage
= rtl::OUString::createFromAscii("Configuration - ");
225 sMessage
+= rtl::OUString::createFromAscii("No Property named '");
226 sMessage
+= _rPropertyName
;
227 sMessage
+= rtl::OUString::createFromAscii("' in this PropertySetInfo");
228 throw beans::UnknownPropertyException(sMessage
, static_cast<XPropertySetInfo
*>(this));
234 //-----------------------------------------------------------------------------------
235 sal_Bool SAL_CALL
NodePropertySetInfo::hasPropertyByName(const rtl::OUString
& _rPropertyName
)
236 throw(uno::RuntimeException
)
240 beans::Property
const* pFound
= find(_rPropertyName
);
242 return (pFound
!= this->end());
246 //-----------------------------------------------------------------------------------
248 //-----------------------------------------------------------------------------------
249 // getting Property Metadata
250 //-----------------------------------------------------------------------------------
252 // XPropertySet & XMultiPropertySet
253 //-----------------------------------------------------------------------------------
254 uno::Reference
< beans::XPropertySetInfo
> implGetPropertySetInfo( NodeGroupInfoAccess
& rNode
, sal_Bool _bWriteable
)
255 throw(uno::RuntimeException
)
257 GuardedNodeData
<NodeAccess
> lock( rNode
);
258 return NodePropertySetInfo::create(rNode
, !_bWriteable
);
261 // XHierarchicalPropertySet & XHierarchicalMultiPropertySet
262 //-----------------------------------------------------------------------------------
263 uno::Reference
< beans::XHierarchicalPropertySetInfo
> implGetHierarchicalPropertySetInfo( NodeGroupInfoAccess
& /*rNode*/ )
264 throw(uno::RuntimeException
)
270 //-----------------------------------------------------------------------------------
271 // setting values - may all throw (PropertyVeto)Exceptions on read-only property sets
272 //-----------------------------------------------------------------------------------
275 //-----------------------------------------------------------------------------------
276 void implSetPropertyValue( NodeGroupAccess
& rNode
, const rtl::OUString
& sPropertyName
, const uno::Any
& aValue
)
277 throw(beans::UnknownPropertyException
, beans::PropertyVetoException
, lang::IllegalArgumentException
,
278 lang::WrappedTargetException
, uno::RuntimeException
)
282 GuardedNodeUpdate
<NodeGroupAccess
> lock( rNode
);
284 rtl::Reference
< configuration::Tree
> const aTree( lock
.getTree() );
285 configuration::NodeRef
const aNode( lock
.getNode() );
287 rtl::OUString aChildName
= configuration::validateChildName(sPropertyName
,aTree
,aNode
);
289 configuration::ValueRef
aChild( aTree
->getChildValue(aNode
, aChildName
) );
291 if (!aChild
.isValid())
293 if ( configuration::hasChildOrElement(aTree
, aNode
, aChildName
) )
295 OSL_ENSURE(aTree
->hasChildNode(aNode
, aChildName
),"ERROR: Configuration: Existing Property not found by implementation");
297 rtl::OUString
sMessage( RTL_CONSTASCII_USTRINGPARAM("Configuration - Cannot set Property Value.") );
298 sMessage
+= rtl::OUString( RTL_CONSTASCII_USTRINGPARAM(" Property '") );
299 sMessage
+= sPropertyName
;
300 sMessage
+= rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("' is not a simple value.") );
302 uno::Reference
<uno::XInterface
> xContext( rNode
.getUnoInstance() );
303 throw beans::PropertyVetoException( sMessage
, xContext
);
307 rtl::OUString
sMessage( RTL_CONSTASCII_USTRINGPARAM("Configuration - Cannot set Property Value.") );
308 sMessage
+= rtl::OUString( RTL_CONSTASCII_USTRINGPARAM(" Property '") );
309 sMessage
+= sPropertyName
;
310 sMessage
+= rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("' not found in ") );
311 sMessage
+= aTree
->getAbsolutePath(aNode
).toString();
313 uno::Reference
<uno::XInterface
> xContext( rNode
.getUnoInstance() );
314 throw beans::UnknownPropertyException( sMessage
, xContext
);
318 configuration::NodeChange aChange
= lock
.getNodeUpdater().validateSetValue( aChild
, aValue
);
319 if (aChange
.test().isChange())
321 Broadcaster
aSender(rNode
.getNotifier().makeBroadcaster(aChange
,true));
323 aSender
.queryConstraints(aChange
);
325 aTree
->integrate(aChange
, aNode
, true);
327 lock
.clearForBroadcast();
328 aSender
.notifyListeners(aChange
);
331 catch (configuration::InvalidName
& ex
)
333 ExceptionMapper
e(ex
);
334 rtl::OUString
sMessage( RTL_CONSTASCII_USTRINGPARAM("Configuration - Cannot set Property Value: ") );
335 uno::Reference
<uno::XInterface
> xContext( rNode
.getUnoInstance() );
336 throw beans::UnknownPropertyException( sMessage
+= e
.message(), xContext
);
338 catch (configuration::TypeMismatch
& ex
)
340 ExceptionMapper
e(ex
);
341 e
.setContext( rNode
.getUnoInstance() );
342 e
.illegalArgument(2);
344 catch (configuration::ConstraintViolation
& ex
)
346 ExceptionMapper
e(ex
);
347 rtl::OUString
sMessage( RTL_CONSTASCII_USTRINGPARAM("Configuration - Cannot set Property Value: ") );
348 uno::Reference
<uno::XInterface
> xContext( rNode
.getUnoInstance() );
349 throw beans::PropertyVetoException( sMessage
+= e
.message(), xContext
);
351 catch (configuration::Exception
& ex
)
353 ExceptionMapper
e(ex
);
354 e
.setContext( rNode
.getUnoInstance() );
360 //-----------------------------------------------------------------------------------
361 void implSetPropertyValues( NodeGroupAccess
& rNode
, const uno::Sequence
< rtl::OUString
>& aPropertyNames
, const uno::Sequence
< uno::Any
>& aValues
)
362 throw(beans::PropertyVetoException
, lang::IllegalArgumentException
,
363 lang::WrappedTargetException
, uno::RuntimeException
)
367 GuardedNodeUpdate
<NodeGroupAccess
> lock( rNode
);
369 rtl::Reference
< configuration::Tree
> const aTree( lock
.getTree() );
370 configuration::NodeRef
const aNode( lock
.getNode() );
372 configuration::NodeChanges aChanges
;
373 for(sal_Int32 i
= 0, count
= aValues
.getLength(); i
< count
; ++i
)
375 rtl::OUString
aChildName( aPropertyNames
[i
] ); // not validated
377 configuration::ValueRef
aChild( aTree
->getChildValue(aNode
, aChildName
) );
379 if (!aChild
.isValid())
381 if ( configuration::hasChildOrElement(aTree
, aNode
, aChildName
) )
383 OSL_ENSURE(aTree
->hasChildNode(aNode
, aChildName
),"ERROR: Configuration: Existing Property not found by implementation");
385 rtl::OUString
sMessage( RTL_CONSTASCII_USTRINGPARAM("Configuration - Cannot set Property Values.") );
386 sMessage
+= rtl::OUString( RTL_CONSTASCII_USTRINGPARAM(" Property '") );
387 sMessage
+= aChildName
;
388 sMessage
+= rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("' is not a simple value.") );
390 uno::Reference
<uno::XInterface
> xContext( rNode
.getUnoInstance() );
391 throw beans::PropertyVetoException( sMessage
, xContext
);
394 OSL_TRACE("Configuration: MultiPropertySet: trying to set unknown property - ignored");
398 configuration::NodeChange aChange
= lock
.getNodeUpdater().validateSetValue( aChild
, aValues
[i
] );
399 if (aChange
.maybeChange())
401 aChanges
.add(aChange
);
405 if (!aChanges
.test().compact().isEmpty())
407 Broadcaster
aSender(rNode
.getNotifier().makeBroadcaster(aChanges
,true));
409 aSender
.queryConstraints(aChanges
);
411 aTree
->integrate(aChanges
, aNode
, true);
413 lock
.clearForBroadcast();
414 aSender
.notifyListeners(aChanges
, true);
417 catch (configuration::TypeMismatch
& ex
)
419 ExceptionMapper
e(ex
);
420 e
.setContext( rNode
.getUnoInstance() );
421 e
.illegalArgument(2);
423 catch (configuration::ConstraintViolation
& ex
)
425 ExceptionMapper
e(ex
);
426 rtl::OUString
sMessage( RTL_CONSTASCII_USTRINGPARAM("Configuration - Cannot set Property Value: ") );
427 uno::Reference
<uno::XInterface
> xContext( rNode
.getUnoInstance() );
428 throw beans::PropertyVetoException( sMessage
+= e
.message(), xContext
);
430 catch (configuration::Exception
& ex
)
432 ExceptionMapper
e(ex
);
433 e
.setContext( rNode
.getUnoInstance() );
438 // XHierarchicalPropertySet
439 //-----------------------------------------------------------------------------------
440 void implSetHierarchicalPropertyValue( NodeGroupAccess
& rNode
, const rtl::OUString
& aPropertyName
, const uno::Any
& aValue
)
441 throw(beans::UnknownPropertyException
, beans::PropertyVetoException
, lang::IllegalArgumentException
,
442 lang::WrappedTargetException
, uno::RuntimeException
)
446 GuardedNodeUpdate
<NodeGroupAccess
> lock( rNode
);
448 rtl::Reference
< configuration::Tree
> const aTree( lock
.getTree() );
449 configuration::NodeRef
const aNode( lock
.getNode() );
451 configuration::RelativePath
const aRelPath
= configuration::validateRelativePath( aPropertyName
, aTree
, aNode
);
453 configuration::AnyNodeRef aNestedValue
= configuration::getLocalDescendant( aTree
, aNode
, aRelPath
);
455 if (!aNestedValue
.isValid())
457 rtl::OUString
sMessage( RTL_CONSTASCII_USTRINGPARAM("Configuration - Cannot set Property Value. Property '") );
458 sMessage
+= aRelPath
.toString();
459 sMessage
+= rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("' was not found in ") );
460 sMessage
+= aTree
->getAbsolutePath(aNode
).toString();
462 uno::Reference
<uno::XInterface
> xContext( rNode
.getUnoInstance() );
463 throw beans::UnknownPropertyException( sMessage
, xContext
);
465 if (aNestedValue
.isNode())
467 rtl::OUString
sMessage( RTL_CONSTASCII_USTRINGPARAM("Configuration - Cannot set Property Value. Property '") );
468 sMessage
+= aRelPath
.toString();
469 sMessage
+= rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("' is not a simple value property.") );
471 uno::Reference
<uno::XInterface
> xContext( rNode
.getUnoInstance() );
472 throw beans::PropertyVetoException( sMessage
, xContext
);
474 OSL_ASSERT(aNode
.isValid());
476 configuration::NodeChange aChange
= lock
.getNodeUpdater().validateSetValue( aNestedValue
.toValue(), aValue
);
477 if (aChange
.test().isChange())
479 Broadcaster
aSender(rNode
.getNotifier().makeBroadcaster(aChange
,false));
481 aSender
.queryConstraints(aChange
);
483 aTree
->integrate(aChange
, aNode
, false);
485 lock
.clearForBroadcast();
486 aSender
.notifyListeners(aChange
);
489 catch (configuration::InvalidName
& ex
)
491 ExceptionMapper
e(ex
);
492 rtl::OUString
sMessage( RTL_CONSTASCII_USTRINGPARAM("Configuration - Cannot set Property Value: ") );
493 uno::Reference
<uno::XInterface
> xContext( rNode
.getUnoInstance() );
494 throw beans::UnknownPropertyException( e
.message(), xContext
);
496 catch (configuration::TypeMismatch
& ex
)
498 ExceptionMapper
e(ex
);
499 e
.setContext( rNode
.getUnoInstance() );
500 e
.illegalArgument(2);
502 catch (configuration::ConstraintViolation
& ex
)
504 ExceptionMapper
e(ex
);
505 rtl::OUString
sMessage( RTL_CONSTASCII_USTRINGPARAM("Configuration - Cannot set Property Value: ") );
506 uno::Reference
<uno::XInterface
> xContext( rNode
.getUnoInstance() );
507 throw beans::PropertyVetoException( sMessage
+= e
.message(), xContext
);
509 catch (configuration::Exception
& ex
)
511 ExceptionMapper
e(ex
);
512 e
.setContext( rNode
.getUnoInstance() );
517 // XMultiHierarchicalPropertySet
518 //-----------------------------------------------------------------------------------
519 void implSetHierarchicalPropertyValues( NodeGroupAccess
& rNode
, const uno::Sequence
< rtl::OUString
>& aPropertyNames
, const uno::Sequence
< uno::Any
>& aValues
)
520 throw(beans::PropertyVetoException
, lang::IllegalArgumentException
,
521 lang::WrappedTargetException
, uno::RuntimeException
)
525 GuardedNodeUpdate
<NodeGroupAccess
> lock( rNode
);
527 rtl::Reference
< configuration::Tree
> const aTree( lock
.getTree() );
528 configuration::NodeRef
const aNode( lock
.getNode() );
530 configuration::NodeChanges aChanges
;
531 for(sal_Int32 i
= 0, count
= aValues
.getLength(); i
< count
; ++i
)
534 configuration::RelativePath aRelPath
= configuration::validateRelativePath( aPropertyNames
[i
], aTree
, aNode
);
536 configuration::AnyNodeRef aNestedValue
= configuration::getLocalDescendant( aTree
, aNode
, aRelPath
);
538 if (!aNestedValue
.isValid())
540 OSL_TRACE("Configuration: MultiPropertySet: trying to set unknown property - ignored");
543 if ( aNestedValue
.isNode() )
545 rtl::OUString
sMessage( RTL_CONSTASCII_USTRINGPARAM("Configuration - Cannot set Property Values.") );
546 sMessage
+= rtl::OUString( RTL_CONSTASCII_USTRINGPARAM(" Property '") );
547 sMessage
+= aRelPath
.toString();
548 sMessage
+= rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("' is not a simple value property.") );
550 uno::Reference
<uno::XInterface
> xContext( rNode
.getUnoInstance() );
551 throw beans::PropertyVetoException( sMessage
, xContext
);
553 OSL_ASSERT(aNode
.isValid());
555 configuration::NodeChange aChange
= lock
.getNodeUpdater().validateSetValue( aNestedValue
.toValue(), aValues
[i
] );
556 if (aChange
.maybeChange())
558 aChanges
.add(aChange
);
561 catch (configuration::InvalidName
& )
563 OSL_TRACE("Configuration: MultiHierarchicalPropertySet: trying to set property <invalid path> - ignored");
567 if (!aChanges
.test().compact().isEmpty())
569 Broadcaster
aSender(rNode
.getNotifier().makeBroadcaster(aChanges
,false));
571 aSender
.queryConstraints(aChanges
);
573 aTree
->integrate(aChanges
, aNode
, false);
575 lock
.clearForBroadcast();
576 aSender
.notifyListeners(aChanges
, true); // if we use 'false' we don't need 'Deep' change objects
579 catch (configuration::TypeMismatch
& ex
)
581 ExceptionMapper
e(ex
);
582 e
.setContext( rNode
.getUnoInstance() );
583 e
.illegalArgument(2);
585 catch (configuration::ConstraintViolation
& ex
)
587 ExceptionMapper
e(ex
);
588 rtl::OUString
sMessage( RTL_CONSTASCII_USTRINGPARAM("Configuration - Cannot set Property Value: ") );
589 uno::Reference
<uno::XInterface
> xContext( rNode
.getUnoInstance() );
590 throw beans::PropertyVetoException( sMessage
+= e
.message(), xContext
);
592 catch (configuration::Exception
& ex
)
594 ExceptionMapper
e(ex
);
595 e
.setContext( rNode
.getUnoInstance() );
600 //-----------------------------------------------------------------------------------
602 //-----------------------------------------------------------------------------------
605 //-----------------------------------------------------------------------------------
606 uno::Any
implGetPropertyValue( NodeGroupInfoAccess
& rNode
,const rtl::OUString
& aPropertyName
)
607 throw(beans::UnknownPropertyException
, lang::WrappedTargetException
, uno::RuntimeException
)
611 GuardedNodeData
<NodeAccess
> lock( rNode
);
613 rtl::Reference
< configuration::Tree
> const aTree( lock
.getTree() );
614 configuration::NodeRef
const aNode( lock
.getNode() );
616 rtl::OUString aChildName
= configuration::validateChildName(aPropertyName
,aTree
,aNode
);
618 configuration::AnyNodeRef
aChild( aTree
->getAnyChild(aNode
, aChildName
) );
620 if (!aChild
.isValid())
622 OSL_ENSURE(!configuration::hasChildOrElement(aTree
,aNode
,aChildName
),"ERROR: Configuration: Existing Property not found by implementation");
624 rtl::OUString
sMessage( RTL_CONSTASCII_USTRINGPARAM("Configuration - Cannot get Property Value. Property '") );
625 sMessage
+= aPropertyName
;
626 sMessage
+= rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("' could not be found in ") );
627 sMessage
+= aTree
->getAbsolutePath(aNode
).toString();
629 uno::Reference
<uno::XInterface
> xContext( rNode
.getUnoInstance() );
630 throw beans::UnknownPropertyException( sMessage
, xContext
);
633 return configapi::makeElement( rNode
.getFactory(), aTree
, aChild
);
635 catch (configuration::InvalidName
& ex
)
637 ExceptionMapper
e(ex
);
638 uno::Reference
<uno::XInterface
> xContext( rNode
.getUnoInstance() );
639 throw beans::UnknownPropertyException( e
.message(), xContext
);
641 catch (configuration::Exception
& ex
)
643 ExceptionMapper
e(ex
);
644 e
.setContext( rNode
.getUnoInstance() );
648 // unreachable, but still there to make some compilers happy
649 OSL_ASSERT(!"Unreachable code");
654 //-----------------------------------------------------------------------------------
655 uno::Sequence
< uno::Any
> implGetPropertyValues( NodeGroupInfoAccess
& rNode
, const uno::Sequence
< rtl::OUString
>& aPropertyNames
)
656 throw(uno::RuntimeException
)
658 sal_Int32
const count
= aPropertyNames
.getLength();
659 uno::Sequence
<uno::Any
> aRet(count
);
663 GuardedNodeData
<NodeAccess
> lock( rNode
);
665 rtl::Reference
< configuration::Tree
> const aTree( lock
.getTree() );
666 configuration::NodeRef
const aNode( lock
.getNode() );
668 for(sal_Int32 i
= 0; i
< count
; ++i
)
670 rtl::OUString
aChildName( aPropertyNames
[i
] ); // not validated
672 configuration::AnyNodeRef
aChild( aTree
->getAnyChild(aNode
, aChildName
) );
674 if (aChild
.isValid())
676 aRet
[i
] = configapi::makeElement( rNode
.getFactory(), aTree
, aChild
);
680 OSL_ENSURE(!configuration::hasChildOrElement(aTree
,aNode
,aChildName
),"ERROR: Configuration: Existing Property not found by implementation");
681 OSL_TRACE("Configuration: MultiPropertySet: trying to get unknown property - returning void");
685 catch (configuration::Exception
& ex
)
687 ExceptionMapper
e(ex
);
688 e
.setContext( rNode
.getUnoInstance() );
695 // XHierarchicalPropertySet
696 //-----------------------------------------------------------------------------------
697 uno::Any
implGetHierarchicalPropertyValue( NodeGroupInfoAccess
& rNode
, const rtl::OUString
& aPropertyName
)
698 throw(beans::UnknownPropertyException
, lang::WrappedTargetException
, uno::RuntimeException
)
702 GuardedNodeData
<NodeAccess
> lock( rNode
);
704 rtl::Reference
< configuration::Tree
> const aTree( lock
.getTree() );
705 configuration::NodeRef
const aNode( lock
.getNode() );
707 configuration::RelativePath aRelPath
= configuration::validateRelativePath( aPropertyName
, aTree
, aNode
);
709 configuration::AnyNodeRef aNestedNode
= configuration::getLocalDescendant( aTree
, aNode
, aRelPath
);
711 if (!aNestedNode
.isValid())
713 rtl::OUString
sMessage( RTL_CONSTASCII_USTRINGPARAM("Configuration - Cannot get Property Value. Property '") );
714 sMessage
+= aRelPath
.toString();
715 sMessage
+= rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("' could not be found in ") );
716 sMessage
+= aTree
->getAbsolutePath(aNode
).toString();
718 uno::Reference
<uno::XInterface
> xContext( rNode
.getUnoInstance() );
719 throw beans::UnknownPropertyException( sMessage
, xContext
);
721 OSL_ASSERT(aNode
.isValid());
723 return configapi::makeElement( rNode
.getFactory(), aTree
, aNestedNode
);
725 catch (configuration::InvalidName
& ex
)
727 ExceptionMapper
e(ex
);
728 uno::Reference
<uno::XInterface
> xContext( rNode
.getUnoInstance() );
729 throw beans::UnknownPropertyException( e
.message(), xContext
);
731 catch (configuration::Exception
& ex
)
733 ExceptionMapper
e(ex
);
734 e
.setContext( rNode
.getUnoInstance() );
738 // unreachable, but still there to make some compilers happy
739 OSL_ASSERT(!"Unreachable code");
743 // XMultiHierarchicalPropertySet
744 //-----------------------------------------------------------------------------------
745 uno::Sequence
< uno::Any
> implGetHierarchicalPropertyValues( NodeGroupInfoAccess
& rNode
, const uno::Sequence
< rtl::OUString
>& aPropertyNames
)
746 throw(uno::RuntimeException
)
748 sal_Int32
const count
= aPropertyNames
.getLength();
749 uno::Sequence
<uno::Any
> aRet(count
);
753 GuardedNodeData
<NodeAccess
> lock( rNode
);
755 rtl::Reference
< configuration::Tree
> const aTree( lock
.getTree() );
756 configuration::NodeRef
const aNode( lock
.getNode() );
758 for(sal_Int32 i
= 0; i
< count
; ++i
)
761 configuration::RelativePath aRelPath
= configuration::validateRelativePath( aPropertyNames
[i
], aTree
, aNode
);
763 configuration::AnyNodeRef aNestedValue
= configuration::getLocalDescendant( aTree
, aNode
, aRelPath
);
765 if (aNestedValue
.isValid())
767 aRet
[i
] = configapi::makeElement( rNode
.getFactory(), aTree
, aNestedValue
);
771 OSL_TRACE("Configuration: MultiPropertySet: trying to get unknown property - returning void");
774 catch (configuration::InvalidName
& )
776 OSL_TRACE("Configuration: MultiPropertySet: trying to get property from unknown path - returning void");
777 OSL_ASSERT(!aRet
[i
].hasValue());
780 catch (configuration::Exception
& ex
)
782 ExceptionMapper
e(ex
);
783 e
.setContext( rNode
.getUnoInstance() );
790 //------------------------------------------------------------------------------------------------------------------
791 // SPECIAL: XMultiPropertySet::firePropertiesChangeEvent
792 //------------------------------------------------------------------------------------------------------------------
794 void implFirePropertiesChangeEvent( NodeGroupInfoAccess
& rNode
, const uno::Sequence
< rtl::OUString
>& aPropertyNames
, const uno::Reference
< beans::XPropertiesChangeListener
>& xListener
)
795 throw(uno::RuntimeException
)
797 OSL_ENSURE(xListener
.is(), "ERROR: requesting to fire Events to a NULL listener.");
800 return; // should this be an exception ??
803 sal_Int32
const count
= aPropertyNames
.getLength();
804 uno::Sequence
<beans::PropertyChangeEvent
> aEvents(count
);
808 GuardedNodeData
<NodeAccess
> lock( rNode
);
810 rtl::Reference
< configuration::Tree
> const aTree( lock
.getTree() );
811 configuration::NodeRef
const aNode( lock
.getNode() );
812 configapi::Factory
& rFactory
= rNode
.getFactory();
816 for(sal_Int32 i
= 0; i
< count
; ++i
)
818 rtl::OUString
aChildName( aPropertyNames
[i
] ); // not validated
820 configuration::AnyNodeRef
aChild( aTree
->getAnyChild(aNode
, aChildName
) );
822 if (aChild
.isValid())
824 aEvents
[nFire
].Source
= rNode
.getUnoInstance();
825 aEvents
[nFire
].PropertyName
= aChildName
;
826 aEvents
[nFire
].PropertyHandle
= -1;
828 aEvents
[nFire
].NewValue
= aEvents
[nFire
].OldValue
= configapi::makeElement( rFactory
, aTree
, aChild
);
833 OSL_ENSURE(!configuration::hasChildOrElement(aTree
,aNode
,aChildName
),"ERROR: Configuration: Existing Property not found by implementation");
834 OSL_TRACE("Configuration: MultiPropertySet: request to fire unknown property - skipping");
838 if (nFire
< count
) aEvents
.realloc(nFire
);;
840 catch (configuration::Exception
& ex
)
842 ExceptionMapper
e(ex
);
843 e
.setContext( rNode
.getUnoInstance() );
847 xListener
->propertiesChange(aEvents
);
850 //------------------------------------------------------------------------------------------------------------------
852 //------------------------------------------------------------------------------------------------------------------
854 beans::PropertyState
implGetPropertyState( NodeAccess
& rNode
, const rtl::OUString
& sPropertyName
)
855 throw(beans::UnknownPropertyException
, uno::RuntimeException
)
859 GuardedNodeData
<NodeAccess
> lock( rNode
);
861 rtl::Reference
< configuration::Tree
> aTree( lock
.getTree() );
862 configuration::NodeRef
const aNode( lock
.getNode() );
864 rtl::OUString aChildName
= configuration::validateChildOrElementName(sPropertyName
,aTree
,aNode
);
866 configuration::AnyNodeRef aChild
= configuration::getChildOrElement(aTree
,aNode
,aChildName
);
867 if (!aChild
.isValid())
869 rtl::OUString
sMessage( RTL_CONSTASCII_USTRINGPARAM("Configuration - Cannot get PropertyState. Property '") );
870 sMessage
+= sPropertyName
;
871 sMessage
+= rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("' not found in ") );
872 sMessage
+= aTree
->getAbsolutePath(aNode
).toString();
874 uno::Reference
<uno::XInterface
> xContext( rNode
.getUnoInstance() );
875 throw beans::UnknownPropertyException( sMessage
, xContext
);
877 OSL_ASSERT(aNode
.isValid());
879 return aTree
->isNodeDefault(aChild
) ? beans::PropertyState_DEFAULT_VALUE
:
880 aChild
.isNode() ? beans::PropertyState_AMBIGUOUS_VALUE
:
881 beans::PropertyState_DIRECT_VALUE
;
883 catch (configuration::InvalidName
& ex
)
885 ExceptionMapper
e(ex
);
886 uno::Reference
<uno::XInterface
> xContext( rNode
.getUnoInstance() );
887 throw beans::UnknownPropertyException( e
.message(), xContext
);
889 catch (configuration::Exception
& ex
)
891 ExceptionMapper
e(ex
);
892 e
.setContext( rNode
.getUnoInstance() );
896 // unreachable, but still there to make some compilers happy
897 OSL_ASSERT(!"Unreachable code");
898 return beans::PropertyState_AMBIGUOUS_VALUE
;
901 //-----------------------------------------------------------------------------------
902 uno::Sequence
< beans::PropertyState
> implGetPropertyStates( NodeAccess
& rNode
, const uno::Sequence
< rtl::OUString
>& aPropertyNames
)
903 throw(beans::UnknownPropertyException
, uno::RuntimeException
)
905 sal_Int32
const count
= aPropertyNames
.getLength();
906 uno::Sequence
<beans::PropertyState
> aRet(count
);
910 GuardedNodeData
<NodeAccess
> lock( rNode
);
912 rtl::Reference
< configuration::Tree
> const aTree( lock
.getTree() );
913 configuration::NodeRef
const aNode( lock
.getNode() );
915 for(sal_Int32 i
= 0; i
< count
; ++i
)
917 rtl::OUString aChildName
= configuration::validateChildOrElementName(aPropertyNames
[i
],aTree
,aNode
);
919 rtl::Reference
< configuration::Tree
> aChildTree( aTree
);
921 configuration::AnyNodeRef aChildNode
= configuration::getChildOrElement(aChildTree
,aNode
,aChildName
);
922 if (!aChildNode
.isValid())
924 rtl::OUString
sMessage( RTL_CONSTASCII_USTRINGPARAM("Configuration - Cannot get PropertyStates. Property '") );
925 sMessage
+= aPropertyNames
[i
];
926 sMessage
+= rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("' could not be found in ") );
927 sMessage
+= aTree
->getAbsolutePath(aNode
).toString();
929 uno::Reference
<uno::XInterface
> xContext( rNode
.getUnoInstance() );
930 throw beans::UnknownPropertyException( sMessage
, xContext
);
932 OSL_ASSERT(aChildNode
.isValid());
934 aRet
[i
] = aChildTree
->isNodeDefault(aChildNode
) ? beans::PropertyState_DEFAULT_VALUE
:
935 aChildNode
.isNode() ? beans::PropertyState_AMBIGUOUS_VALUE
:
936 beans::PropertyState_DIRECT_VALUE
;
940 catch (configuration::InvalidName
& ex
)
942 ExceptionMapper
e(ex
);
943 uno::Reference
<uno::XInterface
> xContext( rNode
.getUnoInstance() );
944 throw beans::UnknownPropertyException( e
.message(), xContext
);
946 catch (configuration::Exception
& ex
)
948 ExceptionMapper
e(ex
);
949 e
.setContext( rNode
.getUnoInstance() );
956 //-----------------------------------------------------------------------------------
957 static inline configuration::NodeChange
validateSetToDefaultHelper(configuration::GroupDefaulter
& _rDefaulter
, configuration::AnyNodeRef _aNode
)
959 if (!_aNode
.isNode())
960 return _rDefaulter
.validateSetToDefaultValue( _aNode
.toValue() );
963 return _rDefaulter
.validateSetToDefaultState( _aNode
.toNode() );
965 //-----------------------------------------------------------------------------------
966 void implSetPropertyToDefault( NodeGroupAccess
& rNode
, const rtl::OUString
& sPropertyName
)
967 throw(beans::UnknownPropertyException
, uno::RuntimeException
)
971 UnoApiLock aWithDefaultLock
;
972 GuardedNodeUpdate
<NodeGroupAccess
> lock( withDefaultData( rNode
) );
974 rtl::Reference
< configuration::Tree
> const aTree( lock
.getTree() );
975 configuration::NodeRef
const aNode( lock
.getNode() );
977 configuration::GroupDefaulter aDefaulter
= lock
.getNodeDefaulter();
979 rtl::OUString aChildName
= configuration::validateChildName(sPropertyName
,aTree
,aNode
);
981 configuration::AnyNodeRef
aChild( aTree
->getAnyChild(aNode
, aChildName
) );
983 configuration::NodeChange aChange
= validateSetToDefaultHelper( aDefaulter
, aChild
);
985 const bool bLocal
= !aDefaulter
.hasDoneSet();
987 if (aChange
.test().isChange() )
989 Broadcaster
aSender(rNode
.getNotifier().makeBroadcaster(aChange
,bLocal
));
991 aSender
.queryConstraints(aChange
);
993 aTree
->integrate(aChange
, aNode
, bLocal
);
995 lock
.clearForBroadcast();
996 aSender
.notifyListeners(aChange
);
999 catch (configuration::InvalidName
& ex
)
1001 ExceptionMapper
e(ex
);
1002 rtl::OUString
sMessage( RTL_CONSTASCII_USTRINGPARAM("Configuration - Cannot restore Default: ") );
1003 uno::Reference
<uno::XInterface
> xContext( rNode
.getUnoInstance() );
1004 throw beans::UnknownPropertyException( sMessage
+= e
.message(), xContext
);
1006 catch (configuration::ConstraintViolation
& ex
)
1008 ExceptionMapper
e(ex
);
1009 rtl::OUString
sMessage( RTL_CONSTASCII_USTRINGPARAM("Configuration - Cannot restore Default: ") );
1010 uno::Reference
<uno::XInterface
> xContext( rNode
.getUnoInstance() );
1011 throw beans::UnknownPropertyException( sMessage
+= e
.message(), xContext
);
1013 catch (configuration::Exception
& ex
)
1015 ExceptionMapper
e(ex
);
1016 e
.setContext( rNode
.getUnoInstance() );
1020 //-----------------------------------------------------------------------------------
1021 void implSetPropertiesToDefault( NodeGroupAccess
& rNode
, const uno::Sequence
< rtl::OUString
>& aPropertyNames
)
1022 throw(beans::UnknownPropertyException
, uno::RuntimeException
)
1026 UnoApiLock aWithDefaultLock
;
1027 GuardedNodeUpdate
<NodeGroupAccess
> lock( withDefaultData( rNode
) );
1029 rtl::Reference
< configuration::Tree
> const aTree( lock
.getTree() );
1030 configuration::NodeRef
const aNode( lock
.getNode() );
1032 configuration::GroupDefaulter aDefaulter
= lock
.getNodeDefaulter();
1034 configuration::NodeChanges aChanges
;
1035 for(sal_Int32 i
= 0, count
= aPropertyNames
.getLength(); i
< count
; ++i
)
1037 rtl::OUString aChildName
= configuration::validateChildName( aPropertyNames
[i
], aTree
, aNode
); // validated
1039 configuration::AnyNodeRef
aChild( aTree
->getAnyChild(aNode
, aChildName
) );
1041 if (!aChild
.isValid())
1043 OSL_ENSURE(!configuration::hasChildOrElement(aTree
, aNode
, aChildName
),"ERROR: Configuration: Existing Property not found by implementation");
1045 rtl::OUString
sMessage( RTL_CONSTASCII_USTRINGPARAM("Configuration - Cannot restore Default.") );
1046 sMessage
+= rtl::OUString( RTL_CONSTASCII_USTRINGPARAM(" Property '") );
1047 sMessage
+= aChildName
;
1048 sMessage
+= rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("' not found in ") );
1049 sMessage
+= aTree
->getAbsolutePath(aNode
).toString();
1051 uno::Reference
<uno::XInterface
> xContext( rNode
.getUnoInstance() );
1052 throw beans::UnknownPropertyException( sMessage
, xContext
);
1054 OSL_ASSERT(aNode
.isValid());
1056 if (!aTree
->hasNodeDefault(aChild
))
1058 rtl::OUString
sMessage( RTL_CONSTASCII_USTRINGPARAM("Configuration - Cannot restore Default.") );
1059 sMessage
+= rtl::OUString( RTL_CONSTASCII_USTRINGPARAM(" Property '") );
1060 sMessage
+= aChildName
;
1062 if (aChild
.isNode())
1063 sMessage
+= rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("' is not a simple value.") );
1066 sMessage
+= rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("' does not have a default value.") );
1068 uno::Reference
<uno::XInterface
> xContext( rNode
.getUnoInstance() );
1069 throw beans::UnknownPropertyException( sMessage
, xContext
);
1072 configuration::NodeChange aChildChange
= validateSetToDefaultHelper(aDefaulter
, aChild
);
1073 if (aChildChange
.maybeChange())
1074 aChanges
.add(aChildChange
);
1077 const bool bLocal
= !aDefaulter
.hasDoneSet();
1079 if (!aChanges
.test().compact().isEmpty())
1081 Broadcaster
aSender(rNode
.getNotifier().makeBroadcaster(aChanges
,bLocal
));
1083 aSender
.queryConstraints(aChanges
);
1085 aTree
->integrate(aChanges
, aNode
, bLocal
);
1087 lock
.clearForBroadcast();
1088 aSender
.notifyListeners(aChanges
, bLocal
);
1092 catch (configuration::InvalidName
& ex
)
1094 ExceptionMapper
e(ex
);
1095 rtl::OUString
sMessage( RTL_CONSTASCII_USTRINGPARAM("Configuration - Cannot restore Defaults: ") );
1096 uno::Reference
<uno::XInterface
> xContext( rNode
.getUnoInstance() );
1097 throw beans::UnknownPropertyException( sMessage
+= e
.message(), xContext
);
1099 catch (configuration::ConstraintViolation
& ex
)
1101 ExceptionMapper
e(ex
);
1102 rtl::OUString
sMessage( RTL_CONSTASCII_USTRINGPARAM("Configuration - Cannot restore Defaults: ") );
1103 uno::Reference
<uno::XInterface
> xContext( rNode
.getUnoInstance() );
1104 throw beans::UnknownPropertyException( sMessage
+= e
.message(), xContext
);
1106 catch (configuration::Exception
& ex
)
1108 ExceptionMapper
e(ex
);
1109 e
.setContext( rNode
.getUnoInstance() );
1114 //-----------------------------------------------------------------------------------
1115 void implSetAllPropertiesToDefault( NodeGroupAccess
& rNode
)
1116 throw(uno::RuntimeException
)
1120 UnoApiLock aWithDefaultLock
;
1121 GuardedNodeUpdate
<NodeGroupAccess
> lock( withDefaultData( rNode
) );
1123 rtl::Reference
< configuration::Tree
> const aTree( lock
.getTree() );
1124 configuration::NodeRef
const aNode( lock
.getNode() );
1126 configuration::GroupDefaulter aDefaulter
= lock
.getNodeDefaulter();
1128 configuration::NodeChanges aChanges
= aDefaulter
.validateSetAllToDefault( );
1130 const bool bLocal
= !aDefaulter
.hasDoneSet();
1132 if (!aChanges
.test().compact().isEmpty())
1134 Broadcaster
aSender(rNode
.getNotifier().makeBroadcaster(aChanges
,bLocal
));
1136 aSender
.queryConstraints(aChanges
);
1138 aTree
->integrate(aChanges
, aNode
, bLocal
);
1140 lock
.clearForBroadcast();
1141 aSender
.notifyListeners(aChanges
, bLocal
);
1145 catch (configuration::InvalidName
& ex
)
1147 ExceptionMapper
e(ex
);
1148 rtl::OUString
sMessage( RTL_CONSTASCII_USTRINGPARAM("Configuration - Cannot restore Defaults: ") );
1149 uno::Reference
<uno::XInterface
> xContext( rNode
.getUnoInstance() );
1150 throw beans::UnknownPropertyException( sMessage
+= e
.message(), xContext
);
1152 catch (configuration::ConstraintViolation
& ex
)
1154 ExceptionMapper
e(ex
);
1155 rtl::OUString
sMessage( RTL_CONSTASCII_USTRINGPARAM("Configuration - Cannot restore Defaults: ") );
1156 uno::Reference
<uno::XInterface
> xContext( rNode
.getUnoInstance() );
1157 throw beans::UnknownPropertyException( sMessage
+= e
.message(), xContext
);
1159 catch (configuration::Exception
& ex
)
1161 ExceptionMapper
e(ex
);
1162 e
.setContext( rNode
.getUnoInstance() );
1167 //-----------------------------------------------------------------------------------
1168 uno::Any
implGetPropertyDefault( NodeGroupInfoAccess
& rNode
, const rtl::OUString
& sPropertyName
)
1169 throw(beans::UnknownPropertyException
, lang::WrappedTargetException
, uno::RuntimeException
)
1174 GuardedNodeData
<NodeAccess
> lock( rNode
);
1176 rtl::Reference
< configuration::Tree
> const aTree( lock
.getTree() );
1177 configuration::NodeRef
const aNode( lock
.getNode() );
1179 rtl::OUString aChildName
= configuration::validateChildName(sPropertyName
,aTree
,aNode
);
1181 configuration::AnyNodeRef aChildNode
= aTree
->getAnyChild(aNode
, aChildName
);
1182 if (!aChildNode
.isValid())
1184 rtl::OUString
sMessage( RTL_CONSTASCII_USTRINGPARAM("Configuration - Cannot get Default. Property '") );
1185 sMessage
+= sPropertyName
;
1186 sMessage
+= rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("' not found in ") );
1187 sMessage
+= aTree
->getAbsolutePath(aNode
).toString();
1189 uno::Reference
<uno::XInterface
> xContext( rNode
.getUnoInstance() );
1190 throw beans::UnknownPropertyException( sMessage
, xContext
);
1192 OSL_ASSERT(aNode
.isValid());
1194 if (!aChildNode
.isNode())
1196 aDefault
= aTree
->getNodeDefaultValue(aChildNode
.toValue());
1199 catch (configuration::InvalidName
& ex
)
1201 ExceptionMapper
e(ex
);
1202 uno::Reference
<uno::XInterface
> xContext( rNode
.getUnoInstance() );
1203 throw beans::UnknownPropertyException( e
.message(), xContext
);
1205 catch (configuration::ConstraintViolation
& ex
)
1207 ExceptionMapper
e(ex
);
1208 rtl::OUString
sMessage( RTL_CONSTASCII_USTRINGPARAM("Configuration - Cannot get Default: ") );
1209 uno::Reference
<uno::XInterface
> xContext( rNode
.getUnoInstance() );
1210 throw beans::UnknownPropertyException( sMessage
+= e
.message(), xContext
);
1212 catch (configuration::Exception
& ex
)
1214 ExceptionMapper
e(ex
);
1215 e
.setContext( rNode
.getUnoInstance() );
1222 //-----------------------------------------------------------------------------------
1223 uno::Sequence
< uno::Any
> implGetPropertyDefaults( NodeGroupInfoAccess
& rNode
, const uno::Sequence
< rtl::OUString
>& aPropertyNames
)
1224 throw(beans::UnknownPropertyException
, lang::WrappedTargetException
, uno::RuntimeException
)
1226 sal_Int32
const count
= aPropertyNames
.getLength();
1227 uno::Sequence
<uno::Any
> aDefaults(count
);
1231 GuardedNodeData
<NodeAccess
> lock( rNode
);
1233 rtl::Reference
< configuration::Tree
> const aTree( lock
.getTree() );
1234 configuration::NodeRef
const aNode( lock
.getNode() );
1236 for(sal_Int32 i
= 0; i
< count
; ++i
)
1238 rtl::OUString aChildName
= configuration::validateChildName(aPropertyNames
[i
],aTree
,aNode
);
1240 configuration::AnyNodeRef aChildNode
= aTree
->getAnyChild(aNode
, aChildName
);
1241 if (!aChildNode
.isValid())
1243 rtl::OUString
sMessage( RTL_CONSTASCII_USTRINGPARAM("Configuration - Cannot get Default. Property '") );
1244 sMessage
+= aPropertyNames
[i
];
1245 sMessage
+= rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("' not found in ") );
1246 sMessage
+= aTree
->getAbsolutePath(aNode
).toString();
1248 uno::Reference
<uno::XInterface
> xContext( rNode
.getUnoInstance() );
1249 throw beans::UnknownPropertyException( sMessage
, xContext
);
1251 OSL_ASSERT(aNode
.isValid());
1253 if (!aChildNode
.isNode())
1255 aDefaults
[i
] = aTree
->getNodeDefaultValue(aChildNode
.toValue());
1259 catch (configuration::InvalidName
& ex
)
1261 ExceptionMapper
e(ex
);
1262 uno::Reference
<uno::XInterface
> xContext( rNode
.getUnoInstance() );
1263 throw beans::UnknownPropertyException( e
.message(), xContext
);
1265 catch (configuration::ConstraintViolation
& ex
)
1267 ExceptionMapper
e(ex
);
1268 rtl::OUString
sMessage( RTL_CONSTASCII_USTRINGPARAM("Configuration - Cannot get Default: ") );
1269 uno::Reference
<uno::XInterface
> xContext( rNode
.getUnoInstance() );
1270 throw beans::UnknownPropertyException( sMessage
+= e
.message(), xContext
);
1272 catch (configuration::Exception
& ex
)
1274 ExceptionMapper
e(ex
);
1275 e
.setContext( rNode
.getUnoInstance() );
1282 //-----------------------------------------------------------------------------------
1283 } // namespace configapi
1285 } // namespace configmgr