merge the formfield patch from ooo-build
[ooovba.git] / autodoc / source / display / inc / toolkit / out_node.hxx
blob2f701a64baf221a01fef0258647b05fad25c8ea3
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: out_node.hxx,v $
10 * $Revision: 1.4 $
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 #ifndef ADC_DISPLAY_OUT_NODE_HXX
32 #define ADC_DISPLAY_OUT_NODE_HXX
37 namespace output
41 /** @resp
42 Represents a tree of names where each node can have only one parent,
43 but a list of children.
45 @see Position
46 @see Tree
48 class Node
50 public:
51 typedef std::vector< Node* > List;
52 typedef UINT32 relative_id;
54 // LIFECYCLE
55 enum E_NullObject { null_object };
57 Node();
58 explicit Node(
59 E_NullObject );
60 ~Node();
62 // OPERATORS
63 bool operator==(
64 const Node & i_node ) const
65 { return pParent == i_node.pParent AND sName == i_node.sName; }
66 bool operator!=(
67 const Node & i_node ) const
68 { return NOT operator==(i_node); }
70 // OPERATIONS
71 /// Seek, and if not existent, create.
72 Node & Provide_Child(
73 const String & i_name );
74 /// Seek, and if not existent, create.
75 Node & Provide_Child(
76 const StringVector &
77 i_path )
78 { return provide_Child(i_path.begin(), i_path.end()); }
79 // INQUIRY
80 intt Depth() const { return nDepth; }
82 const String & Name() const { return sName; }
83 /// @return Id of a namespace or class etc. this directory represents.
84 relative_id RelatedNameRoom() const { return nNameRoomId; }
85 /// @return No delimiter at start, with delimiter at end.
86 void Get_Path(
87 StreamStr & o_result,
88 intt i_maxDepth = -1 ) const;
89 void Get_Chain(
90 StringVector & o_result,
91 intt i_maxDepth = -1 ) const;
92 // ACCESS
93 void Set_RelatedNameRoom(
94 relative_id i_nNameRoomId )
95 { nNameRoomId = i_nNameRoomId; }
96 Node * Parent() { return pParent; }
97 Node * Child(
98 const String & i_name )
99 { return find_Child(i_name); }
100 List & Children() { return aChildren; }
102 /// @return a reference to a Node with Depth() == -1.
103 static Node & Null_();
105 private:
106 // Local
107 Node(
108 const String & i_name,
109 Node & i_parent );
111 Node * find_Child(
112 const String & i_name );
113 Node & add_Child(
114 const String & i_name );
115 Node & provide_Child(
116 StringVector::const_iterator
117 i_next,
118 StringVector::const_iterator
119 i_end );
120 // Data
121 String sName;
122 Node * pParent;
123 List aChildren;
124 intt nDepth;
125 relative_id nNameRoomId;
131 } // namespace output
132 #endif