NVDA Helper
In-process and lite high-speed utilities for NVDA
winword.cpp File Reference
#include <sstream>
#include <vector>
#include <comdef.h>
#include <windows.h>
#include <oleacc.h>
#include <common/xml.h>
#include <common/log.h>
#include <optional>
#include "nvdaHelperRemote.h"
#include <remote/nvdaInProcUtils.h>
#include <remote/WinWord/Constants.h>
#include <remote/WinWord/Fields.h>
#include "winword.h"

Go to the source code of this file.

Classes

class  ScreenUpdatingDisabler
 
struct  winword_expandToLine_args
 
struct  winword_getTextInRange_args
 
struct  winword_moveByLine_args
 

Macros

#define WIN32_LEAN_AND_MEAN
 

Functions

void winword_expandToLine_helper (HWND hwnd, winword_expandToLine_args *args)
 
BOOL generateFormFieldXML (IDispatch *pDispatchRange, IDispatchPtr pDispatchRangeExpandedToParagraph, wostringstream &XMLStream, int &chunkEnd)
 
bool collectSpellingErrorOffsets (IDispatchPtr pDispatchRange, vector< pair< long, long > > &errorVector)
 
int getHeadingLevelFromParagraph (IDispatch *pDispatchParagraph)
 
int generateHeadingXML (IDispatch *pDispatchParagraph, IDispatch *pDispatchParagraphRange, int startOffset, int endOffset, wostringstream &XMLStream)
 
IDispatchPtr CreateExpandedDuplicate (IDispatch *pDispatchRange, const int expandTo)
 
bool collectCommentOffsets (IDispatchPtr pDispatchRange, vector< pair< long, long > > &commentVector)
 
bool collectRevisionOffsets (IDispatchPtr pDispatchRange, vector< tuple< long, long, long > > &revisionsVector)
 
bool fetchTableInfo (IDispatch *pDispatchTable, bool includeLayoutTables, int *rowCount, int *columnCount, int *nestingLevel)
 
int generateTableXML (IDispatch *pDispatchRange, bool includeLayoutTables, int startOffset, int endOffset, wostringstream &XMLStream)
 
void generateXMLAttribsForFormatting (IDispatch *pDispatchRange, int startOffset, int endOffset, int formatConfig, wostringstream &formatAttribsStream)
 
int getInlineShapesCount (IDispatch *pDispatchRange)
 
int generateInlineShapeXML (IDispatch *pDispatchRange, int offset, wostringstream &XMLStream)
 Generates an opening tag for the first inline shape in this range if one exists.
 
bool generateFootnoteEndnoteXML (IDispatch *pDispatchRange, wostringstream &XMLStream, bool footnote)
 
std::optional< intgetSectionBreakType (IDispatchPtr pDispatchRange)
 
std::optional< float > getStartOfRangeDistanceFromEdgeOfDocument (IDispatchPtr pDispatchRange)
 
std::optional< std::pair< float, float > > calculatePreAndPostColumnOffsets (IDispatchPtr pDispatchPageSetup)
 
void detectAndGenerateColumnFormatXML (IDispatchPtr pDispatchRange, wostringstream &xmlStream)
 
void winword_getTextInRange_helper (HWND hwnd, winword_getTextInRange_args *args)
 
void winword_moveByLine_helper (HWND hwnd, winword_moveByLine_args *args)
 
LRESULT CALLBACK winword_callWndProcHook (int code, WPARAM wParam, LPARAM lParam)
 
error_status_t nvdaInProcUtils_winword_expandToLine (handle_t bindingHandle, const unsigned long windowHandle, const int offset, int *lineStart, int *lineEnd)
 
error_status_t nvdaInProcUtils_winword_getTextInRange (handle_t bindingHandle, const unsigned long windowHandle, const int startOffset, const int endOffset, const long formatConfig, BSTR *text)
 
error_status_t nvdaInProcUtils_winword_moveByLine (handle_t bindingHandle, const unsigned long windowHandle, const int offset, const int moveBack, int *newOffset)
 
void winword_inProcess_initialize ()
 
void winword_inProcess_terminate ()
 

Variables

constexpr int formatConfig_reportFontName = 0x1
 
constexpr int formatConfig_reportFontSize = 0x2
 
constexpr int formatConfig_reportFontAttributes = 0x4
 
constexpr int formatConfig_reportColor = 0x8
 
constexpr int formatConfig_reportAlignment = 0x10
 
constexpr int formatConfig_reportStyle = 0x20
 
constexpr int formatConfig_reportSpellingErrors = 0x40
 
constexpr int formatConfig_reportPage = 0x80
 
constexpr int formatConfig_reportLineNumber = 0x100
 
constexpr int formatConfig_reportTables = 0x200
 
constexpr int formatConfig_reportLists = 0x400
 
constexpr int formatConfig_reportLinks = 0x800
 
constexpr int formatConfig_reportComments = 0x1000
 
constexpr int formatConfig_reportHeadings = 0x2000
 
constexpr int formatConfig_reportLanguage = 0x4000
 
constexpr int formatConfig_reportRevisions = 0x8000
 
constexpr int formatConfig_reportParagraphIndentation = 0x10000
 
constexpr int formatConfig_includeLayoutTables = 0x20000
 
constexpr int formatConfig_reportLineSpacing = 0x40000
 
constexpr int formatConfig_reportSuperscriptsAndSubscripts = 0x80000
 
constexpr int formatConfig_reportGraphics = 0x100000
 
constexpr int formatConfig_reportHighlightColor = 0x200000
 
constexpr int formatConfig_fontFlags =(formatConfig_reportFontName|formatConfig_reportFontSize|formatConfig_reportFontAttributes|formatConfig_reportColor|formatConfig_reportSuperscriptsAndSubscripts)
 
constexpr int formatConfig_initialFormatFlags =(formatConfig_reportPage|formatConfig_reportLineNumber|formatConfig_reportTables|formatConfig_reportHeadings|formatConfig_includeLayoutTables)
 
constexpr wchar_t PAGE_BREAK_VALUE = L'\x0c'
 
constexpr wchar_t COLUMN_BREAK_VALUE = L'\x0e'
 
UINT wm_winword_expandToLine =0
 
vector< wstring > headingStyleNames
 
UINT wm_winword_getTextInRange =0
 
UINT wm_winword_moveByLine =0
 

Macro Definition Documentation

◆ WIN32_LEAN_AND_MEAN

#define WIN32_LEAN_AND_MEAN

Function Documentation

◆ winword_expandToLine_helper()

◆ generateFormFieldXML()

◆ collectSpellingErrorOffsets()

bool collectSpellingErrorOffsets ( IDispatchPtr pDispatchRange,
vector< pair< long, long > > & errorVector )

◆ getHeadingLevelFromParagraph()

int getHeadingLevelFromParagraph ( IDispatch * pDispatchParagraph)

◆ generateHeadingXML()

int generateHeadingXML ( IDispatch * pDispatchParagraph,
IDispatch * pDispatchParagraphRange,
int startOffset,
int endOffset,
wostringstream & XMLStream )

◆ CreateExpandedDuplicate()

IDispatchPtr CreateExpandedDuplicate ( IDispatch * pDispatchRange,
const int expandTo )

◆ collectCommentOffsets()

bool collectCommentOffsets ( IDispatchPtr pDispatchRange,
vector< pair< long, long > > & commentVector )

◆ collectRevisionOffsets()

bool collectRevisionOffsets ( IDispatchPtr pDispatchRange,
vector< tuple< long, long, long > > & revisionsVector )

◆ fetchTableInfo()

bool fetchTableInfo ( IDispatch * pDispatchTable,
bool includeLayoutTables,
int * rowCount,
int * columnCount,
int * nestingLevel )

◆ generateTableXML()

◆ generateXMLAttribsForFormatting()

void generateXMLAttribsForFormatting ( IDispatch * pDispatchRange,
int startOffset,
int endOffset,
int formatConfig,
wostringstream & formatAttribsStream )

References appendCharToXML(), formatConfig_fontFlags, formatConfig_reportAlignment, formatConfig_reportColor, formatConfig_reportFontAttributes, formatConfig_reportFontName, formatConfig_reportFontSize, formatConfig_reportHighlightColor, formatConfig_reportLanguage, formatConfig_reportLineNumber, formatConfig_reportLineSpacing, formatConfig_reportLists, formatConfig_reportPage, formatConfig_reportParagraphIndentation, formatConfig_reportStyle, formatConfig_reportSuperscriptsAndSubscripts, wdActiveEndAdjustedPageNumber, wdAlignParagraphCenter, wdAlignParagraphDistribute, wdAlignParagraphJustify, wdAlignParagraphLeft, wdAlignParagraphRight, wdDISPID_FONT_BOLD, wdDISPID_FONT_COLOR, wdDISPID_FONT_DOUBLESTRIKETHROUGH, wdDISPID_FONT_HIDDEN, wdDISPID_FONT_ITALIC, wdDISPID_FONT_NAME, wdDISPID_FONT_SIZE, wdDISPID_FONT_STRIKETHROUGH, wdDISPID_FONT_SUBSCRIPT, wdDISPID_FONT_SUPERSCRIPT, wdDISPID_FONT_UNDERLINE, wdDISPID_LISTFORMAT_LISTSTRING, wdDISPID_PARAGRAPH_RANGE, wdDISPID_PARAGRAPHFORMAT_ALIGNMENT, wdDISPID_PARAGRAPHFORMAT_FIRSTLINEINDENT, wdDISPID_PARAGRAPHFORMAT_LEFTINDENT, wdDISPID_PARAGRAPHFORMAT_LINESPACING, wdDISPID_PARAGRAPHFORMAT_LINESPACINGRULE, wdDISPID_PARAGRAPHFORMAT_RIGHTINDENT, wdDISPID_PARAGRAPHFORMAT_SHADING, wdDISPID_PARAGRAPHS_ITEM, wdDISPID_RANGE_FONT, wdDISPID_RANGE_HIGHLIGHTCOLORINDEX, wdDISPID_RANGE_INFORMATION, wdDISPID_RANGE_LANGUAGEID, wdDISPID_RANGE_LISTFORMAT, wdDISPID_RANGE_PARAGRAPHFORMAT, wdDISPID_RANGE_PARAGRAPHS, wdDISPID_RANGE_START, wdDISPID_RANGE_STYLE, wdDISPID_SHADING_BACKGROUNDPATTERNCOLOR, wdDISPID_STYLE_NAMELOCAL, wdFirstCharacterLineNumber, wdLanguageNone, wdLanguageUnknown, and wdNoProofing.

Referenced by winword_getTextInRange_helper().

◆ getInlineShapesCount()

int getInlineShapesCount ( IDispatch * pDispatchRange)
inline

◆ generateInlineShapeXML()

int generateInlineShapeXML ( IDispatch * pDispatchRange,
int offset,
wostringstream & XMLStream )
inline

Generates an opening tag for the first inline shape in this range if one exists.

If the function is successful, the total number of inline shapes for this range is returned allowing the caller to then perhaps move the range forward a character and try again.

References appendCharToXML(), BOOL(), wdDISPID_INLINESHAPE_ALTERNATIVETEXT, wdDISPID_INLINESHAPE_OLEFORMAT, wdDISPID_INLINESHAPE_TITLE, wdDISPID_INLINESHAPE_TYPE, wdDISPID_INLINESHAPES_COUNT, wdDISPID_INLINESHAPES_ITEM, wdDISPID_OLEFORMAT_PROGID, wdDISPID_RANGE_INLINESHAPES, wdInlineShapeChart, wdInlineShapeEmbeddedOLEObject, wdInlineShapeLinkedPicture, and wdInlineShapePicture.

Referenced by winword_getTextInRange_helper().

◆ generateFootnoteEndnoteXML()

bool generateFootnoteEndnoteXML ( IDispatch * pDispatchRange,
wostringstream & XMLStream,
bool footnote )
inline

◆ getSectionBreakType()

◆ getStartOfRangeDistanceFromEdgeOfDocument()

std::optional< float > getStartOfRangeDistanceFromEdgeOfDocument ( IDispatchPtr pDispatchRange)

◆ calculatePreAndPostColumnOffsets()

◆ detectAndGenerateColumnFormatXML()

◆ winword_getTextInRange_helper()

void winword_getTextInRange_helper ( HWND hwnd,
winword_getTextInRange_args * args )

◆ winword_moveByLine_helper()

◆ winword_callWndProcHook()

◆ nvdaInProcUtils_winword_expandToLine()

error_status_t nvdaInProcUtils_winword_expandToLine ( handle_t bindingHandle,
const unsigned long windowHandle,
const int offset,
int * lineStart,
int * lineEnd )

◆ nvdaInProcUtils_winword_getTextInRange()

error_status_t nvdaInProcUtils_winword_getTextInRange ( handle_t bindingHandle,
const unsigned long windowHandle,
const int startOffset,
const int endOffset,
const long formatConfig,
BSTR * text )

◆ nvdaInProcUtils_winword_moveByLine()

error_status_t nvdaInProcUtils_winword_moveByLine ( handle_t bindingHandle,
const unsigned long windowHandle,
const int offset,
const int moveBack,
int * newOffset )

◆ winword_inProcess_initialize()

◆ winword_inProcess_terminate()

void winword_inProcess_terminate ( )

Variable Documentation

◆ formatConfig_reportFontName

int formatConfig_reportFontName = 0x1
constexpr

◆ formatConfig_reportFontSize

int formatConfig_reportFontSize = 0x2
constexpr

◆ formatConfig_reportFontAttributes

int formatConfig_reportFontAttributes = 0x4
constexpr

◆ formatConfig_reportColor

int formatConfig_reportColor = 0x8
constexpr

◆ formatConfig_reportAlignment

int formatConfig_reportAlignment = 0x10
constexpr

◆ formatConfig_reportStyle

int formatConfig_reportStyle = 0x20
constexpr

◆ formatConfig_reportSpellingErrors

int formatConfig_reportSpellingErrors = 0x40
constexpr

◆ formatConfig_reportPage

int formatConfig_reportPage = 0x80
constexpr

◆ formatConfig_reportLineNumber

int formatConfig_reportLineNumber = 0x100
constexpr

◆ formatConfig_reportTables

int formatConfig_reportTables = 0x200
constexpr

◆ formatConfig_reportLists

int formatConfig_reportLists = 0x400
constexpr

◆ formatConfig_reportLinks

int formatConfig_reportLinks = 0x800
constexpr

◆ formatConfig_reportComments

int formatConfig_reportComments = 0x1000
constexpr

◆ formatConfig_reportHeadings

int formatConfig_reportHeadings = 0x2000
constexpr

◆ formatConfig_reportLanguage

int formatConfig_reportLanguage = 0x4000
constexpr

◆ formatConfig_reportRevisions

int formatConfig_reportRevisions = 0x8000
constexpr

◆ formatConfig_reportParagraphIndentation

int formatConfig_reportParagraphIndentation = 0x10000
constexpr

◆ formatConfig_includeLayoutTables

int formatConfig_includeLayoutTables = 0x20000
constexpr

◆ formatConfig_reportLineSpacing

int formatConfig_reportLineSpacing = 0x40000
constexpr

◆ formatConfig_reportSuperscriptsAndSubscripts

int formatConfig_reportSuperscriptsAndSubscripts = 0x80000
constexpr

◆ formatConfig_reportGraphics

int formatConfig_reportGraphics = 0x100000
constexpr

◆ formatConfig_reportHighlightColor

int formatConfig_reportHighlightColor = 0x200000
constexpr

◆ formatConfig_fontFlags

◆ formatConfig_initialFormatFlags

◆ PAGE_BREAK_VALUE

wchar_t PAGE_BREAK_VALUE = L'\x0c'
constexpr

◆ COLUMN_BREAK_VALUE

wchar_t COLUMN_BREAK_VALUE = L'\x0e'
constexpr

◆ wm_winword_expandToLine

◆ headingStyleNames

vector<wstring> headingStyleNames

◆ wm_winword_getTextInRange

◆ wm_winword_moveByLine