Coverage Report

Created: 2025-07-12 07:51

/src/xpdf-4.05/xpdf/AcroForm.h
Line
Count
Source (jump to first uncovered line)
1
//========================================================================
2
//
3
// AcroForm.h
4
//
5
// Copyright 2012 Glyph & Cog, LLC
6
//
7
//========================================================================
8
9
#ifndef ACROFORM_H
10
#define ACROFORM_H
11
12
#include <aconf.h>
13
14
class TextString;
15
class Gfx;
16
class GfxFont;
17
class GfxFontDict;
18
class AcroFormField;
19
class XFAScanner;
20
class XFAField;
21
class XFAFieldBarcodeInfo;
22
23
//------------------------------------------------------------------------
24
25
class AcroForm {
26
public:
27
28
  static AcroForm *load(PDFDoc *docA, Catalog *catalog, Object *acroFormObjA);
29
30
  ~AcroForm();
31
32
  const char *getType();
33
34
  void draw(int pageNum, Gfx *gfx, GBool printing);
35
36
  int getNumFields();
37
  AcroFormField *getField(int idx);
38
  AcroFormField *findField(int pg, double x, double y);
39
  int findFieldIdx(int pg, double x, double y);
40
41
private:
42
43
  AcroForm(PDFDoc *docA, Object *acroFormObjA);
44
  void buildAnnotPageList(Catalog *catalog);
45
  int lookupAnnotPage(Object *annotRef);
46
  void scanField(Object *fieldRef, char *touchedObjs);
47
48
  PDFDoc *doc;
49
  Object acroFormObj;
50
  GBool needAppearances;
51
  GList *annotPages;    // [AcroFormAnnotPage]
52
  GList *fields;    // [AcroFormField]
53
  XFAScanner *xfaScanner;
54
  GBool isStaticXFA;
55
56
  friend class AcroFormField;
57
};
58
59
//------------------------------------------------------------------------
60
61
enum AcroFormFieldType {
62
  acroFormFieldPushbutton,
63
  acroFormFieldRadioButton,
64
  acroFormFieldCheckbox,
65
  acroFormFieldFileSelect,
66
  acroFormFieldMultilineText,
67
  acroFormFieldText,
68
  acroFormFieldBarcode,
69
  acroFormFieldComboBox,
70
  acroFormFieldListBox,
71
  acroFormFieldSignature
72
};
73
74
class AcroFormField {
75
public:
76
77
  static AcroFormField *load(AcroForm *acroFormA, Object *fieldRefA);
78
79
  ~AcroFormField();
80
81
  int getPageNum();
82
  const char *getType();
83
  Unicode *getName(int *length);
84
  Unicode *getValue(int *length);
85
  void getBBox(double *llx, double *lly, double *urx, double *ury);
86
  void getFont(Ref *fontID, double *fontSize);
87
  void getColor(double *red, double *green, double *blue);
88
  int getMaxLen();
89
90
  Object *getResources(Object *res);
91
92
0
  AcroFormFieldType getAcroFormFieldType() { return type; }
93
  Object *getFieldRef(Object *ref);
94
  Object *getValueObj(Object *val);
95
  Object *getParentRef(Object *parent);
96
0
  GBool getTypeFromParent() { return typeFromParent; }
97
98
private:
99
100
  AcroFormField(AcroForm *acroFormA, Object *fieldRefA, Object *fieldObjA,
101
    AcroFormFieldType typeA, TextString *nameA,
102
    Guint flagsA, GBool typeFromParentA, XFAField *xfaFieldA);
103
  Ref findFontName(char *fontTag);
104
  void draw(int pageNum, Gfx *gfx, GBool printing);
105
  void drawAnnot(int pageNum, Gfx *gfx, GBool printing,
106
     Object *annotRef, Object *annotObj);
107
  void drawExistingAppearance(Gfx *gfx, Dict *annot,
108
            double xMin, double yMin,
109
            double xMax, double yMax);
110
  void drawNewAppearance(Gfx *gfx, Dict *annot,
111
       double xMin, double yMin,
112
       double xMax, double yMax);
113
  void setColor(Array *a, GBool fill, int adjust, GString *appearBuf);
114
  void drawText(GString *text, GString *da, GfxFontDict *fontDict,
115
    GBool multiline, int comb, int quadding, int vAlign,
116
    GBool txField, GBool forceZapfDingbats, int rot,
117
    double x, double y, double width, double height,
118
    double border, GBool whiteBackground, GString *appearBuf);
119
  void drawListBox(GString **text, GBool *selection,
120
       int nOptions, int topIdx,
121
       GString *da, GfxFontDict *fontDict,
122
       GBool quadding, double xMin, double yMin,
123
       double xMax, double yMax, double border,
124
       GString *appearBuf);
125
  void getNextLine(GString *text, int start,
126
       GfxFont *font, double fontSize, double wMax,
127
       int *end, double *width, int *next);
128
  void drawCircle(double cx, double cy, double r, const char *cmd,
129
      GString *appearBuf);
130
  void drawCircleTopLeft(double cx, double cy, double r,
131
       GString *appearBuf);
132
  void drawCircleBottomRight(double cx, double cy, double r,
133
           GString *appearBuf);
134
  void drawBarcode(GString *value, GString *da, GfxFontDict *fontDict, int rot,
135
       double xMin, double yMin, double xMax, double yMax,
136
       XFAFieldBarcodeInfo *barcodeInfo, GString *appearBuf);
137
  GList *tokenize(GString *s);
138
  Object *getAnnotObj(Object *annotObj);
139
  Object *getAnnotResources(Dict *annot, Object *res);
140
  void buildDefaultResourceDict(Object *dr);
141
  Object *fieldLookup(const char *key, Object *obj);
142
  Object *fieldLookup(Dict *dict, const char *key, Object *obj);
143
  Unicode *utf8ToUnicode(GString *s, int *unicodeLength);
144
  GString *unicodeToLatin1(Unicode *u, int unicodeLength);
145
  GBool unicodeStringEqual(Unicode *u, int unicodeLength, GString *s);
146
  GBool unicodeStringEqual(Unicode *u, int unicodeLength, const char *s);
147
  GString *pictureFormatDateTime(GString *value, GString *picture);
148
  GString *pictureFormatNumber(GString *value, GString *picture);
149
  GString *pictureFormatText(GString *value, GString *picture);
150
  GBool isValidInt(GString *s, int start, int len);
151
  int convertInt(GString *s, int start, int len);
152
153
  AcroForm *acroForm;
154
  Object fieldRef;
155
  Object fieldObj;
156
  AcroFormFieldType type;
157
  TextString *name;
158
  Guint flags;
159
  GBool typeFromParent;
160
  XFAField *xfaField;
161
162
  friend class AcroForm;
163
};
164
165
#endif