• Skip to content
  • Skip to link menu
  • KDE API Reference
  • kdelibs-4.14.38 API Reference
  • KDE Home
  • Contact Us
 

KHTML

  • khtml
  • dom
dom_text.cpp
Go to the documentation of this file.
1
23#include "dom_text.h"
24#include "dom_exception.h"
25
26#include <xml/dom_textimpl.h>
27
28using namespace DOM;
29
30CharacterData::CharacterData() : Node()
31{
32}
33
34CharacterData::CharacterData(const CharacterData &other) : Node(other)
35{
36}
37
38CharacterData &CharacterData::operator = (const Node &other)
39{
40 NodeImpl* ohandle = other.handle();
41 if ( impl != ohandle ) {
42 if (!ohandle ||
43 ( ohandle->nodeType() != CDATA_SECTION_NODE &&
44 ohandle->nodeType() != TEXT_NODE &&
45 ohandle->nodeType() != COMMENT_NODE )) {
46 if ( impl ) impl->deref();
47 impl = 0;
48 } else {
49 Node::operator =(other);
50 }
51 }
52 return *this;
53}
54
55CharacterData &CharacterData::operator = (const CharacterData &other)
56{
57 Node::operator =(other);
58 return *this;
59}
60
61CharacterData::~CharacterData()
62{
63}
64
65DOMString CharacterData::data() const
66{
67 if(!impl) return DOMString();
68 return ((CharacterDataImpl *)impl)->data();
69}
70
71void CharacterData::setData( const DOMString &str )
72{
73 if (!impl)
74 return; // ### enable throw DOMException(DOMException::NOT_FOUND_ERR);
75
76 int exceptioncode = 0;
77 ((CharacterDataImpl *)impl)->setData(str, exceptioncode);
78 if ( exceptioncode )
79 throw DOMException( exceptioncode );
80 return;
81}
82
83unsigned long CharacterData::length() const
84{
85 if ( impl )
86 return ((CharacterDataImpl *)impl)->length();
87 return 0;
88}
89
90DOMString CharacterData::substringData( const unsigned long offset, const unsigned long count )
91{
92 if (!impl)
93 return DOMString(); // ### enable throw DOMException(DOMException::NOT_FOUND_ERR);
94
95 int exceptioncode = 0;
96 DOMString str = ((CharacterDataImpl *)impl)->substringData(offset, count, exceptioncode);
97 if ( exceptioncode )
98 throw DOMException( exceptioncode );
99 return str;
100}
101
102void CharacterData::appendData( const DOMString &arg )
103{
104 if (!impl)
105 return; // ### enable throw DOMException(DOMException::NOT_FOUND_ERR);
106
107 int exceptioncode = 0;
108 ((CharacterDataImpl *)impl)->appendData(arg, exceptioncode);
109 if ( exceptioncode )
110 throw DOMException( exceptioncode );
111}
112
113void CharacterData::insertData( const unsigned long offset, const DOMString &arg )
114{
115 if (!impl)
116 return; // ### enable throw DOMException(DOMException::NOT_FOUND_ERR);
117
118 int exceptioncode = 0;
119 ((CharacterDataImpl *)impl)->insertData(offset, arg, exceptioncode);
120 if ( exceptioncode )
121 throw DOMException( exceptioncode );
122}
123
124void CharacterData::deleteData( const unsigned long offset, const unsigned long count )
125{
126 if (!impl)
127 return; // ### enable throw DOMException(DOMException::NOT_FOUND_ERR);
128
129 int exceptioncode = 0;
130 ((CharacterDataImpl *)impl)->deleteData(offset, count, exceptioncode);
131 if ( exceptioncode )
132 throw DOMException( exceptioncode );
133}
134
135void CharacterData::replaceData( const unsigned long offset, const unsigned long count, const DOMString &arg )
136{
137 if (!impl)
138 return; // ### enable throw DOMException(DOMException::NOT_FOUND_ERR);
139
140 int exceptioncode = 0;
141 ((CharacterDataImpl *)impl)->replaceData(offset, count, arg, exceptioncode);
142 if ( exceptioncode )
143 throw DOMException( exceptioncode );
144}
145
146CharacterData::CharacterData(CharacterDataImpl *i) : Node(i)
147{
148}
149
150// ---------------------------------------------------------------------------
151
152Comment::Comment() : CharacterData()
153{
154}
155
156Comment::Comment(const Comment &other) : CharacterData(other)
157{
158}
159
160Comment &Comment::operator = (const Node &other)
161{
162 NodeImpl* ohandle = other.handle();
163 if ( impl != ohandle ) {
164 if (!ohandle || ohandle->nodeType() != COMMENT_NODE) {
165 if ( impl ) impl->deref();
166 impl = 0;
167 } else {
168 Node::operator =(other);
169 }
170 }
171 return *this;
172}
173
174Comment &Comment::operator = (const Comment &other)
175{
176 CharacterData::operator =(other);
177 return *this;
178}
179
180Comment::~Comment()
181{
182}
183
184Comment::Comment(CommentImpl *i) : CharacterData(i)
185{
186}
187
188// ----------------------------------------------------------------------------
189
190Text::Text()
191{
192}
193
194Text::Text(const Text &other) : CharacterData(other)
195{
196}
197
198Text &Text::operator = (const Node &other)
199{
200 NodeImpl* ohandle = other.handle();
201 if ( impl != ohandle ) {
202 if (!ohandle ||
203 (ohandle->nodeType() != TEXT_NODE &&
204 ohandle->nodeType() != CDATA_SECTION_NODE)) {
205 if ( impl ) impl->deref();
206 impl = 0;
207 } else {
208 Node::operator =(other);
209 }
210 }
211 return *this;
212}
213
214Text &Text::operator = (const Text &other)
215{
216 Node::operator =(other);
217 return *this;
218}
219
220Text::~Text()
221{
222}
223
224Text Text::splitText( const unsigned long offset )
225{
226 if (!impl)
227 return 0; // ### enable throw DOMException(DOMException::NOT_FOUND_ERR);
228
229 int exceptioncode = 0;
230 TextImpl *newText = static_cast<TextImpl *>(impl)->splitText(offset, exceptioncode );
231 if ( exceptioncode )
232 throw DOMException( exceptioncode );
233 return newText;
234}
235
236Text::Text(TextImpl *i) : CharacterData(i)
237{
238}
DOM::CharacterData
The CharacterData interface extends Node with a set of attributes and methods for accessing character...
Definition: dom_text.h:50
DOM::CharacterData::CharacterDataImpl
friend class CharacterDataImpl
Definition: dom_text.h:51
DOM::CharacterData::appendData
void appendData(const DOMString &arg)
Append the string to the end of the character data of the node.
Definition: dom_text.cpp:102
DOM::CharacterData::deleteData
void deleteData(const unsigned long offset, const unsigned long count)
Remove a range of characters from the node.
Definition: dom_text.cpp:124
DOM::CharacterData::substringData
DOMString substringData(const unsigned long offset, const unsigned long count)
Extracts a range of data from the node.
Definition: dom_text.cpp:90
DOM::CharacterData::operator=
CharacterData & operator=(const Node &other)
Definition: dom_text.cpp:38
DOM::CharacterData::setData
void setData(const DOMString &)
see data
Definition: dom_text.cpp:71
DOM::CharacterData::replaceData
void replaceData(const unsigned long offset, const unsigned long count, const DOMString &arg)
Replace the characters starting at the specified character offset with the specified string.
Definition: dom_text.cpp:135
DOM::CharacterData::data
DOMString data() const
The character data of the node that implements this interface.
Definition: dom_text.cpp:65
DOM::CharacterData::insertData
void insertData(const unsigned long offset, const DOMString &arg)
Insert a string at the specified character offset.
Definition: dom_text.cpp:113
DOM::CharacterData::CharacterData
CharacterData()
Definition: dom_text.cpp:30
DOM::CharacterData::~CharacterData
~CharacterData()
Definition: dom_text.cpp:61
DOM::CharacterData::length
unsigned long length() const
The number of characters that are available through data and the substringData method below.
Definition: dom_text.cpp:83
DOM::Comment
This represents the content of a comment, i.e., all the characters between the starting ' <!...
Definition: dom_text.h:224
DOM::Comment::Comment
Comment()
Definition: dom_text.cpp:152
DOM::Comment::operator=
Comment & operator=(const Node &other)
Definition: dom_text.cpp:160
DOM::Comment::~Comment
~Comment()
Definition: dom_text.cpp:180
DOM::DOMException
DOM operations only raise exceptions in "exceptional" circumstances, i.e., when an operation is impos...
Definition: dom_exception.h:59
DOM::DOMString
This class implements the basic string we use in the DOM.
Definition: dom_string.h:44
DOM::Node
The Node interface is the primary datatype for the entire Document Object Model.
Definition: dom_node.h:271
DOM::Node::handle
NodeImpl * handle() const
Definition: dom_node.h:925
DOM::Node::operator=
Node & operator=(const Node &other)
Definition: dom_node.cpp:145
DOM::Node::COMMENT_NODE
@ COMMENT_NODE
Definition: dom_node.h:389
DOM::Node::CDATA_SECTION_NODE
@ CDATA_SECTION_NODE
Definition: dom_node.h:385
DOM::Node::TEXT_NODE
@ TEXT_NODE
Definition: dom_node.h:384
DOM::Node::impl
NodeImpl * impl
Definition: dom_node.h:948
DOM::Text
The Text interface represents the textual content (termed character data in XML) of an Element or At...
Definition: dom_text.h:270
DOM::Text::~Text
~Text()
Definition: dom_text.cpp:220
DOM::Text::splitText
Text splitText(const unsigned long offset)
Breaks this Text node into two Text nodes at the specified offset, keeping both in the tree as siblin...
Definition: dom_text.cpp:224
DOM::Text::TextImpl
friend class TextImpl
Definition: dom_text.h:272
DOM::Text::Text
Text()
Definition: dom_text.cpp:190
DOM::Text::operator=
Text & operator=(const Node &other)
Definition: dom_text.cpp:198
dom_exception.h
dom_text.h
DOM
This library provides a full-featured HTML parser and widget.
Definition: design.h:55
This file is part of the KDE documentation.
Documentation copyright © 1996-2023 The KDE developers.
Generated on Mon Feb 20 2023 00:00:00 by doxygen 1.9.6 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.

KHTML

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

kdelibs-4.14.38 API Reference

Skip menu "kdelibs-4.14.38 API Reference"
  • DNSSD
  • Interfaces
  •   KHexEdit
  •   KMediaPlayer
  •   KSpeech
  •   KTextEditor
  • kconf_update
  • KDE3Support
  •   KUnitTest
  • KDECore
  • KDED
  • KDEsu
  • KDEUI
  • KDEWebKit
  • KDocTools
  • KFile
  • KHTML
  • KImgIO
  • KInit
  • kio
  • KIOSlave
  • KJS
  •   KJS-API
  •   WTF
  • kjsembed
  • KNewStuff
  • KParts
  • KPty
  • Kross
  • KUnitConversion
  • KUtils
  • Nepomuk
  • Plasma
  • Solid
  • Sonnet
  • ThreadWeaver
Report problems with this website to our bug tracking system.
Contact the specific authors with questions and comments about the page contents.

KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal