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_ATTR_HXX
21 : #define INCLUDED_UNOXML_SOURCE_DOM_ATTR_HXX
22 :
23 : #include <memory>
24 :
25 : #include <libxml/tree.h>
26 :
27 : #include <cppuhelper/implbase1.hxx>
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/XAttr.hpp>
32 :
33 : #include <node.hxx>
34 :
35 : using namespace com::sun::star::uno;
36 : using namespace com::sun::star::xml::dom;
37 :
38 : namespace DOM
39 : {
40 : typedef ::std::pair< OString, OString > stringpair_t;
41 :
42 : typedef ::cppu::ImplInheritanceHelper1< CNode, XAttr > CAttr_Base;
43 :
44 0 : class CAttr
45 : : public CAttr_Base
46 : {
47 : private:
48 : friend class CDocument;
49 :
50 : private:
51 : xmlAttrPtr m_aAttrPtr;
52 : ::std::auto_ptr< stringpair_t > m_pNamespace;
53 :
54 : protected:
55 : CAttr(CDocument const& rDocument, ::osl::Mutex const& rMutex,
56 : xmlAttrPtr const pAttr);
57 :
58 : public:
59 : /// return the libxml namespace corresponding to m_pNamespace on pNode
60 : xmlNsPtr GetNamespace(xmlNodePtr const pNode);
61 :
62 : virtual bool IsChildTypeAllowed(NodeType const nodeType) SAL_OVERRIDE;
63 :
64 : /**
65 : Returns the name of this attribute.
66 : */
67 : virtual OUString SAL_CALL getName() throw (RuntimeException, std::exception) SAL_OVERRIDE;
68 :
69 : /**
70 : The Element node this attribute is attached to or null if this
71 : attribute is not in use.
72 : */
73 : virtual Reference< XElement > SAL_CALL getOwnerElement() throw (RuntimeException, std::exception) SAL_OVERRIDE;
74 :
75 : /**
76 : If this attribute was explicitly given a value in the original
77 : document, this is true; otherwise, it is false.
78 : */
79 : virtual sal_Bool SAL_CALL getSpecified()throw (RuntimeException, std::exception) SAL_OVERRIDE;
80 :
81 : /**
82 : On retrieval, the value of the attribute is returned as a string.
83 : */
84 : virtual OUString SAL_CALL getValue() throw (RuntimeException, std::exception) SAL_OVERRIDE;
85 :
86 : /**
87 : Sets the value of the attribute from a string.
88 : */
89 :
90 : virtual void SAL_CALL setValue(const OUString& value) throw (RuntimeException, DOMException, std::exception) SAL_OVERRIDE;
91 :
92 : // resolve uno inheritance problems...
93 : // overrides for XNode base
94 : virtual OUString SAL_CALL getNodeName()
95 : throw (RuntimeException, std::exception) SAL_OVERRIDE;
96 : virtual OUString SAL_CALL getNodeValue()
97 : throw (RuntimeException, std::exception) SAL_OVERRIDE;
98 : virtual OUString SAL_CALL getLocalName()
99 : throw (RuntimeException, std::exception) SAL_OVERRIDE;
100 :
101 : // --- delegation for XNde base.
102 0 : virtual Reference< XNode > SAL_CALL appendChild(const Reference< XNode >& newChild)
103 : throw (RuntimeException, DOMException, std::exception) SAL_OVERRIDE
104 : {
105 0 : return CNode::appendChild(newChild);
106 : }
107 0 : virtual Reference< XNode > SAL_CALL cloneNode(sal_Bool deep)
108 : throw (RuntimeException, std::exception) SAL_OVERRIDE
109 : {
110 0 : return CNode::cloneNode(deep);
111 : }
112 0 : virtual Reference< XNamedNodeMap > SAL_CALL getAttributes()
113 : throw (RuntimeException, std::exception) SAL_OVERRIDE
114 : {
115 0 : return CNode::getAttributes();
116 : }
117 0 : virtual Reference< XNodeList > SAL_CALL getChildNodes()
118 : throw (RuntimeException, std::exception) SAL_OVERRIDE
119 : {
120 0 : return CNode::getChildNodes();
121 : }
122 0 : virtual Reference< XNode > SAL_CALL getFirstChild()
123 : throw (RuntimeException, std::exception) SAL_OVERRIDE
124 : {
125 0 : return CNode::getFirstChild();
126 : }
127 0 : virtual Reference< XNode > SAL_CALL getLastChild()
128 : throw (RuntimeException, std::exception) SAL_OVERRIDE
129 : {
130 0 : return CNode::getLastChild();
131 : }
132 : virtual OUString SAL_CALL getNamespaceURI()
133 : throw (RuntimeException, std::exception) SAL_OVERRIDE;
134 0 : virtual Reference< XNode > SAL_CALL getNextSibling()
135 : throw (RuntimeException, std::exception) SAL_OVERRIDE
136 : {
137 0 : return CNode::getNextSibling();
138 : }
139 0 : virtual NodeType SAL_CALL getNodeType()
140 : throw (RuntimeException, std::exception) SAL_OVERRIDE
141 : {
142 0 : return CNode::getNodeType();
143 : }
144 0 : virtual Reference< XDocument > SAL_CALL getOwnerDocument()
145 : throw (RuntimeException, std::exception) SAL_OVERRIDE
146 : {
147 0 : return CNode::getOwnerDocument();
148 : }
149 0 : virtual Reference< XNode > SAL_CALL getParentNode()
150 : throw (RuntimeException, std::exception) SAL_OVERRIDE
151 : {
152 0 : return CNode::getParentNode();
153 : }
154 : virtual OUString SAL_CALL getPrefix()
155 : throw (RuntimeException, std::exception) SAL_OVERRIDE;
156 0 : virtual Reference< XNode > SAL_CALL getPreviousSibling()
157 : throw (RuntimeException, std::exception) SAL_OVERRIDE
158 : {
159 0 : return CNode::getPreviousSibling();
160 : }
161 0 : virtual sal_Bool SAL_CALL hasAttributes()
162 : throw (RuntimeException, std::exception) SAL_OVERRIDE
163 : {
164 0 : return CNode::hasAttributes();
165 : }
166 0 : virtual sal_Bool SAL_CALL hasChildNodes()
167 : throw (RuntimeException, std::exception) SAL_OVERRIDE
168 : {
169 0 : return CNode::hasChildNodes();
170 : }
171 0 : virtual Reference< XNode > SAL_CALL insertBefore(
172 : const Reference< XNode >& newChild, const Reference< XNode >& refChild)
173 : throw (RuntimeException, DOMException, std::exception) SAL_OVERRIDE
174 : {
175 0 : return CNode::insertBefore(newChild, refChild);
176 : }
177 0 : virtual sal_Bool SAL_CALL isSupported(const OUString& feature, const OUString& ver)
178 : throw (RuntimeException, std::exception) SAL_OVERRIDE
179 : {
180 0 : return CNode::isSupported(feature, ver);
181 : }
182 0 : virtual void SAL_CALL normalize()
183 : throw (RuntimeException, std::exception) SAL_OVERRIDE
184 : {
185 0 : CNode::normalize();
186 0 : }
187 0 : virtual Reference< XNode > SAL_CALL removeChild(const Reference< XNode >& oldChild)
188 : throw (RuntimeException, DOMException, std::exception) SAL_OVERRIDE
189 : {
190 0 : return CNode::removeChild(oldChild);
191 : }
192 0 : virtual Reference< XNode > SAL_CALL replaceChild(
193 : const Reference< XNode >& newChild, const Reference< XNode >& oldChild)
194 : throw (RuntimeException, DOMException, std::exception) SAL_OVERRIDE
195 : {
196 0 : return CNode::replaceChild(newChild, oldChild);
197 : }
198 0 : virtual void SAL_CALL setNodeValue(const OUString& nodeValue)
199 : throw (RuntimeException, DOMException, std::exception) SAL_OVERRIDE
200 : {
201 0 : return setValue(nodeValue);
202 : }
203 : virtual void SAL_CALL setPrefix(const OUString& prefix)
204 : throw (RuntimeException, DOMException, std::exception) SAL_OVERRIDE;
205 :
206 : };
207 : }
208 :
209 : #endif
210 :
211 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|