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

Add ability to report the document layout in Microsoft Word #17324

Draft
wants to merge 13 commits into
base: master
Choose a base branch
from
33 changes: 32 additions & 1 deletion source/appModules/winword.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,12 @@
Microsoft Word only.
"""

import api
import appModuleHandler
from scriptHandler import script
import controlTypes
import globalCommands
import speech
from scriptHandler import script, getLastScriptRepeatCount
import ui
from NVDAObjects.IAccessible.winword import WordDocument as IAccessibleWordDocument
from NVDAObjects.UIA.wordDocument import WordDocument as UIAWordDocument
Expand All @@ -21,6 +25,33 @@ def chooseNVDAObjectOverlayClasses(self, obj, clsList):
if UIAWordDocument in clsList or IAccessibleWordDocument in clsList:
clsList.insert(0, WinwordWordDocument)

@script(
category=globalCommands.SCRCAT_FOCUS,
description=_(
# Translators: Input help mode message for report title bar command in Microsoft Word.
"In Microsoft Word, reports the title and the layout of the current document. If pressed twice, spells this information. If pressed three times, copies it to the clipboard",
),
gesture="kb:NVDA+t",
speakOnDemand=True,
)
def script_title(self, gesture):
title = api.getForegroundObject().name
statusBar = api.getStatusBar()
if statusBar is not None:
for child in statusBar.children:
if controlTypes.state.State.PRESSED in child.states:
documentLayout = child.name
foregroundWindowName = title
title = f"{foregroundWindowName} - {documentLayout}"
break
repeatCount = getLastScriptRepeatCount()
if repeatCount == 0:
ui.message(title)
elif repeatCount == 1:
speech.speakSpelling(title)
else:
api.copyToClip(title, notify=True)


class WinwordWordDocument(WordDocument):
@script(gesture="kb:control+shift+e")
Expand Down
1 change: 1 addition & 0 deletions user_docs/en/changes.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ To use this feature, "allow NVDA to control the volume of other applications" mu
* It will now show a message to the user, including the error, in the rare event of a Windows error while attempting COM re-registrations.
* In Word and Outlook the result of more font formatting shortcuts is now reported. (#10271, @CyrilleB79)
* Default input and output braille tables will now be determined based on the NVDA language. (#16390, #290, @nvdaes)
* In Microsoft Word, when using the `report title bar` command, the document layout will be announced if this information is available on the status bar (#15088, @nvdaes)

### Bug Fixes

Expand Down