[orca] Work around some brokenness in LibreOffice tables



commit c3660842fe05b5a7794d6133583d30a5dc697374
Author: Joanmarie Diggs <jdiggs igalia com>
Date:   Tue Oct 29 11:41:57 2013 -0400

    Work around some brokenness in LibreOffice tables

 src/orca/script_utilities.py                      |    4 +-
 src/orca/scripts/apps/soffice/script_utilities.py |   22 +++++++++++++++++++++
 src/orca/scripts/apps/soffice/speech_generator.py |    4 +-
 3 files changed, 26 insertions(+), 4 deletions(-)
---
diff --git a/src/orca/script_utilities.py b/src/orca/script_utilities.py
index 85b1ff3..c9c736e 100644
--- a/src/orca/script_utilities.py
+++ b/src/orca/script_utilities.py
@@ -775,13 +775,13 @@ class Utilities:
         try:
             attributes = obj.getAttributes()
         except:
-            attributes = None
+            attributes = {}
         try:
             role = obj.getRole()
         except:
             role = None
 
-        if role == pyatspi.ROLE_TABLE and attributes:
+        if role == pyatspi.ROLE_TABLE:
             for attribute in attributes:
                 if attribute == "layout-guess:true":
                     layoutOnly = True
diff --git a/src/orca/scripts/apps/soffice/script_utilities.py 
b/src/orca/scripts/apps/soffice/script_utilities.py
index 3848566..93b5583 100644
--- a/src/orca/scripts/apps/soffice/script_utilities.py
+++ b/src/orca/scripts/apps/soffice/script_utilities.py
@@ -490,3 +490,25 @@ class Utilities(script_utilities.Utilities):
                 return charCount > 0
 
         return False
+
+    def selectedChildren(self, obj):
+        if not obj:
+            return []
+
+        # Things only seem broken for certain tables, e.g. the Paths table.
+        # TODO - JD: File the LibreOffice bugs and reference them here.
+        if obj.getRole() != pyatspi.ROLE_TABLE \
+           or self._script.isSpreadSheetCell(obj, True):
+            return script_utilities.Utilities.selectedChildren(self, obj)
+
+        try:
+            selection = obj.querySelection()
+        except:
+            return []
+
+        children = []
+        for i, child in enumerate(obj):
+            if selection.isChildSelected(i):
+                children.append(obj[i])
+
+        return children
diff --git a/src/orca/scripts/apps/soffice/speech_generator.py 
b/src/orca/scripts/apps/soffice/speech_generator.py
index f0eeb0e..a747ef7 100644
--- a/src/orca/scripts/apps/soffice/speech_generator.py
+++ b/src/orca/scripts/apps/soffice/speech_generator.py
@@ -264,7 +264,7 @@ class SpeechGenerator(speech_generator.SpeechGenerator):
         parent = obj.parent
         try:
             parentTable = parent.queryTable()
-        except NotImplementedError:
+        except:
             parentTable = None
         index = self._script.utilities.cellIndex(obj)
         if "lastRow" in self._script.pointOfReference and parentTable \
@@ -337,7 +337,7 @@ class SpeechGenerator(speech_generator.SpeechGenerator):
         parent = obj.parent
         try:
             parentTable = parent.queryTable()
-        except NotImplementedError:
+        except:
             parentTable = None
         index = self._script.utilities.cellIndex(obj)
         if parentTable and "lastColumn" in self._script.pointOfReference \


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