[java-atk-wrapper] TableCell: Implement get_column/row_header_cells



commit 1d780c8cfcc15b338154bfc25db80a737d00416d
Author: Giuseppe <giuseppecapaldo93 gmail com>
Date:   Thu Aug 1 16:17:49 2019 +0200

    TableCell: Implement get_column/row_header_cells

 HACKING                                           |  4 --
 jni/src/jawtablecell.c                            | 74 +++++++++++++++++++++--
 wrapper/org/GNOME/Accessibility/AtkTableCell.java | 34 +++++++++++
 3 files changed, 104 insertions(+), 8 deletions(-)
---
diff --git a/HACKING b/HACKING
index 563c35e..c9e5b75 100644
--- a/HACKING
+++ b/HACKING
@@ -34,10 +34,6 @@ Object base class:
   implementor_ref_accessible
   get_attributes
 
-TableCell:
-  get_column_header_cells
-  get_row_header_cells
-
 Deprecated Methods Which Are Implemented
 ----------------------------------------
 
diff --git a/jni/src/jawtablecell.c b/jni/src/jawtablecell.c
index a90f065..8478543 100644
--- a/jni/src/jawtablecell.c
+++ b/jni/src/jawtablecell.c
@@ -23,7 +23,7 @@
 #include "jawutil.h"
 
 static AtkObject *jaw_table_cell_get_table (AtkTableCell *cell);
-//TODO atk_table_cell_get_column_header_cells()
+static GPtrArray *jaw_table_cell_get_column_header_cells (AtkTableCell *cell);
 static gboolean jaw_table_cell_get_position(AtkTableCell *cell, gint *row, gint *column);
 static gboolean jaw_table_cell_get_row_column_span(AtkTableCell *cell,
                                                    gint         *row,
@@ -31,7 +31,7 @@ static gboolean jaw_table_cell_get_row_column_span(AtkTableCell *cell,
                                                    gint         *row_span,
                                                    gint         *column_span);
 static gint jaw_table_cell_get_row_span(AtkTableCell *cell);
-//TODO atk_table_cell_get_row_header_cells()
+static GPtrArray *jaw_table_cell_get_row_header_cells (AtkTableCell *cell);
 static gint jaw_table_cell_get_column_span(AtkTableCell *cell);
 
 typedef struct _TableCellData {
@@ -45,10 +45,10 @@ jaw_table_cell_interface_init (AtkTableCellIface *iface, gpointer data)
 {
   JAW_DEBUG_ALL("%p, %p", iface, data);
   iface->get_column_span = jaw_table_cell_get_column_span;
-  // TODO: iface->get_column_header_cells from getAccessibleColumnHeader
+  iface->get_column_header_cells = jaw_table_cell_get_column_header_cells;
   iface->get_position = jaw_table_cell_get_position;
   iface->get_row_span = jaw_table_cell_get_row_span;
-  // TODO: iface->get_row_header_cells from getAccessibleRowHeader
+  iface->get_row_header_cells = jaw_table_cell_get_row_header_cells;
   iface->get_row_column_span = jaw_table_cell_get_row_column_span;
   iface->get_table = jaw_table_cell_get_table;
 }
@@ -242,3 +242,69 @@ jaw_table_cell_get_column_span(AtkTableCell *cell)
   (*env)->DeleteGlobalRef(env, jatk_table_cell);
   return column_span;
 }
+
+static GPtrArray*
+jaw_table_cell_get_column_header_cells(AtkTableCell *cell)
+{
+  JAW_DEBUG_C("%p", cell);
+  JawObject *jaw_obj = JAW_OBJECT(cell);
+  if (!jaw_obj) {
+    JAW_DEBUG_I("jaw_obj == NULL");
+    return NULL;
+  }
+  TableCellData *data = jaw_object_get_interface_data(jaw_obj, INTERFACE_TABLE_CELL);
+  JNIEnv *jniEnv = jaw_util_get_jni_env();
+  jobject jatk_table_cell = (*jniEnv)->NewGlobalRef(jniEnv, data->atk_table_cell);
+  if (!jatk_table_cell) {
+    JAW_DEBUG_I("jatk_table_cell == NULL");
+    return NULL;
+  }
+  jclass classAtkTableCell = (*jniEnv)->FindClass(jniEnv, "org/GNOME/Accessibility/AtkTableCell");
+  jmethodID jmid = (*jniEnv)->GetMethodID(jniEnv, classAtkTableCell, "getAccessibleColumnHeader", 
"()[Ljavax/accessibility/AccessibleContext;");
+  jobjectArray ja_ac = (jobjectArray) (*jniEnv)->CallObjectMethod(jniEnv, jatk_table_cell, jmid);
+  (*jniEnv)->DeleteGlobalRef(jniEnv, jatk_table_cell);
+  if (!ja_ac)
+    return NULL;
+  jsize length = (*jniEnv)->GetArrayLength(jniEnv, ja_ac) ;
+  GPtrArray *result = g_ptr_array_sized_new ((guint) length);
+  for ( int i = 0; i < length; i++)
+  {
+    jobject jac = (*jniEnv)->GetObjectArrayElement(jniEnv,ja_ac, i);
+    JawImpl* jaw_impl = jaw_impl_get_instance_from_jaw(jniEnv, jac);
+    g_ptr_array_add(result, jaw_impl);
+  }
+  return result;
+}
+
+static GPtrArray*
+jaw_table_cell_get_row_header_cells(AtkTableCell *cell)
+{
+  JAW_DEBUG_C("%p", cell);
+  JawObject *jaw_obj = JAW_OBJECT(cell);
+  if (!jaw_obj) {
+    JAW_DEBUG_I("jaw_obj == NULL");
+    return NULL;
+  }
+  TableCellData *data = jaw_object_get_interface_data(jaw_obj, INTERFACE_TABLE_CELL);
+  JNIEnv *jniEnv = jaw_util_get_jni_env();
+  jobject jatk_table_cell = (*jniEnv)->NewGlobalRef(jniEnv, data->atk_table_cell);
+  if (!jatk_table_cell) {
+    JAW_DEBUG_I("jatk_table_cell == NULL");
+    return NULL;
+  }
+  jclass classAtkTableCell = (*jniEnv)->FindClass(jniEnv, "org/GNOME/Accessibility/AtkTableCell");
+  jmethodID jmid = (*jniEnv)->GetMethodID(jniEnv, classAtkTableCell, "getAccessibleRowHeader", 
"()[Ljavax/accessibility/AccessibleContext;");
+  jobjectArray ja_ac = (jobjectArray) (*jniEnv)->CallObjectMethod(jniEnv, jatk_table_cell, jmid);
+  (*jniEnv)->DeleteGlobalRef(jniEnv, jatk_table_cell);
+  if (!ja_ac)
+    return NULL;
+  jsize length = (*jniEnv)->GetArrayLength(jniEnv, ja_ac) ;
+  GPtrArray *result = g_ptr_array_sized_new ((guint) length);
+  for ( int i = 0; i < length; i++)
+  {
+    jobject jac = (*jniEnv)->GetObjectArrayElement(jniEnv,ja_ac, i);
+    JawImpl* jaw_impl = jaw_impl_get_instance_from_jaw(jniEnv, jac);
+    g_ptr_array_add(result, jaw_impl);
+  }
+  return result;
+}
\ No newline at end of file
diff --git a/wrapper/org/GNOME/Accessibility/AtkTableCell.java 
b/wrapper/org/GNOME/Accessibility/AtkTableCell.java
index 308503c..2497cb1 100644
--- a/wrapper/org/GNOME/Accessibility/AtkTableCell.java
+++ b/wrapper/org/GNOME/Accessibility/AtkTableCell.java
@@ -74,4 +74,38 @@ public class AtkTableCell {
         return _acc_pt.get();
     }
 
+    public AccessibleContext[] getAccessibleColumnHeader(){
+        if (_acc_pt == null)
+            return null;
+        return AtkUtil.invokeInSwing( () -> {
+            AccessibleTable iteration = _acc_pt.get().getAccessibleColumnHeader();
+            if (iteration != null){
+                int length = iteration.getAccessibleColumnCount();
+                AccessibleContext[] result = new AccessibleContext[length];
+                for (int i = 0; i < length; i++){
+                    result[i] = iteration.getAccessibleAt(0,i).getAccessibleContext();
+                }
+                return result;
+            }
+            return null;
+        }, null);
+    }
+
+    public AccessibleContext[] getAccessibleRowHeader(){
+        if (_acc_pt == null)
+            return null;
+        return AtkUtil.invokeInSwing( () -> {
+            AccessibleTable iteration = _acc_pt.get().getAccessibleRowHeader();
+            if (iteration != null){
+                int length = iteration.getAccessibleRowCount();
+                AccessibleContext[] result = new AccessibleContext[length];
+                for (int i = 0; i < length; i++){
+                    result[i] = iteration.getAccessibleAt(i,0).getAccessibleContext();
+                }
+                return result;
+            }
+            return null;
+        }, null);
+    }
+
 }


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]