NVDA Helper
In-process and lite high-speed utilities for NVDA
|
#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< int > | getSectionBreakType (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 () |
#define WIN32_LEAN_AND_MEAN |
void winword_expandToLine_helper | ( | HWND | hwnd, |
winword_expandToLine_args * | args ) |
References BOOL(), winword_expandToLine_args::lineEnd, winword_expandToLine_args::lineStart, LOG_DEBUGWARNING, winword_expandToLine_args::offset, wdDISPID_RANGE_END, wdDISPID_RANGE_EXPAND, wdDISPID_RANGE_SELECT, wdDISPID_RANGE_START, wdDISPID_SELECTION_ENDOF, wdDISPID_SELECTION_RANGE, wdDISPID_SELECTION_SETRANGE, wdDISPID_SELECTION_STARTISACTIVE, wdDISPID_SELECTION_STARTOF, wdDISPID_WINDOW_APPLICATION, wdDISPID_WINDOW_SELECTION, and wdLine.
Referenced by winword_callWndProcHook().
BOOL generateFormFieldXML | ( | IDispatch * | pDispatchRange, |
IDispatchPtr | pDispatchRangeExpandedToParagraph, | ||
wostringstream & | XMLStream, | ||
int & | chunkEnd ) |
References BOOL(), wdDISPID_CONTENTCONTROL_CHECKED, wdDISPID_CONTENTCONTROL_RANGE, wdDISPID_CONTENTCONTROL_TITLE, wdDISPID_CONTENTCONTROL_TYPE, wdDISPID_CONTENTCONTROLS_ITEM, wdDISPID_FORMFIELD_RANGE, wdDISPID_FORMFIELD_RESULT, wdDISPID_FORMFIELD_STATUSTEXT, wdDISPID_FORMFIELD_TYPE, wdDISPID_FORMFIELDS_ITEM, wdDISPID_RANGE_CONTENTCONTROLS, wdDISPID_RANGE_END, wdDISPID_RANGE_FORMFIELDS, and wdDISPID_RANGE_INRANGE.
Referenced by winword_getTextInRange_helper().
int getHeadingLevelFromParagraph | ( | IDispatch * | pDispatchParagraph | ) |
References headingStyleNames, wdDISPID_DOCUMENT_STYLES, wdDISPID_PARAGRAPH_STYLE, wdDISPID_STYLE_NAMELOCAL, wdDISPID_STYLE_PARENT, and wdDISPID_STYLES_ITEM.
Referenced by generateHeadingXML().
int generateHeadingXML | ( | IDispatch * | pDispatchParagraph, |
IDispatch * | pDispatchParagraphRange, | ||
int | startOffset, | ||
int | endOffset, | ||
wostringstream & | XMLStream ) |
References getHeadingLevelFromParagraph(), wdDISPID_RANGE_END, and wdDISPID_RANGE_START.
Referenced by winword_getTextInRange_helper().
IDispatchPtr CreateExpandedDuplicate | ( | IDispatch * | pDispatchRange, |
const int | expandTo ) |
References LOG_DEBUGWARNING, wdDISPID_RANGE_DUPLICATE, and wdDISPID_RANGE_EXPAND.
Referenced by winword_getTextInRange_helper().
bool collectCommentOffsets | ( | IDispatchPtr | pDispatchRange, |
vector< pair< long, long > > & | commentVector ) |
References wdDISPID_COMMENT_SCOPE, wdDISPID_COMMENTS_COUNT, wdDISPID_COMMENTS_ITEM, wdDISPID_RANGE_COMMENTS, wdDISPID_RANGE_END, and wdDISPID_RANGE_START.
Referenced by winword_getTextInRange_helper().
bool fetchTableInfo | ( | IDispatch * | pDispatchTable, |
bool | includeLayoutTables, | ||
int * | rowCount, | ||
int * | columnCount, | ||
int * | nestingLevel ) |
References BOOL(), wdDISPID_BORDERS_ENABLE, wdDISPID_COLUMNS_COUNT, wdDISPID_ROWS_COUNT, wdDISPID_TABLE_BORDERS, wdDISPID_TABLE_COLUMNS, wdDISPID_TABLE_NESTINGLEVEL, and wdDISPID_TABLE_ROWS.
Referenced by generateTableXML().
int generateTableXML | ( | IDispatch * | pDispatchRange, |
bool | includeLayoutTables, | ||
int | startOffset, | ||
int | endOffset, | ||
wostringstream & | XMLStream ) |
References appendCharToXML(), fetchTableInfo(), wdDISPID_CELL_COLUMNINDEX, wdDISPID_CELL_RANGE, wdDISPID_CELL_ROWINDEX, wdDISPID_CELLS_ITEM, wdDISPID_RANGE_CELLS, wdDISPID_RANGE_END, wdDISPID_RANGE_INFORMATION, wdDISPID_RANGE_START, wdDISPID_RANGE_TABLES, wdDISPID_TABLE_DESCR, wdDISPID_TABLE_RANGE, wdDISPID_TABLE_TITLE, wdDISPID_TABLES_ITEM, wdStartOfRangeColumnNumber, and wdStartOfRangeRowNumber.
Referenced by winword_getTextInRange_helper().
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().
|
inline |
References wdDISPID_INLINESHAPES_COUNT, and wdDISPID_RANGE_INLINESHAPES.
Referenced by winword_getTextInRange_helper().
|
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().
|
inline |
References wdDISPID_FOOTNOTE_INDEX, wdDISPID_FOOTNOTES_COUNT, wdDISPID_FOOTNOTES_ITEM, wdDISPID_RANGE_ENDNOTES, and wdDISPID_RANGE_FOOTNOTES.
Referenced by winword_getTextInRange_helper().
std::optional< int > getSectionBreakType | ( | IDispatchPtr | pDispatchRange | ) |
std::optional< float > getStartOfRangeDistanceFromEdgeOfDocument | ( | IDispatchPtr | pDispatchRange | ) |
References LOG_ERROR, wdDISPID_RANGE_INFORMATION, and wdHorizontalPositionRelativeToPage.
Referenced by detectAndGenerateColumnFormatXML().
std::optional< std::pair< float, float > > calculatePreAndPostColumnOffsets | ( | IDispatchPtr | pDispatchPageSetup | ) |
void detectAndGenerateColumnFormatXML | ( | IDispatchPtr | pDispatchRange, |
wostringstream & | xmlStream ) |
References calculatePreAndPostColumnOffsets(), getStartOfRangeDistanceFromEdgeOfDocument(), LOG_DEBUG, LOG_ERROR, wdDISPID_PAGESETUP_TEXTCOLUMNS, wdDISPID_RANGE_PAGESETUP, wdDISPID_TEXTCOLUMN_SPACEAFTER, wdDISPID_TEXTCOLUMN_WIDTH, wdDISPID_TEXTCOLUMNS_COUNT, and wdDISPID_TEXTCOLUMNS_ITEM.
Referenced by winword_getTextInRange_helper().
void winword_getTextInRange_helper | ( | HWND | hwnd, |
winword_getTextInRange_args * | args ) |
References appendCharToXML(), collectCommentOffsets(), collectRevisionOffsets(), collectSpellingErrorOffsets(), COLUMN_BREAK_VALUE, CreateExpandedDuplicate(), detectAndGenerateColumnFormatXML(), winword_getTextInRange_args::endOffset, winword_getTextInRange_args::formatConfig, formatConfig_includeLayoutTables, formatConfig_initialFormatFlags, formatConfig_reportComments, formatConfig_reportHeadings, formatConfig_reportLinks, formatConfig_reportPage, formatConfig_reportRevisions, formatConfig_reportSpellingErrors, formatConfig_reportTables, generateFootnoteEndnoteXML(), generateFormFieldXML(), generateHeadingXML(), generateInlineShapeXML(), generateTableXML(), generateXMLAttribsForFormatting(), WinWord::Fields::getEndOfPageNumberFieldAtIndex(), getInlineShapesCount(), getSectionBreakType(), WinWord::Fields::hasLinks(), LOG_DEBUGWARNING, PAGE_BREAK_VALUE, winword_getTextInRange_args::startOffset, winword_getTextInRange_args::text, wdActiveEndSectionNumber, wdCharacter, wdCollapseEnd, wdCollapseStart, wdCommentsStory, wdDISPID_PARAGRAPH_RANGE, wdDISPID_PARAGRAPHS_ITEM, wdDISPID_RANGE_COLLAPSE, wdDISPID_RANGE_END, wdDISPID_RANGE_INFORMATION, wdDISPID_RANGE_MOVEEND, wdDISPID_RANGE_PARAGRAPHS, wdDISPID_RANGE_SETRANGE, wdDISPID_RANGE_STORYTYPE, wdDISPID_RANGE_TEXT, wdDISPID_SELECTION_RANGE, wdDISPID_WINDOW_APPLICATION, wdDISPID_WINDOW_SELECTION, wdParagraph, and wdWord.
Referenced by winword_callWndProcHook().
void winword_moveByLine_helper | ( | HWND | hwnd, |
winword_moveByLine_args * | args ) |
References BOOL(), LOG_DEBUGWARNING, winword_moveByLine_args::moveBack, winword_moveByLine_args::newOffset, winword_moveByLine_args::offset, wdDISPID_RANGE_MOVE, wdDISPID_RANGE_SELECT, wdDISPID_RANGE_START, wdDISPID_SELECTION_RANGE, wdDISPID_SELECTION_SETRANGE, wdDISPID_SELECTION_STARTISACTIVE, wdDISPID_WINDOW_APPLICATION, wdDISPID_WINDOW_SELECTION, and wdLine.
Referenced by winword_callWndProcHook().
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 ) |
References winword_getTextInRange_args::text, and wm_winword_getTextInRange.
error_status_t nvdaInProcUtils_winword_moveByLine | ( | handle_t | bindingHandle, |
const unsigned long | windowHandle, | ||
const int | offset, | ||
const int | moveBack, | ||
int * | newOffset ) |
References winword_moveByLine_args::newOffset, and wm_winword_moveByLine.
void winword_inProcess_initialize | ( | ) |
References registerWindowsHook(), winword_callWndProcHook(), wm_winword_expandToLine, wm_winword_getTextInRange, and wm_winword_moveByLine.
Referenced by inProcess_initialize().
void winword_inProcess_terminate | ( | ) |
References unregisterWindowsHook(), and winword_callWndProcHook().
Referenced by inProcess_terminate().
|
constexpr |
Referenced by generateXMLAttribsForFormatting().
|
constexpr |
Referenced by generateXMLAttribsForFormatting().
|
constexpr |
Referenced by generateXMLAttribsForFormatting().
|
constexpr |
Referenced by generateXMLAttribsForFormatting().
|
constexpr |
Referenced by generateXMLAttribsForFormatting().
|
constexpr |
Referenced by generateXMLAttribsForFormatting().
|
constexpr |
Referenced by winword_getTextInRange_helper().
|
constexpr |
Referenced by generateXMLAttribsForFormatting(), and winword_getTextInRange_helper().
|
constexpr |
Referenced by generateXMLAttribsForFormatting().
|
constexpr |
Referenced by winword_getTextInRange_helper().
|
constexpr |
Referenced by generateXMLAttribsForFormatting().
|
constexpr |
Referenced by winword_getTextInRange_helper().
|
constexpr |
Referenced by winword_getTextInRange_helper().
|
constexpr |
Referenced by winword_getTextInRange_helper().
|
constexpr |
Referenced by generateXMLAttribsForFormatting().
|
constexpr |
Referenced by winword_getTextInRange_helper().
|
constexpr |
Referenced by generateXMLAttribsForFormatting().
|
constexpr |
Referenced by winword_getTextInRange_helper().
|
constexpr |
Referenced by generateXMLAttribsForFormatting().
|
constexpr |
Referenced by generateXMLAttribsForFormatting().
|
constexpr |
|
constexpr |
Referenced by generateXMLAttribsForFormatting().
|
constexpr |
Referenced by generateXMLAttribsForFormatting().
|
constexpr |
Referenced by winword_getTextInRange_helper().
|
constexpr |
Referenced by winword_getTextInRange_helper().
|
constexpr |
Referenced by winword_getTextInRange_helper().
UINT wm_winword_expandToLine =0 |
vector<wstring> headingStyleNames |
Referenced by getHeadingLevelFromParagraph().
UINT wm_winword_getTextInRange =0 |
UINT wm_winword_moveByLine =0 |
Referenced by nvdaInProcUtils_winword_moveByLine(), winword_callWndProcHook(), and winword_inProcess_initialize().