Merge lp:~phill-ridout/openlp/1012110_2.0 into lp:openlp/2.0

Proposed by Phill
Status: Merged
Approved by: Jonathan Corwin
Approved revision: 2175
Merged at revision: 2173
Proposed branch: lp:~phill-ridout/openlp/1012110_2.0
Merge into: lp:openlp/2.0
Diff against target: 724 lines (+146/-139)
5 files modified
openlp/plugins/presentations/lib/pptviewcontroller.py (+9/-3)
openlp/plugins/presentations/lib/pptviewlib/ppttest.py (+4/-3)
openlp/plugins/presentations/lib/pptviewlib/pptviewlib.cpp (+122/-122)
openlp/plugins/presentations/lib/pptviewlib/pptviewlib.h (+9/-9)
openlp/plugins/presentations/lib/pptviewlib/pptviewlib.vcproj (+2/-2)
To merge this branch: bzr merge lp:~phill-ridout/openlp/1012110_2.0
Reviewer Review Type Date Requested Status
Jonathan Corwin (community) Approve
Raoul Snyman Approve
Phill Pending
Review via email: mp+192230@code.launchpad.net

This proposal supersedes a proposal from 2013-10-06.

Description of the change

Fixes bug #1012110 by encoding the file name with the file system encoding

To post a comment you must log in.
Revision history for this message
Raoul Snyman (raoul-snyman) wrote : Posted in a previous version of this proposal

I can't test this (as I don't have Windows), but there are a few things you need to change:

On line 17 you should use os.path.normpath(), don't do a manual find and replace. See http://docs.python.org/2/library/os.path.html#os.path.normpath

On line 22 you should use os.path.join().

review: Needs Fixing
Revision history for this message
Raoul Snyman (raoul-snyman) wrote : Posted in a previous version of this proposal

This looks better but I'm going to have to wait for someone with Windows to confirm the fix.

review: Approve
Revision history for this message
Phill (phill-ridout) wrote : Posted in a previous version of this proposal

Sure, I'll let the mailing list know!

On 6 October 2013 09:37, Raoul Snyman <email address hidden> wrote:

> Review: Approve
>
> This looks better but I'm going to have to wait for someone with Windows
> to confirm the fix.
> --
> https://code.launchpad.net/~phill-ridout/openlp/1012110_2.0/+merge/189494
> You are the owner of lp:~phill-ridout/openlp/1012110_2.0.
>

Revision history for this message
Jonathan Corwin (j-corwin) wrote : Posted in a previous version of this proposal

Worked with an English file name. Didn't work with the file name Հայաստան.pptx
(Didn't crash, just said it couldn't open filename ?????????.pptx)

However this might be an issue with the C++ in pptviewlib.dll rather than the python.

Revision history for this message
Phill (phill-ridout) wrote : Posted in a previous version of this proposal

On 7 Oct 2013 08:56, "Jonathan Corwin" <email address hidden> wrote:
>
> Worked with an English file name. Didn't work with the file name
Հայաստան.pptx
> (Didn't crash, just said it couldn't open filename ?????????.pptx)

Presumably it worked fine opening the file in Power Point with out using
OpenLP?

> However this might be an issue with the C++ in pptviewlib.dll rather than
the python.
> --
> https://code.launchpad.net/~phill-ridout/openlp/1012110_2.0/+merge/189494
> You are the owner of lp:~phill-ridout/openlp/1012110_2.0.

Revision history for this message
Jonathan Corwin (j-corwin) wrote : Posted in a previous version of this proposal

> Presumably it worked fine opening the file in Power Point with out using
> OpenLP?

Yes it did

Revision history for this message
Phill (phill-ridout) wrote : Posted in a previous version of this proposal

Python actually creates the question marks when it tries to encode the unicode file name. From what I've read on windows all file names are unicode. How much work would it be to rewrite the c library to use unicode? Would this even solve the issue? Either way this is a bit out of my depth...

review: Needs Fixing
Revision history for this message
Raoul Snyman (raoul-snyman) wrote :

I hope this actually works, as I have no way of testing it :-)

review: Approve
Revision history for this message
Jonathan Corwin (j-corwin) :
review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'openlp/plugins/presentations/lib/pptviewcontroller.py'
2--- openlp/plugins/presentations/lib/pptviewcontroller.py 2013-08-20 18:30:15 +0000
3+++ openlp/plugins/presentations/lib/pptviewcontroller.py 2013-10-22 19:57:11 +0000
4@@ -29,6 +29,7 @@
5
6 import os
7 import logging
8+import sys
9
10 if os.name == u'nt':
11 from ctypes import cdll
12@@ -125,11 +126,16 @@
13 renderer = self.controller.plugin.renderer
14 rect = renderer.screens.current[u'size']
15 rect = RECT(rect.x(), rect.y(), rect.right(), rect.bottom())
16- filepath = str(self.filepath.replace(u'/', u'\\'))
17+ file_system_encoding = 'utf-16-le'
18+ file_path = os.path.normpath(self.filepath)
19+ preview_path = os.path.join(self.get_temp_folder(), u'slide')
20+ # Ensure that the paths are null terminated
21+ file_path = file_path.encode(file_system_encoding) + '\0'
22+ preview_path = preview_path.encode(file_system_encoding) + '\0'
23 if not os.path.isdir(self.get_temp_folder()):
24 os.makedirs(self.get_temp_folder())
25- self.pptid = self.controller.process.OpenPPT(filepath, None, rect,
26- str(self.get_temp_folder()) + '\\slide')
27+ self.pptid = self.controller.process.OpenPPT(file_path, None, rect,
28+ preview_path)
29 if self.pptid >= 0:
30 self.create_thumbnails()
31 self.stop_presentation()
32
33=== modified file 'openlp/plugins/presentations/lib/pptviewlib/ppttest.py'
34--- openlp/plugins/presentations/lib/pptviewlib/ppttest.py 2012-12-30 19:41:24 +0000
35+++ openlp/plugins/presentations/lib/pptviewlib/ppttest.py 2013-10-22 19:57:11 +0000
36@@ -27,7 +27,9 @@
37 # Temple Place, Suite 330, Boston, MA 02111-1307 USA #
38 ###############################################################################
39
40+import os
41 import sys
42+
43 from PyQt4 import QtGui, QtCore
44 from ctypes import *
45 from ctypes.wintypes import RECT
46@@ -172,9 +174,8 @@
47 oldid = self.pptid;
48 rect = RECT(int(self.xEdit.text()), int(self.yEdit.text()),
49 int(self.widthEdit.text()), int(self.heightEdit.text()))
50- filename = str(self.pptEdit.text().replace(u'/', u'\\'))
51- folder = str(self.folderEdit.text().replace(u'/', u'\\'))
52- print filename, folder
53+ filename = os.path.normpath(unicode(self.pptEdit.text())).encode('utf-16-le') + '\0'
54+ folder = os.path.normpath(unicode(self.folderEdit.text())).encode('utf-16-le') + '\0'
55 self.pptid = self.pptdll.OpenPPT(filename, None, rect, folder)
56 print u'id: ' + unicode(self.pptid)
57 if oldid >= 0:
58
59=== modified file 'openlp/plugins/presentations/lib/pptviewlib/pptviewlib.cpp'
60--- openlp/plugins/presentations/lib/pptviewlib/pptviewlib.cpp 2012-12-30 19:41:24 +0000
61+++ openlp/plugins/presentations/lib/pptviewlib/pptviewlib.cpp 2013-10-22 19:57:11 +0000
62@@ -61,18 +61,18 @@
63 switch(ulReasonForCall)
64 {
65 case DLL_PROCESS_ATTACH:
66- DEBUG("PROCESS_ATTACH\n");
67+ DEBUG(L"PROCESS_ATTACH\n");
68 break;
69 case DLL_THREAD_ATTACH:
70- //DEBUG("THREAD_ATTACH\n");
71+ //DEBUG(L"THREAD_ATTACH\n");
72 break;
73 case DLL_THREAD_DETACH:
74- //DEBUG("THREAD_DETACH\n");
75+ //DEBUG(L"THREAD_DETACH\n");
76 break;
77 case DLL_PROCESS_DETACH:
78 // Clean up... hopefully there is only the one process attached?
79 // We'll find out soon enough during tests!
80- DEBUG("PROCESS_DETACH\n");
81+ DEBUG(L"PROCESS_DETACH\n");
82 for (int i = 0; i < MAX_PPTS; i++)
83 ClosePPT(i);
84 break;
85@@ -84,18 +84,18 @@
86 {
87 printf("SetDebug\n");
88 debug = onOff;
89- DEBUG("enabled\n");
90+ DEBUG(L"enabled\n");
91 }
92
93 DllExport BOOL CheckInstalled()
94 {
95- char cmdLine[MAX_PATH * 2];
96+ wchar_t cmdLine[MAX_PATH * 2];
97
98- DEBUG("CheckInstalled\n");
99+ DEBUG(L"CheckInstalled\n");
100 BOOL found = GetPPTViewerPath(cmdLine, sizeof(cmdLine));
101 if(found)
102 {
103- DEBUG("Exe: %s\n", cmdLine);
104+ DEBUG(L"Exe: %s\n", cmdLine);
105 }
106 return found;
107 }
108@@ -106,20 +106,20 @@
109 // "<n>.bmp" will be appended to complete the path. E.g. "c:\temp\slide" would
110 // create "c:\temp\slide1.bmp" slide2.bmp, slide3.bmp etc.
111 // It will also create a *info.txt containing information about the ppt
112-DllExport int OpenPPT(char *filename, HWND hParentWnd, RECT rect,
113- char *previewPath)
114+DllExport int OpenPPT(wchar_t *filename, HWND hParentWnd, RECT rect,
115+ wchar_t *previewPath)
116 {
117 STARTUPINFO si;
118 PROCESS_INFORMATION pi;
119- char cmdLine[MAX_PATH * 2];
120+ wchar_t cmdLine[MAX_PATH * 2];
121 int id;
122
123- DEBUG("OpenPPT start: %s; %s\n", filename, previewPath);
124- DEBUG("OpenPPT start: %u; %i, %i, %i, %i\n", hParentWnd, rect.top,
125+ DEBUG(L"OpenPPT start: %s; %s\n", filename, previewPath);
126+ DEBUG(L"OpenPPT start: %u; %i, %i, %i, %i\n", hParentWnd, rect.top,
127 rect.left, rect.bottom, rect.right);
128 if (GetPPTViewerPath(cmdLine, sizeof(cmdLine)) == FALSE)
129 {
130- DEBUG("OpenPPT: GetPPTViewerPath failed\n");
131+ DEBUG(L"OpenPPT: GetPPTViewerPath failed\n");
132 return -1;
133 }
134 id = -1;
135@@ -133,12 +133,12 @@
136 }
137 if (id < 0)
138 {
139- DEBUG("OpenPPT: Too many PPTs\n");
140+ DEBUG(L"OpenPPT: Too many PPTs\n");
141 return -1;
142 }
143 memset(&pptView[id], 0, sizeof(PPTVIEW));
144- strcpy_s(pptView[id].filename, MAX_PATH, filename);
145- strcpy_s(pptView[id].previewPath, MAX_PATH, previewPath);
146+ wcscpy_s(pptView[id].filename, MAX_PATH, filename);
147+ wcscpy_s(pptView[id].previewPath, MAX_PATH, previewPath);
148 pptView[id].state = PPT_CLOSED;
149 pptView[id].slideCount = 0;
150 pptView[id].currentSlide = 0;
151@@ -169,9 +169,9 @@
152 pptView[id].rect.bottom = rect.bottom;
153 pptView[id].rect.right = rect.right;
154 }
155- strcat_s(cmdLine, MAX_PATH * 2, " /F /S \"");
156- strcat_s(cmdLine, MAX_PATH * 2, filename);
157- strcat_s(cmdLine, MAX_PATH * 2, "\"");
158+ wcscat_s(cmdLine, MAX_PATH * 2, L" /F /S \"");
159+ wcscat_s(cmdLine, MAX_PATH * 2, filename);
160+ wcscat_s(cmdLine, MAX_PATH * 2, L"\"");
161 memset(&si, 0, sizeof(si));
162 memset(&pi, 0, sizeof(pi));
163 BOOL gotInfo = GetPPTInfo(id);
164@@ -190,7 +190,7 @@
165 globalHook = SetWindowsHookEx(WH_CBT, CbtProc, hInstance, NULL);
166 if (globalHook == 0)
167 {
168- DEBUG("OpenPPT: SetWindowsHookEx failed\n");
169+ DEBUG(L"OpenPPT: SetWindowsHookEx failed\n");
170 ClosePPT(id);
171 return -1;
172 }
173@@ -198,7 +198,7 @@
174 Sleep(10);
175 if (!CreateProcess(NULL, cmdLine, NULL, NULL, FALSE, 0, 0, NULL, &si, &pi))
176 {
177- DEBUG("OpenPPT: CreateProcess failed: %s\n", cmdLine);
178+ DEBUG(L"OpenPPT: CreateProcess failed: %s\n", cmdLine);
179 ClosePPT(id);
180 return -1;
181 }
182@@ -210,13 +210,13 @@
183 Sleep(10);
184 if (gotInfo)
185 {
186- DEBUG("OpenPPT: Info loaded, no refresh\n");
187+ DEBUG(L"OpenPPT: Info loaded, no refresh\n");
188 pptView[id].state = PPT_LOADED;
189 Resume(id);
190 }
191 else
192 {
193- DEBUG("OpenPPT: Get info\n");
194+ DEBUG(L"OpenPPT: Get info\n");
195 pptView[id].steps = 0;
196 int steps = 0;
197 while (pptView[id].state == PPT_OPENED)
198@@ -224,18 +224,18 @@
199 if (steps <= pptView[id].steps)
200 {
201 Sleep(20);
202- DEBUG("OpenPPT: Step %d/%d\n", steps, pptView[id].steps);
203+ DEBUG(L"OpenPPT: Step %d/%d\n", steps, pptView[id].steps);
204 steps++;
205 NextStep(id);
206 }
207 Sleep(10);
208 }
209- DEBUG("OpenPPT: Slides %d, Steps %d, first slide steps %d\n",
210+ DEBUG(L"OpenPPT: Slides %d, Steps %d, first slide steps %d\n",
211 pptView[id].slideCount, pptView[id].steps,
212 pptView[id].firstSlideSteps);
213 for(int i = 1; i <= pptView[id].slideCount; i++)
214 {
215- DEBUG("OpenPPT: Slide %d = %d\n", i, pptView[id].slideNos[i]);
216+ DEBUG(L"OpenPPT: Slide %d = %d\n", i, pptView[id].slideNos[i]);
217 }
218 SavePPTInfo(id);
219 if (pptView[id].state == PPT_CLOSING
220@@ -257,7 +257,7 @@
221 }
222 pptView[id].msgHook = NULL;
223 }
224- DEBUG("OpenPPT: Exit: id=%i\n", id);
225+ DEBUG(L"OpenPPT: Exit: id=%i\n", id);
226 return id;
227 }
228 // Load information about the ppt from an info.txt file.
229@@ -270,75 +270,75 @@
230 BOOL GetPPTInfo(int id)
231 {
232 struct _stat fileStats;
233- char info[MAX_PATH];
234+ wchar_t info[MAX_PATH];
235 FILE* pFile;
236- char buf[100];
237+ wchar_t buf[100];
238
239- DEBUG("GetPPTInfo: start\n");
240- if (_stat(pptView[id].filename, &fileStats) != 0)
241+ DEBUG(L"GetPPTInfo: start\n");
242+ if (_wstat(pptView[id].filename, &fileStats) != 0)
243 {
244 return FALSE;
245 }
246- sprintf_s(info, MAX_PATH, "%sinfo.txt", pptView[id].previewPath);
247- int err = fopen_s(&pFile, info, "r");
248+ swprintf_s(info, MAX_PATH, L"%sinfo.txt", pptView[id].previewPath);
249+ int err = _wfopen_s(&pFile, info, L"r");
250 if (err != 0)
251 {
252- DEBUG("GetPPTInfo: file open failed - %d\n", err);
253- return FALSE;
254- }
255- fgets(buf, 100, pFile); // version == 1
256- fgets(buf, 100, pFile);
257- if (fileStats.st_mtime != atoi(buf))
258- {
259- DEBUG("GetPPTInfo: date changed\n");
260- fclose (pFile);
261- return FALSE;
262- }
263- fgets(buf, 100, pFile);
264- if (fileStats.st_size != atoi(buf))
265- {
266- DEBUG("GetPPTInfo: size changed\n");
267- fclose (pFile);
268- return FALSE;
269- }
270- fgets(buf, 100, pFile); // slidecount
271- int slideCount = atoi(buf);
272- fgets(buf, 100, pFile); // first slide steps
273- int firstSlideSteps = atoi(buf);
274+ DEBUG(L"GetPPTInfo: file open failed - %d\n", err);
275+ return FALSE;
276+ }
277+ fgetws(buf, 100, pFile); // version == 1
278+ fgetws(buf, 100, pFile);
279+ if (fileStats.st_mtime != _wtoi(buf))
280+ {
281+ DEBUG(L"GetPPTInfo: date changed\n");
282+ fclose (pFile);
283+ return FALSE;
284+ }
285+ fgetws(buf, 100, pFile);
286+ if (fileStats.st_size != _wtoi(buf))
287+ {
288+ DEBUG(L"GetPPTInfo: size changed\n");
289+ fclose (pFile);
290+ return FALSE;
291+ }
292+ fgetws(buf, 100, pFile); // slidecount
293+ int slideCount = _wtoi(buf);
294+ fgetws(buf, 100, pFile); // first slide steps
295+ int firstSlideSteps = _wtoi(buf);
296 // check all the preview images still exist
297 for (int i = 1; i <= slideCount; i++)
298 {
299- sprintf_s(info, MAX_PATH, "%s%i.bmp", pptView[id].previewPath, i);
300+ swprintf_s(info, MAX_PATH, L"%s%i.bmp", pptView[id].previewPath, i);
301 if (GetFileAttributes(info) == INVALID_FILE_ATTRIBUTES)
302 {
303- DEBUG("GetPPTInfo: bmp not found\n");
304+ DEBUG(L"GetPPTInfo: bmp not found\n");
305 return FALSE;
306 }
307 }
308 fclose(pFile);
309 pptView[id].slideCount = slideCount;
310 pptView[id].firstSlideSteps = firstSlideSteps;
311- DEBUG("GetPPTInfo: exit ok\n");
312+ DEBUG(L"GetPPTInfo: exit ok\n");
313 return TRUE;
314 }
315
316 BOOL SavePPTInfo(int id)
317 {
318 struct _stat fileStats;
319- char info[MAX_PATH];
320+ wchar_t info[MAX_PATH];
321 FILE* pFile;
322
323- DEBUG("SavePPTInfo: start\n");
324- if (_stat(pptView[id].filename, &fileStats) != 0)
325+ DEBUG(L"SavePPTInfo: start\n");
326+ if (_wstat(pptView[id].filename, &fileStats) != 0)
327 {
328- DEBUG("SavePPTInfo: stat of %s failed\n", pptView[id].filename);
329+ DEBUG(L"SavePPTInfo: stat of %s failed\n", pptView[id].filename);
330 return FALSE;
331 }
332- sprintf_s(info, MAX_PATH, "%sinfo.txt", pptView[id].previewPath);
333- int err = fopen_s(&pFile, info, "w");
334+ swprintf_s(info, MAX_PATH, L"%sinfo.txt", pptView[id].previewPath);
335+ int err = _wfopen_s(&pFile, info, L"w");
336 if (err != 0)
337 {
338- DEBUG("SavePPTInfo: fopen of %s failed%i\n", info, err);
339+ DEBUG(L"SavePPTInfo: fopen of %s failed%i\n", info, err);
340 return FALSE;
341 }
342 fprintf(pFile, "1\n");
343@@ -347,21 +347,21 @@
344 fprintf(pFile, "%u\n", pptView[id].slideCount);
345 fprintf(pFile, "%u\n", pptView[id].firstSlideSteps);
346 fclose(pFile);
347- DEBUG("SavePPTInfo: exit ok\n");
348+ DEBUG(L"SavePPTInfo: exit ok\n");
349 return TRUE;
350 }
351
352 // Get the path of the PowerPoint viewer from the registry
353-BOOL GetPPTViewerPath(char *pptViewerPath, int stringSize)
354+BOOL GetPPTViewerPath(wchar_t *pptViewerPath, int stringSize)
355 {
356- char cwd[MAX_PATH];
357+ wchar_t cwd[MAX_PATH];
358
359- DEBUG("GetPPTViewerPath: start\n");
360+ DEBUG(L"GetPPTViewerPath: start\n");
361 if(GetPPTViewerPathFromReg(pptViewerPath, stringSize))
362 {
363- if(_access(pptViewerPath, 0) != -1)
364+ if(_waccess(pptViewerPath, 0) != -1)
365 {
366- DEBUG("GetPPTViewerPath: exit registry\n");
367+ DEBUG(L"GetPPTViewerPath: exit registry\n");
368 return TRUE;
369 }
370 }
371@@ -370,37 +370,37 @@
372 // upset those who like to put things somewhere else
373
374 // Viewer 2007 in 64bit Windows:
375- if(_access("C:\\Program Files (x86)\\Microsoft Office\\Office12\\PPTVIEW.EXE",
376+ if(_waccess(L"C:\\Program Files (x86)\\Microsoft Office\\Office12\\PPTVIEW.EXE",
377 0) != -1)
378 {
379- strcpy_s(
380- "C:\\Program Files (x86)\\Microsoft Office\\Office12\\PPTVIEW.EXE",
381+ wcscpy_s(
382+ L"C:\\Program Files (x86)\\Microsoft Office\\Office12\\PPTVIEW.EXE",
383 stringSize, pptViewerPath);
384- DEBUG("GetPPTViewerPath: exit 64bit 2007\n");
385+ DEBUG(L"GetPPTViewerPath: exit 64bit 2007\n");
386 return TRUE;
387 }
388 // Viewer 2007 in 32bit Windows:
389- if(_access("C:\\Program Files\\Microsoft Office\\Office12\\PPTVIEW.EXE", 0)
390+ if(_waccess(L"C:\\Program Files\\Microsoft Office\\Office12\\PPTVIEW.EXE", 0)
391 != -1)
392 {
393- strcpy_s("C:\\Program Files\\Microsoft Office\\Office12\\PPTVIEW.EXE",
394+ wcscpy_s(L"C:\\Program Files\\Microsoft Office\\Office12\\PPTVIEW.EXE",
395 stringSize, pptViewerPath);
396- DEBUG("GetPPTViewerPath: exit 32bit 2007\n");
397+ DEBUG(L"GetPPTViewerPath: exit 32bit 2007\n");
398 return TRUE;
399 }
400 // Give them the opportunity to place it in the same folder as the app
401- _getcwd(cwd, MAX_PATH);
402- strcat_s(cwd, MAX_PATH, "\\PPTVIEW.EXE");
403- if(_access(cwd, 0) != -1)
404+ _wgetcwd(cwd, MAX_PATH);
405+ wcscat_s(cwd, MAX_PATH, L"\\PPTVIEW.EXE");
406+ if(_waccess(cwd, 0) != -1)
407 {
408- strcpy_s(pptViewerPath, stringSize, cwd);
409- DEBUG("GetPPTViewerPath: exit local\n");
410+ wcscpy_s(pptViewerPath, stringSize, cwd);
411+ DEBUG(L"GetPPTViewerPath: exit local\n");
412 return TRUE;
413 }
414- DEBUG("GetPPTViewerPath: exit fail\n");
415+ DEBUG(L"GetPPTViewerPath: exit fail\n");
416 return FALSE;
417 }
418-BOOL GetPPTViewerPathFromReg(char *pptViewerPath, int stringSize)
419+BOOL GetPPTViewerPathFromReg(wchar_t *pptViewerPath, int stringSize)
420 {
421 HKEY hKey;
422 DWORD dwType, dwSize;
423@@ -411,17 +411,17 @@
424 // PPT Viewer 2003 (recent versions)
425 // PPT Viewer 2003 (older versions)
426 // PPT Viewer 97
427- if ((RegOpenKeyEx(HKEY_CLASSES_ROOT,
428- "PowerPointViewer.Show.12\\shell\\Show\\command", 0, KEY_READ, &hKey)
429- != ERROR_SUCCESS)
430- && (RegOpenKeyEx(HKEY_CLASSES_ROOT,
431- "PowerPointViewer.Show.11\\shell\\Show\\command", 0, KEY_READ, &hKey)
432- != ERROR_SUCCESS)
433- && (RegOpenKeyEx(HKEY_CLASSES_ROOT,
434- "Applications\\PPTVIEW.EXE\\shell\\open\\command", 0, KEY_READ, &hKey)
435- != ERROR_SUCCESS)
436- && (RegOpenKeyEx(HKEY_CLASSES_ROOT,
437- "Applications\\PPTVIEW.EXE\\shell\\Show\\command", 0, KEY_READ, &hKey)
438+ if ((RegOpenKeyExW(HKEY_CLASSES_ROOT,
439+ L"PowerPointViewer.Show.12\\shell\\Show\\command", 0, KEY_READ, &hKey)
440+ != ERROR_SUCCESS)
441+ && (RegOpenKeyExW(HKEY_CLASSES_ROOT,
442+ L"PowerPointViewer.Show.11\\shell\\Show\\command", 0, KEY_READ, &hKey)
443+ != ERROR_SUCCESS)
444+ && (RegOpenKeyExW(HKEY_CLASSES_ROOT,
445+ L"Applications\\PPTVIEW.EXE\\shell\\open\\command", 0, KEY_READ, &hKey)
446+ != ERROR_SUCCESS)
447+ && (RegOpenKeyExW(HKEY_CLASSES_ROOT,
448+ L"Applications\\PPTVIEW.EXE\\shell\\Show\\command", 0, KEY_READ, &hKey)
449 != ERROR_SUCCESS))
450 {
451 return FALSE;
452@@ -436,14 +436,14 @@
453 return FALSE;
454 }
455 // remove "%1" from end of key value
456- pptViewerPath[strlen(pptViewerPath) - 4] = '\0';
457+ pptViewerPath[wcslen(pptViewerPath) - 4] = '\0';
458 return TRUE;
459 }
460
461 // Unhook the Windows hook
462 void Unhook(int id)
463 {
464- DEBUG("Unhook: start %d\n", id);
465+ DEBUG(L"Unhook: start %d\n", id);
466 if (pptView[id].hook != NULL)
467 {
468 UnhookWindowsHookEx(pptView[id].hook);
469@@ -454,13 +454,13 @@
470 }
471 pptView[id].hook = NULL;
472 pptView[id].msgHook = NULL;
473- DEBUG("Unhook: exit ok\n");
474+ DEBUG(L"Unhook: exit ok\n");
475 }
476
477 // Close the PowerPoint viewer, release resources
478 DllExport void ClosePPT(int id)
479 {
480- DEBUG("ClosePPT: start%d\n", id);
481+ DEBUG(L"ClosePPT: start%d\n", id);
482 pptView[id].state = PPT_CLOSED;
483 Unhook(id);
484 if (pptView[id].hWnd == 0)
485@@ -474,13 +474,13 @@
486 CloseHandle(pptView[id].hThread);
487 CloseHandle(pptView[id].hProcess);
488 memset(&pptView[id], 0, sizeof(PPTVIEW));
489- DEBUG("ClosePPT: exit ok\n");
490+ DEBUG(L"ClosePPT: exit ok\n");
491 return;
492 }
493 // Moves the show back onto the display
494 DllExport void Resume(int id)
495 {
496- DEBUG("Resume: %d\n", id);
497+ DEBUG(L"Resume: %d\n", id);
498 MoveWindow(pptView[id].hWnd, pptView[id].rect.left,
499 pptView[id].rect.top,
500 pptView[id].rect.right - pptView[id].rect.left,
501@@ -490,7 +490,7 @@
502 // Moves the show off the screen so it can't be seen
503 DllExport void Stop(int id)
504 {
505- DEBUG("Stop:%d\n", id);
506+ DEBUG(L"Stop:%d\n", id);
507 MoveWindow(pptView[id].hWnd, -32000, -32000,
508 pptView[id].rect.right - pptView[id].rect.left,
509 pptView[id].rect.bottom - pptView[id].rect.top, TRUE);
510@@ -499,7 +499,7 @@
511 // Return the total number of slides
512 DllExport int GetSlideCount(int id)
513 {
514- DEBUG("GetSlideCount:%d\n", id);
515+ DEBUG(L"GetSlideCount:%d\n", id);
516 if (pptView[id].state == 0)
517 {
518 return -1;
519@@ -513,7 +513,7 @@
520 // Return the number of the slide currently viewing
521 DllExport int GetCurrentSlide(int id)
522 {
523- DEBUG("GetCurrentSlide:%d\n", id);
524+ DEBUG(L"GetCurrentSlide:%d\n", id);
525 if (pptView[id].state == 0)
526 {
527 return -1;
528@@ -527,7 +527,7 @@
529 // Take a step forwards through the show
530 DllExport void NextStep(int id)
531 {
532- DEBUG("NextStep:%d (%d)\n", id, pptView[id].currentSlide);
533+ DEBUG(L"NextStep:%d (%d)\n", id, pptView[id].currentSlide);
534 if (pptView[id].currentSlide > pptView[id].slideCount) return;
535 if (pptView[id].currentSlide < pptView[id].slideCount)
536 {
537@@ -540,7 +540,7 @@
538 // Take a step backwards through the show
539 DllExport void PrevStep(int id)
540 {
541- DEBUG("PrevStep:%d (%d)\n", id, pptView[id].currentSlide);
542+ DEBUG(L"PrevStep:%d (%d)\n", id, pptView[id].currentSlide);
543 if (pptView[id].currentSlide > 1)
544 {
545 pptView[id].guess = pptView[id].currentSlide - 1;
546@@ -556,7 +556,7 @@
547 // So send random unmapped letter first (say 'A'), then we can
548 // better guarantee B will blank instead of trying to guess
549 // whether it was already blank or not.
550- DEBUG("Blank:%d\n", id);
551+ DEBUG(L"Blank:%d\n", id);
552 HWND h1 = GetForegroundWindow();
553 HWND h2 = GetFocus();
554 SetForegroundWindow(pptView[id].hWnd);
555@@ -573,7 +573,7 @@
556 // Unblank the show
557 DllExport void Unblank(int id)
558 {
559- DEBUG("Unblank:%d\n", id);
560+ DEBUG(L"Unblank:%d\n", id);
561 // Pressing any key resumes.
562 // For some reason SendMessage works for unblanking, but not blanking.
563 SendMessage(pptView[id].hWnd2, WM_CHAR, 'A', 0);
564@@ -582,7 +582,7 @@
565 // Go directly to a slide
566 DllExport void GotoSlide(int id, int slideNo)
567 {
568- DEBUG("GotoSlide %i %i:\n", id, slideNo);
569+ DEBUG(L"GotoSlide %i %i:\n", id, slideNo);
570 // Did try WM_KEYDOWN/WM_CHAR/WM_KEYUP with SendMessage but didn't work
571 // perhaps I was sending to the wrong window? No idea.
572 // Anyway fall back to keybd_event, which is OK as long we makesure
573@@ -619,7 +619,7 @@
574 // Only way I've found to get around this is to step backwards all the way
575 // through. Lets move the window out of the way first so the audience
576 // doesn't see this.
577- DEBUG("RestartShow:%d\n", id);
578+ DEBUG(L"RestartShow:%d\n", id);
579 Stop(id);
580 GotoSlide(id, pptView[id].slideCount);
581 for (int i=0; i <= pptView[id].steps - pptView[id].lastSlideSteps; i++)
582@@ -644,12 +644,12 @@
583 HHOOK hook = globalHook;
584 if (nCode == HCBT_CREATEWND)
585 {
586- char csClassName[16];
587+ wchar_t csClassName[32];
588 HWND hCurrWnd = (HWND)wParam;
589 DWORD retProcId = NULL;
590 GetClassName(hCurrWnd, csClassName, sizeof(csClassName));
591- if ((strcmp(csClassName, "paneClassDC") == 0)
592- ||(strcmp(csClassName, "screenClass") == 0))
593+ if ((wcscmp(csClassName, L"paneClassDC") == 0)
594+ ||(wcscmp(csClassName, L"screenClass") == 0))
595 {
596 int id = -1;
597 DWORD windowThread = GetWindowThreadProcessId(hCurrWnd, NULL);
598@@ -663,7 +663,7 @@
599 }
600 if (id >= 0)
601 {
602- if (strcmp(csClassName, "paneClassDC") == 0)
603+ if (wcscmp(csClassName, L"paneClassDC") == 0)
604 {
605 pptView[id].hWnd2 = hCurrWnd;
606 }
607@@ -737,7 +737,7 @@
608 CWPSTRUCT *cwp;
609 cwp = (CWPSTRUCT *)lParam;
610 HHOOK hook = NULL;
611- char filename[MAX_PATH];
612+ wchar_t filename[MAX_PATH];
613
614 DWORD windowThread = GetWindowThreadProcessId(cwp->hwnd, NULL);
615 int id = -1;
616@@ -758,9 +758,9 @@
617 {
618 if ((pptView[id].currentSlide > 0)
619 && (pptView[id].previewPath != NULL
620- && strlen(pptView[id].previewPath) > 0))
621+ && wcslen(pptView[id].previewPath) > 0))
622 {
623- sprintf_s(filename, MAX_PATH, "%s%i.bmp",
624+ swprintf_s(filename, MAX_PATH, L"%s%i.bmp",
625 pptView[id].previewPath,
626 pptView[id].currentSlide);
627 CaptureAndSaveWindow(cwp->hwnd, filename);
628@@ -820,7 +820,7 @@
629 return CallNextHookEx(hook, nCode, wParam, lParam);
630 }
631
632-VOID CaptureAndSaveWindow(HWND hWnd, CHAR* filename)
633+VOID CaptureAndSaveWindow(HWND hWnd, wchar_t* filename)
634 {
635 HBITMAP hBmp;
636 if ((hBmp = CaptureWindow(hWnd)) == NULL)
637@@ -863,7 +863,7 @@
638
639 // Writing:
640 FILE* pFile;
641- int err = fopen_s(&pFile, filename, "wb");
642+ int err = _wfopen_s(&pFile, filename, L"wb");
643 if (err == 0)
644 {
645 fwrite(&bmf, sizeof(bmf), 1, pFile);
646@@ -893,7 +893,7 @@
647 if ((hMemDC = CreateCompatibleDC(hDC)) != NULL)
648 {
649 hDCBmp = (HBITMAP)SelectObject(hMemDC, hImage);
650- HMODULE hLib = LoadLibrary("User32");
651+ HMODULE hLib = LoadLibrary(L"User32");
652 // PrintWindow works for windows outside displayable area
653 // but was only introduced in WinXP. BitBlt requires the window to
654 // be topmost and within the viewable area of the display
655
656=== modified file 'openlp/plugins/presentations/lib/pptviewlib/pptviewlib.h'
657--- openlp/plugins/presentations/lib/pptviewlib/pptviewlib.h 2012-12-30 19:41:24 +0000
658+++ openlp/plugins/presentations/lib/pptviewlib/pptviewlib.h 2013-10-22 19:57:11 +0000
659@@ -26,13 +26,13 @@
660
661 #define DllExport extern "C" __declspec( dllexport )
662
663-#define DEBUG(...) if (debug) printf(__VA_ARGS__)
664+#define DEBUG(...) if (debug) wprintf(__VA_ARGS__)
665
666 enum PPTVIEWSTATE {PPT_CLOSED, PPT_STARTED, PPT_OPENED, PPT_LOADED,
667 PPT_CLOSING};
668
669-DllExport int OpenPPT(char *filename, HWND hParentWnd, RECT rect,
670- char *previewPath);
671+DllExport int OpenPPT(wchar_t *filename, HWND hParentWnd, RECT rect,
672+ wchar_t *previewPath);
673 DllExport BOOL CheckInstalled();
674 DllExport void ClosePPT(int id);
675 DllExport int GetCurrentSlide(int id);
676@@ -50,11 +50,11 @@
677 LRESULT CALLBACK CbtProc(int nCode, WPARAM wParam, LPARAM lParam);
678 LRESULT CALLBACK CwpProc(int nCode, WPARAM wParam, LPARAM lParam);
679 LRESULT CALLBACK GetMsgProc(int nCode, WPARAM wParam, LPARAM lParam);
680-BOOL GetPPTViewerPath(char *pptViewerPath, int stringSize);
681-BOOL GetPPTViewerPathFromReg(char *pptViewerPath, int stringSize);
682+BOOL GetPPTViewerPath(wchar_t *pptViewerPath, int stringSize);
683+BOOL GetPPTViewerPathFromReg(wchar_t *pptViewerPath, int stringSize);
684 HBITMAP CaptureWindow(HWND hWnd);
685-VOID SaveBitmap(CHAR* filename, HBITMAP hBmp) ;
686-VOID CaptureAndSaveWindow(HWND hWnd, CHAR* filename);
687+VOID SaveBitmap(wchar_t* filename, HBITMAP hBmp) ;
688+VOID CaptureAndSaveWindow(HWND hWnd, wchar_t* filename);
689 BOOL GetPPTInfo(int id);
690 BOOL SavePPTInfo(int id);
691 void Unhook(int id);
692@@ -80,8 +80,8 @@
693 int lastSlideSteps;
694 int steps;
695 int guess;
696- char filename[MAX_PATH];
697- char previewPath[MAX_PATH];
698+ wchar_t filename[MAX_PATH];
699+ wchar_t previewPath[MAX_PATH];
700 int slideNos[MAX_SLIDES];
701 PPTVIEWSTATE state;
702 };
703
704=== modified file 'openlp/plugins/presentations/lib/pptviewlib/pptviewlib.vcproj'
705--- openlp/plugins/presentations/lib/pptviewlib/pptviewlib.vcproj 2010-09-14 18:18:47 +0000
706+++ openlp/plugins/presentations/lib/pptviewlib/pptviewlib.vcproj 2013-10-22 19:57:11 +0000
707@@ -21,7 +21,7 @@
708 OutputDirectory="$(SolutionDir)$(ConfigurationName)"
709 IntermediateDirectory="$(ConfigurationName)"
710 ConfigurationType="2"
711- CharacterSet="2"
712+ CharacterSet="1"
713 >
714 <Tool
715 Name="VCPreBuildEventTool"
716@@ -93,7 +93,7 @@
717 OutputDirectory="$(SolutionDir)$(ConfigurationName)"
718 IntermediateDirectory="$(ConfigurationName)"
719 ConfigurationType="2"
720- CharacterSet="2"
721+ CharacterSet="1"
722 WholeProgramOptimization="1"
723 >
724 <Tool

Subscribers

People subscribed via source and target branches