2 * CDE - Common Desktop Environment
4 * Copyright (c) 1993-2012, The Open Group. All rights reserved.
6 * These libraries and programs are free software; you can
7 * redistribute them and/or modify them under the terms of the GNU
8 * Lesser General Public License as published by the Free Software
9 * Foundation; either version 2 of the License, or (at your option)
12 * These libraries and programs are distributed in the hope that
13 * they will be useful, but WITHOUT ANY WARRANTY; without even the
14 * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
15 * PURPOSE. See the GNU Lesser General Public License for more
18 * You should have received a copy of the GNU Lesser General Public
19 * License along with these librararies and programs; if not, write
20 * to the Free Software Foundation, Inc., 51 Franklin Street, Fifth
21 * Floor, Boston, MA 02110-1301 USA
23 // $TOG: Element.C /main/5 1998/04/17 11:48:25 mgreess $
27 #include "StyleSheetExceptions.h"
29 #include "AttributeList.h"
31 // /////////////////////////////////////////////////////////////////////////
33 // /////////////////////////////////////////////////////////////////////////
35 #define OLIAS_SIBLING_INFO "LAST"
38 Element::Element(const Element& element)
41 f_sibling_number(element.f_sibling_number),
42 f_attributes(element.f_attributes),
43 f_olias_attributes(element.f_olias_attributes),
44 f_freeAttrLists(false),
45 f_relative_sibling_number(element.f_relative_sibling_number),
46 f_last_child(element.f_last_child),
47 f_relatively_last_child(element.f_relatively_last_child)
52 Element::Element(const Symbol& gi,
53 unsigned int sibling_number,
54 AttributeList *attlist,
55 AttributeList *olias_attributes,
56 unsigned int relative_sibling_number
60 f_sibling_number(sibling_number),
61 f_attributes(attlist),
62 f_olias_attributes(olias_attributes),
63 f_freeAttrLists(true),
64 f_relative_sibling_number(relative_sibling_number)
67 f_relatively_last_child = 0;
69 Symbol name(gSymTab->intern(OLIAS_SIBLING_INFO));
70 const Attribute* x = get_olias_attribute(name);
72 if ( x && x -> value() ) {
73 int code = atoi(x -> value());
77 f_relatively_last_child = 0;
81 f_relatively_last_child = 1;
85 f_relatively_last_child = 1;
88 throw(CASTEXCEPT Exception());
95 if ( f_freeAttrLists == true ) {
96 delete f_olias_attributes;
103 Element::get_attribute(const Symbol &name) const
106 return f_attributes->lookup(name);
112 Element::get_olias_attribute(const Symbol &name) const
114 if (f_olias_attributes)
115 return f_olias_attributes->lookup(name);
121 Element::print(ostream &o) const
126 o << "[" << this->f_sibling_number << "]";
127 o << "[" << this->f_relative_sibling_number<< "]";
128 o << "[" << this-> f_last_child << "]";
129 o << "[" << this-> f_relatively_last_child<< "]";
135 if (f_olias_attributes)
136 o << " #" << *f_olias_attributes ;