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:
~IPVT_FontMap()17     virtual ~IPVT_FontMap() { }
18     virtual CPDF_Font*						GetPDFFont(FX_INT32 nFontIndex) = 0;
19     virtual CFX_ByteString					GetPDFFontAlias(FX_INT32 nFontIndex) = 0;
20 };
21 struct CPVT_Dash {
22 
CPVT_DashCPVT_Dash23     CPVT_Dash(FX_INT32 dash, FX_INT32 gap, FX_INT32 phase) : nDash(dash), nGap(gap), nPhase(phase)
24     {}
25 
26     FX_INT32			nDash;
27 
28     FX_INT32			nGap;
29 
30     FX_INT32			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(FX_INT32 type = 0, FX_FLOAT color1 = 0.0f, FX_FLOAT color2 = 0.0f, FX_FLOAT color3 = 0.0f, FX_FLOAT color4 = 0.0f)
nColorTypeCPVT_Color39         : nColorType(type), fColor1(color1), fColor2(color2), fColor3(color3), fColor4(color4)
40     {}
41 
42     FX_INT32			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     FX_INT32						GetCharWidth(FX_INT32 nFontIndex, FX_WORD word, FX_INT32 nWordStyle);
57 
58     FX_INT32						GetTypeAscent(FX_INT32 nFontIndex);
59 
60     FX_INT32						GetTypeDescent(FX_INT32 nFontIndex);
61 
62     FX_INT32						GetWordFontIndex(FX_WORD word, FX_INT32 charset, FX_INT32 nFontIndex);
63 
64     FX_BOOL							IsLatinWord(FX_WORD word);
65 
66     FX_INT32						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             FX_INT32 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_
97