Skip to content

Handle COMError when fetching table header cells in Word documents#7777

Merged
michaelDCurran merged 1 commit into
nvaccess:masterfrom
bramd:i6827
Dec 8, 2017
Merged

Handle COMError when fetching table header cells in Word documents#7777
michaelDCurran merged 1 commit into
nvaccess:masterfrom
bramd:i6827

Conversation

@bramd

@bramd bramd commented Nov 18, 2017

Copy link
Copy Markdown
Contributor

Link to issue number:

Fixes #6827

Summary of the issue:

Sometimes there is a reference to a COM object in _curHeaderCellTrackerTable, but the object throws a COMError on accessing one of it's properties, such as range.
Especially in Outlook this problem occurs if an email containing a table has been opened and the user closes that email and opens another email containing tables.
The unhandled COMError prevented the user from reading the email/document.

Description of how this pull request fixes the issue:

Handle the COMError.

Testing performed:

Tested on Outlook 2016.

Known issues with pull request:

None.

Change log entry:

Comment thread source/NVDAObjects/window/winword.py Outdated
tableRangesEqual=tableRange.isEqual(self._curHeaderCellTrackerTable.range)
except (COMError, AttributeError):
tableRangesEqual=False
if not self._curHeaderCellTrackerTable or not tableRangesEqual:

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

I belief the if not self._curHeaderCellTrackerTable will alreade be dealt with if the lines above raise an AttributeError. Honestly, I'd check for if not self._curHeaderCellTrackerTable before executing the try statement, which looks somewhat cleaner. I leave it up to you.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

You're right, the first part of this or statement is unneeded. I removed it and left the try/except intact. Removing the except AttributeError and solving this in an if statement would introduce another variable to hold state, or a level of nested if statements. I think having all the logic in a single try/except makes the code easier to read.

michaelDCurran added a commit that referenced this pull request Nov 23, 2017
@michaelDCurran michaelDCurran merged commit de20ef1 into nvaccess:master Dec 8, 2017
@nvaccessAuto nvaccessAuto added this to the 2018.1 milestone Dec 8, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Unable to read tables in Outlook 2016

4 participants