orca r4673 - in trunk: . src/orca src/orca/scripts/apps/soffice



Author: wwalker
Date: Fri Apr 10 13:32:50 2009
New Revision: 4673
URL: http://svn.gnome.org/viewvc/orca?rev=4673&view=rev

Log:
Fix for bug #577245 - Present paragraph-style information in OpenOffice


Modified:
   trunk/ChangeLog
   trunk/src/orca/scripts/apps/soffice/script.py
   trunk/src/orca/settings.py
   trunk/src/orca/where_am_I.py

Modified: trunk/src/orca/scripts/apps/soffice/script.py
==============================================================================
--- trunk/src/orca/scripts/apps/soffice/script.py	(original)
+++ trunk/src/orca/scripts/apps/soffice/script.py	Fri Apr 10 13:32:50 2009
@@ -112,18 +112,14 @@
         #
         self.commFailureAttemptLimit = 1
 
-        # The default set of text attributes to speak to the user. The
-        # only difference over the default set in settings.py is to add
-        # in "left-margin:" and "right-margin:".
-
-        self.enabledBrailledTextAttributes = \
-          "size:; family-name:; weight:400; indent:0mm; left-margin:0mm; " \
-          "right-margin:0mm; underline:none; strikethrough:none; " \
-          "justification:left; style:normal;"
-        self.enabledSpokenTextAttributes = \
-          "size:; family-name:; weight:400; indent:0mm; left-margin:0mm; " \
-          "right-margin:0mm; underline:none; strikethrough:none; " \
-          "justification:left; style:normal;"
+        # Additional default set of text attributes to present to the
+        # user. The only difference over the default set in
+        # settings.py is to add in "left-margin:" and "right-margin:".
+        #
+        self.additionalBrailledTextAttributes = \
+          " left-margin:0mm; right-margin:0mm;"
+        self.additionalSpokenTextAttributes = \
+          " left-margin:0mm; right-margin:0mm;"
 
     def activate(self):
         """Called when this script is activated."""
@@ -132,12 +128,34 @@
 
         self.savedEnabledBrailledTextAttributes = \
             settings.enabledBrailledTextAttributes
-        settings.enabledBrailledTextAttributes = \
-            self.enabledBrailledTextAttributes
+        settings.enabledBrailledTextAttributes += \
+            self.additionalBrailledTextAttributes
 
         self.savedEnabledSpokenTextAttributes = \
             settings.enabledSpokenTextAttributes
-        settings.enabledSpokenTextAttributes = self.enabledSpokenTextAttributes
+        settings.enabledSpokenTextAttributes += \
+            self.additionalSpokenTextAttributes
+
+        # Account for the differences in how OOo expresses indent and
+        # strikethrough.
+        #
+        settings.enabledBrailledTextAttributes = \
+            settings.enabledBrailledTextAttributes.replace(
+            "strikethrough:false;",
+            "strikethrough:none;")
+        settings.enabledSpokenTextAttributes = \
+            settings.enabledSpokenTextAttributes.replace(
+            "strikethrough:false;",
+            "strikethrough:none;")
+
+        settings.enabledBrailledTextAttributes = \
+            settings.enabledBrailledTextAttributes.replace(
+            "indent:0;",
+            "indent:0mm;")
+        settings.enabledSpokenTextAttributes = \
+            settings.enabledSpokenTextAttributes.replace(
+            "indent:0;",
+            "indent:0mm;")
 
     def deactivate(self):
         """Called when this script is deactivated."""

Modified: trunk/src/orca/settings.py
==============================================================================
--- trunk/src/orca/settings.py	(original)
+++ trunk/src/orca/settings.py	Fri Apr 10 13:32:50 2009
@@ -687,7 +687,8 @@
 
 enabledSpokenTextAttributes = \
     "size:; family-name:; weight:400; indent:0; underline:none; " \
-    "strikethrough:false; justification:left; style:normal;"
+    "strikethrough:false; justification:left; style:normal; " \
+    "paragraph-style:;"
 
 # The default set of text attributes to be brailled for the user. Specific
 # application scripts (or individual users can override these values if

Modified: trunk/src/orca/where_am_I.py
==============================================================================
--- trunk/src/orca/where_am_I.py	(original)
+++ trunk/src/orca/where_am_I.py	Fri Apr 10 13:32:50 2009
@@ -158,6 +158,8 @@
         if basicOnly:
             self._speakObjDescription(obj)
 
+        self._lastAttributeString = ""
+
         return True
 
     def _speakCheckBox(self, obj, basicOnly):
@@ -1652,49 +1654,69 @@
             debug.println(self._debugLevel,
                           "line attribs <%s>" % (attribs))
             if attribs:
-                newLine += " ; "
+                if newLine:
+                    newLine += " ; "
                 newLine += attribs
                 newLine += " "
 
             newLine += line[i]
             textOffset += 1
 
+        attribs = self._getAttributesForChar(obj,
+                                             text,
+                                             startOffset,
+                                             line,
+                                             0,
+                                             ["paragraph-style"])
+        if attribs:
+            if newLine:
+                newLine += " ; "
+            newLine += attribs
+
         debug.println(self._debugLevel, "newLine: <%s>" % (newLine))
 
         return newLine
 
-    def _getAttributesForChar(self, obj, text, textOffset, line, lineIndex):
+    def _getAttributesForChar(self,
+                              obj,
+                              text,
+                              textOffset,
+                              line,
+                              lineIndex,
+                              keys=["style", "weight", "underline"]):
 
-        keys = [ "style", "weight", "underline" ]
         attribStr = ""
-        charAttributes = text.getAttributes(textOffset)
 
+        defaultAttributes = text.getDefaultAttributes()
+        attributesDictionary = self._stringToDictionary(defaultAttributes)
+
+        charAttributes = text.getAttributes(textOffset)
         if charAttributes[0]:
             charDict = self._stringToDictionary(charAttributes[0])
-            debug.println(self._debugLevel,
-                          "charDict: %s" % (charDict))
+            for key in charDict.keys():
+                attributesDictionary[key] = charDict[key]
 
+        if attributesDictionary:
             for key in keys:
                 localizedKey = text_attribute_names.getTextAttributeName(key)
-                if key in charDict:
-                    attribute = charDict[key]
+                if key in attributesDictionary:
+                    attribute = attributesDictionary[key]
                     localizedValue = \
                         text_attribute_names.getTextAttributeName(attribute)
                     if attribute:
                         # If it's the 'weight' attribute and greater than 400,
                         # just speak it as bold, otherwise speak the weight.
                         #
-                        if key == "weight" and int(attribute) > 400:
-                            attribStr += " "
-                            # Translators: bold as in the font sense.
-                            #
-                            attribStr += _("bold")
-
+                        if key == "weight":
+                            if int(attribute) > 400:
+                                attribStr += " "
+                                # Translators: bold as in the font sense.
+                                #
+                                attribStr += _("bold")
                         elif key == "underline":
                             if attribute != "none":
                                 attribStr += " "
                                 attribStr += localizedKey
-
                         elif key == "style":
                             if attribute != "normal":
                                 attribStr += " "
@@ -1712,8 +1734,9 @@
                 #
                 attribStr += _("link")
 
-            debug.println(self._debugLevel,
-                          "char <%s>: %s" % (line[lineIndex], attribStr))
+            if line:
+                debug.println(self._debugLevel,
+                              "char <%s>: %s" % (line[lineIndex], attribStr))
 
         # Only return attributes for the beginning of an attribute run.
         if attribStr != self._lastAttributeString:



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