[orca] LibreOffice Writer documents should be fully readable and navigable via the braille display
- From: Joanmarie Diggs <joanied src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [orca] LibreOffice Writer documents should be fully readable and navigable via the braille display
- Date: Sat, 15 Sep 2012 21:03:11 +0000 (UTC)
commit adfab0ab55a286dbc59034a66c79581f7d332d5c
Author: Joanmarie Diggs <jdiggs igalia com>
Date: Sat Sep 15 17:02:58 2012 -0400
LibreOffice Writer documents should be fully readable and navigable via the braille display
Before we only displayed what was spoken in LibreOffice Writer documents.
This makes braille access inefficient because users have to keep switching
between the keyboard and the braille display.
src/orca/scripts/apps/soffice/script.py | 83 ++++++++++++++++++++-
src/orca/scripts/apps/soffice/script_utilities.py | 44 +++++++++++
2 files changed, 126 insertions(+), 1 deletions(-)
---
diff --git a/src/orca/scripts/apps/soffice/script.py b/src/orca/scripts/apps/soffice/script.py
index e4012f6..de185cf 100644
--- a/src/orca/scripts/apps/soffice/script.py
+++ b/src/orca/scripts/apps/soffice/script.py
@@ -262,6 +262,36 @@ class Script(default.Script):
#
_("Clears the dynamic row headers"))
+ self.inputEventHandlers["panBrailleLeftHandler"] = \
+ input_event.InputEventHandler(
+ Script.panBrailleLeft,
+ # Translators: a refreshable braille display is an
+ # external hardware device that presents braille
+ # character to the user. There are a limited number
+ # of cells on the display (typically 40 cells). Orca
+ # provides the feature to build up a longer logical
+ # line and allow the user to press buttons on the
+ # braille display so they can pan left and right over
+ # this line.
+ #
+ _("Pans the braille display to the left."),
+ False) # Do not enable learn mode for this action
+
+ self.inputEventHandlers["panBrailleRightHandler"] = \
+ input_event.InputEventHandler(
+ Script.panBrailleRight,
+ # Translators: a refreshable braille display is an
+ # external hardware device that presents braille
+ # character to the user. There are a limited number
+ # of cells on the display (typically 40 cells). Orca
+ # provides the feature to build up a longer logical
+ # line and allow the user to press buttons on the
+ # braille display so they can pan left and right over
+ # this line.
+ #
+ _("Pans the braille display to the right."),
+ False) # Do not enable learn mode for this action
+
def getAppKeyBindings(self):
"""Returns the application-specific keybindings for this script."""
@@ -778,6 +808,52 @@ class Script(default.Script):
return True
+ def panBrailleLeft(self, inputEvent=None, panAmount=0):
+ """In document content, we want to use the panning keys to browse the
+ entire document.
+ """
+
+ if self.flatReviewContext \
+ or not self.isBrailleBeginningShowing() \
+ or self.isSpreadSheetCell(orca_state.locusOfFocus):
+ return default.Script.panBrailleLeft(self, inputEvent, panAmount)
+
+ obj = self.utilities.findPreviousObject(orca_state.locusOfFocus)
+ orca.setLocusOfFocus(None, obj, notifyScript=False)
+ self.updateBraille(obj)
+
+ # Hack: When panning to the left in a document, we want to start at
+ # the right/bottom of each new object. For now, we'll pan there.
+ # When time permits, we'll give our braille code some smarts.
+ while self.panBrailleInDirection(panToLeft=False):
+ pass
+ self.refreshBraille(False)
+
+ return True
+
+ def panBrailleRight(self, inputEvent=None, panAmount=0):
+ """In document content, we want to use the panning keys to browse the
+ entire document.
+ """
+
+ if self.flatReviewContext \
+ or not self.isBrailleEndShowing() \
+ or self.isSpreadSheetCell(orca_state.locusOfFocus):
+ return default.Script.panBrailleRight(self, inputEvent, panAmount)
+
+ obj = self.utilities.findNextObject(orca_state.locusOfFocus)
+ orca.setLocusOfFocus(None, obj, notifyScript=False)
+ self.updateBraille(obj)
+
+ # Hack: When panning to the right in a document, we want to start at
+ # the left/top of each new object. For now, we'll pan there. When time
+ # permits, we'll give our braille code some smarts.
+ while self.panBrailleInDirection(panToLeft=True):
+ pass
+ self.refreshBraille(False)
+
+ return True
+
def presentInputLine(self, inputEvent):
"""Presents the contents of the spread sheet input line (assuming we
have a handle to it - generated when we first focus on a spread
@@ -2292,4 +2368,9 @@ class Script(default.Script):
return [lineString, 0, startOffset]
- return default.Script.getTextLineAtCaret(self, obj, offset)
+ textLine = default.Script.getTextLineAtCaret(self, obj, offset)
+ if not obj.getState().contains(pyatspi.STATE_FOCUSED):
+ textLine[0] = self.utilities.displayedText(obj)
+
+ return textLine
+
diff --git a/src/orca/scripts/apps/soffice/script_utilities.py b/src/orca/scripts/apps/soffice/script_utilities.py
index 5616776..bdee230 100644
--- a/src/orca/scripts/apps/soffice/script_utilities.py
+++ b/src/orca/scripts/apps/soffice/script_utilities.py
@@ -210,6 +210,50 @@ class Utilities(script_utilities.Utilities):
return parent
+ def findPreviousObject(self, obj):
+ """Finds the object before this one."""
+
+ if not obj:
+ return None
+
+ for relation in obj.getRelationSet():
+ if relation.getRelationType() == pyatspi.RELATION_FLOWS_FROM:
+ return relation.getTarget(0)
+
+ index = obj.getIndexInParent() - 1
+ if not (0 <= index < obj.parent.childCount - 1):
+ obj = obj.parent
+ index = obj.getIndexInParent() - 1
+
+ try:
+ prevObj = obj.parent[index]
+ except:
+ prevObj = obj
+
+ return prevObj
+
+ def findNextObject(self, obj):
+ """Finds the object after this one."""
+
+ if not obj:
+ return None
+
+ for relation in obj.getRelationSet():
+ if relation.getRelationType() == pyatspi.RELATION_FLOWS_TO:
+ return relation.getTarget(0)
+
+ index = obj.getIndexInParent() + 1
+ if not (0 < index < obj.parent.childCount):
+ obj = obj.parent
+ index = obj.getIndexInParent() + 1
+
+ try:
+ nextObj = obj.parent[index]
+ except:
+ nextObj = None
+
+ return nextObj
+
#########################################################################
# #
# Impress-Specific Utilities #
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]