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