From ff2841ea57f7df1148059d189dc49f46d730d051 Mon Sep 17 00:00:00 2001 From: Reef Turner Date: Mon, 24 Oct 2016 14:25:48 +0800 Subject: [PATCH] Report section numbers in MS word. Fixes #5946. When reading through a document, report when the section number changes. This is tied to the report page number setting (available in document formatting settings dialog) --- nvdaHelper/remote/WinWord/Constants.h | 5 ++++- nvdaHelper/remote/winword.cpp | 10 ++++++++++ source/speech.py | 7 +++++++ 3 files changed, 21 insertions(+), 1 deletion(-) diff --git a/nvdaHelper/remote/WinWord/Constants.h b/nvdaHelper/remote/WinWord/Constants.h index 6d2c8f9fb9b..40a494b5a97 100644 --- a/nvdaHelper/remote/WinWord/Constants.h +++ b/nvdaHelper/remote/WinWord/Constants.h @@ -1,7 +1,7 @@ /* This file is a part of the NVDA project. URL: http://www.nvda-project.org/ -Copyright 2006-2010 NVDA contributers. +Copyright 2016 NVDA contributers. This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License version 2.0, as published by the Free Software Foundation. @@ -12,6 +12,8 @@ This license can be found at: http://www.gnu.org/licenses/old-licenses/gpl-2.0.html */ +#pragma once + // See https://github.com/nvaccess/nvda/wiki/Using-COM-with-NVDA-and-Microsoft-Word constexpr int wdDISPID_APPLICATION_ISSANDBOX = 492; constexpr int wdDISPID_APPLICATION_SCREENUPDATING = 26; @@ -145,6 +147,7 @@ constexpr int wdCollapseEnd = 0; constexpr int wdCollapseStart = 1; constexpr int wdActiveEndAdjustedPageNumber = 1; +constexpr int wdActiveEndSectionNumber = 2; constexpr int wdFirstCharacterLineNumber = 10; constexpr int wdWithInTable = 12; constexpr int wdStartOfRangeRowNumber = 13; diff --git a/nvdaHelper/remote/winword.cpp b/nvdaHelper/remote/winword.cpp index 465da95afd1..d7c177b22e4 100644 --- a/nvdaHelper/remote/winword.cpp +++ b/nvdaHelper/remote/winword.cpp @@ -781,6 +781,15 @@ void winword_getTextInRange_helper(HWND hwnd, winword_getTextInRange_args* args) } } + const auto shouldReportSections = (initialFormatConfig&formatConfig_reportPage); + if(shouldReportSections) { + int sectionNumber = -1; + auto res = _com_dispatch_raw_method( pDispatchRange, wdDISPID_RANGE_INFORMATION, DISPATCH_PROPERTYGET, VT_I4, §ionNumber, L"\x0003", wdActiveEndSectionNumber); + if( S_OK == res && sectionNumber >= 0) { + initialFormatAttribsStream << L"section-number=\""<