[orca] Clean up _generateTableCellRow()



commit cfbbc27c6ad62838d7abdb13facb1973fa17310d
Author: Joanmarie Diggs <joanmarie diggs gmail com>
Date:   Tue Jan 21 18:09:55 2020 -0500

    Clean up _generateTableCellRow()

 src/orca/generator.py                             | 73 ++++++-----------------
 src/orca/script_utilities.py                      | 10 +++-
 src/orca/scripts/apps/soffice/script_utilities.py |  5 +-
 3 files changed, 26 insertions(+), 62 deletions(-)
---
diff --git a/src/orca/generator.py b/src/orca/generator.py
index c2d4e2d29..da7653ed2 100644
--- a/src/orca/generator.py
+++ b/src/orca/generator.py
@@ -894,64 +894,25 @@ class Generator:
         has changed.  Otherwise, it will return an array for just the
         current cell.
         """
-        result = []
 
-        try:
-            parentTable = obj.parent.queryTable()
-        except:
-            parentTable = None
-        isDetailedWhereAmI = args.get('formatType', None) == 'detailedWhereAmI'
-        readFullRow = self._script.utilities.shouldReadFullRow(obj)
-        if (readFullRow or isDetailedWhereAmI) and parentTable \
-           and (not self._script.utilities.isLayoutOnly(obj.parent)):
-            parent = obj.parent
-            index = self._script.utilities.cellIndex(obj)
-            row = parentTable.getRowAtIndex(index)
-            column = parentTable.getColumnAtIndex(index)
-
-            # This is an indication of whether we should speak all the
-            # table cells (the user has moved focus up or down a row),
-            # or just the current one (focus has moved left or right in
-            # the same row).
-            #
-            presentAll = True
-            if isDetailedWhereAmI:
-                if parentTable.nColumns <= 1:
-                    return result
-            elif "lastRow" in self._script.pointOfReference \
-               and "lastColumn" in self._script.pointOfReference:
-                pointOfReference = self._script.pointOfReference
-                presentAll = \
-                    (self._mode == 'braille') \
-                    or \
-                    ((pointOfReference["lastRow"] != row) \
-                     or ((row == 0 or row == parentTable.nRows-1) \
-                         and pointOfReference["lastColumn"] == column))
-            if presentAll:
-                args['readingRow'] = True
-                if self._script.utilities.isTableRow(obj):
-                    cells = [x for x in obj]
-                else:
-                    cells = [parentTable.getAccessibleAt(row, i) \
-                                 for i in range(parentTable.nColumns)]
+        presentAll = args.get('readingRow') == True \
+            or args.get('formatType') == 'detailedWhereAmI' \
+            or self._mode == 'braille' \
+            or self._script.utilities.shouldReadFullRow(obj)
 
-                for cell in cells:
-                    if not cell:
-                        continue
-                    state = cell.getState()
-                    showing = state.contains(pyatspi.STATE_SHOWING)
-                    if showing:
-                        cellResult = self._generateRealTableCell(cell, **args)
-                        if cellResult and result and self._mode == 'braille':
-                            result.append(braille.Region(
-                                object_properties.TABLE_CELL_DELIMITER_BRAILLE))
-                        result.extend(cellResult)
-
-                result.extend(self._generatePositionInList(obj, **args))
-            else:
-                result.extend(self._generateRealTableCell(obj, **args))
-        else:
-            result.extend(self._generateRealTableCell(obj, **args))
+        if not presentAll:
+            return self._generateRealTableCell(obj, **args)
+
+        args['readingRow'] = True
+        result = []
+        cells = self._script.utilities.getShowingCellsInSameRow(obj, forceFullRow=True)
+        for cell in cells:
+            cellResult = self._generateRealTableCell(cell, **args)
+            if cellResult and result and self._mode == 'braille':
+                result.append(braille.Region(object_properties.TABLE_CELL_DELIMITER_BRAILLE))
+            result.extend(cellResult)
+
+        result.extend(self._generatePositionInList(obj, **args))
         return result
 
     #####################################################################
diff --git a/src/orca/script_utilities.py b/src/orca/script_utilities.py
index fe5b8bb8e..668ddfa08 100644
--- a/src/orca/script_utilities.py
+++ b/src/orca/script_utilities.py
@@ -1326,6 +1326,9 @@ class Utilities:
         if self._script.inSayAll():
             return False
 
+        if not self.cellRowChanged(obj):
+            return False
+
         table = self.getTable(obj)
         if not table:
             return False
@@ -4394,7 +4397,7 @@ class Utilities:
 
         return startIndex, endIndex
 
-    def getShowingCellsInSameRow(self, obj):
+    def getShowingCellsInSameRow(self, obj, forceFullRow=False):
         parent = self.getTable(obj)
         try:
             table = parent.queryTable()
@@ -4407,7 +4410,10 @@ class Utilities:
         if row == -1:
             return []
 
-        startIndex, endIndex = self._getTableRowRange(obj)
+        if forceFullRow:
+            startIndex, endIndex = 0, table.nColumns
+        else:
+            startIndex, endIndex = self._getTableRowRange(obj)
         if startIndex == endIndex:
             return []
 
diff --git a/src/orca/scripts/apps/soffice/script_utilities.py 
b/src/orca/scripts/apps/soffice/script_utilities.py
index 68fa04499..c7f9e314c 100644
--- a/src/orca/scripts/apps/soffice/script_utilities.py
+++ b/src/orca/scripts/apps/soffice/script_utilities.py
@@ -752,10 +752,7 @@ class Utilities(script_utilities.Utilities):
         if lastKey in ["Tab", "ISO_Left_Tab"]:
             return False
 
-        if not super().shouldReadFullRow(obj):
-            return False
-
-        return self.cellRowChanged(obj)
+        return super().shouldReadFullRow(obj)
 
     def presentEventFromNonShowingObject(self, event):
         return self.inDocumentContent(event.source)


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