Skip to content

Commit

Permalink
Remove reporting of grammar errors, as this causes crashes in Microso…
Browse files Browse the repository at this point in the history
…ft Word.

This reverts commit 05c1eb7.
Re #5954.
  • Loading branch information
jcsteh committed Jun 10, 2016
1 parent 7fd029a commit a26c3ba
Show file tree
Hide file tree
Showing 6 changed files with 6 additions and 51 deletions.
19 changes: 5 additions & 14 deletions nvdaHelper/remote/winword.cpp
Expand Up @@ -73,7 +73,6 @@ using namespace std;
#define wdDISPID_CONTENTCONTROL_TITLE 12
#define wdDISPID_STYLE_NAMELOCAL 0
#define wdDISPID_STYLE_PARENT 1002
#define wdDISPID_RANGE_GRAMMATICALERRORS 315
#define wdDISPID_RANGE_SPELLINGERRORS 316
#define wdDISPID_SPELLINGERRORS_ITEM 0
#define wdDISPID_SPELLINGERRORS_COUNT 1
Expand Down Expand Up @@ -328,7 +327,7 @@ BOOL generateFormFieldXML(IDispatch* pDispatchRange, wostringstream& XMLStream,
return foundFormField;
}

bool collectSpellingGrammarErrorOffsets(int spellingGrammarErrorsDispId, IDispatchPtr pDispatchRange, vector<pair<long,long>>& errorVector) {
bool collectSpellingErrorOffsets(IDispatchPtr pDispatchRange, vector<pair<long,long>>& errorVector) {
IDispatchPtr pDispatchApplication=NULL;
if(_com_dispatch_raw_propget(pDispatchRange,wdDISPID_RANGE_APPLICATION ,VT_DISPATCH,&pDispatchApplication)!=S_OK||!pDispatchApplication) {
return false;
Expand All @@ -340,7 +339,7 @@ bool collectSpellingGrammarErrorOffsets(int spellingGrammarErrorsDispId, IDispat
return false;
}
IDispatchPtr pDispatchSpellingErrors=NULL;
if(_com_dispatch_raw_propget(pDispatchRange,spellingGrammarErrorsDispId,VT_DISPATCH,&pDispatchSpellingErrors)!=S_OK||!pDispatchSpellingErrors) {
if(_com_dispatch_raw_propget(pDispatchRange,wdDISPID_RANGE_SPELLINGERRORS,VT_DISPATCH,&pDispatchSpellingErrors)!=S_OK||!pDispatchSpellingErrors) {
return false;
}
long iVal=0;
Expand Down Expand Up @@ -846,11 +845,9 @@ void winword_getTextInRange_helper(HWND hwnd, winword_getTextInRange_args* args)
}
//Check for any inline shapes in the entire range to work out whether its worth checking for them by word
bool hasInlineShapes=(getInlineShapesCount(pDispatchRange)>0);
vector<pair<long,long> > spellingErrorVector;
vector<pair<long,long> > grammarErrorVector;
vector<pair<long,long> > errorVector;
if(formatConfig&formatConfig_reportSpellingErrors) {
collectSpellingGrammarErrorOffsets(wdDISPID_RANGE_SPELLINGERRORS,pDispatchRange,spellingErrorVector);
collectSpellingGrammarErrorOffsets(wdDISPID_RANGE_GRAMMATICALERRORS,pDispatchRange,grammarErrorVector);
collectSpellingErrorOffsets(pDispatchRange,errorVector);
}
_com_dispatch_raw_method(pDispatchRange,wdDISPID_RANGE_COLLAPSE,DISPATCH_METHOD,VT_EMPTY,NULL,L"\x0003",wdCollapseStart);
int chunkStartOffset=args->startOffset;
Expand Down Expand Up @@ -949,18 +946,12 @@ void winword_getTextInRange_helper(HWND hwnd, winword_getTextInRange_args* args)
XMLStream<<L"<text _startOffset=\""<<chunkStartOffset<<L"\" _endOffset=\""<<chunkEndOffset<<L"\" ";
XMLStream<<initialFormatAttribsStream.str();
generateXMLAttribsForFormatting(pDispatchRange,chunkStartOffset,chunkEndOffset,formatConfig&(~curDisabledFormatConfig),XMLStream);
for(auto i=spellingErrorVector.cbegin();i!=spellingErrorVector.cend();++i) {
for(vector<pair<long,long>>::iterator i=errorVector.begin();i!=errorVector.end();++i) {
if(chunkStartOffset>=i->first&&chunkStartOffset<i->second) {
XMLStream<<L" invalid-spelling=\"1\" ";
break;
}
}
for(auto i=grammarErrorVector.cbegin();i!=grammarErrorVector.cend();++i) {
if(chunkStartOffset>=i->first&&chunkStartOffset<i->second) {
XMLStream<<L" invalid-grammar=\"1\" ";
break;
}
}
for(vector<pair<long,long>>::iterator i=commentVector.begin();i!=commentVector.end();++i) {
if(!(chunkStartOffset>=i->second||chunkEndOffset<=i->first)) {
XMLStream<<L" comment=\""<<(i->second)<<L"\" ";
Expand Down
1 change: 0 additions & 1 deletion source/config/__init__.py
Expand Up @@ -174,7 +174,6 @@ def validateConfig(configObj,validator,validationResult=None,keyList=None):
reportAlignment = boolean(default=false)
reportStyle = boolean(default=false)
reportSpellingErrors = boolean(default=true)
reportGrammarErrors = boolean(default=true)
reportPage = boolean(default=true)
reportLineNumber = boolean(default=False)
reportLineIndentation = boolean(default=False)
Expand Down
16 changes: 1 addition & 15 deletions source/globalCommands.py
Expand Up @@ -430,20 +430,6 @@ def script_toggleReportSpellingErrors(self,gesture):
script_toggleReportSpellingErrors.__doc__=_("Toggles on and off the reporting of spelling errors")
script_toggleReportSpellingErrors.category=SCRCAT_DOCUMENTFORMATTING

def script_toggleReportGrammarErrors(self,gesture):
if config.conf["documentFormatting"]["reportGrammarErrors"]:
# Translators: The message announced when toggling the report grammar errors document formatting setting.
state = _("report grammar errors off")
config.conf["documentFormatting"]["reportGrammarErrors"]=False
else:
# Translators: The message announced when toggling the report grammar errors document formatting setting.
state = _("report grammar errors on")
config.conf["documentFormatting"]["reportGrammarErrors"]=True
ui.message(state)
# Translators: Input help mode message for toggle report grammar errors command.
script_toggleReportGrammarErrors.__doc__=_("Toggles on and off the reporting of grammar errors")
script_toggleReportGrammarErrors.category=SCRCAT_DOCUMENTFORMATTING

def script_toggleReportPage(self,gesture):
if config.conf["documentFormatting"]["reportPage"]:
# Translators: The message announced when toggling the report pages document formatting setting.
Expand Down Expand Up @@ -1240,7 +1226,7 @@ def script_reportFormatting(self,gesture):
formatConfig={
"detectFormatAfterCursor":False,
"reportFontName":True,"reportFontSize":True,"reportFontAttributes":True,"reportColor":True,"reportRevisions":False,"reportEmphasis":False,
"reportStyle":True,"reportAlignment":True,"reportSpellingErrors":True,"reportGrammarErrors":True,
"reportStyle":True,"reportAlignment":True,"reportSpellingErrors":True,
"reportPage":False,"reportLineNumber":False,"reportParagraphIndentation":True,"reportTables":False,
"reportLinks":False,"reportHeadings":False,"reportLists":False,
"reportBlockQuotes":False,"reportComments":False,
Expand Down
6 changes: 0 additions & 6 deletions source/gui/settingsDialogs.py
Expand Up @@ -1098,11 +1098,6 @@ def makeSettings(self, settingsSizer):
settingsSizer.Add(self.spellingErrorsCheckBox,border=10,flag=wx.BOTTOM)
# Translators: This is the label for a checkbox in the
# document formatting settings dialog.
self.grammarErrorsCheckBox=wx.CheckBox(self,wx.ID_ANY,label=_("Report &grammar errors"))
self.grammarErrorsCheckBox.SetValue(config.conf["documentFormatting"]["reportGrammarErrors"])
settingsSizer.Add(self.grammarErrorsCheckBox,border=10,flag=wx.BOTTOM)
# Translators: This is the label for a checkbox in the
# document formatting settings dialog.
self.pageCheckBox=wx.CheckBox(self,wx.NewId(),label=_("Report &pages"))
self.pageCheckBox.SetValue(config.conf["documentFormatting"]["reportPage"])
settingsSizer.Add(self.pageCheckBox,border=10,flag=wx.BOTTOM)
Expand Down Expand Up @@ -1187,7 +1182,6 @@ def onOk(self,evt):
config.conf["documentFormatting"]["reportAlignment"]=self.alignmentCheckBox.IsChecked()
config.conf["documentFormatting"]["reportStyle"]=self.styleCheckBox.IsChecked()
config.conf["documentFormatting"]["reportSpellingErrors"]=self.spellingErrorsCheckBox.IsChecked()
config.conf["documentFormatting"]["reportGrammarErrors"]=self.grammarErrorsCheckBox.IsChecked()
config.conf["documentFormatting"]["reportPage"]=self.pageCheckBox.IsChecked()
config.conf["documentFormatting"]["reportLineNumber"]=self.lineNumberCheckBox.IsChecked()
config.conf["documentFormatting"]["reportLineIndentation"]=self.lineIndentationCheckBox.IsChecked()
Expand Down
14 changes: 0 additions & 14 deletions source/speech.py
Expand Up @@ -1424,20 +1424,6 @@ def getFormatFieldSpeech(attrs,attrsCache=None,formatConfig=None,unit=None,extra
text=""
if text:
textList.append(text)
if formatConfig["reportGrammarErrors"]:
invalidGrammar=attrs.get("invalid-grammar")
oldInvalidGrammar=attrsCache.get("invalid-grammar") if attrsCache is not None else None
if (invalidGrammar or oldInvalidGrammar is not None) and invalidGrammar!=oldInvalidGrammar:
if invalidGrammar:
# Translators: Reported when text contains a grammar error.
text=_("grammar error")
elif extraDetail:
# Translators: Reported when moving out of text containing a grammar error.
text=_("out of grammar error")
else:
text=""
if text:
textList.append(text)
if unit in (textInfos.UNIT_LINE,textInfos.UNIT_SENTENCE,textInfos.UNIT_PARAGRAPH,textInfos.UNIT_READINGCHUNK):
linePrefix=attrs.get("line-prefix")
if linePrefix:
Expand Down
1 change: 0 additions & 1 deletion user_docs/en/userGuide.t2t
Expand Up @@ -1194,7 +1194,6 @@ You can configure reporting of:
- Emphasis
- Text style
- Spelling errors
- Grammar errors
- Page numbers
- Line numbers
- Line indentation
Expand Down

0 comments on commit a26c3ba

Please sign in to comment.