merge the formfield patch from ooo-build
[ooovba.git] / configmgr / source / backend / componentdatahelper.cxx
blob0007ac1bb7ce751b469cdc063c3e5829accc3891
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: componentdatahelper.cxx,v $
10 * $Revision: 1.14 $
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 "componentdatahelper.hxx"
35 #include "treenodefactory.hxx"
36 #include "typeconverter.hxx"
37 #include "strdecl.hxx"
38 #include <rtl/ustrbuf.hxx>
39 #include <com/sun/star/lang/NoSupportException.hpp>
40 #include <com/sun/star/lang/IllegalAccessException.hpp>
41 #include <com/sun/star/lang/IllegalArgumentException.hpp>
42 #include <com/sun/star/container/NoSuchElementException.hpp>
43 #include <com/sun/star/container/ElementExistException.hpp>
44 #include <com/sun/star/beans/IllegalTypeException.hpp>
45 #include <com/sun/star/beans/PropertyExistException.hpp>
46 #include <com/sun/star/beans/UnknownPropertyException.hpp>
48 // -----------------------------------------------------------------------------
49 #define OUSTR( str ) rtl::OUString( RTL_CONSTASCII_USTRINGPARAM(str) )
50 // -----------------------------------------------------------------------------
51 namespace configmgr
53 // -----------------------------------------------------------------------------
54 namespace backend
56 // -----------------------------------------------------------------------------
57 namespace uno = ::com::sun::star::uno;
58 namespace lang = ::com::sun::star::lang;
59 namespace beans = ::com::sun::star::beans;
60 namespace container = ::com::sun::star::container;
61 // -----------------------------------------------------------------------------
63 DataBuilderContext::DataBuilderContext( uno::Reference< uno::XComponentContext > const & xContext )
64 : m_aLogger(xContext)
65 , m_aParentStack()
66 , m_aActiveComponent()
67 , m_pContext()
68 , m_aExpectedComponentName(rtl::OUString())
72 // -----------------------------------------------------------------------------
74 DataBuilderContext::DataBuilderContext( uno::Reference< uno::XComponentContext > const & xContext, uno::XInterface * _pContext, ITemplateDataProvider* aTemplateProvider )
75 : m_aLogger(xContext)
76 , m_aParentStack()
77 , m_aActiveComponent()
78 , m_pContext(_pContext)
79 , m_aExpectedComponentName()
80 , m_aTemplateProvider( aTemplateProvider )
84 // -----------------------------------------------------------------------------
86 DataBuilderContext::DataBuilderContext( uno::Reference< uno::XComponentContext > const & xContext, uno::XInterface * _pContext, const rtl::OUString& aExpectedComponentName, ITemplateDataProvider* aTemplateProvider )
87 : m_aLogger(xContext)
88 , m_aParentStack()
89 , m_aActiveComponent()
90 , m_pContext(_pContext)
91 , m_aExpectedComponentName( aExpectedComponentName )
92 , m_aTemplateProvider( aTemplateProvider )
96 // -----------------------------------------------------------------------------
98 DataBuilderContext::DataBuilderContext(DataBuilderContext const & aBaseContext, uno::XInterface * _pContext)
99 : m_aLogger(aBaseContext.m_aLogger)
100 , m_aParentStack()
101 , m_aActiveComponent()
102 , m_pContext(_pContext)
103 , m_aExpectedComponentName()
104 , m_aTemplateProvider( aBaseContext.m_aTemplateProvider )
108 // -----------------------------------------------------------------------------
110 DataBuilderContext::~DataBuilderContext( )
114 // -----------------------------------------------------------------------------
115 // -----------------------------------------------------------------------------
117 void DataBuilderContext::raiseMalformedDataException(sal_Char const * _pText) const
118 SAL_THROW((com::sun::star::configuration::backend::MalformedDataException, com::sun::star::uno::RuntimeException))
120 rtl::OUString const sMessage = makeMessageWithPath(_pText);
121 m_aLogger.error(sMessage,"parse","configmgr::backend::DataBuilder");
122 throw backenduno::MalformedDataException(sMessage, m_pContext, uno::Any());
124 // -----------------------------------------------------------------------------
126 void DataBuilderContext::raiseIllegalTypeException(sal_Char const * _pText) const
127 SAL_THROW((com::sun::star::configuration::backend::MalformedDataException, com::sun::star::uno::RuntimeException))
129 rtl::OUString const sMessage = makeMessageWithPath(_pText);
130 beans::IllegalTypeException e(sMessage, m_pContext);
132 rtl::OUString const sFullMessage = OUSTR("Illegal Type: ").concat(sMessage);
133 m_aLogger.error(sFullMessage,"parse","configmgr::backend::DataBuilder");
134 throw backenduno::MalformedDataException(sFullMessage, m_pContext, uno::makeAny(e));
136 // -----------------------------------------------------------------------------
138 void DataBuilderContext::raiseIllegalArgumentException(sal_Char const * _pText, sal_Int16 _nPos) const
139 SAL_THROW((com::sun::star::configuration::backend::MalformedDataException , com::sun::star::uno::RuntimeException))
141 rtl::OUString const sMessage = makeMessageWithPath(_pText);
142 lang::IllegalArgumentException e(sMessage, m_pContext, _nPos);
144 rtl::OUString const sFullMessage = OUSTR("Illegal Argument: ").concat(sMessage);
145 m_aLogger.error(sFullMessage,"parse","configmgr::backend::DataBuilder");
146 throw backenduno::MalformedDataException(sFullMessage, m_pContext, uno::makeAny(e));
148 // -----------------------------------------------------------------------------
150 void DataBuilderContext::raiseNoSuchElementException(sal_Char const * _pText, rtl::OUString const & _sElement) const
151 SAL_THROW((com::sun::star::configuration::backend::MalformedDataException , com::sun::star::uno::RuntimeException))
153 rtl::OUString const sMessage = makeMessageWithName(_pText,_sElement);
154 container::NoSuchElementException e(sMessage, m_pContext);
156 rtl::OUString const sFullMessage = OUSTR("No Such Node: ").concat(sMessage);
157 m_aLogger.error(sFullMessage,"parse","configmgr::backend::DataBuilder");
158 throw backenduno::MalformedDataException(sFullMessage, m_pContext, uno::makeAny(e));
160 // -----------------------------------------------------------------------------
162 void DataBuilderContext::raiseElementExistException(sal_Char const * _pText, rtl::OUString const & _sElement) const
163 SAL_THROW((com::sun::star::configuration::backend::MalformedDataException , com::sun::star::uno::RuntimeException))
165 rtl::OUString const sMessage = makeMessageWithName(_pText,_sElement);
166 container::ElementExistException e(sMessage, m_pContext);
168 rtl::OUString const sFullMessage = OUSTR("Node Already Exists: ").concat(sMessage);
169 m_aLogger.error(sFullMessage,"parse","configmgr::backend::DataBuilder");
170 throw backenduno::MalformedDataException(sFullMessage, m_pContext, uno::makeAny(e));
172 // -----------------------------------------------------------------------------
174 void DataBuilderContext::raisePropertyExistException(sal_Char const * _pText, rtl::OUString const & _sElement) const
175 SAL_THROW((com::sun::star::configuration::backend::MalformedDataException , com::sun::star::uno::RuntimeException))
177 rtl::OUString const sMessage = makeMessageWithName(_pText,_sElement);
178 beans::PropertyExistException e(sMessage, m_pContext);
180 rtl::OUString const sFullMessage = OUSTR("No Such Property: ").concat(sMessage);
181 m_aLogger.error(sFullMessage,"parse","configmgr::backend::DataBuilder");
182 throw backenduno::MalformedDataException(sFullMessage, m_pContext, uno::makeAny(e));
184 // -----------------------------------------------------------------------------
186 rtl::OUString DataBuilderContext::makeMessageWithPath(sal_Char const * _pText) const
187 SAL_THROW((com::sun::star::uno::RuntimeException))
189 rtl::OUStringBuffer sMessage;
190 sMessage.appendAscii(_pText);
192 sMessage.appendAscii(" [@").append(getNodeParentagePath()).appendAscii("] ");
194 return sMessage.makeStringAndClear();
196 // -----------------------------------------------------------------------------
198 rtl::OUString DataBuilderContext::makeMessageWithName(sal_Char const * _pText, rtl::OUString const & _aName) const
199 SAL_THROW((com::sun::star::uno::RuntimeException))
201 rtl::OUStringBuffer sMessage;
202 sMessage.appendAscii(_pText);
204 if (_aName.getLength() != 0)
205 sMessage.appendAscii(" [").append(getNodePath(_aName)).appendAscii("] ");
206 else
207 sMessage.appendAscii(" [@").append(getNodeParentagePath()).appendAscii("] ");
209 return sMessage.makeStringAndClear();
211 // -----------------------------------------------------------------------------
212 const sal_Unicode k_pathsep = '/';
214 rtl::OUString DataBuilderContext::getNodeParentagePath() const
216 rtl::OUStringBuffer path;
218 for (Stack< ISubtree * >::bottomup_iterator it = m_aParentStack.begin_up();
219 it != m_aParentStack.end_up(); ++it)
221 OSL_ASSERT(*it);
222 path.append(k_pathsep).append((**it).getName());
225 return path.makeStringAndClear();
227 // -----------------------------------------------------------------------------
229 rtl::OUString DataBuilderContext::getNodePath(rtl::OUString const & aNodeName) const
231 rtl::OUStringBuffer path( getNodeParentagePath() );
233 path.append(k_pathsep).append(aNodeName);
235 return path.makeStringAndClear();
237 // -----------------------------------------------------------------------------
238 // -----------------------------------------------------------------------------
240 bool DataBuilderContext::isDone() const
242 OSL_ENSURE(m_aParentStack.empty() || hasActiveComponent(),"DataBuilderContext:Inconsistent Activity state");
244 return m_aParentStack.empty();
246 // -----------------------------------------------------------------------------
248 ISubtree & DataBuilderContext::implGetCurrentParent() const
249 SAL_THROW((com::sun::star::configuration::backend::MalformedDataException , com::sun::star::uno::RuntimeException))
251 if (m_aParentStack.empty())
252 raiseMalformedDataException("Invalid Component Data: Operation requires open parent node.");
254 OSL_ENSURE( m_aParentStack.top(), "NULL tree on node-stack" );
256 return *m_aParentStack.top();
258 // -----------------------------------------------------------------------------
260 bool DataBuilderContext::isWritable(INode const * pNode) const
261 SAL_THROW(())
263 OSL_PRECOND(pNode,"Unexpected NULL node pointer");
264 return pNode->getAttributes().isWritable();
267 // -----------------------------------------------------------------------------
269 bool DataBuilderContext::isRemovable(ISubtree const * pItem) const
270 SAL_THROW(())
272 OSL_PRECOND(pItem,"Unexpected NULL item pointer");
273 return pItem->getAttributes().isRemovable();
276 // -----------------------------------------------------------------------------
277 // -----------------------------------------------------------------------------
279 rtl::OUString DataBuilderContext::getTemplateComponent( const backenduno::TemplateIdentifier& aItemType ) const
281 if (aItemType.Component.getLength() != 0)
282 return aItemType.Component;
284 else
285 return getActiveComponent();
287 // -----------------------------------------------------------------------------
289 backenduno::TemplateIdentifier DataBuilderContext::completeComponent( const backenduno::TemplateIdentifier& aItemType ) const
291 backenduno::TemplateIdentifier aComplete(aItemType);
292 if (aComplete.Component.getLength() == 0)
293 aComplete.Component = getActiveComponent();
295 return aComplete;
297 // -----------------------------------------------------------------------------
298 // -----------------------------------------------------------------------------
300 backenduno::TemplateIdentifier DataBuilderContext::getCurrentItemType() const
301 SAL_THROW((com::sun::star::configuration::backend::MalformedDataException , com::sun::star::uno::RuntimeException))
303 ISubtree const * pCurrentSet = getCurrentParent().asISubtree();
304 if (!pCurrentSet || !pCurrentSet->isSetNode())
305 raiseMalformedDataException("Component Builder Context: Cannot add/replace node - context is not a set");
307 backenduno::TemplateIdentifier aCompleteType;
309 aCompleteType.Name = pCurrentSet->getElementTemplateName();
310 aCompleteType.Component = pCurrentSet->getElementTemplateModule();
312 return aCompleteType;
314 // -----------------------------------------------------------------------------
316 backenduno::TemplateIdentifier DataBuilderContext::getValidItemType(backenduno::TemplateIdentifier const & aItemType) const
317 SAL_THROW((com::sun::star::configuration::backend::MalformedDataException , com::sun::star::uno::RuntimeException))
319 ISubtree const * pCurrentSet = getCurrentParent().asISubtree();
320 if (!pCurrentSet || !pCurrentSet->isSetNode())
321 raiseMalformedDataException("Component Builder Context: Cannot add/replace node - context is not a set");
323 backenduno::TemplateIdentifier aCompleteType = completeComponent( aItemType );
325 // for now only a single item-type is supported
326 if (aCompleteType.Name != pCurrentSet->getElementTemplateName())
327 raiseIllegalTypeException("Component Builder Context: Cannot add/replace node - template is not permitted in containing set");
329 if (aCompleteType.Component != pCurrentSet->getElementTemplateModule())
330 raiseIllegalTypeException("Component Builder Context: Cannot add/replace node - template is not permitted in containing set (component mismatch)");
332 return aCompleteType;
334 // -----------------------------------------------------------------------------
336 ISubtree * DataBuilderContext::addNodeToCurrent(std::auto_ptr<ISubtree> _aNode)
337 SAL_THROW((com::sun::star::configuration::backend::MalformedDataException , com::sun::star::uno::RuntimeException))
339 OSL_PRECOND(_aNode.get(), "ERROR: Adding a NULL node");
341 if (this->findChild(_aNode->getName()))
342 raiseElementExistException("Component Builder Context: The node to be added does already exist", _aNode->getName());
344 return getCurrentParent().addChild( base_ptr(_aNode) )->asISubtree();
346 // -----------------------------------------------------------------------------
348 ISubtree * DataBuilderContext::addLocalizedToCurrent(std::auto_ptr<ISubtree> _aNode)
349 SAL_THROW((com::sun::star::configuration::backend::MalformedDataException , com::sun::star::uno::RuntimeException))
351 OSL_PRECOND(_aNode.get(), "ERROR: Adding a NULL node");
353 if (this->findChild(_aNode->getName()))
354 raisePropertyExistException("Component Builder Context: The property to be added does already exist", _aNode->getName());
356 return getCurrentParent().addChild( base_ptr(_aNode) )->asISubtree();
358 // -----------------------------------------------------------------------------
360 ValueNode * DataBuilderContext::addPropertyToCurrent(std::auto_ptr<ValueNode> _aNode, bool _bMayReplace)
361 SAL_THROW((com::sun::star::configuration::backend::MalformedDataException , com::sun::star::uno::RuntimeException))
363 OSL_PRECOND(_aNode.get(), "ERROR: Adding a NULL node");
364 OSL_PRECOND(!_bMayReplace || _aNode->getAttributes().isReplacedForUser(), "Wrong status for added property");
366 if (this->findChild(_aNode->getName()))
368 // We currently may get a 'replace', when overriding an added property
369 if (_bMayReplace && getCurrentParent().isSetNode())
371 getCurrentParent().removeChild(_aNode->getName());
372 _aNode->modifyState(node::isReplaced);
374 else
376 raisePropertyExistException("Component Builder Context: The property to be added does already exist", _aNode->getName());
378 return getCurrentParent().addChild( base_ptr(_aNode) )->asValueNode();
380 // -----------------------------------------------------------------------------
382 void DataBuilderContext::markCurrentMerged()
384 Stack< ISubtree * >::topdown_iterator it = m_aParentStack.begin_down(), end = m_aParentStack.end_down();
385 for ( ;it != end && (*it)->isDefault(); ++it)
386 (*it)->modifyState( node::isMerged );
388 #if OSL_DEBUG_LEVEL > 0
389 for ( ;it != end; ++it)
390 OSL_ENSURE(!(*it)->isDefault(),"Found a default node in ancestry of a merged change");
391 #endif
393 // -----------------------------------------------------------------------------
394 // -----------------------------------------------------------------------------
396 bool DataBuilderContext::isProperty(INode * pProp) const
397 SAL_THROW((com::sun::star::uno::RuntimeException))
399 OSL_PRECOND(pProp, "ERROR: Unexpected NULL node");
401 if (pProp == NULL)
403 rtl::OUString sMsg = makeMessageWithName("INTERNAL ERROR (DataBuilderContext): Trying to inspect NULL node",rtl::OUString() );
404 throw uno::RuntimeException( sMsg, m_pContext );
407 if ( ISubtree * pTree = pProp->asISubtree() )
408 return isLocalizedValueSet( *pTree );
410 OSL_ASSERT(dynamic_cast< ValueNode * >(pProp) != 0);
411 return true;
413 // -----------------------------------------------------------------------------
415 INode * DataBuilderContext::findChild(rtl::OUString const & _aName)
416 SAL_THROW((com::sun::star::configuration::backend::MalformedDataException , com::sun::star::uno::RuntimeException))
418 return getCurrentParent().getChild(_aName);
420 // -----------------------------------------------------------------------------
422 INode * DataBuilderContext::findProperty(rtl::OUString const & _aName)
423 SAL_THROW((com::sun::star::configuration::backend::MalformedDataException , com::sun::star::uno::RuntimeException))
425 INode * pResult = findChild(_aName);
426 if (pResult && !isProperty(pResult))
428 raiseMalformedDataException("Component Builder Context: Found an existing inner node, where a property was expected");
430 return pResult;
432 // -----------------------------------------------------------------------------
434 ISubtree * DataBuilderContext::findNode(rtl::OUString const & _aName)
435 SAL_THROW((com::sun::star::configuration::backend::MalformedDataException , com::sun::star::uno::RuntimeException))
437 INode * pResult = findChild(_aName);
439 if (!pResult)
440 return NULL;
442 if (!isNode(pResult))
443 raiseMalformedDataException("Component Builder Context: Found an existing property, where an inner node was expected");
445 OSL_ASSERT(dynamic_cast< ISubtree * >(pResult) != 0);
446 return pResult->asISubtree();
448 // -----------------------------------------------------------------------------
450 void DataBuilderContext::pushNode(ISubtree * pTree)
451 SAL_THROW((com::sun::star::uno::RuntimeException))
453 OSL_PRECOND(hasActiveComponent(), "Component Builder Context: Entering a node without having an active component");
454 OSL_PRECOND(pTree, "ERROR: Pushing a NULL tree");
456 if (pTree == NULL)
458 rtl::OUString sMsg = makeMessageWithName("INTERNAL ERROR (DataBuilderContext): Trying to push NULL tree",rtl::OUString() );
459 throw uno::RuntimeException( sMsg, m_pContext );
461 m_aParentStack.push(pTree);
463 // -----------------------------------------------------------------------------
465 void DataBuilderContext::popNode()
466 SAL_THROW((com::sun::star::configuration::backend::MalformedDataException , com::sun::star::uno::RuntimeException))
468 OSL_PRECOND(hasActiveComponent(), "Component Builder Context: Leaving a node without having an active component");
469 if (m_aParentStack.empty())
470 raiseMalformedDataException("Invalid Component Data: Unmatched end of node");
472 OSL_ENSURE( m_aParentStack.top(), "NULL tree on node-stack" );
474 m_aParentStack.pop();
476 // -----------------------------------------------------------------------------
478 void DataBuilderContext::startActiveComponent(rtl::OUString const & _aComponent)
479 SAL_THROW((com::sun::star::configuration::backend::MalformedDataException , com::sun::star::uno::RuntimeException))
481 OSL_PRECOND(!hasActiveComponent(), "Component Builder Context: Component is already active");
482 OSL_PRECOND(m_aParentStack.empty(), "Component Builder Context: Starting Component/Template while inside a node");
484 if (!m_aParentStack.empty())
485 raiseMalformedDataException("Invalid Component Data: Starting component while node is still open");
487 if (m_aExpectedComponentName.getLength()!=0)
489 if (m_aExpectedComponentName.compareTo ( _aComponent)!= 0 )
490 raiseMalformedDataException("Invalid Component Data: Component name does not match request");
492 m_aActiveComponent = _aComponent;
494 OSL_POSTCOND(hasActiveComponent(), "Component Builder Context: Could not start Component/Template");
496 // -----------------------------------------------------------------------------
498 void DataBuilderContext::endActiveComponent()
499 SAL_THROW((com::sun::star::configuration::backend::MalformedDataException , com::sun::star::uno::RuntimeException))
501 OSL_PRECOND( hasActiveComponent(), "Component Builder Context: No Component active");
502 OSL_PRECOND(m_aParentStack.empty(), "Component Builder Context: Ending Component/Template while inside a node");
504 if (!m_aParentStack.empty())
505 raiseMalformedDataException("Invalid Component Data: Ending component while node is still open");
507 m_aActiveComponent = rtl::OUString();
509 OSL_POSTCOND(!hasActiveComponent(), "Component Builder Context: Could not end Component/Template");
511 // -----------------------------------------------------------------------------
512 ResultHolder< TemplateInstance > DataBuilderContext::getTemplateData (TemplateRequest const & _aRequest )
514 return(m_aTemplateProvider->getTemplateData (_aRequest));
516 // -----------------------------------------------------------------------------
517 // -----------------------------------------------------------------------------
518 ComponentDataFactory::ComponentDataFactory()
519 : m_rNodeFactory( getDefaultTreeNodeFactory() )
522 // -----------------------------------------------------------------------------
524 std::auto_ptr<ISubtree> ComponentDataFactory::createGroup( rtl::OUString const & _aName,
525 bool _bExtensible,
526 node::Attributes const & _aAttributes) const
528 if (_bExtensible)
530 return getNodeFactory().createSetNode( _aName,
531 toTemplateName(TYPE_ANY,false),
532 TEMPLATE_MODULE_NATIVE_VALUE,
533 _aAttributes );
535 else
537 return getNodeFactory().createGroupNode( _aName,
538 _aAttributes );
541 // -----------------------------------------------------------------------------
543 std::auto_ptr<ISubtree> ComponentDataFactory::createSet(rtl::OUString const & _aName,
544 backenduno::TemplateIdentifier const & _aItemType,
545 bool _bExtensible,
546 node::Attributes const & _aAttributes) const
548 OSL_ENSURE(!_bExtensible, "DataBuilderContext: Unimplemented feature: Extensible Set node");
549 if (_bExtensible)
550 return std::auto_ptr<ISubtree>();
552 return getNodeFactory().createSetNode( _aName,
553 _aItemType.Name,
554 _aItemType.Component,
555 _aAttributes );
557 // -----------------------------------------------------------------------------
559 std::auto_ptr<ISubtree> ComponentDataFactory::createLocalizedContainer( rtl::OUString const & _aName,
560 uno::Type const & _aValueType,
561 node::Attributes const & _aAttributes) const
563 node::Attributes aLocalizedAttributes(_aAttributes);
564 aLocalizedAttributes.setLocalized (true);
566 return getNodeFactory().createSetNode( _aName,
567 toTemplateName(_aValueType),
568 TEMPLATE_MODULE_LOCALIZED_VALUE,
569 aLocalizedAttributes );
572 // -----------------------------------------------------------------------------
573 // -----------------------------------------------------------------------------
575 namespace
577 DECLARE_CONSTASCII_USTRING(INSTANCE_MARKER);
578 IMPLEMENT_CONSTASCII_USTRING(INSTANCE_MARKER, "instantiate@");
580 // -----------------------------------------------------------------------------
582 std::auto_ptr<ISubtree> ComponentDataFactory::createPlaceHolder(rtl::OUString const & _aName,
583 backenduno::TemplateIdentifier const & _aInstanceType) const
585 return getNodeFactory().createSetNode( _aName,
586 INSTANCE_MARKER + _aInstanceType.Name,
587 _aInstanceType.Component,
588 node::Attributes());
590 // -----------------------------------------------------------------------------
592 bool ComponentDataFactory::isInstancePlaceHolder(ISubtree const & _aInstanceTree)
594 return !! _aInstanceTree.getElementTemplateName().match(INSTANCE_MARKER);
596 // -----------------------------------------------------------------------------
598 backenduno::TemplateIdentifier ComponentDataFactory::getInstanceType(ISubtree const & _aInstanceTree)
600 OSL_ENSURE( isInstancePlaceHolder(_aInstanceTree), "Instance placeholder tree expected" );
602 backenduno::TemplateIdentifier aResult;
604 if (isInstancePlaceHolder(_aInstanceTree))
606 aResult.Name = _aInstanceTree.getElementTemplateName().copy( INSTANCE_MARKER.getLength() );
607 aResult.Component = _aInstanceTree.getElementTemplateModule();
610 return aResult;
612 // -----------------------------------------------------------------------------
613 // -----------------------------------------------------------------------------
614 } // namespace backend
616 // -------------------------------------------------------------------------
617 } // namespace configmgr