1 //========================================================================
2 //
3 // Annot.h
4 //
5 // Copyright 2000-2003 Glyph & Cog, LLC
6 //
7 //========================================================================
8 
9 //========================================================================
10 //
11 // Modified under the Poppler project - http://poppler.freedesktop.org
12 //
13 // All changes made under the Poppler project to this file are licensed
14 // under GPL version 2 or later
15 //
16 // Copyright (C) 2006 Scott Turner <scotty1024@mac.com>
17 // Copyright (C) 2007, 2008 Julien Rebetez <julienr@svn.gnome.org>
18 // Copyright (C) 2007-2010 Carlos Garcia Campos <carlosgc@gnome.org>
19 // Copyright (C) 2007, 2008 Iñigo Martínez <inigomartinez@gmail.com>
20 // Copyright (C) 2008 Michael Vrable <mvrable@cs.ucsd.edu>
21 // Copyright (C) 2008 Hugo Mercier <hmercier31@gmail.com>
22 // Copyright (C) 2008 Pino Toscano <pino@kde.org>
23 // Copyright (C) 2008 Tomas Are Haavet <tomasare@gmail.com>
24 // Copyright (C) 2009, 2010 Albert Astals Cid <aacid@kde.org>
25 //
26 // To see a description of the changes please see the Changelog file that
27 // came with your tarball or type make ChangeLog if you are building from git
28 //
29 //========================================================================
30 
31 #ifndef ANNOT_H
32 #define ANNOT_H
33 
34 #ifdef USE_GCC_PRAGMAS
35 #pragma interface
36 #endif
37 
38 class XRef;
39 class Gfx;
40 class Catalog;
41 class CharCodeToUnicode;
42 class GfxFont;
43 class GfxFontDict;
44 class Form;
45 class FormWidget;
46 class PDFRectangle;
47 class Movie;
48 class LinkAction;
49 class OCGs;
50 class Sound;
51 
52 enum AnnotLineEndingStyle {
53   annotLineEndingSquare,        // Square
54   annotLineEndingCircle,        // Circle
55   annotLineEndingDiamond,       // Diamond
56   annotLineEndingOpenArrow,     // OpenArrow
57   annotLineEndingClosedArrow,   // ClosedArrow
58   annotLineEndingNone,          // None
59   annotLineEndingButt,          // Butt
60   annotLineEndingROpenArrow,    // ROpenArrow
61   annotLineEndingRClosedArrow,  // RClosedArrow
62   annotLineEndingSlash          // Slash
63 };
64 
65 enum AnnotExternalDataType {
66   annotExternalDataMarkupUnknown,
67   annotExternalDataMarkup3D       // Markup3D
68 };
69 
70 //------------------------------------------------------------------------
71 // AnnotCoord
72 //------------------------------------------------------------------------
73 
74 class AnnotCoord {
75 public:
76 
AnnotCoord()77   AnnotCoord() : x(0), y(0) { }
AnnotCoord(double _x,double _y)78   AnnotCoord(double _x, double _y) : x(_x), y(_y) { }
79 
getX()80   double getX() const { return x; }
getY()81   double getY() const { return y; }
82 
83 protected:
84 
85   double x, y;
86 };
87 
88 //------------------------------------------------------------------------
89 // AnnotPath
90 //------------------------------------------------------------------------
91 
92 class AnnotPath {
93 public:
94   AnnotPath();
95   AnnotPath(Array *array);
96   AnnotPath(AnnotCoord **coords, int coordLength);
97   ~AnnotPath();
98 
99   double getX(int coord) const;
100   double getY(int coord) const;
101   AnnotCoord *getCoord(int coord) const;
getCoordsLength()102   int getCoordsLength() const { return coordsLength; }
103 protected:
104   AnnotCoord **coords;
105   int coordsLength;
106 
107   void parsePathArray(Array *array);
108 };
109 
110 //------------------------------------------------------------------------
111 // AnnotCalloutLine
112 //------------------------------------------------------------------------
113 
114 class AnnotCalloutLine {
115 public:
116 
117   AnnotCalloutLine(double x1, double y1, double x2, double y2);
~AnnotCalloutLine()118   virtual ~AnnotCalloutLine() { }
119 
getX1()120   double getX1() const { return coord1.getX(); }
getY1()121   double getY1() const { return coord1.getY(); }
getX2()122   double getX2() const { return coord2.getX(); }
getY2()123   double getY2() const { return coord2.getY(); }
124 
125 protected:
126 
127   AnnotCoord coord1, coord2;
128 };
129 
130 //------------------------------------------------------------------------
131 // AnnotCalloutMultiLine
132 //------------------------------------------------------------------------
133 
134 class AnnotCalloutMultiLine: public AnnotCalloutLine {
135 public:
136 
137   AnnotCalloutMultiLine(double x1, double y1, double x2, double y2,
138     double x3, double y3);
139 
getX3()140   double getX3() const { return coord3.getX(); }
getY3()141   double getY3() const { return coord3.getY(); }
142 
143 protected:
144 
145   AnnotCoord coord3;
146 };
147 
148 //------------------------------------------------------------------------
149 // AnnotBorderEffect
150 //------------------------------------------------------------------------
151 
152 class AnnotBorderEffect {
153 public:
154 
155   enum AnnotBorderEffectType {
156     borderEffectNoEffect, // S
157     borderEffectCloudy    // C
158   };
159 
160   AnnotBorderEffect(Dict *dict);
161 
getEffectType()162   AnnotBorderEffectType getEffectType() const { return effectType; }
getIntensity()163   double getIntensity() const { return intensity; }
164 
165 private:
166 
167   AnnotBorderEffectType effectType; // S  (Default S)
168   double intensity;                 // I  (Default 0)
169 };
170 
171 //------------------------------------------------------------------------
172 // AnnotQuadrilateral
173 //------------------------------------------------------------------------
174 
175 class AnnotQuadrilaterals {
176   class AnnotQuadrilateral {
177   public:
178     AnnotQuadrilateral(double x1, double y1, double x2, double y2, double x3,
179       double y3, double x4, double y4);
180 
181     AnnotCoord coord1, coord2, coord3, coord4;
182   };
183 
184 public:
185 
186   AnnotQuadrilaterals(Array *array, PDFRectangle *rect);
187   ~AnnotQuadrilaterals();
188 
189   double getX1(int quadrilateral);
190   double getY1(int quadrilateral);
191   double getX2(int quadrilateral);
192   double getY2(int quadrilateral);
193   double getX3(int quadrilateral);
194   double getY3(int quadrilateral);
195   double getX4(int quadrilateral);
196   double getY4(int quadrilateral);
getQuadrilateralsLength()197   int getQuadrilateralsLength() const { return quadrilateralsLength; }
198 protected:
199 
200   AnnotQuadrilateral** quadrilaterals;
201   int quadrilateralsLength;
202 };
203 
204 //------------------------------------------------------------------------
205 // AnnotBorder
206 //------------------------------------------------------------------------
207 
208 class AnnotBorder {
209 public:
210   enum AnnotBorderType {
211     typeUnknown,
212     typeArray,
213     typeBS
214   };
215 
216   enum AnnotBorderStyle {
217     borderSolid,      // Solid
218     borderDashed,     // Dashed
219     borderBeveled,    // Beveled
220     borderInset,      // Inset
221     borderUnderlined  // Underlined
222   };
223 
224   AnnotBorder();
225   virtual ~AnnotBorder();
226 
getType()227   virtual AnnotBorderType getType() const { return type; }
getWidth()228   virtual double getWidth() const { return width; }
getDashLength()229   virtual int getDashLength() const { return dashLength; }
getDash()230   virtual double *getDash() const { return dash; }
getStyle()231   virtual AnnotBorderStyle getStyle() const { return style; }
232 
233 protected:
234   AnnotBorderType type;
235   double width;
236   int dashLength;
237   double *dash;
238   AnnotBorderStyle style;
239 };
240 
241 //------------------------------------------------------------------------
242 // AnnotBorderArray
243 //------------------------------------------------------------------------
244 
245 class AnnotBorderArray: public AnnotBorder {
246 public:
247   AnnotBorderArray();
248   AnnotBorderArray(Array *array);
249 
getHorizontalCorner()250   double getHorizontalCorner() const { return horizontalCorner; }
getVerticalCorner()251   double getVerticalCorner() const { return verticalCorner; }
252 
253 protected:
254   static const int DASH_LIMIT = 10; // implementation note 82 in Appendix H.
255   double horizontalCorner;          // (Default 0)
256   double verticalCorner;            // (Default 0)
257   // double width;                  // (Default 1)  (inherited from AnnotBorder)
258 };
259 
260 //------------------------------------------------------------------------
261 // AnnotBorderBS
262 //------------------------------------------------------------------------
263 
264 class AnnotBorderBS: public AnnotBorder {
265 public:
266 
267   AnnotBorderBS();
268   AnnotBorderBS(Dict *dict);
269 
270 private:
271   // double width;           // W  (Default 1)   (inherited from AnnotBorder)
272   // AnnotBorderStyle style; // S  (Default S)   (inherited from AnnotBorder)
273   // double *dash;           // D  (Default [3]) (inherited from AnnotBorder)
274 };
275 
276 //------------------------------------------------------------------------
277 // AnnotColor
278 //------------------------------------------------------------------------
279 
280 class AnnotColor {
281 public:
282 
283   enum AnnotColorSpace {
284     colorTransparent = 0,
285     colorGray        = 1,
286     colorRGB         = 3,
287     colorCMYK        = 4
288   };
289 
290   AnnotColor();
291   AnnotColor(double gray);
292   AnnotColor(double r, double g, double b);
293   AnnotColor(double c, double m, double y, double k);
294   AnnotColor(Array *array, int adjust = 0);
295 
getSpace()296   AnnotColorSpace getSpace() const { return (AnnotColorSpace) length; }
getValues()297   const double *getValues() const { return values; }
298 
299 private:
300 
301   double values[4];
302   int length;
303 };
304 
305 //------------------------------------------------------------------------
306 // AnnotBorderStyle
307 //------------------------------------------------------------------------
308 
309 enum AnnotBorderType {
310   annotBorderSolid,
311   annotBorderDashed,
312   annotBorderBeveled,
313   annotBorderInset,
314   annotBorderUnderlined
315 };
316 
317 class AnnotBorderStyle {
318 public:
319 
320   AnnotBorderStyle(AnnotBorderType typeA, double widthA,
321 		   double *dashA, int dashLengthA,
322 		   double rA, double gA, double bA);
323   ~AnnotBorderStyle();
324 
getType()325   AnnotBorderType getType() { return type; }
getWidth()326   double getWidth() { return width; }
getDash(double ** dashA,int * dashLengthA)327   void getDash(double **dashA, int *dashLengthA)
328     { *dashA = dash; *dashLengthA = dashLength; }
getColor(double * rA,double * gA,double * bA)329   void getColor(double *rA, double *gA, double *bA)
330     { *rA = r; *gA = g; *bA = b; }
331 
332 private:
333 
334   AnnotBorderType type;
335   double width;
336   double *dash;
337   int dashLength;
338   double r, g, b;
339 };
340 
341 //------------------------------------------------------------------------
342 // AnnotIconFit
343 //------------------------------------------------------------------------
344 
345 class AnnotIconFit {
346 public:
347 
348   enum AnnotIconFitScaleWhen {
349     scaleAlways,  // A
350     scaleBigger,  // B
351     scaleSmaller, // S
352     scaleNever    // N
353   };
354 
355   enum AnnotIconFitScale {
356     scaleAnamorphic,  // A
357     scaleProportional // P
358   };
359 
360   AnnotIconFit(Dict *dict);
361 
getScaleWhen()362   AnnotIconFitScaleWhen getScaleWhen() { return scaleWhen; }
getScale()363   AnnotIconFitScale getScale() { return scale; }
getLeft()364   double getLeft() { return left; }
getBottom()365   double getBottom() { return bottom; }
getFullyBounds()366   bool getFullyBounds() { return fullyBounds; }
367 
368 protected:
369 
370   AnnotIconFitScaleWhen scaleWhen;  // SW (Default A)
371   AnnotIconFitScale scale;          // S  (Default P)
372   double left;                      // A  (Default [0.5 0.5]
373   double bottom;                    // Only if scale is P
374   bool fullyBounds;                 // FB (Default false)
375 };
376 
377 //------------------------------------------------------------------------
378 // AnnotAppearance
379 //------------------------------------------------------------------------
380 
381 class AnnotAppearance {
382 public:
383 
384   enum AnnotAppearanceType {
385     appearNormal,
386     appearRollover,
387     appearDown
388   };
389 
390   AnnotAppearance(Dict *dict);
391 };
392 
393 //------------------------------------------------------------------------
394 // AnnotAppearanceCharacs
395 //------------------------------------------------------------------------
396 
397 class AnnotAppearanceCharacs {
398 public:
399 
400   enum AnnotAppearanceCharacsTextPos {
401     captionNoIcon,    // 0
402     captionNoCaption, // 1
403     captionBelow,     // 2
404     captionAbove,     // 3
405     captionRight,     // 4
406     captionLeft,      // 5
407     captionOverlaid   // 6
408   };
409 
410   AnnotAppearanceCharacs(Dict *dict);
411   ~AnnotAppearanceCharacs();
412 
getRotation()413   int getRotation() { return rotation; }
getBorderColor()414   AnnotColor *getBorderColor() { return borderColor; }
getBackColor()415   AnnotColor *getBackColor() { return backColor; }
getNormalCaption()416   GooString *getNormalCaption() { return normalCaption; }
getRolloverCaption()417   GooString *getRolloverCaption() { return rolloverCaption; }
getAlternateCaption()418   GooString *getAlternateCaption() { return alternateCaption; }
getIconFit()419   AnnotIconFit *getIconFit() { return iconFit; }
getPosition()420   AnnotAppearanceCharacsTextPos getPosition() { return position; }
421 
422 protected:
423 
424   int rotation;                           // R  (Default 0)
425   AnnotColor *borderColor;                // BC
426   AnnotColor *backColor;                  // BG
427   GooString *normalCaption;               // CA
428   GooString *rolloverCaption;             // RC
429   GooString *alternateCaption;            // AC
430   // I
431   // RI
432   // IX
433   AnnotIconFit *iconFit;                  // IF
434   AnnotAppearanceCharacsTextPos position; // TP (Default 0)
435 };
436 
437 //------------------------------------------------------------------------
438 // Annot
439 //------------------------------------------------------------------------
440 
441 class Annot {
442 public:
443   enum AnnotFlag {
444     flagUnknown        = 0x0000,
445     flagInvisible      = 0x0001,
446     flagHidden         = 0x0002,
447     flagPrint          = 0x0004,
448     flagNoZoom         = 0x0008,
449     flagNoRotate       = 0x0010,
450     flagNoView         = 0x0020,
451     flagReadOnly       = 0x0040,
452     flagLocked         = 0x0080,
453     flagToggleNoView   = 0x0100,
454     flagLockedContents = 0x0200
455   };
456 
457   enum AnnotSubtype {
458     typeUnknown,        //                 0
459     typeText,           // Text            1
460     typeLink,           // Link            2
461     typeFreeText,       // FreeText        3
462     typeLine,           // Line            4
463     typeSquare,         // Square          5
464     typeCircle,         // Circle          6
465     typePolygon,        // Polygon         7
466     typePolyLine,       // PolyLine        8
467     typeHighlight,      // Highlight       9
468     typeUnderline,      // Underline      10
469     typeSquiggly,       // Squiggly       11
470     typeStrikeOut,      // StrikeOut      12
471     typeStamp,          // Stamp          13
472     typeCaret,          // Caret          14
473     typeInk,            // Ink            15
474     typePopup,          // Popup          16
475     typeFileAttachment, // FileAttachment 17
476     typeSound,          // Sound          18
477     typeMovie,          // Movie          19
478     typeWidget,         // Widget         20
479     typeScreen,         // Screen         21
480     typePrinterMark,    // PrinterMark    22
481     typeTrapNet,        // TrapNet        23
482     typeWatermark,      // Watermark      24
483     type3D              // 3D             25
484   };
485 
486   Annot(XRef *xrefA, PDFRectangle *rectA, Catalog *catalog);
487   Annot(XRef *xrefA, Dict *dict, Catalog *catalog);
488   Annot(XRef *xrefA, Dict *dict, Catalog *catalog, Object *obj);
489   virtual ~Annot();
isOk()490   GBool isOk() { return ok; }
491 
492   virtual void draw(Gfx *gfx, GBool printing);
493   // Get appearance object.
getAppearance(Object * obj)494   Object *getAppearance(Object *obj) { return appearance.fetch(xref, obj); }
495 
match(Ref * refA)496   GBool match(Ref *refA)
497     { return ref.num == refA->num && ref.gen == refA->gen; }
498 
499   double getXMin();
500   double getYMin();
501 
getFontSize()502   double getFontSize() { return fontSize; }
503 
504   // Sets the annot contents to new_content
505   // new_content should never be NULL
506   void setContents(GooString *new_content);
507 
508   // The annotation takes the ownership of
509   // new_color.
510   void setColor(AnnotColor *new_color);
511 
512   void setPage(Ref *pageRef, int pageIndex);
513 
514   // getters
getXRef()515   XRef *getXRef() const { return xref; }
getRef()516   Ref getRef() const { return ref; }
getType()517   AnnotSubtype getType() const { return type; }
getRect()518   PDFRectangle *getRect() const { return rect; }
getContents()519   GooString *getContents() const { return contents; }
getPageNum()520   int getPageNum() const { return page; }
getName()521   GooString *getName() const { return name; }
getModified()522   GooString *getModified() const { return modified; }
getFlags()523   Guint getFlags() const { return flags; }
524   /*Dict *getAppearDict() const { return appearDict; }*/
getAppearState()525   GooString *getAppearState() const { return appearState; }
getBorder()526   AnnotBorder *getBorder() const { return border; }
getColor()527   AnnotColor *getColor() const { return color; }
getTreeKey()528   int getTreeKey() const { return treeKey; }
529 
getId()530   int getId() { return ref.num; }
531 
532 private:
533   void readArrayNum(Object *pdfArray, int key, double *value);
534   // write vStr[i:j[ in appearBuf
535 
536   void initialize (XRef *xrefA, Dict *dict, Catalog *catalog);
537 
538 
539 protected:
540   void setColor(AnnotColor *color, GBool fill);
541   void drawCircle(double cx, double cy, double r, GBool fill);
542   void drawCircleTopLeft(double cx, double cy, double r);
543   void drawCircleBottomRight(double cx, double cy, double r);
544   void createForm(double *bbox, GBool transparencyGroup, Object *resDict, Object *aStream);
545   void createResourcesDict(char *formName, Object *formStream, char *stateName,
546 			   double opacity, char *blendMode, Object *resDict);
547   GBool isVisible(GBool printing);
548 
549   // Updates the field key of the annotation dictionary
550   // and sets M to the current time
551   void update(const char *key, Object *value);
552 
553   Object annotObj;
554 
555   // required data
556   AnnotSubtype type;                // Annotation type
557   PDFRectangle *rect;               // Rect
558 
559   // optional data
560   GooString *contents;              // Contents
561   int       page;                   // P
562   GooString *name;                  // NM
563   GooString *modified;              // M
564   Guint flags;                      // F (must be a 32 bit unsigned int)
565   //Dict *appearDict;                 // AP (should be correctly parsed)
566   Ref appRef;                       //the reference to the indirect appearance object in XRef
567   Object appearance;     // a reference to the Form XObject stream
568                          //   for the normal appearance
569   GooString *appearState;           // AS
570   int treeKey;                      // Struct Parent;
571   OCGs *optContentConfig;           // Optional content config
572   Object oc;                        // OC
573 
574   XRef *xref;			// the xref table for this PDF file
575   Ref ref;                      // object ref identifying this annotation
576   GooString *appearBuf;
577   AnnotBorder *border;          // Border, BS
578   AnnotColor *color;            // C
579   double fontSize;
580   GBool ok;
581 
582   bool hasRef;
583 };
584 
585 //------------------------------------------------------------------------
586 // AnnotPopup
587 //------------------------------------------------------------------------
588 
589 class AnnotPopup: public Annot {
590 public:
591   AnnotPopup(XRef *xrefA, PDFRectangle *rect, Catalog *catalog);
592   AnnotPopup(XRef *xrefA, Dict *dict, Catalog *catalog, Object *obj);
593   ~AnnotPopup();
594 
getParent(Object * obj)595   Object *getParent(Object *obj) { return parent.fetch (xref, obj); }
getParentNF(Object * obj)596   Object *getParentNF(Object *obj) { return &parent; }
597   void setParent(Object *parentA);
598   void setParent(Annot *parentA);
getOpen()599   GBool getOpen() const { return open; }
600   void setOpen(GBool openA);
601 
602 protected:
603   void initialize(XRef *xrefA, Dict *dict, Catalog *catalog);
604 
605   Object parent; // Parent
606   GBool open;   // Open
607 };
608 
609 //------------------------------------------------------------------------
610 // AnnotMarkup
611 //------------------------------------------------------------------------
612 
613 class AnnotMarkup: public Annot {
614 public:
615   enum  AnnotMarkupReplyType {
616     replyTypeR,     // R
617     replyTypeGroup  // Group
618   };
619 
620   AnnotMarkup(XRef *xrefA, PDFRectangle *rect, Catalog *catalog);
621   AnnotMarkup(XRef *xrefA, Dict *dict, Catalog *catalog, Object *obj);
622   virtual ~AnnotMarkup();
623 
624   // getters
getLabel()625   GooString *getLabel() const { return label; }
getPopup()626   AnnotPopup *getPopup() const { return popup; }
getOpacity()627   double getOpacity() const { return opacity; }
628   // getRC
getDate()629   GooString *getDate() const { return date; }
getInReplyToID()630   int getInReplyToID() const { return inReplyTo.num; }
getSubject()631   GooString *getSubject() const { return subject; }
getReplyTo()632   AnnotMarkupReplyType getReplyTo() const { return replyTo; }
getExData()633   AnnotExternalDataType getExData() const { return exData; }
634 
635   // The annotation takes the ownership of new_popup
636   void setPopup(AnnotPopup *new_popup);
637   void setLabel(GooString *new_label);
638   void setOpacity(double opacityA);
639 
640 protected:
641   GooString *label;             // T            (Default autor)
642   AnnotPopup *popup;            // Popup
643   double opacity;               // CA           (Default 1.0)
644   // RC
645   GooString *date;              // CreationDate
646   Ref inReplyTo;                // IRT
647   GooString *subject;           // Subj
648   AnnotMarkupReplyType replyTo; // RT           (Default R)
649   // this object is overrided by the custom intent fields defined in some
650   // annotation types.
651   //GooString *intent;          // IT
652   AnnotExternalDataType exData; // ExData
653 
654 private:
655   void initialize(XRef *xrefA, Dict *dict, Catalog *catalog, Object *obj);
656 };
657 
658 //------------------------------------------------------------------------
659 // AnnotText
660 //------------------------------------------------------------------------
661 
662 class AnnotText: public AnnotMarkup {
663 public:
664   enum AnnotTextState {
665     stateUnknown,
666     // Marked state model
667     stateMarked,    // Marked
668     stateUnmarked,  // Unmarked
669     // Review state model
670     stateAccepted,  // Accepted
671     stateRejected,  // Rejected
672     stateCancelled, // Cancelled
673     stateCompleted, // Completed
674     stateNone       // None
675   };
676 
677   AnnotText(XRef *xrefA, PDFRectangle *rect, Catalog *catalog);
678   AnnotText(XRef *xrefA, Dict *dict, Catalog *catalog, Object *obj);
679   ~AnnotText();
680 
681   virtual void draw(Gfx *gfx, GBool printing);
682 
683   // getters
getOpen()684   GBool getOpen() const { return open; }
getIcon()685   GooString *getIcon() const { return icon; }
getState()686   AnnotTextState getState() const { return state; }
687 
688   void setOpen(GBool openA);
689   void setIcon(GooString *new_icon);
690 
691 private:
692 
693   void initialize(XRef *xrefA, Catalog *catalog, Dict *dict);
694 
695   GBool open;                       // Open       (Default false)
696   GooString *icon;                  // Name       (Default Note)
697   AnnotTextState state;             // State      (Default Umarked if
698                                     //             StateModel Marked
699                                     //             None if StareModel Review)
700 };
701 
702 //------------------------------------------------------------------------
703 // AnnotMovie
704 //------------------------------------------------------------------------
705 
706 
707 
708 class AnnotMovie: public Annot {
709  public:
710   AnnotMovie(XRef *xrefA, PDFRectangle *rect, Movie *movieA, Catalog *catalog);
711   AnnotMovie(XRef *xrefA, Dict *dict, Catalog *catalog, Object *obj);
712   ~AnnotMovie();
713 
714   virtual void draw(Gfx *gfx, GBool printing);
715 
getTitle()716   GooString* getTitle() { return title; }
getMovie()717   Movie* getMovie() { return movie; }
718 
719  private:
720   void initialize(XRef *xrefA, Catalog *catalog, Dict *dict);
721 
722   GooString* title;      // T
723   Movie* movie;          // Movie + A
724 };
725 
726 
727 //------------------------------------------------------------------------
728 // AnnotScreen
729 //------------------------------------------------------------------------
730 
731 class AnnotScreen: public Annot {
732  public:
733 
734   AnnotScreen(XRef *xrefA, PDFRectangle *rect, Catalog *catalog);
735   AnnotScreen(XRef *xrefA, Dict *dict, Catalog *catalog, Object *obj);
736   ~AnnotScreen();
737 
getTitle()738   GooString* getTitle() { return title; }
739 
getAppearCharacs()740   AnnotAppearanceCharacs *getAppearCharacs() { return appearCharacs; }
getAction()741   LinkAction* getAction() { return action; }
getAdditionActions()742   Object* getAdditionActions() { return &additionAction; }
743 
744  private:
745   void initialize(XRef *xrefA, Catalog *catalog, Dict *dict);
746 
747 
748   GooString* title;                      // T
749 
750   AnnotAppearanceCharacs* appearCharacs; // MK
751 
752   LinkAction *action;                    // A
753   Object additionAction;                 // AA
754 };
755 
756 //------------------------------------------------------------------------
757 // AnnotLink
758 //------------------------------------------------------------------------
759 
760 class AnnotLink: public Annot {
761 public:
762 
763   enum AnnotLinkEffect {
764     effectNone,     // N
765     effectInvert,   // I
766     effectOutline,  // O
767     effectPush      // P
768   };
769 
770   AnnotLink(XRef *xrefA, PDFRectangle *rect, Catalog *catalog);
771   AnnotLink(XRef *xrefA, Dict *dict, Catalog *catalog, Object *obj);
772   virtual ~AnnotLink();
773 
774   virtual void draw(Gfx *gfx, GBool printing);
775 
776   // getters
getActionDict()777   Dict *getActionDict() const { return actionDict; }
getDest()778   Object *getDest() { return &dest; }
getLinkEffect()779   AnnotLinkEffect getLinkEffect() const { return linkEffect; }
getUriAction()780   Dict *getUriAction() const { return uriAction; }
getQuadrilaterals()781   AnnotQuadrilaterals *getQuadrilaterals() const { return quadrilaterals; }
782 
783 protected:
784 
785   void initialize(XRef *xrefA, Catalog *catalog, Dict *dict);
786 
787   Dict *actionDict;                    // A
788   Object dest;                         // Dest
789   AnnotLinkEffect linkEffect;          // H          (Default I)
790   Dict *uriAction;                     // PA
791 
792   AnnotQuadrilaterals *quadrilaterals; // QuadPoints
793 };
794 
795 //------------------------------------------------------------------------
796 // AnnotFreeText
797 //------------------------------------------------------------------------
798 
799 class AnnotFreeText: public AnnotMarkup {
800 public:
801 
802   enum AnnotFreeTextQuadding {
803     quaddingLeftJustified,  // 0
804     quaddingCentered,       // 1
805     quaddingRightJustified  // 2
806   };
807 
808   enum AnnotFreeTextIntent {
809     intentFreeText,           // FreeText
810     intentFreeTextCallout,    // FreeTextCallout
811     intentFreeTextTypeWriter  // FreeTextTypeWriter
812   };
813 
814   AnnotFreeText(XRef *xrefA, PDFRectangle *rect, GooString *da, Catalog *catalog);
815   AnnotFreeText(XRef *xrefA, Dict *dict, Catalog *catalog, Object *obj);
816   ~AnnotFreeText();
817 
818   // getters
getAppearanceString()819   GooString *getAppearanceString() const { return appearanceString; }
getQuadding()820   AnnotFreeTextQuadding getQuadding() const { return quadding; }
821   // return rc
getStyleString()822   GooString *getStyleString() const { return styleString; }
getCalloutLine()823   AnnotCalloutLine *getCalloutLine() const {  return calloutLine; }
getIntent()824   AnnotFreeTextIntent getIntent() const { return intent; }
getBorderEffect()825   AnnotBorderEffect *getBorderEffect() const { return borderEffect; }
getRectangle()826   PDFRectangle *getRectangle() const { return rectangle; }
getEndStyle()827   AnnotLineEndingStyle getEndStyle() const { return endStyle; }
828 
829 protected:
830 
831   void initialize(XRef *xrefA, Catalog *catalog, Dict *dict);
832 
833   // required
834   GooString *appearanceString;      // DA
835 
836   // optional
837   AnnotFreeTextQuadding quadding;   // Q  (Default 0)
838   // RC
839   GooString *styleString;           // DS
840   AnnotCalloutLine *calloutLine;    // CL
841   AnnotFreeTextIntent intent;       // IT
842   AnnotBorderEffect *borderEffect;  // BE
843   PDFRectangle *rectangle;          // RD
844   // inherited  from Annot
845   // AnnotBorderBS border;          // BS
846   AnnotLineEndingStyle endStyle;    // LE (Default None)
847 };
848 
849 //------------------------------------------------------------------------
850 // AnnotLine
851 //------------------------------------------------------------------------
852 
853 class AnnotLine: public AnnotMarkup {
854 public:
855 
856   enum AnnotLineIntent {
857     intentLineArrow,    // LineArrow
858     intentLineDimension // LineDimension
859   };
860 
861   enum AnnotLineCaptionPos {
862     captionPosInline, // Inline
863     captionPosTop     // Top
864   };
865 
866   AnnotLine(XRef *xrefA, PDFRectangle *rect, PDFRectangle *lRect, Catalog *catalog);
867   AnnotLine(XRef *xrefA, Dict *dict, Catalog *catalog, Object *obj);
868   ~AnnotLine();
869 
870   virtual void draw(Gfx *gfx, GBool printing);
871 
872   // getters
getStartStyle()873   AnnotLineEndingStyle getStartStyle() const { return startStyle; }
getEndStyle()874   AnnotLineEndingStyle getEndStyle() const { return endStyle; }
getInteriorColor()875   AnnotColor *getInteriorColor() const { return interiorColor; }
getLeaderLineLength()876   double getLeaderLineLength() const { return leaderLineLength; }
getLeaderLineExtension()877   double getLeaderLineExtension() const { return leaderLineExtension; }
getCaption()878   bool getCaption() const { return caption; }
getIntent()879   AnnotLineIntent getIntent() const { return intent; }
getLeaderLineOffset()880   double  getLeaderLineOffset() const { return leaderLineOffset; }
getCaptionPos()881   AnnotLineCaptionPos getCaptionPos() const { return captionPos; }
getMeasure()882   Dict *getMeasure() const { return measure; }
getCaptionTextHorizontal()883   double getCaptionTextHorizontal() const { return captionTextHorizontal; }
getCaptionTextVertical()884   double getCaptionTextVertical() const { return captionTextVertical; }
getX1()885   double getX1() const { return coord1->getX(); }
getY1()886   double getY1() const { return coord1->getY(); }
getX2()887   double getX2() const { return coord2->getX(); }
getY2()888   double getY2() const { return coord2->getY(); }
889 
890 protected:
891 
892   void initialize(XRef *xrefA, Catalog *catalog, Dict *dict);
893 
894   // required
895   AnnotCoord *coord1, *coord2;
896 
897   // optional
898   // inherited  from Annot
899   // AnnotBorderBS border;          // BS
900   AnnotLineEndingStyle startStyle;  // LE       (Default [/None /None])
901   AnnotLineEndingStyle endStyle;    //
902   AnnotColor *interiorColor;        // IC
903   double leaderLineLength;          // LL       (Default 0)
904   double leaderLineExtension;       // LLE      (Default 0)
905   bool caption;                     // Cap      (Default false)
906   AnnotLineIntent intent;           // IT
907   double leaderLineOffset;          // LLO
908   AnnotLineCaptionPos captionPos;   // CP       (Default Inline)
909   Dict *measure;                    // Measure
910   double captionTextHorizontal;     // CO       (Default [0, 0])
911   double captionTextVertical;       //
912 };
913 
914 //------------------------------------------------------------------------
915 // AnnotTextMarkup
916 //------------------------------------------------------------------------
917 
918 class AnnotTextMarkup: public AnnotMarkup {
919 public:
920 
921   AnnotTextMarkup(XRef *xrefA, PDFRectangle *rect, AnnotSubtype subType,
922 		  AnnotQuadrilaterals *quadPoints, Catalog *catalog);
923   AnnotTextMarkup(XRef *xrefA, Dict *dict, Catalog *catalog, Object *obj);
924   virtual ~AnnotTextMarkup();
925 
926   virtual void draw(Gfx *gfx, GBool printing);
927 
getQuadrilaterals()928   AnnotQuadrilaterals *getQuadrilaterals() const { return quadrilaterals; }
929 
930 protected:
931 
932   void initialize(XRef *xrefA, Catalog *catalog, Dict *dict);
933 
934   AnnotQuadrilaterals *quadrilaterals; // QuadPoints
935 };
936 
937 //------------------------------------------------------------------------
938 // AnnotStamp
939 //------------------------------------------------------------------------
940 
941 class AnnotStamp: public AnnotMarkup {
942 public:
943 
944   AnnotStamp(XRef *xrefA, PDFRectangle *rect, Catalog *catalog);
945   AnnotStamp(XRef *xrefA, Dict *dict, Catalog *catalog, Object *obj);
946   ~AnnotStamp();
947 
948   // getters
getIcon()949   GooString *getIcon() const { return icon; }
950 
951 private:
952 
953   void initialize(XRef *xrefA, Catalog *catalog, Dict *dict);
954 
955   GooString *icon;                  // Name       (Default Draft)
956 };
957 
958 //------------------------------------------------------------------------
959 // AnnotGeometry
960 //------------------------------------------------------------------------
961 
962 class AnnotGeometry: public AnnotMarkup {
963 public:
964 
965   AnnotGeometry(XRef *xrefA, PDFRectangle *rect, AnnotSubtype subType, Catalog *catalog);
966   AnnotGeometry(XRef *xrefA, Dict *dict, Catalog *catalog, Object *obj);
967   ~AnnotGeometry();
968 
969   virtual void draw(Gfx *gfx, GBool printing);
970 
971   // getters
getInteriorColor()972   AnnotColor *getInteriorColor() const { return interiorColor; }
getBorderEffect()973   AnnotBorderEffect *getBorderEffect() const { return borderEffect; }
getGeometryRect()974   PDFRectangle *getGeometryRect() const { return geometryRect; }
975 
976 private:
977 
978   void initialize(XRef *xrefA, Catalog *catalog, Dict *dict);
979 
980   AnnotColor *interiorColor;        // IC
981   AnnotBorderEffect *borderEffect;  // BE
982   PDFRectangle *geometryRect;       // RD (combined with Rect)
983 };
984 
985 //------------------------------------------------------------------------
986 // AnnotPolygon
987 //------------------------------------------------------------------------
988 
989 class AnnotPolygon: public AnnotMarkup {
990 public:
991 
992   enum AnnotPolygonIntent {
993     polygonCloud,      // PolygonCloud
994     polylineDimension, // PolyLineDimension
995     polygonDimension   // PolygonDimension
996   };
997 
998   AnnotPolygon(XRef *xrefA, PDFRectangle *rect, AnnotSubtype subType,
999 	       AnnotPath *path, Catalog *catalog);
1000   AnnotPolygon(XRef *xrefA, Dict *dict, Catalog *catalog, Object *obj);
1001   ~AnnotPolygon();
1002 
1003   // getters
getVertices()1004   AnnotPath *getVertices() const { return vertices; }
getStartStyle()1005   AnnotLineEndingStyle getStartStyle() const { return startStyle; }
getEndStyle()1006   AnnotLineEndingStyle getEndStyle() const { return endStyle; }
getInteriorColor()1007   AnnotColor *getInteriorColor() const { return interiorColor; }
getBorderEffect()1008   AnnotBorderEffect *getBorderEffect() const { return borderEffect; }
getIntent()1009   AnnotPolygonIntent getIntent() const { return intent; }
1010 
1011 private:
1012 
1013   void initialize(XRef *xrefA, Catalog *catalog, Dict *dict);
1014 
1015   // required
1016   AnnotPath *vertices;              // Vertices
1017 
1018   // optional
1019   AnnotLineEndingStyle startStyle;  // LE       (Default [/None /None])
1020   AnnotLineEndingStyle endStyle;    //
1021   // inherited  from Annot
1022   // AnnotBorderBS border;          // BS
1023   AnnotColor *interiorColor;        // IC
1024   AnnotBorderEffect *borderEffect;  // BE
1025   AnnotPolygonIntent intent;        // IT
1026   // Measure
1027 };
1028 
1029 //------------------------------------------------------------------------
1030 // AnnotCaret
1031 //------------------------------------------------------------------------
1032 
1033 class AnnotCaret: public AnnotMarkup {
1034 public:
1035 
1036   enum AnnotCaretSymbol {
1037     symbolNone,     // None
1038     symbolP         // P
1039   };
1040 
1041   AnnotCaret(XRef *xrefA, PDFRectangle *rect, Catalog *catalog);
1042   AnnotCaret(XRef *xrefA, Dict *dict, Catalog *catalog, Object *obj);
1043   ~AnnotCaret();
1044 
1045   // getters
getSymbol()1046   AnnotCaretSymbol getSymbol() const { return symbol; }
getCaretRect()1047   PDFRectangle *getCaretRect() const { return caretRect; }
1048 
1049 private:
1050 
1051   void initialize(XRef *xrefA, Catalog *catalog, Dict *dict);
1052 
1053   AnnotCaretSymbol symbol;       // Sy         (Default None)
1054   PDFRectangle *caretRect;       // RD (combined with Rect)
1055 };
1056 
1057 //------------------------------------------------------------------------
1058 // AnnotInk
1059 //------------------------------------------------------------------------
1060 
1061 class AnnotInk: public AnnotMarkup {
1062 public:
1063 
1064   AnnotInk(XRef *xrefA, PDFRectangle *rect, AnnotPath **paths, int n_paths, Catalog *catalog);
1065   AnnotInk(XRef *xrefA, Dict *dict, Catalog *catalog, Object *obj);
1066   ~AnnotInk();
1067 
1068   // getters
getInkList()1069   AnnotPath **getInkList() const { return inkList; }
getInkListLength()1070   int getInkListLength() const { return inkListLength; }
1071 
1072 private:
1073 
1074   void initialize(XRef *xrefA, Catalog *catalog, Dict *dict);
1075 
1076   // required
1077   AnnotPath **inkList;       // InkList
1078   int inkListLength;
1079 
1080   // optional
1081   // inherited from Annot
1082   // AnnotBorderBS border;  // BS
1083 };
1084 
1085 //------------------------------------------------------------------------
1086 // AnnotFileAttachment
1087 //------------------------------------------------------------------------
1088 
1089 class AnnotFileAttachment: public AnnotMarkup {
1090 public:
1091 
1092   AnnotFileAttachment(XRef *xrefA, PDFRectangle *rect, GooString *filename, Catalog *catalog);
1093   AnnotFileAttachment(XRef *xrefA, Dict *dict, Catalog *catalog, Object *obj);
1094   ~AnnotFileAttachment();
1095 
1096   virtual void draw(Gfx *gfx, GBool printing);
1097 
1098   // getters
getFile()1099   Object *getFile() { return &file; }
getName()1100   GooString *getName() const { return name; }
1101 
1102 private:
1103 
1104   void initialize(XRef *xrefA, Catalog *catalog, Dict *dict);
1105 
1106   // required
1107   Object file;      // FS
1108 
1109   // optional
1110   GooString *name;  // Name
1111 };
1112 
1113 //------------------------------------------------------------------------
1114 // AnnotSound
1115 //------------------------------------------------------------------------
1116 
1117 class AnnotSound: public AnnotMarkup {
1118 public:
1119 
1120   AnnotSound(XRef *xrefA, PDFRectangle *rect, Sound *soundA, Catalog *catalog);
1121   AnnotSound(XRef *xrefA, Dict *dict, Catalog *catalog, Object *obj);
1122   ~AnnotSound();
1123 
1124   virtual void draw(Gfx *gfx, GBool printing);
1125 
1126   // getters
getSound()1127   Sound *getSound() { return sound; }
getName()1128   GooString *getName() const { return name; }
1129 
1130 private:
1131 
1132   void initialize(XRef *xrefA, Catalog *catalog, Dict *dict);
1133 
1134   // required
1135   Sound *sound;                  // Sound
1136 
1137   // optional
1138   GooString *name;               // Name
1139 };
1140 
1141 //------------------------------------------------------------------------
1142 // AnnotWidget
1143 //------------------------------------------------------------------------
1144 
1145 class AnnotWidget: public Annot {
1146 public:
1147 
1148   enum AnnotWidgetHighlightMode {
1149     highlightModeNone,    // N
1150     highlightModeInvert,  // I
1151     highlightModeOutline, // O
1152     highlightModePush     // P,T
1153   };
1154 
1155   AnnotWidget(XRef *xrefA, Dict *dict, Catalog *catalog, Object *obj);
1156   virtual ~AnnotWidget();
1157 
1158   virtual void draw(Gfx *gfx, GBool printing);
1159 
1160   void generateFieldAppearance ();
1161 
getMode()1162   AnnotWidgetHighlightMode getMode() { return mode; }
getAppearCharacs()1163   AnnotAppearanceCharacs *getAppearCharacs() { return appearCharacs; }
getAction()1164   Dict *getAction() { return action; }
getAdditionActions()1165   Dict *getAdditionActions() { return additionActions; }
getParent()1166   Dict *getParent() { return parent; }
1167 
1168 private:
1169 
1170   void initialize(XRef *xrefA, Catalog *catalog, Dict *dict);
1171 
1172   void drawText(GooString *text, GooString *da, GfxFontDict *fontDict,
1173 		GBool multiline, int comb, int quadding,
1174 		GBool txField, GBool forceZapfDingbats,
1175 		GBool password=false);
1176   void drawListBox(GooString **text, GBool *selection,
1177 		   int nOptions, int topIdx,
1178 		   GooString *da, GfxFontDict *fontDict, int quadding);
1179   void layoutText(GooString *text, GooString *outBuf, int *i, GfxFont *font,
1180 		  double *width, double widthLimit, int *charCount,
1181 		  GBool noReencode);
1182   void writeString(GooString *str, GooString *appearBuf);
1183 
1184   Form *form;
1185   FormWidget *widget;                     // FormWidget object for this annotation
1186   AnnotWidgetHighlightMode mode;          // H  (Default I)
1187   AnnotAppearanceCharacs *appearCharacs;  // MK
1188   Dict *action;                           // A
1189   Dict *additionActions;                  // AA
1190   // inherited  from Annot
1191   // AnnotBorderBS border;                // BS
1192   Dict *parent;                           // Parent
1193   GBool regen;
1194   GBool addDingbatsResource;
1195 };
1196 
1197 //------------------------------------------------------------------------
1198 // Annot3D
1199 //------------------------------------------------------------------------
1200 
1201 class Annot3D: public Annot {
1202   class Activation {
1203   public:
1204     enum ActivationATrigger {
1205       aTriggerUnknown,
1206       aTriggerPageOpened,  // PO
1207       aTriggerPageVisible, // PV
1208       aTriggerUserAction   // XA
1209     };
1210 
1211     enum ActivationAState {
1212       aStateUnknown,
1213       aStateEnabled, // I
1214       aStateDisabled // L
1215     };
1216 
1217     enum ActivationDTrigger {
1218       dTriggerUnknown,
1219       dTriggerPageClosed,    // PC
1220       dTriggerPageInvisible, // PI
1221       dTriggerUserAction     // XD
1222     };
1223 
1224     enum ActivationDState {
1225       dStateUnknown,
1226       dStateUninstantiaded, // U
1227       dStateInstantiated,   // I
1228       dStateLive            // L
1229     };
1230 
1231     Activation(Dict *dict);
1232   private:
1233 
1234     ActivationATrigger aTrigger;  // A   (Default XA)
1235     ActivationAState aState;      // AIS (Default L)
1236     ActivationDTrigger dTrigger;  // D   (Default PI)
1237     ActivationDState dState;      // DIS (Default U)
1238     GBool displayToolbar;         // TB  (Default true)
1239     GBool displayNavigation;      // NP  (Default false);
1240   };
1241 public:
1242 
1243   Annot3D(XRef *xrefA, PDFRectangle *rect, Catalog *catalog);
1244   Annot3D(XRef *xrefA, Dict *dict, Catalog *catalog, Object *obj);
1245   ~Annot3D();
1246 
1247   // getters
1248 
1249 private:
1250 
1251   void initialize(XRef *xrefA, Catalog *catalog, Dict *dict);
1252 
1253   Activation *activation;  // 3DA
1254 };
1255 
1256 //------------------------------------------------------------------------
1257 // Annots
1258 //------------------------------------------------------------------------
1259 
1260 class Annots {
1261 public:
1262 
1263   // Build a list of Annot objects.
1264   Annots(XRef *xref, Catalog *catalog, Object *annotsObj);
1265 
1266   ~Annots();
1267 
1268   // Iterate through list of annotations.
getNumAnnots()1269   int getNumAnnots() { return nAnnots; }
getAnnot(int i)1270   Annot *getAnnot(int i) { return annots[i]; }
1271 
1272 private:
1273   Annot* createAnnot(XRef *xref, Dict* dict, Catalog *catalog, Object *obj);
1274   Annot *findAnnot(Ref *ref);
1275 
1276   Annot **annots;
1277   int nAnnots;
1278 };
1279 
1280 #endif
1281