blob: 8627d665f2ce9962065911cd85c3bf2a70c4e315 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
|
#ifndef DALI_INTERNAL_ACCESSIBILITY_ACCESSIBLE_OBJECTS_HOLDER_H
#define DALI_INTERNAL_ACCESSIBILITY_ACCESSIBLE_OBJECTS_HOLDER_H
/*
* Copyright (c) 2024 Samsung Electronics Co., Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*/
// INTERNAL INCLUDES
#include <dali/devel-api/atspi-interfaces/accessible.h>
/**
* @brief The BridgeText class is to correspond with Dali::Accessibility::Text.
*/
class BridgeData
{
public:
/**
* @brief Gets the string of the path excluding the specified prefix.
*
* @param path The path to get
* @return The string stripped of the specific prefix
*/
static std::string StripPrefix(const std::string& path);
/**
* @brief Finds the Accessible object according to the path.
*
* @param[in] path The path for Accessible object
* @return The Accessible object corresponding to the path
*/
Dali::Accessibility::Accessible* Find(const std::string& path) const;
/**
* @brief Returns the target object of the currently executed DBus method call.
*
* @return The Accessible object
* @note When a DBus method is called on some object, this target object (`currentObject`) is temporarily saved by the bridge,
* because DBus handles the invocation target separately from the method arguments.
* We then use the saved object inside the 'glue' method (e.g. BridgeValue::GetMinimum)
* to call the equivalent method on the respective C++ object (this could be ScrollBar::AccessibleImpl::GetMinimum in the example given).
*/
Dali::Accessibility::Accessible* FindCurrentObject() const;
/**
* @brief Returns the target object of the currently executed DBus method call.
*
* This method tries to downcast the return value of FindCurrentObject() to the requested type,
* issuing an error reply to the DBus caller if the requested type is not implemented. Whether
* a given type is implemented is decided based on the return value of Accessible::GetInterfaces()
* for the current object.
*
* @tparam I The requested AT-SPI interface
* @return The Accessible object (cast to a more derived type)
*
* @see FindCurrentObject()
* @see Dali::Accessibility::AtspiInterface
* @see Dali::Accessibility::AtspiInterfaceType
* @see Dali::Accessibility::Accessible::GetInterfaces()
*/
template<Dali::Accessibility::AtspiInterface I>
auto* FindCurrentObjectWithInterface() const
{
using Type = Dali::Accessibility::AtspiInterfaceType<I>;
Type* result;
auto* currentObject = FindCurrentObject();
DALI_ASSERT_DEBUG(currentObject); // FindCurrentObject() throws domain_error
if(!(result = Dali::Accessibility::Accessible::DownCast<I>(currentObject)))
{
std::stringstream s;
s << "Object " << currentObject->GetAddress().ToString();
s << " does not implement ";
s << Dali::Accessibility::Accessible::GetInterfaceName(I);
throw std::domain_error{s.str()};
}
return result;
}
void AddKnownObject(const Accessible* object);
void RemoveKnownObject(const Accessible* object);
/**
* @brief Sets the global extents offset.
*
* This offset will be added during serialization of GetExtents() return value to D-Bus.
* Local calls to GetExtents() are unaffected.
*
* @param[in] x Horizontal offset
* @param[in] y Vertical offset
*
* @see Dali::Accessibility::Bridge::SetSocketOffset()
* @see Dali::Accessibility::Component::GetExtents()
*/
using OffsetType = pair::<int32_t, int32_t>;
void SetExtentsOffset(int32_t x, int32_t y);
OffsetType GetExtentsOffset() const;
private:
std::unordered_set<const Accessible*> mKnownObjects;
OffsetType mExtentsOffset{0, 0};
};
#endif // DALI_INTERNAL_ACCESSIBILITY_ACCESSIBLE_OBJECTS_HOLDER_H
|