1//
2// Text.cpp
3//
4// Library: XML
5// Package: DOM
6// Module: DOM
7//
8// Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH.
9// and Contributors.
10//
11// SPDX-License-Identifier: BSL-1.0
12//
13
14
15#include "Poco/DOM/Text.h"
16#include "Poco/DOM/Document.h"
17#include "Poco/DOM/DOMException.h"
18
19
20namespace Poco {
21namespace XML {
22
23
24const XMLString Text::NODE_NAME = toXMLString("#text");
25
26
27Text::Text(Document* pOwnerDocument, const XMLString& data):
28 CharacterData(pOwnerDocument, data)
29{
30}
31
32
33Text::Text(Document* pOwnerDocument, const Text& text):
34 CharacterData(pOwnerDocument, text)
35{
36}
37
38
39Text::~Text()
40{
41}
42
43
44Text* Text::splitText(unsigned long offset)
45{
46 Node* pParent = parentNode();
47 if (!pParent) throw DOMException(DOMException::HIERARCHY_REQUEST_ERR);
48 int n = length() - offset;
49 Text* pNew = ownerDocument()->createTextNode(substringData(offset, n));
50 deleteData(offset, n);
51 pParent->insertBefore(pNew, nextSibling())->release();
52 return pNew;
53}
54
55
56const XMLString& Text::nodeName() const
57{
58 return NODE_NAME;
59}
60
61
62unsigned short Text::nodeType() const
63{
64 return Node::TEXT_NODE;
65}
66
67
68XMLString Text::innerText() const
69{
70 return nodeValue();
71}
72
73
74Node* Text::copyNode(bool /*deep*/, Document* pOwnerDocument) const
75{
76 return new Text(pOwnerDocument, *this);
77}
78
79
80} } // namespace Poco::XML
81