KHTML
dom_text.cpp
Go to the documentation of this file.00001
00023 #include "dom/dom_exception.h"
00024 #include "dom/dom_text.h"
00025 #include "xml/dom_textimpl.h"
00026
00027 using namespace DOM;
00028
00029 CharacterData::CharacterData() : Node()
00030 {
00031 }
00032
00033 CharacterData::CharacterData(const CharacterData &other) : Node(other)
00034 {
00035 }
00036
00037 CharacterData &CharacterData::operator = (const Node &other)
00038 {
00039 NodeImpl* ohandle = other.handle();
00040 if ( impl != ohandle ) {
00041 if (!ohandle ||
00042 ( ohandle->nodeType() != CDATA_SECTION_NODE &&
00043 ohandle->nodeType() != TEXT_NODE &&
00044 ohandle->nodeType() != COMMENT_NODE )) {
00045 if ( impl ) impl->deref();
00046 impl = 0;
00047 } else {
00048 Node::operator =(other);
00049 }
00050 }
00051 return *this;
00052 }
00053
00054 CharacterData &CharacterData::operator = (const CharacterData &other)
00055 {
00056 Node::operator =(other);
00057 return *this;
00058 }
00059
00060 CharacterData::~CharacterData()
00061 {
00062 }
00063
00064 DOMString CharacterData::data() const
00065 {
00066 if(!impl) return DOMString();
00067 return ((CharacterDataImpl *)impl)->data();
00068 }
00069
00070 void CharacterData::setData( const DOMString &str )
00071 {
00072 if (!impl)
00073 return;
00074
00075 int exceptioncode = 0;
00076 ((CharacterDataImpl *)impl)->setData(str, exceptioncode);
00077 if ( exceptioncode )
00078 throw DOMException( exceptioncode );
00079 return;
00080 }
00081
00082 unsigned long CharacterData::length() const
00083 {
00084 if ( impl )
00085 return ((CharacterDataImpl *)impl)->length();
00086 return 0;
00087 }
00088
00089 DOMString CharacterData::substringData( const unsigned long offset, const unsigned long count )
00090 {
00091 if (!impl)
00092 return DOMString();
00093
00094 int exceptioncode = 0;
00095 DOMString str = ((CharacterDataImpl *)impl)->substringData(offset, count, exceptioncode);
00096 if ( exceptioncode )
00097 throw DOMException( exceptioncode );
00098 return str;
00099 }
00100
00101 void CharacterData::appendData( const DOMString &arg )
00102 {
00103 if (!impl)
00104 return;
00105
00106 int exceptioncode = 0;
00107 ((CharacterDataImpl *)impl)->appendData(arg, exceptioncode);
00108 if ( exceptioncode )
00109 throw DOMException( exceptioncode );
00110 }
00111
00112 void CharacterData::insertData( const unsigned long offset, const DOMString &arg )
00113 {
00114 if (!impl)
00115 return;
00116
00117 int exceptioncode = 0;
00118 ((CharacterDataImpl *)impl)->insertData(offset, arg, exceptioncode);
00119 if ( exceptioncode )
00120 throw DOMException( exceptioncode );
00121 }
00122
00123 void CharacterData::deleteData( const unsigned long offset, const unsigned long count )
00124 {
00125 if (!impl)
00126 return;
00127
00128 int exceptioncode = 0;
00129 ((CharacterDataImpl *)impl)->deleteData(offset, count, exceptioncode);
00130 if ( exceptioncode )
00131 throw DOMException( exceptioncode );
00132 }
00133
00134 void CharacterData::replaceData( const unsigned long offset, const unsigned long count, const DOMString &arg )
00135 {
00136 if (!impl)
00137 return;
00138
00139 int exceptioncode = 0;
00140 ((CharacterDataImpl *)impl)->replaceData(offset, count, arg, exceptioncode);
00141 if ( exceptioncode )
00142 throw DOMException( exceptioncode );
00143 }
00144
00145 CharacterData::CharacterData(CharacterDataImpl *i) : Node(i)
00146 {
00147 }
00148
00149
00150
00151 Comment::Comment() : CharacterData()
00152 {
00153 }
00154
00155 Comment::Comment(const Comment &other) : CharacterData(other)
00156 {
00157 }
00158
00159 Comment &Comment::operator = (const Node &other)
00160 {
00161 NodeImpl* ohandle = other.handle();
00162 if ( impl != ohandle ) {
00163 if (!ohandle || ohandle->nodeType() != COMMENT_NODE) {
00164 if ( impl ) impl->deref();
00165 impl = 0;
00166 } else {
00167 Node::operator =(other);
00168 }
00169 }
00170 return *this;
00171 }
00172
00173 Comment &Comment::operator = (const Comment &other)
00174 {
00175 CharacterData::operator =(other);
00176 return *this;
00177 }
00178
00179 Comment::~Comment()
00180 {
00181 }
00182
00183 Comment::Comment(CommentImpl *i) : CharacterData(i)
00184 {
00185 }
00186
00187
00188
00189 Text::Text()
00190 {
00191 }
00192
00193 Text::Text(const Text &other) : CharacterData(other)
00194 {
00195 }
00196
00197 Text &Text::operator = (const Node &other)
00198 {
00199 NodeImpl* ohandle = other.handle();
00200 if ( impl != ohandle ) {
00201 if (!ohandle ||
00202 (ohandle->nodeType() != TEXT_NODE &&
00203 ohandle->nodeType() != CDATA_SECTION_NODE)) {
00204 if ( impl ) impl->deref();
00205 impl = 0;
00206 } else {
00207 Node::operator =(other);
00208 }
00209 }
00210 return *this;
00211 }
00212
00213 Text &Text::operator = (const Text &other)
00214 {
00215 Node::operator =(other);
00216 return *this;
00217 }
00218
00219 Text::~Text()
00220 {
00221 }
00222
00223 Text Text::splitText( const unsigned long offset )
00224 {
00225 if (!impl)
00226 return 0;
00227
00228 int exceptioncode = 0;
00229 TextImpl *newText = static_cast<TextImpl *>(impl)->splitText(offset, exceptioncode );
00230 if ( exceptioncode )
00231 throw DOMException( exceptioncode );
00232 return newText;
00233 }
00234
00235 Text::Text(TextImpl *i) : CharacterData(i)
00236 {
00237 }