LibreOffice Module configmgr (master)  1
childaccess.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 <sal/config.h>
23 
24 #include <memory>
25 #include <optional>
26 #include <vector>
27 
28 #include <com/sun/star/container/XChild.hpp>
29 #include <com/sun/star/lang/XUnoTunnel.hpp>
30 #include <com/sun/star/uno/Reference.hxx>
31 #include <com/sun/star/uno/Sequence.hxx>
32 #include <rtl/ref.hxx>
33 #include <sal/types.h>
34 
35 #include "access.hxx"
36 
37 namespace com::sun::star::uno {
38  class Any;
39  class Type;
40  class XInterface;
41 }
42 
43 namespace configmgr {
44 
45 class Components;
46 class Modifications;
47 class Node;
48 class RootAccess;
49 
51  public Access, public css::container::XChild,
52  public css::lang::XUnoTunnel
53 {
54 public:
55  static css::uno::Sequence< sal_Int8 > const & getUnoTunnelId();
56 
58  Components & components, rtl::Reference< RootAccess > const & root,
59  rtl::Reference< Access > const & parent, OUString const & name,
60  rtl::Reference< Node > const & node);
61 
63  Components & components, rtl::Reference< RootAccess > const & root,
64  rtl::Reference< Node > const & node);
65 
66  virtual std::vector<OUString> getAbsolutePath() override;
67  virtual std::vector<OUString> getRelativePath() override;
68 
69  virtual OUString getRelativePathRepresentation() override;
70  virtual rtl::Reference< Node > getNode() override;
71 
72  virtual bool isFinalized() override;
73 
74  virtual OUString getNameInternal() override;
75 
77  virtual rtl::Reference< Access > getParentAccess() override;
78 
79  virtual void SAL_CALL acquire() noexcept override;
80  virtual void SAL_CALL release() noexcept override;
81 
82  virtual css::uno::Reference< css::uno::XInterface >
83  SAL_CALL getParent() override;
84 
85  virtual void SAL_CALL setParent(
86  css::uno::Reference< css::uno::XInterface > const &) override;
87 
88  virtual sal_Int64 SAL_CALL getSomething(
89  css::uno::Sequence< sal_Int8 > const & aIdentifier) override;
90 
91  void bind(
92  rtl::Reference< RootAccess > const & root,
93  rtl::Reference< Access > const & parent, OUString const & name)
94  noexcept;
95 
96  void unbind() noexcept;
97 
98  bool isInTransaction() const { return inTransaction_; }
99  void committed();
100  void setNode(rtl::Reference< Node > const & node);
101 
102  void setProperty(
103  css::uno::Any const & value,
104  Modifications * localModifications);
105 
106  css::uno::Any asValue();
107  static bool asSimpleValue(const rtl::Reference< Node > &rNode,
108  css::uno::Any &value,
109  Components &components);
110 
111  void commitChanges(bool valid, Modifications * globalModifications);
112 
113 private:
114  virtual ~ChildAccess() override;
115 
116  virtual void addTypes(
117  std::vector< css::uno::Type > * types) const override;
118 
119  virtual void addSupportedServiceNames(
120  std::vector<OUString> * services) override;
121 
122  virtual css::uno::Any SAL_CALL queryInterface(
123  css::uno::Type const & aType) override;
124 
126  rtl::Reference< Access > parent_; // null if free node
127  OUString name_;
129  std::optional< css::uno::Any > changedValue_;
131  // to determine if a free node can be inserted underneath some root
132  std::shared_ptr<osl::Mutex> lock_;
133 };
134 
135 }
136 
137 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
ChildAccess(Components &components, rtl::Reference< RootAccess > const &root, rtl::Reference< Access > const &parent, OUString const &name, rtl::Reference< Node > const &node)
Definition: childaccess.cxx:64
virtual OUString getRelativePathRepresentation() override
virtual void addSupportedServiceNames(std::vector< OUString > *services) override
void unbind() noexcept
virtual void addTypes(std::vector< css::uno::Type > *types) const override
virtual rtl::Reference< RootAccess > getRootAccess() override
std::shared_ptr< osl::Mutex > lock_
virtual void SAL_CALL release() noexcept override
void setNode(rtl::Reference< Node > const &node)
virtual std::vector< OUString > getAbsolutePath() override
Definition: childaccess.cxx:84
virtual rtl::Reference< Node > getNode() override
rtl::Reference< Node > node_
virtual css::uno::Any SAL_CALL queryInterface(css::uno::Type const &aType) override
virtual rtl::Reference< Access > getParentAccess() override
virtual void SAL_CALL acquire() noexcept override
virtual bool isFinalized() override
rtl::Reference< RootAccess > root_
static css::uno::Sequence< sal_Int8 > const & getUnoTunnelId()
Definition: childaccess.cxx:58
bool isInTransaction() const
Definition: childaccess.hxx:98
virtual std::vector< OUString > getRelativePath() override
Definition: childaccess.cxx:92
virtual css::uno::Reference< css::uno::XInterface > SAL_CALL getParent() override
void commitChanges(bool valid, Modifications *globalModifications)
std::optional< css::uno::Any > changedValue_
static bool asSimpleValue(const rtl::Reference< Node > &rNode, css::uno::Any &value, Components &components)
Can we quickly extract a simple value into value ? if so returns true.
virtual ~ChildAccess() override
std::vector< uno::Reference< sheet::XSpreadsheetDocument > > Components
void bind(rtl::Reference< RootAccess > const &root, rtl::Reference< Access > const &parent, OUString const &name) noexcept
virtual sal_Int64 SAL_CALL getSomething(css::uno::Sequence< sal_Int8 > const &aIdentifier) override
css::uno::Any asValue()
void setProperty(css::uno::Any const &value, Modifications *localModifications)
OUString name
Definition: components.cxx:83
rtl::Reference< Access > parent_
virtual void SAL_CALL setParent(css::uno::Reference< css::uno::XInterface > const &) override
virtual OUString getNameInternal() override