This repository has been archived by the owner on Nov 9, 2017. It is now read-only.
/
Annot.h
161 lines (127 loc) · 4.46 KB
/
Annot.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
//========================================================================
//
// Annot.h
//
// Copyright 2000-2003 Glyph & Cog, LLC
//
//========================================================================
#ifndef ANNOT_H
#define ANNOT_H
#ifdef USE_GCC_PRAGMAS
#pragma interface
#endif
class XRef;
class Gfx;
class Catalog;
class CharCodeToUnicode;
class GfxFont;
class GfxFontDict;
class FormWidget;
//------------------------------------------------------------------------
// AnnotBorderStyle
//------------------------------------------------------------------------
enum AnnotBorderType {
annotBorderSolid,
annotBorderDashed,
annotBorderBeveled,
annotBorderInset,
annotBorderUnderlined
};
class AnnotBorderStyle {
public:
AnnotBorderStyle(AnnotBorderType typeA, double widthA,
double *dashA, int dashLengthA,
double rA, double gA, double bA);
~AnnotBorderStyle();
AnnotBorderType getType() { return type; }
double getWidth() { return width; }
void getDash(double **dashA, int *dashLengthA)
{ *dashA = dash; *dashLengthA = dashLength; }
void getColor(double *rA, double *gA, double *bA)
{ *rA = r; *gA = g; *bA = b; }
private:
AnnotBorderType type;
double width;
double *dash;
int dashLength;
double r, g, b;
};
//------------------------------------------------------------------------
// Annot
//------------------------------------------------------------------------
class Annot {
public:
Annot(XRef *xrefA, Dict *acroForm, Dict *dict, Catalog *catalog);
Annot(XRef *xrefA, Dict *acroForm, Dict *dict, const Ref& aref, Catalog *catalog);
~Annot();
GBool isOk() { return ok; }
void draw(Gfx *gfx, GBool printing);
// Get appearance object.
Object *getAppearance(Object *obj) { return appearance.fetch(xref, obj); }
GBool textField() { return isTextField; }
AnnotBorderStyle *getBorderStyle () { return borderStyle; }
GBool match(Ref *refA)
{ return ref.num == refA->num && ref.gen == refA->gen; }
void generateFieldAppearance(Dict *field, Dict *annot, Dict *acroForm);
double getXMin() { return xMin; }
double getYMin() { return yMin; }
double getFontSize() { return fontSize; }
private:
void setColor(Array *a, GBool fill, int adjust);
void drawText(GooString *text, GooString *da, GfxFontDict *fontDict,
GBool multiline, int comb, int quadding,
GBool txField, GBool forceZapfDingbats,
GBool password=false);
void drawListBox(GooString **text, GBool *selection,
int nOptions, int topIdx,
GooString *da, GfxFontDict *fontDict, GBool quadding);
void getNextLine(GooString *text, int start,
GfxFont *font, double fontSize, double wMax,
int *end, double *width, int *next);
void drawCircle(double cx, double cy, double r, GBool fill);
void drawCircleTopLeft(double cx, double cy, double r);
void drawCircleBottomRight(double cx, double cy, double r);
void readArrayNum(Object *pdfArray, int key, double *value);
// write vStr[i:j[ in appearBuf
void writeTextString (GooString *text, GooString *appearBuf, int *i, int j, CharCodeToUnicode *ccToUnicode, GBool password);
void initialize (XRef *xrefA, Dict *acroForm, Dict *dict, Catalog *catalog);
XRef *xref; // the xref table for this PDF file
Ref ref; // object ref identifying this annotation
FormWidget *widget; // FormWidget object for this annotation
GooString *type; // annotation type
Object appearance; // a reference to the Form XObject stream
// for the normal appearance
GooString *appearBuf;
Guint flags;
double xMin, yMin, // annotation rectangle
xMax, yMax;
AnnotBorderStyle *borderStyle;
double fontSize;
GBool ok;
GBool regen, isTextField;
GBool isMultiline, isListbox;
bool hasRef;
bool hidden;
};
//------------------------------------------------------------------------
// Annots
//------------------------------------------------------------------------
class Annots {
public:
// Build a list of Annot objects.
Annots(XRef *xref, Catalog *catalog, Object *annotsObj);
~Annots();
// Iterate through list of annotations.
int getNumAnnots() { return nAnnots; }
Annot *getAnnot(int i) { return annots[i]; }
// (Re)generate the appearance streams for all annotations belonging
// to a form field.
void generateAppearances(Dict *acroForm);
private:
void scanFieldAppearances(Dict *node, Ref *ref, Dict *parent,
Dict *acroForm);
Annot *findAnnot(Ref *ref);
Annot **annots;
int nAnnots;
};
#endif