update dev300-m58
[ooovba.git] / configmgr / source / treemgr / nodeimpl.cxx
blob5c4abf60bea81750949c46843adf72ac8ea847c6
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: nodeimpl.cxx,v $
10 * $Revision: 1.26 $
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"
33 #include <stdio.h>
34 #include "nodeimpl.hxx"
35 #include "valuenodeimpl.hxx"
36 #include "groupnodeimpl.hxx"
37 #include "nodevisitor.hxx"
38 #include "tree.hxx"
39 #include "nodechange.hxx"
40 #include "nodechangeimpl.hxx"
41 #include "nodechangeinfo.hxx"
42 #include "change.hxx"
43 #include <osl/diagnose.h>
45 namespace configmgr
47 namespace configuration
50 // Specific types of nodes
51 //-----------------------------------------------------------------------------
53 //-----------------------------------------------------------------------------
54 // class GroupNodeImpl
55 //-----------------------------------------------------------------------------
57 sharable::GroupNode * GroupNodeImpl::getDataAccess() const
59 sharable::Node * node = getOriginalNodeAccess();
60 OSL_ASSERT(node != 0 && node->isGroup());
61 return &node->group;
63 //-----------------------------------------------------------------------------
65 GroupNodeImpl::GroupNodeImpl(sharable::GroupNode * _pNodeRef)
66 : NodeImpl(reinterpret_cast<sharable::Node *>(_pNodeRef))
67 , m_pCache( NULL )
70 //-----------------------------------------------------------------------------
72 bool GroupNodeImpl::areValueDefaultsAvailable() const
74 return getDataAccess()->hasDefaultsAvailable();
76 //-----------------------------------------------------------------------------
78 ValueMemberNode GroupNodeImpl::makeValueMember(sharable::ValueNode * node)
80 return ValueMemberNode(node);
82 //-----------------------------------------------------------------------------
84 sharable::ValueNode * GroupNodeImpl::getOriginalValueNode(rtl::OUString const& _aName) const
86 OSL_ENSURE( _aName.getLength() != 0, "Cannot get nameless child value");
88 sharable::GroupNode * group = getDataAccess();
90 if (m_pCache)
92 if (m_pCache->isNamed(_aName))
93 return m_pCache->valueData();
95 m_pCache = group->getNextChild(m_pCache);
97 if (m_pCache && m_pCache->isNamed(_aName))
98 return m_pCache->valueData();
99 m_pCache = NULL;
102 sharable::Node * child = group->getChild(_aName);
103 m_pCache = child;
105 // to do: investigate cache lifecycle more deeply.
107 return child == 0 ? 0 : child->valueData();
110 //-----------------------------------------------------------------------------
111 // class ValueElementNodeImpl
112 //-----------------------------------------------------------------------------
114 sharable::ValueNode * ValueElementNodeImpl::getDataAccess() const
116 sharable::Node * node = getOriginalNodeAccess();
117 OSL_ASSERT(node != 0 && node->isValue());
118 return &node->value;
120 //-----------------------------------------------------------------------------
122 ValueElementNodeImpl::ValueElementNodeImpl(sharable::ValueNode * const& _aNodeRef)
123 : NodeImpl(reinterpret_cast<sharable::Node *>(_aNodeRef))
126 //-----------------------------------------------------------------------------
128 com::sun::star::uno::Any ValueElementNodeImpl::getValue() const
130 return getDataAccess()->getValue();
132 //-----------------------------------------------------------------------------
134 com::sun::star::uno::Type ValueElementNodeImpl::getValueType() const
136 return getDataAccess()->getValueType();
138 //-----------------------------------------------------------------------------