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: updateimpl.cxx,v $
10 * $Revision: 1.15.20.8 $
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 "updateimpl.hxx"
35 #include "accessimpl.hxx"
36 #include "apinodeaccess.hxx"
37 #include "apinodeupdate.hxx"
38 #include "noderef.hxx"
39 #include "valueref.hxx"
40 #include "nodechange.hxx"
41 #include "configset.hxx"
42 #include "configgroup.hxx"
43 #include "confignotifier.hxx"
44 #include "broadcaster.hxx"
45 #include <com/sun/star/lang/DisposedException.hpp>
46 #include <com/sun/star/beans/PropertyVetoException.hpp>
47 #include <osl/diagnose.h>
53 //-----------------------------------------------------------------------------------
54 namespace lang
= css::lang
;
55 namespace util
= css::util
;
56 namespace container
= css::container
;
59 //-----------------------------------------------------------------------------------
61 //-----------------------------------------------------------------------------------
63 //-----------------------------------------------------------------------------------
66 //-----------------------------------------------------------------------------------
67 void implReplaceByName(NodeGroupAccess
& rNode
, const rtl::OUString
& sName
, const uno::Any
& rElement
)
68 throw(lang::IllegalArgumentException
, container::NoSuchElementException
, lang::WrappedTargetException
, uno::RuntimeException
)
72 GuardedNodeUpdate
<NodeGroupAccess
> lock( rNode
);
74 rtl::Reference
< configuration::Tree
> const aTree( lock
.getTree() );
75 configuration::NodeRef
const aNode( lock
.getNode() );
77 rtl::OUString aChildName
= configuration::validateChildName(sName
,aTree
,aNode
);
79 configuration::ValueRef
aChildValue( aTree
->getChildValue(aNode
, aChildName
) );
81 if (!aChildValue
.isValid())
83 if (aTree
->hasChildNode(aNode
, aChildName
))
85 rtl::OUString
sMessage( RTL_CONSTASCII_USTRINGPARAM("Configuration - Cannot set Value. Node '") );
87 sMessage
+= rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("' is not a simple value.") );
89 uno::Reference
<uno::XInterface
> xContext( rNode
.getUnoInstance() );
90 throw lang::IllegalArgumentException( sMessage
, xContext
, 2 );
94 OSL_ENSURE(!configuration::hasChildOrElement(aTree
,aNode
,aChildName
),"ERROR: Configuration: Existing child node not found by implementation");
95 rtl::OUString
sMessage( RTL_CONSTASCII_USTRINGPARAM("Configuration - Cannot set Value. Value '") );
97 sMessage
+= rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("' not found in ") );
98 sMessage
+= aTree
->getAbsolutePath(aNode
).toString();
100 uno::Reference
<uno::XInterface
> xContext( rNode
.getUnoInstance() );
101 throw container::NoSuchElementException( sMessage
, xContext
);
105 configuration::NodeChange aChange
= lock
.getNodeUpdater().validateSetValue(aChildValue
, rElement
);
107 if (aChange
.test().isChange())
109 Broadcaster
aSender(rNode
.getNotifier().makeBroadcaster(aChange
,true));
110 // lock.clearForBroadcast();
112 aSender
.queryConstraints(aChange
);
114 aTree
->integrate(aChange
, aNode
, true);
116 lock
.clearForBroadcast();
117 aSender
.notifyListeners(aChange
);
120 catch (configuration::InvalidName
& ex
)
122 ExceptionMapper
e(ex
);
123 rtl::OUString
sMessage( RTL_CONSTASCII_USTRINGPARAM("Configuration - Cannot set Value: ") );
124 uno::Reference
<uno::XInterface
> xContext( rNode
.getUnoInstance() );
125 throw container::NoSuchElementException( e
.message(), xContext
);
127 catch (configuration::TypeMismatch
& ex
)
129 ExceptionMapper
e(ex
);
130 e
.setContext( rNode
.getUnoInstance() );
131 e
.illegalArgument(2);
133 catch (configuration::ConstraintViolation
& ex
)
135 ExceptionMapper
e(ex
);
136 e
.setContext( rNode
.getUnoInstance() );
137 e
.illegalArgument(2);
139 catch (configuration::Exception
& ex
)
141 ExceptionMapper
e(ex
);
142 e
.setContext( rNode
.getUnoInstance() );
145 catch (css::beans::PropertyVetoException
& ex
)
147 rtl::OUString
sMessage( RTL_CONSTASCII_USTRINGPARAM("Configuration - Cannot set Value. Change was Vetoed: ") );
148 throw lang::WrappedTargetException( sMessage
+= ex
.Message
, rNode
.getUnoInstance(), uno::makeAny(ex
) );
151 //-----------------------------------------------------------------------------------
153 void implReplaceByName(NodeTreeSetAccess
& rNode
, const rtl::OUString
& sName
, const uno::Any
& rElement
)
154 throw(lang::IllegalArgumentException
, container::NoSuchElementException
, lang::WrappedTargetException
, uno::RuntimeException
)
158 GuardedNodeUpdate
<NodeTreeSetAccess
> lock( rNode
);
160 rtl::Reference
< configuration::Tree
> const aTree( lock
.getTree() );
161 configuration::NodeRef
const aNode( lock
.getNode() );
163 rtl::OUString aChildName
= configuration::validateElementName(sName
,aTree
,aNode
);
165 rtl::Reference
< configuration::ElementTree
> aElement( aTree
->getElement(aNode
,aChildName
) );
169 OSL_ENSURE(!configuration::hasChildOrElement(aTree
,aNode
,aChildName
),"ERROR: Configuration: Existing Set element not found by implementation");
171 rtl::OUString
sMessage( RTL_CONSTASCII_USTRINGPARAM("Configuration - Cannot replace Set Element. Element '") );
173 sMessage
+= rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("' not found in Set ") );
174 sMessage
+= aTree
->getAbsolutePath(aNode
).toString();
176 uno::Reference
<uno::XInterface
> xContext( rNode
.getUnoInstance() );
177 throw container::NoSuchElementException( sMessage
, xContext
);
180 rtl::Reference
< configuration::ElementTree
> aElementTree
= configapi::extractElementTree(rNode
.getFactory(), rElement
, rNode
.getElementInfo());
181 if (!aElementTree
.is())
183 rtl::OUString
sMessage( RTL_CONSTASCII_USTRINGPARAM("Configuration - Cannot replace Set Element: ") );
184 sMessage
+= rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("Replacing object was not created from this set's template") );
186 uno::Reference
<uno::XInterface
> xContext( rNode
.getUnoInstance() );
187 throw lang::IllegalArgumentException( sMessage
, xContext
, 2 );
190 configuration::NodeChange aChange
= lock
.getNodeUpdater().validateReplaceElement( aElement
, aElementTree
);
192 if (aChange
.test().isChange())
194 Broadcaster
aSender(rNode
.getNotifier().makeBroadcaster(aChange
,true));
196 //aSender.queryConstraints(aChange); - N/A: no external constraints on set children possible
198 aTree
->integrate(aChange
, aNode
, true);
199 attachSetElement(rNode
, aElementTree
);
201 lock
.clearForBroadcast();
202 aSender
.notifyListeners(aChange
);
205 catch (configuration::InvalidName
& ex
)
207 ExceptionMapper
e(ex
);
208 rtl::OUString
sMessage( RTL_CONSTASCII_USTRINGPARAM("Configuration - Cannot replace Set Element: ") );
209 uno::Reference
<uno::XInterface
> xContext( rNode
.getUnoInstance() );
210 throw container::NoSuchElementException( e
.message(), xContext
);
212 catch (configuration::TypeMismatch
& ex
)
214 ExceptionMapper
e(ex
);
215 e
.setContext( rNode
.getUnoInstance() );
216 e
.illegalArgument(2);
218 catch (configuration::Exception
& ex
)
220 ExceptionMapper
e(ex
);
221 e
.setContext( rNode
.getUnoInstance() );
225 //-----------------------------------------------------------------------------------
227 void implReplaceByName(NodeValueSetAccess
& rNode
, const rtl::OUString
& sName
, const uno::Any
& rElement
)
228 throw(lang::IllegalArgumentException
, container::NoSuchElementException
, lang::WrappedTargetException
, uno::RuntimeException
)
232 GuardedNodeUpdate
<NodeValueSetAccess
> lock( rNode
);
234 rtl::Reference
< configuration::Tree
> const aTree( lock
.getTree() );
235 configuration::NodeRef
const aNode( lock
.getNode() );
237 rtl::OUString aChildName
= configuration::validateElementName(sName
,aTree
,aNode
);
239 rtl::Reference
< configuration::ElementTree
> aElement( aTree
->getElement(aNode
,aChildName
) );
243 OSL_ENSURE(!configuration::hasChildOrElement(aTree
,aNode
,aChildName
),"ERROR: Configuration: Existing Set element not found by implementation");
245 rtl::OUString
sMessage( RTL_CONSTASCII_USTRINGPARAM("Configuration - Cannot replace Set Element. Element '") );
247 sMessage
+= rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("' not found in Set ") );
248 sMessage
+= aTree
->getAbsolutePath(aNode
).toString();
250 uno::Reference
<uno::XInterface
> xContext( rNode
.getUnoInstance() );
251 throw container::NoSuchElementException( sMessage
, xContext
);
254 configuration::NodeChange aChange
= lock
.getNodeUpdater().validateReplaceElement( aElement
, rElement
);
256 if (aChange
.test().isChange())
258 Broadcaster
aSender(rNode
.getNotifier().makeBroadcaster(aChange
,true));
260 //aSender.queryConstraints(aChange); - N/A: no external constraints on set children possible
262 aTree
->integrate(aChange
, aNode
, true);
264 lock
.clearForBroadcast();
265 aSender
.notifyListeners(aChange
);
268 catch (configuration::InvalidName
& ex
)
270 ExceptionMapper
e(ex
);
271 rtl::OUString
sMessage( RTL_CONSTASCII_USTRINGPARAM("Configuration - Cannot replace Set Element: ") );
272 uno::Reference
<uno::XInterface
> xContext( rNode
.getUnoInstance() );
273 throw container::NoSuchElementException( e
.message(), xContext
);
275 catch (configuration::TypeMismatch
& ex
)
277 ExceptionMapper
e(ex
);
278 e
.setContext( rNode
.getUnoInstance() );
279 e
.illegalArgument(2);
281 catch (configuration::ConstraintViolation
& ex
)
283 ExceptionMapper
e(ex
);
284 e
.setContext( rNode
.getUnoInstance() );
285 e
.illegalArgument(2);
287 catch (configuration::Exception
& ex
)
289 ExceptionMapper
e(ex
);
290 e
.setContext( rNode
.getUnoInstance() );
296 //-----------------------------------------------------------------------------------
297 void implInsertByName(NodeTreeSetAccess
& rNode
, const rtl::OUString
& sName
, const uno::Any
& rElement
)
298 throw(lang::IllegalArgumentException
, container::ElementExistException
, lang::WrappedTargetException
, uno::RuntimeException
)
302 GuardedNodeUpdate
<NodeTreeSetAccess
> lock( rNode
);
304 rtl::Reference
< configuration::Tree
> const aTree( lock
.getTree() );
305 configuration::NodeRef
const aNode( lock
.getNode() );
307 rtl::OUString aChildName
= configuration::validateElementName(sName
,aTree
,aNode
);
309 if( aTree
->hasElement(aNode
,aChildName
) )
311 rtl::OUString
sMessage( RTL_CONSTASCII_USTRINGPARAM("Configuration - Cannot insert into Set. Element '") );
313 sMessage
+= rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("' is already present in Set ") );
314 sMessage
+= aTree
->getAbsolutePath(aNode
).toString();
316 uno::Reference
<uno::XInterface
> xContext( rNode
.getUnoInstance() );
317 throw container::ElementExistException( sMessage
, xContext
);
319 OSL_ENSURE(!configuration::hasChildOrElement(aTree
,aNode
,aChildName
),"ERROR: Configuration: Existing Set element not found by implementation");
321 rtl::Reference
< configuration::ElementTree
> aElementTree
= configapi::extractElementTree(rNode
.getFactory(), rElement
, rNode
.getElementInfo());
322 if (!aElementTree
.is())
324 rtl::OUString
sMessage( RTL_CONSTASCII_USTRINGPARAM("Configuration - Cannot insert into Set: ") );
325 sMessage
+= rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("Inserted object was not created from this set's template") );
327 uno::Reference
<uno::XInterface
> xContext( rNode
.getUnoInstance() );
328 throw lang::IllegalArgumentException( sMessage
, xContext
, 2 );
331 configuration::NodeChange aChange
= lock
.getNodeUpdater().validateInsertElement(aChildName
, aElementTree
);
333 aChange
.test(); // make sure old values are set up correctly
334 OSL_ENSURE(aChange
.isChange(), "ERROR: Adding a node validated as empty change");
336 Broadcaster
aSender(rNode
.getNotifier().makeBroadcaster(aChange
,true));
338 //aSender.queryConstraints(); - N/A: no external constraints on set children possible
340 aTree
->integrate(aChange
, aNode
, true);
341 attachSetElement(rNode
, aElementTree
);
343 lock
.clearForBroadcast();
344 aSender
.notifyListeners(aChange
);
346 catch (configuration::InvalidName
& ex
)
348 ExceptionMapper
e(ex
);
349 e
.setContext( rNode
.getUnoInstance() );
350 e
.illegalArgument( 1 );
352 catch (configuration::TypeMismatch
& ex
)
354 ExceptionMapper
e(ex
);
355 e
.setContext( rNode
.getUnoInstance() );
356 e
.illegalArgument(2);
358 catch (configuration::Exception
& ex
)
360 ExceptionMapper
e(ex
);
361 e
.setContext( rNode
.getUnoInstance() );
367 //-----------------------------------------------------------------------------------
369 void implInsertByName(NodeValueSetAccess
& rNode
, const rtl::OUString
& sName
, const uno::Any
& rElement
)
370 throw(lang::IllegalArgumentException
, container::ElementExistException
, lang::WrappedTargetException
, uno::RuntimeException
)
374 GuardedNodeUpdate
<NodeValueSetAccess
> lock( rNode
);
376 rtl::Reference
< configuration::Tree
> const aTree( lock
.getTree() );
377 configuration::NodeRef
const aNode( lock
.getNode() );
379 rtl::OUString aChildName
= configuration::validateElementName(sName
,aTree
,aNode
);
381 if( aTree
->hasElement(aNode
,aChildName
) )
383 rtl::OUString
sMessage( RTL_CONSTASCII_USTRINGPARAM("Configuration - Cannot insert into Set. Element '") );
385 sMessage
+= rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("' is already present in Set ") );
386 sMessage
+= aTree
->getAbsolutePath(aNode
).toString();
388 uno::Reference
<uno::XInterface
> xContext( rNode
.getUnoInstance() );
389 throw container::ElementExistException( sMessage
, xContext
);
391 OSL_ENSURE(!configuration::hasChildOrElement(aTree
,aNode
,aChildName
),"ERROR: Configuration: Existing Set element not found by implementation");
393 configuration::NodeChange aChange
= lock
.getNodeUpdater().validateInsertElement(aChildName
, rElement
);
395 aChange
.test(); // make sure old values are set up correctly
396 OSL_ENSURE(aChange
.isChange(), "ERROR: Adding a node validated as empty change");
398 Broadcaster
aSender(rNode
.getNotifier().makeBroadcaster(aChange
,true));
400 //aSender.queryConstraints(); - N/A: no external constraints on set children possible
402 aTree
->integrate(aChange
, aNode
, true);
404 lock
.clearForBroadcast();
405 aSender
.notifyListeners(aChange
);
407 catch (configuration::InvalidName
& ex
)
409 ExceptionMapper
e(ex
);
410 e
.setContext( rNode
.getUnoInstance() );
411 e
.illegalArgument( 1 );
413 catch (configuration::TypeMismatch
& ex
)
415 ExceptionMapper
e(ex
);
416 e
.setContext( rNode
.getUnoInstance() );
417 e
.illegalArgument(2);
419 catch (configuration::ConstraintViolation
& ex
)
421 ExceptionMapper
e(ex
);
422 e
.setContext( rNode
.getUnoInstance() );
423 e
.illegalArgument(2);
425 catch (configuration::Exception
& ex
)
427 ExceptionMapper
e(ex
);
428 e
.setContext( rNode
.getUnoInstance() );
434 //-----------------------------------------------------------------------------------
435 void implRemoveByName(NodeTreeSetAccess
& rNode
, const rtl::OUString
& sName
)
436 throw(css::container::NoSuchElementException
, lang::WrappedTargetException
, uno::RuntimeException
)
440 GuardedNodeUpdate
<NodeTreeSetAccess
> lock( rNode
);
442 rtl::Reference
< configuration::Tree
> const aTree( lock
.getTree() );
443 configuration::NodeRef
const aNode( lock
.getNode() );
445 rtl::OUString aChildName
= configuration::validateElementName(sName
,aTree
,aNode
);
447 rtl::Reference
< configuration::ElementTree
> aElement( aTree
->getElement(aNode
,aChildName
) );
451 OSL_ENSURE(!configuration::hasChildOrElement(aTree
,aNode
,aChildName
),"ERROR: Configuration: Existing Set element not found by implementation");
453 rtl::OUString
sMessage( RTL_CONSTASCII_USTRINGPARAM("Configuration - Cannot remove Set Element. Element '") );
455 sMessage
+= rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("' not found in Set ") );
456 sMessage
+= aTree
->getAbsolutePath(aNode
).toString();
458 uno::Reference
<uno::XInterface
> xContext( rNode
.getUnoInstance() );
459 throw container::NoSuchElementException( sMessage
, xContext
);
462 configuration::NodeChange aChange
= lock
.getNodeUpdater().validateRemoveElement(aElement
);
464 aChange
.test(); // make sure old values are set up correctly
465 OSL_ENSURE(aChange
.isChange(), "ERROR: Removing a node validated as empty change");
467 Broadcaster
aSender(rNode
.getNotifier().makeBroadcaster(aChange
,true));
469 //aSender.queryConstraints(); - N/A: no external constraints on set children possible
471 aTree
->integrate(aChange
, aNode
, true);
472 detachSetElement(rNode
.getFactory(), aElement
);
474 lock
.clearForBroadcast();
475 aSender
.notifyListeners(aChange
);
477 catch (configuration::InvalidName
& ex
)
479 ExceptionMapper
e(ex
);
480 rtl::OUString
sMessage( RTL_CONSTASCII_USTRINGPARAM("Configuration - Cannot remove Set Element: ") );
481 uno::Reference
<uno::XInterface
> xContext( rNode
.getUnoInstance() );
482 throw container::NoSuchElementException( sMessage
+= e
.message(), xContext
);
484 catch (configuration::Exception
& ex
)
486 ExceptionMapper
e(ex
);
487 e
.setContext( rNode
.getUnoInstance() );
492 //-----------------------------------------------------------------------------------
493 void implRemoveByName(NodeValueSetAccess
& rNode
, const rtl::OUString
& sName
)
494 throw(css::container::NoSuchElementException
, lang::WrappedTargetException
, uno::RuntimeException
)
498 GuardedNodeUpdate
<NodeValueSetAccess
> lock( rNode
);
500 rtl::Reference
< configuration::Tree
> const aTree( lock
.getTree() );
501 configuration::NodeRef
const aNode( lock
.getNode() );
503 rtl::OUString aChildName
= configuration::validateElementName(sName
,aTree
,aNode
);
505 rtl::Reference
< configuration::ElementTree
> aElement
= aTree
->getElement(aNode
,aChildName
);
508 OSL_ENSURE(!configuration::hasChildOrElement(aTree
,aNode
,aChildName
),"ERROR: Configuration: Existing Set element not found by implementation");
510 rtl::OUString
sMessage( RTL_CONSTASCII_USTRINGPARAM("Configuration - Cannot remove Set Element. Element '") );
512 sMessage
+= rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("' not found in Set ") );
513 sMessage
+= aTree
->getAbsolutePath(aNode
).toString();
515 uno::Reference
<uno::XInterface
> xContext( rNode
.getUnoInstance() );
516 throw container::NoSuchElementException( sMessage
, xContext
);
519 configuration::NodeChange aChange
= lock
.getNodeUpdater().validateRemoveElement(aElement
);
521 aChange
.test(); // make sure old values are set up correctly
522 OSL_ENSURE(aChange
.isChange(), "ERROR: Removing a node validated as empty change");
524 Broadcaster
aSender(rNode
.getNotifier().makeBroadcaster(aChange
,true));
526 //aSender.queryConstraints(); - N/A: no external constraints on set children possible
528 aTree
->integrate(aChange
, aNode
, true);
530 lock
.clearForBroadcast();
531 aSender
.notifyListeners(aChange
);
533 catch (configuration::InvalidName
& ex
)
535 ExceptionMapper
e(ex
);
536 rtl::OUString
sMessage( RTL_CONSTASCII_USTRINGPARAM("Configuration - Cannot remove Set Element: ") );
537 uno::Reference
<uno::XInterface
> xContext( rNode
.getUnoInstance() );
538 throw container::NoSuchElementException( sMessage
+= e
.message(), xContext
);
540 catch (configuration::Exception
& ex
)
542 ExceptionMapper
e(ex
);
543 e
.setContext( rNode
.getUnoInstance() );
548 //-----------------------------------------------------------------------------------
550 // XPropertyWithState
551 //-----------------------------------------------------------------------------------
553 void implSetToDefaultAsProperty(NodeSetAccess
& rNode
)
554 throw (css::lang::WrappedTargetException
, uno::RuntimeException
)
558 GuardedNodeUpdate
<NodeSetAccess
> lock( rNode
);
560 rtl::Reference
< configuration::Tree
> const aTree( lock
.getTree() );
561 configuration::NodeRef
const aNode( lock
.getNode() );
563 configuration::SetDefaulter aDefaulter
= lock
.getNodeDefaulter();
565 configuration::NodeChange aChange
= aDefaulter
.validateSetToDefaultState();
567 const bool bLocal
= true;
569 if (aChange
.test().isChange() )
571 Broadcaster
aSender(rNode
.getNotifier().makeBroadcaster(aChange
,bLocal
));
573 aSender
.queryConstraints(aChange
);
575 aTree
->integrate(aChange
, aNode
, bLocal
);
577 lock
.clearForBroadcast();
578 aSender
.notifyListeners(aChange
);
581 catch (configuration::ConstraintViolation
& ex
)
583 ExceptionMapper
e(ex
);
584 rtl::OUString
sMessage( RTL_CONSTASCII_USTRINGPARAM("Configuration - Cannot restore Default: ") );
585 uno::Reference
<uno::XInterface
> xContext( rNode
.getUnoInstance() );
587 throw lang::WrappedTargetException( sMessage
+= e
.message(), xContext
, uno::Any());
589 catch (configuration::Exception
& ex
)
591 ExceptionMapper
e(ex
);
592 e
.setContext( rNode
.getUnoInstance() );
595 catch (lang::WrappedTargetException
& ) { throw;}
596 catch (uno::RuntimeException
& ) { throw;}
597 catch (uno::Exception
& e
)
599 rtl::OUString
sMessage( RTL_CONSTASCII_USTRINGPARAM("Configuration - Cannot restore Default: ") );
600 uno::Reference
<uno::XInterface
> xContext( rNode
.getUnoInstance() );
602 throw lang::WrappedTargetException( sMessage
+= e
.Message
, xContext
, uno::makeAny(e
));
605 //-----------------------------------------------------------------------------------
607 // XSingleServiceFactory
608 //-----------------------------------------------------------------------------------
609 uno::Reference
< uno::XInterface
> implCreateElement(NodeTreeSetAccess
& rNode
)
610 throw(uno::Exception
, uno::RuntimeException
)
612 uno::Reference
< uno::XInterface
> xRet
;
615 GuardedNodeData
<NodeSetAccess
> lock( rNode
); // no provider lock needed ? => if template lock is separate - OK
617 rtl::Reference
< configuration::ElementTree
> aNewElement( rNode
.getElementFactory().instantiateTemplate(rNode
.getElementInfo()) );
619 uno::Any aAny
= configapi::makeElement( rNode
.getFactory(), aNewElement
);
620 if (!(aAny
>>= xRet
)) // no parent available
622 OSL_ASSERT(!xRet
.is()); // make sure we return NULL
623 OSL_ENSURE(!aAny
.hasValue(), "configmgr: BasicSetElement::getParent: could not extract parent - node is not an object");
626 catch (configuration::Exception
& ex
)
628 ExceptionMapper
e(ex
);
629 e
.setContext( rNode
.getUnoInstance() );
635 //-----------------------------------------------------------------------------------
637 uno::Reference
< uno::XInterface
> implCreateElement(NodeTreeSetAccess
& rNode
, const uno::Sequence
< uno::Any
>& aArguments
)
638 throw(uno::Exception
, uno::RuntimeException
)
640 { (void)aArguments
; }
641 OSL_ENSURE(aArguments
.getLength() == 0, "ConfigurationContainer: createInstance: Arguments not supported - ignoring ...");
642 return implCreateElement(rNode
);
645 //-----------------------------------------------------------------------------------
646 } // namespace configapi
648 } // namespace configmgr