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