22 #include <com/sun/star/lang/XMultiServiceFactory.hpp>
23 #include <com/sun/star/container/XHierarchicalNameAccess.hpp>
24 #include <com/sun/star/configuration/theDefaultProvider.hpp>
25 #include <com/sun/star/util/XChangesBatch.hpp>
27 #include <osl/diagnose.h>
38 const OUString& rsRootName,
53 OUString sAccessService;
55 sAccessService =
"com.sun.star.configuration.ConfigurationAccess";
57 sAccessService =
"com.sun.star.configuration.ConfigurationUpdateAccess";
59 Reference<lang::XMultiServiceFactory> xProvider =
60 configuration::theDefaultProvider::get( rxContext );
61 mxRoot = xProvider->createInstanceWithArguments(
62 sAccessService, aCreationArguments);
84 Reference<container::XHierarchicalNameAccess>(
mxRoot, UNO_QUERY),
93 Reference<container::XHierarchicalNameAccess> xNode (
maNode, UNO_QUERY);
97 Reference<container::XHierarchicalNameAccess>(
maNode, UNO_QUERY),
99 if (Reference<XInterface>(
maNode, UNO_QUERY).is())
113 if (Reference<XInterface>(
maNode, UNO_QUERY).is())
121 const OUString& rsPropertyName,
125 if (xProperties.is())
127 xProperties->setPropertyValue(rsPropertyName, rValue);
135 const css::uno::Reference<css::container::XHierarchicalNameAccess>& rxNode,
136 const OUString& sPathToNode)
138 if (sPathToNode.isEmpty())
145 return rxNode->getByHierarchicalName(sPathToNode);
150 TOOLS_WARN_EXCEPTION(
"sdext.presenter",
"caught exception while getting configuration node " << sPathToNode);
157 const css::uno::Reference<css::container::XHierarchicalNameAccess>& rxNode,
158 const OUString& rsPathToNode)
165 Reference<util::XChangesBatch> xConfiguration (
mxRoot, UNO_QUERY);
166 if (xConfiguration.is())
167 xConfiguration->commitChanges();
172 const ::std::vector<OUString>& rArguments,
173 const ItemProcessor& rProcessor)
175 if (!rxContainer.is())
178 ::std::vector<Any> aValues(rArguments.size());
180 for (
const OUString& rsKey : aKeys)
182 bool bHasAllValues (
true);
185 OSL_ASSERT(xSet.is());
190 for (
size_t nValueIndex=0; nValueIndex<aValues.size(); ++nValueIndex)
192 if ( ! xSetItem->hasByName(rArguments[nValueIndex]))
193 bHasAllValues =
false;
195 aValues[nValueIndex] = xSetItem->getByName(rArguments[nValueIndex]);
199 bHasAllValues =
false;
207 const PropertySetProcessor& rProcessor)
209 if (rxContainer.is())
212 for (
const OUString& rsKey : aKeys)
216 rProcessor(rsKey, xSet);
225 if (rxContainer.is())
228 for (
const auto& rKey : aKeys)
231 rxContainer->getByName(rKey),
233 if (xProperties.is())
234 if (rPredicate(rKey, xProperties))
235 return Any(xProperties);
242 std::u16string_view rsValue,
243 const OUString& rsPropertyName,
244 const css::uno::Reference<css::beans::XPropertySet>& rxNode)
247 if (
GetProperty(rxNode, rsPropertyName) >>= sValue)
248 return sValue == rsValue;
255 const OUString& rsKey)
257 OSL_ASSERT(rxProperties.is());
258 if ( ! rxProperties.is())
264 if ( ! xInfo->hasPropertyByName(rsKey))
266 return rxProperties->getPropertyValue(rsKey);
268 catch (beans::UnknownPropertyException&)
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
~PresenterConfigurationAccess()
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)
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)...
#define DBG_UNHANDLED_EXCEPTION(...)
static css::uno::Any Find(const css::uno::Reference< css::container::XNameAccess > &rxContainer, const Predicate &rPredicate)
#define TOOLS_WARN_EXCEPTION(area, stream)
css::uno::Sequence< css::uno::Any > InitAnyPropertySequence(::std::initializer_list< ::std::pair< OUString, css::uno::Any > > vInit)
css::uno::Any GetConfigurationNode(const OUString &rsPathToNode)
Return a configuration node below the root of the called object.
static bool IsStringPropertyEqual(std::u16string_view rsValue, const OUString &rsPropertyName, const css::uno::Reference< css::beans::XPropertySet > &rxNode)
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.
bool GoToChild(const OUString &rsPathToNode)
Move the focused node to the (possibly indirect) child specified by the given path.