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