[orca] Add option to always speak full selected range in spreadsheet



commit 08ba20219d5d5fa293cb3888caadef4a2b9fb955
Author: Joanmarie Diggs <jdiggs igalia com>
Date:   Thu Jul 12 10:22:47 2018 -0400

    Add option to always speak full selected range in spreadsheet
    
    While this setting is still experimental, enabling it will require
    putting the following lines in your orca-customizations.py file:
    
    import orca.settings
    orca.settings.alwaysSpeakSelectedSpreadsheetRange = True

 src/orca/scripts/apps/soffice/script.py           |  3 +++
 src/orca/scripts/apps/soffice/script_utilities.py | 31 +++++++++++++++++++----
 src/orca/settings.py                              |  1 +
 3 files changed, 30 insertions(+), 5 deletions(-)
---
diff --git a/src/orca/scripts/apps/soffice/script.py b/src/orca/scripts/apps/soffice/script.py
index 736c635e6..867b0446f 100644
--- a/src/orca/scripts/apps/soffice/script.py
+++ b/src/orca/scripts/apps/soffice/script.py
@@ -844,6 +844,9 @@ class Script(default.Script):
         if self.utilities.isSpreadSheetTable(event.source):
             if _settingsManager.getSetting('onlySpeakDisplayedText'):
                 return
+            if _settingsManager.getSetting('alwaysSpeakSelectedSpreadsheetRange'):
+                self.utilities.speakSelectedCellRange(event.source)
+                return
             if self.utilities.handleRowAndColumnSelectionChange(event.source):
                 return
             self.utilities.handleCellSelectionChange(event.source)
diff --git a/src/orca/scripts/apps/soffice/script_utilities.py 
b/src/orca/scripts/apps/soffice/script_utilities.py
index c169ff7ac..80854e6c3 100644
--- a/src/orca/scripts/apps/soffice/script_utilities.py
+++ b/src/orca/scripts/apps/soffice/script_utilities.py
@@ -798,17 +798,37 @@ class Utilities(script_utilities.Utilities):
 
         return name.strip()
 
-    def handleCellSelectionChange(self, obj):
+    def _getCoordinatesForSelectedRange(self, obj):
         interfaces = pyatspi.listInterfaces(obj)
         if not ("Table" in interfaces and "Selection" in interfaces):
-            return True
+            return (-1, -1), (-1, -1)
 
-        table = obj.queryTable()
-        count = self.selectedChildCount(obj)
         first, last = self.firstAndLastSelectedChildren(obj)
         firstCoords = self.coordinatesForCell(first)
         lastCoords = self.coordinatesForCell(last)
-        focusCoords = tuple(self.coordinatesForCell(orca_state.locusOfFocus))
+        return firstCoords, lastCoords
+
+    def speakSelectedCellRange(self, obj):
+        firstCoords, lastCoords = self._getCoordinatesForSelectedRange(obj)
+        if firstCoords == (-1, -1) or lastCoords == (-1, -1):
+            return True
+
+        self._script.presentationInterrupt()
+
+        if firstCoords == lastCoords:
+            cell = self._getCellNameForCoordinates(obj, *firstCoords, True)
+            self._script.speakMessage(messages.CELL_SELECTED % cell)
+            return True
+
+        cell1 = self._getCellNameForCoordinates(obj, *firstCoords, True)
+        cell2 = self._getCellNameForCoordinates(obj, *lastCoords, True)
+        self._script.speakMessage(messages.CELL_RANGE_SELECTED % (cell1, cell2))
+        return True
+
+    def handleCellSelectionChange(self, obj):
+        firstCoords, lastCoords = self._getCoordinatesForSelectedRange(obj)
+        if firstCoords == (-1, -1) or lastCoords == (-1, -1):
+            return True
 
         current = []
         for r in range(firstCoords[0], lastCoords[0]+1):
@@ -821,6 +841,7 @@ class Utilities(script_utilities.Utilities):
 
         unselected = sorted(previous.difference(current))
         selected = sorted(current.difference(previous))
+        focusCoords = tuple(self.coordinatesForCell(orca_state.locusOfFocus))
         if focusCoords in selected:
             selected.remove(focusCoords)
 
diff --git a/src/orca/settings.py b/src/orca/settings.py
index ad96e58ec..fe1715f50 100644
--- a/src/orca/settings.py
+++ b/src/orca/settings.py
@@ -397,5 +397,6 @@ rewindAndFastForwardInSayAll = False
 structNavInSayAll = False
 
 # N.B. The following are experimental and may change or go away at any time.
+alwaysSpeakSelectedSpreadsheetRange = False
 enableSadPidginHack = False
 presentChatRoomLast = False


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