ppt 2010 fix (hopefully). pptviewer tidyups

This commit is contained in:
Jonathan Corwin 2011-03-15 00:10:40 +00:00
parent e8de37f7b3
commit 0b827218bc
7 changed files with 431 additions and 385 deletions

View File

@ -80,7 +80,8 @@ class Controller(object):
if self.doc.is_active(): if self.doc.is_active():
return return
if not self.doc.is_loaded(): if not self.doc.is_loaded():
self.doc.load_presentation() if not self.doc.load_presentation():
return
if self.is_live: if self.is_live:
self.doc.start_presentation() self.doc.start_presentation()
if self.doc.slidenumber > 1: if self.doc.slidenumber > 1:

View File

@ -77,8 +77,11 @@ class PowerpointController(PresentationController):
""" """
Loads PowerPoint process Loads PowerPoint process
""" """
self.process = Dispatch(u'PowerPoint.Application') log.debug(u'start_process')
self.process.Visible = True if not self.process:
self.process = Dispatch(u'PowerPoint.Application')
if float(self.process.Version) < 13:
self.process.Visible = True
self.process.WindowState = 2 self.process.WindowState = 2
def kill(self): def kill(self):
@ -120,13 +123,14 @@ class PowerpointDocument(PresentationDocument):
``presentation`` ``presentation``
The file name of the presentations to run. The file name of the presentations to run.
""" """
log.debug(u'LoadPresentation') log.debug(u'load_presentation')
if not self.controller.process or not self.controller.process.Visible: if not self.controller.process or not self.controller.process.Visible:
self.controller.start_process() self.controller.start_process()
try: try:
self.controller.process.Presentations.Open(self.filepath, False, self.controller.process.Presentations.Open(self.filepath, False,
False, True) False, True)
except pywintypes.com_error: except pywintypes.com_error:
log.debug(u'PPT open failed')
return False return False
self.presentation = self.controller.process.Presentations( self.presentation = self.controller.process.Presentations(
self.controller.process.Presentations.Count) self.controller.process.Presentations.Count)
@ -145,6 +149,7 @@ class PowerpointDocument(PresentationDocument):
However, for the moment, we want a physical file since it makes life However, for the moment, we want a physical file since it makes life
easier elsewhere. easier elsewhere.
""" """
log.debug(u'create_thumbnails')
if self.check_thumbnails(): if self.check_thumbnails():
return return
for num in range(0, self.presentation.Slides.Count): for num in range(0, self.presentation.Slides.Count):
@ -170,6 +175,7 @@ class PowerpointDocument(PresentationDocument):
""" """
Returns ``True`` if a presentation is loaded. Returns ``True`` if a presentation is loaded.
""" """
log.debug(u'is_loaded')
try: try:
if not self.controller.process.Visible: if not self.controller.process.Visible:
return False return False
@ -186,6 +192,7 @@ class PowerpointDocument(PresentationDocument):
""" """
Returns ``True`` if a presentation is currently active. Returns ``True`` if a presentation is currently active.
""" """
log.debug(u'is_active')
if not self.is_loaded(): if not self.is_loaded():
return False return False
try: try:
@ -201,6 +208,7 @@ class PowerpointDocument(PresentationDocument):
""" """
Unblanks (restores) the presentation. Unblanks (restores) the presentation.
""" """
log.debug(u'unblank_screen')
self.presentation.SlideShowSettings.Run() self.presentation.SlideShowSettings.Run()
self.presentation.SlideShowWindow.View.State = 1 self.presentation.SlideShowWindow.View.State = 1
self.presentation.SlideShowWindow.Activate() self.presentation.SlideShowWindow.Activate()
@ -209,12 +217,14 @@ class PowerpointDocument(PresentationDocument):
""" """
Blanks the screen. Blanks the screen.
""" """
log.debug(u'blank_screen')
self.presentation.SlideShowWindow.View.State = 3 self.presentation.SlideShowWindow.View.State = 3
def is_blank(self): def is_blank(self):
""" """
Returns ``True`` if screen is blank. Returns ``True`` if screen is blank.
""" """
log.debug(u'is_blank')
if self.is_active(): if self.is_active():
return self.presentation.SlideShowWindow.View.State == 3 return self.presentation.SlideShowWindow.View.State == 3
else: else:
@ -224,6 +234,7 @@ class PowerpointDocument(PresentationDocument):
""" """
Stops the current presentation and hides the output. Stops the current presentation and hides the output.
""" """
log.debug(u'stop_presentation')
self.presentation.SlideShowWindow.View.Exit() self.presentation.SlideShowWindow.View.Exit()
if os.name == u'nt': if os.name == u'nt':
@ -231,6 +242,7 @@ class PowerpointDocument(PresentationDocument):
""" """
Starts a presentation from the beginning. Starts a presentation from the beginning.
""" """
log.debug(u'start_presentation')
#SlideShowWindow measures its size/position by points, not pixels #SlideShowWindow measures its size/position by points, not pixels
try: try:
dpi = win32ui.GetActiveWindow().GetDC().GetDeviceCaps(88) dpi = win32ui.GetActiveWindow().GetDC().GetDeviceCaps(88)
@ -253,30 +265,35 @@ class PowerpointDocument(PresentationDocument):
""" """
Returns the current slide number. Returns the current slide number.
""" """
log.debug(u'get_slide_number')
return self.presentation.SlideShowWindow.View.CurrentShowPosition return self.presentation.SlideShowWindow.View.CurrentShowPosition
def get_slide_count(self): def get_slide_count(self):
""" """
Returns total number of slides. Returns total number of slides.
""" """
log.debug(u'get_slide_count')
return self.presentation.Slides.Count return self.presentation.Slides.Count
def goto_slide(self, slideno): def goto_slide(self, slideno):
""" """
Moves to a specific slide in the presentation. Moves to a specific slide in the presentation.
""" """
log.debug(u'goto_slide')
self.presentation.SlideShowWindow.View.GotoSlide(slideno) self.presentation.SlideShowWindow.View.GotoSlide(slideno)
def next_step(self): def next_step(self):
""" """
Triggers the next effect of slide on the running presentation. Triggers the next effect of slide on the running presentation.
""" """
log.debug(u'next_step')
self.presentation.SlideShowWindow.View.Next() self.presentation.SlideShowWindow.View.Next()
def previous_step(self): def previous_step(self):
""" """
Triggers the previous slide on the running presentation. Triggers the previous slide on the running presentation.
""" """
log.debug(u'previous_step')
self.presentation.SlideShowWindow.View.Previous() self.presentation.SlideShowWindow.View.Previous()
def get_slide_text(self, slide_no): def get_slide_text(self, slide_no):

View File

@ -84,7 +84,8 @@ class PptviewController(PresentationController):
dllpath = os.path.join(self.plugin.pluginManager.basepath, dllpath = os.path.join(self.plugin.pluginManager.basepath,
u'presentations', u'lib', u'pptviewlib', u'pptviewlib.dll') u'presentations', u'lib', u'pptviewlib', u'pptviewlib.dll')
self.process = cdll.LoadLibrary(dllpath) self.process = cdll.LoadLibrary(dllpath)
self.process.SetDebug(1) if log.isEnabledFor(log.DEBUG):
self.process.SetDebug(1)
def kill(self): def kill(self):
""" """

View File

@ -133,7 +133,7 @@ class PPTViewer(QtGui.QWidget):
def OpenClick(self): def OpenClick(self):
oldid = self.pptid; oldid = self.pptid;
rect = RECT(100,100,900,700) rect = RECT(100,100,900,700)
filename = unicode(self.PPTEdit.text()) filename = str(self.PPTEdit.text().replace(u'/', u'\\'))
print filename print filename
self.pptid = pptdll.OpenPPT(filename, None, rect, 'c:\\temp\\slide') self.pptid = pptdll.OpenPPT(filename, None, rect, 'c:\\temp\\slide')
print "id: " + unicode(self.pptid) print "id: " + unicode(self.pptid)

File diff suppressed because it is too large Load Diff

View File

@ -1,60 +1,63 @@
#define DllExport extern "C" __declspec( dllexport ) #define DllExport extern "C" __declspec(dllexport)
#define DEBUG(...) if(debug) printf(__VA_ARGS__)
enum PPTVIEWSTATE { PPT_CLOSED, PPT_STARTED, PPT_OPENED, PPT_LOADED, PPT_CLOSING}; enum PPTVIEWSTATE {PPT_CLOSED, PPT_STARTED, PPT_OPENED,
PPT_LOADED, PPT_CLOSING};
DllExport int OpenPPT(char *filename, HWND hParentWnd, RECT rect, char *previewpath); DllExport int OpenPPT(char *filename, HWND h_parent_wnd, RECT rect,
char *preview_path);
DllExport BOOL CheckInstalled(); DllExport BOOL CheckInstalled();
DllExport void ClosePPT(int id); DllExport void ClosePPT(int id);
DllExport int GetCurrentSlide(int id); DllExport int GetCurrentSlide(int id);
DllExport int GetSlideCount(int id); DllExport int GetSlideCount(int id);
DllExport void NextStep(int id); DllExport void NextStep(int id);
DllExport void PrevStep(int id); DllExport void PrevStep(int id);
DllExport void GotoSlide(int id, int slideno); DllExport void GotoSlide(int id, int slide_no);
DllExport void RestartShow(int id); DllExport void RestartShow(int id);
DllExport void Blank(int id); DllExport void Blank(int id);
DllExport void Unblank(int id); DllExport void Unblank(int id);
DllExport void Stop(int id); DllExport void Stop(int id);
DllExport void Resume(int id); DllExport void Resume(int id);
DllExport void SetDebug(BOOL onoff); DllExport void SetDebug(BOOL on_off);
LRESULT CALLBACK CbtProc(int nCode, WPARAM wParam, LPARAM lParam); LRESULT CALLBACK CbtProc(int n_code, WPARAM w_param, LPARAM l_param);
LRESULT CALLBACK CwpProc(int nCode, WPARAM wParam, LPARAM lParam); LRESULT CALLBACK CwpProc(int n_code, WPARAM w_param, LPARAM l_param);
LRESULT CALLBACK GetMsgProc(int nCode, WPARAM wParam, LPARAM lParam); LRESULT CALLBACK GetMsgProc(int n_code, WPARAM w_param, LPARAM l_param);
BOOL GetPPTViewerPath(char *pptviewerpath, int strsize); BOOL GetPPTViewerPath(char *pptviewer_path, int str_size);
HBITMAP CaptureWindow (HWND hWnd); HBITMAP CaptureWindow (HWND h_wnd);
VOID SaveBitmap (CHAR* filename, HBITMAP hBmp) ; VOID SaveBitmap (CHAR* filename, HBITMAP h_bmp);
VOID CaptureAndSaveWindow(HWND hWnd, CHAR* filename); VOID CaptureAndSaveWindow(HWND h_wnd, CHAR* filename);
BOOL GetPPTInfo(int id); BOOL GetPPTInfo(int id);
BOOL SavePPTInfo(int id); BOOL SavePPTInfo(int id);
BOOL InitPPTObject(int id, char *filename, HWND hParentWnd, BOOL InitPPTObject(int id, char *filename, HWND h_parent_wnd,
RECT rect, char *previewpath); RECT rect, char *preview_path);
BOOL StartPPTView(int id); BOOL StartPPTView(int id);
void Unhook(int id); void Unhook(int id);
#define MAX_PPTOBJS 16 #define MAX_PPTS 16
#define MAX_SLIDES 256 #define MAX_SLIDES 256
struct PPTVIEWOBJ struct PPTVIEW
{ {
HHOOK hook; HHOOK hook;
HHOOK mhook; HHOOK mhook;
HWND hWnd; HWND h_wnd; // The main pptview window
HWND hWnd2; HWND h_wnd_input; // A child pptview window which takes windows messages
HWND hParentWnd; HWND h_parent_wnd;
HANDLE hProcess; HANDLE h_process;
HANDLE hThread; HANDLE h_thread;
DWORD dwProcessId; DWORD dw_process_id;
DWORD dwThreadId; DWORD dw_thread_id;
RECT rect; RECT rect;
int slideCount; int slide_count;
int currentSlide; int current_slide;
int firstSlideSteps; int first_slide_steps;
int steps; int steps;
int guess; int guess; // What the current slide might be, based on the last action
char filename[MAX_PATH]; char filename[MAX_PATH];
char previewpath[MAX_PATH]; char preview_path[MAX_PATH];
int slideNo[MAX_SLIDES]; int slide_no[MAX_SLIDES];
PPTVIEWSTATE state; PPTVIEWSTATE state;
}; };