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.
4 
5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
6 
7 #ifndef FPDFSDK_FSDK_DEFINE_H_
8 #define FPDFSDK_FSDK_DEFINE_H_
9 
10 #include "core/fpdfapi/parser/cpdf_parser.h"
11 #include "core/fxge/fx_dib.h"
12 #include "public/fpdfview.h"
13 
14 #ifdef PDF_ENABLE_XFA
15 #include "fpdfsdk/fpdfxfa/cpdfxfa_context.h"
16 #endif  // PDF_ENABLE_XFA
17 
18 #ifdef _WIN32
19 #include <math.h>
20 #include <tchar.h>
21 #endif
22 
23 class CPDF_Annot;
24 class CPDF_Page;
25 class CPDF_PageRenderContext;
26 class IFSDK_PAUSE_Adapter;
27 
28 // Layering prevents fxcrt from knowing about FPDF_FILEACCESS, so this can't
29 // be a static method of IFX_SeekableReadStream.
30 CFX_RetainPtr<IFX_SeekableReadStream> MakeSeekableReadStream(
31     FPDF_FILEACCESS* pFileAccess);
32 
33 #ifdef PDF_ENABLE_XFA
34 // Layering prevents fxcrt from knowing about FPDF_FILEHANDLER, so this can't
35 // be a static method of IFX_SeekableStream.
36 CFX_RetainPtr<IFX_SeekableStream> MakeSeekableStream(
37     FPDF_FILEHANDLER* pFileHandler);
38 #endif  // PDF_ENABLE_XFA
39 
40 // Object types for public FPDF_ types; these correspond to next layer down
41 // from fpdfsdk. For master, these are CPDF_ types, but for XFA, these are
42 // CPDFXFA_ types.
43 #ifndef PDF_ENABLE_XFA
44 using UnderlyingDocumentType = CPDF_Document;
45 using UnderlyingPageType = CPDF_Page;
46 #else   // PDF_ENABLE_XFA
47 using UnderlyingDocumentType = CPDFXFA_Context;
48 using UnderlyingPageType = CPDFXFA_Page;
49 #endif  // PDF_ENABLE_XFA
50 
51 // Conversions to/from underlying types.
52 UnderlyingDocumentType* UnderlyingFromFPDFDocument(FPDF_DOCUMENT doc);
53 FPDF_DOCUMENT FPDFDocumentFromUnderlying(UnderlyingDocumentType* doc);
54 
55 UnderlyingPageType* UnderlyingFromFPDFPage(FPDF_PAGE page);
56 
57 // Conversions to/from FPDF_ types.
58 CPDF_Document* CPDFDocumentFromFPDFDocument(FPDF_DOCUMENT doc);
59 FPDF_DOCUMENT FPDFDocumentFromCPDFDocument(CPDF_Document* doc);
60 
61 CPDF_Page* CPDFPageFromFPDFPage(FPDF_PAGE page);
62 
63 CFX_DIBitmap* CFXBitmapFromFPDFBitmap(FPDF_BITMAP bitmap);
64 
65 void FSDK_SetSandBoxPolicy(FPDF_DWORD policy, FPDF_BOOL enable);
66 FPDF_BOOL FSDK_IsSandBoxPolicyEnabled(FPDF_DWORD policy);
67 void FPDF_RenderPage_Retail(CPDF_PageRenderContext* pContext,
68                             FPDF_PAGE page,
69                             int start_x,
70                             int start_y,
71                             int size_x,
72                             int size_y,
73                             int rotate,
74                             int flags,
75                             bool bNeedToRestore,
76                             IFSDK_PAUSE_Adapter* pause);
77 
78 void CheckUnSupportError(CPDF_Document* pDoc, uint32_t err_code);
79 void CheckUnSupportAnnot(CPDF_Document* pDoc, const CPDF_Annot* pPDFAnnot);
80 void ProcessParseError(CPDF_Parser::Error err);
81 
82 #endif  // FPDFSDK_FSDK_DEFINE_H_
83