[java-atk-wrapper] TableCell: fix implementation
- From: Samuel Thibault <sthibaul src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [java-atk-wrapper] TableCell: fix implementation
- Date: Thu, 1 Aug 2019 11:24:28 +0000 (UTC)
commit 542c978bac4d39276875674f765461ea3b6334b5
Author: Giuseppe <giuseppecapaldo93 gmail com>
Date: Thu Aug 1 13:22:15 2019 +0200
TableCell: fix implementation
The TableCell interface is to be presented by the children, not the
table.
jni/src/jawtablecell.c | 101 ++++++++++----------
wrapper/org/GNOME/Accessibility/AtkObject.java | 15 ++-
wrapper/org/GNOME/Accessibility/AtkTableCell.java | 111 ++++++----------------
3 files changed, 92 insertions(+), 135 deletions(-)
---
diff --git a/jni/src/jawtablecell.c b/jni/src/jawtablecell.c
index 4aa1c6b..a90f065 100644
--- a/jni/src/jawtablecell.c
+++ b/jni/src/jawtablecell.c
@@ -23,6 +23,7 @@
#include "jawutil.h"
static AtkObject *jaw_table_cell_get_table (AtkTableCell *cell);
+//TODO atk_table_cell_get_column_header_cells()
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,
@@ -30,6 +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 gint jaw_table_cell_get_column_span(AtkTableCell *cell);
typedef struct _TableCellData {
@@ -122,8 +124,19 @@ jaw_table_cell_get_table(AtkTableCell *cell)
return ATK_OBJECT(jaw_impl);
}
+static void
+getPosition (JNIEnv *jniEnv, jobject jatk_table_cell, jclass classAtkTableCell, gint *row, gint *column)
+{
+ jfieldID id_row = (*jniEnv)->GetFieldID(jniEnv, classAtkTableCell,"row","I");
+ jfieldID id_column = (*jniEnv)->GetFieldID(jniEnv, classAtkTableCell,"column","I");
+ jint jrow = (*jniEnv)->GetIntField(jniEnv, jatk_table_cell, id_row);
+ jint jcolumn =(*jniEnv)->GetIntField(jniEnv, jatk_table_cell, id_column);
+ (*row) = (gint) jrow;
+ (*column) = (gint) jcolumn;
+}
+
static gboolean
-jaw_table_cell_get_position(AtkTableCell *cell, gint *row, gint *column)
+jaw_table_cell_get_position (AtkTableCell *cell, gint *row, gint *column)
{
JAW_DEBUG_C("%p, %p, %p", cell, row, column);
JawObject *jaw_obj = JAW_OBJECT(cell);
@@ -138,27 +151,30 @@ jaw_table_cell_get_position(AtkTableCell *cell, gint *row, gint *column)
JAW_DEBUG_I("jatk_table_cell == NULL");
return FALSE;
}
-
- jclass classAtkTableCell = (*jniEnv)->FindClass(jniEnv,
- "org/GNOME/Accessibility/AtkTableCell");
- jmethodID jmid = (*jniEnv)->GetMethodID(jniEnv,
- classAtkTableCell,
- "getPosition",
- "(II)Z;");
- jboolean jposition = (*jniEnv)->CallBooleanMethod(jniEnv,
- jatk_table_cell,
- jmid,
- (jint)GPOINTER_TO_INT(row),
- (jint)GPOINTER_TO_INT(column));
+ jclass classAtkTableCell = (*jniEnv)->FindClass(jniEnv, "org/GNOME/Accessibility/AtkTableCell");
+ getPosition (jniEnv, jatk_table_cell, classAtkTableCell, row, column);
(*jniEnv)->DeleteGlobalRef(jniEnv, jatk_table_cell);
- return jposition;
+ return TRUE;
}
-static gboolean jaw_table_cell_get_row_column_span(AtkTableCell *cell,
- gint *row,
- gint *column,
- gint *row_span,
- gint *column_span)
+static void
+getRowSpan (JNIEnv *jniEnv, jobject jatk_table_cell, jclass classAtkTableCell, gint *row_span)
+{
+ jfieldID id_row_span = (*jniEnv)->GetFieldID(jniEnv, classAtkTableCell,"rowSpan","I");
+ jint jrow_span = (*jniEnv)->GetIntField(jniEnv, jatk_table_cell, id_row_span);
+ (*row_span) = (gint) jrow_span;
+}
+
+static void
+getColumnSpan (JNIEnv *jniEnv, jobject jatk_table_cell, jclass classAtkTableCell, gint *column_span)
+{
+ jfieldID id_column_span = (*jniEnv)->GetFieldID(jniEnv, classAtkTableCell,"columnSpan","I");
+ jint jcolumn_span =(*jniEnv)->GetIntField(jniEnv, jatk_table_cell, id_column_span);
+ (*column_span) = (gint) jcolumn_span;
+}
+
+static gboolean
+jaw_table_cell_get_row_column_span(AtkTableCell *cell, gint *row, gint *column, gint *row_span, gint
*column_span)
{
JAW_DEBUG_C("%p, %p, %p, %p, %p", cell, row, column, row_span, column_span);
JawObject *jaw_obj = JAW_OBJECT(cell);
@@ -173,23 +189,12 @@ static gboolean jaw_table_cell_get_row_column_span(AtkTableCell *cell,
JAW_DEBUG_I("jatk_table_cell == NULL");
return FALSE;
}
-
- jclass classAtkTableCell = (*jniEnv)->FindClass(jniEnv,
- "org/GNOME/Accessibility/AtkTableCell");
- jmethodID jmid = (*jniEnv)->GetMethodID(jniEnv,
- classAtkTableCell,
- "getRowColumnSpan",
- "(IIII)Z;");
- jboolean jspan = (*jniEnv)->CallBooleanMethod(jniEnv,
- jatk_table_cell,
- jmid,
- (jint)GPOINTER_TO_INT(row),
- (jint)GPOINTER_TO_INT(column),
- (jint)GPOINTER_TO_INT(row_span),
- (jint)GPOINTER_TO_INT(column_span)
- );
+ jclass classAtkTableCell = (*jniEnv)->FindClass(jniEnv, "org/GNOME/Accessibility/AtkTableCell");
+ getPosition (jniEnv, jatk_table_cell, classAtkTableCell, row, column);
+ getRowSpan (jniEnv, jatk_table_cell, classAtkTableCell, row_span);
+ getColumnSpan (jniEnv, jatk_table_cell, classAtkTableCell, column_span);
(*jniEnv)->DeleteGlobalRef(jniEnv, jatk_table_cell);
- return jspan;
+ return TRUE;
}
static gint
@@ -208,16 +213,11 @@ jaw_table_cell_get_row_span(AtkTableCell *cell)
JAW_DEBUG_I("jatk_table_cell == NULL");
return 0;
}
-
- jclass classAtkTableCell = (*env)->FindClass(env,
- "org/GNOME/Accessibility/AtkTableCell");
- jmethodID jmid = (*env)->GetMethodID(env,
- classAtkTableCell,
- "getRowSpan",
- "()I;");
- gint ret = (gint) (*env)->CallIntMethod(env, jatk_table_cell, jmid);
+ gint row_span = -1;
+ jclass classAtkTableCell = (*env)->FindClass(env, "org/GNOME/Accessibility/AtkTableCell");
+ getRowSpan (env, jatk_table_cell, classAtkTableCell, &row_span);
(*env)->DeleteGlobalRef(env, jatk_table_cell);
- return ret;
+ return row_span;
}
static gint
@@ -236,14 +236,9 @@ jaw_table_cell_get_column_span(AtkTableCell *cell)
JAW_DEBUG_I("jatk_table_cell == NULL");
return 0;
}
-
- jclass classAtkTableCell = (*env)->FindClass(env,
- "org/GNOME/Accessibility/AtkTableCell");
- jmethodID jmid = (*env)->GetMethodID(env,
- classAtkTableCell,
- "getColumnSpan",
- "()I;");
- gint ret = (gint) (*env)->CallIntMethod(env, jatk_table_cell, jmid);
+ gint column_span = -1;
+ jclass classAtkTableCell = (*env)->FindClass(env, "org/GNOME/Accessibility/AtkTableCell");
+ getColumnSpan (env, jatk_table_cell, classAtkTableCell, &column_span);
(*env)->DeleteGlobalRef(env, jatk_table_cell);
- return ret;
+ return column_span;
}
diff --git a/wrapper/org/GNOME/Accessibility/AtkObject.java b/wrapper/org/GNOME/Accessibility/AtkObject.java
index 1ce61f6..b89093f 100644
--- a/wrapper/org/GNOME/Accessibility/AtkObject.java
+++ b/wrapper/org/GNOME/Accessibility/AtkObject.java
@@ -82,8 +82,19 @@ public class AtkObject{
AccessibleTable table = ac.getAccessibleTable();
if (table != null){
flags |= AtkObject.INTERFACE_TABLE;
- if (table instanceof AccessibleExtendedTable)
- flags |= AtkObject.INTERFACE_TABLE_CELL;
+ }
+ Accessible parent = ac.getAccessibleParent();
+ if (parent != null){
+ AccessibleContext pc = parent.getAccessibleContext();
+ if (pc != null){
+ table = pc.getAccessibleTable();
+ // Unfortunately without the AccessibleExtendedTable interface
+ // we can't determine the column/row of this accessible in the
+ // table
+ if (table != null && table instanceof AccessibleExtendedTable){
+ flags |= AtkObject.INTERFACE_TABLE_CELL;
+ }
+ }
}
if (ac.getAccessibleValue() != null)
flags |= AtkObject.INTERFACE_VALUE;
diff --git a/wrapper/org/GNOME/Accessibility/AtkTableCell.java
b/wrapper/org/GNOME/Accessibility/AtkTableCell.java
index 0c0c5dd..308503c 100644
--- a/wrapper/org/GNOME/Accessibility/AtkTableCell.java
+++ b/wrapper/org/GNOME/Accessibility/AtkTableCell.java
@@ -22,25 +22,41 @@ package org.GNOME.Accessibility;
import javax.accessibility.*;
import java.lang.ref.WeakReference;
-public class AtkTableCell extends AtkTable {
+public class AtkTableCell {
WeakReference<AccessibleContext> _ac;
-
- WeakReference<AccessibleExtendedTable> _acc_table_cell;
- private int rowSpan, columnSpan;
+ WeakReference<AccessibleTable> _acc_pt;
+ public int row, rowSpan, column, columnSpan;
public AtkTableCell (AccessibleContext ac) {
- super(ac);
this._ac = new WeakReference<AccessibleContext>(ac);
- AccessibleTable acc_table = ac.getAccessibleTable();
-
- if (acc_table instanceof AccessibleExtendedTable) {
- _acc_table_cell = new WeakReference<AccessibleExtendedTable>((AccessibleExtendedTable)acc_table);
- } else {
- _acc_table_cell = null;
+ Accessible parent = ac.getAccessibleParent();
+ _acc_pt = null;
+ row = -1;
+ rowSpan = -1;
+ column = -1;
+ columnSpan = -1;
+ if (parent == null){
+ return;
+ }
+ AccessibleContext pc = parent.getAccessibleContext();
+ if(pc == null){
+ return;
}
- rowSpan = 0;
- columnSpan = 0;
+ AccessibleTable pt = pc.getAccessibleTable();
+ if(pt == null){
+ return;
+ }
+ _acc_pt = new WeakReference<AccessibleTable>(pt);
+ int index = ac.getAccessibleIndexInParent();
+ if (!(pt instanceof AccessibleExtendedTable)){
+ return;
+ }
+ AccessibleExtendedTable aet = (AccessibleExtendedTable) pt;
+ row = aet.getAccessibleRow(index);
+ column = aet.getAccessibleColumn(index);
+ rowSpan = pt.getAccessibleRowExtentAt(row,column);
+ columnSpan = pt.getAccessibleColumnExtentAt(row,column);
}
public static AtkTableCell createAtkTableCell(AccessibleContext ac){
@@ -53,74 +69,9 @@ public class AtkTableCell extends AtkTable {
* AccessibleTable instance.
*/
public AccessibleTable getTable() {
- if (_acc_table_cell == null)
+ if (_acc_pt == null)
return null;
- return _acc_table_cell.get();
- }
-
- /**
- * @param row the row of the accessible table cell
- * @param column the column of the accessible table cell
- * @return: whether the accessible index of the table cell is found
- */
- public boolean getPosition(int row, int column) {
- if (_acc_table_cell == null)
- return false;
- AccessibleExtendedTable acc_table_cell = _acc_table_cell.get();
- if (acc_table_cell == null)
- return false;
-
- return AtkUtil.invokeInSwing ( () -> {
- int index = acc_table_cell.getAccessibleIndex(row, column);
- if (index < 0)
- return false;
- return true;
- }, false);
- }
-
- /**
- * @param row the row of the accessible table cell
- * @param column the column of the accessible table cell
- * @param rowSpan the row span of the accessible table cell the
- * @param columnSpan the column span of the accessible table cell
- * @return: whether the column and row span was retrieved
- */
- public boolean getRowColumnSpan(int row, int column, int rowSpan, int columnSpan) {
- AccessibleTable acc_table = _acc_table.get();
- if (acc_table == null)
- return false;
-
- return AtkUtil.invokeInSwing ( () -> {
- this.rowSpan = rowSpan;
- this.columnSpan = columnSpan;
- int chekRowSpan = acc_table.getAccessibleRowExtentAt(row, column);
- int checkColumnSpan = acc_table.getAccessibleColumnExtentAt(row, column);
- if (chekRowSpan < 0 && checkColumnSpan < 0)
- return false;
- return true;
- }, false);
- }
-
- /**
- * @return: span of the table_cell row as an int
- */
- public int getRowSpan() {
- return AtkUtil.invokeInSwing ( () -> {
- if (rowSpan < 0)
- return -1;
- return rowSpan;
- }, -1);
- }
-
- /**
- * @return: span of the table_cell column as an int
- */
- public int getColumnSpan() {
- return AtkUtil.invokeInSwing ( () -> {
- if (columnSpan < 0)
- return -1;
- return columnSpan;
- }, -1);
+ return _acc_pt.get();
}
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]