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