Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enable cursor movement with braille display routing keys in PowerPoint #17004

Merged
merged 8 commits into from
Aug 15, 2024
30 changes: 30 additions & 0 deletions source/appModules/powerpnt.py
Original file line number Diff line number Diff line change
Expand Up @@ -1128,6 +1128,36 @@ def _getFormatFieldAndOffsets(self, offset, formatConfig, calculateOffsets=True)
formatField["link"] = True
return formatField, (startOffset, endOffset)

def _setCaretOffset(self, offset: int):
seanbudd marked this conversation as resolved.
Show resolved Hide resolved
if not 0 <= offset <= (maxLength := self._getStoryLength()):
SaschaCowley marked this conversation as resolved.
Show resolved Hide resolved
log.debugWarning(
f"Got out of range {offset=} (min 0, max {maxLength}. Clamping.",
stack_info=True,
)
offset = max(0, min(offset, maxLength))
# Use the TextRange.select method to move the text caret to a 0-length TextRange.
# The TextRange.characters method is 1-indexed.
self.obj.ppObject.textRange.characters(offset + 1, 0).select()

def _setSelectionOffsets(self, start: int, end: int):
if not start < end:
log.debug(f"start must be less than end. Got {start=}, {end=}.", stack_info=True)
return
maxLength = self._getStoryLength()
# Having start = maxLength does not make sense, as there will be no selection if this is the case.
if not 0 <= start < maxLength:
SaschaCowley marked this conversation as resolved.
Show resolved Hide resolved
log.debugWarning(
f"Got out of range {start=} (min 0, max {maxLength - 1}. Clamping.",
stack_info=True,
)
start = max(0, min(start, maxLength - 1))
# Having end = 0 does not make sense, as there will be no selection if this is the case.
if not 0 < end <= maxLength:
SaschaCowley marked this conversation as resolved.
Show resolved Hide resolved
log.debugWarning(f"Got out of range {end=} (min 1, max {maxLength}. Clamping.", stack_info=True)
end = max(1, min(end, maxLength))
# The TextRange.characters method is 1-indexed.
self.obj.ppObject.textRange.characters(start + 1, end - start).select()


class Table(Shape):
"""Represents the table shape in Powerpoint. Provides row and column counts."""
Expand Down
3 changes: 3 additions & 0 deletions user_docs/en/changes.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,9 @@ The available options are:
* The timeout to perform a multiple keypress is now configurable; this may be especially useful for people with dexterity impairment. (#11929, @CyrilleB79)
* When performing a braille cursor routing action, NVDA can now automatically speak the character at the cursor. (#8072, @LeonarddeR)
* This option is disabled by default. You can enable "Speak character when routing cursor in text" in NVDA's braille settings.
* Improvements in PowerPoint: (#17004)
* It is now possible to use braille display routing keys to move the text cursor in Microsoft PowerPoint. (#9101)
* It is now possible to use NVDA's review cursor selection commands to select text in Microsoft PowerPoint.
SaschaCowley marked this conversation as resolved.
Show resolved Hide resolved

### Changes

Expand Down