VectorImageRenderer: Remove TizenVectorImageRenderer dependency
[platform/core/uifw/dali-adaptor.git] / dali / internal / accessibility / bridge / bridge-editable-text.cpp
1 /*
2  * Copyright (c) 2021 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-editable-text.h>
20
21 // INTERNAL INCLUDES
22 #include <dali/internal/clipboard/common/clipboard-impl.h>
23
24 using namespace Dali::Accessibility;
25
26 void BridgeEditableText::RegisterInterfaces()
27 {
28   DBus::DBusInterfaceDescription desc{AtspiDbusInterfaceEditableText};
29   AddFunctionToInterface(desc, "CopyText", &BridgeEditableText::CopyText);
30   AddFunctionToInterface(desc, "CutText", &BridgeEditableText::CutText);
31   AddFunctionToInterface(desc, "DeleteText", &BridgeEditableText::DeleteText);
32   AddFunctionToInterface(desc, "InsertText", &BridgeEditableText::InsertText);
33   AddFunctionToInterface(desc, "PasteText", &BridgeEditableText::PasteText);
34   AddFunctionToInterface(desc, "SetTextContents", &BridgeEditableText::SetTextContents);
35   dbusServer.addInterface("/", desc, true);
36 }
37
38 EditableText* BridgeEditableText::FindSelf() const
39 {
40   auto s = BridgeBase::FindSelf();
41   assert(s);
42   auto s2 = dynamic_cast<EditableText*>(s);
43   if(!s2)
44     throw std::domain_error{"object " + s->GetAddress().ToString() + " doesn't have Text interface"};
45   return s2;
46 }
47
48 DBus::ValueOrError<bool> BridgeEditableText::CopyText(int32_t startPos, int32_t endPos)
49 {
50   return FindSelf()->CopyText(startPos, endPos);
51 }
52
53 DBus::ValueOrError<bool> BridgeEditableText::CutText(int32_t startPos, int32_t endPos)
54 {
55   return FindSelf()->CutText(startPos, endPos);
56 }
57
58 DBus::ValueOrError<bool> BridgeEditableText::DeleteText(int32_t startPos, int32_t endPos)
59 {
60   return FindSelf()->DeleteText(startPos, endPos);
61 }
62
63 DBus::ValueOrError<bool> BridgeEditableText::InsertText(int32_t startPos, std::string text, [[maybe_unused]] int32_t length)
64 {
65   return FindSelf()->InsertText(startPos, std::move(text));
66 }
67
68 DBus::ValueOrError<bool> BridgeEditableText::PasteText(int32_t pos)
69 {
70   // auto imfManager = Dali::Internal::Adaptor::ImfManager::Get();
71   // imfManager.SetCursorPosition( pos );
72   // auto clipboard = Dali::Internal::Adaptor::Clipboard::Get();
73   // clipboard.RequestItem();
74   // return true;
75   return false;
76 }
77
78 DBus::ValueOrError<bool> BridgeEditableText::SetTextContents(std::string newContents)
79 {
80   return FindSelf()->SetTextContents(std::move(newContents));
81 }