Skip to content

Fix PowerPoint caret reporting when text contains wide characters, and overall improvement of TextInfo implementation#17015

Merged
seanbudd merged 17 commits into
nvaccess:masterfrom
LeonarddeR:pptOffsetFix
Aug 29, 2024
Merged

Fix PowerPoint caret reporting when text contains wide characters, and overall improvement of TextInfo implementation#17015
seanbudd merged 17 commits into
nvaccess:masterfrom
LeonarddeR:pptOffsetFix

Conversation

@LeonarddeR

@LeonarddeR LeonarddeR commented Aug 16, 2024

Copy link
Copy Markdown
Collaborator

Link to issue number:

Fixes #17006
Fixes #9941

Summary of the issue:

Wide character reporting in PowerPoint was broken.

Description of user facing changes

  1. NVDA no longer fails reporting the caret position when a text frame contains wide characters.
  2. NVDA is now able to report the position of characters.
  3. Sentence navigation now works

Description of development approach

The TextInfo implementation for PowerPoint turns out to be pretty incomplete. I added offset calculations for characters, words and paragraphs.

Testing strategy:

Tested the several implemented methods using the Python Console, as well as sentence navigation with alt+up/downArrow

Known issues with pull request:

None known

Code Review Checklist:

  • Documentation:
    • Change log entry
    • User Documentation
    • Developer / Technical Documentation
    • Context sensitive help for GUI changes
  • Testing:
    • Unit tests
    • System (end to end) tests
    • Manual testing
  • UX of all users considered:
    • Speech
    • Braille
    • Low Vision
    • Different web browsers
    • Localization in other languages / culture than English
  • API is compatible with existing add-ons.
  • Security precautions taken.

Summary by CodeRabbit

  • New Features

    • Enhanced text handling within PowerPoint presentations, improving text range validation and offset calculations.
    • Added methods for precise text navigation including character, word, line, and paragraph offsets.
    • Introduced a method for calculating bounding rectangles based on character offsets.
  • Bug Fixes

    • Improved caret reporting and screen coordinate accuracy, enhancing accessibility for users with assistive technologies.
  • Refactor

    • Streamlined existing methods to utilize new functionalities and improve error handling.

@LeonarddeR LeonarddeR requested a review from a team as a code owner August 16, 2024 17:55
@LeonarddeR LeonarddeR requested a review from seanbudd August 16, 2024 17:55
@coderabbitai

coderabbitai Bot commented Aug 16, 2024

Copy link
Copy Markdown
Contributor

Walkthrough

The changes to the powerpnt.py module significantly enhance text handling within PowerPoint presentations. Key improvements include the introduction of robust methods for managing text ranges, character offsets, and improved error handling. Notably, the handling of wide characters has been refined, ensuring accurate caret position reporting, which is critical for accessibility features.

Changes

File Change Summary
source/appModules/powerpnt.py - Replaced _getTextRange with _getPptTextRange for better validation and error handling.
- Introduced _getCharacterOffsets, _getWordOffsets, _getLineNumFromOffset, and _getParagraphOffsets for precise text navigation.
- Refactored _setCaretOffset and _setSelectionOffsets for streamlined logic and improved selection management.
- Enhanced logging and accessibility features for caret and screen coordinate reporting.

Assessment against linked issues

Objective Addressed Explanation
Wide characters break caret position reporting (Issue #17006)
Improved error handling and validation for text ranges
Accurate screen coordinate reporting

Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

Share
Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai generate interesting stats about this repository and render them as a table.
    • @coderabbitai show all the console.log statements in this repository.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (invoked as PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Additionally, you can add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@LeonarddeR LeonarddeR changed the title Fix PowerPoint caret reporting when text contains wide characters, as… Fix PowerPoint caret reporting when text contains wide characters, and overall improvement of TextInfo implementation Aug 16, 2024

@SaschaCowley SaschaCowley left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the great work Leonard. Just a couple of small changes :)

Comment thread source/appModules/powerpnt.py Outdated
Comment thread user_docs/en/changes.md Outdated
Comment thread user_docs/en/changes.md Outdated
@seanbudd seanbudd added the merge-early Merge Early in a developer cycle label Aug 19, 2024
@seanbudd seanbudd added this to the 2025.1 milestone Aug 19, 2024
@seanbudd seanbudd added the conceptApproved Similar 'triaged' for issues, PR accepted in theory, implementation needs review. label Aug 20, 2024
Comment thread source/appModules/powerpnt.py Outdated
Comment thread user_docs/en/changes.md Outdated
Comment thread user_docs/en/changes.md Outdated
Co-authored-by: Sascha Cowley <16543535+SaschaCowley@users.noreply.github.com>
Comment thread source/appModules/powerpnt.py Outdated
Comment thread source/appModules/powerpnt.py Outdated
@SaschaCowley

Copy link
Copy Markdown
Member

Can you please resolve the merge conflicts?

@SaschaCowley SaschaCowley left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @LeonarddeR. Just a minor change to the changes entry, and a question about some method documentation.

Comment thread user_docs/en/changes.md Outdated
Comment thread source/appModules/powerpnt.py Outdated
@seanbudd seanbudd requested a review from SaschaCowley August 29, 2024 00:43
Comment thread source/textInfos/offsets.py Outdated
LeonarddeR and others added 3 commits August 29, 2024 08:03
@seanbudd seanbudd requested a review from SaschaCowley August 29, 2024 06:07

@SaschaCowley SaschaCowley left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @LeonarddeR, nice work.

@seanbudd seanbudd merged commit 68f5fcc into nvaccess:master Aug 29, 2024
@LeonarddeR LeonarddeR deleted the pptOffsetFix branch August 23, 2025 06:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

conceptApproved Similar 'triaged' for issues, PR accepted in theory, implementation needs review. merge-early Merge Early in a developer cycle

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Wide characters break caret position reporting in PowerPoint PowerPoint: Report more accurate position of text with NVDA+delete

3 participants