Fix incorrect CPDFSDK_PageView::CountAnnots(). (try 2)
[pdfium.git] / fpdfsdk / include / fsdk_define.h
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_INCLUDE_FSDK_DEFINE_H_
8 #define FPDFSDK_INCLUDE_FSDK_DEFINE_H_
9
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"
14 #include "../../core/include/fpdfapi/fpdf_serial.h"
15 #include "../../core/include/fpdfapi/fpdfapi.h"
16 #include "../../core/include/fpdfdoc/fpdf_doc.h"
17 #include "../../core/include/fpdfdoc/fpdf_vt.h"
18 #include "../../core/include/fxge/fx_ge.h"
19 #include "../../core/include/fxge/fx_ge_win32.h"
20 #include "../../public/fpdfview.h"
21
22 #ifdef _WIN32
23 #include <tchar.h>
24 #include <math.h>
25 #endif
26
27 // Convert a #FX_ARGB to a #FX_COLORREF.
28 #define FX_ARGBTOCOLORREF(argb)                                            \
29   ((((FX_DWORD)argb & 0x00FF0000) >> 16) | ((FX_DWORD)argb & 0x0000FF00) | \
30    (((FX_DWORD)argb & 0x000000FF) << 16))
31
32 // Convert a #FX_COLORREF to a #FX_ARGB.
33 #define FX_COLORREFTOARGB(rgb)                                   \
34   ((FX_DWORD)0xFF000000 | (((FX_DWORD)rgb & 0x000000FF) << 16) | \
35    ((FX_DWORD)rgb & 0x0000FF00) | (((FX_DWORD)rgb & 0x00FF0000) >> 16))
36
37 typedef unsigned int FX_UINT;
38 class CRenderContext;
39 class IFSDK_PAUSE_Adapter;
40
41 class CPDF_CustomAccess final : public IFX_FileRead {
42  public:
43   CPDF_CustomAccess(FPDF_FILEACCESS* pFileAccess);
44   ~CPDF_CustomAccess() override {}
45
46   // IFX_FileRead
47   FX_FILESIZE GetSize() override { return m_FileAccess.m_FileLen; }
48   void Release() override { delete this; }
49   FX_BOOL ReadBlock(void* buffer, FX_FILESIZE offset, size_t size) override;
50
51  private:
52   FPDF_FILEACCESS m_FileAccess;
53 };
54
55 // Conversions to/from FPDF_ types.
56 CPDF_Document* CPDFDocumentFromFPDFDocument(FPDF_DOCUMENT doc);
57 FPDF_DOCUMENT FPDFDocumentFromCPDFDocument(CPDF_Document* doc);
58
59 CPDF_Page* CPDFPageFromFPDFPage(FPDF_PAGE page);
60
61 void DropContext(void* data);
62 void FSDK_SetSandBoxPolicy(FPDF_DWORD policy, FPDF_BOOL enable);
63 FPDF_BOOL FSDK_IsSandBoxPolicyEnabled(FPDF_DWORD policy);
64 void FPDF_RenderPage_Retail(CRenderContext* pContext,
65                             FPDF_PAGE page,
66                             int start_x,
67                             int start_y,
68                             int size_x,
69                             int size_y,
70                             int rotate,
71                             int flags,
72                             FX_BOOL bNeedToRestore,
73                             IFSDK_PAUSE_Adapter* pause);
74
75 void CheckUnSupportError(CPDF_Document* pDoc, FX_DWORD err_code);
76 void CheckUnSupportAnnot(CPDF_Document* pDoc, CPDF_Annot* pPDFAnnot);
77 void ProcessParseError(FX_DWORD err_code);
78
79 #endif  // FPDFSDK_INCLUDE_FSDK_DEFINE_H_