• Skip to content
  • Skip to link menu
KDE 4.3 API Reference
  • KDE API Reference
  • kdelibs
  • Sitemap
  • Contact Us
 

KHTML

dom_node.cpp

Go to the documentation of this file.
00001 
00023 #include "dom/dom_doc.h"
00024 #include "dom/dom_exception.h"
00025 #include "dom/dom2_events.h"
00026 #include "xml/dom_docimpl.h"
00027 #include "xml/dom_elementimpl.h"
00028 #include "xml/dom2_eventsimpl.h"
00029 
00030 #include <QtCore/QRect>
00031 
00032 using namespace DOM;
00033 
00034 NamedNodeMap::NamedNodeMap()
00035 {
00036     impl = 0;
00037 }
00038 
00039 NamedNodeMap::NamedNodeMap(const NamedNodeMap &other)
00040 {
00041     impl = other.impl;
00042     if (impl) impl->ref();
00043 }
00044 
00045 NamedNodeMap::NamedNodeMap(NamedNodeMapImpl *i)
00046 {
00047     impl = i;
00048     if (impl) impl->ref();
00049 }
00050 
00051 NamedNodeMap &NamedNodeMap::operator = (const NamedNodeMap &other)
00052 {
00053     if ( impl != other.impl ) {
00054         if(impl) impl->deref();
00055         impl = other.impl;
00056         if(impl) impl->ref();
00057     }
00058     return *this;
00059 }
00060 
00061 NamedNodeMap::~NamedNodeMap()
00062 {
00063     if(impl) impl->deref();
00064 }
00065 
00066 Node NamedNodeMap::getNamedItem( const DOMString &name ) const
00067 {
00068     if (!impl) return 0;
00069     return impl->getNamedItem(name);
00070 }
00071 
00072 Node NamedNodeMap::setNamedItem( const Node &arg )
00073 {
00074     if (!impl) throw DOMException(DOMException::NOT_FOUND_ERR);
00075 
00076     int exceptioncode = 0;
00077     Node r = impl->setNamedItem(arg, exceptioncode);
00078     if (exceptioncode)
00079         throw DOMException(exceptioncode);
00080     return r;
00081 }
00082 
00083 Node NamedNodeMap::removeNamedItem( const DOMString &name )
00084 {
00085     if (!impl) throw DOMException(DOMException::NOT_FOUND_ERR);
00086     int exceptioncode = 0;
00087     Node r = impl->removeNamedItem(name, exceptioncode);
00088     if (exceptioncode)
00089         throw DOMException(exceptioncode);
00090     return r;
00091 }
00092 
00093 Node NamedNodeMap::item( unsigned long index ) const
00094 {
00095     if (!impl) return 0;
00096     return impl->item(index);
00097 }
00098 
00099 Node NamedNodeMap::getNamedItemNS( const DOMString &namespaceURI, const DOMString &localName ) const
00100 {
00101     if (!impl) return 0;
00102     return impl->getNamedItemNS(namespaceURI, localName);
00103 }
00104 
00105 Node NamedNodeMap::setNamedItemNS( const Node &arg )
00106 {
00107     if (!impl) throw DOMException(DOMException::NOT_FOUND_ERR);
00108     int exceptioncode = 0;
00109     Node r = impl->setNamedItemNS(arg, exceptioncode);
00110     if (exceptioncode)
00111         throw DOMException(exceptioncode);
00112     return r;
00113 }
00114 
00115 Node NamedNodeMap::removeNamedItemNS( const DOMString &namespaceURI, const DOMString &localName )
00116 {
00117     if (!impl) throw DOMException(DOMException::NOT_FOUND_ERR);
00118     int exceptioncode = 0;
00119     Node r = impl->removeNamedItemNS(namespaceURI, localName, exceptioncode);
00120     if (exceptioncode)
00121         throw DOMException(exceptioncode);
00122     return r;
00123 }
00124 
00125 unsigned long NamedNodeMap::length() const
00126 {
00127     if (!impl) return 0;
00128     return impl->length();
00129 }
00130 
00131 // ---------------------------------------------------------------------------
00132 
00133 Node::Node(const Node &other)
00134 {
00135     impl = other.impl;
00136     if(impl) impl->ref();
00137 }
00138 
00139 Node::Node( NodeImpl *i )
00140 {
00141     impl = i;
00142     if(impl) impl->ref();
00143 }
00144 
00145 Node &Node::operator = (const Node &other)
00146 {
00147     if(impl != other.impl) {
00148         if(impl) impl->deref();
00149         impl = other.impl;
00150         if(impl) impl->ref();
00151     }
00152     return *this;
00153 }
00154 
00155 bool Node::operator == (const Node &other) const
00156 {
00157     return (impl == other.impl);
00158 }
00159 
00160 bool Node::operator != (const Node &other) const
00161 {
00162     return !(impl == other.impl);
00163 }
00164 
00165 Node::~Node()
00166 {
00167     if(impl) impl->deref();
00168 }
00169 
00170 DOMString Node::nodeName() const
00171 {
00172     if(impl) return impl->nodeName();
00173     return DOMString();
00174 }
00175 
00176 DOMString Node::nodeValue() const
00177 {
00178     // ### should throw exception on plain node ?
00179     if(impl) return impl->nodeValue();
00180     return DOMString();
00181 }
00182 
00183 void Node::setNodeValue( const DOMString &_str )
00184 {
00185     if (!impl) throw DOMException(DOMException::NOT_FOUND_ERR);
00186 
00187     int exceptioncode = 0;
00188     if(impl) impl->setNodeValue( _str,exceptioncode );
00189     if (exceptioncode)
00190     throw DOMException(exceptioncode);
00191 }
00192 
00193 unsigned short Node::nodeType() const
00194 {
00195     if (!impl) throw DOMException(DOMException::NOT_FOUND_ERR);
00196     return impl->nodeType();
00197 }
00198 
00199 Node Node::parentNode() const
00200 {
00201     if (!impl) throw DOMException(DOMException::NOT_FOUND_ERR);
00202     return impl->parentNode();
00203 }
00204 
00205 NodeList Node::childNodes() const
00206 {
00207     if (!impl) return 0;
00208     return impl->childNodes();
00209 }
00210 
00211 Node Node::firstChild() const
00212 {
00213     if (!impl) throw DOMException(DOMException::NOT_FOUND_ERR);
00214     return impl->firstChild();
00215 }
00216 
00217 Node Node::lastChild() const
00218 {
00219     if (!impl) throw DOMException(DOMException::NOT_FOUND_ERR);
00220     return impl->lastChild();
00221 }
00222 
00223 Node Node::previousSibling() const
00224 {
00225     if (!impl) throw DOMException(DOMException::NOT_FOUND_ERR);
00226     return impl->previousSibling();
00227 }
00228 
00229 Node Node::nextSibling() const
00230 {
00231     if (!impl) throw DOMException(DOMException::NOT_FOUND_ERR);
00232     return impl->nextSibling();
00233 }
00234 
00235 NamedNodeMap Node::attributes() const
00236 {
00237     if (!impl || !impl->isElementNode()) return 0;
00238     return static_cast<ElementImpl*>(impl)->attributes();
00239 }
00240 
00241 Document Node::ownerDocument() const
00242 {
00243     if (!impl || !impl->ownerDocument())
00244         return Document(false);
00245     return impl->ownerDocument();
00246 }
00247 
00248 Node Node::insertBefore( const Node &newChild, const Node &refChild )
00249 {
00250     if (!impl) throw DOMException(DOMException::NOT_FOUND_ERR);
00251     int exceptioncode = 0;
00252     NodeImpl *r = impl->insertBefore( newChild.impl, refChild.impl, exceptioncode );
00253     if (exceptioncode)
00254     throw DOMException(exceptioncode);
00255     return r;
00256 }
00257 
00258 Node Node::replaceChild( const Node &newChild, const Node &oldChild )
00259 {
00260     if (!impl) throw DOMException(DOMException::NOT_FOUND_ERR);
00261     int exceptioncode = 0;
00262     impl->replaceChild( newChild.impl, oldChild.impl, exceptioncode );
00263     if (exceptioncode)
00264     throw DOMException(exceptioncode);
00265     return oldChild;
00266 }
00267 
00268 Node Node::removeChild( const Node &oldChild )
00269 {
00270     if (!impl) throw DOMException(DOMException::NOT_FOUND_ERR);
00271     int exceptioncode = 0;
00272     impl->removeChild( oldChild.impl, exceptioncode );
00273     if (exceptioncode)
00274     throw DOMException(exceptioncode);
00275 
00276     return oldChild;
00277 }
00278 
00279 Node Node::appendChild( const Node &newChild )
00280 {
00281     if (!impl) throw DOMException(DOMException::NOT_FOUND_ERR);
00282     int exceptioncode = 0;
00283     NodeImpl *r = impl->appendChild( newChild.impl, exceptioncode );
00284     if (exceptioncode)
00285     throw DOMException(exceptioncode);
00286     return r;
00287 }
00288 
00289 bool Node::hasAttributes()
00290 {
00291     if (!impl) throw DOMException(DOMException::NOT_FOUND_ERR);
00292     return impl->hasAttributes();
00293 }
00294 
00295 bool Node::hasChildNodes(  )
00296 {
00297     if (!impl) return false;
00298     return impl->hasChildNodes();
00299 }
00300 
00301 Node Node::cloneNode( bool deep )
00302 {
00303     if (!impl) return 0;
00304     return impl->cloneNode( deep ).get();
00305 }
00306 
00307 void Node::normalize (  )
00308 {
00309     if (!impl) return;
00310     impl->normalize();
00311 }
00312 
00313 bool Node::isSupported( const DOMString &feature,
00314                         const DOMString &version ) const
00315 {
00316     return NodeImpl::isSupported(feature, version);
00317 }
00318 
00319 DOMString Node::namespaceURI(  ) const
00320 {
00321     if (!impl) return DOMString();
00322     return impl->namespaceURI();
00323 }
00324 
00325 DOMString Node::prefix(  ) const
00326 {
00327     if (!impl) return DOMString();
00328     return impl->prefix();
00329 }
00330 
00331 void Node::setPrefix(const DOMString &prefix )
00332 {
00333     if (!impl) throw DOMException(DOMException::NOT_FOUND_ERR);
00334     int exceptioncode = 0;
00335     impl->setPrefix(prefix,exceptioncode);
00336     if (exceptioncode)
00337         throw DOMException(exceptioncode);
00338 }
00339 
00340 DOMString Node::localName(  ) const
00341 {
00342     if (!impl) return DOMString();
00343     return impl->localName();
00344 }
00345 
00346 void Node::addEventListener(const DOMString &type,
00347               EventListener *listener,
00348               const bool useCapture)
00349 {
00350     if (!impl) return;
00351     if (listener)
00352         impl->addEventListener(EventName::fromString(type),listener,useCapture);
00353 }
00354 
00355 void Node::removeEventListener(const DOMString &type,
00356                  EventListener *listener,
00357                  bool useCapture)
00358 {
00359     if (!impl) return;
00360     impl->removeEventListener(EventName::fromString(type),listener,useCapture);
00361 }
00362 
00363 bool Node::dispatchEvent(const Event &evt)
00364 {
00365     if (!impl)
00366     throw DOMException(DOMException::INVALID_STATE_ERR);
00367 
00368     if (!evt.handle())
00369         throw DOMException(DOMException::NOT_FOUND_ERR);
00370 
00371     int exceptioncode = 0;
00372     impl->dispatchEvent(evt.handle(),exceptioncode);
00373     if (exceptioncode)
00374     throw DOMException(exceptioncode);
00375     return !evt.handle()->defaultPrevented();
00376 }
00377 
00378 DOMString Node::textContent() const
00379 {
00380     if (!impl) return DOMString();
00381     return impl->textContent();
00382 }
00383 
00384 void Node::setTextContent(const DOMString& content)
00385 {
00386     if (!impl) throw DOMException(DOMException::NOT_FOUND_ERR);
00387     int exceptioncode = 0;
00388     impl->setTextContent(content, exceptioncode);
00389     if (exceptioncode)
00390         throw DOMException(exceptioncode);
00391 }
00392 
00393 unsigned Node::compareDocumentPosition(const Node& other)
00394 {
00395     if (!impl || !other.impl)
00396     throw DOMException(DOMException::NOT_FOUND_ERR);
00397     return impl->compareDocumentPosition(other.impl);
00398 }
00399 
00400 unsigned int Node::elementId() const
00401 {
00402     if (!impl) return 0;
00403     return impl->id();
00404 }
00405 
00406 unsigned long Node::index() const
00407 {
00408     if (!impl) return 0;
00409     return impl->nodeIndex();
00410 }
00411 
00412 QString Node::toHTML()
00413 {
00414     if (!impl) return QString();
00415     return impl->toString().string();
00416 }
00417 
00418 void Node::applyChanges()
00419 {
00420     if (!impl) return;
00421     impl->recalcStyle( NodeImpl::Inherit );
00422 }
00423 
00424 void Node::getCursor(int offset, int &_x, int &_y, int &height)
00425 {
00426     if (!impl) throw DOMException(DOMException::NOT_FOUND_ERR);
00427     int dummy;
00428     impl->getCaret(offset, false, _x, _y, dummy, height);
00429 }
00430 
00431 QRect Node::getRect()
00432 {
00433     if (!impl) throw DOMException(DOMException::NOT_FOUND_ERR);
00434     return impl->getRect();
00435 }
00436 
00437 //-----------------------------------------------------------------------------
00438 
00439 NodeList::NodeList()
00440 {
00441     impl = 0;
00442 }
00443 
00444 NodeList::NodeList(const NodeList &other)
00445 {
00446     impl = other.impl;
00447     if(impl) impl->ref();
00448 }
00449 
00450 NodeList::NodeList(const NodeListImpl *i)
00451 {
00452     impl = const_cast<NodeListImpl *>(i);
00453     if(impl) impl->ref();
00454 }
00455 
00456 NodeList &NodeList::operator = (const NodeList &other)
00457 {
00458     if ( impl != other.impl ) {
00459         if(impl) impl->deref();
00460         impl = other.impl;
00461         if(impl) impl->ref();
00462     }
00463     return *this;
00464 }
00465 
00466 NodeList::~NodeList()
00467 {
00468     if(impl) impl->deref();
00469 }
00470 
00471 Node NodeList::item( unsigned long index ) const
00472 {
00473     if (!impl) return 0;
00474     return impl->item(index);
00475 }
00476 
00477 unsigned long NodeList::length() const
00478 {
00479     if (!impl) return 0;
00480     return impl->length();
00481 }

KHTML

Skip menu "KHTML"
  • Main Page
  • Namespace List
  • Class Hierarchy
  • Alphabetical List
  • Class List
  • File List
  • Namespace Members
  • Class Members
  • Related Pages

kdelibs

Skip menu "kdelibs"
  • DNSSD
  • Interfaces
  •   KHexEdit
  •   KMediaPlayer
  •   KSpeech
  •   KTextEditor
  • Kate
  • kconf_update
  • KDE3Support
  •   KUnitTest
  • KDECore
  • KDED
  • KDEsu
  • KDEUI
  • KDocTools
  • KFile
  • KHTML
  • KImgIO
  • KInit
  • kio
  • KIOSlave
  • KJS
  •   KJS-API
  •   WTF
  • kjsembed
  • KNewStuff
  • KParts
  • KPty
  • Kross
  • KUtils
  • Nepomuk
  • Plasma
  • Solid
  • Sonnet
  • ThreadWeaver
Generated for kdelibs by doxygen 1.6.1
This website is maintained by Adriaan de Groot and Allen Winter.
KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal