dom_text.cpp
#include "dom/dom_exception.h"
#include "dom/dom_text.h"
#include "xml/dom_textimpl.h"
using namespace DOM;
CharacterData::CharacterData() : Node()
{
}
CharacterData::CharacterData(const CharacterData &other) : Node(other)
{
}
CharacterData &CharacterData::operator = (const Node &other)
{
NodeImpl* ohandle = other.handle();
if ( impl != ohandle ) {
if (!ohandle ||
( ohandle->nodeType() != CDATA_SECTION_NODE &&
ohandle->nodeType() != TEXT_NODE &&
ohandle->nodeType() != COMMENT_NODE )) {
if ( impl ) impl->deref();
impl = 0;
} else {
Node::operator =(other);
}
}
return *this;
}
CharacterData &CharacterData::operator = (const CharacterData &other)
{
Node::operator =(other);
return *this;
}
CharacterData::~CharacterData()
{
}
DOMString CharacterData::data() const
{
if(!impl) return DOMString();
return ((CharacterDataImpl *)impl)->data();
}
void CharacterData::setData( const DOMString &str )
{
if (!impl)
return; // ### enable throw DOMException(DOMException::NOT_FOUND_ERR);
int exceptioncode = 0;
((CharacterDataImpl *)impl)->setData(str, exceptioncode);
if ( exceptioncode )
throw DOMException( exceptioncode );
return;
}
unsigned long CharacterData::length() const
{
if ( impl )
return ((CharacterDataImpl *)impl)->length();
return 0;
}
DOMString CharacterData::substringData( const unsigned long offset, const unsigned long count )
{
if (!impl)
return DOMString(); // ### enable throw DOMException(DOMException::NOT_FOUND_ERR);
int exceptioncode = 0;
DOMString str = ((CharacterDataImpl *)impl)->substringData(offset, count, exceptioncode);
if ( exceptioncode )
throw DOMException( exceptioncode );
return str;
}
void CharacterData::appendData( const DOMString &arg )
{
if (!impl)
return; // ### enable throw DOMException(DOMException::NOT_FOUND_ERR);
int exceptioncode = 0;
((CharacterDataImpl *)impl)->appendData(arg, exceptioncode);
if ( exceptioncode )
throw DOMException( exceptioncode );
}
void CharacterData::insertData( const unsigned long offset, const DOMString &arg )
{
if (!impl)
return; // ### enable throw DOMException(DOMException::NOT_FOUND_ERR);
int exceptioncode = 0;
((CharacterDataImpl *)impl)->insertData(offset, arg, exceptioncode);
if ( exceptioncode )
throw DOMException( exceptioncode );
}
void CharacterData::deleteData( const unsigned long offset, const unsigned long count )
{
if (!impl)
return; // ### enable throw DOMException(DOMException::NOT_FOUND_ERR);
int exceptioncode = 0;
((CharacterDataImpl *)impl)->deleteData(offset, count, exceptioncode);
if ( exceptioncode )
throw DOMException( exceptioncode );
}
void CharacterData::replaceData( const unsigned long offset, const unsigned long count, const DOMString &arg )
{
if (!impl)
return; // ### enable throw DOMException(DOMException::NOT_FOUND_ERR);
int exceptioncode = 0;
((CharacterDataImpl *)impl)->replaceData(offset, count, arg, exceptioncode);
if ( exceptioncode )
throw DOMException( exceptioncode );
}
CharacterData::CharacterData(CharacterDataImpl *i) : Node(i)
{
}
// ---------------------------------------------------------------------------
Comment::Comment() : CharacterData()
{
}
Comment::Comment(const Comment &other) : CharacterData(other)
{
}
Comment &Comment::operator = (const Node &other)
{
NodeImpl* ohandle = other.handle();
if ( impl != ohandle ) {
if (!ohandle || ohandle->nodeType() != COMMENT_NODE) {
if ( impl ) impl->deref();
impl = 0;
} else {
Node::operator =(other);
}
}
return *this;
}
Comment &Comment::operator = (const Comment &other)
{
CharacterData::operator =(other);
return *this;
}
Comment::~Comment()
{
}
Comment::Comment(CommentImpl *i) : CharacterData(i)
{
}
// ----------------------------------------------------------------------------
Text::Text()
{
}
Text::Text(const Text &other) : CharacterData(other)
{
}
Text &Text::operator = (const Node &other)
{
NodeImpl* ohandle = other.handle();
if ( impl != ohandle ) {
if (!ohandle ||
(ohandle->nodeType() != TEXT_NODE &&
ohandle->nodeType() != CDATA_SECTION_NODE)) {
if ( impl ) impl->deref();
impl = 0;
} else {
Node::operator =(other);
}
}
return *this;
}
Text &Text::operator = (const Text &other)
{
Node::operator =(other);
return *this;
}
Text::~Text()
{
}
Text Text::splitText( const unsigned long offset )
{
if (!impl)
return 0; // ### enable throw DOMException(DOMException::NOT_FOUND_ERR);
int exceptioncode = 0;
TextImpl *newText = static_cast<TextImpl *>(impl)->splitText(offset, exceptioncode );
if ( exceptioncode )
throw DOMException( exceptioncode );
return newText;
}
Text::Text(TextImpl *i) : CharacterData(i)
{
}
DOM::Node
The Node interface is the primary datatype for the entire Document Object Model.
Definition: dom_node.h:274
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:82
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:134
DOM::DOMException
DOM operations only raise exceptions in "exceptional" circumstances, i.e., when an operation is impos...
Definition: dom_exception.h:57
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:89
DOM::Comment
This represents the content of a comment, i.e., all the characters between the starting '
Definition: dom_text.h:223
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:101
DOM::DOMString
This class implements the basic string we use in the DOM.
Definition: dom_string.h:43
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:123
DOM::CharacterData::data
DOMString data() const
The character data of the node that implements this interface.
Definition: dom_text.cpp:64
DOM::CharacterData::setData
void setData(const DOMString &)
see data NO_MODIFICATION_ALLOWED_ERR: Raised when the node is readonly.
Definition: dom_text.cpp:70
DOM::CharacterData::insertData
void insertData(const unsigned long offset, const DOMString &arg)
Insert a string at the specified character offset.
Definition: dom_text.cpp:112
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:223
DOM::CharacterData
The CharacterData interface extends Node with a set of attributes and methods for accessing character...
Definition: dom_text.h:49

KDE Home | KDE Accessibility Home | Description of Access Keys