| 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 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 89 CFX_DIBitmap* CFXBitmapFromFPDFBitmap(FPDF_BITMAP bitmap) { | 89 CFX_DIBitmap* CFXBitmapFromFPDFBitmap(FPDF_BITMAP bitmap) { |
| 90 return static_cast<CFX_DIBitmap*>(bitmap); | 90 return static_cast<CFX_DIBitmap*>(bitmap); |
| 91 } | 91 } |
| 92 | 92 |
| 93 #ifdef PDF_ENABLE_XFA | 93 #ifdef PDF_ENABLE_XFA |
| 94 CFPDF_FileStream::CFPDF_FileStream(FPDF_FILEHANDLER* pFS) { | 94 CFPDF_FileStream::CFPDF_FileStream(FPDF_FILEHANDLER* pFS) { |
| 95 m_pFS = pFS; | 95 m_pFS = pFS; |
| 96 m_nCurPos = 0; | 96 m_nCurPos = 0; |
| 97 } | 97 } |
| 98 | 98 |
| 99 IFX_FileStream* CFPDF_FileStream::Retain() { | 99 IFX_SeekableStream* CFPDF_FileStream::Retain() { |
| 100 return this; | 100 return this; |
| 101 } | 101 } |
| 102 | 102 |
| 103 void CFPDF_FileStream::Release() { | 103 void CFPDF_FileStream::Release() { |
| 104 if (m_pFS && m_pFS->Release) | 104 if (m_pFS && m_pFS->Release) |
| 105 m_pFS->Release(m_pFS->clientData); | 105 m_pFS->Release(m_pFS->clientData); |
| 106 delete this; | 106 delete this; |
| 107 } | 107 } |
| 108 | 108 |
| 109 FX_FILESIZE CFPDF_FileStream::GetSize() { | 109 FX_FILESIZE CFPDF_FileStream::GetSize() { |
| (...skipping 208 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 318 | 318 |
| 319 DLLEXPORT void STDCALL FPDF_SetPrintTextWithGDI(FPDF_BOOL use_gdi) { | 319 DLLEXPORT void STDCALL FPDF_SetPrintTextWithGDI(FPDF_BOOL use_gdi) { |
| 320 g_pdfium_print_text_with_gdi = !!use_gdi; | 320 g_pdfium_print_text_with_gdi = !!use_gdi; |
| 321 } | 321 } |
| 322 #endif | 322 #endif |
| 323 | 323 |
| 324 DLLEXPORT FPDF_DOCUMENT STDCALL FPDF_LoadDocument(FPDF_STRING file_path, | 324 DLLEXPORT FPDF_DOCUMENT STDCALL FPDF_LoadDocument(FPDF_STRING file_path, |
| 325 FPDF_BYTESTRING password) { | 325 FPDF_BYTESTRING password) { |
| 326 // NOTE: the creation of the file needs to be by the embedder on the | 326 // NOTE: the creation of the file needs to be by the embedder on the |
| 327 // other side of this API. | 327 // other side of this API. |
| 328 IFX_FileRead* pFileAccess = FX_CreateFileRead((const FX_CHAR*)file_path); | 328 IFX_SeekableReadStream* pFileAccess = |
| 329 FX_CreateFileRead((const FX_CHAR*)file_path); |
| 329 if (!pFileAccess) { | 330 if (!pFileAccess) { |
| 330 return nullptr; | 331 return nullptr; |
| 331 } | 332 } |
| 332 | 333 |
| 333 std::unique_ptr<CPDF_Parser> pParser(new CPDF_Parser); | 334 std::unique_ptr<CPDF_Parser> pParser(new CPDF_Parser); |
| 334 pParser->SetPassword(password); | 335 pParser->SetPassword(password); |
| 335 | 336 |
| 336 std::unique_ptr<CPDF_Document> pDocument( | 337 std::unique_ptr<CPDF_Document> pDocument( |
| 337 new CPDF_Document(std::move(pParser))); | 338 new CPDF_Document(std::move(pParser))); |
| 338 CPDF_Parser::Error error = | 339 CPDF_Parser::Error error = |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 374 bool bDynamicXFA = pRoot->GetBooleanFor("NeedsRendering", false); | 375 bool bDynamicXFA = pRoot->GetBooleanFor("NeedsRendering", false); |
| 375 *docType = bDynamicXFA ? DOCTYPE_DYNAMIC_XFA : DOCTYPE_STATIC_XFA; | 376 *docType = bDynamicXFA ? DOCTYPE_DYNAMIC_XFA : DOCTYPE_STATIC_XFA; |
| 376 return TRUE; | 377 return TRUE; |
| 377 } | 378 } |
| 378 | 379 |
| 379 DLLEXPORT FPDF_BOOL STDCALL FPDF_LoadXFA(FPDF_DOCUMENT document) { | 380 DLLEXPORT FPDF_BOOL STDCALL FPDF_LoadXFA(FPDF_DOCUMENT document) { |
| 380 return document && (static_cast<CPDFXFA_Document*>(document))->LoadXFADoc(); | 381 return document && (static_cast<CPDFXFA_Document*>(document))->LoadXFADoc(); |
| 381 } | 382 } |
| 382 #endif // PDF_ENABLE_XFA | 383 #endif // PDF_ENABLE_XFA |
| 383 | 384 |
| 384 class CMemFile final : public IFX_FileRead { | 385 class CMemFile final : public IFX_SeekableReadStream { |
| 385 public: | 386 public: |
| 386 CMemFile(uint8_t* pBuf, FX_FILESIZE size) : m_pBuf(pBuf), m_size(size) {} | 387 CMemFile(uint8_t* pBuf, FX_FILESIZE size) : m_pBuf(pBuf), m_size(size) {} |
| 387 | 388 |
| 388 void Release() override { delete this; } | 389 void Release() override { delete this; } |
| 389 FX_FILESIZE GetSize() override { return m_size; } | 390 FX_FILESIZE GetSize() override { return m_size; } |
| 390 FX_BOOL ReadBlock(void* buffer, FX_FILESIZE offset, size_t size) override { | 391 FX_BOOL ReadBlock(void* buffer, FX_FILESIZE offset, size_t size) override { |
| 391 if (offset < 0) { | 392 if (offset < 0) { |
| 392 return FALSE; | 393 return FALSE; |
| 393 } | 394 } |
| 394 FX_SAFE_FILESIZE newPos = | 395 FX_SAFE_FILESIZE newPos = |
| (...skipping 699 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1094 if (!buffer) { | 1095 if (!buffer) { |
| 1095 *buflen = len; | 1096 *buflen = len; |
| 1096 } else if (*buflen >= len) { | 1097 } else if (*buflen >= len) { |
| 1097 memcpy(buffer, utf16Name.c_str(), len); | 1098 memcpy(buffer, utf16Name.c_str(), len); |
| 1098 *buflen = len; | 1099 *buflen = len; |
| 1099 } else { | 1100 } else { |
| 1100 *buflen = -1; | 1101 *buflen = -1; |
| 1101 } | 1102 } |
| 1102 return (FPDF_DEST)pDestObj; | 1103 return (FPDF_DEST)pDestObj; |
| 1103 } | 1104 } |
| OLD | NEW |