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/dib/cfx_dibitmap.h" 12 #include "core/fxge/fx_dib.h" 13 #include "public/fpdfview.h" 14 15 #ifdef PDF_ENABLE_XFA 16 #include "fpdfsdk/fpdfxfa/cpdfxfa_context.h" 17 #endif // PDF_ENABLE_XFA 18 19 #ifdef _WIN32 20 #include <math.h> 21 #include <tchar.h> 22 #endif 23 24 class CPDF_Annot; 25 class CPDF_Page; 26 class CPDF_PageObject; 27 class CPDF_PageRenderContext; 28 class CPDF_PathObject; 29 class CPDF_Stream; 30 class IFSDK_PAUSE_Adapter; 31 class FX_PATHPOINT; 32 33 // Layering prevents fxcrt from knowing about FPDF_FILEACCESS, so this can't 34 // be a static method of IFX_SeekableReadStream. 35 RetainPtr<IFX_SeekableReadStream> MakeSeekableReadStream( 36 FPDF_FILEACCESS* pFileAccess); 37 38 #ifdef PDF_ENABLE_XFA 39 // Layering prevents fxcrt from knowing about FPDF_FILEHANDLER, so this can't 40 // be a static method of IFX_SeekableStream. 41 RetainPtr<IFX_SeekableStream> MakeSeekableStream( 42 FPDF_FILEHANDLER* pFileHandler); 43 #endif // PDF_ENABLE_XFA 44 45 // Object types for public FPDF_ types; these correspond to next layer down 46 // from fpdfsdk. For master, these are CPDF_ types, but for XFA, these are 47 // CPDFXFA_ types. 48 #ifndef PDF_ENABLE_XFA 49 using UnderlyingDocumentType = CPDF_Document; 50 using UnderlyingPageType = CPDF_Page; 51 #else // PDF_ENABLE_XFA 52 using UnderlyingDocumentType = CPDFXFA_Context; 53 using UnderlyingPageType = CPDFXFA_Page; 54 #endif // PDF_ENABLE_XFA 55 56 // Conversions to/from underlying types. 57 UnderlyingDocumentType* UnderlyingFromFPDFDocument(FPDF_DOCUMENT doc); 58 FPDF_DOCUMENT FPDFDocumentFromUnderlying(UnderlyingDocumentType* doc); 59 60 UnderlyingPageType* UnderlyingFromFPDFPage(FPDF_PAGE page); 61 62 // Conversions to/from FPDF_ types. 63 CPDF_Document* CPDFDocumentFromFPDFDocument(FPDF_DOCUMENT doc); 64 FPDF_DOCUMENT FPDFDocumentFromCPDFDocument(CPDF_Document* doc); 65 66 CPDF_Page* CPDFPageFromFPDFPage(FPDF_PAGE page); 67 68 CPDF_PathObject* CPDFPathObjectFromFPDFPageObject(FPDF_PAGEOBJECT page_object); 69 70 CPDF_PageObject* CPDFPageObjectFromFPDFPageObject(FPDF_PAGEOBJECT page_object); 71 72 CPDF_Object* CPDFObjectFromFPDFAttachment(FPDF_ATTACHMENT attachment); 73 74 ByteString CFXByteStringFromFPDFWideString(FPDF_WIDESTRING wide_string); 75 76 CFX_DIBitmap* CFXBitmapFromFPDFBitmap(FPDF_BITMAP bitmap); 77 78 CFX_FloatRect CFXFloatRectFromFSRECTF(const FS_RECTF& rect); 79 void FSRECTFFromCFXFloatRect(const CFX_FloatRect& rect, FS_RECTF* out_rect); 80 81 const FX_PATHPOINT* FXPathPointFromFPDFPathSegment(FPDF_PATHSEGMENT segment); 82 83 unsigned long Utf16EncodeMaybeCopyAndReturnLength(const WideString& text, 84 void* buffer, 85 unsigned long buflen); 86 87 unsigned long DecodeStreamMaybeCopyAndReturnLength(const CPDF_Stream* stream, 88 void* buffer, 89 unsigned long buflen); 90 91 void FSDK_SetSandBoxPolicy(FPDF_DWORD policy, FPDF_BOOL enable); 92 FPDF_BOOL FSDK_IsSandBoxPolicyEnabled(FPDF_DWORD policy); 93 void FPDF_RenderPage_Retail(CPDF_PageRenderContext* pContext, 94 FPDF_PAGE page, 95 int start_x, 96 int start_y, 97 int size_x, 98 int size_y, 99 int rotate, 100 int flags, 101 bool bNeedToRestore, 102 IFSDK_PAUSE_Adapter* pause); 103 104 void CheckUnSupportError(CPDF_Document* pDoc, uint32_t err_code); 105 void CheckUnSupportAnnot(CPDF_Document* pDoc, const CPDF_Annot* pPDFAnnot); 106 void ProcessParseError(CPDF_Parser::Error err); 107 FPDF_BOOL FPDFPageObj_SetFillColor(FPDF_PAGEOBJECT page_object, 108 unsigned int R, 109 unsigned int G, 110 unsigned int B, 111 unsigned int A); 112 113 #endif // FPDFSDK_FSDK_DEFINE_H_ 114