Coverage Report

Created: 2025-07-11 06:50

/src/xpdf-4.05/xpdf/XFAScanner.h
Line
Count
Source (jump to first uncovered line)
1
//========================================================================
2
//
3
// XFAScanner.h
4
//
5
// Copyright 2020 Glyph & Cog, LLC
6
//
7
//========================================================================
8
9
#ifndef XFASCANNER_H
10
#define XFASCANNER_H
11
12
#include <aconf.h>
13
14
class GHash;
15
class ZxElement;
16
17
//------------------------------------------------------------------------
18
19
enum XFAFieldLayoutHAlign {
20
  xfaFieldLayoutHAlignLeft,
21
  xfaFieldLayoutHAlignCenter,
22
  xfaFieldLayoutHAlignRight
23
};
24
25
enum XFAFieldLayoutVAlign {
26
  xfaFieldLayoutVAlignTop,
27
  xfaFieldLayoutVAlignMiddle,
28
  xfaFieldLayoutVAlignBottom
29
};
30
31
class XFAFieldLayoutInfo {
32
public:
33
34
  XFAFieldLayoutInfo(XFAFieldLayoutHAlign hAlignA,
35
         XFAFieldLayoutVAlign vAlignA);
36
37
  XFAFieldLayoutHAlign hAlign;
38
  XFAFieldLayoutVAlign vAlign;
39
};
40
41
//------------------------------------------------------------------------
42
43
enum XFAFieldPictureSubtype {
44
  xfaFieldPictureDateTime,
45
  xfaFieldPictureNumeric,
46
  xfaFieldPictureText
47
};
48
49
class XFAFieldPictureInfo {
50
public:
51
52
  XFAFieldPictureInfo(XFAFieldPictureSubtype subtypeA, GString *formatA);
53
  ~XFAFieldPictureInfo();
54
55
  XFAFieldPictureSubtype subtype;
56
  GString *format;    // picture format string
57
};
58
59
//------------------------------------------------------------------------
60
61
class XFAFieldBarcodeInfo {
62
public:
63
64
  XFAFieldBarcodeInfo(GString *barcodeTypeA, double wideNarrowRatioA,
65
          double moduleWidthA, double moduleHeightA,
66
          int dataLengthA, int errorCorrectionLevelA,
67
          GString *textLocationA);
68
  ~XFAFieldBarcodeInfo();
69
70
  GString *barcodeType;
71
  double wideNarrowRatio;
72
  double moduleWidth;
73
  double moduleHeight;
74
  int dataLength;
75
  int errorCorrectionLevel;
76
  GString *textLocation;
77
};
78
79
//------------------------------------------------------------------------
80
81
class XFAField {
82
public:
83
84
  XFAField(GString *nameA, GString *fullNameA, GString *valueA,
85
     XFAFieldLayoutInfo *layoutInfoA,
86
     XFAFieldPictureInfo *pictureInfoA,
87
     XFAFieldBarcodeInfo *barcodeInfoA);
88
  ~XFAField();
89
90
  // Get the field's value, or NULL if it doesn't have a value.  Sets
91
  // *[length] to the length of the Unicode string.
92
0
  GString *getValue() { return value; }
93
94
  // Return a pointer to the field's picture formatting info object,
95
  // or NULL if the field doesn't have picture formatting.
96
0
  XFAFieldPictureInfo *getPictureInfo() { return pictureInfo; }
97
98
  // Return a pointer to the field's layout info object, or NULL if
99
  // the field doesn't have layout info.
100
0
  XFAFieldLayoutInfo *getLayoutInfo() { return layoutInfo; }
101
102
  // Return a pointer to the field's barcode info object, or NULL if
103
  // the field isn't a barcode.
104
0
  XFAFieldBarcodeInfo *getBarcodeInfo() { return barcodeInfo; }
105
106
private:
107
108
  friend class XFAScanner;
109
110
  GString *name;    // UTF-8
111
  GString *fullName;    // UTF-8
112
  GString *value;   // UTF-8
113
  XFAFieldLayoutInfo *layoutInfo;
114
  XFAFieldPictureInfo *pictureInfo;
115
  XFAFieldBarcodeInfo *barcodeInfo;
116
};
117
118
//------------------------------------------------------------------------
119
120
class XFAScanner {
121
public:
122
123
  static XFAScanner *load(Object *xfaObj);
124
125
  virtual ~XFAScanner();
126
127
  // Find an XFA field matchined the specified AcroForm field name.
128
  // Returns NULL if there is no matching field.
129
  XFAField *findField(GString *acroFormFieldName);
130
131
private:
132
133
  XFAScanner();
134
  static GString *readXFAStreams(Object *xfaObj);
135
  GHash *scanFormValues(ZxElement *xmlRoot);
136
  void scanFormNode(ZxElement *elem, GString *fullName,
137
        GHash *formValues);
138
  void scanNode(ZxElement *elem,
139
    GString *parentName, GString *parentFullName,
140
    GHash *nameIdx, GHash *fullNameIdx,
141
    GString *exclGroupName, ZxElement *xmlRoot,
142
    GHash *formValues);
143
  void scanField(ZxElement *elem, GString *name, GString *fullName,
144
     GString *exclGroupName, ZxElement *xmlRoot,
145
     GHash *formValues);
146
  GString *getFieldValue(ZxElement *elem, GString *name,
147
       GString *fullName, GString *exclGroupName,
148
       ZxElement *xmlRoot, GHash *formValues);
149
  GString *getDatasetsValue(char *partName, ZxElement *elem);
150
  XFAFieldLayoutInfo *getFieldLayoutInfo(ZxElement *elem);
151
  XFAFieldPictureInfo *getFieldPictureInfo(ZxElement *elem);
152
  XFAFieldBarcodeInfo *getFieldBarcodeInfo(ZxElement *elem);
153
  double getMeasurement(GString *s);
154
  GString *getNodeName(ZxElement *elem);
155
  GString *getNodeFullName(ZxElement *elem);
156
  GBool nodeIsBindGlobal(ZxElement *elem);
157
  GBool nodeIsBindNone(ZxElement *elem);
158
159
  GHash *fields;    // [XFAField]
160
};
161
162
#endif