[java-atk-wrapper] JNI/Wrapper remove get_text before/after offset



commit 5ec8c43a9b7c2e091a2f11679857131341ad5897
Author: Magdalen Berns <m berns thismagpie com>
Date:   Sun Jul 19 11:15:03 2015 +0100

    JNI/Wrapper remove get_text before/after offset
    
    Bug: https://bugzilla.gnome.org/show_bug.cgi?id=752319

 jni/src/jawtext.c                            |  121 -------------
 wrapper/org/GNOME/Accessibility/AtkText.java |  251 --------------------------
 2 files changed, 0 insertions(+), 372 deletions(-)
---
diff --git a/jni/src/jawtext.c b/jni/src/jawtext.c
index b7da5c3..c4fe5b8 100644
--- a/jni/src/jawtext.c
+++ b/jni/src/jawtext.c
@@ -32,23 +32,12 @@ static gchar* jaw_text_get_text(AtkText *text,
 
 static gunichar jaw_text_get_character_at_offset(AtkText *text, gint offset);
 
-static gchar* jaw_text_get_text_after_offset(AtkText *text,
-                                             gint offset,
-                                             AtkTextBoundary boundary_type,
-                                             gint *start_offset,
-                                             gint *end_offset);
-
 static gchar* jaw_text_get_text_at_offset(AtkText *text,
                                           gint offset,
                                           AtkTextBoundary boundary_type,
                                           gint *start_offset,
                                           gint *end_offset);
 
-static gchar* jaw_text_get_text_before_offset(AtkText *text,
-                                              gint offset,
-                                              AtkTextBoundary boundary_type,
-                                              gint *start_offset,
-                                              gint *end_offset);
 static gint jaw_text_get_caret_offset(AtkText *text);
 
 static void jaw_text_get_character_extents(AtkText *text,
@@ -102,9 +91,7 @@ jaw_text_interface_init (AtkTextIface *iface)
 {
   iface->get_text = jaw_text_get_text;
   iface->get_character_at_offset = jaw_text_get_character_at_offset;
-  iface->get_text_after_offset = jaw_text_get_text_after_offset;
   iface->get_text_at_offset = jaw_text_get_text_at_offset;
-  iface->get_text_before_offset = jaw_text_get_text_before_offset;
   iface->get_caret_offset = jaw_text_get_caret_offset;
   iface->get_character_extents = jaw_text_get_character_extents;
   iface->get_character_count = jaw_text_get_character_count;
@@ -218,60 +205,6 @@ jaw_text_get_character_at_offset (AtkText *text, gint offset)
 }
 
 static gchar*
-jaw_text_get_text_after_offset (AtkText *text,
-                                gint offset,
-                                AtkTextBoundary boundary_type,
-                                gint *start_offset,
-                                gint *end_offset)
-{
-  JawObject *jaw_obj = JAW_OBJECT(text);
-  TextData *data = jaw_object_get_interface_data(jaw_obj, INTERFACE_TEXT);
-  jobject atk_text = data->atk_text;
-
-  JNIEnv *jniEnv = jaw_util_get_jni_env();
-  jclass classAtkText = (*jniEnv)->FindClass(jniEnv,
-                                             "org/GNOME/Accessibility/AtkText");
-  jmethodID jmid = (*jniEnv)->GetMethodID(jniEnv,
-                                          classAtkText,
-                                          "get_text_after_offset",
-                                          "(II)Lorg/GNOME/Accessibility/AtkText$StringSequence;");
-  jobject jStrSeq = (*jniEnv)->CallObjectMethod(jniEnv,
-                                                atk_text,
-                                                jmid,
-                                                (jint)offset,
-                                                (jint)boundary_type );
-
-  if (jStrSeq == NULL)
-  {
-    return NULL;
-  }
-
-  jclass classStringSeq = (*jniEnv)->FindClass(jniEnv,
-                                               "org/GNOME/Accessibility/AtkText$StringSequence");
-  jfieldID jfidStr = (*jniEnv)->GetFieldID(jniEnv,
-                                           classStringSeq,
-                                           "str",
-                                           "Ljava/lang/String;");
-  jfieldID jfidStart = (*jniEnv)->GetFieldID(jniEnv,
-                                             classStringSeq,
-                                             "start_offset",
-                                             "I");
-  jfieldID jfidEnd = (*jniEnv)->GetFieldID(jniEnv,
-                                           classStringSeq,
-                                           "end_offset",
-                                           "I");
-
-  jstring jStr = (*jniEnv)->GetObjectField(jniEnv, jStrSeq, jfidStr);
-  jint jStart = (*jniEnv)->GetIntField(jniEnv, jStrSeq, jfidStart);
-  jint jEnd = (*jniEnv)->GetIntField(jniEnv, jStrSeq, jfidEnd);
-
-  (*start_offset) = (gint)jStart;
-  (*end_offset) = (gint)jEnd;
-
-  return jaw_text_get_gtext_from_jstr(jniEnv, data, jStr);
-}
-
-static gchar*
 jaw_text_get_text_at_offset (AtkText *text,
                              gint offset,
                              AtkTextBoundary boundary_type,
@@ -324,60 +257,6 @@ jaw_text_get_text_at_offset (AtkText *text,
   return jaw_text_get_gtext_from_jstr(jniEnv, data, jStr);
 }
 
-static gchar*
-jaw_text_get_text_before_offset(AtkText *text,
-                                gint offset,
-                                AtkTextBoundary boundary_type,
-                                gint *start_offset,
-                                gint *end_offset)
-{
-  JawObject *jaw_obj = JAW_OBJECT(text);
-  TextData *data = jaw_object_get_interface_data(jaw_obj, INTERFACE_TEXT);
-  jobject atk_text = data->atk_text;
-
-  JNIEnv *jniEnv = jaw_util_get_jni_env();
-  jclass classAtkText = (*jniEnv)->FindClass(jniEnv,
-                                             "org/GNOME/Accessibility/AtkText");
-  jmethodID jmid = (*jniEnv)->GetMethodID(jniEnv,
-                                          classAtkText,
-                                          "get_text_before_offset",
-                                          "(II)Lorg/GNOME/Accessibility/AtkText$StringSequence;");
-  jobject jStrSeq = (*jniEnv)->CallObjectMethod( jniEnv,
-                                                 atk_text,
-                                                 jmid,
-                                                 (jint)offset,
-                                                 (jint)boundary_type );
-
-  if (jStrSeq == NULL)
-  {
-    return NULL;
-  }
-
-  jclass classStringSeq = (*jniEnv)->FindClass(jniEnv,
-                                               "org/GNOME/Accessibility/AtkText$StringSequence");
-  jfieldID jfidStr = (*jniEnv)->GetFieldID(jniEnv,
-                                           classStringSeq,
-                                           "str",
-                                           "Ljava/lang/String;");
-  jfieldID jfidStart = (*jniEnv)->GetFieldID(jniEnv,
-                                             classStringSeq,
-                                             "start_offset",
-                                             "I");
-  jfieldID jfidEnd = (*jniEnv)->GetFieldID(jniEnv,
-                                           classStringSeq,
-                                           "end_offset",
-                                           "I");
-
-  jstring jStr = (*jniEnv)->GetObjectField(jniEnv, jStrSeq, jfidStr);
-  jint jStart = (*jniEnv)->GetIntField(jniEnv, jStrSeq, jfidStart);
-  jint jEnd = (*jniEnv)->GetIntField(jniEnv, jStrSeq, jfidEnd);
-
-  (*start_offset) = (gint)jStart;
-  (*end_offset) = (gint)jEnd;
-
-  return jaw_text_get_gtext_from_jstr(jniEnv, data, jStr);
-}
-
 static gint
 jaw_text_get_caret_offset (AtkText *text)
 {
diff --git a/wrapper/org/GNOME/Accessibility/AtkText.java b/wrapper/org/GNOME/Accessibility/AtkText.java
index df4ba68..57d6b6d 100644
--- a/wrapper/org/GNOME/Accessibility/AtkText.java
+++ b/wrapper/org/GNOME/Accessibility/AtkText.java
@@ -84,23 +84,6 @@ public class AtkText {
                return str.charAt(0);
        }
 
-       public StringSequence get_text_after_offset (int offset,
-                               int boundary_type) {
-               if (acc_text instanceof AccessibleExtendedText) {
-                       AccessibleExtendedText acc_ext_text = (AccessibleExtendedText)acc_text;
-
-                       int part = getPartTypeFromBoundary(boundary_type);
-                       if (part == -1) {
-                               return null;
-                       }
-
-                       AccessibleTextSequence seq = acc_ext_text.getTextSequenceAfter(part, offset);
-                       return new StringSequence(seq.text, seq.startIndex, seq.endIndex+1);
-               } else {
-                       return private_get_text_after_offset(offset, boundary_type);
-               }
-       }
-       
        public StringSequence get_text_at_offset (int offset,
                                int boundary_type) {
                if (acc_text instanceof AccessibleExtendedText) {
@@ -119,24 +102,7 @@ public class AtkText {
                        return private_get_text_at_offset(offset, boundary_type);
                }
        }
-       
-       public StringSequence get_text_before_offset (int offset,
-                               int boundary_type) {
-               if (acc_text instanceof AccessibleExtendedText) {
-                       AccessibleExtendedText acc_ext_text = (AccessibleExtendedText)acc_text;
-
-                       int part = getPartTypeFromBoundary(boundary_type);
-                       if (part == -1) {
-                               return null;
-                       }
 
-                       AccessibleTextSequence seq = acc_ext_text.getTextSequenceBefore(part, offset);
-                       return new StringSequence(seq.text, seq.startIndex, seq.endIndex+1);
-               } else {
-                       return private_get_text_before_offset(offset, boundary_type);
-               }
-       }
-       
        public int get_caret_offset () {
                return acc_text.getCaretPosition();
        }
@@ -423,114 +389,6 @@ public class AtkText {
                return end;
        }
 
-       private StringSequence private_get_text_after_offset (int offset,
-                       int boundary_type) {
-               int char_count = get_character_count();
-               if (offset < 0 || offset >= char_count) {
-                       return null;
-               }
-
-               switch (boundary_type) {
-                       case AtkTextBoundary.CHAR :
-                       {
-                               if (offset >= char_count-1) {
-                                       return null;
-                               }
-
-                               String str = get_text(offset+1, offset+2);
-                               return new StringSequence(str, offset+1, offset+2);
-                       }
-                       case AtkTextBoundary.WORD_START :
-                       {
-                               String s = get_text(0, get_character_count());
-                               int start = getNextWordStart(offset, s);
-                               if (start == BreakIterator.DONE) {
-                                       return null;
-                               }
-
-                               int end = getNextWordStart(start, s);
-                               if (end == BreakIterator.DONE) {
-                                       end = s.length();
-                               }
-
-                               String str = get_text(start, end);
-                               return new StringSequence(str, start, end);
-                       }
-                       case AtkTextBoundary.WORD_END :
-                       {
-                               String s = get_text(0, get_character_count());
-                               int start = getNextWordEnd(offset, s);
-                               if (start == BreakIterator.DONE) {
-                                       return null;
-                               }
-
-                               int end = getNextWordEnd(start, s);
-                               if (end == BreakIterator.DONE) {
-                                       end = s.length();
-                               }
-
-                               String str = get_text(start, end);
-                               return new StringSequence(str, start, end);
-                       }
-                       case AtkTextBoundary.SENTENCE_START :
-                       {
-                               String s = get_text(0, get_character_count());
-                               int start = getNextSentenceStart(offset, s);
-                               if (start == BreakIterator.DONE) {
-                                       return null;
-                               }
-
-                               int end = getNextSentenceStart(start, s);
-                               if (end == BreakIterator.DONE) {
-                                       end = s.length();
-                               }
-
-                               String str = get_text(start, end);
-                               return new StringSequence(str, start, end);
-                       }
-                       case AtkTextBoundary.SENTENCE_END :
-                       {
-                               String s = get_text(0, get_character_count());
-                               int start = getNextSentenceEnd(offset, s);
-                               if (start == BreakIterator.DONE) {
-                                       return null;
-                               }
-
-                               int end = getNextSentenceEnd(start, s);
-                               if (end == BreakIterator.DONE) {
-                                       end = s.length();
-                               }
-
-                               String str = get_text(start, end);
-                               return new StringSequence(str, start, end);
-                       }
-                       case AtkTextBoundary.LINE_START :
-                       case AtkTextBoundary.LINE_END :
-                       {
-                               BreakIterator lines = BreakIterator.getLineInstance();
-                               String s = get_text(0, get_character_count());
-                               lines.setText(s);
-
-                               int start = lines.following(offset);
-                               if (start == BreakIterator.DONE) {
-                                       return null;
-                               }
-
-                               int end = lines.next();
-                               if (end == BreakIterator.DONE) {
-                                       end = s.length();
-                               }
-
-                               String str = get_text(start, end);
-                               return new StringSequence(str, start, end);
-                       }
-                       default :
-                       {
-                               return null;
-                       }
-               }
-       }
-
        private StringSequence private_get_text_at_offset (int offset,
                        int boundary_type) {
                int char_count = get_character_count();
@@ -634,114 +492,5 @@ public class AtkText {
                        }
                }
        }
-
-       private StringSequence private_get_text_before_offset (int offset,
-                       int boundary_type) {
-               int char_count = get_character_count();
-               if (offset < 0 || offset >= char_count) {
-                       return null;
-               }
-
-               switch (boundary_type) {
-                       case AtkTextBoundary.CHAR :
-                       {
-                               if (offset < 1) {
-                                       return null;
-                               }
-
-                               String str = get_text(offset-1, offset);
-                               return new StringSequence(str, offset-1, offset);
-                       }
-                       case AtkTextBoundary.WORD_START :
-                       {
-                               String s = get_text(0, get_character_count());
-                               int end = getPreviousWordStart(offset, s);
-                               if (end == BreakIterator.DONE) {
-                                       return null;
-                               }
-
-                               int start = getPreviousWordStart(end, s);
-                               if (start == BreakIterator.DONE) {
-                                       start = 0;
-                               }
-
-                               String str = get_text(start, end);
-                               return new StringSequence(str, start, end);
-                       }
-                       case AtkTextBoundary.WORD_END :
-                       {
-                               String s = get_text(0, get_character_count());
-                               int end = getPreviousWordEnd(offset, s);
-                               if (end == BreakIterator.DONE) {
-                                       return null;
-                               }
-
-                               int start = getPreviousWordEnd(end, s);
-                               if (start == BreakIterator.DONE) {
-                                       start = 0;
-                               }
-
-                               String str = get_text(start, end);
-                               return new StringSequence(str, start, end);
-                       }
-                       case AtkTextBoundary.SENTENCE_START :
-                       {
-                               String s = get_text(0, get_character_count());
-                               int end = getPreviousSentenceStart(offset, s);
-                               if (end == BreakIterator.DONE) {
-                                       return null;
-                               }
-
-                               int start = getPreviousSentenceStart(end, s);
-                               if (start == BreakIterator.DONE) {
-                                       start = 0;
-                               }
-
-                               String str = get_text(start, end);
-                               return new StringSequence(str, start, end);
-                       }
-                       case AtkTextBoundary.SENTENCE_END :
-                       {
-                               String s = get_text(0, get_character_count());
-                               int end = getPreviousSentenceEnd(offset, s);
-                               if (end == BreakIterator.DONE) {
-                                       return null;
-                               }
-
-                               int start = getPreviousSentenceEnd(end, s);
-                               if (start == BreakIterator.DONE) {
-                                       start = 0;
-                               }
-
-                               String str = get_text(start, end);
-                               return new StringSequence(str, start, end);
-                       }
-                       case AtkTextBoundary.LINE_START :
-                       case AtkTextBoundary.LINE_END :
-                       {
-                               BreakIterator lines = BreakIterator.getLineInstance();
-                               String s = get_text(0, get_character_count());
-                               lines.setText(s);
-
-                               int end = lines.preceding(offset);
-                               if (end == BreakIterator.DONE) {
-                                       return null;
-                               }
-
-                               int start = lines.preceding(end);
-                               if (start == BreakIterator.DONE) {
-                                       start = 0;
-                               }
-
-                               String str = get_text(start, end);
-                               return new StringSequence(str, start, end);
-                       }
-                       default :
-                       {
-                               return null;
-                       }
-               }
-       }
-
 }
 


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