LibreOffice Module unotools (master) 1
confignode.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#ifndef INCLUDED_UNOTOOLS_CONFIGNODE_HXX
20#define INCLUDED_UNOTOOLS_CONFIGNODE_HXX
21
24
25namespace com::sun::star::container { class XHierarchicalNameAccess; }
26namespace com::sun::star::container { class XNameAccess; }
27namespace com::sun::star::container { class XNameContainer; }
28namespace com::sun::star::container { class XNameReplace; }
29namespace com::sun::star::lang { class XMultiServiceFactory; }
30namespace com::sun::star::uno { class XComponentContext; }
31namespace com::sun::star::util { class XChangesBatch; }
32
33namespace utl
34{
35
41 {
42 private:
43 css::uno::Reference< css::container::XHierarchicalNameAccess >
45 css::uno::Reference< css::container::XNameAccess >
47 css::uno::Reference< css::container::XNameReplace >
49 css::uno::Reference< css::container::XNameContainer >
52
53 OConfigurationNode insertNode(const OUString& _rName,const css::uno::Reference< css::uno::XInterface >& _xNode) const noexcept;
54
55 protected:
58 const css::uno::Reference< css::uno::XInterface >& _rxNode
59 );
60
61 const css::uno::Reference< css::container::XNameAccess >&
62 getUNONode() const { return m_xDirectAccess; }
63
64 public:
66 OConfigurationNode() :m_bEscapeNames(false) { }
71
73 OConfigurationNode& operator=(const OConfigurationNode& _rSource);
74 OConfigurationNode& operator=(OConfigurationNode&& _rSource);
75
77 OUString getLocalName() const;
78
82 OConfigurationNode openNode(const OUString& _rPath) const noexcept;
83
84 OConfigurationNode openNode( const char* _pAsciiPath ) const
85 {
86 return openNode( OUString::createFromAscii( _pAsciiPath ) );
87 }
88
97 OConfigurationNode createNode(const OUString& _rName) const noexcept;
98
104 bool removeNode(const OUString& _rName) const noexcept;
105
113 css::uno::Any getNodeValue(const OUString& _rPath) const noexcept;
114
115 css::uno::Any getNodeValue( const char* _pAsciiPath ) const
116 {
117 return getNodeValue( OUString::createFromAscii( _pAsciiPath ) );
118 }
119
126 bool setNodeValue(const OUString& _rPath, const css::uno::Any& _rValue) const noexcept;
127
128 bool setNodeValue( const char* _pAsciiPath, const css::uno::Any& _rValue ) const
129 {
130 return setNodeValue( OUString::createFromAscii( _pAsciiPath ), _rValue );
131 }
132
134 css::uno::Sequence< OUString >
135 getNodeNames() const noexcept;
136
138 virtual void clear() noexcept;
139
140 // meta information about the node
141
143 bool isSetNode() const;
144
146 bool hasByName(const OUString& _rName) const noexcept;
147
149 bool hasByHierarchicalName( const OUString& _rName ) const noexcept;
150
152 bool isValid() const { return m_xHierarchyAccess.is(); }
153
155 bool isReadonly() const { return !m_xReplaceAccess.is(); }
156
157 protected:
158 // OEventListenerAdapter
159 virtual void _disposing( const css::lang::EventObject& _rSource ) override;
160
161 protected:
163 {
165 NO_CALLER
166 };
167 OUString normalizeName(const OUString& _rName, NAMEORIGIN _eOrigin) const;
168 };
169
170 //= OConfigurationTreeRoot
171
178 {
179 css::uno::Reference< css::util::XChangesBatch >
184 const css::uno::Reference< css::uno::XInterface >& _rxRootNode
185 );
186
187 public:
190 {
194 CM_UPDATABLE
195 };
196
197 public:
202
206 const css::uno::Reference<css::uno::XComponentContext> & i_rContext,
207 const OUString& i_rNodePath,
208 const bool i_bUpdatable
209 );
210
226 static OConfigurationTreeRoot createWithProvider(
227 const css::uno::Reference< css::lang::XMultiServiceFactory >& _rxConfProvider,
228 const OUString& _rPath,
229 sal_Int32 _nDepth,
230 CREATION_MODE _eMode
231 );
232
245 static OConfigurationTreeRoot createWithComponentContext(const css::uno::Reference< css::uno::XComponentContext >& _rxContext,
246 const OUString& _rPath, sal_Int32 _nDepth = -1, CREATION_MODE _eMode = CM_UPDATABLE);
247
254 static OConfigurationTreeRoot tryCreateWithComponentContext( const css::uno::Reference< css::uno::XComponentContext >& rxContext,
255 const OUString& _rPath, sal_Int32 _nDepth = -1, CREATION_MODE _eMode = CM_UPDATABLE );
256
262 bool commit() const noexcept;
263
265 virtual void clear() noexcept override;
266 };
267
268} // namespace utl
269
270#endif // INCLUDED_UNOTOOLS_CONFIGNODE_HXX
271
272/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
a small wrapper around a configuration node.
Definition: confignode.hxx:41
css::uno::Reference< css::container::XNameReplace > m_xReplaceAccess
accessing children (mandatory interface of our UNO object)
Definition: confignode.hxx:48
bool m_bEscapeNames
modifying set nodes (optional interface of our UNO object)
Definition: confignode.hxx:51
OConfigurationNode()
constructs an empty and invalid node object
Definition: confignode.hxx:66
bool setNodeValue(const char *_pAsciiPath, const css::uno::Any &_rValue) const
Definition: confignode.hxx:128
css::uno::Reference< css::container::XHierarchicalNameAccess > m_xHierarchyAccess
Definition: confignode.hxx:44
css::uno::Reference< css::container::XNameContainer > m_xContainerAccess
replacing child values
Definition: confignode.hxx:50
OConfigurationNode(const css::uno::Reference< css::uno::XInterface > &_rxNode)
constructs a node object with an interface representing a node
css::uno::Reference< css::container::XNameAccess > m_xDirectAccess
accessing children grandchildren (mandatory interface of our UNO object)
Definition: confignode.hxx:46
css::uno::Any getNodeValue(const char *_pAsciiPath) const
Definition: confignode.hxx:115
const css::uno::Reference< css::container::XNameAccess > & getUNONode() const
Definition: confignode.hxx:62
bool setNodeValue(const OUString &_rPath, const css::uno::Any &_rValue) const noexcept
write a node valueThe value given is written into the node specified by the given relative path.
OConfigurationNode openNode(const char *_pAsciiPath) const
Definition: confignode.hxx:84
bool isReadonly() const
check whether the object is read-only of updatable
Definition: confignode.hxx:155
a specialized version of an OConfigurationNode, representing the root of a configuration sub treeOnly...
Definition: confignode.hxx:178
OConfigurationTreeRoot()
default ctorThe object constructed here is invalid (i.e.
Definition: confignode.hxx:201
css::uno::Reference< css::util::XChangesBatch > m_xCommitter
Definition: confignode.hxx:180
CREATION_MODE
modes to use when creating a top-level node object
Definition: confignode.hxx:190
@ CM_READONLY
open the node (i.e. sub tree) for read access only
Definition: confignode.hxx:192
OConfigurationTreeRoot(const css::uno::Reference< css::uno::XInterface > &_rxRootNode)
ctor for a readonly node
OConfigurationTreeRoot(const css::uno::Reference< css::uno::XComponentContext > &i_rContext, const OUString &i_rNodePath, const bool i_bUpdatable)
creates a configuration tree for the given path in the given mode
base class for non-UNO dispose listeners
#define UNOTOOLS_DLLPUBLIC