Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(385)

Side by Side Diff: fpdfsdk/fpdfview.cpp

Issue 2414883006: Revert of Reland: Make the CPDFXFA_App non-global (Closed)
Patch Set: Created 4 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « fpdfsdk/fpdfsave.cpp ('k') | fpdfsdk/fpdfxfa/DEPS » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 PDFium Authors. All rights reserved. 1 // Copyright 2014 PDFium 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 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com 5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
6 6
7 #include "public/fpdfview.h" 7 #include "public/fpdfview.h"
8 8
9 #include <memory> 9 #include <memory>
10 #include <utility> 10 #include <utility>
(...skipping 24 matching lines...) Expand all
35 #include "public/fpdf_progressive.h" 35 #include "public/fpdf_progressive.h"
36 #include "third_party/base/numerics/safe_conversions_impl.h" 36 #include "third_party/base/numerics/safe_conversions_impl.h"
37 #include "third_party/base/ptr_util.h" 37 #include "third_party/base/ptr_util.h"
38 38
39 #ifdef PDF_ENABLE_XFA 39 #ifdef PDF_ENABLE_XFA
40 #include "fpdfsdk/fpdfxfa/cpdfxfa_app.h" 40 #include "fpdfsdk/fpdfxfa/cpdfxfa_app.h"
41 #include "fpdfsdk/fpdfxfa/cpdfxfa_document.h" 41 #include "fpdfsdk/fpdfxfa/cpdfxfa_document.h"
42 #include "fpdfsdk/fpdfxfa/cpdfxfa_page.h" 42 #include "fpdfsdk/fpdfxfa/cpdfxfa_page.h"
43 #include "fpdfsdk/fpdfxfa/cxfa_fwladaptertimermgr.h" 43 #include "fpdfsdk/fpdfxfa/cxfa_fwladaptertimermgr.h"
44 #include "public/fpdf_formfill.h" 44 #include "public/fpdf_formfill.h"
45 #include "xfa/fxbarcode/BC_Library.h"
46 #endif // PDF_ENABLE_XFA 45 #endif // PDF_ENABLE_XFA
47 46
48 #if _FXM_PLATFORM_ == _FXM_PLATFORM_WINDOWS_ 47 #if _FXM_PLATFORM_ == _FXM_PLATFORM_WINDOWS_
49 #include "core/fxge/cfx_windowsdevice.h" 48 #include "core/fxge/cfx_windowsdevice.h"
50 #endif 49 #endif
51 50
52 UnderlyingDocumentType* UnderlyingFromFPDFDocument(FPDF_DOCUMENT doc) { 51 UnderlyingDocumentType* UnderlyingFromFPDFDocument(FPDF_DOCUMENT doc) {
53 return static_cast<UnderlyingDocumentType*>(doc); 52 return static_cast<UnderlyingDocumentType*>(doc);
54 } 53 }
55 54
56 FPDF_DOCUMENT FPDFDocumentFromUnderlying(UnderlyingDocumentType* doc) { 55 FPDF_DOCUMENT FPDFDocumentFromUnderlying(UnderlyingDocumentType* doc) {
57 return static_cast<FPDF_DOCUMENT>(doc); 56 return static_cast<FPDF_DOCUMENT>(doc);
58 } 57 }
59 58
60 UnderlyingPageType* UnderlyingFromFPDFPage(FPDF_PAGE page) { 59 UnderlyingPageType* UnderlyingFromFPDFPage(FPDF_PAGE page) {
61 return static_cast<UnderlyingPageType*>(page); 60 return static_cast<UnderlyingPageType*>(page);
62 } 61 }
63 62
64 CPDF_Document* CPDFDocumentFromFPDFDocument(FPDF_DOCUMENT doc) { 63 CPDF_Document* CPDFDocumentFromFPDFDocument(FPDF_DOCUMENT doc) {
65 #ifdef PDF_ENABLE_XFA 64 #ifdef PDF_ENABLE_XFA
66 return doc ? UnderlyingFromFPDFDocument(doc)->GetPDFDoc() : nullptr; 65 return doc ? UnderlyingFromFPDFDocument(doc)->GetPDFDoc() : nullptr;
67 #else // PDF_ENABLE_XFA 66 #else // PDF_ENABLE_XFA
68 return UnderlyingFromFPDFDocument(doc); 67 return UnderlyingFromFPDFDocument(doc);
69 #endif // PDF_ENABLE_XFA 68 #endif // PDF_ENABLE_XFA
70 } 69 }
71 70
72 FPDF_DOCUMENT FPDFDocumentFromCPDFDocument(CPDF_Document* doc) { 71 FPDF_DOCUMENT FPDFDocumentFromCPDFDocument(CPDF_Document* doc) {
73 #ifdef PDF_ENABLE_XFA 72 #ifdef PDF_ENABLE_XFA
74 return doc ? FPDFDocumentFromUnderlying( 73 return doc ? FPDFDocumentFromUnderlying(new CPDFXFA_Document(
75 new CPDFXFA_Document(pdfium::WrapUnique(doc))) 74 pdfium::WrapUnique(doc), CPDFXFA_App::GetInstance()))
76 : nullptr; 75 : nullptr;
77 #else // PDF_ENABLE_XFA 76 #else // PDF_ENABLE_XFA
78 return FPDFDocumentFromUnderlying(doc); 77 return FPDFDocumentFromUnderlying(doc);
79 #endif // PDF_ENABLE_XFA 78 #endif // PDF_ENABLE_XFA
80 } 79 }
81 80
82 CPDF_Page* CPDFPageFromFPDFPage(FPDF_PAGE page) { 81 CPDF_Page* CPDFPageFromFPDFPage(FPDF_PAGE page) {
83 #ifdef PDF_ENABLE_XFA 82 #ifdef PDF_ENABLE_XFA
84 return page ? UnderlyingFromFPDFPage(page)->GetPDFPage() : nullptr; 83 return page ? UnderlyingFromFPDFPage(page)->GetPDFPage() : nullptr;
85 #else // PDF_ENABLE_XFA 84 #else // PDF_ENABLE_XFA
(...skipping 193 matching lines...) Expand 10 before | Expand all | Expand 10 after
279 pModule->Init(cfg ? cfg->m_pUserFontPaths : nullptr, g_pCodecModule); 278 pModule->Init(cfg ? cfg->m_pUserFontPaths : nullptr, g_pCodecModule);
280 CPDF_ModuleMgr* pModuleMgr = CPDF_ModuleMgr::Get(); 279 CPDF_ModuleMgr* pModuleMgr = CPDF_ModuleMgr::Get();
281 pModuleMgr->SetCodecModule(g_pCodecModule); 280 pModuleMgr->SetCodecModule(g_pCodecModule);
282 pModuleMgr->InitPageModule(); 281 pModuleMgr->InitPageModule();
283 pModuleMgr->LoadEmbeddedGB1CMaps(); 282 pModuleMgr->LoadEmbeddedGB1CMaps();
284 pModuleMgr->LoadEmbeddedJapan1CMaps(); 283 pModuleMgr->LoadEmbeddedJapan1CMaps();
285 pModuleMgr->LoadEmbeddedCNS1CMaps(); 284 pModuleMgr->LoadEmbeddedCNS1CMaps();
286 pModuleMgr->LoadEmbeddedKorea1CMaps(); 285 pModuleMgr->LoadEmbeddedKorea1CMaps();
287 286
288 #ifdef PDF_ENABLE_XFA 287 #ifdef PDF_ENABLE_XFA
289 FXJSE_Initialize(); 288 CPDFXFA_App::GetInstance()->Initialize(
290 BC_Library_Init(); 289 (cfg && cfg->version >= 2) ? static_cast<v8::Isolate*>(cfg->m_pIsolate)
290 : nullptr);
291 #endif // PDF_ENABLE_XFA 291 #endif // PDF_ENABLE_XFA
292
292 if (cfg && cfg->version >= 2) 293 if (cfg && cfg->version >= 2)
293 IJS_Runtime::Initialize(cfg->m_v8EmbedderSlot, cfg->m_pIsolate); 294 IJS_Runtime::Initialize(cfg->m_v8EmbedderSlot, cfg->m_pIsolate);
294 } 295 }
295 296
296 DLLEXPORT void STDCALL FPDF_DestroyLibrary() { 297 DLLEXPORT void STDCALL FPDF_DestroyLibrary() {
297 #ifdef PDF_ENABLE_XFA 298 #ifdef PDF_ENABLE_XFA
298 BC_Library_Destory(); 299 CPDFXFA_App::ReleaseInstance();
299 FXJSE_Finalize();
300 #endif // PDF_ENABLE_XFA 300 #endif // PDF_ENABLE_XFA
301
302 CPDF_ModuleMgr::Destroy(); 301 CPDF_ModuleMgr::Destroy();
303 CFX_GEModule::Destroy(); 302 CFX_GEModule::Destroy();
304 303
305 delete g_pCodecModule; 304 delete g_pCodecModule;
306 g_pCodecModule = nullptr; 305 g_pCodecModule = nullptr;
307 306
308 IJS_Runtime::Destroy(); 307 IJS_Runtime::Destroy();
309 } 308 }
310 309
311 #ifndef _WIN32 310 #ifndef _WIN32
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
371 pParser->SetPassword(password); 370 pParser->SetPassword(password);
372 371
373 std::unique_ptr<CPDF_Document> pDocument( 372 std::unique_ptr<CPDF_Document> pDocument(
374 new CPDF_Document(std::move(pParser))); 373 new CPDF_Document(std::move(pParser)));
375 CPDF_Parser::Error error = 374 CPDF_Parser::Error error =
376 pDocument->GetParser()->StartParse(pFileAccess, pDocument.get()); 375 pDocument->GetParser()->StartParse(pFileAccess, pDocument.get());
377 if (error != CPDF_Parser::SUCCESS) { 376 if (error != CPDF_Parser::SUCCESS) {
378 ProcessParseError(error); 377 ProcessParseError(error);
379 return nullptr; 378 return nullptr;
380 } 379 }
381 return FPDFDocumentFromCPDFDocument(pDocument.release()); 380 #ifdef PDF_ENABLE_XFA
381 return new CPDFXFA_Document(std::move(pDocument), CPDFXFA_App::GetInstance());
382 #else // PDF_ENABLE_XFA
383 return pDocument.release();
384 #endif // PDF_ENABLE_XFA
382 } 385 }
383 386
384 #ifdef PDF_ENABLE_XFA 387 #ifdef PDF_ENABLE_XFA
385 DLLEXPORT FPDF_BOOL STDCALL FPDF_HasXFAField(FPDF_DOCUMENT document, 388 DLLEXPORT FPDF_BOOL STDCALL FPDF_HasXFAField(FPDF_DOCUMENT document,
386 int* docType) { 389 int* docType) {
387 if (!document) 390 if (!document)
388 return FALSE; 391 return FALSE;
389 392
390 CPDF_Document* pdfDoc = 393 CPDF_Document* pdfDoc =
391 (static_cast<CPDFXFA_Document*>(document))->GetPDFDoc(); 394 (static_cast<CPDFXFA_Document*>(document))->GetPDFDoc();
(...skipping 735 matching lines...) Expand 10 before | Expand all | Expand 10 after
1127 if (!buffer) { 1130 if (!buffer) {
1128 *buflen = len; 1131 *buflen = len;
1129 } else if (*buflen >= len) { 1132 } else if (*buflen >= len) {
1130 memcpy(buffer, utf16Name.c_str(), len); 1133 memcpy(buffer, utf16Name.c_str(), len);
1131 *buflen = len; 1134 *buflen = len;
1132 } else { 1135 } else {
1133 *buflen = -1; 1136 *buflen = -1;
1134 } 1137 }
1135 return (FPDF_DEST)pDestObj; 1138 return (FPDF_DEST)pDestObj;
1136 } 1139 }
OLDNEW
« no previous file with comments | « fpdfsdk/fpdfsave.cpp ('k') | fpdfsdk/fpdfxfa/DEPS » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698