LibreOffice Module sdext (master)  1
PresenterConfigurationAccess.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 #ifndef INCLUDED_SDEXT_SOURCE_PRESENTER_PRESENTERCONFIGURATIONACCESS_HXX
21 #define INCLUDED_SDEXT_SOURCE_PRESENTER_PRESENTERCONFIGURATIONACCESS_HXX
22 
23 #include <rtl/ustring.hxx>
24 #include <com/sun/star/beans/XPropertySet.hpp>
25 #include <com/sun/star/container/XNameAccess.hpp>
26 #include <com/sun/star/container/XHierarchicalNameAccess.hpp>
27 #include <com/sun/star/uno/XComponentContext.hpp>
28 
29 #include <vector>
30 #include <functional>
31 
32 namespace sdext::presenter {
33 
49 {
50 public:
52  typedef ::std::function<bool (
53  const OUString&,
54  const css::uno::Reference<css::beans::XPropertySet>&)> Predicate;
55  static const OUString msPresenterScreenRootName;
56 
67  const css::uno::Reference<css::uno::XComponentContext>& rxContext,
68  const OUString& rsRootName,
69  WriteMode eMode);
70 
72 
77  css::uno::Any GetConfigurationNode (
78  const OUString& rsPathToNode);
79 
85  bool IsValid() const;
86 
89  bool GoToChild (const OUString& rsPathToNode);
90 
93  bool GoToChild (const Predicate& rPredicate);
94 
99  bool SetProperty (const OUString& rsPropertyName, const css::uno::Any& rValue);
100 
111  static css::uno::Any GetConfigurationNode (
112  const css::uno::Reference<css::container::XHierarchicalNameAccess>& rxNode,
113  const OUString& rsPathToNode);
114 
115  static css::uno::Reference<css::beans::XPropertySet> GetNodeProperties (
116  const css::uno::Reference<css::container::XHierarchicalNameAccess>& rxNode,
117  const OUString& rsPathToNode);
118 
123  void CommitChanges();
124 
125  typedef ::std::function<void (
126  const ::std::vector<css::uno::Any>&) > ItemProcessor;
127  typedef ::std::function<void (
128  const OUString&,
129  const css::uno::Reference<css::beans::XPropertySet>&) > PropertySetProcessor;
130 
143  static void ForAll (
144  const css::uno::Reference<css::container::XNameAccess>& rxContainer,
145  const ::std::vector<OUString>& rArguments,
146  const ItemProcessor& rProcessor);
147  static void ForAll (
148  const css::uno::Reference<css::container::XNameAccess>& rxContainer,
149  const PropertySetProcessor& rProcessor);
150 
151  static css::uno::Any Find (
152  const css::uno::Reference<css::container::XNameAccess>& rxContainer,
153  const Predicate& rPredicate);
154 
155  static bool IsStringPropertyEqual (
156  const OUString& rsValue,
157  const OUString& rsPropertyName,
158  const css::uno::Reference<css::beans::XPropertySet>& rxNode);
159 
164  static css::uno::Any GetProperty (
165  const css::uno::Reference<css::beans::XPropertySet>& rxProperties,
166  const OUString& rsKey);
167 
168 private:
169  css::uno::Reference<css::uno::XInterface> mxRoot;
170  css::uno::Any maNode;
171 };
172 
173 } // end of namespace sdext::tools
174 
175 #endif
176 
177 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
static void ForAll(const css::uno::Reference< css::container::XNameAccess > &rxContainer, const ::std::vector< OUString > &rArguments, const ItemProcessor &rProcessor)
Execute a functor for all elements of the given container.
static css::uno::Any GetProperty(const css::uno::Reference< css::beans::XPropertySet > &rxProperties, const OUString &rsKey)
This method wraps a call to getPropertyValue() and returns an empty Any instead of throwing an except...
css::uno::Reference< css::uno::XInterface > mxRoot
void CommitChanges()
Write any changes that have been made back to the configuration.
::std::function< bool(const OUString &, const css::uno::Reference< css::beans::XPropertySet > &)> Predicate
static css::uno::Reference< css::beans::XPropertySet > GetNodeProperties(const css::uno::Reference< css::container::XHierarchicalNameAccess > &rxNode, const OUString &rsPathToNode)
::std::function< void(const OUString &, const css::uno::Reference< css::beans::XPropertySet > &) > PropertySetProcessor
This class gives access to the configuration.
bool SetProperty(const OUString &rsPropertyName, const css::uno::Any &rValue)
Modify the property child of the currently focused node.
bool IsValid() const
Return when opening the configuration (via creating a new PresenterConfigurationAccess object)...
static css::uno::Any Find(const css::uno::Reference< css::container::XNameAccess > &rxContainer, const Predicate &rPredicate)
css::uno::Any GetConfigurationNode(const OUString &rsPathToNode)
Return a configuration node below the root of the called object.
PresenterConfigurationAccess(const css::uno::Reference< css::uno::XComponentContext > &rxContext, const OUString &rsRootName, WriteMode eMode)
Create a new object to access the configuration entries below the given root.
::std::function< void(const ::std::vector< css::uno::Any > &) > ItemProcessor
bool GoToChild(const OUString &rsPathToNode)
Move the focused node to the (possibly indirect) child specified by the given path.
static bool IsStringPropertyEqual(const OUString &rsValue, const OUString &rsPropertyName, const css::uno::Reference< css::beans::XPropertySet > &rxNode)
typedef void(CALLTYPE *GetFuncDataPtr)(sal_uInt16 &nNo