1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
20 #ifndef INCLUDED_UNOXML_SOURCE_DOM_ELEMENT_HXX
21 #define INCLUDED_UNOXML_SOURCE_DOM_ELEMENT_HXX
23 #include <libxml/tree.h>
25 #include <com/sun/star/uno/Reference.h>
26 #include <com/sun/star/xml/dom/XNode.hpp>
27 #include <com/sun/star/xml/dom/XNodeList.hpp>
28 #include <com/sun/star/xml/dom/XNamedNodeMap.hpp>
29 #include <com/sun/star/xml/dom/NodeType.hpp>
31 #include <cppuhelper/implbase.hxx>
36 typedef ::cppu::ImplInheritanceHelper
<CNode
, css::xml::dom::XElement
> CElement_Base
;
39 : public CElement_Base
42 friend class CDocument
;
44 css::uno::Reference
< css::xml::dom::XAttr
> setAttributeNode_Impl_Lock(
45 css::uno::Reference
< css::xml::dom::XAttr
> const& xNewAttr
, bool const bNS
);
48 CElement(CDocument
const& rDocument
, ::osl::Mutex
const& rMutex
,
49 xmlNodePtr
const pNode
);
53 virtual void saxify(const css::uno::Reference
< css::xml::sax::XDocumentHandler
>& i_xHandler
) override
;
55 virtual void fastSaxify( Context
& i_rContext
) override
;
57 virtual bool IsChildTypeAllowed(css::xml::dom::NodeType
const nodeType
) override
;
60 Retrieves an attribute value by name.
62 virtual OUString SAL_CALL
getAttribute(const OUString
& name
)
63 throw (css::uno::RuntimeException
, std::exception
) override
;
66 Retrieves an attribute node by name.
68 virtual css::uno::Reference
< css::xml::dom::XAttr
> SAL_CALL
getAttributeNode(const OUString
& name
)
69 throw (css::uno::RuntimeException
, std::exception
) override
;
72 Retrieves an Attr node by local name and namespace URI.
74 virtual css::uno::Reference
< css::xml::dom::XAttr
> SAL_CALL
getAttributeNodeNS(const OUString
& namespaceURI
, const OUString
& localName
)
75 throw (css::uno::RuntimeException
, std::exception
) override
;
78 Retrieves an attribute value by local name and namespace URI.
80 virtual OUString SAL_CALL
getAttributeNS(const OUString
& namespaceURI
, const OUString
& localName
)
81 throw (css::uno::RuntimeException
, std::exception
) override
;
84 Returns a NodeList of all descendant Elements with a given tag name,
85 in the order in which they are
86 encountered in a preorder traversal of this Element tree.
88 virtual css::uno::Reference
< css::xml::dom::XNodeList
> SAL_CALL
getElementsByTagName(const OUString
& name
)
89 throw (css::uno::RuntimeException
, std::exception
) override
;
92 Returns a NodeList of all the descendant Elements with a given local
93 name and namespace URI in the order in which they are encountered in
94 a preorder traversal of this Element tree.
96 virtual css::uno::Reference
< css::xml::dom::XNodeList
> SAL_CALL
getElementsByTagNameNS(const OUString
& namespaceURI
,
97 const OUString
& localName
)
98 throw (css::uno::RuntimeException
, std::exception
) override
;
101 The name of the element.
103 virtual OUString SAL_CALL
getTagName()
104 throw (css::uno::RuntimeException
, std::exception
) override
;
107 Returns true when an attribute with a given name is specified on this
108 element or has a default value, false otherwise.
110 virtual sal_Bool SAL_CALL
hasAttribute(const OUString
& name
)
111 throw (css::uno::RuntimeException
, std::exception
) override
;
114 Returns true when an attribute with a given local name and namespace
115 URI is specified on this element or has a default value, false otherwise.
117 virtual sal_Bool SAL_CALL
hasAttributeNS(const OUString
& namespaceURI
, const OUString
& localName
)
118 throw (css::uno::RuntimeException
, std::exception
) override
;
121 Removes an attribute by name.
123 virtual void SAL_CALL
removeAttribute(const OUString
& name
)
124 throw (css::uno::RuntimeException
, css::xml::dom::DOMException
, std::exception
) override
;
127 Removes the specified attribute node.
129 virtual css::uno::Reference
< css::xml::dom::XAttr
> SAL_CALL
removeAttributeNode(const css::uno::Reference
< css::xml::dom::XAttr
>& oldAttr
)
130 throw (css::uno::RuntimeException
, css::xml::dom::DOMException
, std::exception
) override
;
133 Removes an attribute by local name and namespace URI.
135 virtual void SAL_CALL
removeAttributeNS(const OUString
& namespaceURI
, const OUString
& localName
)
136 throw (css::uno::RuntimeException
, css::xml::dom::DOMException
, std::exception
) override
;
139 Adds a new attribute.
141 virtual void SAL_CALL
setAttribute(const OUString
& name
, const OUString
& value
)
142 throw (css::uno::RuntimeException
, css::xml::dom::DOMException
, std::exception
) override
;
145 Adds a new attribute node.
147 virtual css::uno::Reference
< css::xml::dom::XAttr
> SAL_CALL
setAttributeNode(const css::uno::Reference
< css::xml::dom::XAttr
>& newAttr
)
148 throw (css::uno::RuntimeException
, css::xml::dom::DOMException
, std::exception
) override
;
151 Adds a new attribute.
153 virtual css::uno::Reference
< css::xml::dom::XAttr
> SAL_CALL
setAttributeNodeNS(const css::uno::Reference
< css::xml::dom::XAttr
>& newAttr
)
154 throw (css::uno::RuntimeException
, css::xml::dom::DOMException
, std::exception
) override
;
157 Adds a new attribute.
159 virtual void SAL_CALL
setAttributeNS(
160 const OUString
& namespaceURI
, const OUString
& qualifiedName
, const OUString
& value
)
161 throw (css::uno::RuntimeException
, css::xml::dom::DOMException
, std::exception
) override
;
163 // overrides for XNode base
164 virtual OUString SAL_CALL
getNodeName()
165 throw (css::uno::RuntimeException
, std::exception
) override
;
166 virtual OUString SAL_CALL
getNodeValue()
167 throw (css::uno::RuntimeException
, std::exception
) override
;
168 virtual css::uno::Reference
< css::xml::dom::XNamedNodeMap
> SAL_CALL
getAttributes()
169 throw (css::uno::RuntimeException
, std::exception
) override
;
170 virtual OUString SAL_CALL
getLocalName()
171 throw (css::uno::RuntimeException
, std::exception
) override
;
173 // resolve uno inheritance problems...
174 // --- delegation for XNode base.
175 virtual css::uno::Reference
< css::xml::dom::XNode
> SAL_CALL
appendChild(const css::uno::Reference
< css::xml::dom::XNode
>& newChild
)
176 throw (css::uno::RuntimeException
, css::xml::dom::DOMException
, std::exception
) override
178 return CNode::appendChild(newChild
);
180 virtual css::uno::Reference
< css::xml::dom::XNode
> SAL_CALL
cloneNode(sal_Bool deep
)
181 throw (css::uno::RuntimeException
, std::exception
) override
183 return CNode::cloneNode(deep
);
185 virtual css::uno::Reference
< css::xml::dom::XNodeList
> SAL_CALL
getChildNodes()
186 throw (css::uno::RuntimeException
, std::exception
) override
188 return CNode::getChildNodes();
190 virtual css::uno::Reference
< css::xml::dom::XNode
> SAL_CALL
getFirstChild()
191 throw (css::uno::RuntimeException
, std::exception
) override
193 return CNode::getFirstChild();
195 virtual css::uno::Reference
< css::xml::dom::XNode
> SAL_CALL
getLastChild()
196 throw (css::uno::RuntimeException
, std::exception
) override
198 return CNode::getLastChild();
200 virtual OUString SAL_CALL
getNamespaceURI()
201 throw (css::uno::RuntimeException
, std::exception
) override
203 return CNode::getNamespaceURI();
205 virtual css::uno::Reference
< css::xml::dom::XNode
> SAL_CALL
getNextSibling()
206 throw (css::uno::RuntimeException
, std::exception
) override
208 return CNode::getNextSibling();
210 virtual css::xml::dom::NodeType SAL_CALL
getNodeType()
211 throw (css::uno::RuntimeException
, std::exception
) override
213 return CNode::getNodeType();
215 virtual css::uno::Reference
< css::xml::dom::XDocument
> SAL_CALL
getOwnerDocument()
216 throw (css::uno::RuntimeException
, std::exception
) override
218 return CNode::getOwnerDocument();
220 virtual css::uno::Reference
< css::xml::dom::XNode
> SAL_CALL
getParentNode()
221 throw (css::uno::RuntimeException
, std::exception
) override
223 return CNode::getParentNode();
225 virtual OUString SAL_CALL
getPrefix()
226 throw (css::uno::RuntimeException
, std::exception
) override
228 return CNode::getPrefix();
230 virtual css::uno::Reference
< css::xml::dom::XNode
> SAL_CALL
getPreviousSibling()
231 throw (css::uno::RuntimeException
, std::exception
) override
233 return CNode::getPreviousSibling();
235 virtual sal_Bool SAL_CALL
hasAttributes()
236 throw (css::uno::RuntimeException
, std::exception
) override
238 return CNode::hasAttributes();
240 virtual sal_Bool SAL_CALL
hasChildNodes()
241 throw (css::uno::RuntimeException
, std::exception
) override
243 return CNode::hasChildNodes();
245 virtual css::uno::Reference
< css::xml::dom::XNode
> SAL_CALL
insertBefore(
246 const css::uno::Reference
< css::xml::dom::XNode
>& newChild
, const css::uno::Reference
< css::xml::dom::XNode
>& refChild
)
247 throw (css::uno::RuntimeException
, css::xml::dom::DOMException
, std::exception
) override
249 return CNode::insertBefore(newChild
, refChild
);
251 virtual sal_Bool SAL_CALL
isSupported(const OUString
& feature
, const OUString
& ver
)
252 throw (css::uno::RuntimeException
, std::exception
) override
254 return CNode::isSupported(feature
, ver
);
256 virtual void SAL_CALL
normalize()
257 throw (css::uno::RuntimeException
, std::exception
) override
261 virtual css::uno::Reference
< css::xml::dom::XNode
> SAL_CALL
removeChild(const css::uno::Reference
< css::xml::dom::XNode
>& oldChild
)
262 throw (css::uno::RuntimeException
, css::xml::dom::DOMException
, std::exception
) override
264 return CNode::removeChild(oldChild
);
266 virtual css::uno::Reference
< css::xml::dom::XNode
> SAL_CALL
replaceChild(
267 const css::uno::Reference
< css::xml::dom::XNode
>& newChild
, const css::uno::Reference
< css::xml::dom::XNode
>& oldChild
)
268 throw (css::uno::RuntimeException
, css::xml::dom::DOMException
, std::exception
) override
270 return CNode::replaceChild(newChild
, oldChild
);
272 virtual void SAL_CALL
setNodeValue(const OUString
& nodeValue
)
273 throw (css::uno::RuntimeException
, css::xml::dom::DOMException
, std::exception
) override
275 return CNode::setNodeValue(nodeValue
);
277 virtual void SAL_CALL
setPrefix(const OUString
& prefix
)
278 throw (css::uno::RuntimeException
, css::xml::dom::DOMException
, std::exception
) override
280 return CNode::setPrefix(prefix
);
289 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */