From 1d78fb227ff7006b7ffbc8284aaf4ac38c0cc03e Mon Sep 17 00:00:00 2001 From: Michael Curran Date: Tue, 26 Mar 2013 11:42:05 +1000 Subject: [PATCH] Microsoft word: don't expose a language for format changes that only contains whitepsace. This is mostly needed as MS Word only marks east-asian characters (not whitespace) as an asian language, and it falls back to english US or another european langage for whitepsace. Now all whitespace has no language and therefore NVDA uses the synth or interface language. A fix for #2047 --- source/NVDAObjects/window/winword.py | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/source/NVDAObjects/window/winword.py b/source/NVDAObjects/window/winword.py index 18bc14b5b..17880dd89 100755 --- a/source/NVDAObjects/window/winword.py +++ b/source/NVDAObjects/window/winword.py @@ -187,13 +187,21 @@ class WordDocumentTextInfo(textInfos.TextInfo): log.debugWarning("winword_getTextInRange failed with %d"%res) return [self.text] commandList=XMLFormatting.XMLTextParser().parse(text.value) - for index in xrange(len(commandList)): - if isinstance(commandList[index],textInfos.FieldCommand): - field=commandList[index].field + for index,item in enumerate(commandList): + if isinstance(item,textInfos.FieldCommand): + field=item.field if isinstance(field,textInfos.ControlField): - commandList[index].field=self._normalizeControlField(field) + item.field=self._normalizeControlField(field) elif isinstance(field,textInfos.FormatField): - commandList[index].field=self._normalizeFormatField(field) + item.field=self._normalizeFormatField(field) + elif index>0 and isinstance(item,basestring) and item.isspace(): + #2047: don't expose language for whitespace as its incorrect for east-asian languages + lastItem=commandList[index-1] + if isinstance(lastItem,textInfos.FieldCommand) and isinstance(lastItem.field,textInfos.FormatField): + try: + del lastItem.field['language'] + except KeyError: + pass return commandList def _normalizeControlField(self,field): -- 2.11.0