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