From 85d5277e99b6d8a1c2ff7c09b11bba67a5648234 Mon Sep 17 00:00:00 2001
From: Leonard de Ruijter <alderuijter@gmail.com>
Date: Thu, 22 Jan 2015 11:37:11 +0100
Subject: [PATCH] Initial implementation of the possibility to enable/disable
 graphics reporting, re #4837

---
 source/NVDAObjects/window/winword.py | 13 +++++++------
 source/appModules/powerpnt.py        |  2 ++
 source/config/__init__.py            |  1 +
 source/globalCommands.py             |  2 +-
 source/gui/settingsDialogs.py        |  6 ++++++
 source/speech.py                     |  6 ++++++
 source/textInfos/__init__.py         |  1 +
 7 files changed, 24 insertions(+), 7 deletions(-)

diff --git a/source/NVDAObjects/window/winword.py b/source/NVDAObjects/window/winword.py
index 2565351..8405fce 100755
--- a/source/NVDAObjects/window/winword.py
+++ b/source/NVDAObjects/window/winword.py
@@ -248,13 +248,14 @@ formatConfigFlagsMap={
 	"reportTables":512,
 	"reportLists":1024,
 	"reportLinks":2048,
-	"reportComments":4096,
-	"reportHeadings":8192,
-	"autoLanguageSwitching":16384,	
-	"reportRevisions":32768,
-	"reportParagraphIndentation":65536,
+	"reportGraphics":4096,
+	"reportComments":8192,
+	"reportHeadings":16384,
+	"autoLanguageSwitching":32768,	
+	"reportRevisions":65536,
+	"reportParagraphIndentation":131072,
 }
-formatConfigFlag_includeLayoutTables=131072
+formatConfigFlag_includeLayoutTables=262144
 
 class WordDocumentHeadingQuickNavItem(browseMode.TextInfoQuickNavItem):
 
diff --git a/source/appModules/powerpnt.py b/source/appModules/powerpnt.py
index 89d9993..46b404e 100644
--- a/source/appModules/powerpnt.py
+++ b/source/appModules/powerpnt.py
@@ -852,6 +852,8 @@ class TextFrameTextInfo(textInfos.offsets.OffsetsTextInfo):
 			formatField['color']=colors.RGB.fromCOLORREF(font.color.rgb)
 		if formatConfig["reportLinks"] and curRun.actionSettings(ppMouseClick).action==ppActionHyperlink:
 			formatField["link"]=True
+			if formatConfig["reportGraphics"]:
+			formatField["graphic"]=True
 		return formatField,(startOffset,endOffset)
 
 class Table(Shape):
diff --git a/source/config/__init__.py b/source/config/__init__.py
index 1ae0c5f..bb0b938 100644
--- a/source/config/__init__.py
+++ b/source/config/__init__.py
@@ -175,6 +175,7 @@ confspec = ConfigObj(StringIO(
 	reportTableHeaders = boolean(default=True)
 	reportTableCellCoords = boolean(default=True)
 	reportLinks = boolean(default=true)
+	reportGraphics = boolean(default=true)
 	reportComments = boolean(default=true)
 	reportLists = boolean(default=true)
 	reportHeadings = boolean(default=true)
diff --git a/source/globalCommands.py b/source/globalCommands.py
index 5c376dd..5429792 100755
--- a/source/globalCommands.py
+++ b/source/globalCommands.py
@@ -861,7 +861,7 @@ class GlobalCommands(ScriptableObject):
 			"reportFontName":True,"reportFontSize":True,"reportFontAttributes":True,"reportColor":True,"reportRevisions":False,
 			"reportStyle":True,"reportAlignment":True,"reportSpellingErrors":True,
 			"reportPage":False,"reportLineNumber":False,"reportParagraphIndentation":True,"reportTables":False,
-			"reportLinks":False,"reportHeadings":False,"reportLists":False,
+			"reportLinks":False,"reportGraphics":False,"reportHeadings":False,"reportLists":False,
 			"reportBlockQuotes":False,"reportComments":False,
 		}
 		textList=[]
diff --git a/source/gui/settingsDialogs.py b/source/gui/settingsDialogs.py
index 0666e99..ac70278 100644
--- a/source/gui/settingsDialogs.py
+++ b/source/gui/settingsDialogs.py
@@ -1109,6 +1109,11 @@ class DocumentFormattingDialog(SettingsDialog):
 		settingsSizer.Add(self.linksCheckBox,border=10,flag=wx.BOTTOM)
 		# Translators: This is the label for a checkbox in the
 		# document formatting settings dialog.
+		self.graphicsCheckBox=wx.CheckBox(self,wx.NewId(),label=_("Report &graphics"))
+		self.graphicsCheckBox.SetValue(config.conf["documentFormatting"]["reportGraphics"])
+		settingsSizer.Add(self.graphicsCheckBox,border=10,flag=wx.BOTTOM)
+		# Translators: This is the label for a checkbox in the
+		# document formatting settings dialog.
 		self.headingsCheckBox=wx.CheckBox(self,wx.NewId(),label=_("Report &headings"))
 		self.headingsCheckBox.SetValue(config.conf["documentFormatting"]["reportHeadings"])
 		settingsSizer.Add(self.headingsCheckBox,border=10,flag=wx.BOTTOM)
@@ -1159,6 +1164,7 @@ class DocumentFormattingDialog(SettingsDialog):
 		config.conf["documentFormatting"]["reportTableHeaders"]=self.tableHeadersCheckBox.IsChecked()
 		config.conf["documentFormatting"]["reportTableCellCoords"]=self.tableCellCoordsCheckBox.IsChecked() 
 		config.conf["documentFormatting"]["reportLinks"]=self.linksCheckBox.IsChecked()
+		config.conf["documentFormatting"]["reportGraphics"]=self.graphicsCheckBox.IsChecked()
 		config.conf["documentFormatting"]["reportHeadings"]=self.headingsCheckBox.IsChecked()
 		config.conf["documentFormatting"]["reportLists"]=self.listsCheckBox.IsChecked()
 		config.conf["documentFormatting"]["reportBlockQuotes"]=self.blockQuotesCheckBox.IsChecked()
diff --git a/source/speech.py b/source/speech.py
index f4497dd..6da4de2 100755
--- a/source/speech.py
+++ b/source/speech.py
@@ -1290,6 +1290,12 @@ def getFormatFieldSpeech(attrs,attrsCache=None,formatConfig=None,unit=None,extra
 		if (link or oldLink is not None) and link!=oldLink:
 			text=_("link") if link else _("out of %s")%_("link")
 			textList.append(text)
+	if  formatConfig["reportGraphics"]:
+		graphic=attrs.get("graphic")
+		oldGraphic=attrsCache.get("graphic") if attrsCache is not None else None
+		if (graphic or oldGraphic is not None) and graphic!=oldGraphic:
+			text=_("graphic") if graphic else _("out of %s")%_("graphic")
+			textList.append(text)
 	if  formatConfig["reportComments"]:
 		comment=attrs.get("comment")
 		oldComment=attrsCache.get("comment") if attrsCache is not None else None
diff --git a/source/textInfos/__init__.py b/source/textInfos/__init__.py
index 35f894c..2a5d1be 100755
--- a/source/textInfos/__init__.py
+++ b/source/textInfos/__init__.py
@@ -61,6 +61,7 @@ class ControlField(Field):
 				return self.PRESCAT_LAYOUT
 		if reason in (controlTypes.REASON_CARET, controlTypes.REASON_SAYALL, controlTypes.REASON_FOCUS) and (
 			(role == controlTypes.ROLE_LINK and not formatConfig["reportLinks"])
+			or (role == controlTypes.ROLE_GRAPHIC and not formatConfig["reportGraphics"])
 			or (role == controlTypes.ROLE_HEADING and not formatConfig["reportHeadings"])
 			or (role == controlTypes.ROLE_BLOCKQUOTE and not formatConfig["reportBlockQuotes"])
 			or (role in (controlTypes.ROLE_TABLE, controlTypes.ROLE_TABLECELL, controlTypes.ROLE_TABLEROWHEADER, controlTypes.ROLE_TABLECOLUMNHEADER) and not formatConfig["reportTables"])
-- 
1.9.5.msysgit.0

