2 * Copyright (c) 2021 Samsung Electronics Co., Ltd.
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
8 * http://www.apache.org/licenses/LICENSE-2.0
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.
19 #include <dali/internal/accessibility/bridge/bridge-editable-text.h>
22 #include <dali/internal/clipboard/common/clipboard-impl.h>
24 using namespace Dali::Accessibility;
26 void BridgeEditableText::RegisterInterfaces()
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);
38 EditableText* BridgeEditableText::FindSelf() const
40 auto s = BridgeBase::FindSelf();
42 auto s2 = dynamic_cast<EditableText*>(s);
44 throw std::domain_error{"object " + s->GetAddress().ToString() + " doesn't have Text interface"};
48 DBus::ValueOrError<bool> BridgeEditableText::CopyText(int32_t startPos, int32_t endPos)
50 return FindSelf()->CopyText(startPos, endPos);
53 DBus::ValueOrError<bool> BridgeEditableText::CutText(int32_t startPos, int32_t endPos)
55 return FindSelf()->CutText(startPos, endPos);
58 DBus::ValueOrError<bool> BridgeEditableText::DeleteText(int32_t startPos, int32_t endPos)
60 return FindSelf()->DeleteText(startPos, endPos);
63 DBus::ValueOrError<bool> BridgeEditableText::InsertText(int32_t startPos, std::string text, [[maybe_unused]] int32_t length)
65 return FindSelf()->InsertText(startPos, std::move(text));
68 DBus::ValueOrError<bool> BridgeEditableText::PasteText(int32_t pos)
70 // auto imfManager = Dali::Internal::Adaptor::ImfManager::Get();
71 // imfManager.SetCursorPosition( pos );
72 // auto clipboard = Dali::Internal::Adaptor::Clipboard::Get();
73 // clipboard.RequestItem();
78 DBus::ValueOrError<bool> BridgeEditableText::SetTextContents(std::string newContents)
80 return FindSelf()->SetTextContents(std::move(newContents));