Skip to content

Commit c3e54e0

Browse files
Merge af7f289 into 37e5eb8
2 parents 37e5eb8 + af7f289 commit c3e54e0

2 files changed

Lines changed: 36 additions & 0 deletions

File tree

source/appModules/soffice.py

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
import speech
2626
import api
2727
import braille
28+
import inputCore
2829
import languageHandler
2930
import vision
3031

@@ -318,6 +319,40 @@ def _get_locationText(self):
318319
class SymphonyDocument(CompoundDocument):
319320
TextInfo = SymphonyDocumentTextInfo
320321

322+
# override base class implementation because that one assumes
323+
# that the text retrieved from the text info for the text unit
324+
# is the same as the text that actually gets removed, which at
325+
# least isn't true for Writer paragraphs when removing a word
326+
# followed by whitespace using Ctrl+Backspace
327+
def _backspaceScriptHelper(self, unit: str, gesture: inputCore.InputGesture):
328+
try:
329+
oldInfo = self.makeTextInfo(textInfos.POSITION_CARET)
330+
ia2TextObj = oldInfo._start.obj.IAccessibleTextObject
331+
oldCaretOffset = ia2TextObj.caretOffset
332+
oldText = ia2TextObj.text(0, ia2TextObj.nCharacters)
333+
except NotImplementedError:
334+
gesture.send()
335+
return
336+
337+
gesture.send()
338+
339+
newInfo = self.makeTextInfo(textInfos.POSITION_CARET)
340+
ia2TextObj = newInfo._start.obj.IAccessibleTextObject
341+
newCaretOffset = ia2TextObj.caretOffset
342+
newText = ia2TextObj.text(0, ia2TextObj.nCharacters)
343+
344+
# double-check check that text between previous and current
345+
# caret position was deleted and announce it
346+
deletedText = oldText[newCaretOffset:oldCaretOffset]
347+
if newText == oldText[0:newCaretOffset] + oldText[oldCaretOffset:]:
348+
if len(deletedText) > 1:
349+
speech.speakMessage(deletedText)
350+
else:
351+
speech.speakSpelling(deletedText)
352+
self._caretScriptPostMovedHelper(None, gesture, newInfo)
353+
else:
354+
log.warning('Backspace did not remove text as expected.')
355+
321356

322357
class AppModule(appModuleHandler.AppModule):
323358

user_docs/en/changes.t2t

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ This option now announces additional relevant information about an object when t
2525
- Reporting of object shortcut keys has been improved. (#10807)
2626
- The SAPI4 synthesizer now properly supports volume, rate and pitch changes embedded in speech. (#15271)
2727
- Multi line state is now correctly reported in applications using Java Access Bridge. (#14609)
28+
- 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)
2829
-
2930

3031
== Changes for Developers ==

0 commit comments

Comments
 (0)