File indexing completed on 2024-04-28 15:22:59
0001 /** 0002 * This file is part of the DOM implementation for KDE. 0003 * 0004 * Copyright 1999 Lars Knoll (knoll@kde.org) 0005 * Copyright 2004 Allan Sandfeld Jensen (kde@carewolf.com) 0006 * 0007 * This library is free software; you can redistribute it and/or 0008 * modify it under the terms of the GNU Library General Public 0009 * License as published by the Free Software Foundation; either 0010 * version 2 of the License, or (at your option) any later version. 0011 * 0012 * This library is distributed in the hope that it will be useful, 0013 * but WITHOUT ANY WARRANTY; without even the implied warranty of 0014 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 0015 * Library General Public License for more details. 0016 * 0017 * You should have received a copy of the GNU Library General Public License 0018 * along with this library; see the file COPYING.LIB. If not, write to 0019 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, 0020 * Boston, MA 02110-1301, USA. 0021 * 0022 */ 0023 // -------------------------------------------------------------------------- 0024 0025 #include "dom/html_block.h" 0026 #include "dom/html_misc.h" 0027 #include "html/html_blockimpl.h" 0028 #include "html/html_miscimpl.h" 0029 0030 using namespace DOM; 0031 0032 HTMLBlockquoteElement::HTMLBlockquoteElement() 0033 : HTMLElement() 0034 { 0035 } 0036 0037 HTMLBlockquoteElement::HTMLBlockquoteElement(const HTMLBlockquoteElement &other) 0038 : HTMLElement(other) 0039 { 0040 } 0041 0042 HTMLBlockquoteElement::HTMLBlockquoteElement(HTMLElementImpl *impl) 0043 : HTMLElement(impl) 0044 { 0045 } 0046 0047 HTMLBlockquoteElement &HTMLBlockquoteElement::operator = (const Node &other) 0048 { 0049 assignOther(other, ID_BLOCKQUOTE); 0050 return *this; 0051 } 0052 0053 HTMLBlockquoteElement &HTMLBlockquoteElement::operator = (const HTMLBlockquoteElement &other) 0054 { 0055 HTMLElement::operator = (other); 0056 return *this; 0057 } 0058 0059 HTMLBlockquoteElement::~HTMLBlockquoteElement() 0060 { 0061 } 0062 0063 DOMString HTMLBlockquoteElement::cite() const 0064 { 0065 if (!impl) { 0066 return DOMString(); 0067 } 0068 return ((ElementImpl *)impl)->getAttribute(ATTR_CITE); 0069 } 0070 0071 void HTMLBlockquoteElement::setCite(const DOMString &value) 0072 { 0073 if (impl) { 0074 ((ElementImpl *)impl)->setAttribute(ATTR_CITE, value); 0075 } 0076 } 0077 0078 // -------------------------------------------------------------------------- 0079 0080 HTMLDivElement::HTMLDivElement() 0081 : HTMLElement() 0082 { 0083 } 0084 0085 HTMLDivElement::HTMLDivElement(const HTMLDivElement &other) 0086 : HTMLElement(other) 0087 { 0088 } 0089 0090 HTMLDivElement::HTMLDivElement(HTMLDivElementImpl *impl) 0091 : HTMLElement(impl) 0092 { 0093 } 0094 0095 HTMLDivElement &HTMLDivElement::operator = (const Node &other) 0096 { 0097 assignOther(other, ID_DIV); 0098 return *this; 0099 } 0100 0101 HTMLDivElement &HTMLDivElement::operator = (const HTMLDivElement &other) 0102 { 0103 HTMLElement::operator = (other); 0104 return *this; 0105 } 0106 0107 HTMLDivElement::~HTMLDivElement() 0108 { 0109 } 0110 0111 DOMString HTMLDivElement::align() const 0112 { 0113 if (!impl) { 0114 return DOMString(); 0115 } 0116 return ((ElementImpl *)impl)->getAttribute(ATTR_ALIGN); 0117 } 0118 0119 void HTMLDivElement::setAlign(const DOMString &value) 0120 { 0121 if (impl) { 0122 ((ElementImpl *)impl)->setAttribute(ATTR_ALIGN, value); 0123 } 0124 } 0125 0126 // -------------------------------------------------------------------------- 0127 0128 HTMLHRElement::HTMLHRElement() 0129 : HTMLElement() 0130 { 0131 } 0132 0133 HTMLHRElement::HTMLHRElement(const HTMLHRElement &other) 0134 : HTMLElement(other) 0135 { 0136 } 0137 0138 HTMLHRElement::HTMLHRElement(HTMLHRElementImpl *impl) 0139 : HTMLElement(impl) 0140 { 0141 } 0142 0143 HTMLHRElement &HTMLHRElement::operator = (const Node &other) 0144 { 0145 assignOther(other, ID_HR); 0146 return *this; 0147 } 0148 0149 HTMLHRElement &HTMLHRElement::operator = (const HTMLHRElement &other) 0150 { 0151 HTMLElement::operator = (other); 0152 return *this; 0153 } 0154 0155 HTMLHRElement::~HTMLHRElement() 0156 { 0157 } 0158 0159 DOMString HTMLHRElement::align() const 0160 { 0161 if (!impl) { 0162 return DOMString(); 0163 } 0164 return ((ElementImpl *)impl)->getAttribute(ATTR_ALIGN); 0165 } 0166 0167 void HTMLHRElement::setAlign(const DOMString &value) 0168 { 0169 if (impl) { 0170 ((ElementImpl *)impl)->setAttribute(ATTR_ALIGN, value); 0171 } 0172 } 0173 0174 bool HTMLHRElement::noShade() const 0175 { 0176 if (!impl) { 0177 return false; 0178 } 0179 return !((ElementImpl *)impl)->getAttribute(ATTR_NOSHADE).isNull(); 0180 } 0181 0182 void HTMLHRElement::setNoShade(bool _noShade) 0183 { 0184 if (impl) { 0185 DOMString str; 0186 if (_noShade) { 0187 str = ""; 0188 } 0189 ((ElementImpl *)impl)->setAttribute(ATTR_NOSHADE, str); 0190 } 0191 } 0192 0193 DOMString HTMLHRElement::size() const 0194 { 0195 if (!impl) { 0196 return DOMString(); 0197 } 0198 return ((ElementImpl *)impl)->getAttribute(ATTR_SIZE); 0199 } 0200 0201 void HTMLHRElement::setSize(const DOMString &value) 0202 { 0203 if (impl) { 0204 ((ElementImpl *)impl)->setAttribute(ATTR_SIZE, value); 0205 } 0206 } 0207 0208 DOMString HTMLHRElement::width() const 0209 { 0210 if (!impl) { 0211 return DOMString(); 0212 } 0213 return ((ElementImpl *)impl)->getAttribute(ATTR_WIDTH); 0214 } 0215 0216 void HTMLHRElement::setWidth(const DOMString &value) 0217 { 0218 if (impl) { 0219 ((ElementImpl *)impl)->setAttribute(ATTR_WIDTH, value); 0220 } 0221 } 0222 0223 // -------------------------------------------------------------------------- 0224 0225 HTMLHeadingElement::HTMLHeadingElement() 0226 : HTMLElement() 0227 { 0228 } 0229 0230 HTMLHeadingElement::HTMLHeadingElement(const HTMLHeadingElement &other) 0231 : HTMLElement(other) 0232 { 0233 } 0234 0235 HTMLHeadingElement::HTMLHeadingElement(HTMLElementImpl *impl) 0236 : HTMLElement(impl) 0237 { 0238 } 0239 0240 HTMLHeadingElement &HTMLHeadingElement::operator = (const Node &other) 0241 { 0242 if (other.elementId() != ID_H1 && 0243 other.elementId() != ID_H2 && 0244 other.elementId() != ID_H3 && 0245 other.elementId() != ID_H4 && 0246 other.elementId() != ID_H5 && 0247 other.elementId() != ID_H6) { 0248 if (impl) { 0249 impl->deref(); 0250 } 0251 impl = nullptr; 0252 } else { 0253 Node::operator = (other); 0254 } 0255 return *this; 0256 } 0257 0258 HTMLHeadingElement &HTMLHeadingElement::operator = (const HTMLHeadingElement &other) 0259 { 0260 HTMLElement::operator = (other); 0261 return *this; 0262 } 0263 0264 HTMLHeadingElement::~HTMLHeadingElement() 0265 { 0266 } 0267 0268 DOMString HTMLHeadingElement::align() const 0269 { 0270 if (!impl) { 0271 return DOMString(); 0272 } 0273 return ((ElementImpl *)impl)->getAttribute(ATTR_ALIGN); 0274 } 0275 0276 void HTMLHeadingElement::setAlign(const DOMString &value) 0277 { 0278 if (impl) { 0279 ((ElementImpl *)impl)->setAttribute(ATTR_ALIGN, value); 0280 } 0281 } 0282 0283 // -------------------------------------------------------------------------- 0284 0285 HTMLParagraphElement::HTMLParagraphElement() : HTMLElement() 0286 { 0287 } 0288 0289 HTMLParagraphElement::HTMLParagraphElement(const HTMLParagraphElement &other) 0290 : HTMLElement(other) 0291 { 0292 } 0293 0294 HTMLParagraphElement::HTMLParagraphElement(HTMLElementImpl *impl) 0295 : HTMLElement(impl) 0296 { 0297 } 0298 0299 HTMLParagraphElement &HTMLParagraphElement::operator = (const Node &other) 0300 { 0301 assignOther(other, ID_P); 0302 return *this; 0303 } 0304 0305 HTMLParagraphElement &HTMLParagraphElement::operator = (const HTMLParagraphElement &other) 0306 { 0307 HTMLElement::operator = (other); 0308 return *this; 0309 } 0310 0311 HTMLParagraphElement::~HTMLParagraphElement() 0312 { 0313 } 0314 0315 DOMString HTMLParagraphElement::align() const 0316 { 0317 if (!impl) { 0318 return DOMString(); 0319 } 0320 return ((ElementImpl *)impl)->getAttribute(ATTR_ALIGN); 0321 } 0322 0323 void HTMLParagraphElement::setAlign(const DOMString &value) 0324 { 0325 if (impl) { 0326 ((ElementImpl *)impl)->setAttribute(ATTR_ALIGN, value); 0327 } 0328 } 0329 0330 // -------------------------------------------------------------------------- 0331 0332 HTMLPreElement::HTMLPreElement() : HTMLElement() 0333 { 0334 } 0335 0336 HTMLPreElement::HTMLPreElement(const HTMLPreElement &other) 0337 : HTMLElement(other) 0338 { 0339 } 0340 0341 HTMLPreElement::HTMLPreElement(HTMLPreElementImpl *impl) 0342 : HTMLElement(impl) 0343 { 0344 } 0345 0346 HTMLPreElement &HTMLPreElement::operator = (const Node &other) 0347 { 0348 assignOther(other, (impl ? impl->id() : ID_PRE)); 0349 return *this; 0350 } 0351 0352 HTMLPreElement &HTMLPreElement::operator = (const HTMLPreElement &other) 0353 { 0354 HTMLElement::operator = (other); 0355 return *this; 0356 } 0357 0358 HTMLPreElement::~HTMLPreElement() 0359 { 0360 } 0361 0362 long HTMLPreElement::width() const 0363 { 0364 if (!impl) { 0365 return 0; 0366 } 0367 DOMString w = ((ElementImpl *)impl)->getAttribute(ATTR_WIDTH); 0368 return w.toInt(); 0369 } 0370 0371 void HTMLPreElement::setWidth(long _width) 0372 { 0373 if (!impl) { 0374 return; 0375 } 0376 0377 QString aStr; 0378 aStr.sprintf("%ld", _width); 0379 DOMString value(aStr); 0380 ((ElementImpl *)impl)->setAttribute(ATTR_WIDTH, value); 0381 } 0382 0383 // -------------------------------------------------------------------------- 0384 0385 HTMLLayerElement::HTMLLayerElement() : HTMLElement() 0386 { 0387 } 0388 0389 HTMLLayerElement::HTMLLayerElement(const HTMLLayerElement &other) 0390 : HTMLElement(other) 0391 { 0392 } 0393 0394 HTMLLayerElement::HTMLLayerElement(HTMLLayerElementImpl *impl) 0395 : HTMLElement(impl) 0396 { 0397 } 0398 0399 HTMLLayerElement &HTMLLayerElement::operator = (const Node &other) 0400 { 0401 assignOther(other, ID_LAYER); 0402 return *this; 0403 } 0404 0405 HTMLLayerElement &HTMLLayerElement::operator = (const HTMLLayerElement &other) 0406 { 0407 HTMLElement::operator = (other); 0408 return *this; 0409 } 0410 0411 HTMLLayerElement::~HTMLLayerElement() 0412 { 0413 } 0414 0415 long HTMLLayerElement::top() const 0416 { 0417 if (!impl) { 0418 return 0; 0419 } 0420 DOMString t = ((ElementImpl *)impl)->getAttribute(ATTR_TOP); 0421 return t.toInt(); 0422 } 0423 0424 void HTMLLayerElement::setTop(long _top) 0425 { 0426 if (!impl) { 0427 return; 0428 } 0429 0430 QString aStr; 0431 aStr.sprintf("%ld", _top); 0432 DOMString value(aStr); 0433 ((ElementImpl *)impl)->setAttribute(ATTR_TOP, value); 0434 } 0435 0436 long HTMLLayerElement::left() const 0437 { 0438 if (!impl) { 0439 return 0; 0440 } 0441 DOMString l = ((ElementImpl *)impl)->getAttribute(ATTR_LEFT); 0442 return l.toInt(); 0443 } 0444 0445 void HTMLLayerElement::setLeft(long _left) 0446 { 0447 if (!impl) { 0448 return; 0449 } 0450 0451 QString aStr; 0452 aStr.sprintf("%ld", _left); 0453 DOMString value(aStr); 0454 ((ElementImpl *)impl)->setAttribute(ATTR_LEFT, value); 0455 } 0456 0457 DOMString HTMLLayerElement::visibility() const 0458 { 0459 if (!impl) { 0460 return DOMString(); 0461 } 0462 return ((ElementImpl *)impl)->getAttribute(ATTR_VISIBILITY); 0463 } 0464 0465 void HTMLLayerElement::setVisibility(const DOMString &value) 0466 { 0467 if (impl) { 0468 ((ElementImpl *)impl)->setAttribute(ATTR_VISIBILITY, value); 0469 } 0470 } 0471 0472 DOMString HTMLLayerElement::bgColor() const 0473 { 0474 if (!impl) { 0475 return DOMString(); 0476 } 0477 return ((ElementImpl *)impl)->getAttribute(ATTR_BGCOLOR); 0478 } 0479 0480 void HTMLLayerElement::setBgColor(const DOMString &value) 0481 { 0482 if (impl) { 0483 ((ElementImpl *)impl)->setAttribute(ATTR_BGCOLOR, value); 0484 } 0485 } 0486 0487 HTMLCollection HTMLLayerElement::layers() const 0488 { 0489 if (!impl) { 0490 return HTMLCollection(); 0491 } 0492 return HTMLCollection(impl, HTMLCollectionImpl::DOC_LAYERS); 0493 }