Skip to content

Commit c51766c

Browse files
authored
Merge 734f3a2 into 38e12d3
2 parents 38e12d3 + 734f3a2 commit c51766c

2 files changed

Lines changed: 33 additions & 1 deletion

File tree

source/appModules/winword.py

Lines changed: 32 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,12 @@
88
Microsoft Word only.
99
"""
1010

11+
import api
1112
import appModuleHandler
12-
from scriptHandler import script
13+
import controlTypes
14+
import globalCommands
15+
import speech
16+
from scriptHandler import script, getLastScriptRepeatCount
1317
import ui
1418
from NVDAObjects.IAccessible.winword import WordDocument as IAccessibleWordDocument
1519
from NVDAObjects.UIA.wordDocument import WordDocument as UIAWordDocument
@@ -21,6 +25,33 @@ def chooseNVDAObjectOverlayClasses(self, obj, clsList):
2125
if UIAWordDocument in clsList or IAccessibleWordDocument in clsList:
2226
clsList.insert(0, WinwordWordDocument)
2327

28+
@script(
29+
category=globalCommands.SCRCAT_FOCUS,
30+
# Translators: Message presented in input help mode to describe a command in Microsoft Word documents.
31+
description=_(
32+
"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",
33+
),
34+
gesture="kb:NVDA+t",
35+
speakOnDemand=True,
36+
)
37+
def script_title(self, gesture):
38+
title = api.getForegroundObject().name
39+
statusBar = api.getStatusBar()
40+
if statusBar is not None:
41+
for child in statusBar.children:
42+
if controlTypes.state.State.PRESSED in child.states:
43+
documentLayout = child.name
44+
foregroundWindowName = title
45+
title = f"{foregroundWindowName} - {documentLayout}"
46+
break
47+
repeatCount = getLastScriptRepeatCount()
48+
if repeatCount == 0:
49+
ui.message(title)
50+
elif repeatCount == 1:
51+
speech.speakSpelling(title)
52+
else:
53+
api.copyToClip(title, notify=True)
54+
2455

2556
class WinwordWordDocument(WordDocument):
2657
@script(gesture="kb:control+shift+e")

user_docs/en/changes.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ To use this feature, "allow NVDA to control the volume of other applications" mu
3838
* 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.
3939
* In Word and Outlook the result of more font formatting shortcuts is now reported. (#10271, @CyrilleB79)
4040
* Default input and output braille tables will now be determined based on the NVDA language. (#16390, #290, @nvdaes)
41+
* In Microsoft Word, when using the `report title` command, the document layout will be announced if possible (#15088, @nvdaes)
4142

4243
### Bug Fixes
4344

0 commit comments

Comments
 (0)