Skip to content

Commit 71980e4

Browse files
Merge 29ca79b into d0614df
2 parents d0614df + 29ca79b commit 71980e4

2 files changed

Lines changed: 63 additions & 21 deletions

File tree

source/appModules/soffice.py

Lines changed: 60 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,9 @@
44
# Copyright (C) 2006-2022 NV Access Limited, Bill Dengler, Leonard de Ruijter
55

66
from typing import (
7+
Dict,
78
Optional,
9+
Tuple,
810
Union
911
)
1012

@@ -31,20 +33,24 @@
3133

3234

3335
class SymphonyTextInfo(IA2TextTextInfo):
34-
35-
def _getFormatFieldAndOffsets(self,offset,formatConfig,calculateOffsets=True):
36-
obj = self.obj
37-
try:
38-
startOffset,endOffset,attribsString=obj.IAccessibleTextObject.attributes(offset)
39-
except COMError:
40-
log.debugWarning("could not get attributes",exc_info=True)
41-
return textInfos.FormatField(),(self._startOffset,self._endOffset)
36+
def _getFormatFieldFromLegacyAttributesString( # noqa: C901
37+
self,
38+
attribsString: str,
39+
offset: int
40+
) -> textInfos.FormatField:
41+
42+
"""Get format field with information retrieved from a text
43+
attributes string containing LibreOffice's legacy custom text
44+
attributes (used by LibreOffice <= 7.6), instead of attributes
45+
according to the IAccessible2 text attributes specification
46+
(used by LibreOffice >= 24.2).
47+
48+
:param attribsString: Legacy text attributes string.
49+
:param offset: Character offset for which the attributes are
50+
retrieved.
51+
:return: Format field containing the text attribute information.
52+
"""
4253
formatField=textInfos.FormatField()
43-
if not attribsString and offset>0:
44-
try:
45-
attribsString=obj.IAccessibleTextObject.attributes(offset-1)[2]
46-
except COMError:
47-
pass
4854
if attribsString:
4955
formatField.update(splitIA2Attribs(attribsString))
5056

@@ -101,6 +107,47 @@ def _getFormatFieldAndOffsets(self,offset,formatConfig,calculateOffsets=True):
101107
if backgroundColor:
102108
formatField['background-color']=colors.RGB.fromString(backgroundColor)
103109

110+
if offset == 0:
111+
# Only include the list item prefix on the first line of the paragraph.
112+
numbering = formatField.get("Numbering")
113+
if numbering:
114+
formatField["line-prefix"] = numbering.get("NumberingPrefix") or numbering.get("BulletChar")
115+
116+
return formatField
117+
118+
def _getFormatFieldAndOffsets( # noqa: C901
119+
self,
120+
offset: int,
121+
formatConfig: Optional[Dict],
122+
calculateOffsets: bool = True
123+
) -> Tuple[textInfos.FormatField, Tuple[int, int]]:
124+
obj = self.obj
125+
try:
126+
startOffset, endOffset, attribsString = obj.IAccessibleTextObject.attributes(offset)
127+
except COMError:
128+
log.debugWarning("could not get attributes", exc_info=True)
129+
return textInfos.FormatField(), (self._startOffset, self._endOffset)
130+
131+
if not attribsString and offset > 0:
132+
try:
133+
attribsString = obj.IAccessibleTextObject.attributes(offset - 1)[2]
134+
except COMError:
135+
pass
136+
137+
# LibreOffice >= 24.2 uses IAccessible2 text attributes, earlier versions use
138+
# custom attributes, with the attrtibutes string starting with "Version:1;"
139+
if attribsString and attribsString.startswith('Version:1;'):
140+
formatField = self._getFormatFieldFromLegacyAttributesString(
141+
attribsString,
142+
offset
143+
)
144+
else:
145+
formatField, (startOffset, endOffset) = super()._getFormatFieldAndOffsets(
146+
offset,
147+
formatConfig,
148+
calculateOffsets
149+
)
150+
104151
# optimisation: Assume a hyperlink occupies a full attribute run.
105152
try:
106153
if obj.IAccessibleTextObject.QueryInterface(
@@ -110,12 +157,6 @@ def _getFormatFieldAndOffsets(self,offset,formatConfig,calculateOffsets=True):
110157
except COMError:
111158
pass
112159

113-
if offset == 0:
114-
# Only include the list item prefix on the first line of the paragraph.
115-
numbering = formatField.get("Numbering")
116-
if numbering:
117-
formatField["line-prefix"] = numbering.get("NumberingPrefix") or numbering.get("BulletChar")
118-
119160
if obj.hasFocus:
120161
# Symphony exposes some information for the caret position as attributes on the document object.
121162
# optimisation: Use the tree interceptor to get the document.

user_docs/en/changes.t2t

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,9 @@ This option now announces additional relevant information about an object when t
3030
- Reporting of object shortcut keys has been improved. (#10807, @CyrilleB79)
3131
- The SAPI4 synthesizer now properly supports volume, rate and pitch changes embedded in speech. (#15271, @LeonarddeR)
3232
- Multi line state is now correctly reported in applications using Java Access Bridge. (#14609)
33-
- In LibreOffice, words deleted using the ``control+backspace`` keyboard shortcut are now also properly announced when the deleted word is followed by whitespace (like spaces and tabs). (#15436)
34-
- In LibreOffice, announcement of the status bar using the ``NVDA+end`` keyboard shortcut now also works for dialogs in LibreOffice version 24.2 and newer. (#15591)
33+
- In LibreOffice, words deleted using the ``control+backspace`` keyboard shortcut are now also properly announced when the deleted word is followed by whitespace (like spaces and tabs). (#15436, @michaelweghorn)
34+
- In LibreOffice, announcement of the status bar using the ``NVDA+end`` keyboard shortcut now also works for dialogs in LibreOffice version 24.2 and newer. (#15591, @michaelweghorn)
35+
- In LibreOffice, text attributes according to the [IAccessible2 text attributes specification https://wiki.linuxfoundation.org/accessibility/iaccessible2/textattributes] are supported, which is required to support announcement of text attributes in LibreOffice versions 24.2 and above and makes the announcement of spelling errors work when announcing a line in Writer. (#15648, @michaelweghorn)
3536
- In Microsoft Excel with UIA disabled, braille is updated, and the active cell content is spoken, when ``control+y``, ``control+z`` or ``alt+backspace`` is pressed. (15547)
3637
- In Microsoft Word with UIA disabled braille is updated when ``control+v``, ``control+x``, ``control+y``, ``control+z``, ``alt+backspace``, ``backspace`` or ``control+backspace`` is pressed.
3738
It is also updated with UIA enabled, when typing text and braille is tethered to review and review follows caret. (#3276)

0 commit comments

Comments
 (0)