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: out_node.cxx,v $
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 ************************************************************************/
32 #include <toolkit/out_node.hxx>
35 // NOT FULLY DEFINED SERVICES
51 { return p1
->Name() < p2
->Name(); }
54 struct Less_NodePtr C_Less_NodePtr
;
57 Node
C_aNullNode(Node::null_object
);
60 } // namepace anonymous
63 //********************** Node ***************************//
75 Node::Node( E_NullObject
)
84 Node::Node( const String
& i_name
,
89 nDepth(i_parent
.Depth()+1),
96 for ( List::iterator it
= aChildren
.begin();
97 it
!= aChildren
.end();
105 Node::Provide_Child( const String
& i_name
)
108 ret
= find_Child(i_name
);
111 return add_Child(i_name
);
115 Node::Get_Path( StreamStr
& o_result
,
116 intt i_maxDepth
) const
118 // Intentionally 'i_maxDepth != 0', so max_Depth == -1 sets no limit:
122 pParent
->Get_Path(o_result
, i_maxDepth
-1);
123 o_result
<< sName
<< '/';
128 Node::Get_Chain( StringVector
& o_result
,
129 intt i_maxDepth
) const
133 // This is called also for the toplevel Node,
134 // but there happens nothing:
137 pParent
->Get_Chain(o_result
, i_maxDepth
-1);
138 o_result
.push_back(sName
);
144 Node::find_Child( const String
& i_name
)
147 aSearch
.sName
= i_name
;
150 ret
= std::lower_bound( aChildren
.begin(),
154 if ( ret
!= aChildren
.end() ? (*ret
)->Name() == i_name
: false )
161 Node::add_Child( const String
& i_name
)
164 pNew
= new Node(i_name
,*this);
165 aChildren
.insert( std::lower_bound( aChildren
.begin(),
174 Node::provide_Child( StringVector::const_iterator i_next
,
175 StringVector::const_iterator i_end
)
179 return Provide_Child(*i_next
).provide_Child(i_next
+1,i_end
);
192 } // namespace output