diff --git a/source/appModules/soffice.py b/source/appModules/soffice.py index c1332da45e8..979accf9ead 100755 --- a/source/appModules/soffice.py +++ b/source/appModules/soffice.py @@ -25,6 +25,7 @@ import speech import api import braille +import inputCore import languageHandler import vision @@ -318,6 +319,40 @@ def _get_locationText(self): class SymphonyDocument(CompoundDocument): TextInfo = SymphonyDocumentTextInfo + # override base class implementation because that one assumes + # that the text retrieved from the text info for the text unit + # is the same as the text that actually gets removed, which at + # least isn't true for Writer paragraphs when removing a word + # followed by whitespace using Ctrl+Backspace + def _backspaceScriptHelper(self, unit: str, gesture: inputCore.InputGesture): + try: + oldInfo = self.makeTextInfo(textInfos.POSITION_CARET) + ia2TextObj = oldInfo._start.obj.IAccessibleTextObject + oldCaretOffset = ia2TextObj.caretOffset + oldText = ia2TextObj.text(0, ia2TextObj.nCharacters) + except NotImplementedError: + gesture.send() + return + + gesture.send() + + newInfo = self.makeTextInfo(textInfos.POSITION_CARET) + ia2TextObj = newInfo._start.obj.IAccessibleTextObject + newCaretOffset = ia2TextObj.caretOffset + newText = ia2TextObj.text(0, ia2TextObj.nCharacters) + + # double-check check that text between previous and current + # caret position was deleted and announce it + deletedText = oldText[newCaretOffset:oldCaretOffset] + if newText == oldText[0:newCaretOffset] + oldText[oldCaretOffset:]: + if len(deletedText) > 1: + speech.speakMessage(deletedText) + else: + speech.speakSpelling(deletedText) + self._caretScriptPostMovedHelper(None, gesture, newInfo) + else: + log.warning('Backspace did not remove text as expected.') + class AppModule(appModuleHandler.AppModule): diff --git a/user_docs/en/changes.t2t b/user_docs/en/changes.t2t index 17c25a8ed34..d9522298257 100644 --- a/user_docs/en/changes.t2t +++ b/user_docs/en/changes.t2t @@ -21,6 +21,7 @@ This option now announces additional relevant information about an object when t == Bug Fixes == - Reporting of object shortcut keys has been improved. (#10807) - The SAPI4 synthesizer now properly supports volume, rate and pitch changes embedded in speech. (#15271) +- 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) - == Changes for Developers ==