fix logic
[personal-kdelibs.git] / khtml / xml / dom_xmlimpl.h
blob0bde4c3081ba5a17f34f8cdbd98b0e58482bdbd5
1 /*
2 * This file is part of the DOM implementation for KDE.
4 * Copyright (C) 2000 Peter Kelly (pmk@post.com)
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.
23 #ifndef _DOM_XmlImpl_h_
24 #define _DOM_XmlImpl_h_
26 #include "xml/dom_nodeimpl.h"
27 #include "misc/loader_client.h"
29 #include <QtXml/qxml.h>
31 namespace khtml {
32 class CachedCSSStyleSheet;
35 namespace DOM {
37 class DocumentImpl;
38 class CSSStyleSheetImpl;
39 class StyleSheetImpl;
40 class DOMString;
42 class EntityImpl : public NodeBaseImpl
44 public:
45 EntityImpl(DocumentImpl *doc);
46 EntityImpl(DocumentImpl *doc, DOMString _name);
47 EntityImpl(DocumentImpl *doc, DOMString _publicId, DOMString _systemId, DOMString _notationName);
48 virtual ~EntityImpl();
50 // DOM methods & attributes for Entity
52 virtual DOMString publicId() const;
53 virtual DOMString systemId() const;
54 virtual DOMString notationName() const;
56 // DOM methods overridden from parent classes
58 virtual DOMString nodeName() const;
59 virtual unsigned short nodeType() const;
60 virtual WTF::PassRefPtr<NodeImpl> cloneNode ( bool deep );
62 // Other methods (not part of DOM)
64 virtual bool childTypeAllowed( unsigned short type );
66 virtual DOMString toString() const;
68 protected:
69 DOMStringImpl *m_publicId;
70 DOMStringImpl *m_systemId;
71 DOMStringImpl *m_notationName;
72 DOMStringImpl *m_name;
76 class EntityReferenceImpl : public NodeBaseImpl
78 public:
79 EntityReferenceImpl(DocumentImpl *doc);
80 EntityReferenceImpl(DocumentImpl *doc, DOMStringImpl *_entityName);
81 virtual ~EntityReferenceImpl();
83 // DOM methods overridden from parent classes
85 virtual DOMString nodeName() const;
86 virtual unsigned short nodeType() const;
87 virtual WTF::PassRefPtr<NodeImpl> cloneNode ( bool deep );
89 // Other methods (not part of DOM)
91 virtual bool childTypeAllowed( unsigned short type );
93 virtual DOMString toString() const;
94 protected:
95 DOMStringImpl *m_entityName;
98 class NotationImpl : public NodeBaseImpl
100 public:
101 NotationImpl(DocumentImpl *doc);
102 NotationImpl(DocumentImpl *doc, DOMString _name, DOMString _publicId, DOMString _systemId);
103 virtual ~NotationImpl();
105 // DOM methods & attributes for Notation
107 virtual DOMString publicId() const;
108 virtual DOMString systemId() const;
110 // DOM methods overridden from parent classes
112 virtual DOMString nodeName() const;
113 virtual unsigned short nodeType() const;
114 virtual WTF::PassRefPtr<NodeImpl> cloneNode ( bool deep );
116 // Other methods (not part of DOM)
118 virtual bool childTypeAllowed( unsigned short type );
119 protected:
120 DOMStringImpl *m_name;
121 DOMStringImpl *m_publicId;
122 DOMStringImpl *m_systemId;
126 class ProcessingInstructionImpl : public NodeBaseImpl, private khtml::CachedObjectClient
128 public:
129 ProcessingInstructionImpl(DocumentImpl *doc);
130 ProcessingInstructionImpl(DocumentImpl *doc, DOMString _target, DOMString _data);
131 virtual ~ProcessingInstructionImpl();
133 // DOM methods & attributes for Notation
135 virtual DOMString target() const;
136 DOMString data() const { return m_data; }
137 virtual void setData( const DOMString &_data, int &exceptioncode );
139 // DOM methods overridden from parent classes
141 virtual DOMString nodeName() const;
142 virtual unsigned short nodeType() const;
143 virtual DOMString nodeValue() const;
144 virtual void setNodeValue( const DOMString &_nodeValue, int &exceptioncode );
145 virtual WTF::PassRefPtr<NodeImpl> cloneNode ( bool deep );
147 // Other methods (not part of DOM)
149 virtual DOMString localHref() const;
150 virtual bool childTypeAllowed( unsigned short type );
151 StyleSheetImpl *sheet() const;
152 void checkStyleSheet();
153 virtual void setStyleSheet(const DOM::DOMString &url, const DOM::DOMString &sheet, const DOM::DOMString &charset, const DOM::DOMString &mimetype);
154 virtual void setStyleSheet(CSSStyleSheetImpl* sheet);
156 virtual DOMString toString() const;
158 virtual bool offsetInCharacters() const { return true; }
159 virtual int maxCharacterOffset() const;
161 bool isAlternate() const { return m_alternate; }
162 protected:
163 DOMStringImpl *m_target;
164 DOMStringImpl *m_data;
165 DOMStringImpl *m_localHref;
166 DOMStringImpl *m_title;
167 DOMStringImpl *m_media;
168 bool m_alternate;
169 khtml::CachedCSSStyleSheet *m_cachedSheet;
170 CSSStyleSheetImpl *m_sheet;
173 class XMLAttributeReader : public QXmlDefaultHandler
175 public:
176 XMLAttributeReader(const QString& _attrString);
177 virtual ~XMLAttributeReader();
178 QXmlAttributes readAttrs(bool &ok);
179 bool startElement(const QString& namespaceURI, const QString& localName, const QString& qName, const QXmlAttributes& atts);
181 protected:
182 QXmlAttributes attrs;
183 QString m_attrString;
186 } //namespace
188 #endif