Initial commit.
[pdfium.git] / core / include / fpdfdoc / fpdf_ap.h
1 // Copyright 2014 PDFium Authors. All rights reserved.\r
2 // Use of this source code is governed by a BSD-style license that can be\r
3 // found in the LICENSE file.\r
4  \r
5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com\r
6 \r
7 #define _FPDF_AP_H_\r
8 #include "../fxcrt/fx_basic.h"\r
9 #include "../fpdfapi/fpdf_parser.h"\r
10 #include "fpdf_vt.h"\r
11 class IPVT_FontMap\r
12 {\r
13 public:\r
14 \r
15     virtual CPDF_Font*                                          GetPDFFont(FX_INT32 nFontIndex) = 0;\r
16 \r
17     virtual CFX_ByteString                                      GetPDFFontAlias(FX_INT32 nFontIndex) = 0;\r
18 };\r
19 struct CPVT_Dash {\r
20 \r
21     CPVT_Dash(FX_INT32 dash, FX_INT32 gap, FX_INT32 phase) : nDash(dash), nGap(gap), nPhase(phase)\r
22     {}\r
23 \r
24     FX_INT32                    nDash;\r
25 \r
26     FX_INT32                    nGap;\r
27 \r
28     FX_INT32                    nPhase;\r
29 };\r
30 #define CT_TRANSPARENT          0\r
31 #define CT_GRAY                         1\r
32 #define CT_RGB                          2\r
33 #define CT_CMYK                         3\r
34 struct CPVT_Color {\r
35 \r
36     CPVT_Color(FX_INT32 type = 0, FX_FLOAT color1 = 0.0f, FX_FLOAT color2 = 0.0f, FX_FLOAT color3 = 0.0f, FX_FLOAT color4 = 0.0f)\r
37         : nColorType(type), fColor1(color1), fColor2(color2), fColor3(color3), fColor4(color4)\r
38     {}\r
39 \r
40     FX_INT32                    nColorType;\r
41     FX_FLOAT                    fColor1;\r
42     FX_FLOAT                    fColor2;\r
43     FX_FLOAT                    fColor3;\r
44     FX_FLOAT                    fColor4;\r
45 };\r
46 class CPVT_Provider : public IPDF_VariableText_Provider\r
47 {\r
48 public:\r
49 \r
50     CPVT_Provider(IPVT_FontMap * pFontMap);\r
51 \r
52     virtual ~CPVT_Provider();\r
53 \r
54     FX_INT32                                            GetCharWidth(FX_INT32 nFontIndex, FX_WORD word, FX_INT32 nWordStyle);\r
55 \r
56     FX_INT32                                            GetTypeAscent(FX_INT32 nFontIndex);\r
57 \r
58     FX_INT32                                            GetTypeDescent(FX_INT32 nFontIndex);\r
59 \r
60     FX_INT32                                            GetWordFontIndex(FX_WORD word, FX_INT32 charset, FX_INT32 nFontIndex);\r
61 \r
62     FX_BOOL                                                     IsLatinWord(FX_WORD word);\r
63 \r
64     FX_INT32                                            GetDefaultFontIndex();\r
65 private:\r
66 \r
67     IPVT_FontMap *      m_pFontMap;\r
68 };\r
69 #define PBS_SOLID                       0\r
70 #define PBS_DASH                        1\r
71 #define PBS_BEVELED                     2\r
72 #define PBS_INSET                       3\r
73 #define PBS_UNDERLINED          4\r
74 class CPVT_GenerateAP\r
75 {\r
76 public:\r
77 \r
78     static FX_BOOL                                                      GenerateTextFieldAP(CPDF_Document* pDoc, CPDF_Dictionary* pAnnotDict);\r
79 \r
80     static FX_BOOL                                                      GenerateComboBoxAP(CPDF_Document* pDoc, CPDF_Dictionary* pAnnotDict);\r
81 \r
82     static FX_BOOL                                                      GenerateListBoxAP(CPDF_Document* pDoc, CPDF_Dictionary* pAnnotDict);\r
83 \r
84     static CFX_ByteString                                       GenerateEditAP(IPVT_FontMap * pFontMap, IPDF_VariableText_Iterator * pIterator,\r
85             const CPDF_Point & ptOffset, FX_BOOL bContinuous, FX_WORD SubWord = 0, const CPVT_WordRange * pVisible = NULL);\r
86 \r
87     static CFX_ByteString                                       GenerateBorderAP(const CPDF_Rect & rect, FX_FLOAT fWidth,\r
88             const CPVT_Color & color, const CPVT_Color & crLeftTop, const CPVT_Color & crRightBottom,\r
89             FX_INT32 nStyle, const CPVT_Dash & dash);\r
90 \r
91     static CFX_ByteString                                       GenerateColorAP(const CPVT_Color & color, const FX_BOOL & bFillOrStroke);\r
92 };\r