| 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 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 43 #include "public/fpdf_formfill.h" | 43 #include "public/fpdf_formfill.h" |
| 44 #include "xfa/fxbarcode/BC_Library.h" | 44 #include "xfa/fxbarcode/BC_Library.h" |
| 45 #endif // PDF_ENABLE_XFA | 45 #endif // PDF_ENABLE_XFA |
| 46 | 46 |
| 47 #if _FXM_PLATFORM_ == _FXM_PLATFORM_WINDOWS_ | 47 #if _FXM_PLATFORM_ == _FXM_PLATFORM_WINDOWS_ |
| 48 #include "core/fxge/cfx_windowsdevice.h" | 48 #include "core/fxge/cfx_windowsdevice.h" |
| 49 #endif | 49 #endif |
| 50 | 50 |
| 51 namespace { | 51 namespace { |
| 52 | 52 |
| 53 // Also indicates whether library is currently initialized. |
| 54 CCodec_ModuleMgr* g_pCodecModule = nullptr; |
| 55 |
| 53 void RenderPageImpl(CPDF_PageRenderContext* pContext, | 56 void RenderPageImpl(CPDF_PageRenderContext* pContext, |
| 54 CPDF_Page* pPage, | 57 CPDF_Page* pPage, |
| 55 const CFX_Matrix& matrix, | 58 const CFX_Matrix& matrix, |
| 56 const FX_RECT& clipping_rect, | 59 const FX_RECT& clipping_rect, |
| 57 int flags, | 60 int flags, |
| 58 bool bNeedToRestore, | 61 bool bNeedToRestore, |
| 59 IFSDK_PAUSE_Adapter* pause) { | 62 IFSDK_PAUSE_Adapter* pause) { |
| 60 if (!pContext->m_pOptions) | 63 if (!pContext->m_pOptions) |
| 61 pContext->m_pOptions = pdfium::MakeUnique<CPDF_RenderOptions>(); | 64 pContext->m_pOptions = pdfium::MakeUnique<CPDF_RenderOptions>(); |
| 62 | 65 |
| (...skipping 225 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 288 | 291 |
| 289 FPDF_BOOL FSDK_IsSandBoxPolicyEnabled(FPDF_DWORD policy) { | 292 FPDF_BOOL FSDK_IsSandBoxPolicyEnabled(FPDF_DWORD policy) { |
| 290 switch (policy) { | 293 switch (policy) { |
| 291 case FPDF_POLICY_MACHINETIME_ACCESS: | 294 case FPDF_POLICY_MACHINETIME_ACCESS: |
| 292 return !!(foxit_sandbox_policy & 0x01); | 295 return !!(foxit_sandbox_policy & 0x01); |
| 293 default: | 296 default: |
| 294 return false; | 297 return false; |
| 295 } | 298 } |
| 296 } | 299 } |
| 297 | 300 |
| 298 CCodec_ModuleMgr* g_pCodecModule = nullptr; | |
| 299 | |
| 300 DLLEXPORT void STDCALL FPDF_InitLibrary() { | 301 DLLEXPORT void STDCALL FPDF_InitLibrary() { |
| 301 FPDF_InitLibraryWithConfig(nullptr); | 302 FPDF_InitLibraryWithConfig(nullptr); |
| 302 } | 303 } |
| 303 | 304 |
| 304 DLLEXPORT void STDCALL | 305 DLLEXPORT void STDCALL |
| 305 FPDF_InitLibraryWithConfig(const FPDF_LIBRARY_CONFIG* cfg) { | 306 FPDF_InitLibraryWithConfig(const FPDF_LIBRARY_CONFIG* cfg) { |
| 307 if (g_pCodecModule) |
| 308 return; |
| 309 |
| 306 g_pCodecModule = new CCodec_ModuleMgr(); | 310 g_pCodecModule = new CCodec_ModuleMgr(); |
| 307 | 311 |
| 308 CFX_GEModule* pModule = CFX_GEModule::Get(); | 312 CFX_GEModule* pModule = CFX_GEModule::Get(); |
| 309 pModule->Init(cfg ? cfg->m_pUserFontPaths : nullptr, g_pCodecModule); | 313 pModule->Init(cfg ? cfg->m_pUserFontPaths : nullptr, g_pCodecModule); |
| 314 |
| 310 CPDF_ModuleMgr* pModuleMgr = CPDF_ModuleMgr::Get(); | 315 CPDF_ModuleMgr* pModuleMgr = CPDF_ModuleMgr::Get(); |
| 311 pModuleMgr->SetCodecModule(g_pCodecModule); | 316 pModuleMgr->SetCodecModule(g_pCodecModule); |
| 312 pModuleMgr->InitPageModule(); | 317 pModuleMgr->InitPageModule(); |
| 313 pModuleMgr->LoadEmbeddedGB1CMaps(); | 318 pModuleMgr->LoadEmbeddedGB1CMaps(); |
| 314 pModuleMgr->LoadEmbeddedJapan1CMaps(); | 319 pModuleMgr->LoadEmbeddedJapan1CMaps(); |
| 315 pModuleMgr->LoadEmbeddedCNS1CMaps(); | 320 pModuleMgr->LoadEmbeddedCNS1CMaps(); |
| 316 pModuleMgr->LoadEmbeddedKorea1CMaps(); | 321 pModuleMgr->LoadEmbeddedKorea1CMaps(); |
| 317 | 322 |
| 318 #ifdef PDF_ENABLE_XFA | 323 #ifdef PDF_ENABLE_XFA |
| 319 FXJSE_Initialize(); | 324 FXJSE_Initialize(); |
| 320 BC_Library_Init(); | 325 BC_Library_Init(); |
| 321 #endif // PDF_ENABLE_XFA | 326 #endif // PDF_ENABLE_XFA |
| 322 if (cfg && cfg->version >= 2) | 327 if (cfg && cfg->version >= 2) |
| 323 IJS_Runtime::Initialize(cfg->m_v8EmbedderSlot, cfg->m_pIsolate); | 328 IJS_Runtime::Initialize(cfg->m_v8EmbedderSlot, cfg->m_pIsolate); |
| 324 } | 329 } |
| 325 | 330 |
| 326 DLLEXPORT void STDCALL FPDF_DestroyLibrary() { | 331 DLLEXPORT void STDCALL FPDF_DestroyLibrary() { |
| 332 if (!g_pCodecModule) |
| 333 return; |
| 334 |
| 327 #ifdef PDF_ENABLE_XFA | 335 #ifdef PDF_ENABLE_XFA |
| 328 BC_Library_Destory(); | 336 BC_Library_Destory(); |
| 329 FXJSE_Finalize(); | 337 FXJSE_Finalize(); |
| 330 #endif // PDF_ENABLE_XFA | 338 #endif // PDF_ENABLE_XFA |
| 331 | 339 |
| 332 CPDF_ModuleMgr::Destroy(); | 340 CPDF_ModuleMgr::Destroy(); |
| 333 CFX_GEModule::Destroy(); | 341 CFX_GEModule::Destroy(); |
| 334 | 342 |
| 335 delete g_pCodecModule; | 343 delete g_pCodecModule; |
| 336 g_pCodecModule = nullptr; | 344 g_pCodecModule = nullptr; |
| (...skipping 832 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1169 if (!buffer) { | 1177 if (!buffer) { |
| 1170 *buflen = len; | 1178 *buflen = len; |
| 1171 } else if (len <= *buflen) { | 1179 } else if (len <= *buflen) { |
| 1172 memcpy(buffer, utf16Name.c_str(), len); | 1180 memcpy(buffer, utf16Name.c_str(), len); |
| 1173 *buflen = len; | 1181 *buflen = len; |
| 1174 } else { | 1182 } else { |
| 1175 *buflen = -1; | 1183 *buflen = -1; |
| 1176 } | 1184 } |
| 1177 return (FPDF_DEST)pDestObj; | 1185 return (FPDF_DEST)pDestObj; |
| 1178 } | 1186 } |
| OLD | NEW |