[java-atk-wrapper] Create jaw_table_cell_get_position



commit e234b6b4fd1c7b61d1ee870af02ee557b045b401
Author: Magdalen Berns <m berns thismagpie com>
Date:   Wed Jun 17 18:03:26 2015 +0100

    Create jaw_table_cell_get_position
    
    Bug: https://bugzilla.gnome.org/show_bug.cgi?id=751123

 HACKING                                           |    1 -
 jni/src/jawtablecell.c                            |   41 ++++++++++++++++++++-
 wrapper/org/GNOME/Accessibility/AtkTableCell.java |    7 ++++
 3 files changed, 47 insertions(+), 2 deletions(-)
---
diff --git a/HACKING b/HACKING
index 3869974..818c693 100644
--- a/HACKING
+++ b/HACKING
@@ -56,7 +56,6 @@ Table:
 TableCell:
   get_column_span
   get_column_header_cells
-  get_position
   get_row_span
   get_row_header_cells
   get_row_column_span
diff --git a/jni/src/jawtablecell.c b/jni/src/jawtablecell.c
index f9b989e..bc6dcf4 100644
--- a/jni/src/jawtablecell.c
+++ b/jni/src/jawtablecell.c
@@ -26,7 +26,10 @@ extern void jaw_table_cell_interface_init (AtkTableCellIface*);
 extern gpointer jaw_table_cell_data_init (jobject ac);
 extern void jaw_table_cell_data_finalize (gpointer);
 
-static AtkObject *jaw_table_cell_get_table (AtkTableCell *cell);
+static AtkObject      *jaw_table_cell_get_table   (AtkTableCell *cell);
+static gboolean        jaw_table_cell_get_position(AtkTableCell *cell,
+                                                   gint *row,
+                                                   gint *column);
 
 typedef struct _TableCellData {
   jobject atk_table_cell;
@@ -38,6 +41,7 @@ void
 jaw_table_cell_interface_init (AtkTableCellIface *iface)
 {
   iface->get_table = jaw_table_cell_get_table;
+  iface->get_position = jaw_table_cell_get_position;
 }
 
 gpointer
@@ -98,3 +102,38 @@ jaw_table_cell_get_table(AtkTableCell *cell)
 
   return ATK_OBJECT(jaw_impl);
 }
+
+static gboolean
+jaw_table_cell_get_position (AtkTableCell *cell, gint *row, gint *column)
+{
+  if (row == NULL || column == NULL)
+    return FALSE;
+
+  JawObject *jaw_obj = JAW_OBJECT(cell);
+  TableCellData *data = jaw_object_get_interface_data(jaw_obj, INTERFACE_TABLE_CELL);
+  jobject jatk_table_cell = data->atk_table_cell;
+
+  JNIEnv *jniEnv = jaw_util_get_jni_env();
+  jclass classAtkComponent = (*jniEnv)->FindClass(jniEnv, "org/GNOME/Accessibility/AtkComponent");
+  jmethodID jmid = (*jniEnv)->GetMethodID(jniEnv, classAtkComponent, "getPosition", "(II)Ljava/awt/Point;");
+  jobject jpoint = (*jniEnv)->CallObjectMethod(jniEnv, jatk_table_cell, jmid);
+
+  if (jpoint == NULL)
+  {
+    (*row) = 0;
+    (*column) = 0;
+    return FALSE;
+  }
+
+  jclass classPoint = (*jniEnv)->FindClass(jniEnv, "java/awt/Point");
+  jfieldID jfidR = (*jniEnv)->GetFieldID(jniEnv, classPoint, "row", "I");
+  jfieldID jfidC = (*jniEnv)->GetFieldID(jniEnv, classPoint, "column", "I");
+  jint jr = (*jniEnv)->GetIntField(jniEnv, jpoint, jfidR);
+  jint jc = (*jniEnv)->GetIntField(jniEnv, jpoint, jfidC);
+
+  (*row)    = (gint)jr;
+  (*column) = (gint)jc;
+
+  return TRUE;
+}
+
diff --git a/wrapper/org/GNOME/Accessibility/AtkTableCell.java 
b/wrapper/org/GNOME/Accessibility/AtkTableCell.java
index 9d6cad7..e484f3f 100644
--- a/wrapper/org/GNOME/Accessibility/AtkTableCell.java
+++ b/wrapper/org/GNOME/Accessibility/AtkTableCell.java
@@ -20,6 +20,7 @@
 package org.GNOME.Accessibility;
 
 import javax.accessibility.*;
+import java.awt.Point;
 
 public class AtkTableCell {
 
@@ -35,5 +36,11 @@ public class AtkTableCell {
   public AccessibleTable getTable() {
     return acc_table_cell;
   }
+
+  public Point getPosition (int row, int column) {
+    int rowExtent = acc_table_cell.getAccessibleRowExtentAt(row, column);
+    int colExtent = acc_table_cell.getAccessibleColumnExtentAt(row, column);
+    return new Point(rowExtent, colExtent);
+  }
 }
 


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