Clean up CPDF_AnnotList.
[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 "../fpdfapi/fpdf_parser.h"
11 #include "fpdf_vt.h"
12
13 class IPVT_FontMap {
14  public:
15   virtual ~IPVT_FontMap() {}
16   virtual CPDF_Font* GetPDFFont(int32_t nFontIndex) = 0;
17   virtual CFX_ByteString GetPDFFontAlias(int32_t nFontIndex) = 0;
18 };
19 struct CPVT_Dash {
20   CPVT_Dash(int32_t dash, int32_t gap, int32_t phase)
21       : nDash(dash), nGap(gap), nPhase(phase) {}
22
23   int32_t nDash;
24
25   int32_t nGap;
26
27   int32_t nPhase;
28 };
29 #define CT_TRANSPARENT 0
30 #define CT_GRAY 1
31 #define CT_RGB 2
32 #define CT_CMYK 3
33 struct CPVT_Color {
34   CPVT_Color(int32_t type = 0,
35              FX_FLOAT color1 = 0.0f,
36              FX_FLOAT color2 = 0.0f,
37              FX_FLOAT color3 = 0.0f,
38              FX_FLOAT color4 = 0.0f)
39       : nColorType(type),
40         fColor1(color1),
41         fColor2(color2),
42         fColor3(color3),
43         fColor4(color4) {}
44
45   int32_t nColorType;
46   FX_FLOAT fColor1;
47   FX_FLOAT fColor2;
48   FX_FLOAT fColor3;
49   FX_FLOAT fColor4;
50 };
51 class CPVT_Provider : public IPDF_VariableText_Provider {
52  public:
53   CPVT_Provider(IPVT_FontMap* pFontMap);
54   ~CPVT_Provider() override;
55
56   // IPDF_VariableText_Provider
57   int32_t GetCharWidth(int32_t nFontIndex,
58                        FX_WORD word,
59                        int32_t nWordStyle) override;
60   int32_t GetTypeAscent(int32_t nFontIndex) override;
61   int32_t GetTypeDescent(int32_t nFontIndex) override;
62   int32_t GetWordFontIndex(FX_WORD word,
63                            int32_t charset,
64                            int32_t nFontIndex) override;
65   FX_BOOL IsLatinWord(FX_WORD word) override;
66   int32_t GetDefaultFontIndex() override;
67
68  private:
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  public:
78   static FX_BOOL GenerateTextFieldAP(CPDF_Document* pDoc,
79                                      CPDF_Dictionary* pAnnotDict);
80
81   static FX_BOOL GenerateComboBoxAP(CPDF_Document* pDoc,
82                                     CPDF_Dictionary* pAnnotDict);
83
84   static FX_BOOL GenerateListBoxAP(CPDF_Document* pDoc,
85                                    CPDF_Dictionary* pAnnotDict);
86
87   static CFX_ByteString GenerateEditAP(IPVT_FontMap* pFontMap,
88                                        IPDF_VariableText_Iterator* pIterator,
89                                        const CPDF_Point& ptOffset,
90                                        FX_BOOL bContinuous,
91                                        FX_WORD SubWord = 0,
92                                        const CPVT_WordRange* pVisible = NULL);
93
94   static CFX_ByteString GenerateBorderAP(const CPDF_Rect& rect,
95                                          FX_FLOAT fWidth,
96                                          const CPVT_Color& color,
97                                          const CPVT_Color& crLeftTop,
98                                          const CPVT_Color& crRightBottom,
99                                          int32_t nStyle,
100                                          const CPVT_Dash& dash);
101
102   static CFX_ByteString GenerateColorAP(const CPVT_Color& color,
103                                         const FX_BOOL& bFillOrStroke);
104 };
105
106 #endif  // CORE_INCLUDE_FPDFDOC_FPDF_AP_H_