John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 1 | // Copyright 2014 PDFium Authors. All rights reserved. |
| 2 | // Use of this source code is governed by a BSD-style license that can be |
| 3 | // found in the LICENSE file. |
Lei Zhang | a6d9f0e | 2015-06-13 00:48:38 -0700 | [diff] [blame] | 4 | |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 5 | // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com |
| 6 | |
Tom Sepez | 19922bb | 2015-05-28 13:23:12 -0700 | [diff] [blame] | 7 | #ifndef FPDFSDK_INCLUDE_FSDK_DEFINE_H_ |
| 8 | #define FPDFSDK_INCLUDE_FSDK_DEFINE_H_ |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 9 | |
Lei Zhang | a688a04 | 2015-11-09 13:57:49 -0800 | [diff] [blame] | 10 | #include "core/include/fpdfapi/fpdf_module.h" |
| 11 | #include "core/include/fpdfapi/fpdf_pageobj.h" |
| 12 | #include "core/include/fpdfapi/fpdf_parser.h" |
| 13 | #include "core/include/fpdfapi/fpdf_render.h" |
Lei Zhang | a688a04 | 2015-11-09 13:57:49 -0800 | [diff] [blame] | 14 | #include "core/include/fpdfdoc/fpdf_doc.h" |
| 15 | #include "core/include/fpdfdoc/fpdf_vt.h" |
| 16 | #include "core/include/fxge/fx_ge.h" |
| 17 | #include "core/include/fxge/fx_ge_win32.h" |
Tom Sepez | 40e9ff3 | 2015-11-30 12:39:54 -0800 | [diff] [blame] | 18 | #include "public/fpdfview.h" |
| 19 | |
Tom Sepez | 51da093 | 2015-11-25 16:05:49 -0800 | [diff] [blame] | 20 | #ifdef PDF_ENABLE_XFA |
Tom Sepez | 50d12ad | 2015-11-24 09:50:51 -0800 | [diff] [blame] | 21 | #include "fpdfsdk/include/fpdfxfa/fpdfxfa_doc.h" |
| 22 | #include "fpdfsdk/include/fpdfxfa/fpdfxfa_page.h" |
Lei Zhang | 875b9c9 | 2016-01-08 13:51:10 -0800 | [diff] [blame] | 23 | #include "xfa/include/fwl/adapter/fwl_adaptertimermgr.h" |
| 24 | #include "xfa/include/fxbarcode/BC_BarCode.h" |
| 25 | #include "xfa/include/fxfa/fxfa.h" |
| 26 | #include "xfa/include/fxgraphics/fx_graphics.h" |
| 27 | #include "xfa/include/fxjse/fxjse.h" |
Tom Sepez | 40e9ff3 | 2015-11-30 12:39:54 -0800 | [diff] [blame] | 28 | #endif // PDF_ENABLE_XFA |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 29 | |
Tom Sepez | 75f43c4 | 2015-07-15 16:35:53 -0700 | [diff] [blame] | 30 | #ifdef _WIN32 |
Tom Sepez | 75f43c4 | 2015-07-15 16:35:53 -0700 | [diff] [blame] | 31 | #include <math.h> |
Dan Sinclair | 61046b9 | 2016-02-18 14:48:48 -0500 | [diff] [blame] | 32 | #include <tchar.h> |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 33 | #endif |
| 34 | |
Tom Sepez | b95fc6d | 2015-10-20 14:32:51 -0700 | [diff] [blame] | 35 | // Convert a #FX_ARGB to a #FX_COLORREF. |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 36 | #define FX_ARGBTOCOLORREF(argb) \ |
| 37 | ((((FX_DWORD)argb & 0x00FF0000) >> 16) | ((FX_DWORD)argb & 0x0000FF00) | \ |
| 38 | (((FX_DWORD)argb & 0x000000FF) << 16)) |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 39 | |
Tom Sepez | b95fc6d | 2015-10-20 14:32:51 -0700 | [diff] [blame] | 40 | // Convert a #FX_COLORREF to a #FX_ARGB. |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 41 | #define FX_COLORREFTOARGB(rgb) \ |
| 42 | ((FX_DWORD)0xFF000000 | (((FX_DWORD)rgb & 0x000000FF) << 16) | \ |
| 43 | ((FX_DWORD)rgb & 0x0000FF00) | (((FX_DWORD)rgb & 0x00FF0000) >> 16)) |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 44 | |
Lei Zhang | a6d9f0e | 2015-06-13 00:48:38 -0700 | [diff] [blame] | 45 | typedef unsigned int FX_UINT; |
Tom Sepez | 75f43c4 | 2015-07-15 16:35:53 -0700 | [diff] [blame] | 46 | class CRenderContext; |
| 47 | class IFSDK_PAUSE_Adapter; |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 48 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 49 | class CPDF_CustomAccess final : public IFX_FileRead { |
| 50 | public: |
Lei Zhang | c2fb35f | 2016-01-05 16:46:58 -0800 | [diff] [blame] | 51 | explicit CPDF_CustomAccess(FPDF_FILEACCESS* pFileAccess); |
Lei Zhang | 2b1a2d5 | 2015-08-14 22:16:22 -0700 | [diff] [blame] | 52 | ~CPDF_CustomAccess() override {} |
| 53 | |
| 54 | // IFX_FileRead |
| 55 | FX_FILESIZE GetSize() override { return m_FileAccess.m_FileLen; } |
| 56 | void Release() override { delete this; } |
| 57 | FX_BOOL ReadBlock(void* buffer, FX_FILESIZE offset, size_t size) override; |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 58 | |
Tom Sepez | 51da093 | 2015-11-25 16:05:49 -0800 | [diff] [blame] | 59 | #ifdef PDF_ENABLE_XFA |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 60 | virtual CFX_ByteString GetFullPath() { return ""; } |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 61 | virtual FX_BOOL GetByte(FX_DWORD pos, uint8_t& ch); |
| 62 | virtual FX_BOOL GetBlock(FX_DWORD pos, uint8_t* pBuf, FX_DWORD size); |
Tom Sepez | 40e9ff3 | 2015-11-30 12:39:54 -0800 | [diff] [blame] | 63 | #endif // PDF_ENABLE_XFA |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 64 | |
Tom Sepez | dfbf8e7 | 2015-10-14 14:17:26 -0700 | [diff] [blame] | 65 | private: |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 66 | FPDF_FILEACCESS m_FileAccess; |
Tom Sepez | 51da093 | 2015-11-25 16:05:49 -0800 | [diff] [blame] | 67 | #ifdef PDF_ENABLE_XFA |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 68 | uint8_t m_Buffer[512]; |
| 69 | FX_DWORD m_BufferOffset; |
Tom Sepez | 40e9ff3 | 2015-11-30 12:39:54 -0800 | [diff] [blame] | 70 | #endif // PDF_ENABLE_XFA |
Bo Xu | fdc00a7 | 2014-10-28 23:03:33 -0700 | [diff] [blame] | 71 | }; |
| 72 | |
Tom Sepez | 40e9ff3 | 2015-11-30 12:39:54 -0800 | [diff] [blame] | 73 | #ifdef PDF_ENABLE_XFA |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 74 | class CFPDF_FileStream : public IFX_FileStream { |
| 75 | public: |
| 76 | CFPDF_FileStream(FPDF_FILEHANDLER* pFS); |
| 77 | virtual ~CFPDF_FileStream() {} |
Bo Xu | fdc00a7 | 2014-10-28 23:03:33 -0700 | [diff] [blame] | 78 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 79 | virtual IFX_FileStream* Retain(); |
| 80 | virtual void Release(); |
Bo Xu | fdc00a7 | 2014-10-28 23:03:33 -0700 | [diff] [blame] | 81 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 82 | virtual FX_FILESIZE GetSize(); |
| 83 | virtual FX_BOOL IsEOF(); |
| 84 | virtual FX_FILESIZE GetPosition() { return m_nCurPos; } |
| 85 | virtual void SetPosition(FX_FILESIZE pos) { m_nCurPos = pos; } |
| 86 | virtual FX_BOOL ReadBlock(void* buffer, FX_FILESIZE offset, size_t size); |
| 87 | virtual size_t ReadBlock(void* buffer, size_t size); |
| 88 | virtual FX_BOOL WriteBlock(const void* buffer, |
| 89 | FX_FILESIZE offset, |
| 90 | size_t size); |
| 91 | virtual FX_BOOL Flush(); |
Bo Xu | fdc00a7 | 2014-10-28 23:03:33 -0700 | [diff] [blame] | 92 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 93 | protected: |
| 94 | FPDF_FILEHANDLER* m_pFS; |
| 95 | FX_FILESIZE m_nCurPos; |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 96 | }; |
Tom Sepez | 40e9ff3 | 2015-11-30 12:39:54 -0800 | [diff] [blame] | 97 | #endif // PDF_ENABLE_XFA |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 98 | |
Tom Sepez | 50d12ad | 2015-11-24 09:50:51 -0800 | [diff] [blame] | 99 | // Object types for public FPDF_ types; these correspond to next layer down |
| 100 | // from fpdfsdk. For master, these are CPDF_ types, but for XFA, these are |
| 101 | // CPDFXFA_ types. |
Tom Sepez | 51da093 | 2015-11-25 16:05:49 -0800 | [diff] [blame] | 102 | #ifndef PDF_ENABLE_XFA |
| 103 | using UnderlyingDocumentType = CPDF_Document; |
| 104 | using UnderlyingPageType = CPDF_Page; |
Tom Sepez | 40e9ff3 | 2015-11-30 12:39:54 -0800 | [diff] [blame] | 105 | #else // PDF_ENABLE_XFA |
Tom Sepez | 50d12ad | 2015-11-24 09:50:51 -0800 | [diff] [blame] | 106 | using UnderlyingDocumentType = CPDFXFA_Document; |
| 107 | using UnderlyingPageType = CPDFXFA_Page; |
Tom Sepez | 40e9ff3 | 2015-11-30 12:39:54 -0800 | [diff] [blame] | 108 | #endif // PDF_ENABLE_XFA |
Tom Sepez | 50d12ad | 2015-11-24 09:50:51 -0800 | [diff] [blame] | 109 | |
| 110 | // Conversions to/from underlying types. |
| 111 | UnderlyingDocumentType* UnderlyingFromFPDFDocument(FPDF_DOCUMENT doc); |
| 112 | FPDF_DOCUMENT FPDFDocumentFromUnderlying(UnderlyingDocumentType* doc); |
| 113 | |
| 114 | UnderlyingPageType* UnderlyingFromFPDFPage(FPDF_PAGE page); |
| 115 | |
Tom Sepez | bf59a07 | 2015-10-21 14:07:23 -0700 | [diff] [blame] | 116 | // Conversions to/from FPDF_ types. |
Tom Sepez | 471a103 | 2015-10-15 16:17:18 -0700 | [diff] [blame] | 117 | CPDF_Document* CPDFDocumentFromFPDFDocument(FPDF_DOCUMENT doc); |
Tom Sepez | bf59a07 | 2015-10-21 14:07:23 -0700 | [diff] [blame] | 118 | FPDF_DOCUMENT FPDFDocumentFromCPDFDocument(CPDF_Document* doc); |
| 119 | |
Tom Sepez | db0be96 | 2015-10-16 14:00:21 -0700 | [diff] [blame] | 120 | CPDF_Page* CPDFPageFromFPDFPage(FPDF_PAGE page); |
Tom Sepez | 471a103 | 2015-10-15 16:17:18 -0700 | [diff] [blame] | 121 | |
Tom Sepez | 75f43c4 | 2015-07-15 16:35:53 -0700 | [diff] [blame] | 122 | void DropContext(void* data); |
| 123 | void FSDK_SetSandBoxPolicy(FPDF_DWORD policy, FPDF_BOOL enable); |
| 124 | FPDF_BOOL FSDK_IsSandBoxPolicyEnabled(FPDF_DWORD policy); |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 125 | void FPDF_RenderPage_Retail(CRenderContext* pContext, |
| 126 | FPDF_PAGE page, |
| 127 | int start_x, |
| 128 | int start_y, |
| 129 | int size_x, |
| 130 | int size_y, |
| 131 | int rotate, |
| 132 | int flags, |
| 133 | FX_BOOL bNeedToRestore, |
Tom Sepez | 75f43c4 | 2015-07-15 16:35:53 -0700 | [diff] [blame] | 134 | IFSDK_PAUSE_Adapter* pause); |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 135 | |
Tom Sepez | 7da9803 | 2015-08-19 10:42:45 -0700 | [diff] [blame] | 136 | void CheckUnSupportError(CPDF_Document* pDoc, FX_DWORD err_code); |
Lei Zhang | 1b700c3 | 2015-10-30 23:55:35 -0700 | [diff] [blame] | 137 | void CheckUnSupportAnnot(CPDF_Document* pDoc, const CPDF_Annot* pPDFAnnot); |
Tom Sepez | f10ae63 | 2016-01-26 14:19:52 -0800 | [diff] [blame] | 138 | void ProcessParseError(CPDF_Parser::Error err); |
Tom Sepez | 7da9803 | 2015-08-19 10:42:45 -0700 | [diff] [blame] | 139 | |
Tom Sepez | 19922bb | 2015-05-28 13:23:12 -0700 | [diff] [blame] | 140 | #endif // FPDFSDK_INCLUDE_FSDK_DEFINE_H_ |