1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: text.hxx,v $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
34 #include <sal/types.h>
35 #include <cppuhelper/implbase1.hxx>
36 #include <com/sun/star/uno/Reference.h>
37 #include <com/sun/star/uno/Exception.hpp>
38 #include <com/sun/star/xml/dom/XNode.hpp>
39 #include <com/sun/star/xml/dom/XText.hpp>
40 #include <com/sun/star/xml/dom/XCharacterData.hpp>
41 #include <libxml/tree.h>
42 #include "characterdata.hxx"
44 using ::rtl::OUString
;
45 using namespace com::sun::star::uno
;
46 using namespace com::sun::star::lang
;
47 using namespace com::sun::star::xml::dom
;
51 class CText
: public cppu::ImplInheritanceHelper1
< CCharacterData
, XText
>
57 CText(const xmlNodePtr aNodePtr
);
58 void init_text(const xmlNodePtr aNodePtr
);
62 virtual void SAL_CALL
saxify(
63 const Reference
< XDocumentHandler
>& i_xHandler
);
65 virtual void SAL_CALL
fastSaxify( Context
& io_rContext
);
67 // Breaks this node into two nodes at the specified offset, keeping
68 // both in the tree as siblings.
69 virtual Reference
< XText
> SAL_CALL
splitText(sal_Int32 offset
)
70 throw (RuntimeException
);
73 // --- delegations for XCharacterData
74 virtual void SAL_CALL
appendData(const OUString
& arg
)
75 throw (RuntimeException
, DOMException
)
77 CCharacterData::appendData(arg
);
79 virtual void SAL_CALL
deleteData(sal_Int32 offset
, sal_Int32 count
)
80 throw (RuntimeException
, DOMException
)
82 CCharacterData::deleteData(offset
, count
);
84 virtual OUString SAL_CALL
getData() throw (RuntimeException
)
86 return CCharacterData::getData();
88 virtual sal_Int32 SAL_CALL
getLength() throw (RuntimeException
)
90 return CCharacterData::getLength();
92 virtual void SAL_CALL
insertData(sal_Int32 offset
, const OUString
& arg
)
93 throw (RuntimeException
, DOMException
)
95 CCharacterData::insertData(offset
, arg
);
97 virtual void SAL_CALL
replaceData(sal_Int32 offset
, sal_Int32 count
, const OUString
& arg
)
98 throw (RuntimeException
, DOMException
)
100 CCharacterData::replaceData(offset
, count
, arg
);
102 virtual void SAL_CALL
setData(const OUString
& data
)
103 throw (RuntimeException
, DOMException
)
105 CCharacterData::setData(data
);
107 virtual OUString SAL_CALL
subStringData(sal_Int32 offset
, sal_Int32 count
)
108 throw (RuntimeException
, DOMException
)
110 return CCharacterData::subStringData(offset
, count
);
114 // --- overrides for XNode base
115 virtual OUString SAL_CALL
getNodeName()
116 throw (RuntimeException
);
118 // --- resolve uno inheritance problems...
119 // --- delegation for XNde base.
120 virtual Reference
< XNode
> SAL_CALL
appendChild(const Reference
< XNode
>& newChild
)
121 throw (RuntimeException
, DOMException
)
123 return CCharacterData::appendChild(newChild
);
125 virtual Reference
< XNode
> SAL_CALL
cloneNode(sal_Bool deep
)
126 throw (RuntimeException
)
128 return CCharacterData::cloneNode(deep
);
130 virtual Reference
< XNamedNodeMap
> SAL_CALL
getAttributes()
131 throw (RuntimeException
)
133 return CCharacterData::getAttributes();
135 virtual Reference
< XNodeList
> SAL_CALL
getChildNodes()
136 throw (RuntimeException
)
138 return CCharacterData::getChildNodes();
140 virtual Reference
< XNode
> SAL_CALL
getFirstChild()
141 throw (RuntimeException
)
143 return CCharacterData::getFirstChild();
145 virtual Reference
< XNode
> SAL_CALL
getLastChild()
146 throw (RuntimeException
)
148 return CCharacterData::getLastChild();
150 virtual OUString SAL_CALL
getLocalName()
151 throw (RuntimeException
)
153 return CCharacterData::getLocalName();
155 virtual OUString SAL_CALL
getNamespaceURI()
156 throw (RuntimeException
)
158 return CCharacterData::getNamespaceURI();
160 virtual Reference
< XNode
> SAL_CALL
getNextSibling()
161 throw (RuntimeException
)
163 return CCharacterData::getNextSibling();
165 virtual NodeType SAL_CALL
getNodeType()
166 throw (RuntimeException
)
168 return CCharacterData::getNodeType();
170 virtual OUString SAL_CALL
getNodeValue() throw (RuntimeException
)
172 return CCharacterData::getNodeValue();
174 virtual Reference
< XDocument
> SAL_CALL
getOwnerDocument()
175 throw (RuntimeException
)
177 return CCharacterData::getOwnerDocument();
179 virtual Reference
< XNode
> SAL_CALL
getParentNode()
180 throw (RuntimeException
)
182 return CCharacterData::getParentNode();
184 virtual OUString SAL_CALL
getPrefix()
185 throw (RuntimeException
)
187 return CCharacterData::getPrefix();
189 virtual Reference
< XNode
> SAL_CALL
getPreviousSibling()
190 throw (RuntimeException
)
192 return CCharacterData::getPreviousSibling();
194 virtual sal_Bool SAL_CALL
hasAttributes()
195 throw (RuntimeException
)
197 return CCharacterData::hasAttributes();
199 virtual sal_Bool SAL_CALL
hasChildNodes()
200 throw (RuntimeException
)
202 return CCharacterData::hasChildNodes();
204 virtual Reference
< XNode
> SAL_CALL
insertBefore(
205 const Reference
< XNode
>& newChild
, const Reference
< XNode
>& refChild
)
206 throw (RuntimeException
, DOMException
)
208 return CCharacterData::insertBefore(newChild
, refChild
);
210 virtual sal_Bool SAL_CALL
isSupported(const OUString
& feature
, const OUString
& ver
)
211 throw (RuntimeException
)
213 return CCharacterData::isSupported(feature
, ver
);
215 virtual void SAL_CALL
normalize()
216 throw (RuntimeException
)
218 CCharacterData::normalize();
220 virtual Reference
< XNode
> SAL_CALL
removeChild(const Reference
< XNode
>& oldChild
)
221 throw (RuntimeException
, DOMException
)
223 return CCharacterData::removeChild(oldChild
);
225 virtual Reference
< XNode
> SAL_CALL
replaceChild(
226 const Reference
< XNode
>& newChild
, const Reference
< XNode
>& oldChild
)
227 throw (RuntimeException
, DOMException
)
229 return CCharacterData::replaceChild(newChild
, oldChild
);
231 virtual void SAL_CALL
setNodeValue(const OUString
& nodeValue
)
232 throw (RuntimeException
, DOMException
)
234 return CCharacterData::setNodeValue(nodeValue
);
236 virtual void SAL_CALL
setPrefix(const OUString
& prefix
)
237 throw (RuntimeException
, DOMException
)
239 return CCharacterData::setPrefix(prefix
);