OSDN Git Service

Powerpoint appModule: better detection of Slide Show vs Document window:
authorMichael Curran <mick@kulgan.net>
Tue, 25 Dec 2012 01:10:45 +0000 (11:10 +1000)
committerMichael Curran <mick@kulgan.net>
Tue, 25 Dec 2012 01:10:45 +0000 (11:10 +1000)
* PaneClassDC NVDAObject: implement a FindOverlayClasses which chooses DocumentWindow or SlideShowWindow if available, by looking at the object given back by fetching the Powerpoint object model.
* Rather than using the appModule's chooseNVDAObjectOverLayClass, use the appModule's event_gainFocus and instanciate a new PaneClassDC instance and bounce focus there.

source/appModules/powerpnt.py

index 7d15e75..7632d05 100644 (file)
@@ -77,6 +77,18 @@ def getBulletText(ppBulletFormat):
 class PaneClassDC(Window):\r
        """Handles fetching of the Powerpoint object model."""\r
 \r
+       def findOverlayClasses(self,clsList):\r
+               m=self.ppObjectModel\r
+               if m:\r
+                       #If there is a selection then its an editable document (slide).\r
+                       #Otherwize it must be a slide show.\r
+                       try:\r
+                               m.selection\r
+                               clsList.append(DocumentWindow)\r
+                       except comtypes.COMError:\r
+                               clsList.append(SlideShowWindow)\r
+               clsList.append(PaneClassDC)\r
+\r
        def _get_ppObjectModel(self):\r
                """Fetches and caches the Powerpoint DocumentWindow object for the current presentation."""\r
                try:\r
@@ -484,9 +496,9 @@ class SlideShowWindow(ReviewCursorManager,PaneClassDC):
 \r
 class AppModule(appModuleHandler.AppModule):\r
 \r
-       def chooseNVDAObjectOverlayClasses(self, obj, clsList):\r
+       def event_gainFocus(self,obj,nextHandler):\r
                if obj.windowClassName=="paneClassDC" and isinstance(obj,Window) and not isinstance(obj,PpObject) and obj.role==controlTypes.ROLE_PANE:\r
-                       if obj.childCount==0:\r
-                               clsList.insert(0,DocumentWindow)\r
-                       else:\r
-                               clsList.insert(0,SlideShowWindow)\r
+                       newObj=PaneClassDC(windowHandle=obj.windowHandle)\r
+                       eventHandler.queueEvent("gainFocus",newObj)\r
+               else:\r
+                       nextHandler()\r