OLD | NEW |
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include <limits.h> | 5 #include <limits.h> |
6 #include <stdio.h> | 6 #include <stdio.h> |
7 #include <stdlib.h> | 7 #include <stdlib.h> |
8 #include <string.h> | 8 #include <string.h> |
9 #include <wchar.h> | 9 #include <wchar.h> |
10 | 10 |
(...skipping 178 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
189 | 189 |
190 FPDF_RenderPage(dc, page, 0, 0, width, height, 0, | 190 FPDF_RenderPage(dc, page, 0, 0, width, height, 0, |
191 FPDF_ANNOT | FPDF_PRINTING | FPDF_NO_CATCH); | 191 FPDF_ANNOT | FPDF_PRINTING | FPDF_NO_CATCH); |
192 | 192 |
193 DeleteEnhMetaFile(CloseEnhMetaFile(dc)); | 193 DeleteEnhMetaFile(CloseEnhMetaFile(dc)); |
194 } | 194 } |
195 #endif | 195 #endif |
196 | 196 |
197 int ExampleAppAlert(IPDF_JSPLATFORM*, FPDF_WIDESTRING msg, FPDF_WIDESTRING, | 197 int ExampleAppAlert(IPDF_JSPLATFORM*, FPDF_WIDESTRING msg, FPDF_WIDESTRING, |
198 int, int) { | 198 int, int) { |
199 // Deal with differences between UTF16LE and wchar_t on this platform. | 199 std::wstring platform_string = GetWideString(msg); |
200 size_t characters = 0; | 200 printf("Alert: %ls\n", platform_string.c_str()); |
201 while (msg[characters]) { | |
202 ++characters; | |
203 } | |
204 wchar_t* platform_string = | |
205 static_cast<wchar_t*>(malloc((characters + 1) * sizeof(wchar_t))); | |
206 for (size_t i = 0; i < characters + 1; ++i) { | |
207 unsigned char* ptr = (unsigned char*)&msg[i]; | |
208 platform_string[i] = ptr[0] + 256 * ptr[1]; | |
209 } | |
210 printf("Alert: %ls\n", platform_string); | |
211 free(platform_string); | |
212 return 0; | 201 return 0; |
213 } | 202 } |
214 | 203 |
215 void ExampleDocGotoPage(IPDF_JSPLATFORM*, int pageNumber) { | 204 void ExampleDocGotoPage(IPDF_JSPLATFORM*, int pageNumber) { |
216 printf("Goto Page: %d\n", pageNumber); | 205 printf("Goto Page: %d\n", pageNumber); |
217 } | 206 } |
218 | 207 |
219 void ExampleUnsupportedHandler(UNSUPPORT_INFO*, int type) { | 208 void ExampleUnsupportedHandler(UNSUPPORT_INFO*, int type) { |
220 std::string feature = "Unknown"; | 209 std::string feature = "Unknown"; |
221 switch (type) { | 210 switch (type) { |
(...skipping 365 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
587 } | 576 } |
588 | 577 |
589 FPDF_DestroyLibrary(); | 578 FPDF_DestroyLibrary(); |
590 #ifdef PDF_ENABLE_V8 | 579 #ifdef PDF_ENABLE_V8 |
591 v8::V8::ShutdownPlatform(); | 580 v8::V8::ShutdownPlatform(); |
592 delete platform; | 581 delete platform; |
593 #endif // PDF_ENABLE_V8 | 582 #endif // PDF_ENABLE_V8 |
594 | 583 |
595 return 0; | 584 return 0; |
596 } | 585 } |
OLD | NEW |