| 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 193 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 278 pModule->Init(cfg ? cfg->m_pUserFontPaths : nullptr, g_pCodecModule); | 279 pModule->Init(cfg ? cfg->m_pUserFontPaths : nullptr, g_pCodecModule); |
| 279 CPDF_ModuleMgr* pModuleMgr = CPDF_ModuleMgr::Get(); | 280 CPDF_ModuleMgr* pModuleMgr = CPDF_ModuleMgr::Get(); |
| 280 pModuleMgr->SetCodecModule(g_pCodecModule); | 281 pModuleMgr->SetCodecModule(g_pCodecModule); |
| 281 pModuleMgr->InitPageModule(); | 282 pModuleMgr->InitPageModule(); |
| 282 pModuleMgr->LoadEmbeddedGB1CMaps(); | 283 pModuleMgr->LoadEmbeddedGB1CMaps(); |
| 283 pModuleMgr->LoadEmbeddedJapan1CMaps(); | 284 pModuleMgr->LoadEmbeddedJapan1CMaps(); |
| 284 pModuleMgr->LoadEmbeddedCNS1CMaps(); | 285 pModuleMgr->LoadEmbeddedCNS1CMaps(); |
| 285 pModuleMgr->LoadEmbeddedKorea1CMaps(); | 286 pModuleMgr->LoadEmbeddedKorea1CMaps(); |
| 286 | 287 |
| 287 #ifdef PDF_ENABLE_XFA | 288 #ifdef PDF_ENABLE_XFA |
| 288 CPDFXFA_App::GetInstance()->Initialize( | 289 FXJSE_Initialize(); |
| 289 (cfg && cfg->version >= 2) ? static_cast<v8::Isolate*>(cfg->m_pIsolate) | 290 BC_Library_Init(); |
| 290 : nullptr); | |
| 291 #endif // PDF_ENABLE_XFA | 291 #endif // PDF_ENABLE_XFA |
| 292 | |
| 293 if (cfg && cfg->version >= 2) | 292 if (cfg && cfg->version >= 2) |
| 294 IJS_Runtime::Initialize(cfg->m_v8EmbedderSlot, cfg->m_pIsolate); | 293 IJS_Runtime::Initialize(cfg->m_v8EmbedderSlot, cfg->m_pIsolate); |
| 295 } | 294 } |
| 296 | 295 |
| 297 DLLEXPORT void STDCALL FPDF_DestroyLibrary() { | 296 DLLEXPORT void STDCALL FPDF_DestroyLibrary() { |
| 298 #ifdef PDF_ENABLE_XFA | 297 #ifdef PDF_ENABLE_XFA |
| 299 CPDFXFA_App::ReleaseInstance(); | 298 BC_Library_Destory(); |
| 299 FXJSE_Finalize(); |
| 300 #endif // PDF_ENABLE_XFA | 300 #endif // PDF_ENABLE_XFA |
| 301 |
| 301 CPDF_ModuleMgr::Destroy(); | 302 CPDF_ModuleMgr::Destroy(); |
| 302 CFX_GEModule::Destroy(); | 303 CFX_GEModule::Destroy(); |
| 303 | 304 |
| 304 delete g_pCodecModule; | 305 delete g_pCodecModule; |
| 305 g_pCodecModule = nullptr; | 306 g_pCodecModule = nullptr; |
| 306 | 307 |
| 307 IJS_Runtime::Destroy(); | 308 IJS_Runtime::Destroy(); |
| 308 } | 309 } |
| 309 | 310 |
| 310 #ifndef _WIN32 | 311 #ifndef _WIN32 |
| (...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 370 pParser->SetPassword(password); | 371 pParser->SetPassword(password); |
| 371 | 372 |
| 372 std::unique_ptr<CPDF_Document> pDocument( | 373 std::unique_ptr<CPDF_Document> pDocument( |
| 373 new CPDF_Document(std::move(pParser))); | 374 new CPDF_Document(std::move(pParser))); |
| 374 CPDF_Parser::Error error = | 375 CPDF_Parser::Error error = |
| 375 pDocument->GetParser()->StartParse(pFileAccess, pDocument.get()); | 376 pDocument->GetParser()->StartParse(pFileAccess, pDocument.get()); |
| 376 if (error != CPDF_Parser::SUCCESS) { | 377 if (error != CPDF_Parser::SUCCESS) { |
| 377 ProcessParseError(error); | 378 ProcessParseError(error); |
| 378 return nullptr; | 379 return nullptr; |
| 379 } | 380 } |
| 380 #ifdef PDF_ENABLE_XFA | 381 return FPDFDocumentFromCPDFDocument(pDocument.release()); |
| 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 | |
| 385 } | 382 } |
| 386 | 383 |
| 387 #ifdef PDF_ENABLE_XFA | 384 #ifdef PDF_ENABLE_XFA |
| 388 DLLEXPORT FPDF_BOOL STDCALL FPDF_HasXFAField(FPDF_DOCUMENT document, | 385 DLLEXPORT FPDF_BOOL STDCALL FPDF_HasXFAField(FPDF_DOCUMENT document, |
| 389 int* docType) { | 386 int* docType) { |
| 390 if (!document) | 387 if (!document) |
| 391 return FALSE; | 388 return FALSE; |
| 392 | 389 |
| 393 CPDF_Document* pdfDoc = | 390 CPDF_Document* pdfDoc = |
| 394 (static_cast<CPDFXFA_Document*>(document))->GetPDFDoc(); | 391 (static_cast<CPDFXFA_Document*>(document))->GetPDFDoc(); |
| (...skipping 735 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1130 if (!buffer) { | 1127 if (!buffer) { |
| 1131 *buflen = len; | 1128 *buflen = len; |
| 1132 } else if (*buflen >= len) { | 1129 } else if (*buflen >= len) { |
| 1133 memcpy(buffer, utf16Name.c_str(), len); | 1130 memcpy(buffer, utf16Name.c_str(), len); |
| 1134 *buflen = len; | 1131 *buflen = len; |
| 1135 } else { | 1132 } else { |
| 1136 *buflen = -1; | 1133 *buflen = -1; |
| 1137 } | 1134 } |
| 1138 return (FPDF_DEST)pDestObj; | 1135 return (FPDF_DEST)pDestObj; |
| 1139 } | 1136 } |
| OLD | NEW |