OLD | NEW |
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 Loading... |
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" |
45 #endif // PDF_ENABLE_XFA | 46 #endif // PDF_ENABLE_XFA |
46 | 47 |
47 #if _FXM_PLATFORM_ == _FXM_PLATFORM_WINDOWS_ | 48 #if _FXM_PLATFORM_ == _FXM_PLATFORM_WINDOWS_ |
48 #include "core/fxge/cfx_windowsdevice.h" | 49 #include "core/fxge/cfx_windowsdevice.h" |
49 #endif | 50 #endif |
50 | 51 |
51 UnderlyingDocumentType* UnderlyingFromFPDFDocument(FPDF_DOCUMENT doc) { | 52 UnderlyingDocumentType* UnderlyingFromFPDFDocument(FPDF_DOCUMENT doc) { |
52 return static_cast<UnderlyingDocumentType*>(doc); | 53 return static_cast<UnderlyingDocumentType*>(doc); |
53 } | 54 } |
54 | 55 |
55 FPDF_DOCUMENT FPDFDocumentFromUnderlying(UnderlyingDocumentType* doc) { | 56 FPDF_DOCUMENT FPDFDocumentFromUnderlying(UnderlyingDocumentType* doc) { |
56 return static_cast<FPDF_DOCUMENT>(doc); | 57 return static_cast<FPDF_DOCUMENT>(doc); |
57 } | 58 } |
58 | 59 |
59 UnderlyingPageType* UnderlyingFromFPDFPage(FPDF_PAGE page) { | 60 UnderlyingPageType* UnderlyingFromFPDFPage(FPDF_PAGE page) { |
60 return static_cast<UnderlyingPageType*>(page); | 61 return static_cast<UnderlyingPageType*>(page); |
61 } | 62 } |
62 | 63 |
63 CPDF_Document* CPDFDocumentFromFPDFDocument(FPDF_DOCUMENT doc) { | 64 CPDF_Document* CPDFDocumentFromFPDFDocument(FPDF_DOCUMENT doc) { |
64 #ifdef PDF_ENABLE_XFA | 65 #ifdef PDF_ENABLE_XFA |
65 return doc ? UnderlyingFromFPDFDocument(doc)->GetPDFDoc() : nullptr; | 66 return doc ? UnderlyingFromFPDFDocument(doc)->GetPDFDoc() : nullptr; |
66 #else // PDF_ENABLE_XFA | 67 #else // PDF_ENABLE_XFA |
67 return UnderlyingFromFPDFDocument(doc); | 68 return UnderlyingFromFPDFDocument(doc); |
68 #endif // PDF_ENABLE_XFA | 69 #endif // PDF_ENABLE_XFA |
69 } | 70 } |
70 | 71 |
71 FPDF_DOCUMENT FPDFDocumentFromCPDFDocument(CPDF_Document* doc) { | 72 FPDF_DOCUMENT FPDFDocumentFromCPDFDocument(CPDF_Document* doc) { |
72 #ifdef PDF_ENABLE_XFA | 73 #ifdef PDF_ENABLE_XFA |
73 return doc ? FPDFDocumentFromUnderlying(new CPDFXFA_Document( | 74 return doc ? FPDFDocumentFromUnderlying( |
74 pdfium::WrapUnique(doc), CPDFXFA_App::GetInstance())) | 75 new CPDFXFA_Document(pdfium::WrapUnique(doc))) |
75 : nullptr; | 76 : nullptr; |
76 #else // PDF_ENABLE_XFA | 77 #else // PDF_ENABLE_XFA |
77 return FPDFDocumentFromUnderlying(doc); | 78 return FPDFDocumentFromUnderlying(doc); |
78 #endif // PDF_ENABLE_XFA | 79 #endif // PDF_ENABLE_XFA |
79 } | 80 } |
80 | 81 |
81 CPDF_Page* CPDFPageFromFPDFPage(FPDF_PAGE page) { | 82 CPDF_Page* CPDFPageFromFPDFPage(FPDF_PAGE page) { |
82 #ifdef PDF_ENABLE_XFA | 83 #ifdef PDF_ENABLE_XFA |
83 return page ? UnderlyingFromFPDFPage(page)->GetPDFPage() : nullptr; | 84 return page ? UnderlyingFromFPDFPage(page)->GetPDFPage() : nullptr; |
84 #else // PDF_ENABLE_XFA | 85 #else // PDF_ENABLE_XFA |
(...skipping 157 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
242 pModule->Init(cfg ? cfg->m_pUserFontPaths : nullptr, g_pCodecModule); | 243 pModule->Init(cfg ? cfg->m_pUserFontPaths : nullptr, g_pCodecModule); |
243 CPDF_ModuleMgr* pModuleMgr = CPDF_ModuleMgr::Get(); | 244 CPDF_ModuleMgr* pModuleMgr = CPDF_ModuleMgr::Get(); |
244 pModuleMgr->SetCodecModule(g_pCodecModule); | 245 pModuleMgr->SetCodecModule(g_pCodecModule); |
245 pModuleMgr->InitPageModule(); | 246 pModuleMgr->InitPageModule(); |
246 pModuleMgr->LoadEmbeddedGB1CMaps(); | 247 pModuleMgr->LoadEmbeddedGB1CMaps(); |
247 pModuleMgr->LoadEmbeddedJapan1CMaps(); | 248 pModuleMgr->LoadEmbeddedJapan1CMaps(); |
248 pModuleMgr->LoadEmbeddedCNS1CMaps(); | 249 pModuleMgr->LoadEmbeddedCNS1CMaps(); |
249 pModuleMgr->LoadEmbeddedKorea1CMaps(); | 250 pModuleMgr->LoadEmbeddedKorea1CMaps(); |
250 | 251 |
251 #ifdef PDF_ENABLE_XFA | 252 #ifdef PDF_ENABLE_XFA |
252 CPDFXFA_App::GetInstance()->Initialize( | 253 FXJSE_Initialize(); |
253 (cfg && cfg->version >= 2) ? static_cast<v8::Isolate*>(cfg->m_pIsolate) | 254 BC_Library_Init(); |
254 : nullptr); | |
255 #endif // PDF_ENABLE_XFA | 255 #endif // PDF_ENABLE_XFA |
256 | |
257 if (cfg && cfg->version >= 2) | 256 if (cfg && cfg->version >= 2) |
258 IJS_Runtime::Initialize(cfg->m_v8EmbedderSlot, cfg->m_pIsolate); | 257 IJS_Runtime::Initialize(cfg->m_v8EmbedderSlot, cfg->m_pIsolate); |
259 } | 258 } |
260 | 259 |
261 DLLEXPORT void STDCALL FPDF_DestroyLibrary() { | 260 DLLEXPORT void STDCALL FPDF_DestroyLibrary() { |
262 #ifdef PDF_ENABLE_XFA | 261 #ifdef PDF_ENABLE_XFA |
263 CPDFXFA_App::ReleaseInstance(); | 262 BC_Library_Destory(); |
| 263 FXJSE_Finalize(); |
264 #endif // PDF_ENABLE_XFA | 264 #endif // PDF_ENABLE_XFA |
| 265 |
265 CPDF_ModuleMgr::Destroy(); | 266 CPDF_ModuleMgr::Destroy(); |
266 CFX_GEModule::Destroy(); | 267 CFX_GEModule::Destroy(); |
267 | 268 |
268 delete g_pCodecModule; | 269 delete g_pCodecModule; |
269 g_pCodecModule = nullptr; | 270 g_pCodecModule = nullptr; |
270 | 271 |
271 IJS_Runtime::Destroy(); | 272 IJS_Runtime::Destroy(); |
272 } | 273 } |
273 | 274 |
274 #ifndef _WIN32 | 275 #ifndef _WIN32 |
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
335 pParser->SetPassword(password); | 336 pParser->SetPassword(password); |
336 | 337 |
337 std::unique_ptr<CPDF_Document> pDocument( | 338 std::unique_ptr<CPDF_Document> pDocument( |
338 new CPDF_Document(std::move(pParser))); | 339 new CPDF_Document(std::move(pParser))); |
339 CPDF_Parser::Error error = | 340 CPDF_Parser::Error error = |
340 pDocument->GetParser()->StartParse(pFileAccess, pDocument.get()); | 341 pDocument->GetParser()->StartParse(pFileAccess, pDocument.get()); |
341 if (error != CPDF_Parser::SUCCESS) { | 342 if (error != CPDF_Parser::SUCCESS) { |
342 ProcessParseError(error); | 343 ProcessParseError(error); |
343 return nullptr; | 344 return nullptr; |
344 } | 345 } |
345 #ifdef PDF_ENABLE_XFA | 346 return FPDFDocumentFromCPDFDocument(pDocument.release()); |
346 return new CPDFXFA_Document(std::move(pDocument), CPDFXFA_App::GetInstance()); | |
347 #else // PDF_ENABLE_XFA | |
348 return pDocument.release(); | |
349 #endif // PDF_ENABLE_XFA | |
350 } | 347 } |
351 | 348 |
352 #ifdef PDF_ENABLE_XFA | 349 #ifdef PDF_ENABLE_XFA |
353 DLLEXPORT FPDF_BOOL STDCALL FPDF_HasXFAField(FPDF_DOCUMENT document, | 350 DLLEXPORT FPDF_BOOL STDCALL FPDF_HasXFAField(FPDF_DOCUMENT document, |
354 int* docType) { | 351 int* docType) { |
355 if (!document) | 352 if (!document) |
356 return FALSE; | 353 return FALSE; |
357 | 354 |
358 CPDF_Document* pdfDoc = | 355 CPDF_Document* pdfDoc = |
359 (static_cast<CPDFXFA_Document*>(document))->GetPDFDoc(); | 356 (static_cast<CPDFXFA_Document*>(document))->GetPDFDoc(); |
(...skipping 735 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1095 if (!buffer) { | 1092 if (!buffer) { |
1096 *buflen = len; | 1093 *buflen = len; |
1097 } else if (*buflen >= len) { | 1094 } else if (*buflen >= len) { |
1098 memcpy(buffer, utf16Name.c_str(), len); | 1095 memcpy(buffer, utf16Name.c_str(), len); |
1099 *buflen = len; | 1096 *buflen = len; |
1100 } else { | 1097 } else { |
1101 *buflen = -1; | 1098 *buflen = -1; |
1102 } | 1099 } |
1103 return (FPDF_DEST)pDestObj; | 1100 return (FPDF_DEST)pDestObj; |
1104 } | 1101 } |
OLD | NEW |