xref: /aoo4110/main/unoxml/source/dom/attr.hxx (revision b1cdbd2c)
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() throw (RuntimeException);
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() throw (RuntimeException);
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()throw (RuntimeException);
85 
86         /**
87         On retrieval, the value of the attribute is returned as a string.
88         */
89         virtual OUString SAL_CALL getValue() throw (RuntimeException);
90 
91         /**
92         Sets the value of the attribute from a string.
93         */
94 
95         virtual void SAL_CALL setValue(const OUString& value) throw (RuntimeException, DOMException);
96 
97         // resolve uno inheritance problems...
98         // overrides for XNode base
99         virtual OUString SAL_CALL getNodeName()
100             throw (RuntimeException);
101         virtual OUString SAL_CALL getNodeValue()
102             throw (RuntimeException);
103         virtual OUString SAL_CALL getLocalName()
104             throw (RuntimeException);
105 
106     // --- delegation for XNde base.
appendChild(const Reference<XNode> & newChild)107     virtual Reference< XNode > SAL_CALL appendChild(const Reference< XNode >& newChild)
108         throw (RuntimeException, DOMException)
109     {
110         return CNode::appendChild(newChild);
111     }
cloneNode(sal_Bool deep)112     virtual Reference< XNode > SAL_CALL cloneNode(sal_Bool deep)
113         throw (RuntimeException)
114     {
115         return CNode::cloneNode(deep);
116     }
getAttributes()117     virtual Reference< XNamedNodeMap > SAL_CALL getAttributes()
118         throw (RuntimeException)
119     {
120         return CNode::getAttributes();
121     }
getChildNodes()122     virtual Reference< XNodeList > SAL_CALL getChildNodes()
123         throw (RuntimeException)
124     {
125         return CNode::getChildNodes();
126     }
getFirstChild()127     virtual Reference< XNode > SAL_CALL getFirstChild()
128         throw (RuntimeException)
129     {
130         return CNode::getFirstChild();
131     }
getLastChild()132     virtual Reference< XNode > SAL_CALL getLastChild()
133         throw (RuntimeException)
134     {
135         return CNode::getLastChild();
136     }
137     virtual OUString SAL_CALL getNamespaceURI()
138         throw (RuntimeException);
getNextSibling()139     virtual Reference< XNode > SAL_CALL getNextSibling()
140         throw (RuntimeException)
141     {
142         return CNode::getNextSibling();
143     }
getNodeType()144     virtual NodeType SAL_CALL getNodeType()
145         throw (RuntimeException)
146     {
147         return CNode::getNodeType();
148     }
getOwnerDocument()149     virtual Reference< XDocument > SAL_CALL getOwnerDocument()
150         throw (RuntimeException)
151     {
152         return CNode::getOwnerDocument();
153     }
getParentNode()154     virtual Reference< XNode > SAL_CALL getParentNode()
155         throw (RuntimeException)
156     {
157         return CNode::getParentNode();
158     }
159     virtual OUString SAL_CALL getPrefix()
160         throw (RuntimeException);
getPreviousSibling()161     virtual Reference< XNode > SAL_CALL getPreviousSibling()
162         throw (RuntimeException)
163     {
164         return CNode::getPreviousSibling();
165     }
hasAttributes()166     virtual sal_Bool SAL_CALL hasAttributes()
167         throw (RuntimeException)
168     {
169         return CNode::hasAttributes();
170     }
hasChildNodes()171     virtual sal_Bool SAL_CALL hasChildNodes()
172         throw (RuntimeException)
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         throw (RuntimeException, DOMException)
179     {
180         return CNode::insertBefore(newChild, refChild);
181     }
isSupported(const OUString & feature,const OUString & ver)182     virtual sal_Bool SAL_CALL isSupported(const OUString& feature, const OUString& ver)
183         throw (RuntimeException)
184     {
185         return CNode::isSupported(feature, ver);
186     }
normalize()187     virtual void SAL_CALL normalize()
188         throw (RuntimeException)
189     {
190         CNode::normalize();
191     }
removeChild(const Reference<XNode> & oldChild)192     virtual Reference< XNode > SAL_CALL removeChild(const Reference< XNode >& oldChild)
193         throw (RuntimeException, DOMException)
194     {
195         return CNode::removeChild(oldChild);
196     }
replaceChild(const Reference<XNode> & newChild,const Reference<XNode> & oldChild)197     virtual Reference< XNode > SAL_CALL replaceChild(
198             const Reference< XNode >& newChild, const Reference< XNode >& oldChild)
199         throw (RuntimeException, DOMException)
200     {
201         return CNode::replaceChild(newChild, oldChild);
202     }
setNodeValue(const OUString & nodeValue)203     virtual void SAL_CALL setNodeValue(const OUString& nodeValue)
204         throw (RuntimeException, DOMException)
205     {
206         return setValue(nodeValue);
207     }
208     virtual void SAL_CALL setPrefix(const OUString& prefix)
209         throw (RuntimeException, DOMException);
210 
211     };
212 }
213 
214 #endif
215