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_ATTR_HXX 25 #define DOM_ATTR_HXX 26 27 #include <memory> 28 29 #include <libxml/tree.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/XAttr.hpp> 36 37 #include <node.hxx> 38 39 using ::rtl::OUString; 40 using namespace com::sun::star::uno; 41 using namespace com::sun::star::xml::dom; 42 43 namespace DOM 44 { 45 typedef ::std::pair< ::rtl::OString, ::rtl::OString > stringpair_t; 46 47 typedef ::cppu::ImplInheritanceHelper1< CNode, XAttr > CAttr_Base; 48 49 class CAttr 50 : public CAttr_Base 51 { 52 private: 53 friend class CDocument; 54 55 private: 56 xmlAttrPtr m_aAttrPtr; 57 ::std::auto_ptr< stringpair_t > m_pNamespace; 58 59 protected: 60 CAttr(CDocument const& rDocument, ::osl::Mutex const& rMutex, 61 xmlAttrPtr const pAttr); 62 63 public: 64 /// return the libxml namespace corresponding to m_pNamespace on pNode 65 xmlNsPtr GetNamespace(xmlNodePtr const pNode); 66 67 virtual bool IsChildTypeAllowed(NodeType const nodeType); 68 69 /** 70 Returns the name of this attribute. 71 */ 72 virtual OUString SAL_CALL getName(); 73 74 /** 75 The Element node this attribute is attached to or null if this 76 attribute is not in use. 77 */ 78 virtual Reference< XElement > SAL_CALL getOwnerElement(); 79 80 /** 81 If this attribute was explicitly given a value in the original 82 document, this is true; otherwise, it is false. 83 */ 84 virtual sal_Bool SAL_CALL getSpecified(); 85 86 /** 87 On retrieval, the value of the attribute is returned as a string. 88 */ 89 virtual OUString SAL_CALL getValue(); 90 91 /** 92 Sets the value of the attribute from a string. 93 */ 94 95 virtual void SAL_CALL setValue(const OUString& value); 96 97 // resolve uno inheritance problems... 98 // overrides for XNode base 99 virtual OUString SAL_CALL getNodeName(); 100 virtual OUString SAL_CALL getNodeValue(); 101 virtual OUString SAL_CALL getLocalName(); 102 103 // --- delegation for XNde 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 } 128 virtual OUString SAL_CALL getNamespaceURI(); getNextSibling()129 virtual Reference< XNode > SAL_CALL getNextSibling() 130 { 131 return CNode::getNextSibling(); 132 } getNodeType()133 virtual NodeType SAL_CALL getNodeType() 134 { 135 return CNode::getNodeType(); 136 } getOwnerDocument()137 virtual Reference< XDocument > SAL_CALL getOwnerDocument() 138 { 139 return CNode::getOwnerDocument(); 140 } getParentNode()141 virtual Reference< XNode > SAL_CALL getParentNode() 142 { 143 return CNode::getParentNode(); 144 } 145 virtual OUString SAL_CALL getPrefix(); getPreviousSibling()146 virtual Reference< XNode > SAL_CALL getPreviousSibling() 147 { 148 return CNode::getPreviousSibling(); 149 } hasAttributes()150 virtual sal_Bool SAL_CALL hasAttributes() 151 { 152 return CNode::hasAttributes(); 153 } hasChildNodes()154 virtual sal_Bool SAL_CALL hasChildNodes() 155 { 156 return CNode::hasChildNodes(); 157 } insertBefore(const Reference<XNode> & newChild,const Reference<XNode> & refChild)158 virtual Reference< XNode > SAL_CALL insertBefore( 159 const Reference< XNode >& newChild, const Reference< XNode >& refChild) 160 { 161 return CNode::insertBefore(newChild, refChild); 162 } isSupported(const OUString & feature,const OUString & ver)163 virtual sal_Bool SAL_CALL isSupported(const OUString& feature, const OUString& ver) 164 { 165 return CNode::isSupported(feature, ver); 166 } normalize()167 virtual void SAL_CALL normalize() 168 { 169 CNode::normalize(); 170 } removeChild(const Reference<XNode> & oldChild)171 virtual Reference< XNode > SAL_CALL removeChild(const Reference< XNode >& oldChild) 172 { 173 return CNode::removeChild(oldChild); 174 } replaceChild(const Reference<XNode> & newChild,const Reference<XNode> & oldChild)175 virtual Reference< XNode > SAL_CALL replaceChild( 176 const Reference< XNode >& newChild, const Reference< XNode >& oldChild) 177 { 178 return CNode::replaceChild(newChild, oldChild); 179 } setNodeValue(const OUString & nodeValue)180 virtual void SAL_CALL setNodeValue(const OUString& nodeValue) 181 { 182 return setValue(nodeValue); 183 } 184 virtual void SAL_CALL setPrefix(const OUString& prefix); 185 186 }; 187 } 188 189 #endif 190