forked from openlp/openlp
ppt2010 fix (part 2). pptviewer fixes and tidies
bzr-revno: 1397
This commit is contained in:
commit
ce9e2ad20f
@ -80,8 +80,7 @@ class PowerpointController(PresentationController):
|
|||||||
log.debug(u'start_process')
|
log.debug(u'start_process')
|
||||||
if not self.process:
|
if not self.process:
|
||||||
self.process = Dispatch(u'PowerPoint.Application')
|
self.process = Dispatch(u'PowerPoint.Application')
|
||||||
if float(self.process.Version) < 13:
|
self.process.Visible = True
|
||||||
self.process.Visible = True
|
|
||||||
self.process.WindowState = 2
|
self.process.WindowState = 2
|
||||||
|
|
||||||
def kill(self):
|
def kill(self):
|
||||||
|
@ -30,19 +30,32 @@ from ctypes import *
|
|||||||
from ctypes.wintypes import RECT
|
from ctypes.wintypes import RECT
|
||||||
|
|
||||||
class PPTViewer(QtGui.QWidget):
|
class PPTViewer(QtGui.QWidget):
|
||||||
|
"""
|
||||||
|
Standalone Test Harness for the pptviewlib library
|
||||||
|
"""
|
||||||
def __init__(self, parent=None):
|
def __init__(self, parent=None):
|
||||||
QtGui.QWidget.__init__(self, parent)
|
QtGui.QWidget.__init__(self, parent)
|
||||||
self.pptid = -1
|
self.pptid = -1
|
||||||
self.setWindowTitle(u'PowerPoint Viewer Test')
|
self.setWindowTitle(u'PowerPoint Viewer Test')
|
||||||
|
|
||||||
PPTLabel = QtGui.QLabel(u'Open PowerPoint file')
|
ppt_label = QtGui.QLabel(u'Open PowerPoint file')
|
||||||
slideLabel = QtGui.QLabel(u'Go to slide #')
|
slide_label = QtGui.QLabel(u'Go to slide #')
|
||||||
self.PPTEdit = QtGui.QLineEdit()
|
self.pptEdit = QtGui.QLineEdit()
|
||||||
self.slideEdit = QtGui.QLineEdit()
|
self.slideEdit = QtGui.QLineEdit()
|
||||||
|
x_label = QtGui.QLabel(u'X pos')
|
||||||
|
y_label = QtGui.QLabel(u'Y pos')
|
||||||
|
width_label = QtGui.QLabel(u'Width')
|
||||||
|
height_label = QtGui.QLabel(u'Height')
|
||||||
|
self.xEdit = QtGui.QLineEdit(u'100')
|
||||||
|
self.yEdit = QtGui.QLineEdit(u'100')
|
||||||
|
self.widthEdit = QtGui.QLineEdit(u'900')
|
||||||
|
self.heightEdit = QtGui.QLineEdit(u'700')
|
||||||
self.total = QtGui.QLabel()
|
self.total = QtGui.QLabel()
|
||||||
PPTBtn = QtGui.QPushButton(u'Open')
|
ppt_btn = QtGui.QPushButton(u'Open')
|
||||||
PPTDlgBtn = QtGui.QPushButton(u'...')
|
ppt_dlg_btn = QtGui.QPushButton(u'...')
|
||||||
slideBtn = QtGui.QPushButton(u'Go')
|
folder_label = QtGui.QLabel(u'Slide .bmp path')
|
||||||
|
self.folderEdit = QtGui.QLineEdit(u'slide')
|
||||||
|
slide_btn = QtGui.QPushButton(u'Go')
|
||||||
prev = QtGui.QPushButton(u'Prev')
|
prev = QtGui.QPushButton(u'Prev')
|
||||||
next = QtGui.QPushButton(u'Next')
|
next = QtGui.QPushButton(u'Next')
|
||||||
blank = QtGui.QPushButton(u'Blank')
|
blank = QtGui.QPushButton(u'Blank')
|
||||||
@ -51,122 +64,149 @@ class PPTViewer(QtGui.QWidget):
|
|||||||
close = QtGui.QPushButton(u'Close')
|
close = QtGui.QPushButton(u'Close')
|
||||||
resume = QtGui.QPushButton(u'Resume')
|
resume = QtGui.QPushButton(u'Resume')
|
||||||
stop = QtGui.QPushButton(u'Stop')
|
stop = QtGui.QPushButton(u'Stop')
|
||||||
pptwindow = QtGui.QWidget()
|
|
||||||
|
|
||||||
grid = QtGui.QGridLayout()
|
grid = QtGui.QGridLayout()
|
||||||
grid.addWidget(PPTLabel, 0, 0)
|
row = 0
|
||||||
grid.addWidget(self.PPTEdit, 0, 1)
|
grid.addWidget(folder_label, 0, 0)
|
||||||
grid.addWidget(PPTDlgBtn, 0, 2)
|
grid.addWidget(self.folderEdit, 0, 1)
|
||||||
grid.addWidget(PPTBtn, 0, 3)
|
row = row + 1
|
||||||
grid.addWidget(slideLabel, 1, 0)
|
grid.addWidget(x_label, row, 0)
|
||||||
grid.addWidget(self.slideEdit, 1, 1)
|
grid.addWidget(self.xEdit, row, 1)
|
||||||
grid.addWidget(slideBtn, 1, 3)
|
grid.addWidget(y_label, row, 2)
|
||||||
grid.addWidget(prev, 2, 0)
|
grid.addWidget(self.yEdit, row, 3)
|
||||||
grid.addWidget(next, 2, 1)
|
row = row + 1
|
||||||
grid.addWidget(blank, 3, 0)
|
grid.addWidget(width_label, row, 0)
|
||||||
grid.addWidget(unblank, 3, 1)
|
grid.addWidget(self.widthEdit, row, 1)
|
||||||
grid.addWidget(restart, 4, 0)
|
grid.addWidget(height_label, row, 2)
|
||||||
grid.addWidget(close, 4, 1)
|
grid.addWidget(self.heightEdit, row, 3)
|
||||||
grid.addWidget(stop, 5, 0)
|
row = row + 1
|
||||||
grid.addWidget(resume, 5, 1)
|
grid.addWidget(ppt_label, row, 0)
|
||||||
grid.addWidget(pptwindow, 6, 0, 10, 3)
|
grid.addWidget(self.pptEdit, row, 1)
|
||||||
self.connect(PPTBtn, QtCore.SIGNAL(u'clicked()'), self.OpenClick)
|
grid.addWidget(ppt_dlg_btn, row, 2)
|
||||||
self.connect(PPTDlgBtn, QtCore.SIGNAL(u'clicked()'), self.OpenDialog)
|
grid.addWidget(ppt_btn, row, 3)
|
||||||
self.connect(slideBtn, QtCore.SIGNAL(u'clicked()'), self.GotoClick)
|
row = row + 1
|
||||||
self.connect(prev, QtCore.SIGNAL(u'clicked()'), self.PrevClick)
|
grid.addWidget(slide_label, row, 0)
|
||||||
self.connect(next, QtCore.SIGNAL(u'clicked()'), self.NextClick)
|
grid.addWidget(self.slideEdit, row, 1)
|
||||||
self.connect(blank, QtCore.SIGNAL(u'clicked()'), self.BlankClick)
|
grid.addWidget(slide_btn, row, 2)
|
||||||
self.connect(unblank, QtCore.SIGNAL(u'clicked()'), self.UnblankClick)
|
row = row + 1
|
||||||
self.connect(restart, QtCore.SIGNAL(u'clicked()'), self.RestartClick)
|
grid.addWidget(prev, row, 0)
|
||||||
self.connect(close, QtCore.SIGNAL(u'clicked()'), self.CloseClick)
|
grid.addWidget(next, row, 1)
|
||||||
self.connect(stop, QtCore.SIGNAL(u'clicked()'), self.StopClick)
|
row = row + 1
|
||||||
self.connect(resume, QtCore.SIGNAL(u'clicked()'), self.ResumeClick)
|
grid.addWidget(blank, row, 0)
|
||||||
|
grid.addWidget(unblank, row, 1)
|
||||||
|
row = row + 1
|
||||||
|
grid.addWidget(restart, row, 0)
|
||||||
|
grid.addWidget(close, row, 1)
|
||||||
|
row = row + 1
|
||||||
|
grid.addWidget(stop, row, 0)
|
||||||
|
grid.addWidget(resume, row, 1)
|
||||||
|
self.connect(ppt_btn, QtCore.SIGNAL(u'clicked()'), self.openClick)
|
||||||
|
self.connect(ppt_dlg_btn, QtCore.SIGNAL(u'clicked()'), self.openDialog)
|
||||||
|
self.connect(slide_btn, QtCore.SIGNAL(u'clicked()'), self.gotoClick)
|
||||||
|
self.connect(prev, QtCore.SIGNAL(u'clicked()'), self.prevClick)
|
||||||
|
self.connect(next, QtCore.SIGNAL(u'clicked()'), self.nextClick)
|
||||||
|
self.connect(blank, QtCore.SIGNAL(u'clicked()'), self.blankClick)
|
||||||
|
self.connect(unblank, QtCore.SIGNAL(u'clicked()'), self.unblankClick)
|
||||||
|
self.connect(restart, QtCore.SIGNAL(u'clicked()'), self.restartClick)
|
||||||
|
self.connect(close, QtCore.SIGNAL(u'clicked()'), self.closeClick)
|
||||||
|
self.connect(stop, QtCore.SIGNAL(u'clicked()'), self.stopClick)
|
||||||
|
self.connect(resume, QtCore.SIGNAL(u'clicked()'), self.resumeClick)
|
||||||
self.setLayout(grid)
|
self.setLayout(grid)
|
||||||
|
|
||||||
self.resize(300, 150)
|
self.resize(300, 150)
|
||||||
|
|
||||||
def PrevClick(self):
|
def prevClick(self):
|
||||||
if self.pptid<0: return
|
if self.pptid < 0:
|
||||||
pptdll.PrevStep(self.pptid)
|
return
|
||||||
self.UpdateCurrSlide()
|
self.pptdll.PrevStep(self.pptid)
|
||||||
|
self.updateCurrSlide()
|
||||||
app.processEvents()
|
app.processEvents()
|
||||||
|
|
||||||
def NextClick(self):
|
def nextClick(self):
|
||||||
if(self.pptid<0): return
|
if self.pptid < 0:
|
||||||
pptdll.NextStep(self.pptid)
|
return
|
||||||
self.UpdateCurrSlide()
|
self.pptdll.NextStep(self.pptid)
|
||||||
|
self.updateCurrSlide()
|
||||||
app.processEvents()
|
app.processEvents()
|
||||||
|
|
||||||
def BlankClick(self):
|
def blankClick(self):
|
||||||
if(self.pptid<0): return
|
if self.pptid < 0:
|
||||||
pptdll.Blank(self.pptid)
|
return
|
||||||
|
self.pptdll.Blank(self.pptid)
|
||||||
app.processEvents()
|
app.processEvents()
|
||||||
|
|
||||||
def UnblankClick(self):
|
def unblankClick(self):
|
||||||
if(self.pptid<0): return
|
if self.pptid < 0:
|
||||||
pptdll.Unblank(self.pptid)
|
return
|
||||||
|
self.pptdll.Unblank(self.pptid)
|
||||||
app.processEvents()
|
app.processEvents()
|
||||||
|
|
||||||
def RestartClick(self):
|
def restartClick(self):
|
||||||
if(self.pptid<0): return
|
if self.pptid < 0:
|
||||||
pptdll.RestartShow(self.pptid)
|
return
|
||||||
self.UpdateCurrSlide()
|
self.pptdll.RestartShow(self.pptid)
|
||||||
|
self.updateCurrSlide()
|
||||||
app.processEvents()
|
app.processEvents()
|
||||||
|
|
||||||
def StopClick(self):
|
def stopClick(self):
|
||||||
if(self.pptid<0): return
|
if self.pptid < 0:
|
||||||
pptdll.Stop(self.pptid)
|
return
|
||||||
|
self.pptdll.Stop(self.pptid)
|
||||||
app.processEvents()
|
app.processEvents()
|
||||||
|
|
||||||
def ResumeClick(self):
|
def resumeClick(self):
|
||||||
if(self.pptid<0): return
|
if self.pptid < 0:
|
||||||
pptdll.Resume(self.pptid)
|
return
|
||||||
|
self.pptdll.Resume(self.pptid)
|
||||||
app.processEvents()
|
app.processEvents()
|
||||||
|
|
||||||
def CloseClick(self):
|
def closeClick(self):
|
||||||
if(self.pptid<0): return
|
if self.pptid < 0:
|
||||||
pptdll.ClosePPT(self.pptid)
|
return
|
||||||
|
self.pptdll.ClosePPT(self.pptid)
|
||||||
self.pptid = -1
|
self.pptid = -1
|
||||||
app.processEvents()
|
app.processEvents()
|
||||||
|
|
||||||
def OpenClick(self):
|
def openClick(self):
|
||||||
oldid = self.pptid;
|
oldid = self.pptid;
|
||||||
rect = RECT(100,100,900,700)
|
rect = RECT(int(self.xEdit.text()), int(self.yEdit.text()),
|
||||||
filename = str(self.PPTEdit.text().replace(u'/', u'\\'))
|
int(self.widthEdit.text()), int(self.heightEdit.text()))
|
||||||
print filename
|
filename = str(self.pptEdit.text().replace(u'/', u'\\'))
|
||||||
self.pptid = pptdll.OpenPPT(filename, None, rect, 'c:\\temp\\slide')
|
folder = str(self.folderEdit.text().replace(u'/', u'\\'))
|
||||||
print "id: " + unicode(self.pptid)
|
print filename, folder
|
||||||
if oldid>=0:
|
self.pptid = self.pptdll.OpenPPT(filename, None, rect, folder)
|
||||||
pptdll.ClosePPT(oldid);
|
print u'id: ' + unicode(self.pptid)
|
||||||
slides = pptdll.GetSlideCount(self.pptid)
|
if oldid >= 0:
|
||||||
print "slidecount: " + unicode(slides)
|
self.pptdll.ClosePPT(oldid);
|
||||||
self.total.setNum(pptdll.GetSlideCount(self.pptid))
|
slides = self.pptdll.GetSlideCount(self.pptid)
|
||||||
self.UpdateCurrSlide()
|
print u'slidecount: ' + unicode(slides)
|
||||||
|
self.total.setNum(self.pptdll.GetSlideCount(self.pptid))
|
||||||
|
self.updateCurrSlide()
|
||||||
|
|
||||||
def UpdateCurrSlide(self):
|
def updateCurrSlide(self):
|
||||||
if(self.pptid<0): return
|
if self.pptid < 0:
|
||||||
slide = unicode(pptdll.GetCurrentSlide(self.pptid))
|
return
|
||||||
print "currslide: " + slide
|
slide = unicode(self.pptdll.GetCurrentSlide(self.pptid))
|
||||||
|
print u'currslide: ' + slide
|
||||||
self.slideEdit.setText(slide)
|
self.slideEdit.setText(slide)
|
||||||
app.processEvents()
|
app.processEvents()
|
||||||
|
|
||||||
def GotoClick(self):
|
def gotoClick(self):
|
||||||
if(self.pptid<0): return
|
if self.pptid < 0:
|
||||||
|
return
|
||||||
print self.slideEdit.text()
|
print self.slideEdit.text()
|
||||||
pptdll.GotoSlide(self.pptid, int(self.slideEdit.text()))
|
self.pptdll.GotoSlide(self.pptid, int(self.slideEdit.text()))
|
||||||
self.UpdateCurrSlide()
|
self.updateCurrSlide()
|
||||||
app.processEvents()
|
app.processEvents()
|
||||||
|
|
||||||
def OpenDialog(self):
|
def openDialog(self):
|
||||||
self.PPTEdit.setText(QtGui.QFileDialog.getOpenFileName(self, 'Open file'))
|
self.pptEdit.setText(QtGui.QFileDialog.getOpenFileName(self,
|
||||||
|
u'Open file'))
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
#pptdll = cdll.LoadLibrary(r'C:\Documents and Settings\jonathan\Desktop\pptviewlib.dll')
|
|
||||||
pptdll = cdll.LoadLibrary(r'pptviewlib.dll')
|
pptdll = cdll.LoadLibrary(r'pptviewlib.dll')
|
||||||
pptdll.SetDebug(1)
|
pptdll.SetDebug(1)
|
||||||
print "Begin..."
|
print u'Begin...'
|
||||||
app = QtGui.QApplication(sys.argv)
|
app = QtGui.QApplication(sys.argv)
|
||||||
qb = PPTViewer()
|
window = PPTViewer()
|
||||||
qb.show()
|
window.pptdll = pptdll
|
||||||
|
window.show()
|
||||||
sys.exit(app.exec_())
|
sys.exit(app.exec_())
|
||||||
|
File diff suppressed because it is too large
Load Diff
Binary file not shown.
@ -1,55 +1,84 @@
|
|||||||
|
/******************************************************************************
|
||||||
|
* PptViewLib - PowerPoint Viewer 2003/2007 Controller *
|
||||||
|
* OpenLP - Open Source Lyrics Projection *
|
||||||
|
* --------------------------------------------------------------------------- *
|
||||||
|
* Copyright (c) 2008-2011 Raoul Snyman *
|
||||||
|
* Portions copyright (c) 2008-2011 Tim Bentley, Jonathan Corwin, Michael *
|
||||||
|
* Gorven, Scott Guerrieri, Meinert Jordan, Armin Köhler, Andreas Preikschat, *
|
||||||
|
* Christian Richter, Philip Ridout, Maikel Stuivenberg, Martin Thompson, Jon *
|
||||||
|
* Tibble, Carsten Tinggaard, Frode Woldsund *
|
||||||
|
* --------------------------------------------------------------------------- *
|
||||||
|
* This program is free software; you can redistribute it and/or modify it *
|
||||||
|
* under the terms of the GNU General Public License as published by the Free *
|
||||||
|
* Software Foundation; version 2 of the License. *
|
||||||
|
* *
|
||||||
|
* This program is distributed in the hope that it will be useful, but WITHOUT *
|
||||||
|
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or *
|
||||||
|
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for *
|
||||||
|
* more details. *
|
||||||
|
* *
|
||||||
|
* You should have received a copy of the GNU General Public License along *
|
||||||
|
* with this program; if not, write to the Free Software Foundation, Inc., 59 *
|
||||||
|
* Temple Place, Suite 330, Boston, MA 02111-1307 USA *
|
||||||
|
******************************************************************************/
|
||||||
|
|
||||||
#define DllExport extern "C" __declspec( dllexport )
|
#define DllExport extern "C" __declspec( dllexport )
|
||||||
|
|
||||||
enum PPTVIEWSTATE { PPT_CLOSED, PPT_STARTED, PPT_OPENED, PPT_LOADED, PPT_CLOSING};
|
#define DEBUG(...) if (debug) printf(__VA_ARGS__)
|
||||||
|
|
||||||
DllExport int OpenPPT(char *filename, HWND hParentWnd, RECT rect, char *previewpath);
|
enum PPTVIEWSTATE {PPT_CLOSED, PPT_STARTED, PPT_OPENED, PPT_LOADED,
|
||||||
|
PPT_CLOSING};
|
||||||
|
|
||||||
|
DllExport int OpenPPT(char *filename, HWND hParentWnd, RECT rect,
|
||||||
|
char *previewPath);
|
||||||
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 onOff);
|
||||||
|
|
||||||
LRESULT CALLBACK CbtProc(int nCode, WPARAM wParam, LPARAM lParam);
|
LRESULT CALLBACK CbtProc(int nCode, WPARAM wParam, LPARAM lParam);
|
||||||
LRESULT CALLBACK CwpProc(int nCode, WPARAM wParam, LPARAM lParam);
|
LRESULT CALLBACK CwpProc(int nCode, WPARAM wParam, LPARAM lParam);
|
||||||
LRESULT CALLBACK GetMsgProc(int nCode, WPARAM wParam, LPARAM lParam);
|
LRESULT CALLBACK GetMsgProc(int nCode, WPARAM wParam, LPARAM lParam);
|
||||||
BOOL GetPPTViewerPath(char *pptviewerpath, int strsize);
|
BOOL GetPPTViewerPath(char *pptViewerPath, int stringSize);
|
||||||
HBITMAP CaptureWindow (HWND hWnd);
|
HBITMAP CaptureWindow(HWND hWnd);
|
||||||
VOID SaveBitmap (CHAR* filename, HBITMAP hBmp) ;
|
VOID SaveBitmap(CHAR* filename, HBITMAP hBmp) ;
|
||||||
VOID CaptureAndSaveWindow(HWND hWnd, CHAR* filename);
|
VOID CaptureAndSaveWindow(HWND hWnd, CHAR* filename);
|
||||||
BOOL GetPPTInfo(int id);
|
BOOL GetPPTInfo(int id);
|
||||||
BOOL SavePPTInfo(int id);
|
BOOL SavePPTInfo(int id);
|
||||||
|
|
||||||
|
|
||||||
void Unhook(int id);
|
void Unhook(int id);
|
||||||
|
|
||||||
#define MAX_PPTOBJS 50
|
#define MAX_PPTS 16
|
||||||
|
#define MAX_SLIDES 256
|
||||||
|
|
||||||
struct PPTVIEWOBJ
|
struct PPTVIEW
|
||||||
{
|
{
|
||||||
HHOOK hook;
|
HHOOK hook;
|
||||||
HHOOK mhook;
|
HHOOK msgHook;
|
||||||
HWND hWnd;
|
HWND hWnd;
|
||||||
HWND hWnd2;
|
HWND hWnd2;
|
||||||
HWND hParentWnd;
|
HWND hParentWnd;
|
||||||
HANDLE hProcess;
|
HANDLE hProcess;
|
||||||
HANDLE hThread;
|
HANDLE hThread;
|
||||||
DWORD dwProcessId;
|
DWORD dwProcessId;
|
||||||
DWORD dwThreadId;
|
DWORD dwThreadId;
|
||||||
RECT rect;
|
RECT rect;
|
||||||
int slideCount;
|
int slideCount;
|
||||||
int currentSlide;
|
int currentSlide;
|
||||||
int firstSlideSteps;
|
int firstSlideSteps;
|
||||||
int steps;
|
int lastSlideSteps;
|
||||||
char filename[MAX_PATH];
|
int steps;
|
||||||
char previewpath[MAX_PATH];
|
int guess;
|
||||||
PPTVIEWSTATE state;
|
char filename[MAX_PATH];
|
||||||
|
char previewPath[MAX_PATH];
|
||||||
|
int slideNos[MAX_SLIDES];
|
||||||
|
PPTVIEWSTATE state;
|
||||||
};
|
};
|
||||||
|
Loading…
Reference in New Issue
Block a user