[orca] Handle LO's recently-corrected exposure of text attributes for spellcheck



commit 58ce7c7bedbf56bb65d4f25e49bd5780a8831692
Author: Joanmarie Diggs <jdiggs igalia com>
Date:   Mon Dec 12 05:36:40 2016 -0500

    Handle LO's recently-corrected exposure of text attributes for spellcheck
    
    Note: The LO fix has only just been committed and is not yet available
    in shipping versions of LO. In addition, in recent, earlier versions of
    LO, a broken LO accessibility tree made it impossible for Orca to find
    the spellcheck dialog. If your version of LO does not have fixes for both
    of these issues, this change to Orca will not work.

 src/orca/scripts/apps/soffice/spellcheck.py |   16 +++++++---------
 1 files changed, 7 insertions(+), 9 deletions(-)
---
diff --git a/src/orca/scripts/apps/soffice/spellcheck.py b/src/orca/scripts/apps/soffice/spellcheck.py
index 3b8cce0..d9e288d 100644
--- a/src/orca/scripts/apps/soffice/spellcheck.py
+++ b/src/orca/scripts/apps/soffice/spellcheck.py
@@ -87,15 +87,13 @@ class SpellCheck(spellcheck.SpellCheck):
         except:
             return ""
 
-        for i in range(text.characterCount):
-            attributes, start, end = text.getAttributeRun(i, False)
-            if attributes and start != end:
-                string = text.getText(start, end)
-                break
-        else:
-            msg = "SOFFICE: No text attributes for word in %s." % self._errorWidget
-            debug.println(debug.LEVEL_INFO, msg, True)
-            string = text.getText(0, -1)
+        offset, string = 0, ""
+        while 0 <= offset < text.characterCount:
+            attributes, start, end = text.getAttributeRun(offset, False)
+            attrs = dict([attr.split(":", 1) for attr in attributes])
+            if attrs.get("fg-color", "").replace(" ", "") == "255,0,0":
+                return text.getText(start, end)
+            offset = max(end, offset + 1)
 
         return string
 


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