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