[Tizen][AT-SPI] Add Table and TableCell interfaces
[platform/core/uifw/dali-adaptor.git] / dali / internal / accessibility / bridge / bridge-table.cpp
1 /*
2  * Copyright (c) 2023 Samsung Electronics Co., Ltd.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  *
16  */
17
18 // CLASS HEADER
19 #include <dali/internal/accessibility/bridge/bridge-table.h>
20
21 // INTERNAL INCLUDES
22 #include <dali/devel-api/atspi-interfaces/table-cell.h>
23
24 using namespace Dali::Accessibility;
25
26 void BridgeTable::RegisterInterfaces()
27 {
28   DBus::DBusInterfaceDescription desc{Accessible::GetInterfaceName(AtspiInterface::TABLE)};
29
30   AddGetPropertyToInterface(desc, "NRows", &BridgeTable::GetRowCount);
31   AddGetPropertyToInterface(desc, "NColumns", &BridgeTable::GetColumnCount);
32   AddGetPropertyToInterface(desc, "NSelectedRows", &BridgeTable::GetSelectedRowCount);
33   AddGetPropertyToInterface(desc, "NSelectedColumns", &BridgeTable::GetSelectedColumnCount);
34   AddGetPropertyToInterface(desc, "Caption", &BridgeTable::GetCaption);
35   AddGetPropertyToInterface(desc, "Summary", &BridgeTable::GetSummary);
36   AddFunctionToInterface(desc, "GetAccessibleAt", &BridgeTable::GetCell);
37   AddFunctionToInterface(desc, "GetIndexAt", &BridgeTable::GetChildIndex);
38   AddFunctionToInterface(desc, "GetRowAtIndex", &BridgeTable::GetRowByChildIndex);
39   AddFunctionToInterface(desc, "GetColumnAtIndex", &BridgeTable::GetColumnByChildIndex);
40   AddFunctionToInterface(desc, "GetRowDescription", &BridgeTable::GetRowDescription);
41   AddFunctionToInterface(desc, "GetColumnDescription", &BridgeTable::GetColumnDescription);
42   AddFunctionToInterface(desc, "GetRowExtentAt", &BridgeTable::GetRowSpan);
43   AddFunctionToInterface(desc, "GetColumnExtentAt", &BridgeTable::GetColumnSpan);
44   AddFunctionToInterface(desc, "GetRowHeader", &BridgeTable::GetRowHeader);
45   AddFunctionToInterface(desc, "GetColumnHeader", &BridgeTable::GetColumnHeader);
46   AddFunctionToInterface(desc, "GetSelectedRows", &BridgeTable::GetSelectedRows);
47   AddFunctionToInterface(desc, "GetSelectedColumns", &BridgeTable::GetSelectedColumns);
48   AddFunctionToInterface(desc, "IsRowSelected", &BridgeTable::IsRowSelected);
49   AddFunctionToInterface(desc, "IsColumnSelected", &BridgeTable::IsColumnSelected);
50   AddFunctionToInterface(desc, "IsSelected", &BridgeTable::IsCellSelected);
51   AddFunctionToInterface(desc, "AddRowSelection", &BridgeTable::AddRowSelection);
52   AddFunctionToInterface(desc, "AddColumnSelection", &BridgeTable::AddColumnSelection);
53   AddFunctionToInterface(desc, "RemoveRowSelection", &BridgeTable::RemoveRowSelection);
54   AddFunctionToInterface(desc, "RemoveColumnSelection", &BridgeTable::RemoveColumnSelection);
55   AddFunctionToInterface(desc, "GetRowColumnExtentsAtIndex", &BridgeTable::GetRowColumnSpan);
56
57   mDbusServer.addInterface("/", desc, true);
58 }
59
60 Table* BridgeTable::FindSelf() const
61 {
62   return FindCurrentObjectWithInterface<AtspiInterface::TABLE>();
63 }
64
65 DBus::ValueOrError<std::int32_t> BridgeTable::GetRowCount()
66 {
67   return FindSelf()->GetRowCount();
68 }
69
70 DBus::ValueOrError<std::int32_t> BridgeTable::GetColumnCount()
71 {
72   return FindSelf()->GetColumnCount();
73 }
74
75 DBus::ValueOrError<std::int32_t> BridgeTable::GetSelectedRowCount()
76 {
77   return FindSelf()->GetSelectedRowCount();
78 }
79
80 DBus::ValueOrError<std::int32_t> BridgeTable::GetSelectedColumnCount()
81 {
82   return FindSelf()->GetSelectedColumnCount();
83 }
84
85 DBus::ValueOrError<Accessible*> BridgeTable::GetCaption()
86 {
87   return FindSelf()->GetCaption();
88 }
89
90 DBus::ValueOrError<Accessible*> BridgeTable::GetSummary()
91 {
92   return FindSelf()->GetSummary();
93 }
94
95 DBus::ValueOrError<Accessible*> BridgeTable::GetCell(std::int32_t row, std::int32_t column)
96 {
97   return FindSelf()->GetCell(row, column);
98 }
99
100 DBus::ValueOrError<std::int32_t> BridgeTable::GetChildIndex(std::int32_t row, std::int32_t column)
101 {
102   return static_cast<std::int32_t>(FindSelf()->GetChildIndex(row, column));
103 }
104
105 DBus::ValueOrError<std::int32_t> BridgeTable::GetRowByChildIndex(std::int32_t childIndex)
106 {
107   return FindSelf()->GetRowByChildIndex(static_cast<std::size_t>(childIndex));
108 }
109
110 DBus::ValueOrError<std::int32_t> BridgeTable::GetColumnByChildIndex(std::int32_t childIndex)
111 {
112   return FindSelf()->GetColumnByChildIndex(static_cast<std::size_t>(childIndex));
113 }
114
115 DBus::ValueOrError<std::string> BridgeTable::GetRowDescription(std::int32_t row)
116 {
117   return FindSelf()->GetRowDescription(row);
118 }
119
120 DBus::ValueOrError<std::string> BridgeTable::GetColumnDescription(std::int32_t column)
121 {
122   return FindSelf()->GetColumnDescription(column);
123 }
124
125 DBus::ValueOrError<std::int32_t> BridgeTable::GetRowSpan(std::int32_t row, std::int32_t column)
126 {
127   return FindSelf()->GetRowSpan(row, column);
128 }
129
130 DBus::ValueOrError<std::int32_t> BridgeTable::GetColumnSpan(std::int32_t row, std::int32_t column)
131 {
132   return FindSelf()->GetColumnSpan(row, column);
133 }
134
135 DBus::ValueOrError<Accessible*> BridgeTable::GetRowHeader(std::int32_t row)
136 {
137   return FindSelf()->GetRowHeader(row);
138 }
139
140 DBus::ValueOrError<Accessible*> BridgeTable::GetColumnHeader(std::int32_t column)
141 {
142   return FindSelf()->GetColumnHeader(column);
143 }
144
145 DBus::ValueOrError<std::vector<std::int32_t>> BridgeTable::GetSelectedRows()
146 {
147   return FindSelf()->GetSelectedRows();
148 }
149
150 DBus::ValueOrError<std::vector<std::int32_t>> BridgeTable::GetSelectedColumns()
151 {
152   return FindSelf()->GetSelectedColumns();
153 }
154
155 DBus::ValueOrError<bool> BridgeTable::IsRowSelected(std::int32_t row)
156 {
157   return FindSelf()->IsRowSelected(row);
158 }
159
160 DBus::ValueOrError<bool> BridgeTable::IsColumnSelected(std::int32_t column)
161 {
162   return FindSelf()->IsColumnSelected(column);
163 }
164
165 DBus::ValueOrError<bool> BridgeTable::IsCellSelected(std::int32_t row, std::int32_t column)
166 {
167   return FindSelf()->IsCellSelected(row, column);
168 }
169
170 DBus::ValueOrError<bool> BridgeTable::AddRowSelection(std::int32_t row)
171 {
172   return FindSelf()->AddRowSelection(row);
173 }
174
175 DBus::ValueOrError<bool> BridgeTable::AddColumnSelection(std::int32_t column)
176 {
177   return FindSelf()->AddColumnSelection(column);
178 }
179
180 DBus::ValueOrError<bool> BridgeTable::RemoveRowSelection(std::int32_t row)
181 {
182   return FindSelf()->RemoveRowSelection(row);
183 }
184
185 DBus::ValueOrError<bool> BridgeTable::RemoveColumnSelection(std::int32_t column)
186 {
187   return FindSelf()->RemoveColumnSelection(column);
188 }
189
190 BridgeTable::RowColumnSpanType BridgeTable::GetRowColumnSpan(std::int32_t childIndex)
191 {
192   Table::RowColumnSpanType span = FindSelf()->GetRowColumnSpan(static_cast<std::size_t>(childIndex));
193
194   return {span.success, span.row, span.column, span.rowSpan, span.columnSpan, span.isSelected};
195 }