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_ATTR_HXX 29 #define DOM_ATTR_HXX 30 31 #include <memory> 32 33 #include <libxml/tree.h> 34 35 #include <cppuhelper/implbase1.hxx> 36 37 #include <com/sun/star/uno/Reference.h> 38 #include <com/sun/star/xml/dom/XNode.hpp> 39 #include <com/sun/star/xml/dom/XAttr.hpp> 40 41 #include <node.hxx> 42 43 using ::rtl::OUString; 44 using namespace com::sun::star::uno; 45 using namespace com::sun::star::xml::dom; 46 47 namespace DOM 48 { 49 typedef ::std::pair< ::rtl::OString, ::rtl::OString > stringpair_t; 50 51 typedef ::cppu::ImplInheritanceHelper1< CNode, XAttr > CAttr_Base; 52 53 class CAttr 54 : public CAttr_Base 55 { 56 private: 57 friend class CDocument; 58 59 private: 60 xmlAttrPtr m_aAttrPtr; 61 ::std::auto_ptr< stringpair_t > m_pNamespace; 62 63 protected: 64 CAttr(CDocument const& rDocument, ::osl::Mutex const& rMutex, 65 xmlAttrPtr const pAttr); 66 67 public: 68 /// return the libxml namespace corresponding to m_pNamespace on pNode 69 xmlNsPtr GetNamespace(xmlNodePtr const pNode); 70 71 virtual bool IsChildTypeAllowed(NodeType const nodeType); 72 73 /** 74 Returns the name of this attribute. 75 */ 76 virtual OUString SAL_CALL getName() throw (RuntimeException); 77 78 /** 79 The Element node this attribute is attached to or null if this 80 attribute is not in use. 81 */ 82 virtual Reference< XElement > SAL_CALL getOwnerElement() throw (RuntimeException); 83 84 /** 85 If this attribute was explicitly given a value in the original 86 document, this is true; otherwise, it is false. 87 */ 88 virtual sal_Bool SAL_CALL getSpecified()throw (RuntimeException); 89 90 /** 91 On retrieval, the value of the attribute is returned as a string. 92 */ 93 virtual OUString SAL_CALL getValue() throw (RuntimeException); 94 95 /** 96 Sets the value of the attribute from a string. 97 */ 98 99 virtual void SAL_CALL setValue(const OUString& value) throw (RuntimeException, DOMException); 100 101 // resolve uno inheritance problems... 102 // overrides for XNode base 103 virtual OUString SAL_CALL getNodeName() 104 throw (RuntimeException); 105 virtual OUString SAL_CALL getNodeValue() 106 throw (RuntimeException); 107 virtual OUString SAL_CALL getLocalName() 108 throw (RuntimeException); 109 110 // --- delegation for XNde base. 111 virtual Reference< XNode > SAL_CALL appendChild(const Reference< XNode >& newChild) 112 throw (RuntimeException, DOMException) 113 { 114 return CNode::appendChild(newChild); 115 } 116 virtual Reference< XNode > SAL_CALL cloneNode(sal_Bool deep) 117 throw (RuntimeException) 118 { 119 return CNode::cloneNode(deep); 120 } 121 virtual Reference< XNamedNodeMap > SAL_CALL getAttributes() 122 throw (RuntimeException) 123 { 124 return CNode::getAttributes(); 125 } 126 virtual Reference< XNodeList > SAL_CALL getChildNodes() 127 throw (RuntimeException) 128 { 129 return CNode::getChildNodes(); 130 } 131 virtual Reference< XNode > SAL_CALL getFirstChild() 132 throw (RuntimeException) 133 { 134 return CNode::getFirstChild(); 135 } 136 virtual Reference< XNode > SAL_CALL getLastChild() 137 throw (RuntimeException) 138 { 139 return CNode::getLastChild(); 140 } 141 virtual OUString SAL_CALL getNamespaceURI() 142 throw (RuntimeException); 143 virtual Reference< XNode > SAL_CALL getNextSibling() 144 throw (RuntimeException) 145 { 146 return CNode::getNextSibling(); 147 } 148 virtual NodeType SAL_CALL getNodeType() 149 throw (RuntimeException) 150 { 151 return CNode::getNodeType(); 152 } 153 virtual Reference< XDocument > SAL_CALL getOwnerDocument() 154 throw (RuntimeException) 155 { 156 return CNode::getOwnerDocument(); 157 } 158 virtual Reference< XNode > SAL_CALL getParentNode() 159 throw (RuntimeException) 160 { 161 return CNode::getParentNode(); 162 } 163 virtual OUString SAL_CALL getPrefix() 164 throw (RuntimeException); 165 virtual Reference< XNode > SAL_CALL getPreviousSibling() 166 throw (RuntimeException) 167 { 168 return CNode::getPreviousSibling(); 169 } 170 virtual sal_Bool SAL_CALL hasAttributes() 171 throw (RuntimeException) 172 { 173 return CNode::hasAttributes(); 174 } 175 virtual sal_Bool SAL_CALL hasChildNodes() 176 throw (RuntimeException) 177 { 178 return CNode::hasChildNodes(); 179 } 180 virtual Reference< XNode > SAL_CALL insertBefore( 181 const Reference< XNode >& newChild, const Reference< XNode >& refChild) 182 throw (RuntimeException, DOMException) 183 { 184 return CNode::insertBefore(newChild, refChild); 185 } 186 virtual sal_Bool SAL_CALL isSupported(const OUString& feature, const OUString& ver) 187 throw (RuntimeException) 188 { 189 return CNode::isSupported(feature, ver); 190 } 191 virtual void SAL_CALL normalize() 192 throw (RuntimeException) 193 { 194 CNode::normalize(); 195 } 196 virtual Reference< XNode > SAL_CALL removeChild(const Reference< XNode >& oldChild) 197 throw (RuntimeException, DOMException) 198 { 199 return CNode::removeChild(oldChild); 200 } 201 virtual Reference< XNode > SAL_CALL replaceChild( 202 const Reference< XNode >& newChild, const Reference< XNode >& oldChild) 203 throw (RuntimeException, DOMException) 204 { 205 return CNode::replaceChild(newChild, oldChild); 206 } 207 virtual void SAL_CALL setNodeValue(const OUString& nodeValue) 208 throw (RuntimeException, DOMException) 209 { 210 return setValue(nodeValue); 211 } 212 virtual void SAL_CALL setPrefix(const OUString& prefix) 213 throw (RuntimeException, DOMException); 214 215 }; 216 } 217 218 #endif 219