LibreOffice Module unoxml (master) 1
attr.hxx
Go to the documentation of this file.
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#pragma once
21
22#include <memory>
23#include <optional>
24
25#include <libxml/tree.h>
26
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
35namespace DOM
36{
37 typedef ::std::pair< OString, OString > stringpair_t;
38
39 typedef ::cppu::ImplInheritanceHelper< CNode, css::xml::dom::XAttr > CAttr_Base;
40
41 class CAttr
42 : public CAttr_Base
43 {
44 friend class CDocument;
45
46 xmlAttrPtr m_aAttrPtr;
47 ::std::optional< stringpair_t > m_oNamespace;
48
49 CAttr(CDocument const& rDocument, ::osl::Mutex const& rMutex,
50 xmlAttrPtr const pAttr);
51
52 public:
54 xmlNsPtr GetNamespace(xmlNodePtr const pNode);
55
56 virtual bool IsChildTypeAllowed(css::xml::dom::NodeType const nodeType,
57 css::xml::dom::NodeType const*) override;
58
62 virtual OUString SAL_CALL getName() override;
63
68 virtual css::uno::Reference< css::xml::dom::XElement > SAL_CALL getOwnerElement() override;
69
74 virtual sal_Bool SAL_CALL getSpecified() override;
75
79 virtual OUString SAL_CALL getValue() override;
80
85 virtual void SAL_CALL setValue(const OUString& value) override;
86
87 // resolve uno inheritance problems...
88 // overrides for XNode base
89 virtual OUString SAL_CALL getNodeName() override;
90 virtual OUString SAL_CALL getNodeValue() override;
91 virtual OUString SAL_CALL getLocalName() override;
92
93 // --- delegation for XNode base.
94 virtual css::uno::Reference< css::xml::dom::XNode > SAL_CALL appendChild(const css::uno::Reference< css::xml::dom::XNode >& newChild) override
95 {
96 return CNode::appendChild(newChild);
97 }
98 virtual css::uno::Reference< css::xml::dom::XNode > SAL_CALL cloneNode(sal_Bool deep) override
99 {
100 return CNode::cloneNode(deep);
101 }
102 virtual css::uno::Reference< css::xml::dom::XNamedNodeMap > SAL_CALL getAttributes() override
103 {
104 return CNode::getAttributes();
105 }
106 virtual css::uno::Reference< css::xml::dom::XNodeList > SAL_CALL getChildNodes() override
107 {
108 return CNode::getChildNodes();
109 }
110 virtual css::uno::Reference< css::xml::dom::XNode > SAL_CALL getFirstChild() override
111 {
112 return CNode::getFirstChild();
113 }
114 virtual css::uno::Reference< css::xml::dom::XNode > SAL_CALL getLastChild() override
115 {
116 return CNode::getLastChild();
117 }
118 virtual OUString SAL_CALL getNamespaceURI() override;
119 virtual css::uno::Reference< css::xml::dom::XNode > SAL_CALL getNextSibling() override
120 {
121 return CNode::getNextSibling();
122 }
123 virtual css::xml::dom::NodeType SAL_CALL getNodeType() override
124 {
125 return CNode::getNodeType();
126 }
127 virtual css::uno::Reference< css::xml::dom::XDocument > SAL_CALL getOwnerDocument() override
128 {
129 return CNode::getOwnerDocument();
130 }
131 virtual css::uno::Reference< css::xml::dom::XNode > SAL_CALL getParentNode() override
132 {
133 return CNode::getParentNode();
134 }
135 virtual OUString SAL_CALL getPrefix() override;
136 virtual css::uno::Reference< css::xml::dom::XNode > SAL_CALL getPreviousSibling() override
137 {
138 return CNode::getPreviousSibling();
139 }
140 virtual sal_Bool SAL_CALL hasAttributes() override
141 {
142 return CNode::hasAttributes();
143 }
144 virtual sal_Bool SAL_CALL hasChildNodes() override
145 {
146 return CNode::hasChildNodes();
147 }
148 virtual css::uno::Reference< css::xml::dom::XNode > SAL_CALL insertBefore(
149 const css::uno::Reference< css::xml::dom::XNode >& newChild, const css::uno::Reference< css::xml::dom::XNode >& refChild) override
150 {
151 return CNode::insertBefore(newChild, refChild);
152 }
153 virtual sal_Bool SAL_CALL isSupported(const OUString& feature, const OUString& ver) override
154 {
155 return CNode::isSupported(feature, ver);
156 }
157 virtual void SAL_CALL normalize() override
158 {
159 CNode::normalize();
160 }
161 virtual css::uno::Reference< css::xml::dom::XNode > SAL_CALL removeChild(const css::uno::Reference< css::xml::dom::XNode >& oldChild) override
162 {
163 return CNode::removeChild(oldChild);
164 }
165 virtual css::uno::Reference< css::xml::dom::XNode > SAL_CALL replaceChild(
166 const css::uno::Reference< css::xml::dom::XNode >& newChild, const css::uno::Reference< css::xml::dom::XNode >& oldChild) override
167 {
168 return CNode::replaceChild(newChild, oldChild);
169 }
170 virtual void SAL_CALL setNodeValue(const OUString& nodeValue) override
171 {
172 return setValue(nodeValue);
173 }
174 virtual void SAL_CALL setPrefix(const OUString& prefix) override;
175
176 };
177}
178
179/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
virtual css::uno::Reference< css::xml::dom::XNode > SAL_CALL getPreviousSibling() override
Definition: attr.hxx:136
virtual css::xml::dom::NodeType SAL_CALL getNodeType() override
Definition: attr.hxx:123
virtual css::uno::Reference< css::xml::dom::XDocument > SAL_CALL getOwnerDocument() override
Definition: attr.hxx:127
CAttr(CDocument const &rDocument, ::osl::Mutex const &rMutex, xmlAttrPtr const pAttr)
Definition: attr.cxx:39
virtual css::uno::Reference< css::xml::dom::XNode > SAL_CALL getLastChild() override
Definition: attr.hxx:114
virtual OUString SAL_CALL getValue() override
On retrieval, the value of the attribute is returned as a string.
Definition: attr.cxx:148
virtual css::uno::Reference< css::xml::dom::XNode > SAL_CALL getNextSibling() override
Definition: attr.hxx:119
virtual bool IsChildTypeAllowed(css::xml::dom::NodeType const nodeType, css::xml::dom::NodeType const *) override
Definition: attr.cxx:73
virtual OUString SAL_CALL getPrefix() override
Definition: attr.cxx:229
virtual OUString SAL_CALL getName() override
Returns the name of this attribute.
Definition: attr.cxx:101
virtual css::uno::Reference< css::xml::dom::XNode > SAL_CALL insertBefore(const css::uno::Reference< css::xml::dom::XNode > &newChild, const css::uno::Reference< css::xml::dom::XNode > &refChild) override
Definition: attr.hxx:148
xmlAttrPtr m_aAttrPtr
Definition: attr.hxx:46
virtual sal_Bool SAL_CALL hasAttributes() override
Definition: attr.hxx:140
virtual css::uno::Reference< css::xml::dom::XNode > SAL_CALL appendChild(const css::uno::Reference< css::xml::dom::XNode > &newChild) override
Definition: attr.hxx:94
virtual OUString SAL_CALL getNodeName() override
Definition: attr.cxx:84
virtual OUString SAL_CALL getNodeValue() override
Definition: attr.cxx:88
virtual void SAL_CALL setPrefix(const OUString &prefix) override
Definition: attr.cxx:211
virtual OUString SAL_CALL getLocalName() override
Definition: attr.cxx:92
virtual css::uno::Reference< css::xml::dom::XNode > SAL_CALL replaceChild(const css::uno::Reference< css::xml::dom::XNode > &newChild, const css::uno::Reference< css::xml::dom::XNode > &oldChild) override
Definition: attr.hxx:165
::std::optional< stringpair_t > m_oNamespace
Definition: attr.hxx:47
virtual css::uno::Reference< css::xml::dom::XNode > SAL_CALL cloneNode(sal_Bool deep) override
Definition: attr.hxx:98
xmlNsPtr GetNamespace(xmlNodePtr const pNode)
return the libxml namespace corresponding to m_pNamespace on pNode
Definition: attr.cxx:47
virtual void SAL_CALL normalize() override
Definition: attr.hxx:157
virtual void SAL_CALL setValue(const OUString &value) override
Sets the value of the attribute from a string.
Definition: attr.cxx:165
virtual css::uno::Reference< css::xml::dom::XElement > SAL_CALL getOwnerElement() override
The Element node this attribute is attached to or null if this attribute is not in use.
Definition: attr.cxx:117
virtual sal_Bool SAL_CALL isSupported(const OUString &feature, const OUString &ver) override
Definition: attr.hxx:153
virtual css::uno::Reference< css::xml::dom::XNamedNodeMap > SAL_CALL getAttributes() override
Definition: attr.hxx:102
virtual OUString SAL_CALL getNamespaceURI() override
Definition: attr.cxx:248
virtual sal_Bool SAL_CALL hasChildNodes() override
Definition: attr.hxx:144
virtual css::uno::Reference< css::xml::dom::XNode > SAL_CALL removeChild(const css::uno::Reference< css::xml::dom::XNode > &oldChild) override
Definition: attr.hxx:161
virtual css::uno::Reference< css::xml::dom::XNodeList > SAL_CALL getChildNodes() override
Definition: attr.hxx:106
virtual css::uno::Reference< css::xml::dom::XNode > SAL_CALL getFirstChild() override
Definition: attr.hxx:110
virtual void SAL_CALL setNodeValue(const OUString &nodeValue) override
Definition: attr.hxx:170
virtual sal_Bool SAL_CALL getSpecified() override
If this attribute was explicitly given a value in the original document, this is true; otherwise,...
Definition: attr.cxx:138
virtual css::uno::Reference< css::xml::dom::XNode > SAL_CALL getParentNode() override
Definition: attr.hxx:131
Definition: attr.cxx:38
::cppu::ImplInheritanceHelper< CNode, css::xml::dom::XAttr > CAttr_Base
Definition: attr.hxx:39
::std::pair< OString, OString > stringpair_t
Definition: attr.hxx:37
unsigned char sal_Bool