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: treefragment.hxx,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 ************************************************************************/
31 #ifndef INCLUDED_SHARABLE_TREEFRAGMENT_HXX
32 #define INCLUDED_SHARABLE_TREEFRAGMENT_HXX
39 //-----------------------------------------------------------------------------
42 //-----------------------------------------------------------------------------
43 /* a TreeFragment header is interpreted differently, depending on the kind of TreeFragment
46 name points to the element name (the name in the root node is the template name)
47 parent points to the SetNode that is the parent. The containing treefragment can
48 be recovered from this with some care
49 next points to the next element of the same set. It is null for the last element.
50 state is fully used here
53 name points to the template name (same as the name in the root node)
54 component points to the home component name of the template
55 (often the same as 'component' in the component tree)
56 next points to another template TreeFragment. It is null for the last template.
57 state must be 'replaced' here (rarely it might be marked as mandatory)
59 - for a component tree
60 name points to the component name (same as the name in the root node)
61 component is equal to name (or NULL ?)
62 next points to another template TreeFragment. It is null if there is no template.
63 state must be either 'defaulted' or 'merged'
64 (it should be marked as mandatory although that is not used yet)
66 struct TreeFragmentHeader
68 struct TreeFragment
*next
; // next sibling set element or template
69 rtl_uString
* name
; // element-name/template name
72 union Node
*parent
; // parent node
73 rtl_uString
* component
; // component name
75 sal_uInt16 count
; // number of contained nodes
79 //-----------------------------------------------------------------------------
80 /* a tree fragment is stored as a variable-sized struct
81 containing a header and a fixed sequence of nodes
99 H(count = 12) : [R;A;A1;A2;B;C;C1;C11;C12;C2;C21;D]
101 //-----------------------------------------------------------------------------
102 /* tree fragments are used for: Component trees, Template trees, Set elements
104 They are only fragments, as for a TreeFragment a Set is considered a leaf node.
105 Set elements are maintained as a singly linked list that is accessible from the set node
107 A cache component has the Root (component tree) TreeFragment at a well-known location.
108 The 'next' element of the component tree points to the list of template TreeFragments
109 used in the component.
113 TreeFragmentHeader header
; // really variable-sized:
114 Node nodes
[1]; // nodes[header.count]
116 // header info access
117 bool hasDefaultsAvailable() const;
119 bool isDefault() const;
122 bool isNamed(rtl::OUString
const & _aName
) const;
124 rtl::OUString
getName() const;
126 void setName(rtl::OUString
const & name
);
128 configmgr::node::Attributes
getAttributes()const;
130 Node
* getRootNode() { return nodes
; }
132 static TreeFragment
*allocate(sal_uInt32 nFragments
);
133 static void free_shallow( TreeFragment
*pFragment
);
135 //-----------------------------------------------------------------------------
138 //-----------------------------------------------------------------------------
141 #endif // INCLUDED_SHARABLE_TREEFRAGMENT_HXX