1 /************************************************************** 2 * 3 * Licensed to the Apache Software Foundation (ASF) under one 4 * or more contributor license agreements. See the NOTICE file 5 * distributed with this work for additional information 6 * regarding copyright ownership. The ASF licenses this file 7 * to you under the Apache License, Version 2.0 (the 8 * "License"); you may not use this file except in compliance 9 * with the License. You may obtain a copy of the License at 10 * 11 * http://www.apache.org/licenses/LICENSE-2.0 12 * 13 * Unless required by applicable law or agreed to in writing, 14 * software distributed under the License is distributed on an 15 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16 * KIND, either express or implied. See the License for the 17 * specific language governing permissions and limitations 18 * under the License. 19 * 20 *************************************************************/ 21 22 23 24 #ifndef DOM_CHARACTERDATA_HXX 25 #define DOM_CHARACTERDATA_HXX 26 27 #include <libxml/tree.h> 28 29 #include <sal/types.h> 30 31 #include <cppuhelper/implbase1.hxx> 32 33 #include <com/sun/star/uno/Reference.h> 34 #include <com/sun/star/xml/dom/XNode.hpp> 35 #include <com/sun/star/xml/dom/XCharacterData.hpp> 36 37 #include <node.hxx> 38 39 40 using ::rtl::OUString; 41 using namespace com::sun::star::uno; 42 using namespace com::sun::star::xml::dom; 43 44 namespace DOM 45 { 46 typedef ::cppu::ImplInheritanceHelper1< CNode, XCharacterData > 47 CCharacterData_Base; 48 49 class CCharacterData 50 : public CCharacterData_Base 51 { 52 53 protected: 54 CCharacterData(CDocument const& rDocument, ::osl::Mutex const& rMutex, 55 NodeType const& reNodeType, xmlNodePtr const& rpNode); 56 57 void dispatchEvent_Impl( 58 OUString const& prevValue, OUString const& newValue); 59 60 public: 61 /** 62 Append the string to the end of the character data of the node. 63 */ 64 virtual void SAL_CALL appendData(const OUString& arg); 65 66 /** 67 Remove a range of 16-bit units from the node. 68 */ 69 virtual void SAL_CALL deleteData(sal_Int32 offset, sal_Int32 count); 70 71 /** 72 Return the character data of the node that implements this interface. 73 */ 74 virtual OUString SAL_CALL getData(); 75 76 /** 77 The number of 16-bit units that are available through data and the 78 substringData method below. 79 */ 80 virtual sal_Int32 SAL_CALL getLength(); 81 82 /** 83 Insert a string at the specified 16-bit unit offset. 84 */ 85 virtual void SAL_CALL insertData(sal_Int32 offset, const OUString& arg); 86 87 /** 88 Replace the characters starting at the specified 16-bit unit offset 89 with the specified string. 90 */ 91 virtual void SAL_CALL replaceData(sal_Int32 offset, sal_Int32 count, const OUString& arg); 92 93 /** 94 Set the character data of the node that implements this interface. 95 */ 96 virtual void SAL_CALL setData(const OUString& data); 97 98 /** 99 Extracts a range of data from the node. 100 */ 101 virtual OUString SAL_CALL subStringData(sal_Int32 offset, sal_Int32 count); 102 103 // --- delegation for XNode base. appendChild(const Reference<XNode> & newChild)104 virtual Reference< XNode > SAL_CALL appendChild(const Reference< XNode >& newChild) 105 { 106 return CNode::appendChild(newChild); 107 } cloneNode(sal_Bool deep)108 virtual Reference< XNode > SAL_CALL cloneNode(sal_Bool deep) 109 { 110 return CNode::cloneNode(deep); 111 } getAttributes()112 virtual Reference< XNamedNodeMap > SAL_CALL getAttributes() 113 { 114 return CNode::getAttributes(); 115 } getChildNodes()116 virtual Reference< XNodeList > SAL_CALL getChildNodes() 117 { 118 return CNode::getChildNodes(); 119 } getFirstChild()120 virtual Reference< XNode > SAL_CALL getFirstChild() 121 { 122 return CNode::getFirstChild(); 123 } getLastChild()124 virtual Reference< XNode > SAL_CALL getLastChild() 125 { 126 return CNode::getLastChild(); 127 } getLocalName()128 virtual OUString SAL_CALL getLocalName() 129 { 130 return CNode::getLocalName(); 131 } getNamespaceURI()132 virtual OUString SAL_CALL getNamespaceURI() 133 { 134 return CNode::getNamespaceURI(); 135 } getNextSibling()136 virtual Reference< XNode > SAL_CALL getNextSibling() 137 { 138 return CNode::getNextSibling(); 139 } getNodeName()140 virtual OUString SAL_CALL getNodeName() 141 { 142 return CNode::getNodeName(); 143 } getNodeType()144 virtual NodeType SAL_CALL getNodeType() 145 { 146 return CNode::getNodeType(); 147 } getNodeValue()148 virtual OUString SAL_CALL getNodeValue() 149 { 150 return getData(); 151 } getOwnerDocument()152 virtual Reference< XDocument > SAL_CALL getOwnerDocument() 153 { 154 return CNode::getOwnerDocument(); 155 } getParentNode()156 virtual Reference< XNode > SAL_CALL getParentNode() 157 { 158 return CNode::getParentNode(); 159 } getPrefix()160 virtual OUString SAL_CALL getPrefix() 161 { 162 return CNode::getPrefix(); 163 } getPreviousSibling()164 virtual Reference< XNode > SAL_CALL getPreviousSibling() 165 { 166 return CNode::getPreviousSibling(); 167 } hasAttributes()168 virtual sal_Bool SAL_CALL hasAttributes() 169 { 170 return CNode::hasAttributes(); 171 } hasChildNodes()172 virtual sal_Bool SAL_CALL hasChildNodes() 173 { 174 return CNode::hasChildNodes(); 175 } insertBefore(const Reference<XNode> & newChild,const Reference<XNode> & refChild)176 virtual Reference< XNode > SAL_CALL insertBefore( 177 const Reference< XNode >& newChild, const Reference< XNode >& refChild) 178 { 179 return CNode::insertBefore(newChild, refChild); 180 } isSupported(const OUString & feature,const OUString & ver)181 virtual sal_Bool SAL_CALL isSupported(const OUString& feature, const OUString& ver) 182 { 183 return CNode::isSupported(feature, ver); 184 } normalize()185 virtual void SAL_CALL normalize() 186 { 187 CNode::normalize(); 188 } removeChild(const Reference<XNode> & oldChild)189 virtual Reference< XNode > SAL_CALL removeChild(const Reference< XNode >& oldChild) 190 { 191 return CNode::removeChild(oldChild); 192 } replaceChild(const Reference<XNode> & newChild,const Reference<XNode> & oldChild)193 virtual Reference< XNode > SAL_CALL replaceChild( 194 const Reference< XNode >& newChild, const Reference< XNode >& oldChild) 195 { 196 return CNode::replaceChild(newChild, oldChild); 197 } setNodeValue(const OUString & nodeValue)198 virtual void SAL_CALL setNodeValue(const OUString& nodeValue) 199 { 200 return setData(nodeValue); 201 } setPrefix(const OUString & prefix)202 virtual void SAL_CALL setPrefix(const OUString& prefix) 203 { 204 return CNode::setPrefix(prefix); 205 } 206 207 208 }; 209 } 210 211 #endif 212