fix logic
[personal-kdelibs.git] / khtml / dom / html_list.cpp
blob470971fdfe63dd9dc5b6228c5bd28e299a756608
1 /**
2 * This file is part of the DOM implementation for KDE.
4 * Copyright 1999 Lars Knoll (knoll@kde.org)
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Library General Public
8 * License as published by the Free Software Foundation; either
9 * version 2 of the License, or (at your option) any later version.
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Library General Public License for more details.
16 * You should have received a copy of the GNU Library General Public License
17 * along with this library; see the file COPYING.LIB. If not, write to
18 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
19 * Boston, MA 02110-1301, USA.
22 // --------------------------------------------------------------------------
24 #include "dom/html_list.h"
25 #include "html/html_listimpl.h"
26 #include "misc/htmlhashes.h"
28 using namespace DOM;
30 HTMLDListElement::HTMLDListElement() : HTMLElement()
34 HTMLDListElement::HTMLDListElement(const HTMLDListElement &other) : HTMLElement(other)
38 HTMLDListElement::HTMLDListElement(HTMLDListElementImpl *impl) : HTMLElement(impl)
42 HTMLDListElement &HTMLDListElement::operator = (const Node &other)
44 assignOther( other, ID_DL );
45 return *this;
48 HTMLDListElement &HTMLDListElement::operator = (const HTMLDListElement &other)
50 HTMLElement::operator = (other);
51 return *this;
54 HTMLDListElement::~HTMLDListElement()
58 bool HTMLDListElement::compact() const
60 if(!impl) return 0;
61 return !((ElementImpl *)impl)->getAttribute(ATTR_COMPACT).isNull();
64 void HTMLDListElement::setCompact( bool _compact )
66 if(impl)
68 DOMString str;
69 if( _compact )
70 str = "";
71 ((ElementImpl *)impl)->setAttribute(ATTR_COMPACT, str);
75 // --------------------------------------------------------------------------
77 HTMLDirectoryElement::HTMLDirectoryElement() : HTMLElement()
81 HTMLDirectoryElement::HTMLDirectoryElement(const HTMLDirectoryElement &other) : HTMLElement(other)
85 HTMLDirectoryElement::HTMLDirectoryElement(HTMLDirectoryElementImpl *impl) : HTMLElement(impl)
89 HTMLDirectoryElement &HTMLDirectoryElement::operator = (const Node &other)
91 assignOther( other, ID_DIR );
92 return *this;
95 HTMLDirectoryElement &HTMLDirectoryElement::operator = (const HTMLDirectoryElement &other)
97 HTMLElement::operator = (other);
98 return *this;
101 HTMLDirectoryElement::~HTMLDirectoryElement()
105 bool HTMLDirectoryElement::compact() const
107 if(!impl) return 0;
108 return !((ElementImpl *)impl)->getAttribute(ATTR_COMPACT).isNull();
111 void HTMLDirectoryElement::setCompact( bool _compact )
113 if(impl)
115 DOMString str;
116 if( _compact )
117 str = "";
118 ((ElementImpl *)impl)->setAttribute(ATTR_COMPACT, str);
122 // --------------------------------------------------------------------------
124 HTMLLIElement::HTMLLIElement() : HTMLElement()
128 HTMLLIElement::HTMLLIElement(const HTMLLIElement &other) : HTMLElement(other)
132 HTMLLIElement::HTMLLIElement(HTMLLIElementImpl *impl) : HTMLElement(impl)
136 HTMLLIElement &HTMLLIElement::operator = (const Node &other)
138 assignOther( other, ID_LI );
139 return *this;
142 HTMLLIElement &HTMLLIElement::operator = (const HTMLLIElement &other)
144 HTMLElement::operator = (other);
145 return *this;
148 HTMLLIElement::~HTMLLIElement()
152 DOMString HTMLLIElement::type() const
154 if(!impl) return DOMString();
155 return ((ElementImpl *)impl)->getAttribute(ATTR_TYPE);
158 void HTMLLIElement::setType( const DOMString &value )
160 if(impl) ((ElementImpl *)impl)->setAttribute(ATTR_TYPE, value);
163 long HTMLLIElement::value() const
165 if(!impl) return 0;
166 return ((ElementImpl *)impl)->getAttribute(ATTR_VALUE).toInt();
169 void HTMLLIElement::setValue( long _value )
171 if(impl) {
172 DOMString value(QString::number(_value));
173 ((ElementImpl *)impl)->setAttribute(ATTR_VALUE,value);
177 // --------------------------------------------------------------------------
179 HTMLMenuElement::HTMLMenuElement() : HTMLElement()
183 HTMLMenuElement::HTMLMenuElement(const HTMLMenuElement &other) : HTMLElement(other)
187 HTMLMenuElement::HTMLMenuElement(HTMLMenuElementImpl *impl) : HTMLElement(impl)
191 HTMLMenuElement &HTMLMenuElement::operator = (const Node &other)
193 assignOther( other, ID_MENU );
194 return *this;
197 HTMLMenuElement &HTMLMenuElement::operator = (const HTMLMenuElement &other)
199 HTMLElement::operator = (other);
200 return *this;
203 HTMLMenuElement::~HTMLMenuElement()
207 bool HTMLMenuElement::compact() const
209 if(!impl) return 0;
210 return !((ElementImpl *)impl)->getAttribute(ATTR_COMPACT).isNull();
213 void HTMLMenuElement::setCompact( bool _compact )
215 if(impl)
217 DOMString str;
218 if( _compact )
219 str = "";
220 ((ElementImpl *)impl)->setAttribute(ATTR_COMPACT, str);
224 // --------------------------------------------------------------------------
226 HTMLOListElement::HTMLOListElement() : HTMLElement()
230 HTMLOListElement::HTMLOListElement(const HTMLOListElement &other) : HTMLElement(other)
234 HTMLOListElement::HTMLOListElement(HTMLOListElementImpl *impl) : HTMLElement(impl)
238 HTMLOListElement &HTMLOListElement::operator = (const Node &other)
240 assignOther( other, ID_OL );
241 return *this;
244 HTMLOListElement &HTMLOListElement::operator = (const HTMLOListElement &other)
246 HTMLElement::operator = (other);
247 return *this;
250 HTMLOListElement::~HTMLOListElement()
254 bool HTMLOListElement::compact() const
256 if(!impl) return 0;
257 return !((ElementImpl *)impl)->getAttribute(ATTR_COMPACT).isNull();
260 void HTMLOListElement::setCompact( bool _compact )
262 if(impl)
264 DOMString str;
265 if( _compact )
266 str = "";
267 ((ElementImpl *)impl)->setAttribute(ATTR_COMPACT, str);
271 long HTMLOListElement::start() const
273 if(!impl) return 0;
274 return ((ElementImpl *)impl)->getAttribute(ATTR_START).toInt();
277 void HTMLOListElement::setStart( long _start )
280 if(impl) {
281 DOMString value(QString::number(_start));
282 ((ElementImpl *)impl)->setAttribute(ATTR_START,value);
286 DOMString HTMLOListElement::type() const
288 if(!impl) return DOMString();
289 return ((ElementImpl *)impl)->getAttribute(ATTR_TYPE);
292 void HTMLOListElement::setType( const DOMString &value )
294 if(impl) ((ElementImpl *)impl)->setAttribute(ATTR_TYPE, value);
297 // --------------------------------------------------------------------------
299 HTMLUListElement::HTMLUListElement() : HTMLElement()
303 HTMLUListElement::HTMLUListElement(const HTMLUListElement &other) : HTMLElement(other)
307 HTMLUListElement::HTMLUListElement(HTMLUListElementImpl *impl) : HTMLElement(impl)
311 HTMLUListElement &HTMLUListElement::operator = (const Node &other)
313 assignOther( other, ID_UL );
314 return *this;
317 HTMLUListElement &HTMLUListElement::operator = (const HTMLUListElement &other)
319 HTMLElement::operator = (other);
320 return *this;
323 HTMLUListElement::~HTMLUListElement()
327 bool HTMLUListElement::compact() const
329 if(!impl) return 0;
330 return !((ElementImpl *)impl)->getAttribute(ATTR_COMPACT).isNull();
333 void HTMLUListElement::setCompact( bool _compact )
335 if(impl)
337 DOMString str;
338 if( _compact )
339 str = "";
340 ((ElementImpl *)impl)->setAttribute(ATTR_COMPACT, str);
344 DOMString HTMLUListElement::type() const
346 if(!impl) return DOMString();
347 return ((ElementImpl *)impl)->getAttribute(ATTR_TYPE);
350 void HTMLUListElement::setType( const DOMString &value )
352 if(impl) ((ElementImpl *)impl)->setAttribute(ATTR_TYPE, value);