Merge from lp:~j-corwin/openlp/presentations

bzr-revno: 566
This commit is contained in:
Jonathan Corwin 2009-09-24 10:54:38 +02:00 committed by Raoul Snyman
commit 3a9cd0ff03
7 changed files with 347 additions and 337 deletions

View File

@ -24,6 +24,7 @@
from impresscontroller import ImpressController
#from powerpointcontroller import PowerpointController
from pptviewcontroller import PptviewController
from messagelistener import MessageListener
from mediaitem import PresentationMediaItem
from presentationtab import PresentationTab

View File

@ -22,128 +22,135 @@
# Temple Place, Suite 330, Boston, MA 02111-1307 USA #
###############################################################################
import logging
import os, subprocess
import time
import sys
import win32api
from PyQt4 import QtGui, QtCore
from ctypes import *
from ctypes.wintypes import RECT
pptdll = cdll.LoadLibrary(r'C:\Documents and Settings\jonathan\My Documents\Personal\openlp\openlp-2\trunk\openlp\libraries\pptviewlib\pptviewlib.dll')
from PyQt4 import QtCore
class BoxLayout(QtGui.QWidget):
def __init__(self, parent=None):
QtGui.QWidget.__init__(self, parent)
class PptviewController(object):
"""
Class to control interactions with PowerPOint Viewer Presentations
It creates the runtime Environment , Loads the and Closes the Presentation
As well as trigggering the correct activities based on the users input
"""
global log
log = logging.getLogger(u'PptviewController')
def __init__(self):
log.debug(u'Initialising')
self.process = None
self.document = None
self.presentation = None
self.pptid = None
self.startPPTView()
def startPPTView(self):
"""
Loads the PPTVIEWLIB library
"""
log.debug(u'start PPTView')
self.presentation = cdll.LoadLibrary(r'openlp\plugins\presentations\lib\pptviewlib\pptviewlib.dll')
def kill(self):
"""
Called at system exit to clean up any running presentations
"""
log.debug(u'Kill')
self.closePresentation()
def loadPresentation(self, presentation):
"""
Called when a presentation is added to the SlideController.
It builds the environment, starts communcations with the background
OpenOffice task started earlier. If OpenOffice is not present is is
started. Once the environment is available the presentation is loaded
and started.
``presentation``
The file name of the presentatios to the run.
"""
log.debug(u'LoadPresentation')
if(self.pptid>=0):
self.CloseClick()
rect = RECT()
rect.left = 0
rect.top = 0
rect.width = 0
rect.hight = 0
try:
tempfolder = None #r'c:\temp\pptviewlib\' + presentation
self.pptid = self.presentation.OpenPPT(presentation, None, rect, tempfolder)
except:
log.exception(u'Failed to load presentation')
#self.slidecount = pptdll.GetSlideCount(self.pptid)
def closePresentation(self):
"""
Close presentation and clean up objects
Triggerent by new object being added to SlideController orOpenLP
being shut down
"""
if(self.pptid<0): return
self.presentation.Close(self.pptid)
self.pptid = -1
self.setWindowTitle(u'box layout')
PPTLabel = QtGui.QLabel(u'Open PowerPoint file')
slideLabel = QtGui.QLabel(u'Go to slide #')
self.PPTEdit = QtGui.QLineEdit()
self.slideEdit = QtGui.QLineEdit()
self.total = QtGui.QLabel()
PPTBtn = QtGui.QPushButton(u'Open')
PPTDlgBtn = QtGui.QPushButton(u'...')
slideBtn = QtGui.QPushButton(u'Go')
prev = QtGui.QPushButton(u'Prev')
next = QtGui.QPushButton(u'Next')
blank = QtGui.QPushButton(u'Blank')
unblank = QtGui.QPushButton(u'Unblank')
restart = QtGui.QPushButton(u'Restart')
close = QtGui.QPushButton(u'Close')
resume = QtGui.QPushButton(u'Resume')
stop = QtGui.QPushButton(u'Stop')
pptwindow = QtGui.QWidget()
def isActive(self):
return self.pptid >= 0
grid = QtGui.QGridLayout()
grid.addWidget(PPTLabel, 0, 0)
grid.addWidget(self.PPTEdit, 0, 1)
grid.addWidget(PPTDlgBtn, 0, 2)
grid.addWidget(PPTBtn, 0, 3)
grid.addWidget(slideLabel, 1, 0)
grid.addWidget(self.slideEdit, 1, 1)
grid.addWidget(slideBtn, 1, 3)
grid.addWidget(prev, 2, 0)
grid.addWidget(next, 2, 1)
grid.addWidget(blank, 3, 0)
grid.addWidget(unblank, 3, 1)
grid.addWidget(restart, 4, 0)
grid.addWidget(stop, 4, 1)
grid.addWidget(resume, 4, 2)
grid.addWidget(pptwindow, 5, 0, 10, 3)
self.connect(PPTBtn, QtCore.SIGNAL(u'clicked()'), self.OpenClick)
self.connect(PPTDlgBtn, QtCore.SIGNAL(u'clicked()'), self.OpenDialog)
self.connect(slideBtn, 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)
def resume(self):
if(self.pptid<0): return
self.presentation.Resume(self.pptid)
self.setLayout(grid)
def pause(self):
return
self.resize(300, 150)
def blankScreen(self):
if(self.pptid<0): return
self.presentation.Blank(self.pptid)
def PrevClick(self):
def unblankScreen(self):
if(self.pptid<0): return
self.presentation.Unblank(self.pptid)
def stop(self):
if(self.pptid<0): return
self.presentation.Stop(self.pptid)
def go(self):
if(self.pptid<0): return
self.presentation.RestartShow(self.pptid)
def getSlideNumber(self):
if(self.pptid<0): return -1
return self.presentation.GetCurrentSlide(self.pptid)
def setSlideNumber(self, slideno):
if(self.pptid<0): return
self.presentation.GotoSlide(self.pptid, slideno)
slideNumber = property(getSlideNumber, setSlideNumber)
def nextStep(self):
"""
Triggers the next effect of slide on the running presentation
"""
if(self.pptid<0): return
self.presentation.NextStep(self.pptid)
def previousStep(self):
"""
Triggers the previous slide on the running presentation
"""
if self.pptid<0: return
pptdll.PrevStep(self.pptid)
self.slideEdit.setText(pptdll.GetCurrentSlide(self.pptid))
self.presentation.PrevStep(self.pptid)
def NextClick(self):
if(self.pptid<0): return
pptdll.NextStep(self.pptid)
self.slideEdit.setText(pptdll.GetCurrentSlide(self.pptid))
def BlankClick(self):
if(self.pptid<0): return
pptdll.Blank(self.pptid)
def UnblankClick(self):
if(self.pptid<0): return
pptdll.Unblank(self.pptid)
def RestartClick(self):
if(self.pptid<0): return
pptdll.RestartShow(self.pptid)
self.slideEdit.setText(pptdll.GetCurrentSlide(self.pptid))
def StopClick(self):
if(self.pptid<0): return
pptdll.Stop(self.pptid)
def ResumeClick(self):
if(self.pptid<0): return
pptdll.Resume(self.pptid)
def CloseClick(self):
if(self.pptid<0): return
pptdll.Close(self.pptid)
self.pptid = -1
def OpenClick(self):
if(self.pptid>=0):
self.CloseClick()
rect = RECT()
rect.left = 100
rect.top = 100
rect.width = 900
rect.hight = 700
#self.pptid = pptdll.OpenPPT(self.PPTEdit.text, None, rect, "c:\temp\slide')
self.pptid = pptdll.OpenPPT(u'C:\\test 1.ppt', None, rect, 'c:\temp\slide')
self.total.setText(pptdll.GetSlideCount(self.pptid))
self.slideEdit.setText(unicode(pptdll.GetCurrentSlide(self.pptid)))
def GotoClick(self):
if(self.pptid<0): return
pptdll.GotoSlide(self.pptid, self.slideEdit.text)
self.slideEdit.setText(pptdll.GetCurrentSlide(self.pptid))
def OpenDialog(self):
self.PPTEdit.setText(QtGui.QFileDialog.getOpenFileName(self, 'Open file'))
app = QtGui.QApplication(sys.argv)
qb = BoxLayout()
qb.show()
sys.exit(app.exec_())

View File

@ -27,6 +27,7 @@
#include <sys/stat.h>
#include "pptviewlib.h"
// Because of the callbacks used by SetWindowsHookEx, the memory used needs to be
// sharable across processes (the callbacks are done from a different process)
// Therefore use data_seg with RWS memory.
@ -310,9 +311,10 @@ BOOL GetPPTViewerPath(char *pptviewerpath, int strsize)
LRESULT lresult;
DEBUG("GetPPTViewerPath: start\n");
if(RegOpenKeyEx(HKEY_CLASSES_ROOT, "Applications\\PPTVIEW.EXE\\shell\\open\\command", 0, KEY_READ, &hkey)!=ERROR_SUCCESS)
if(RegOpenKeyEx(HKEY_CLASSES_ROOT, "Applications\\PPTVIEW.EXE\\shell\\Show\\command", 0, KEY_READ, &hkey)!=ERROR_SUCCESS)
return FALSE;
if(RegOpenKeyEx(HKEY_CLASSES_ROOT, "PowerPointViewer.Show.12\\shell\\Show\\command", 0, KEY_READ, &hkey)!=ERROR_SUCCESS)
if(RegOpenKeyEx(HKEY_CLASSES_ROOT, "Applications\\PPTVIEW.EXE\\shell\\open\\command", 0, KEY_READ, &hkey)!=ERROR_SUCCESS)
if(RegOpenKeyEx(HKEY_CLASSES_ROOT, "Applications\\PPTVIEW.EXE\\shell\\Show\\command", 0, KEY_READ, &hkey)!=ERROR_SUCCESS)
return FALSE;
dwtype = REG_SZ;
dwsize = (DWORD)strsize;
lresult = RegQueryValueEx(hkey, NULL, NULL, &dwtype, (LPBYTE)pptviewerpath, &dwsize );

View File

@ -51,4 +51,4 @@ struct PPTVIEWOBJ
char filename[MAX_PATH];
char previewpath[MAX_PATH];
PPTVIEWSTATE state;
};
};

View File

@ -1,203 +1,202 @@
<?xml version="1.0" encoding="Windows-1252"?>
<VisualStudioProject
ProjectType="Visual C++"
Version="9.00"
Name="pptviewlib"
ProjectGUID="{04CC20D1-DC5A-4189-8181-4011E3C21DCF}"
RootNamespace="pptviewlib"
Keyword="Win32Proj"
TargetFrameworkVersion="196613"
>
<Platforms>
<Platform
Name="Win32"
/>
</Platforms>
<ToolFiles>
</ToolFiles>
<Configurations>
<Configuration
Name="Debug|Win32"
OutputDirectory="$(SolutionDir)$(ConfigurationName)"
IntermediateDirectory="$(ConfigurationName)"
ConfigurationType="2"
CharacterSet="2"
>
<Tool
Name="VCPreBuildEventTool"
/>
<Tool
Name="VCCustomBuildTool"
/>
<Tool
Name="VCXMLDataGeneratorTool"
/>
<Tool
Name="VCWebServiceProxyGeneratorTool"
/>
<Tool
Name="VCMIDLTool"
/>
<Tool
Name="VCCLCompilerTool"
Optimization="0"
PreprocessorDefinitions="WIN32;_DEBUG;_WINDOWS;_USRDLL;PPTVIEWLIB_EXPORTS"
MinimalRebuild="true"
BasicRuntimeChecks="3"
RuntimeLibrary="3"
UsePrecompiledHeader="0"
WarningLevel="3"
DebugInformationFormat="4"
/>
<Tool
Name="VCManagedResourceCompilerTool"
/>
<Tool
Name="VCResourceCompilerTool"
/>
<Tool
Name="VCPreLinkEventTool"
/>
<Tool
Name="VCLinkerTool"
LinkIncremental="2"
ModuleDefinitionFile=""
GenerateDebugInformation="true"
SubSystem="2"
TargetMachine="1"
/>
<Tool
Name="VCALinkTool"
/>
<Tool
Name="VCManifestTool"
/>
<Tool
Name="VCXDCMakeTool"
/>
<Tool
Name="VCBscMakeTool"
/>
<Tool
Name="VCFxCopTool"
/>
<Tool
Name="VCAppVerifierTool"
/>
<Tool
Name="VCPostBuildEventTool"
/>
</Configuration>
<Configuration
Name="Release|Win32"
OutputDirectory="$(SolutionDir)$(ConfigurationName)"
IntermediateDirectory="$(ConfigurationName)"
ConfigurationType="2"
CharacterSet="1"
WholeProgramOptimization="1"
>
<Tool
Name="VCPreBuildEventTool"
/>
<Tool
Name="VCCustomBuildTool"
/>
<Tool
Name="VCXMLDataGeneratorTool"
/>
<Tool
Name="VCWebServiceProxyGeneratorTool"
/>
<Tool
Name="VCMIDLTool"
/>
<Tool
Name="VCCLCompilerTool"
Optimization="2"
EnableIntrinsicFunctions="true"
PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS;_USRDLL;PPTVIEWLIB_EXPORTS"
RuntimeLibrary="2"
EnableFunctionLevelLinking="true"
UsePrecompiledHeader="2"
WarningLevel="3"
DebugInformationFormat="3"
/>
<Tool
Name="VCManagedResourceCompilerTool"
/>
<Tool
Name="VCResourceCompilerTool"
/>
<Tool
Name="VCPreLinkEventTool"
/>
<Tool
Name="VCLinkerTool"
LinkIncremental="1"
ModuleDefinitionFile="pptviewlib.def"
GenerateDebugInformation="true"
SubSystem="2"
OptimizeReferences="2"
EnableCOMDATFolding="2"
TargetMachine="1"
/>
<Tool
Name="VCALinkTool"
/>
<Tool
Name="VCManifestTool"
/>
<Tool
Name="VCXDCMakeTool"
/>
<Tool
Name="VCBscMakeTool"
/>
<Tool
Name="VCFxCopTool"
/>
<Tool
Name="VCAppVerifierTool"
/>
<Tool
Name="VCPostBuildEventTool"
/>
</Configuration>
</Configurations>
<References>
</References>
<Files>
<Filter
Name="Source Files"
Filter="cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx"
UniqueIdentifier="{4FC737F1-C7A5-4376-A066-2A32D752A2FF}"
>
<File
RelativePath=".\pptviewlib.cpp"
>
</File>
<File
RelativePath=".\README.TXT"
>
</File>
</Filter>
<Filter
Name="Header Files"
Filter="h;hpp;hxx;hm;inl;inc;xsd"
UniqueIdentifier="{93995380-89BD-4b04-88EB-625FBE52EBFB}"
>
<File
RelativePath=".\pptviewlib.h"
>
</File>
</Filter>
<Filter
Name="Resource Files"
Filter="rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav"
UniqueIdentifier="{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}"
>
</Filter>
</Files>
<Globals>
</Globals>
</VisualStudioProject>
<?xml version="1.0" encoding="Windows-1252"?>
<VisualStudioProject
ProjectType="Visual C++"
Version="9.00"
Name="pptviewlib"
ProjectGUID="{04CC20D1-DC5A-4189-8181-4011E3C21DCF}"
RootNamespace="pptviewlib"
Keyword="Win32Proj"
TargetFrameworkVersion="196613"
>
<Platforms>
<Platform
Name="Win32"
/>
</Platforms>
<ToolFiles>
</ToolFiles>
<Configurations>
<Configuration
Name="Debug|Win32"
OutputDirectory="$(SolutionDir)$(ConfigurationName)"
IntermediateDirectory="$(ConfigurationName)"
ConfigurationType="2"
CharacterSet="2"
>
<Tool
Name="VCPreBuildEventTool"
/>
<Tool
Name="VCCustomBuildTool"
/>
<Tool
Name="VCXMLDataGeneratorTool"
/>
<Tool
Name="VCWebServiceProxyGeneratorTool"
/>
<Tool
Name="VCMIDLTool"
/>
<Tool
Name="VCCLCompilerTool"
Optimization="0"
PreprocessorDefinitions="WIN32;_DEBUG;_WINDOWS;_USRDLL;PPTVIEWLIB_EXPORTS"
MinimalRebuild="true"
BasicRuntimeChecks="3"
RuntimeLibrary="3"
UsePrecompiledHeader="0"
WarningLevel="3"
DebugInformationFormat="4"
/>
<Tool
Name="VCManagedResourceCompilerTool"
/>
<Tool
Name="VCResourceCompilerTool"
/>
<Tool
Name="VCPreLinkEventTool"
/>
<Tool
Name="VCLinkerTool"
LinkIncremental="2"
ModuleDefinitionFile=""
GenerateDebugInformation="true"
SubSystem="2"
TargetMachine="1"
/>
<Tool
Name="VCALinkTool"
/>
<Tool
Name="VCManifestTool"
/>
<Tool
Name="VCXDCMakeTool"
/>
<Tool
Name="VCBscMakeTool"
/>
<Tool
Name="VCFxCopTool"
/>
<Tool
Name="VCAppVerifierTool"
/>
<Tool
Name="VCPostBuildEventTool"
/>
</Configuration>
<Configuration
Name="Release|Win32"
OutputDirectory="$(SolutionDir)$(ConfigurationName)"
IntermediateDirectory="$(ConfigurationName)"
ConfigurationType="2"
CharacterSet="2"
WholeProgramOptimization="1"
>
<Tool
Name="VCPreBuildEventTool"
/>
<Tool
Name="VCCustomBuildTool"
/>
<Tool
Name="VCXMLDataGeneratorTool"
/>
<Tool
Name="VCWebServiceProxyGeneratorTool"
/>
<Tool
Name="VCMIDLTool"
/>
<Tool
Name="VCCLCompilerTool"
Optimization="2"
EnableIntrinsicFunctions="true"
PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS;_USRDLL;PPTVIEWLIB_EXPORTS"
RuntimeLibrary="2"
EnableFunctionLevelLinking="true"
UsePrecompiledHeader="0"
WarningLevel="3"
DebugInformationFormat="3"
/>
<Tool
Name="VCManagedResourceCompilerTool"
/>
<Tool
Name="VCResourceCompilerTool"
/>
<Tool
Name="VCPreLinkEventTool"
/>
<Tool
Name="VCLinkerTool"
LinkIncremental="1"
GenerateDebugInformation="true"
SubSystem="2"
OptimizeReferences="2"
EnableCOMDATFolding="2"
TargetMachine="1"
/>
<Tool
Name="VCALinkTool"
/>
<Tool
Name="VCManifestTool"
/>
<Tool
Name="VCXDCMakeTool"
/>
<Tool
Name="VCBscMakeTool"
/>
<Tool
Name="VCFxCopTool"
/>
<Tool
Name="VCAppVerifierTool"
/>
<Tool
Name="VCPostBuildEventTool"
/>
</Configuration>
</Configurations>
<References>
</References>
<Files>
<Filter
Name="Source Files"
Filter="cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx"
UniqueIdentifier="{4FC737F1-C7A5-4376-A066-2A32D752A2FF}"
>
<File
RelativePath=".\pptviewlib.cpp"
>
</File>
<File
RelativePath=".\README.TXT"
>
</File>
</Filter>
<Filter
Name="Header Files"
Filter="h;hpp;hxx;hm;inl;inc;xsd"
UniqueIdentifier="{93995380-89BD-4b04-88EB-625FBE52EBFB}"
>
<File
RelativePath=".\pptviewlib.h"
>
</File>
</Filter>
<Filter
Name="Resource Files"
Filter="rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav"
UniqueIdentifier="{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}"
>
</Filter>
</Files>
<Globals>
</Globals>
</VisualStudioProject>

View File

@ -31,10 +31,12 @@ from PyQt4 import QtCore, QtGui
from openlp.core.lib import Plugin, MediaManagerItem
from openlp.plugins.presentations.lib import PresentationMediaItem, \
PresentationTab, ImpressController
try:
from openlp.plugins.presentations.lib import PowerpointController
except:
pass
if os.name == u'nt':
try:
from openlp.plugins.presentations.lib import PowerpointController
except:
pass
from openlp.plugins.presentations.lib import PptviewController
class PresentationPlugin(Plugin):
@ -91,26 +93,25 @@ class PresentationPlugin(Plugin):
self.registerControllers(u'Impress', openoffice)
except:
log.exception(u'Failed to set up plugin for Impress')
#Lets see if Powerpoint is required (Default is Not wanted)
if int(self.config.get_config(
u'Powerpoint', QtCore.Qt.Unchecked)) == QtCore.Qt.Checked:
try:
#Check to see if we are Win32
from win32com.client import Dispatch
powerpoint = PowerpointController()
self.registerControllers(u'Powerpoint', powerpoint)
except:
log.exception(u'Failed to set up plugin for Powerpoint')
#Lets see if Powerpoint Viewer is required (Default is Not wanted)
if int(self.config.get_config(
u'Powerpoint Viewer', QtCore.Qt.Unchecked)) == QtCore.Qt.Checked:
try:
#Check to see if we are Win32
from win32com.client import Dispatch
powerpoint = PowerpointController()
self.registerControllers(u'Powerpoint Viewer', powerpoint)
except:
log.exception(u'Failed to set up plugin for Powerpoint Viewer')
if os.name == u'nt':
#Lets see if Powerpoint is required (Default is Not wanted)
if int(self.config.get_config(
u'Powerpoint', QtCore.Qt.Unchecked)) == QtCore.Qt.Checked:
try:
#Check to see if we are Win32
from win32com.client import Dispatch
powerpoint = PowerpointController()
self.registerControllers(u'Powerpoint', powerpoint)
except:
log.exception(u'Failed to set up plugin for Powerpoint')
#Lets see if Powerpoint Viewer is required (Default is Not wanted)
if int(self.config.get_config(
u'Powerpoint Viewer', QtCore.Qt.Unchecked)) == QtCore.Qt.Checked:
try:
pptview = PptviewController()
self.registerControllers(u'Powerpoint Viewer', pptview)
except:
log.exception(u'Failed to set up plugin for Powerpoint Viewer')
#If we have no available controllers disable plugin
if len(self.controllers) > 0:
return True