| 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 | 9 | 
| 10 #include <list> | 10 #include <list> | 
| (...skipping 177 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 188   // If a PS_NULL pen is used, the dimensions of the rectangle are 1 pixel less. | 188   // If a PS_NULL pen is used, the dimensions of the rectangle are 1 pixel less. | 
| 189   Rectangle(dc, 0, 0, width + 1, height + 1); | 189   Rectangle(dc, 0, 0, width + 1, height + 1); | 
| 190 | 190 | 
| 191   FPDF_RenderPage(dc, page, 0, 0, width, height, 0, | 191   FPDF_RenderPage(dc, page, 0, 0, width, height, 0, | 
| 192                   FPDF_ANNOT | FPDF_PRINTING | FPDF_NO_CATCH); | 192                   FPDF_ANNOT | FPDF_PRINTING | FPDF_NO_CATCH); | 
| 193 | 193 | 
| 194   DeleteEnhMetaFile(CloseEnhMetaFile(dc)); | 194   DeleteEnhMetaFile(CloseEnhMetaFile(dc)); | 
| 195 } | 195 } | 
| 196 #endif | 196 #endif | 
| 197 | 197 | 
|  | 198 // These example JS platform callback handlers are entirely optional, | 
|  | 199 // and exist here to show the flow of information from a document back | 
|  | 200 // to the embedder. | 
| 198 int ExampleAppAlert(IPDF_JSPLATFORM*, | 201 int ExampleAppAlert(IPDF_JSPLATFORM*, | 
| 199                     FPDF_WIDESTRING msg, | 202                     FPDF_WIDESTRING msg, | 
| 200                     FPDF_WIDESTRING title, | 203                     FPDF_WIDESTRING title, | 
| 201                     int nType, | 204                     int nType, | 
| 202                     int nIcon) { | 205                     int nIcon) { | 
| 203   printf("%ls", GetPlatformWString(title).c_str()); | 206   printf("%ls", GetPlatformWString(title).c_str()); | 
| 204   if (nIcon || nType) | 207   if (nIcon || nType) | 
| 205     printf("[icon=%d,type=%d]", nIcon, nType); | 208     printf("[icon=%d,type=%d]", nIcon, nType); | 
| 206   printf(": %ls\n", GetPlatformWString(msg).c_str()); | 209   printf(": %ls\n", GetPlatformWString(msg).c_str()); | 
| 207   return 0; | 210   return 0; | 
| 208 } | 211 } | 
| 209 | 212 | 
|  | 213 int ExampleAppResponse(IPDF_JSPLATFORM*, | 
|  | 214                        FPDF_WIDESTRING question, | 
|  | 215                        FPDF_WIDESTRING title, | 
|  | 216                        FPDF_WIDESTRING defaultValue, | 
|  | 217                        FPDF_WIDESTRING label, | 
|  | 218                        FPDF_BOOL isPassword, | 
|  | 219                        void* response, | 
|  | 220                        int length) { | 
|  | 221   printf("%ls: %ls, defaultValue=%ls, label=%ls, isPassword=%d, length=%d\n", | 
|  | 222          GetPlatformWString(title).c_str(), | 
|  | 223          GetPlatformWString(question).c_str(), | 
|  | 224          GetPlatformWString(defaultValue).c_str(), | 
|  | 225          GetPlatformWString(label).c_str(), isPassword, length); | 
|  | 226 | 
|  | 227   // UTF-16, always LE regardless of platform. | 
|  | 228   uint8_t* ptr = static_cast<uint8_t*>(response); | 
|  | 229   ptr[0] = 'N'; | 
|  | 230   ptr[1] = 0; | 
|  | 231   ptr[2] = 'o'; | 
|  | 232   ptr[3] = 0; | 
|  | 233   return 4; | 
|  | 234 } | 
|  | 235 | 
| 210 void ExampleDocGotoPage(IPDF_JSPLATFORM*, int pageNumber) { | 236 void ExampleDocGotoPage(IPDF_JSPLATFORM*, int pageNumber) { | 
| 211   printf("Goto Page: %d\n", pageNumber); | 237   printf("Goto Page: %d\n", pageNumber); | 
| 212 } | 238 } | 
| 213 | 239 | 
| 214 void ExampleDocMail(IPDF_JSPLATFORM*, | 240 void ExampleDocMail(IPDF_JSPLATFORM*, | 
| 215                     void* mailData, | 241                     void* mailData, | 
| 216                     int length, | 242                     int length, | 
| 217                     FPDF_BOOL bUI, | 243                     FPDF_BOOL bUI, | 
| 218                     FPDF_WIDESTRING To, | 244                     FPDF_WIDESTRING To, | 
| 219                     FPDF_WIDESTRING Subject, | 245                     FPDF_WIDESTRING Subject, | 
| (...skipping 198 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 418 } | 444 } | 
| 419 | 445 | 
| 420 void RenderPdf(const std::string& name, const char* pBuf, size_t len, | 446 void RenderPdf(const std::string& name, const char* pBuf, size_t len, | 
| 421                const Options& options) { | 447                const Options& options) { | 
| 422   fprintf(stderr, "Rendering PDF file %s.\n", name.c_str()); | 448   fprintf(stderr, "Rendering PDF file %s.\n", name.c_str()); | 
| 423 | 449 | 
| 424   IPDF_JSPLATFORM platform_callbacks; | 450   IPDF_JSPLATFORM platform_callbacks; | 
| 425   memset(&platform_callbacks, '\0', sizeof(platform_callbacks)); | 451   memset(&platform_callbacks, '\0', sizeof(platform_callbacks)); | 
| 426   platform_callbacks.version = 3; | 452   platform_callbacks.version = 3; | 
| 427   platform_callbacks.app_alert = ExampleAppAlert; | 453   platform_callbacks.app_alert = ExampleAppAlert; | 
|  | 454   platform_callbacks.app_response = ExampleAppResponse; | 
| 428   platform_callbacks.Doc_gotoPage = ExampleDocGotoPage; | 455   platform_callbacks.Doc_gotoPage = ExampleDocGotoPage; | 
| 429   platform_callbacks.Doc_mail = ExampleDocMail; | 456   platform_callbacks.Doc_mail = ExampleDocMail; | 
| 430 | 457 | 
| 431   FPDF_FORMFILLINFO form_callbacks; | 458   FPDF_FORMFILLINFO form_callbacks; | 
| 432   memset(&form_callbacks, '\0', sizeof(form_callbacks)); | 459   memset(&form_callbacks, '\0', sizeof(form_callbacks)); | 
| 433   form_callbacks.version = 1; | 460   form_callbacks.version = 1; | 
| 434   form_callbacks.m_pJsPlatform = &platform_callbacks; | 461   form_callbacks.m_pJsPlatform = &platform_callbacks; | 
| 435 | 462 | 
| 436   TestLoader loader(pBuf, len); | 463   TestLoader loader(pBuf, len); | 
| 437   FPDF_FILEACCESS file_access; | 464   FPDF_FILEACCESS file_access; | 
| (...skipping 208 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 646   } | 673   } | 
| 647 | 674 | 
| 648   FPDF_DestroyLibrary(); | 675   FPDF_DestroyLibrary(); | 
| 649 #ifdef PDF_ENABLE_V8 | 676 #ifdef PDF_ENABLE_V8 | 
| 650   v8::V8::ShutdownPlatform(); | 677   v8::V8::ShutdownPlatform(); | 
| 651   delete platform; | 678   delete platform; | 
| 652 #endif  // PDF_ENABLE_V8 | 679 #endif  // PDF_ENABLE_V8 | 
| 653 | 680 | 
| 654   return 0; | 681   return 0; | 
| 655 } | 682 } | 
| OLD | NEW | 
|---|