From d6eb08c759bcdb034c76f4db0483bdfe146c2616 Mon Sep 17 00:00:00 2001 From: Philip Ridout Date: Thu, 17 Oct 2013 21:15:35 +0100 Subject: [PATCH] Final touches --- .../presentations/lib/pptviewcontroller.py | 13 ++-- .../presentations/lib/pptviewlib/ppttest.py | 7 ++- .../lib/pptviewlib/pptviewlib.cpp | 20 +++---- .../lib/pptviewlib/pptviewlib.vcproj | 60 +------------------ 4 files changed, 21 insertions(+), 79 deletions(-) diff --git a/openlp/plugins/presentations/lib/pptviewcontroller.py b/openlp/plugins/presentations/lib/pptviewcontroller.py index 8a9998540..f252483a2 100644 --- a/openlp/plugins/presentations/lib/pptviewcontroller.py +++ b/openlp/plugins/presentations/lib/pptviewcontroller.py @@ -90,7 +90,7 @@ class PptviewController(PresentationController): u'presentations', u'lib', u'pptviewlib', u'pptviewlib.dll') self.process = cdll.LoadLibrary(dllpath) if log.isEnabledFor(logging.DEBUG): - self.process.SetDebug(0) + self.process.SetDebug(1) def kill(self): """ @@ -127,12 +127,11 @@ class PptviewDocument(PresentationDocument): rect = renderer.screens.current[u'size'] rect = RECT(rect.x(), rect.y(), rect.right(), rect.bottom()) file_system_encoding = 'utf-16-le' - # Add a null char on the end otherwise we get spurious issues with - # the encoding. - file_path = os.path.normpath(self.filepath) + u'\0' - preview_path = os.path.join(self.get_temp_folder(), u'slide') + u'\0' - file_path = file_path.encode(file_system_encoding) - preview_path = preview_path.encode(file_system_encoding) + file_path = os.path.normpath(self.filepath) + preview_path = os.path.join(self.get_temp_folder(), u'slide') + # Ensure that the paths are null terminated + file_path = file_path.encode(file_system_encoding) + '\0' + preview_path = preview_path.encode(file_system_encoding) + '\0' if not os.path.isdir(self.get_temp_folder()): os.makedirs(self.get_temp_folder()) self.pptid = self.controller.process.OpenPPT(file_path, None, rect, diff --git a/openlp/plugins/presentations/lib/pptviewlib/ppttest.py b/openlp/plugins/presentations/lib/pptviewlib/ppttest.py index 7dea7621d..6645e9006 100644 --- a/openlp/plugins/presentations/lib/pptviewlib/ppttest.py +++ b/openlp/plugins/presentations/lib/pptviewlib/ppttest.py @@ -27,8 +27,9 @@ # Temple Place, Suite 330, Boston, MA 02111-1307 USA # ############################################################################### -import sys import os +import sys + from PyQt4 import QtGui, QtCore from ctypes import * from ctypes.wintypes import RECT @@ -173,8 +174,8 @@ class PPTViewer(QtGui.QWidget): oldid = self.pptid; rect = RECT(int(self.xEdit.text()), int(self.yEdit.text()), int(self.widthEdit.text()), int(self.heightEdit.text())) - filename = os.path.normpath(unicode(self.pptEdit.text())).encode('utf-16-le') - folder = os.path.normpath(unicode(self.folderEdit.text())).encode('utf-16-le') + filename = os.path.normpath(unicode(self.pptEdit.text())).encode('utf-16-le') + '\0' + folder = os.path.normpath(unicode(self.folderEdit.text())).encode('utf-16-le') + '\0' self.pptid = self.pptdll.OpenPPT(filename, None, rect, folder) print u'id: ' + unicode(self.pptid) if oldid >= 0: diff --git a/openlp/plugins/presentations/lib/pptviewlib/pptviewlib.cpp b/openlp/plugins/presentations/lib/pptviewlib/pptviewlib.cpp index 3c37ff02b..a4ee5053c 100644 --- a/openlp/plugins/presentations/lib/pptviewlib/pptviewlib.cpp +++ b/openlp/plugins/presentations/lib/pptviewlib/pptviewlib.cpp @@ -370,7 +370,7 @@ BOOL GetPPTViewerPath(wchar_t *pptViewerPath, int stringSize) // upset those who like to put things somewhere else // Viewer 2007 in 64bit Windows: - if(_access("C:\\Program Files (x86)\\Microsoft Office\\Office12\\PPTVIEW.EXE", + if(_waccess(L"C:\\Program Files (x86)\\Microsoft Office\\Office12\\PPTVIEW.EXE", 0) != -1) { wcscpy_s( @@ -380,7 +380,7 @@ BOOL GetPPTViewerPath(wchar_t *pptViewerPath, int stringSize) return TRUE; } // Viewer 2007 in 32bit Windows: - if(_access("C:\\Program Files\\Microsoft Office\\Office12\\PPTVIEW.EXE", 0) + if(_waccess(L"C:\\Program Files\\Microsoft Office\\Office12\\PPTVIEW.EXE", 0) != -1) { wcscpy_s(L"C:\\Program Files\\Microsoft Office\\Office12\\PPTVIEW.EXE", @@ -411,17 +411,17 @@ BOOL GetPPTViewerPathFromReg(wchar_t *pptViewerPath, int stringSize) // PPT Viewer 2003 (recent versions) // PPT Viewer 2003 (older versions) // PPT Viewer 97 - if ((RegOpenKeyExA(HKEY_CLASSES_ROOT, - "PowerPointViewer.Show.12\\shell\\Show\\command", 0, KEY_READ, &hKey) + if ((RegOpenKeyExW(HKEY_CLASSES_ROOT, + L"PowerPointViewer.Show.12\\shell\\Show\\command", 0, KEY_READ, &hKey) != ERROR_SUCCESS) - && (RegOpenKeyExA(HKEY_CLASSES_ROOT, - "PowerPointViewer.Show.11\\shell\\Show\\command", 0, KEY_READ, &hKey) + && (RegOpenKeyExW(HKEY_CLASSES_ROOT, + L"PowerPointViewer.Show.11\\shell\\Show\\command", 0, KEY_READ, &hKey) != ERROR_SUCCESS) - && (RegOpenKeyExA(HKEY_CLASSES_ROOT, - "Applications\\PPTVIEW.EXE\\shell\\open\\command", 0, KEY_READ, &hKey) + && (RegOpenKeyExW(HKEY_CLASSES_ROOT, + L"Applications\\PPTVIEW.EXE\\shell\\open\\command", 0, KEY_READ, &hKey) != ERROR_SUCCESS) - && (RegOpenKeyExA(HKEY_CLASSES_ROOT, - "Applications\\PPTVIEW.EXE\\shell\\Show\\command", 0, KEY_READ, &hKey) + && (RegOpenKeyExW(HKEY_CLASSES_ROOT, + L"Applications\\PPTVIEW.EXE\\shell\\Show\\command", 0, KEY_READ, &hKey) != ERROR_SUCCESS)) { return FALSE; diff --git a/openlp/plugins/presentations/lib/pptviewlib/pptviewlib.vcproj b/openlp/plugins/presentations/lib/pptviewlib/pptviewlib.vcproj index 92e30fabb..d2843e510 100644 --- a/openlp/plugins/presentations/lib/pptviewlib/pptviewlib.vcproj +++ b/openlp/plugins/presentations/lib/pptviewlib/pptviewlib.vcproj @@ -18,7 +18,7 @@ - - - - - - - - - - - - - - - - - - -