Merge to XFA: Use stdint.h types throughout PDFium.
[pdfium.git] / core / include / fpdfdoc / fpdf_ap.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 CORE_INCLUDE_FPDFDOC_FPDF_AP_H_
8 #define CORE_INCLUDE_FPDFDOC_FPDF_AP_H_
9
10 #include "../fxcrt/fx_basic.h"
11 #include "../fpdfapi/fpdf_parser.h"
12 #include "fpdf_vt.h"
13
14 class IPVT_FontMap
15 {
16 public:
17     virtual ~IPVT_FontMap() { }
18     virtual CPDF_Font*                                          GetPDFFont(int32_t nFontIndex) = 0;
19     virtual CFX_ByteString                                      GetPDFFontAlias(int32_t nFontIndex) = 0;
20 };
21 struct CPVT_Dash {
22
23     CPVT_Dash(int32_t dash, int32_t gap, int32_t phase) : nDash(dash), nGap(gap), nPhase(phase)
24     {}
25
26     int32_t                     nDash;
27
28     int32_t                     nGap;
29
30     int32_t                     nPhase;
31 };
32 #define CT_TRANSPARENT          0
33 #define CT_GRAY                         1
34 #define CT_RGB                          2
35 #define CT_CMYK                         3
36 struct CPVT_Color {
37
38     CPVT_Color(int32_t type = 0, FX_FLOAT color1 = 0.0f, FX_FLOAT color2 = 0.0f, FX_FLOAT color3 = 0.0f, FX_FLOAT color4 = 0.0f)
39         : nColorType(type), fColor1(color1), fColor2(color2), fColor3(color3), fColor4(color4)
40     {}
41
42     int32_t                     nColorType;
43     FX_FLOAT                    fColor1;
44     FX_FLOAT                    fColor2;
45     FX_FLOAT                    fColor3;
46     FX_FLOAT                    fColor4;
47 };
48 class CPVT_Provider : public IPDF_VariableText_Provider
49 {
50 public:
51
52     CPVT_Provider(IPVT_FontMap * pFontMap);
53
54     virtual ~CPVT_Provider();
55
56     int32_t                                             GetCharWidth(int32_t nFontIndex, FX_WORD word, int32_t nWordStyle);
57
58     int32_t                                             GetTypeAscent(int32_t nFontIndex);
59
60     int32_t                                             GetTypeDescent(int32_t nFontIndex);
61
62     int32_t                                             GetWordFontIndex(FX_WORD word, int32_t charset, int32_t nFontIndex);
63
64     FX_BOOL                                                     IsLatinWord(FX_WORD word);
65
66     int32_t                                             GetDefaultFontIndex();
67 private:
68
69     IPVT_FontMap *      m_pFontMap;
70 };
71 #define PBS_SOLID                       0
72 #define PBS_DASH                        1
73 #define PBS_BEVELED                     2
74 #define PBS_INSET                       3
75 #define PBS_UNDERLINED          4
76 class CPVT_GenerateAP
77 {
78 public:
79
80     static FX_BOOL                                                      GenerateTextFieldAP(CPDF_Document* pDoc, CPDF_Dictionary* pAnnotDict);
81
82     static FX_BOOL                                                      GenerateComboBoxAP(CPDF_Document* pDoc, CPDF_Dictionary* pAnnotDict);
83
84     static FX_BOOL                                                      GenerateListBoxAP(CPDF_Document* pDoc, CPDF_Dictionary* pAnnotDict);
85
86     static CFX_ByteString                                       GenerateEditAP(IPVT_FontMap * pFontMap, IPDF_VariableText_Iterator * pIterator,
87             const CPDF_Point & ptOffset, FX_BOOL bContinuous, FX_WORD SubWord = 0, const CPVT_WordRange * pVisible = NULL);
88
89     static CFX_ByteString                                       GenerateBorderAP(const CPDF_Rect & rect, FX_FLOAT fWidth,
90             const CPVT_Color & color, const CPVT_Color & crLeftTop, const CPVT_Color & crRightBottom,
91             int32_t nStyle, const CPVT_Dash & dash);
92
93     static CFX_ByteString                                       GenerateColorAP(const CPVT_Color & color, const FX_BOOL & bFillOrStroke);
94 };
95
96 #endif  // CORE_INCLUDE_FPDFDOC_FPDF_AP_H_