nvda
3bd2cb8d - Fix AttributeError when instantiating ITextDocumentTextInfo without a selection object (#20362)

Commit
159 days ago
Fix AttributeError when instantiating ITextDocumentTextInfo without a selection object (#20362) closes #17390 Summary of the issue: In PowerPoint and other Office applications, using F2 to edit a text shape and pressing Ctrl+K opens the "Insert Link" dialog. Trying to write, navigate, or re-read the text in the dialog's edit fields caused NVDA to fail silently. In the logs, this triggered the following traceback: File "globalCommands.pyc", line 211, in script_reportCurrentLine File "NVDAObjects\window\edit.pyc", line 1107, in makeTextInfo File "NVDAObjects\window\edit.pyc", line 895, in __init__ AttributeError: 'NoneType' object has no attribute 'duplicate' This occurred because ITextDocumentTextInfo assumed self.obj.ITextSelectionObject was always valid, but Office's partial/restricted TOM implementation for these dialog edit fields returns None for the selection object. Description of user facing changes: Users can now type, navigate, and read text (using arrows and NVDA+upArrow) normally within the edit fields of the PowerPoint "Insert Link" dialog (and other similar Office dialog edit fields). Description of developer facing changes: None. Description of development approach: Updated Edit._get_TextInfo in source/NVDAObjects/window/edit.py to check that self.ITextSelectionObject is not None before returning ITextDocumentTextInfo. If it is None, we immediately fall back to the standard EditTextInfo. Updated RichEdit.makeTextInfo in source/NVDAObjects/window/edit.py to catch AttributeError in addition to COMError during instantiation of ITextDocumentTextInfo, ensuring a safe fallback to EditTextInfo. Standard EditTextInfo uses standard Windows Messages/APIs which these edit controls fully support, enabling proper reading and navigation.
Parents
Loading