[AT-SPI] text: add "GetRangeExtents" interface 59/271759/5
authorShinwoo Kim <cinoo.kim@samsung.com>
Mon, 28 Feb 2022 07:46:23 +0000 (16:46 +0900)
committerShinwoo Kim <cinoo.kim@samsung.com>
Fri, 4 Mar 2022 04:12:59 +0000 (13:12 +0900)
This interface will be used for getting MBR(Minimum Bounding Rectangle)
with following usage on the AT client side.

  cc = atspi_text_get_character_count(text, NULL);
  rect = atspi_text_get_range_extents(text, 0, cc, ATSPI_COORD_TYPE_WINDOW, NULL);

Change-Id: Iea4881269ee53807d75c0236c35672be7208fdac

dali/devel-api/atspi-interfaces/text.h
dali/internal/accessibility/bridge/bridge-impl.cpp
dali/internal/accessibility/bridge/bridge-text.cpp
dali/internal/accessibility/bridge/bridge-text.h

index f632807..0606fc8 100644 (file)
@@ -19,6 +19,7 @@
 
 // EXTERNAL INCLUDES
 #include <string>
+#include <dali/public-api/math/rect.h>
 
 // INTERNAL INCLUDES
 #include <dali/devel-api/adaptor-framework/accessibility.h>
@@ -120,6 +121,18 @@ public:
   virtual bool SetRangeOfSelection(std::size_t selectionIndex, std::size_t startOffset, std::size_t endOffset) = 0;
 
   /**
+   * @brief Gets the bounding box for text within a range in text.
+   *
+   * @param[in] startOffset The index of first character
+   * @param[in] endOffset The index of first character after the last one expected
+   * @param[in] type The enumeration with type of coordinate system
+   *
+   * @return Rect<> giving the position and size of the specified range of text
+   * @remarks This method is `GetRangeExtents` in DBus method.
+   */
+  virtual Rect<> GetRangeExtents(std::size_t startOffset, std::size_t endOffset, CoordinateType type) = 0;
+
+  /**
    * @brief Downcasts an Accessible to a Text.
    *
    * @param obj The Accessible
index e5bc0ca..e499795 100644 (file)
@@ -142,7 +142,7 @@ public:
     mDirectReadingClient.method<DBus::ValueOrError<void>(bool)>("PauseResume").asyncCall([](DBus::ValueOrError<void> msg) {
       if(!msg)
       {
-        LOG() << "Direct reading command failed (" << msg.getError().message << ")";
+        LOG() << "Direct reading command failed (" << msg.getError().message << ")\n";
       }
     },
                                                                                         true);
@@ -161,7 +161,7 @@ public:
     mDirectReadingClient.method<DBus::ValueOrError<void>(bool)>("PauseResume").asyncCall([](DBus::ValueOrError<void> msg) {
       if(!msg)
       {
-        LOG() << "Direct reading command failed (" << msg.getError().message << ")";
+        LOG() << "Direct reading command failed (" << msg.getError().message << ")\n";
       }
     },
                                                                                         false);
@@ -180,7 +180,7 @@ public:
     mDirectReadingClient.method<DBus::ValueOrError<void>(bool)>("StopReading").asyncCall([](DBus::ValueOrError<void> msg) {
       if(!msg)
       {
-        LOG() << "Direct reading command failed (" << msg.getError().message << ")";
+        LOG() << "Direct reading command failed (" << msg.getError().message << ")\n";
       }
     },
                                                                                         alsoNonDiscardable);
@@ -199,7 +199,7 @@ public:
     mDirectReadingClient.method<DBus::ValueOrError<std::string, bool, int32_t>(std::string, bool)>("ReadCommand").asyncCall([=](DBus::ValueOrError<std::string, bool, int32_t> msg) {
       if(!msg)
       {
-        LOG() << "Direct reading command failed (" << msg.getError().message << ")";
+        LOG() << "Direct reading command failed (" << msg.getError().message << ")\n";
       }
       else if(callback)
       {
index aec0ada..2707e44 100644 (file)
@@ -38,6 +38,7 @@ void BridgeText::RegisterInterfaces()
   AddFunctionToInterface(desc, "GetSelection", &BridgeText::GetRangeOfSelection);
   AddFunctionToInterface(desc, "SetSelection", &BridgeText::SetRangeOfSelection);
   AddFunctionToInterface(desc, "RemoveSelection", &BridgeText::RemoveSelection);
+  AddFunctionToInterface(desc, "GetRangeExtents", &BridgeText::GetRangeExtents);
   mDbusServer.addInterface("/", desc, true);
 }
 
@@ -87,3 +88,9 @@ DBus::ValueOrError<bool> BridgeText::SetRangeOfSelection(int32_t selectionIndex,
 {
   return FindSelf()->SetRangeOfSelection(selectionIndex, startOffset, endOffset);
 }
+
+DBus::ValueOrError<int32_t, int32_t, int32_t, int32_t> BridgeText::GetRangeExtents(int32_t startOffset, int32_t endOffset, uint32_t coordType)
+{
+  auto rect = FindSelf()->GetRangeExtents(startOffset, endOffset, static_cast<CoordinateType>(coordType));
+  return {static_cast<int32_t>(rect.x), static_cast<int32_t>(rect.y), static_cast<int32_t>(rect.width), static_cast<int32_t>(rect.height)};
+}
index 737d318..cc50c3f 100644 (file)
@@ -82,6 +82,11 @@ public:
    * @copydoc Dali::Accessibility::Text::SetRangeOfSelection()
    */
   DBus::ValueOrError<bool> SetRangeOfSelection(int32_t selectionIndex, int32_t startOffset, int32_t endOffset);
+
+  /**
+   * @copydoc Dali::Accessibility::Text::GetRangeExtents()
+   */
+  DBus::ValueOrError<int32_t, int32_t, int32_t, int32_t> GetRangeExtents(int32_t startOffset, int32_t endOffset, uint32_t coordType);
 };
 
 #endif // DALI_INTERNAL_ACCESSIBILITY_BRIDGE_TEXT_H