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():
return
if not self.doc.is_loaded():
self.doc.load_presentation()
if not self.doc.load_presentation():
return
if self.is_live:
self.doc.start_presentation()
if self.doc.slidenumber > 1:

View File

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

View File

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

View File

@ -133,7 +133,7 @@ class PPTViewer(QtGui.QWidget):
def OpenClick(self):
oldid = self.pptid;
rect = RECT(100,100,900,700)
filename = unicode(self.PPTEdit.text())
filename = str(self.PPTEdit.text().replace(u'/', u'\\'))
print filename
self.pptid = pptdll.OpenPPT(filename, None, rect, 'c:\\temp\\slide')
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 void ClosePPT(int id);
DllExport int GetCurrentSlide(int id);
DllExport int GetSlideCount(int id);
DllExport void NextStep(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 Blank(int id);
DllExport void Unblank(int id);
DllExport void Stop(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 CwpProc(int nCode, WPARAM wParam, LPARAM lParam);
LRESULT CALLBACK GetMsgProc(int nCode, WPARAM wParam, LPARAM lParam);
BOOL GetPPTViewerPath(char *pptviewerpath, int strsize);
HBITMAP CaptureWindow (HWND hWnd);
VOID SaveBitmap (CHAR* filename, HBITMAP hBmp) ;
VOID CaptureAndSaveWindow(HWND hWnd, CHAR* filename);
LRESULT CALLBACK CbtProc(int n_code, WPARAM w_param, LPARAM l_param);
LRESULT CALLBACK CwpProc(int n_code, WPARAM w_param, LPARAM l_param);
LRESULT CALLBACK GetMsgProc(int n_code, WPARAM w_param, LPARAM l_param);
BOOL GetPPTViewerPath(char *pptviewer_path, int str_size);
HBITMAP CaptureWindow (HWND h_wnd);
VOID SaveBitmap (CHAR* filename, HBITMAP h_bmp);
VOID CaptureAndSaveWindow(HWND h_wnd, CHAR* filename);
BOOL GetPPTInfo(int id);
BOOL SavePPTInfo(int id);
BOOL InitPPTObject(int id, char *filename, HWND hParentWnd,
RECT rect, char *previewpath);
BOOL InitPPTObject(int id, char *filename, HWND h_parent_wnd,
RECT rect, char *preview_path);
BOOL StartPPTView(int id);
void Unhook(int id);
#define MAX_PPTOBJS 16
#define MAX_PPTS 16
#define MAX_SLIDES 256
struct PPTVIEWOBJ
struct PPTVIEW
{
HHOOK hook;
HHOOK mhook;
HWND hWnd;
HWND hWnd2;
HWND hParentWnd;
HANDLE hProcess;
HANDLE hThread;
DWORD dwProcessId;
DWORD dwThreadId;
HWND h_wnd; // The main pptview window
HWND h_wnd_input; // A child pptview window which takes windows messages
HWND h_parent_wnd;
HANDLE h_process;
HANDLE h_thread;
DWORD dw_process_id;
DWORD dw_thread_id;
RECT rect;
int slideCount;
int currentSlide;
int firstSlideSteps;
int slide_count;
int current_slide;
int first_slide_steps;
int steps;
int guess;
int guess; // What the current slide might be, based on the last action
char filename[MAX_PATH];
char previewpath[MAX_PATH];
int slideNo[MAX_SLIDES];
char preview_path[MAX_PATH];
int slide_no[MAX_SLIDES];
PPTVIEWSTATE state;
};