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

KHTML

  • sources
  • kde-4.12
  • kdelibs
  • 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 
28 using namespace DOM;
29 
30 CharacterData::CharacterData() : Node()
31 {
32 }
33 
34 CharacterData::CharacterData(const CharacterData &other) : Node(other)
35 {
36 }
37 
38 CharacterData &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 
55 CharacterData &CharacterData::operator = (const CharacterData &other)
56 {
57  Node::operator =(other);
58  return *this;
59 }
60 
61 CharacterData::~CharacterData()
62 {
63 }
64 
65 DOMString CharacterData::data() const
66 {
67  if(!impl) return DOMString();
68  return ((CharacterDataImpl *)impl)->data();
69 }
70 
71 void 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 
83 unsigned long CharacterData::length() const
84 {
85  if ( impl )
86  return ((CharacterDataImpl *)impl)->length();
87  return 0;
88 }
89 
90 DOMString 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 
102 void 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 
113 void 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 
124 void 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 
135 void 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 
146 CharacterData::CharacterData(CharacterDataImpl *i) : Node(i)
147 {
148 }
149 
150 // ---------------------------------------------------------------------------
151 
152 Comment::Comment() : CharacterData()
153 {
154 }
155 
156 Comment::Comment(const Comment &other) : CharacterData(other)
157 {
158 }
159 
160 Comment &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 
174 Comment &Comment::operator = (const Comment &other)
175 {
176  CharacterData::operator =(other);
177  return *this;
178 }
179 
180 Comment::~Comment()
181 {
182 }
183 
184 Comment::Comment(CommentImpl *i) : CharacterData(i)
185 {
186 }
187 
188 // ----------------------------------------------------------------------------
189 
190 Text::Text()
191 {
192 }
193 
194 Text::Text(const Text &other) : CharacterData(other)
195 {
196 }
197 
198 Text &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 
214 Text &Text::operator = (const Text &other)
215 {
216  Node::operator =(other);
217  return *this;
218 }
219 
220 Text::~Text()
221 {
222 }
223 
224 Text 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 
236 Text::Text(TextImpl *i) : CharacterData(i)
237 {
238 }
DOM::Comment::Comment
Comment()
Definition: dom_text.cpp:152
DOM::Comment::~Comment
~Comment()
Definition: dom_text.cpp:180
DOM::Node
The Node interface is the primary datatype for the entire Document Object Model.
Definition: dom_node.h:270
DOM::Text::~Text
~Text()
Definition: dom_text.cpp:220
DOM::CharacterData::operator=
CharacterData & operator=(const Node &other)
Definition: dom_text.cpp:38
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::Node::operator=
Node & operator=(const Node &other)
Definition: dom_node.cpp:145
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::DOMException
DOM operations only raise exceptions in "exceptional" circumstances, i.e., when an operation is impos...
Definition: dom_exception.h:58
DOM::CharacterData::CharacterData
CharacterData()
Definition: dom_text.cpp:30
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::Node::CDATA_SECTION_NODE
Definition: dom_node.h:385
DOM::Comment
This represents the content of a comment, i.e., all the characters between the starting '
Definition: dom_text.h:223
DOM::Comment::operator=
Comment & operator=(const Node &other)
Definition: dom_text.cpp:160
DOM::Text
The Text interface represents the textual content (termed character data in XML) of an Element or At...
Definition: dom_text.h:269
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::~CharacterData
~CharacterData()
Definition: dom_text.cpp:61
DOM::DOMString
This class implements the basic string we use in the DOM.
Definition: dom_string.h:43
dom_exception.h
DOM::Text::operator=
Text & operator=(const Node &other)
Definition: dom_text.cpp:198
DOM::Text::Text
Text()
Definition: dom_text.cpp:190
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_text.h
DOM::Node::impl
NodeImpl * impl
Definition: dom_node.h:948
DOM::CharacterData::CharacterDataImpl
friend class CharacterDataImpl
Definition: dom_text.h:51
DOM::Text::TextImpl
friend class TextImpl
Definition: dom_text.h:272
DOM::CharacterData::data
DOMString data() const
The character data of the node that implements this interface.
Definition: dom_text.cpp:65
DOM::CharacterData::setData
void setData(const DOMString &)
see data NO_MODIFICATION_ALLOWED_ERR: Raised when the node is readonly.
Definition: dom_text.cpp:71
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::Node::TEXT_NODE
Definition: dom_node.h:384
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::Node::handle
NodeImpl * handle() const
Definition: dom_node.h:925
DOM::Node::COMMENT_NODE
Definition: dom_node.h:389
DOM::CharacterData
The CharacterData interface extends Node with a set of attributes and methods for accessing character...
Definition: dom_text.h:49
This file is part of the KDE documentation.
Documentation copyright © 1996-2014 The KDE developers.
Generated on Tue Oct 14 2014 22:51:20 by doxygen 1.8.7 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 API Reference

Skip menu "kdelibs 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
  • kjsembed
  •   WTF
  • KNewStuff
  • KParts
  • KPty
  • Kross
  • KUnitConversion
  • KUtils
  • Nepomuk
  • Nepomuk-Core
  • Nepomuk
  • Plasma
  • Solid
  • Sonnet
  • ThreadWeaver

Search



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