[orca] Fix for bgo#619101 - Duplicate caret-moved events in OOo Writer are causing Orca to double-speak lin



commit 483a070f15641962b1326868df5d4f869d3f8174
Author: Joanmarie Diggs <joanmarie diggs gmail com>
Date:   Thu May 20 09:46:42 2010 -0400

    Fix for bgo#619101 - Duplicate caret-moved events in OOo Writer are causing Orca to double-speak lines of text

 src/orca/scripts/apps/soffice/script.py           |    3 ++
 src/orca/scripts/apps/soffice/script_utilities.py |   22 +++++++++++++++++++++
 2 files changed, 25 insertions(+), 0 deletions(-)
---
diff --git a/src/orca/scripts/apps/soffice/script.py b/src/orca/scripts/apps/soffice/script.py
index aaf87a3..8a879c5 100644
--- a/src/orca/scripts/apps/soffice/script.py
+++ b/src/orca/scripts/apps/soffice/script.py
@@ -2027,6 +2027,9 @@ class Script(default.Script):
         if self.isStructuralNavigationCommand():
             return
 
+        if self.utilities.isDuplicateEvent(event):
+            return
+
         # If we are losing focus and we in:
         # 1/ a paragraph in an ooimpress slide presentation
         # 2/ a paragraph in an oowriter text document
diff --git a/src/orca/scripts/apps/soffice/script_utilities.py b/src/orca/scripts/apps/soffice/script_utilities.py
index 1d2da02..86309b9 100644
--- a/src/orca/scripts/apps/soffice/script_utilities.py
+++ b/src/orca/scripts/apps/soffice/script_utilities.py
@@ -89,6 +89,28 @@ class Utilities(script_utilities.Utilities):
 
         return readOnly
 
+    def isDuplicateEvent(self, event):
+        """Returns True if we believe this event is a duplicate which we
+        wish to ignore."""
+
+        if not event:
+            return False
+
+        if event.type.startswith("object:text-caret-moved"):
+            try:
+                obj, offset = \
+                    self._script.pointOfReference["lastCursorPosition"]
+            except:
+                return False
+            else:
+                # Doing an intentional equality check rather than calling
+                # isSameObject() because we'd rather double-present an
+                # object than not present it at all.
+                #
+                return obj == event.source and offset == event.detail1
+
+        return False
+
     def isSameObject(self, obj1, obj2):
         same = script_utilities.Utilities.isSameObject(self, obj1, obj2)
 



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