Skip to content

Commit 733f082

Browse files
authored
Merge 279f2ef into 041609e
2 parents 041609e + 279f2ef commit 733f082

12 files changed

Lines changed: 122 additions & 44 deletions

File tree

source/NVDAObjects/IAccessible/sysListView32.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# A part of NonVisual Desktop Access (NVDA)
2-
# Copyright (C) 2006-2020 NV Access Limited, Peter Vágner, Leonard de Ruijter
2+
# Copyright (C) 2006-2022 NV Access Limited, Peter Vágner, Leonard de Ruijter, Cyrille Bougot
33
# This file is covered by the GNU General Public License.
44
# See the file COPYING for more details.
55

@@ -18,6 +18,7 @@
1818
from ..window import Window
1919
from NVDAObjects.behaviors import RowWithoutCellObjects, RowWithFakeNavigation
2020
import config
21+
from config.configFlags import ReportTableHeaders
2122
from locationHelper import RectLTRB
2223
from logHandler import log
2324
from typing import Optional
@@ -626,7 +627,10 @@ def _get_name(self):
626627
content = self._getColumnContent(col)
627628
if not content:
628629
continue
629-
if config.conf["documentFormatting"]["reportTableHeaders"] and col != 1:
630+
if config.conf["documentFormatting"]["reportTableHeaders"] in (
631+
ReportTableHeaders.ROWS_AND_COLUMNS,
632+
ReportTableHeaders.COLUMNS,
633+
) and col != 1:
630634
header = self._getColumnHeader(col)
631635
else:
632636
header = None

source/NVDAObjects/IAccessible/winword.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
import braille
1414
import controlTypes
1515
import config
16+
from config.configFlags import ReportTableHeaders
1617
import tableUtils
1718
import textInfos
1819
import eventHandler
@@ -205,7 +206,7 @@ def fetchAssociatedHeaderCellText(self,cell,columnHeader=False):
205206

206207
def script_setColumnHeader(self,gesture):
207208
scriptCount=scriptHandler.getLastScriptRepeatCount()
208-
if not config.conf['documentFormatting']['reportTableHeaders']:
209+
if config.conf['documentFormatting']['reportTableHeaders'] == ReportTableHeaders.OFF:
209210
# Translators: a message reported in the SetColumnHeader script for Microsoft Word.
210211
ui.message(_("Cannot set headers. Please enable reporting of table headers in Document Formatting Settings"))
211212
return
@@ -233,7 +234,7 @@ def script_setColumnHeader(self,gesture):
233234

234235
def script_setRowHeader(self,gesture):
235236
scriptCount=scriptHandler.getLastScriptRepeatCount()
236-
if not config.conf['documentFormatting']['reportTableHeaders']:
237+
if config.conf['documentFormatting']['reportTableHeaders'] == ReportTableHeaders.OFF:
237238
# Translators: a message reported in the SetRowHeader script for Microsoft Word.
238239
ui.message(_("Cannot set headers. Please enable reporting of table headers in Document Formatting Settings"))
239240
return

source/NVDAObjects/window/excel.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
# A part of NonVisual Desktop Access (NVDA)
2-
# Copyright (C) 2006-2022 NV Access Limited, Dinesh Kaushal, Siddhartha Gupta, Accessolutions, Julien Cochuyt
2+
# Copyright (C) 2006-2022 NV Access Limited, Dinesh Kaushal, Siddhartha Gupta, Accessolutions, Julien Cochuyt,
3+
# Cyrille Bougot
34
# This file is covered by the GNU General Public License.
45
# See the file COPYING for more details.
56

@@ -24,6 +25,7 @@
2425
import speech
2526
from tableUtils import HeaderCellInfo, HeaderCellTracker
2627
import config
28+
from config.configFlags import ReportTableHeaders
2729
import textInfos
2830
import colors
2931
import eventHandler
@@ -1272,7 +1274,7 @@ def script_openDropdown(self,gesture):
12721274
gesture="kb:NVDA+shift+c")
12731275
def script_setColumnHeader(self,gesture):
12741276
scriptCount=scriptHandler.getLastScriptRepeatCount()
1275-
if not config.conf['documentFormatting']['reportTableHeaders']:
1277+
if config.conf['documentFormatting']['reportTableHeaders'] == ReportTableHeaders.OFF:
12761278
# Translators: a message reported in the SetColumnHeader script for Excel.
12771279
ui.message(_("Cannot set headers. Please enable reporting of table headers in Document Formatting Settings"))
12781280
return
@@ -1298,7 +1300,7 @@ def script_setColumnHeader(self,gesture):
12981300
gesture="kb:NVDA+shift+r")
12991301
def script_setRowHeader(self,gesture):
13001302
scriptCount=scriptHandler.getLastScriptRepeatCount()
1301-
if not config.conf['documentFormatting']['reportTableHeaders']:
1303+
if config.conf['documentFormatting']['reportTableHeaders'] == ReportTableHeaders.OFF:
13021304
# Translators: a message reported in the SetRowHeader script for Excel.
13031305
ui.message(_("Cannot set headers. Please enable reporting of table headers in Document Formatting Settings"))
13041306
return

source/appModules/outlook.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
import api
2727
import controlTypes
2828
import config
29+
from config.configFlags import ReportTableHeaders
2930
import speech
3031
import ui
3132
from NVDAObjects.IAccessible import IAccessible
@@ -509,7 +510,10 @@ def _get_name(self):
509510
continue
510511
name=e.cachedName
511512
columnHeaderTextList=[]
512-
if name and config.conf['documentFormatting']['reportTableHeaders']:
513+
if name and config.conf['documentFormatting']['reportTableHeaders'] in (
514+
ReportTableHeaders.ROWS_AND_COLUMNS,
515+
ReportTableHeaders.COLUMNS,
516+
):
513517
columnHeaderItems=e.getCachedPropertyValueEx(UIAHandler.UIA_TableItemColumnHeaderItemsPropertyId,True)
514518
else:
515519
columnHeaderItems=None

source/braille.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@
3232
import keyboardHandler
3333
import baseObject
3434
import config
35+
from config.configFlags import ReportTableHeaders
3536
from logHandler import log
3637
import controlTypes
3738
import api
@@ -794,7 +795,7 @@ def getControlFieldBraille( # noqa: C901
794795
"hasDetails": hasDetails,
795796
"detailsRole": detailsRole,
796797
}
797-
if reportTableHeaders:
798+
if reportTableHeaders in (ReportTableHeaders.ROWS_AND_COLUMNS, ReportTableHeaders.COLUMNS):
798799
props["columnHeaderText"] = field.get("table-columnheadertext")
799800
return getPropertiesBraille(**props)
800801

source/config/configFlags.py

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
# A part of NonVisual Desktop Access (NVDA)
2+
# Copyright (C) 2022 NV Access Limited, Cyrille Bougot
3+
# This file is covered by the GNU General Public License.
4+
# See the file COPYING for more details.
5+
6+
"""Flags used for the configuration.
7+
"""
8+
from enum import unique
9+
from utils.displayString import DisplayStringIntEnum
10+
11+
12+
@unique
13+
class ReportTableHeaders(DisplayStringIntEnum):
14+
"""The possible config values to report table headers.
15+
"""
16+
17+
OFF = 0
18+
ROWS_AND_COLUMNS = 1
19+
ROWS = 2
20+
COLUMNS = 3
21+
22+
@property
23+
def _displayStringLabels(self):
24+
return {
25+
# Translators: This is the label for a combobox in the
26+
# document formatting settings panel.
27+
ReportTableHeaders.OFF: _("Off"),
28+
# Translators: This is the label for a combobox in the
29+
# document formatting settings panel.
30+
ReportTableHeaders.ROWS_AND_COLUMNS: _("Rows and columns"),
31+
# Translators: This is the label for a combobox in the
32+
# document formatting settings panel.
33+
ReportTableHeaders.ROWS: _("Rows"),
34+
# Translators: This is the label for a combobox in the
35+
# document formatting settings panel.
36+
ReportTableHeaders.COLUMNS: _("Columns"),
37+
}

source/config/configSpec.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# -*- coding: UTF-8 -*-
22
# A part of NonVisual Desktop Access (NVDA)
33
# Copyright (C) 2006-2022 NV Access Limited, Babbage B.V., Davy Kager, Bill Dengler, Julien Cochuyt,
4-
# Joseph Lee, Dawid Pieper, mltony, Bram Duvigneau
4+
# Joseph Lee, Dawid Pieper, mltony, Bram Duvigneau, Cyrille Bougot
55
# This file is covered by the GNU General Public License.
66
# See the file COPYING for more details.
77

@@ -12,7 +12,7 @@
1212
#: provide an upgrade step (@see profileUpgradeSteps.py). An upgrade step does not need to be added when
1313
#: just adding a new element to (or removing from) the schema, only when old versions of the config
1414
#: (conforming to old schema versions) will not work correctly with the new schema.
15-
latestSchemaVersion = 7
15+
latestSchemaVersion = 8
1616

1717
#: The configuration specification string
1818
#: @type: String
@@ -207,7 +207,8 @@
207207
reportParagraphIndentation = boolean(default=False)
208208
reportTables = boolean(default=true)
209209
includeLayoutTables = boolean(default=False)
210-
reportTableHeaders = boolean(default=True)
210+
# 0: Off, 1: Rows and columns, 2: Rows, 3: Columns
211+
reportTableHeaders = integer(0, 3, default=1)
211212
reportTableCellCoords = boolean(default=True)
212213
reportBorderStyle = boolean(default=False)
213214
reportBorderColor = boolean(default=False)

source/config/profileUpgradeSteps.py

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# -*- coding: UTF-8 -*-
22
# A part of NonVisual Desktop Access (NVDA)
3-
# Copyright (C) 2016–2022 NV Access Limited, Bill Dengler
3+
# Copyright (C) 2016–2022 NV Access Limited, Bill Dengler, Cyrille Bougot
44
# This file is covered by the GNU General Public License.
55
# See the file COPYING for more details.
66

@@ -118,3 +118,19 @@ def upgradeConfigFrom_6_to_7(profile: Dict[str, str]) -> None:
118118
selectiveEventRegistration = False
119119
if selectiveEventRegistration:
120120
profile['UIA']['eventRegistration'] = "selective"
121+
122+
123+
def upgradeConfigFrom_7_to_8(profile: Dict[str, str]) -> None:
124+
"""
125+
In Document formatting settings, "Row/column headers" check box has been replaced with "Headers" combobox.
126+
"""
127+
try:
128+
reportTableHeaders = profile['documentFormatting']['reportTableHeaders']
129+
except KeyError:
130+
# Setting does not exist, no need for upgrade of this setting
131+
log.debug("reportTableHeaders not present, no action taken.")
132+
else:
133+
if reportTableHeaders:
134+
profile['documentFormatting']['reportTableHeaders'] = 1 # Rows and columns
135+
else:
136+
profile['documentFormatting']['reportTableHeaders'] = 0 # Off

source/globalCommands.py

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
# See the file COPYING for more details.
55
# Copyright (C) 2006-2022 NV Access Limited, Peter Vágner, Aleksey Sadovoy, Rui Batista, Joseph Lee,
66
# Leonard de Ruijter, Derek Riemer, Babbage B.V., Davy Kager, Ethan Holliger, Łukasz Golonka, Accessolutions,
7-
# Julien Cochuyt, Jakub Lukowicz, Bill Dengler
7+
# Julien Cochuyt, Jakub Lukowicz, Bill Dengler, Cyrille Bougot
88

99
import itertools
1010

@@ -667,19 +667,17 @@ def script_toggleReportTables(self,gesture):
667667

668668
@script(
669669
# Translators: Input help mode message for toggle report table row/column headers command.
670-
description=_("Toggles on and off the reporting of table row and column headers"),
670+
description=_("Cycle through the possible modes to report table row and column headers"),
671671
category=SCRCAT_DOCUMENTFORMATTING
672672
)
673673
def script_toggleReportTableHeaders(self,gesture):
674-
if config.conf["documentFormatting"]["reportTableHeaders"]:
675-
# Translators: The message announced when toggling the report table row/column headers document formatting setting.
676-
state = _("report table row and column headers off")
677-
config.conf["documentFormatting"]["reportTableHeaders"]=False
678-
else:
679-
# Translators: The message announced when toggling the report table row/column headers document formatting setting.
680-
state = _("report table row and column headers on")
681-
config.conf["documentFormatting"]["reportTableHeaders"]=True
682-
ui.message(state)
674+
from config.configFlags import ReportTableHeaders
675+
numVals = len(ReportTableHeaders)
676+
state = ReportTableHeaders((config.conf["documentFormatting"]["reportTableHeaders"] + 1) % numVals)
677+
config.conf["documentFormatting"]["reportTableHeaders"] = state.value
678+
# Translators: Reported when the user cycles through report table header modes.
679+
# {mode} will be replaced with the mode; e.g. None, Rows and columns, Rows or Columns.
680+
ui.message(_("Report table headers {mode}").format(mode=state.displayString))
683681

684682
@script(
685683
# Translators: Input help mode message for toggle report table cell coordinates command.

source/gui/settingsDialogs.py

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
import installer
2626
from synthDriverHandler import changeVoice, getSynth, getSynthList, setSynth, SynthDriver
2727
import config
28+
from config.configFlags import ReportTableHeaders
2829
import languageHandler
2930
import speech
3031
import gui
@@ -2395,11 +2396,18 @@ def makeSettings(self, settingsSizer):
23952396
self.tablesCheckBox = tablesGroup.addItem(wx.CheckBox(tablesGroupBox, label=_("&Tables")))
23962397
self.tablesCheckBox.SetValue(config.conf["documentFormatting"]["reportTables"])
23972398

2398-
# Translators: This is the label for a checkbox in the
2399-
# document formatting settings panel.
2400-
_tableHeadersCheckBox = wx.CheckBox(tablesGroupBox, label=_("Row/column h&eaders"))
2401-
self.tableHeadersCheckBox = tablesGroup.addItem(_tableHeadersCheckBox)
2402-
self.tableHeadersCheckBox.SetValue(config.conf["documentFormatting"]["reportTableHeaders"])
2399+
tableHeaderChoices = [i.displayString for i in ReportTableHeaders]
2400+
# The possible config values to report table headers, in the order they appear
2401+
# in the combo box.
2402+
self.tableHeaderVals = [i.value for i in ReportTableHeaders]
2403+
self.tableHeadersComboBox = tablesGroup.addLabeledControl(
2404+
# Translators: This is the label for a combobox in the
2405+
# document formatting settings panel.
2406+
_("H&eaders"),
2407+
wx.Choice,
2408+
choices=tableHeaderChoices,
2409+
)
2410+
self.tableHeadersComboBox.SetSelection(config.conf['documentFormatting']['reportTableHeaders'])
24032411

24042412
# Translators: This is the label for a checkbox in the
24052413
# document formatting settings panel.
@@ -2530,7 +2538,7 @@ def onSave(self):
25302538
config.conf["documentFormatting"]["reportParagraphIndentation"]=self.paragraphIndentationCheckBox.IsChecked()
25312539
config.conf["documentFormatting"]["reportLineSpacing"]=self.lineSpacingCheckBox.IsChecked()
25322540
config.conf["documentFormatting"]["reportTables"]=self.tablesCheckBox.IsChecked()
2533-
config.conf["documentFormatting"]["reportTableHeaders"]=self.tableHeadersCheckBox.IsChecked()
2541+
config.conf["documentFormatting"]["reportTableHeaders"] = self.tableHeadersComboBox.GetSelection()
25342542
config.conf["documentFormatting"]["reportTableCellCoords"]=self.tableCellCoordsCheckBox.IsChecked()
25352543
choice = self.borderComboBox.GetSelection()
25362544
config.conf["documentFormatting"]["reportBorderStyle"] = choice in (1,2)

0 commit comments

Comments
 (0)