Introduce getTextMinBoundingRect command 73/280073/5 submit/tizen/20220826.010518
authorChihun Jeong <chihun.jeong@samsung.com>
Wed, 24 Aug 2022 07:20:26 +0000 (16:20 +0900)
committerWoochanlee <wc0917.lee@samsung.com>
Fri, 26 Aug 2022 00:49:27 +0000 (09:49 +0900)
Change-Id: I3a7679b6dddd2126e8cfefdad4428700a5f8f5d5

17 files changed:
libaurum/inc/Accessibility/AccessibleNode.h
libaurum/inc/Impl/Accessibility/AtspiAccessibleNode.h
libaurum/inc/Impl/Accessibility/AtspiWrapper.h
libaurum/inc/Impl/Accessibility/MockAccessibleNode.h
libaurum/inc/UiObject.h
libaurum/src/Accessibility/AccessibleNode.cc
libaurum/src/Impl/Accessibility/AtspiAccessibleNode.cc
libaurum/src/Impl/Accessibility/AtspiWrapper.cc
libaurum/src/Impl/Accessibility/MockAccessibleNode.cc
libaurum/src/UiObject.cc
org.tizen.aurum-bootstrap/inc/AurumServiceImpl.h
org.tizen.aurum-bootstrap/inc/Commands/Commands.h
org.tizen.aurum-bootstrap/inc/Commands/GetTextMinBoundingRectCommand.h [new file with mode: 0644]
org.tizen.aurum-bootstrap/meson.build
org.tizen.aurum-bootstrap/src/AurumServiceImpl.cc
org.tizen.aurum-bootstrap/src/Commands/GetTextMinBoundingRectCommand.cc [new file with mode: 0644]
protocol/aurum.proto

index 2fa3a41..be58257 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2021 Samsung Electronics Co., Ltd All Rights Reserved
+ * Copyright (c) 2022 Samsung Electronics Co., Ltd All Rights Reserved
  *
  *  Licensed under the Apache License, Version 2.0 (the "License");
  *  you may not use this file except in compliance with the License.
@@ -277,6 +277,12 @@ public:
     double getIncrement() const;
 
     /**
+     * @copydoc UiObject::getTextMinBoundingRect()
+     *
+     */
+    Rect<int> getTextMinBoundingRect() const;
+
+    /**
      * @copydoc UiObject::isCheckable()
      */
     bool isCheckable() const;
@@ -406,6 +412,11 @@ public:
     virtual bool setFocus() = 0;
 
     /**
+     * @copydoc UIObject::updateTextMinBoundingRect()
+     */
+    virtual void updateTextMinBoundingRect() = 0;
+
+    /**
      * @brief Updates Node information from atspi server.
      *
      * @since_tizen 6.5
@@ -516,6 +527,7 @@ protected:
     std::string mToolkitName;
     Rect<int> mScreenBoundingBox;
     Rect<int> mWindowBoundingBox;
+    Rect<int> mTextMinBoundingRect;
     int mSupportingIfaces;
     int mFeatureProperty;
     int mPid;
index ffd1816..6fa1ce3 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2021 Samsung Electronics Co., Ltd All Rights Reserved
+ * Copyright (c) 2022 Samsung Electronics Co., Ltd All Rights Reserved
  *
  *  Licensed under the Apache License, Version 2.0 (the "License");
  *  you may not use this file except in compliance with the License.
@@ -137,6 +137,11 @@ public:
     void updatePid() override;
 
     /**
+     * @copydoc UiObject::updateTextMinBoundingRect()
+     */
+    void updateTextMinBoundingRect() override;
+
+    /**
      * @copydoc UiObject::setFocus()
      */
     bool setFocus() override;
index d34ceba..0389c30 100644 (file)
@@ -68,6 +68,7 @@ public:
     static gdouble Atspi_value_get_minimum_increment(AtspiValue *iface, GError **error);
     static guint Atspi_accessible_get_process_id(AtspiAccessible *node, GError **error);
     static gchar *Atspi_accessible_get_toolkit_name(AtspiAccessible *node, GError **error);
+    static AtspiRect *Atspi_text_get_minimum_bounding_rectangles(AtspiText* obj, gint start_offset, gint end_offset, AtspiCoordType type, GError** error);
 
 private:
     static std::recursive_mutex mMutex;
index 2a8afa6..abb23c4 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2021 Samsung Electronics Co., Ltd All Rights Reserved
+ * Copyright (c) 2022 Samsung Electronics Co., Ltd All Rights Reserved
  *
  *  Licensed under the Apache License, Version 2.0 (the "License");
  *  you may not use this file except in compliance with the License.
@@ -147,6 +147,12 @@ public:
      */
     bool setFocus() override;
 
+    /**
+     * @brief TBD
+     * @since_tizen 7.0
+     */
+    void updateTextMinBoundingRect() override;
+
        /**
      * @brief TBD
      * @since_tizen 6.5
index 1863560..bb50d19 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2021 Samsung Electronics Co., Ltd All Rights Reserved
+ * Copyright (c) 2022 Samsung Electronics Co., Ltd All Rights Reserved
  *
  *  Licensed under the Apache License, Version 2.0 (the "License");
  *  you may not use this file except in compliance with the License.
@@ -422,6 +422,16 @@ public:
     const double getIncrement() const;
 
     /**
+     * @brief Gets text object's minimum bounding rectangle(MBR).
+     *        It works only for NUI Text Object.
+     *
+     * @return Rect
+     *
+     * @since_tizen 7.0
+     */
+    const Rect<int> getTextMinBoundingRect() const;
+
+    /**
      * @brief Sets object's value.
      *
      * @param[in] double value
@@ -601,6 +611,15 @@ public:
      * @since_tizen 7.0
      */
     void updateToolkitName() const;
+
+       /*
+     * @brief Updates text object's minimum bounding rectangle(MBR).
+     *        It works only for NUI Text Object.
+     *
+     * @since_tizen 7.0
+     */
+    void updateTextMinBoundingRect() const;
+
     /**
      * @brief Sets focus to object.
      *
index e7bdbd1..92e9cb6 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2021 Samsung Electronics Co., Ltd All Rights Reserved
+ * Copyright (c) 2022 Samsung Electronics Co., Ltd All Rights Reserved
  *
  *  Licensed under the Apache License, Version 2.0 (the "License");
  *  you may not use this file except in compliance with the License.
@@ -270,3 +270,8 @@ int AccessibleNode::getPid() const
 {
     return mPid;
 }
+
+Rect<int> AccessibleNode::getTextMinBoundingRect() const
+{
+    return mTextMinBoundingRect;
+}
\ No newline at end of file
index 4130cd4..00e5f7f 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2021 Samsung Electronics Co., Ltd All Rights Reserved
+ * Copyright (c) 2022 Samsung Electronics Co., Ltd All Rights Reserved
  *
  *  Licensed under the Apache License, Version 2.0 (the "License");
  *  you may not use this file except in compliance with the License.
@@ -272,6 +272,27 @@ void AtspiAccessibleNode::updatePid()
     mPid = AtspiWrapper::Atspi_accessible_get_process_id(mNode, NULL);
 }
 
+void AtspiAccessibleNode::updateTextMinBoundingRect()
+{
+    AtspiWrapper::Atspi_accessible_clear_cache(mNode);
+
+    AtspiText *text = atspi_accessible_get_text_iface(mNode);
+    if (text)
+    {
+        gint cc = atspi_text_get_character_count(text, NULL);
+        AtspiRect *textMinBoundingRectExtent = AtspiWrapper::Atspi_text_get_minimum_bounding_rectangles(text, 0, cc, ATSPI_COORD_TYPE_WINDOW, NULL);
+
+        if (textMinBoundingRectExtent) {
+            mTextMinBoundingRect =
+                Rect<int>{textMinBoundingRectExtent->x, textMinBoundingRectExtent->y, textMinBoundingRectExtent->x + textMinBoundingRectExtent->width,
+                    textMinBoundingRectExtent->y + textMinBoundingRectExtent->height};
+            g_free(textMinBoundingRectExtent);
+        }
+
+        g_object_unref(text);
+    }
+}
+
 bool AtspiAccessibleNode::setFocus()
 {
     AtspiComponent *component = AtspiWrapper::Atspi_accessible_get_component_iface(mNode);
index ceef6cf..b923969 100644 (file)
@@ -218,3 +218,10 @@ gchar *AtspiWrapper::Atspi_accessible_get_toolkit_name(AtspiAccessible *node, GE
     std::unique_lock<std::recursive_mutex> lock(mMutex);
     return atspi_accessible_get_toolkit_name(node, error);
 }
+
+AtspiRect *AtspiWrapper::Atspi_text_get_minimum_bounding_rectangles(AtspiText* obj, gint start_offset, gint end_offset, AtspiCoordType type, GError** error)
+{
+    std::unique_lock<std::recursive_mutex> lock(mMutex);
+    return atspi_text_get_range_extents(obj, start_offset, end_offset, type, error);
+}
+
index 1650e10..a397f37 100644 (file)
@@ -130,6 +130,10 @@ bool MockAccessibleNode::setFocus()
     return false;
 }
 
+void MockAccessibleNode::updateTextMinBoundingRect()
+{
+}
+
 void MockAccessibleNode::refresh(bool updateAll)
 {
 }
index c975859..577ef65 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2021 Samsung Electronics Co., Ltd All Rights Reserved
+ * Copyright (c) 2022 Samsung Electronics Co., Ltd All Rights Reserved
  *
  *  Licensed under the Apache License, Version 2.0 (the "License");
  *  you may not use this file except in compliance with the License.
@@ -219,6 +219,11 @@ const double UiObject::getIncrement() const
     return getAccessibleNode()->getIncrement();
 }
 
+const Rect<int> UiObject::getTextMinBoundingRect() const
+{
+    return getAccessibleNode()->getTextMinBoundingRect();
+}
+
 bool UiObject::setValue(double value)
 {
     return getAccessibleNode()->setValue(value);
@@ -370,6 +375,11 @@ void UiObject::updateToolkitName() const
     mNode->updateToolkitName();
 }
 
+void UiObject::updateTextMinBoundingRect() const
+{
+    mNode->updateTextMinBoundingRect();
+}
+
 bool UiObject::setFocus() const
 {
     return mNode->setFocus();
index deb020b..5857444 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2021 Samsung Electronics Co., Ltd All Rights Reserved
+ * Copyright (c) 2022 Samsung Electronics Co., Ltd All Rights Reserved
  *
  *  Licensed under the Apache License, Version 2.0 (the "License");
  *  you may not use this file except in compliance with the License.
@@ -126,6 +126,10 @@ public:
     ::grpc::Status enableScreenAnalyzer(::grpc::ServerContext *context,
                                         const ::aurum::ReqEnableScreenAnalyzer *request,
                                         ::aurum::RspEnableScreenAnalyzer *response) override;
+    ::grpc::Status getTextMinBoundingRect(::grpc::ServerContext *context,
+                            const ::aurum::ReqGetTextMinBoundingRect *request,
+                            ::aurum::RspGetTextMinBoundingRect *response) override;
 };
 
 #endif
+
index 6445640..650b31b 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2021 Samsung Electronics Co., Ltd All Rights Reserved
+ * Copyright (c) 2022 Samsung Electronics Co., Ltd All Rights Reserved
  *
  *  Licensed under the Apache License, Version 2.0 (the "License");
  *  you may not use this file except in compliance with the License.
@@ -51,3 +51,5 @@
 #include "Commands/SetFocusCommand.h"
 #include "Commands/GetActiveAppToolkitNameCommand.h"
 #include "Commands/EnableScreenAnalyzerCommand.h"
+
+#include "Commands/GetTextMinBoundingRectCommand.h"
diff --git a/org.tizen.aurum-bootstrap/inc/Commands/GetTextMinBoundingRectCommand.h b/org.tizen.aurum-bootstrap/inc/Commands/GetTextMinBoundingRectCommand.h
new file mode 100644 (file)
index 0000000..bc04262
--- /dev/null
@@ -0,0 +1,34 @@
+/*
+ * Copyright (c) 2022 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ *  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.
+ *
+ */
+
+#include <gio/gio.h>
+#include <grpcpp/grpcpp.h>
+#include "Commands/Command.h"
+#include "ObjectMapper.h"
+#include <aurum.grpc.pb.h>
+#include "config.h"
+
+class GetTextMinBoundingRectCommand : public Command {
+private:
+    const ::aurum::ReqGetTextMinBoundingRect *mRequest;
+    ::aurum::RspGetTextMinBoundingRect *mResponse;
+
+public:
+    GetTextMinBoundingRectCommand(const ::aurum::ReqGetTextMinBoundingRect *request,
+                   ::aurum::RspGetTextMinBoundingRect *response);
+    ::grpc::Status execute() override;
+};
\ No newline at end of file
index fb99f18..3f20d19 100644 (file)
@@ -47,6 +47,7 @@ bootstrap_svr_src += [
    files('src/Commands/SetFocusCommand.cc'),
    files('src/Commands/GetActiveAppToolkitNameCommand.cc'),
    files('src/Commands/EnableScreenAnalyzerCommand.cc'),
+   files('src/Commands/GetTextMinBoundingRectCommand.cc'),
 ]
 
 bootstrap_svr_dep = [
index 00abf4e..477ab5e 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2021 Samsung Electronics Co., Ltd All Rights Reserved
+ * Copyright (c) 2022 Samsung Electronics Co., Ltd All Rights Reserved
  *
  *  Licensed under the Apache License, Version 2.0 (the "License");
  *  you may not use this file except in compliance with the License.
@@ -281,3 +281,11 @@ aurumServiceImpl::~aurumServiceImpl()
     return execute(cmd.get(), true);
 }
 
+::grpc::Status aurumServiceImpl::getTextMinBoundingRect(::grpc::ServerContext *context,
+                                         const ::aurum::ReqGetTextMinBoundingRect *request,
+                                         ::aurum::RspGetTextMinBoundingRect *response)
+{
+    std::unique_ptr<GetTextMinBoundingRectCommand> cmd = std::make_unique<GetTextMinBoundingRectCommand>(request, response);
+    return execute(cmd.get(), true);
+}
+
diff --git a/org.tizen.aurum-bootstrap/src/Commands/GetTextMinBoundingRectCommand.cc b/org.tizen.aurum-bootstrap/src/Commands/GetTextMinBoundingRectCommand.cc
new file mode 100644 (file)
index 0000000..c512ae5
--- /dev/null
@@ -0,0 +1,50 @@
+/*
+ * Copyright (c) 2022 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ *  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.
+ *
+ */
+
+#include "bootstrap.h"
+#include "GetTextMinBoundingRectCommand.h"
+#include "UiObject.h"
+
+GetTextMinBoundingRectCommand::GetTextMinBoundingRectCommand(const ::aurum::ReqGetTextMinBoundingRect *request,
+                               ::aurum::RspGetTextMinBoundingRect *response)
+    : mRequest{request}, mResponse{response}
+{
+}
+
+::grpc::Status GetTextMinBoundingRectCommand::execute()
+{
+    LOGI("GetTextMinBoundingRect --------------- ");
+
+    ObjectMapper *mObjMap = ObjectMapper::getInstance();
+    std::shared_ptr<UiObject> obj = mObjMap->getElement(mRequest->elementid());
+    if (obj) {
+        obj->updateTextMinBoundingRect();
+        ::aurum::Rect *rect = mResponse->mutable_size();
+        const Rect<int> &size = obj->getTextMinBoundingRect();
+
+        rect->set_x(size.mTopLeft.x);
+        rect->set_y(size.mTopLeft.y);
+        rect->set_width(size.width());
+        rect->set_height(size.height());
+
+        mResponse->set_status(::aurum::RspStatus::OK);
+    }
+    else
+        mResponse->set_status(::aurum::RspStatus::ERROR);
+
+    return grpc::Status::OK;
+}
\ No newline at end of file
index 51600f5..0e076f9 100644 (file)
@@ -35,6 +35,7 @@ service Bootstrap {
    rpc findElements(ReqFindElements) returns (RspFindElements) {}
    rpc getActiveAppToolkitName(ReqGetActiveAppToolkitName) returns (RspGetActiveAppToolkitName) {}
    rpc enableScreenAnalyzer(ReqEnableScreenAnalyzer) returns (RspEnableScreenAnalyzer) {}
+   rpc getTextMinBoundingRect(ReqGetTextMinBoundingRect) returns (RspGetTextMinBoundingRect) {}
 }
 
 // ------------------------------------ //
@@ -593,3 +594,12 @@ message RspEnableScreenAnalyzer {
    RspStatus status = 1;
 }
 
+message ReqGetTextMinBoundingRect {
+   string elementId = 1;
+}
+
+message RspGetTextMinBoundingRect {
+   RspStatus status = 1;
+   Rect size = 2;
+}
+