fix logic
[personal-kdelibs.git] / khtml / dom / dom_xml.cpp
blobee7246cdaec395ceba5780e518cbbe261e4c425d
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.
24 #include "dom/dom_xml.h"
25 #include "dom/dom_exception.h"
26 #include "xml/dom_textimpl.h"
27 #include "xml/dom_xmlimpl.h"
29 using namespace DOM;
31 CDATASection::CDATASection()
35 CDATASection::CDATASection(const CDATASection &) : Text()
39 CDATASection &CDATASection::operator = (const Node &other)
41 NodeImpl* ohandle = other.handle();
42 if ( impl != ohandle ) {
43 if (!ohandle || ohandle->nodeType() != CDATA_SECTION_NODE) {
44 if ( impl ) impl->deref();
45 impl = 0;
46 } else {
47 Node::operator =(other);
50 return *this;
53 CDATASection &CDATASection::operator = (const CDATASection &other)
55 Node::operator =(other);
56 return *this;
59 CDATASection::~CDATASection()
63 CDATASection::CDATASection(CDATASectionImpl *i) : Text(i)
67 // ----------------------------------------------------------------------------
68 Entity::Entity()
72 Entity::Entity(const Entity &) : Node()
76 Entity &Entity::operator = (const Node &other)
78 NodeImpl* ohandle = other.handle();
79 if ( impl != ohandle ) {
80 if (!ohandle || ohandle->nodeType() != ENTITY_NODE) {
81 if ( impl ) impl->deref();
82 impl = 0;
83 } else {
84 Node::operator =(other);
87 return *this;
90 Entity &Entity::operator = (const Entity &other)
92 Node::operator =(other);
93 return *this;
96 Entity::~Entity()
100 DOMString Entity::publicId() const
102 if (!impl)
103 return DOMString(); // ### enable throw DOMException(DOMException::NOT_FOUND_ERR);
105 return ((EntityImpl*)impl)->publicId();
108 DOMString Entity::systemId() const
110 if (!impl)
111 return DOMString(); // ### enable throw DOMException(DOMException::NOT_FOUND_ERR);
113 return ((EntityImpl*)impl)->systemId();
116 DOMString Entity::notationName() const
118 if (!impl)
119 return DOMString(); // ### enable throw DOMException(DOMException::NOT_FOUND_ERR);
121 return ((EntityImpl*)impl)->notationName();
124 Entity::Entity(EntityImpl *i) : Node(i)
128 // ----------------------------------------------------------------------------
130 EntityReference::EntityReference()
134 EntityReference::EntityReference(const EntityReference &) : Node()
138 EntityReference &EntityReference::operator = (const Node &other)
140 NodeImpl* ohandle = other.handle();
141 if ( impl != ohandle ) {
142 if (!ohandle || ohandle->nodeType() != ENTITY_REFERENCE_NODE) {
143 if ( impl ) impl->deref();
144 impl = 0;
145 } else {
146 Node::operator =(other);
149 return *this;
152 EntityReference &EntityReference::operator = (const EntityReference &other)
154 Node::operator =(other);
155 return *this;
158 EntityReference::~EntityReference()
162 EntityReference::EntityReference(EntityReferenceImpl *i) : Node(i)
166 // ----------------------------------------------------------------------------
168 Notation::Notation()
172 Notation::Notation(const Notation &) : Node()
176 Notation &Notation::operator = (const Node &other)
178 NodeImpl* ohandle = other.handle();
179 if ( impl != ohandle ) {
180 if (!ohandle || ohandle->nodeType() != NOTATION_NODE) {
181 if ( impl ) impl->deref();
182 impl = 0;
183 } else {
184 Node::operator =(other);
187 return *this;
190 Notation &Notation::operator = (const Notation &other)
192 Node::operator =(other);
193 return *this;
196 Notation::~Notation()
200 DOMString Notation::publicId() const
202 if (!impl)
203 return DOMString(); // ### enable throw DOMException(DOMException::NOT_FOUND_ERR);
205 return ((NotationImpl*)impl)->publicId();
208 DOMString Notation::systemId() const
210 if (!impl)
211 return DOMString(); // ### enable throw DOMException(DOMException::NOT_FOUND_ERR);
213 return ((NotationImpl*)impl)->systemId();
216 Notation::Notation(NotationImpl *i) : Node(i)
221 // ----------------------------------------------------------------------------
223 ProcessingInstruction::ProcessingInstruction()
227 ProcessingInstruction::ProcessingInstruction(const ProcessingInstruction &)
228 : Node()
232 ProcessingInstruction &ProcessingInstruction::operator = (const Node &other)
234 NodeImpl* ohandle = other.handle();
235 if ( impl != ohandle ) {
236 if (!ohandle || ohandle->nodeType() != PROCESSING_INSTRUCTION_NODE) {
237 if ( impl ) impl->deref();
238 impl = 0;
239 } else {
240 Node::operator =(other);
243 return *this;
246 ProcessingInstruction &ProcessingInstruction::operator = (const ProcessingInstruction &other)
248 Node::operator =(other);
249 return *this;
252 ProcessingInstruction::~ProcessingInstruction()
256 DOMString ProcessingInstruction::target() const
258 if (!impl)
259 return DOMString(); // ### enable throw DOMException(DOMException::NOT_FOUND_ERR);
261 return ((ProcessingInstructionImpl*)impl)->target();
264 DOMString ProcessingInstruction::data() const
266 if (!impl)
267 return DOMString(); // ### enable throw DOMException(DOMException::NOT_FOUND_ERR);
269 return ((ProcessingInstructionImpl*)impl)->data();
272 void ProcessingInstruction::setData( const DOMString &_data )
274 if (!impl)
275 return; // ### enable throw DOMException(DOMException::NOT_FOUND_ERR);
277 int exceptioncode = 0;
278 ((ProcessingInstructionImpl*)impl)->setData(_data, exceptioncode);
279 if (exceptioncode)
280 throw DOMException(exceptioncode);
283 ProcessingInstruction::ProcessingInstruction(ProcessingInstructionImpl *i) : Node(i)
287 StyleSheet ProcessingInstruction::sheet() const
289 if (impl) return ((ProcessingInstructionImpl*)impl)->sheet();
290 return 0;