1 /************************************************************************* 2 * 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 * 5 * Copyright 2000, 2010 Oracle and/or its affiliates. 6 * 7 * OpenOffice.org - a multi-platform office productivity suite 8 * 9 * This file is part of OpenOffice.org. 10 * 11 * OpenOffice.org is free software: you can redistribute it and/or modify 12 * it under the terms of the GNU Lesser General Public License version 3 13 * only, as published by the Free Software Foundation. 14 * 15 * OpenOffice.org is distributed in the hope that it will be useful, 16 * but WITHOUT ANY WARRANTY; without even the implied warranty of 17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18 * GNU Lesser General Public License version 3 for more details 19 * (a copy is included in the LICENSE file that accompanied this code). 20 * 21 * You should have received a copy of the GNU Lesser General Public License 22 * version 3 along with OpenOffice.org. If not, see 23 * <http://www.openoffice.org/license.html> 24 * for a copy of the LGPLv3 License. 25 * 26 ************************************************************************/ 27 28 #ifndef DOM_ELEMENT_HXX 29 #define DOM_ELEMENT_HXX 30 31 #include <libxml/tree.h> 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/XNodeList.hpp> 36 #include <com/sun/star/xml/dom/XNamedNodeMap.hpp> 37 #include <com/sun/star/xml/dom/NodeType.hpp> 38 39 #include <node.hxx> 40 41 42 using ::rtl::OUString; 43 using namespace com::sun::star::uno; 44 using namespace com::sun::star::xml::dom; 45 46 namespace DOM 47 { 48 typedef ::cppu::ImplInheritanceHelper1<CNode, XElement > CElement_Base; 49 50 class CElement 51 : public CElement_Base 52 { 53 private: 54 friend class CDocument; 55 56 Reference< XAttr > setAttributeNode_Impl_Lock( 57 Reference< XAttr > const& xNewAttr, bool const bNS); 58 59 protected: 60 CElement(CDocument const& rDocument, ::osl::Mutex const& rMutex, 61 xmlNodePtr const pNode); 62 63 public: 64 65 virtual void saxify(const Reference< XDocumentHandler >& i_xHandler); 66 67 virtual void fastSaxify( Context& i_rContext ); 68 69 virtual bool IsChildTypeAllowed(NodeType const nodeType); 70 71 /** 72 Retrieves an attribute value by name. 73 */ 74 virtual OUString SAL_CALL getAttribute(const OUString& name) 75 throw (RuntimeException); 76 77 /** 78 Retrieves an attribute node by name. 79 */ 80 virtual Reference< XAttr > SAL_CALL getAttributeNode(const OUString& name) 81 throw (RuntimeException); 82 83 /** 84 Retrieves an Attr node by local name and namespace URI. 85 */ 86 virtual Reference< XAttr > SAL_CALL getAttributeNodeNS(const OUString& namespaceURI, const OUString& localName) 87 throw (RuntimeException); 88 89 /** 90 Retrieves an attribute value by local name and namespace URI. 91 */ 92 virtual OUString SAL_CALL getAttributeNS(const OUString& namespaceURI, const OUString& localName) 93 throw (RuntimeException); 94 95 /** 96 Returns a NodeList of all descendant Elements with a given tag name, 97 in the order in which they are 98 encountered in a preorder traversal of this Element tree. 99 */ 100 virtual Reference< XNodeList > SAL_CALL getElementsByTagName(const OUString& name) 101 throw (RuntimeException); 102 103 /** 104 Returns a NodeList of all the descendant Elements with a given local 105 name and namespace URI in the order in which they are encountered in 106 a preorder traversal of this Element tree. 107 */ 108 virtual Reference< XNodeList > SAL_CALL getElementsByTagNameNS(const OUString& namespaceURI, 109 const OUString& localName) 110 throw (RuntimeException); 111 112 /** 113 The name of the element. 114 */ 115 virtual OUString SAL_CALL getTagName() 116 throw (RuntimeException); 117 118 /** 119 Returns true when an attribute with a given name is specified on this 120 element or has a default value, false otherwise. 121 */ 122 virtual sal_Bool SAL_CALL hasAttribute(const OUString& name) 123 throw (RuntimeException); 124 125 /** 126 Returns true when an attribute with a given local name and namespace 127 URI is specified on this element or has a default value, false otherwise. 128 */ 129 virtual sal_Bool SAL_CALL hasAttributeNS(const OUString& namespaceURI, const OUString& localName) 130 throw (RuntimeException); 131 132 /** 133 Removes an attribute by name. 134 */ 135 virtual void SAL_CALL removeAttribute(const OUString& name) 136 throw (RuntimeException, DOMException); 137 138 /** 139 Removes the specified attribute node. 140 */ 141 virtual Reference< XAttr > SAL_CALL removeAttributeNode(const Reference< XAttr >& oldAttr) 142 throw (RuntimeException, DOMException); 143 144 /** 145 Removes an attribute by local name and namespace URI. 146 */ 147 virtual void SAL_CALL removeAttributeNS(const OUString& namespaceURI, const OUString& localName) 148 throw (RuntimeException, DOMException); 149 150 /** 151 Adds a new attribute. 152 */ 153 virtual void SAL_CALL setAttribute(const OUString& name, const OUString& value) 154 throw (RuntimeException, DOMException); 155 156 /** 157 Adds a new attribute node. 158 */ 159 virtual Reference< XAttr > SAL_CALL setAttributeNode(const Reference< XAttr >& newAttr) 160 throw (RuntimeException, DOMException); 161 162 /** 163 Adds a new attribute. 164 */ 165 virtual Reference< XAttr > SAL_CALL setAttributeNodeNS(const Reference< XAttr >& newAttr) 166 throw (RuntimeException, DOMException); 167 168 /** 169 Adds a new attribute. 170 */ 171 virtual void SAL_CALL setAttributeNS( 172 const OUString& namespaceURI, const OUString& qualifiedName, const OUString& value) 173 throw (RuntimeException, DOMException); 174 175 /** 176 sets the element name 177 */ 178 virtual void SAL_CALL setElementName(const OUString& elementName) 179 throw (RuntimeException, DOMException); 180 181 // overrides for XNode base 182 virtual OUString SAL_CALL getNodeName() 183 throw (RuntimeException); 184 virtual OUString SAL_CALL getNodeValue() 185 throw (RuntimeException); 186 virtual Reference< XNamedNodeMap > SAL_CALL getAttributes() 187 throw (RuntimeException); 188 virtual OUString SAL_CALL getLocalName() 189 throw (RuntimeException); 190 191 // resolve uno inheritance problems... 192 // --- delegation for XNde base. 193 virtual Reference< XNode > SAL_CALL appendChild(const Reference< XNode >& newChild) 194 throw (RuntimeException, DOMException) 195 { 196 return CNode::appendChild(newChild); 197 } 198 virtual Reference< XNode > SAL_CALL cloneNode(sal_Bool deep) 199 throw (RuntimeException) 200 { 201 return CNode::cloneNode(deep); 202 } 203 virtual Reference< XNodeList > SAL_CALL getChildNodes() 204 throw (RuntimeException) 205 { 206 return CNode::getChildNodes(); 207 } 208 virtual Reference< XNode > SAL_CALL getFirstChild() 209 throw (RuntimeException) 210 { 211 return CNode::getFirstChild(); 212 } 213 virtual Reference< XNode > SAL_CALL getLastChild() 214 throw (RuntimeException) 215 { 216 return CNode::getLastChild(); 217 } 218 virtual OUString SAL_CALL getNamespaceURI() 219 throw (RuntimeException) 220 { 221 return CNode::getNamespaceURI(); 222 } 223 virtual Reference< XNode > SAL_CALL getNextSibling() 224 throw (RuntimeException) 225 { 226 return CNode::getNextSibling(); 227 } 228 virtual NodeType SAL_CALL getNodeType() 229 throw (RuntimeException) 230 { 231 return CNode::getNodeType(); 232 } 233 virtual Reference< XDocument > SAL_CALL getOwnerDocument() 234 throw (RuntimeException) 235 { 236 return CNode::getOwnerDocument(); 237 } 238 virtual Reference< XNode > SAL_CALL getParentNode() 239 throw (RuntimeException) 240 { 241 return CNode::getParentNode(); 242 } 243 virtual OUString SAL_CALL getPrefix() 244 throw (RuntimeException) 245 { 246 return CNode::getPrefix(); 247 } 248 virtual Reference< XNode > SAL_CALL getPreviousSibling() 249 throw (RuntimeException) 250 { 251 return CNode::getPreviousSibling(); 252 } 253 virtual sal_Bool SAL_CALL hasAttributes() 254 throw (RuntimeException) 255 { 256 return CNode::hasAttributes(); 257 } 258 virtual sal_Bool SAL_CALL hasChildNodes() 259 throw (RuntimeException) 260 { 261 return CNode::hasChildNodes(); 262 } 263 virtual Reference< XNode > SAL_CALL insertBefore( 264 const Reference< XNode >& newChild, const Reference< XNode >& refChild) 265 throw (RuntimeException, DOMException) 266 { 267 return CNode::insertBefore(newChild, refChild); 268 } 269 virtual sal_Bool SAL_CALL isSupported(const OUString& feature, const OUString& ver) 270 throw (RuntimeException) 271 { 272 return CNode::isSupported(feature, ver); 273 } 274 virtual void SAL_CALL normalize() 275 throw (RuntimeException) 276 { 277 CNode::normalize(); 278 } 279 virtual Reference< XNode > SAL_CALL removeChild(const Reference< XNode >& oldChild) 280 throw (RuntimeException, DOMException) 281 { 282 return CNode::removeChild(oldChild); 283 } 284 virtual Reference< XNode > SAL_CALL replaceChild( 285 const Reference< XNode >& newChild, const Reference< XNode >& oldChild) 286 throw (RuntimeException, DOMException) 287 { 288 return CNode::replaceChild(newChild, oldChild); 289 } 290 virtual void SAL_CALL setNodeValue(const OUString& nodeValue) 291 throw (RuntimeException, DOMException) 292 { 293 return CNode::setNodeValue(nodeValue); 294 } 295 virtual void SAL_CALL setPrefix(const OUString& prefix) 296 throw (RuntimeException, DOMException) 297 { 298 return CNode::setPrefix(prefix); 299 } 300 301 }; 302 303 } 304 305 #endif 306