[Tizen][AT-SPI] Add Table and TableCell interfaces
[platform/core/uifw/dali-adaptor.git] / dali / internal / accessibility / bridge / bridge-table-cell.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-cell.h>
20
21 // INTERNAL INCLUDES
22 #include <dali/devel-api/atspi-interfaces/table.h>
23
24 using namespace Dali::Accessibility;
25
26 void BridgeTableCell::RegisterInterfaces()
27 {
28   DBus::DBusInterfaceDescription desc{Accessible::GetInterfaceName(AtspiInterface::TABLE_CELL)};
29
30   AddGetPropertyToInterface(desc, "Table", &BridgeTableCell::GetTable);
31   AddGetPropertyToInterface(desc, "Position", &BridgeTableCell::GetCellPosition);
32   AddGetPropertyToInterface(desc, "RowSpan", &BridgeTableCell::GetCellRowSpan);
33   AddGetPropertyToInterface(desc, "ColumnSpan", &BridgeTableCell::GetCellColumnSpan);
34   AddFunctionToInterface(desc, "GetRowColumnSpan", &BridgeTableCell::GetCellRowColumnSpan);
35
36   mDbusServer.addInterface("/", desc, true);
37 }
38
39 TableCell* BridgeTableCell::FindSelf() const
40 {
41   return FindCurrentObjectWithInterface<AtspiInterface::TABLE_CELL>();
42 }
43
44 DBus::ValueOrError<Accessible*> BridgeTableCell::GetTable()
45 {
46   return FindSelf()->GetTable();
47 }
48
49 DBus::ValueOrError<std::int32_t, std::int32_t> BridgeTableCell::GetCellPosition()
50 {
51   std::pair<int, int> position = FindSelf()->GetCellPosition();
52
53   return {position.first, position.second};
54 }
55
56 DBus::ValueOrError<std::int32_t> BridgeTableCell::GetCellRowSpan()
57 {
58   return FindSelf()->GetCellRowSpan();
59 }
60
61 DBus::ValueOrError<std::int32_t> BridgeTableCell::GetCellColumnSpan()
62 {
63   return FindSelf()->GetCellColumnSpan();
64 }
65
66 DBus::ValueOrError<std::int32_t, std::int32_t, std::int32_t, std::int32_t> BridgeTableCell::GetCellRowColumnSpan()
67 {
68   TableCell::RowColumnSpanType span = FindSelf()->GetCellRowColumnSpan();
69
70   return {span.row, span.column, span.rowSpan, span.columnSpan};
71 }