xref: /aoo4110/main/unoxml/source/dom/element.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_ELEMENT_HXX
25 #define DOM_ELEMENT_HXX
26 
27 #include <libxml/tree.h>
28 
29 #include <com/sun/star/uno/Reference.h>
30 #include <com/sun/star/xml/dom/XNode.hpp>
31 #include <com/sun/star/xml/dom/XNodeList.hpp>
32 #include <com/sun/star/xml/dom/XNamedNodeMap.hpp>
33 #include <com/sun/star/xml/dom/NodeType.hpp>
34 
35 #include <node.hxx>
36 
37 
38 using ::rtl::OUString;
39 using namespace com::sun::star::uno;
40 using namespace com::sun::star::xml::dom;
41 
42 namespace DOM
43 {
44     typedef ::cppu::ImplInheritanceHelper1<CNode, XElement > CElement_Base;
45 
46     class CElement
47         : public CElement_Base
48     {
49     private:
50         friend class CDocument;
51 
52         Reference< XAttr > setAttributeNode_Impl_Lock(
53                 Reference< XAttr > const& xNewAttr, bool const bNS);
54 
55     protected:
56         CElement(CDocument const& rDocument, ::osl::Mutex const& rMutex,
57                 xmlNodePtr const pNode);
58 
59     public:
60 
61         virtual void saxify(const Reference< XDocumentHandler >& i_xHandler);
62 
63         virtual void fastSaxify( Context& i_rContext );
64 
65         virtual bool IsChildTypeAllowed(NodeType const nodeType);
66 
67         /**
68         Retrieves an attribute value by name.
69         */
70         virtual OUString  SAL_CALL getAttribute(const OUString& name)
71             throw (RuntimeException);
72 
73         /**
74         Retrieves an attribute node by name.
75         */
76         virtual Reference< XAttr > SAL_CALL getAttributeNode(const OUString& name)
77             throw (RuntimeException);
78 
79         /**
80         Retrieves an Attr node by local name and namespace URI.
81         */
82         virtual Reference< XAttr > SAL_CALL getAttributeNodeNS(const OUString& namespaceURI, const OUString& localName)
83             throw (RuntimeException);
84 
85         /**
86         Retrieves an attribute value by local name and namespace URI.
87         */
88         virtual OUString SAL_CALL getAttributeNS(const OUString& namespaceURI, const OUString& localName)
89             throw (RuntimeException);
90 
91         /**
92         Returns a NodeList of all descendant Elements with a given tag name,
93         in the order in which they are
94         encountered in a preorder traversal of this Element tree.
95         */
96         virtual Reference< XNodeList > SAL_CALL getElementsByTagName(const OUString& name)
97             throw (RuntimeException);
98 
99         /**
100         Returns a NodeList of all the descendant Elements with a given local
101         name and namespace URI in the order in which they are encountered in
102         a preorder traversal of this Element tree.
103         */
104         virtual Reference< XNodeList > SAL_CALL getElementsByTagNameNS(const OUString& namespaceURI,
105                 const OUString& localName)
106             throw (RuntimeException);
107 
108         /**
109         The name of the element.
110         */
111         virtual OUString SAL_CALL getTagName()
112             throw (RuntimeException);
113 
114         /**
115         Returns true when an attribute with a given name is specified on this
116         element or has a default value, false otherwise.
117         */
118         virtual sal_Bool SAL_CALL hasAttribute(const OUString& name)
119             throw (RuntimeException);
120 
121         /**
122         Returns true when an attribute with a given local name and namespace
123         URI is specified on this element or has a default value, false otherwise.
124         */
125         virtual sal_Bool SAL_CALL hasAttributeNS(const OUString& namespaceURI, const OUString& localName)
126             throw (RuntimeException);
127 
128         /**
129         Removes an attribute by name.
130         */
131         virtual void SAL_CALL removeAttribute(const OUString& name)
132             throw (RuntimeException, DOMException);
133 
134         /**
135         Removes the specified attribute node.
136         */
137         virtual Reference< XAttr > SAL_CALL removeAttributeNode(const Reference< XAttr >& oldAttr)
138             throw (RuntimeException, DOMException);
139 
140         /**
141         Removes an attribute by local name and namespace URI.
142         */
143         virtual void SAL_CALL removeAttributeNS(const OUString& namespaceURI, const OUString& localName)
144             throw (RuntimeException, DOMException);
145 
146         /**
147         Adds a new attribute.
148         */
149         virtual void SAL_CALL setAttribute(const OUString& name, const OUString& value)
150             throw (RuntimeException, DOMException);
151 
152         /**
153         Adds a new attribute node.
154         */
155         virtual Reference< XAttr > SAL_CALL setAttributeNode(const Reference< XAttr >& newAttr)
156             throw (RuntimeException, DOMException);
157 
158         /**
159         Adds a new attribute.
160         */
161         virtual Reference< XAttr > SAL_CALL setAttributeNodeNS(const Reference< XAttr >& newAttr)
162             throw (RuntimeException, DOMException);
163 
164         /**
165         Adds a new attribute.
166         */
167         virtual void SAL_CALL setAttributeNS(
168                 const OUString& namespaceURI, const OUString& qualifiedName, const OUString& value)
169             throw (RuntimeException, DOMException);
170 
171         /**
172         sets the element name
173         */
174         virtual void SAL_CALL setElementName(const OUString& elementName)
175             throw (RuntimeException, DOMException);
176 
177         // overrides for XNode base
178         virtual OUString SAL_CALL getNodeName()
179             throw (RuntimeException);
180         virtual OUString SAL_CALL getNodeValue()
181             throw (RuntimeException);
182         virtual Reference< XNamedNodeMap > SAL_CALL getAttributes()
183             throw (RuntimeException);
184         virtual OUString SAL_CALL getLocalName()
185             throw (RuntimeException);
186 
187         // resolve uno inheritance problems...
188         // --- delegation for XNde base.
appendChild(const Reference<XNode> & newChild)189         virtual Reference< XNode > SAL_CALL appendChild(const Reference< XNode >& newChild)
190             throw (RuntimeException, DOMException)
191         {
192             return CNode::appendChild(newChild);
193         }
cloneNode(sal_Bool deep)194         virtual Reference< XNode > SAL_CALL cloneNode(sal_Bool deep)
195             throw (RuntimeException)
196         {
197             return CNode::cloneNode(deep);
198         }
getChildNodes()199         virtual Reference< XNodeList > SAL_CALL getChildNodes()
200             throw (RuntimeException)
201         {
202             return CNode::getChildNodes();
203         }
getFirstChild()204         virtual Reference< XNode > SAL_CALL getFirstChild()
205             throw (RuntimeException)
206         {
207             return CNode::getFirstChild();
208         }
getLastChild()209         virtual Reference< XNode > SAL_CALL getLastChild()
210             throw (RuntimeException)
211         {
212             return CNode::getLastChild();
213         }
getNamespaceURI()214         virtual OUString SAL_CALL getNamespaceURI()
215             throw (RuntimeException)
216         {
217             return CNode::getNamespaceURI();
218         }
getNextSibling()219         virtual Reference< XNode > SAL_CALL getNextSibling()
220             throw (RuntimeException)
221         {
222             return CNode::getNextSibling();
223         }
getNodeType()224         virtual NodeType SAL_CALL getNodeType()
225             throw (RuntimeException)
226         {
227             return CNode::getNodeType();
228         }
getOwnerDocument()229         virtual Reference< XDocument > SAL_CALL getOwnerDocument()
230             throw (RuntimeException)
231         {
232             return CNode::getOwnerDocument();
233         }
getParentNode()234         virtual Reference< XNode > SAL_CALL getParentNode()
235             throw (RuntimeException)
236         {
237             return CNode::getParentNode();
238         }
getPrefix()239         virtual OUString SAL_CALL getPrefix()
240             throw (RuntimeException)
241         {
242             return CNode::getPrefix();
243         }
getPreviousSibling()244         virtual Reference< XNode > SAL_CALL getPreviousSibling()
245             throw (RuntimeException)
246         {
247             return CNode::getPreviousSibling();
248         }
hasAttributes()249         virtual sal_Bool SAL_CALL hasAttributes()
250             throw (RuntimeException)
251         {
252             return CNode::hasAttributes();
253         }
hasChildNodes()254         virtual sal_Bool SAL_CALL hasChildNodes()
255             throw (RuntimeException)
256         {
257             return CNode::hasChildNodes();
258         }
insertBefore(const Reference<XNode> & newChild,const Reference<XNode> & refChild)259         virtual Reference< XNode > SAL_CALL insertBefore(
260                 const Reference< XNode >& newChild, const Reference< XNode >& refChild)
261             throw (RuntimeException, DOMException)
262         {
263             return CNode::insertBefore(newChild, refChild);
264         }
isSupported(const OUString & feature,const OUString & ver)265         virtual sal_Bool SAL_CALL isSupported(const OUString& feature, const OUString& ver)
266             throw (RuntimeException)
267         {
268             return CNode::isSupported(feature, ver);
269         }
normalize()270         virtual void SAL_CALL normalize()
271             throw (RuntimeException)
272         {
273             CNode::normalize();
274         }
removeChild(const Reference<XNode> & oldChild)275         virtual Reference< XNode > SAL_CALL removeChild(const Reference< XNode >& oldChild)
276             throw (RuntimeException, DOMException)
277         {
278             return CNode::removeChild(oldChild);
279         }
replaceChild(const Reference<XNode> & newChild,const Reference<XNode> & oldChild)280         virtual Reference< XNode > SAL_CALL replaceChild(
281                 const Reference< XNode >& newChild, const Reference< XNode >& oldChild)
282             throw (RuntimeException, DOMException)
283         {
284             return CNode::replaceChild(newChild, oldChild);
285         }
setNodeValue(const OUString & nodeValue)286         virtual void SAL_CALL setNodeValue(const OUString& nodeValue)
287             throw (RuntimeException, DOMException)
288         {
289             return CNode::setNodeValue(nodeValue);
290         }
setPrefix(const OUString & prefix)291         virtual void SAL_CALL setPrefix(const OUString& prefix)
292             throw (RuntimeException, DOMException)
293         {
294             return CNode::setPrefix(prefix);
295         }
296 
297     };
298 
299 }
300 
301 #endif
302