Skip to content

Commit 47af401

Browse files
authored
For single column SysListViews, ignore column order array as it is not required (#13761)
Fixes #13659, #13735 Summary of the issue: Certain applications don't provide a column order array. For the case of single column list views, a column order array is unnecessary, as a default mapping can be assumed. Description of how this pull request fixes the issue: For single column list views, map the first column in the UX, to the first column index: i.e. [0] is the column order array. When fetching from a multi column list view, log an error if the column order array is unknown.
1 parent fa15d49 commit 47af401

2 files changed

Lines changed: 38 additions & 17 deletions

File tree

source/NVDAObjects/IAccessible/sysListView32.py

Lines changed: 37 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -217,7 +217,10 @@ def _get_isMultiColumn(self):
217217
def _get_rowCount(self):
218218
return watchdog.cancellableSendMessage(self.windowHandle, LVM_GETITEMCOUNT, 0, 0)
219219

220-
def _get_columnCount(self):
220+
columnCount: int
221+
"""Typing information for auto-property: _get_columnCount"""
222+
223+
def _get_columnCount(self) -> int:
221224
if not self.isMultiColumn:
222225
return 0
223226
headerHwnd= watchdog.cancellableSendMessage(self.windowHandle,LVM_GETHEADER,0,0)
@@ -287,10 +290,27 @@ def _getColumnOrderArrayRaw(self, columnCount: int) -> Optional[ctypes.Array]:
287290
return self._getColumnOrderArrayRawOutProc(columnCount)
288291
return self._getColumnOrderArrayRawInProc(columnCount)
289292

290-
_columnOrderArray: Optional[ctypes.Array]
291-
292-
def _get__columnOrderArray(self) -> Optional[ctypes.Array]:
293-
return self._getColumnOrderArrayRaw(self.columnCount)
293+
def _getMappedColumn(self, presentationIndex: int) -> Optional[int]:
294+
"""
295+
Multi-column SysListViews can have their columns re-ordered.
296+
To keep a consistent internal mapping, a column order array is used
297+
to map a presentation index to a consistent internal index.
298+
For single-column SysListViews, the mapping is not necessary.
299+
If the column order array cannot be fetched from a multi-column SysListView,
300+
this returns None.
301+
302+
@param presentationIndex: One based index for the column as presented to the user.
303+
@return: The internal / logical column zero based index for the column.
304+
None if the mapped column cannot be determined.
305+
"""
306+
if presentationIndex == 1 and self.columnCount == 1:
307+
# Use an implied default column mapping for single column list views
308+
return 0
309+
columnOrderArray = self._getColumnOrderArrayRaw(self.columnCount)
310+
if columnOrderArray is None:
311+
log.error("Cannot fetch column as column order array is unknown")
312+
return None
313+
return columnOrderArray[presentationIndex - 1]
294314

295315

296316
class GroupingItem(Window):
@@ -454,10 +474,10 @@ def _getColumnLocationRaw(self, index: int) -> Optional[RectLTRB]:
454474
return RectLTRB(left, top, right, bottom).toScreen(self.windowHandle).toLTWH()
455475

456476
def _getColumnLocation(self, column: int) -> Optional[RectLTRB]:
457-
if self.parent._columnOrderArray is None:
458-
log.debugWarning("Cannot fetch column location as column order array is unknown")
477+
mappedColumn = self.parent._getMappedColumn(column)
478+
if mappedColumn is None:
459479
return None
460-
return self._getColumnLocationRaw(self.parent._columnOrderArray[column - 1])
480+
return self._getColumnLocationRaw(mappedColumn)
461481

462482
def _getColumnContentRawInProc(self, index: int) -> Optional[str]:
463483
"""Retrieves text for a given column.
@@ -510,10 +530,10 @@ def _getColumnContentRaw(self, index: int) -> Optional[str]:
510530
return self._getColumnContentRawInProc(index)
511531

512532
def _getColumnContent(self, column: int) -> Optional[str]:
513-
if self.parent._columnOrderArray is None:
514-
log.debugWarning("Cannot fetch column content as column order array is unknown")
533+
mappedColumn = self.parent._getMappedColumn(column)
534+
if mappedColumn is None:
515535
return None
516-
return self._getColumnContentRaw(self.parent._columnOrderArray[column - 1])
536+
return self._getColumnContentRaw(mappedColumn)
517537

518538
def _getColumnImageIDRaw(self, index):
519539
processHandle=self.processHandle
@@ -530,10 +550,10 @@ def _getColumnImageIDRaw(self, index):
530550
return item.iImage
531551

532552
def _getColumnImageID(self, column):
533-
if self.parent._columnOrderArray is None:
534-
log.debugWarning("Cannot fetch column image ID as column order array is unknown")
553+
mappedColumn = self.parent._getMappedColumn(column)
554+
if mappedColumn is None:
535555
return None
536-
return self._getColumnImageIDRaw(self.parent._columnOrderArray[column - 1])
556+
return self._getColumnImageIDRaw(mappedColumn)
537557

538558
def _getColumnHeaderRawOutProc(self, index: int) -> Optional[str]:
539559
"""Retrieves text of the header for the given column.
@@ -584,10 +604,10 @@ def _getColumnHeaderRaw(self, index: int) -> Optional[str]:
584604
return self._getColumnHeaderRawInProc(index)
585605

586606
def _getColumnHeader(self, column: int) -> Optional[str]:
587-
if self.parent._columnOrderArray is None:
588-
log.debugWarning("Cannot fetch column header as column order array is unknown")
607+
mappedColumn = self.parent._getMappedColumn(column)
608+
if mappedColumn is None:
589609
return None
590-
return self._getColumnHeaderRaw(self.parent._columnOrderArray[column - 1])
610+
return self._getColumnHeaderRaw(mappedColumn)
591611

592612
def _get_name(self):
593613
parent = self.parent

user_docs/en/changes.t2t

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,7 @@ What's New in NVDA
6363
- Hidden text is no longer announced in Wordpad and other ``richEdit`` controls. (#13618)
6464
- NVDA will announce status bar content in Windows 11 Notepad. (#13386)
6565
- Navigator object highlighting now shows up immediately upon activation of the feature. (#13641)
66+
- Fix reading single column list view items. (#13659, #13735)
6667
-
6768

6869

0 commit comments

Comments
 (0)