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-2011, 2013, 2015 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-2011, 2013, 2016 Albert Astals Cid <aacid@kde.org>
25 // Copyright (C) 2012, 2013 Fabio D'Urso <fabiodurso@hotmail.it>
26 // Copyright (C) 2012, 2015 Tobias Koenig <tokoe@kdab.com>
27 // Copyright (C) 2013 Thomas Freitag <Thomas.Freitag@alfa.de>
28 // Copyright (C) 2013 Adrian Johnson <ajohnson@redneon.com>
29 //
30 // To see a description of the changes please see the Changelog file that
31 // came with your tarball or type make ChangeLog if you are building from git
32 //
33 //========================================================================
34 
35 #ifndef ANNOT_H
36 #define ANNOT_H
37 
38 #ifdef USE_GCC_PRAGMAS
39 #pragma interface
40 #endif
41 
42 #include "Object.h"
43 
44 class XRef;
45 class Gfx;
46 class CharCodeToUnicode;
47 class GfxFont;
48 class GfxResources;
49 class Page;
50 class PDFDoc;
51 class Form;
52 class FormWidget;
53 class FormField;
54 class FormFieldChoice;
55 class PDFRectangle;
56 class Movie;
57 class LinkAction;
58 class Sound;
59 class FileSpec;
60 
61 enum AnnotLineEndingStyle {
62   annotLineEndingSquare,        // Square
63   annotLineEndingCircle,        // Circle
64   annotLineEndingDiamond,       // Diamond
65   annotLineEndingOpenArrow,     // OpenArrow
66   annotLineEndingClosedArrow,   // ClosedArrow
67   annotLineEndingNone,          // None
68   annotLineEndingButt,          // Butt
69   annotLineEndingROpenArrow,    // ROpenArrow
70   annotLineEndingRClosedArrow,  // RClosedArrow
71   annotLineEndingSlash          // Slash
72 };
73 
74 enum AnnotExternalDataType {
75   annotExternalDataMarkupUnknown,
76   annotExternalDataMarkup3D       // Markup3D
77 };
78 
79 //------------------------------------------------------------------------
80 // AnnotCoord
81 //------------------------------------------------------------------------
82 
83 class AnnotCoord {
84 public:
85 
AnnotCoord()86   AnnotCoord() : x(0), y(0) { }
AnnotCoord(double _x,double _y)87   AnnotCoord(double _x, double _y) : x(_x), y(_y) { }
88 
getX()89   double getX() const { return x; }
getY()90   double getY() const { return y; }
91 
92 protected:
93 
94   double x, y;
95 };
96 
97 //------------------------------------------------------------------------
98 // AnnotPath
99 //------------------------------------------------------------------------
100 
101 class AnnotPath {
102 public:
103   AnnotPath();
104   AnnotPath(Array *array);
105   AnnotPath(AnnotCoord **coords, int coordLength);
106   ~AnnotPath();
107 
108   double getX(int coord) const;
109   double getY(int coord) const;
110   AnnotCoord *getCoord(int coord) const;
getCoordsLength()111   int getCoordsLength() const { return coordsLength; }
112 protected:
113   AnnotCoord **coords;
114   int coordsLength;
115 
116   void parsePathArray(Array *array);
117 };
118 
119 //------------------------------------------------------------------------
120 // AnnotCalloutLine
121 //------------------------------------------------------------------------
122 
123 class AnnotCalloutLine {
124 public:
125 
126   AnnotCalloutLine(double x1, double y1, double x2, double y2);
~AnnotCalloutLine()127   virtual ~AnnotCalloutLine() { }
128 
getX1()129   double getX1() const { return coord1.getX(); }
getY1()130   double getY1() const { return coord1.getY(); }
getX2()131   double getX2() const { return coord2.getX(); }
getY2()132   double getY2() const { return coord2.getY(); }
133 
134 protected:
135 
136   AnnotCoord coord1, coord2;
137 };
138 
139 //------------------------------------------------------------------------
140 // AnnotCalloutMultiLine
141 //------------------------------------------------------------------------
142 
143 class AnnotCalloutMultiLine: public AnnotCalloutLine {
144 public:
145 
146   AnnotCalloutMultiLine(double x1, double y1, double x2, double y2,
147     double x3, double y3);
148 
getX3()149   double getX3() const { return coord3.getX(); }
getY3()150   double getY3() const { return coord3.getY(); }
151 
152 protected:
153 
154   AnnotCoord coord3;
155 };
156 
157 //------------------------------------------------------------------------
158 // AnnotBorderEffect
159 //------------------------------------------------------------------------
160 
161 class AnnotBorderEffect {
162 public:
163 
164   enum AnnotBorderEffectType {
165     borderEffectNoEffect, // S
166     borderEffectCloudy    // C
167   };
168 
169   AnnotBorderEffect(Dict *dict);
170 
getEffectType()171   AnnotBorderEffectType getEffectType() const { return effectType; }
getIntensity()172   double getIntensity() const { return intensity; }
173 
174 private:
175 
176   AnnotBorderEffectType effectType; // S  (Default S)
177   double intensity;                 // I  (Default 0)
178 };
179 
180 //------------------------------------------------------------------------
181 // AnnotQuadrilateral
182 //------------------------------------------------------------------------
183 
184 class AnnotQuadrilaterals {
185 public:
186   class AnnotQuadrilateral {
187   public:
188     AnnotQuadrilateral(double x1, double y1, double x2, double y2, double x3,
189       double y3, double x4, double y4);
190 
191     AnnotCoord coord1, coord2, coord3, coord4;
192   };
193 
194   AnnotQuadrilaterals(Array *array, PDFRectangle *rect);
195   AnnotQuadrilaterals(AnnotQuadrilateral **quads, int quadsLength);
196   ~AnnotQuadrilaterals();
197 
198   double getX1(int quadrilateral);
199   double getY1(int quadrilateral);
200   double getX2(int quadrilateral);
201   double getY2(int quadrilateral);
202   double getX3(int quadrilateral);
203   double getY3(int quadrilateral);
204   double getX4(int quadrilateral);
205   double getY4(int quadrilateral);
getQuadrilateralsLength()206   int getQuadrilateralsLength() const { return quadrilateralsLength; }
207 protected:
208 
209   AnnotQuadrilateral** quadrilaterals;
210   int quadrilateralsLength;
211 };
212 
213 //------------------------------------------------------------------------
214 // AnnotBorder
215 //------------------------------------------------------------------------
216 
217 class AnnotBorder {
218 public:
219   enum AnnotBorderType {
220     typeArray,
221     typeBS
222   };
223 
224   enum AnnotBorderStyle {
225     borderSolid,      // Solid
226     borderDashed,     // Dashed
227     borderBeveled,    // Beveled
228     borderInset,      // Inset
229     borderUnderlined  // Underlined
230   };
231 
232   virtual ~AnnotBorder();
233 
setWidth(double new_width)234   virtual void setWidth(double new_width) { width = new_width; }
235 
236   virtual AnnotBorderType getType() const = 0;
getWidth()237   virtual double getWidth() const { return width; }
getDashLength()238   virtual int getDashLength() const { return dashLength; }
getDash()239   virtual double *getDash() const { return dash; }
getStyle()240   virtual AnnotBorderStyle getStyle() const { return style; }
241 
242   virtual void writeToObject(XRef *xref, Object *obj1) const = 0;
243 
244 protected:
245   AnnotBorder();
246 
247   GBool parseDashArray(Object *dashObj);
248 
249   AnnotBorderType type;
250   double width;
251   static const int DASH_LIMIT = 10; // implementation note 82 in Appendix H.
252   int dashLength;
253   double *dash;
254   AnnotBorderStyle style;
255 };
256 
257 //------------------------------------------------------------------------
258 // AnnotBorderArray
259 //------------------------------------------------------------------------
260 
261 class AnnotBorderArray: public AnnotBorder {
262 public:
263   AnnotBorderArray();
264   AnnotBorderArray(Array *array);
265 
setHorizontalCorner(double hc)266   void setHorizontalCorner(double hc) { horizontalCorner = hc; }
setVerticalCorner(double vc)267   void setVerticalCorner(double vc) { verticalCorner = vc; }
268 
getHorizontalCorner()269   double getHorizontalCorner() const { return horizontalCorner; }
getVerticalCorner()270   double getVerticalCorner() const { return verticalCorner; }
271 
272 private:
getType()273   virtual AnnotBorderType getType() const { return typeArray; }
274   virtual void writeToObject(XRef *xref, Object *obj1) const;
275 
276   double horizontalCorner;          // (Default 0)
277   double verticalCorner;            // (Default 0)
278   // double width;                  // (Default 1)  (inherited from AnnotBorder)
279 };
280 
281 //------------------------------------------------------------------------
282 // AnnotBorderBS
283 //------------------------------------------------------------------------
284 
285 class AnnotBorderBS: public AnnotBorder {
286 public:
287 
288   AnnotBorderBS();
289   AnnotBorderBS(Dict *dict);
290 
291 private:
getType()292   virtual AnnotBorderType getType() const { return typeBS; }
293   virtual void writeToObject(XRef *xref, Object *obj1) const;
294 
295   const char *getStyleName() const;
296 
297   // double width;           // W  (Default 1)   (inherited from AnnotBorder)
298   // AnnotBorderStyle style; // S  (Default S)   (inherited from AnnotBorder)
299   // double *dash;           // D  (Default [3]) (inherited from AnnotBorder)
300 };
301 
302 //------------------------------------------------------------------------
303 // AnnotColor
304 //------------------------------------------------------------------------
305 
306 class AnnotColor {
307 public:
308 
309   enum AnnotColorSpace {
310     colorTransparent = 0,
311     colorGray        = 1,
312     colorRGB         = 3,
313     colorCMYK        = 4
314   };
315 
316   AnnotColor();
317   AnnotColor(double gray);
318   AnnotColor(double r, double g, double b);
319   AnnotColor(double c, double m, double y, double k);
320   AnnotColor(Array *array, int adjust = 0);
321 
322   void adjustColor(int adjust);
323 
getSpace()324   AnnotColorSpace getSpace() const { return (AnnotColorSpace) length; }
getValues()325   const double *getValues() const { return values; }
326 
327   void writeToObject(XRef *xref, Object *dest) const;
328 
329 private:
330 
331   double values[4];
332   int length;
333 };
334 
335 //------------------------------------------------------------------------
336 // AnnotIconFit
337 //------------------------------------------------------------------------
338 
339 class AnnotIconFit {
340 public:
341 
342   enum AnnotIconFitScaleWhen {
343     scaleAlways,  // A
344     scaleBigger,  // B
345     scaleSmaller, // S
346     scaleNever    // N
347   };
348 
349   enum AnnotIconFitScale {
350     scaleAnamorphic,  // A
351     scaleProportional // P
352   };
353 
354   AnnotIconFit(Dict *dict);
355 
getScaleWhen()356   AnnotIconFitScaleWhen getScaleWhen() { return scaleWhen; }
getScale()357   AnnotIconFitScale getScale() { return scale; }
getLeft()358   double getLeft() { return left; }
getBottom()359   double getBottom() { return bottom; }
getFullyBounds()360   bool getFullyBounds() { return fullyBounds; }
361 
362 protected:
363 
364   AnnotIconFitScaleWhen scaleWhen;  // SW (Default A)
365   AnnotIconFitScale scale;          // S  (Default P)
366   double left;                      // A  (Default [0.5 0.5]
367   double bottom;                    // Only if scale is P
368   bool fullyBounds;                 // FB (Default false)
369 };
370 
371 //------------------------------------------------------------------------
372 // AnnotAppearance
373 //------------------------------------------------------------------------
374 
375 class AnnotAppearance {
376 public:
377 
378   enum AnnotAppearanceType {
379     appearNormal,
380     appearRollover,
381     appearDown
382   };
383 
384   AnnotAppearance(PDFDoc *docA, Object *dict);
385   ~AnnotAppearance();
386 
387   // State is ignored if no subdictionary is present
388   void getAppearanceStream(AnnotAppearanceType type, const char *state, Object *dest);
389 
390   // Access keys in normal appearance subdictionary (N)
391   GooString * getStateKey(int i);
392   int getNumStates();
393 
394   // Removes all associated streams in the xref table. Caller is required to
395   // reset parent annotation's AP and AS after this call.
396   void removeAllStreams();
397 
398   // Test if this AnnotAppearance references the specified stream
399   GBool referencesStream(Ref targetStreamRef);
400 
401 private:
402   static GBool referencesStream(Object *stateObj, Ref targetStreamRef);
403   void removeStream(Ref refToStream);
404   void removeStateStreams(Object *state);
405 
406 protected:
407   PDFDoc *doc;
408   XRef *xref;                   // the xref table for this PDF file
409   Object appearDict;            // Annotation's AP
410 };
411 
412 //------------------------------------------------------------------------
413 // AnnotAppearanceCharacs
414 //------------------------------------------------------------------------
415 
416 class AnnotAppearanceCharacs {
417 public:
418 
419   enum AnnotAppearanceCharacsTextPos {
420     captionNoIcon,    // 0
421     captionNoCaption, // 1
422     captionBelow,     // 2
423     captionAbove,     // 3
424     captionRight,     // 4
425     captionLeft,      // 5
426     captionOverlaid   // 6
427   };
428 
429   AnnotAppearanceCharacs(Dict *dict);
430   ~AnnotAppearanceCharacs();
431 
getRotation()432   int getRotation() { return rotation; }
getBorderColor()433   AnnotColor *getBorderColor() { return borderColor; }
getBackColor()434   AnnotColor *getBackColor() { return backColor; }
getNormalCaption()435   GooString *getNormalCaption() { return normalCaption; }
getRolloverCaption()436   GooString *getRolloverCaption() { return rolloverCaption; }
getAlternateCaption()437   GooString *getAlternateCaption() { return alternateCaption; }
getIconFit()438   AnnotIconFit *getIconFit() { return iconFit; }
getPosition()439   AnnotAppearanceCharacsTextPos getPosition() { return position; }
440 
441 protected:
442 
443   int rotation;                           // R  (Default 0)
444   AnnotColor *borderColor;                // BC
445   AnnotColor *backColor;                  // BG
446   GooString *normalCaption;               // CA
447   GooString *rolloverCaption;             // RC
448   GooString *alternateCaption;            // AC
449   // I
450   // RI
451   // IX
452   AnnotIconFit *iconFit;                  // IF
453   AnnotAppearanceCharacsTextPos position; // TP (Default 0)
454 };
455 
456 //------------------------------------------------------------------------
457 // AnnotAppearanceBBox
458 //------------------------------------------------------------------------
459 
460 class AnnotAppearanceBBox
461 {
462 public:
463   AnnotAppearanceBBox(PDFRectangle *init);
464 
setBorderWidth(double w)465   void setBorderWidth(double w) { borderWidth = w; }
466 
467   // The following functions operate on coords relative to [origX origY]
468   void extendTo(double x, double y);
469   void getBBoxRect(double bbox[4]) const;
470 
471   // Get boundaries in page coordinates
472   double getPageXMin() const;
473   double getPageYMin() const;
474   double getPageXMax() const;
475   double getPageYMax() const;
476 
477 private:
478   double origX, origY, borderWidth;
479   double minX, minY, maxX, maxY;
480 };
481 
482 //------------------------------------------------------------------------
483 // Annot
484 //------------------------------------------------------------------------
485 
486 class Annot {
487   friend class Annots;
488   friend class Page;
489 public:
490   enum AnnotFlag {
491     flagUnknown        = 0x0000,
492     flagInvisible      = 0x0001,
493     flagHidden         = 0x0002,
494     flagPrint          = 0x0004,
495     flagNoZoom         = 0x0008,
496     flagNoRotate       = 0x0010,
497     flagNoView         = 0x0020,
498     flagReadOnly       = 0x0040,
499     flagLocked         = 0x0080,
500     flagToggleNoView   = 0x0100,
501     flagLockedContents = 0x0200
502   };
503 
504   enum AnnotSubtype {
505     typeUnknown,        //                 0
506     typeText,           // Text            1
507     typeLink,           // Link            2
508     typeFreeText,       // FreeText        3
509     typeLine,           // Line            4
510     typeSquare,         // Square          5
511     typeCircle,         // Circle          6
512     typePolygon,        // Polygon         7
513     typePolyLine,       // PolyLine        8
514     typeHighlight,      // Highlight       9
515     typeUnderline,      // Underline      10
516     typeSquiggly,       // Squiggly       11
517     typeStrikeOut,      // StrikeOut      12
518     typeStamp,          // Stamp          13
519     typeCaret,          // Caret          14
520     typeInk,            // Ink            15
521     typePopup,          // Popup          16
522     typeFileAttachment, // FileAttachment 17
523     typeSound,          // Sound          18
524     typeMovie,          // Movie          19
525     typeWidget,         // Widget         20
526     typeScreen,         // Screen         21
527     typePrinterMark,    // PrinterMark    22
528     typeTrapNet,        // TrapNet        23
529     typeWatermark,      // Watermark      24
530     type3D,             // 3D             25
531     typeRichMedia       // RichMedia      26
532   };
533 
534   /**
535    * Describes the additional actions of a screen or widget annotation.
536    */
537   enum AdditionalActionsType {
538     actionCursorEntering, ///< Performed when the cursor enters the annotation's active area
539     actionCursorLeaving,  ///< Performed when the cursor exists the annotation's active area
540     actionMousePressed,   ///< Performed when the mouse button is pressed inside the annotation's active area
541     actionMouseReleased,  ///< Performed when the mouse button is released inside the annotation's active area
542     actionFocusIn,        ///< Performed when the annotation receives the input focus
543     actionFocusOut,       ///< Performed when the annotation loses the input focus
544     actionPageOpening,    ///< Performed when the page containing the annotation is opened
545     actionPageClosing,    ///< Performed when the page containing the annotation is closed
546     actionPageVisible,    ///< Performed when the page containing the annotation becomes visible
547     actionPageInvisible   ///< Performed when the page containing the annotation becomes invisible
548   };
549 
550   enum FormAdditionalActionsType {
551     actionFieldModified,   ///< Performed when the when the user modifies the field
552     actionFormatField,     ///< Performed before the field is formatted to display its value
553     actionValidateField,   ///< Performed when the field value changes
554     actionCalculateField,  ///< Performed when the field needs to be recalculated
555   };
556 
557   Annot(PDFDoc *docA, PDFRectangle *rectA);
558   Annot(PDFDoc *docA, Dict *dict);
559   Annot(PDFDoc *docA, Dict *dict, Object *obj);
isOk()560   GBool isOk() { return ok; }
561 
562   void incRefCnt();
563   void decRefCnt();
564 
565   virtual void draw(Gfx *gfx, GBool printing);
566   // Get the resource dict of the appearance stream
567   virtual Object *getAppearanceResDict(Object *dest);
568 
match(Ref * refA)569   GBool match(Ref *refA)
570     { return ref.num == refA->num && ref.gen == refA->gen; }
571 
572   double getXMin();
573   double getYMin();
574   double getXMax();
575   double getYMax();
576 
getFontSize()577   double getFontSize() { return fontSize; }
578 
579   void setRect(PDFRectangle *rect);
580   void setRect(double x1, double y1, double x2, double y2);
581 
582   // Sets the annot contents to new_content
583   // new_content should never be NULL
584   virtual void setContents(GooString *new_content);
585   void setName(GooString *new_name);
586   void setModified(GooString *new_date);
587   void setFlags(Guint new_flags);
588 
589   void setBorder(AnnotBorder *new_border); // Takes ownership
590 
591   // The annotation takes the ownership of
592   // new_color.
593   void setColor(AnnotColor *new_color);
594 
595   void setAppearanceState(const char *state);
596 
597   // getters
getDoc()598   PDFDoc *getDoc() const { return doc; }
getXRef()599   XRef *getXRef() const { return xref; }
getHasRef()600   GBool getHasRef() const { return hasRef; }
getRef()601   Ref getRef() const { return ref; }
getType()602   AnnotSubtype getType() const { return type; }
getRect()603   PDFRectangle *getRect() const { return rect; }
604   void getRect(double *x1, double *y1, double *x2, double *y2) const;
getContents()605   GooString *getContents() const { return contents; }
getPageNum()606   int getPageNum() const { return page; }
getName()607   GooString *getName() const { return name; }
getModified()608   GooString *getModified() const { return modified; }
getFlags()609   Guint getFlags() const { return flags; }
getAppearStreams()610   AnnotAppearance *getAppearStreams() const { return appearStreams; }
getAppearState()611   GooString *getAppearState() const { return appearState; }
getBorder()612   AnnotBorder *getBorder() const { return border; }
getColor()613   AnnotColor *getColor() const { return color; }
getTreeKey()614   int getTreeKey() const { return treeKey; }
615 
getId()616   int getId() { return ref.num; }
617 
618   // Check if point is inside the annot rectangle.
619   GBool inRect(double x, double y) const;
620 
621 private:
622   void readArrayNum(Object *pdfArray, int key, double *value);
623   // write vStr[i:j[ in appearBuf
624 
625   void initialize (PDFDoc *docA, Dict *dict);
626   void setPage (int new_page, GBool updateP); // Called by Page::addAnnot and Annots ctor
627 
628 
629 protected:
630   virtual ~Annot();
631   virtual void removeReferencedObjects(); // Called by Page::removeAnnot
632   void setColor(AnnotColor *color, GBool fill);
633   void setLineStyleForBorder(AnnotBorder *border);
634   void drawCircle(double cx, double cy, double r, GBool fill);
635   void drawCircleTopLeft(double cx, double cy, double r);
636   void drawCircleBottomRight(double cx, double cy, double r);
637   void layoutText(GooString *text, GooString *outBuf, int *i, GfxFont *font,
638 		  double *width, double widthLimit, int *charCount,
639 		  GBool noReencode);
640   void writeString(GooString *str, GooString *appearBuf);
641   void createForm(double *bbox, GBool transparencyGroup, Object *resDict, Object *aStream);
642   void createResourcesDict(const char *formName, Object *formStream, const char *stateName,
643 			   double opacity, const char *blendMode, Object *resDict);
644   GBool isVisible(GBool printing);
645   int getRotation() const;
646 
647   // Updates the field key of the annotation dictionary
648   // and sets M to the current time
649   void update(const char *key, Object *value);
650 
651   // Delete appearance streams and reset appearance state
652   void invalidateAppearance();
653 
654   int refCnt;
655 
656   Object annotObj;
657 
658   // required data
659   AnnotSubtype type;                // Annotation type
660   PDFRectangle *rect;               // Rect
661 
662   // optional data
663   GooString *contents;              // Contents
664   int       page;                   // P
665   GooString *name;                  // NM
666   GooString *modified;              // M
667   Guint flags;                      // F (must be a 32 bit unsigned int)
668   AnnotAppearance *appearStreams;   // AP
669   Object appearance;     // a reference to the Form XObject stream
670                          //   for the normal appearance
671   AnnotAppearanceBBox *appearBBox;  // BBox of generated appearance
672   GooString *appearState;           // AS
673   int treeKey;                      // Struct Parent;
674   Object oc;                        // OC
675 
676   PDFDoc *doc;
677   XRef *xref;			// the xref table for this PDF file
678   Ref ref;                      // object ref identifying this annotation
679   GooString *appearBuf;
680   AnnotBorder *border;          // Border, BS
681   AnnotColor *color;            // C
682   double fontSize;
683   GBool ok;
684 
685   bool hasRef;
686 #if MULTITHREADED
687   GooMutex mutex;
688 #endif
689 };
690 
691 //------------------------------------------------------------------------
692 // AnnotPopup
693 //------------------------------------------------------------------------
694 
695 class AnnotPopup: public Annot {
696 public:
697   AnnotPopup(PDFDoc *docA, PDFRectangle *rect);
698   AnnotPopup(PDFDoc *docA, Dict *dict, Object *obj);
699   ~AnnotPopup();
700 
getParent(Object * obj)701   Object *getParent(Object *obj) { return parent.fetch (xref, obj); }
getParentNF()702   Object *getParentNF() { return &parent; }
703   void setParent(Object *parentA);
704   void setParent(Annot *parentA);
getOpen()705   GBool getOpen() const { return open; }
706   void setOpen(GBool openA);
707 
708 protected:
709   void initialize(PDFDoc *docA, Dict *dict);
710 
711   Object parent; // Parent
712   GBool open;   // Open
713 };
714 
715 //------------------------------------------------------------------------
716 // AnnotMarkup
717 //------------------------------------------------------------------------
718 
719 class AnnotMarkup: public Annot {
720 public:
721   enum  AnnotMarkupReplyType {
722     replyTypeR,     // R
723     replyTypeGroup  // Group
724   };
725 
726   AnnotMarkup(PDFDoc *docA, PDFRectangle *rect);
727   AnnotMarkup(PDFDoc *docA, Dict *dict, Object *obj);
728   virtual ~AnnotMarkup();
729 
730   // getters
getLabel()731   GooString *getLabel() const { return label; }
getPopup()732   AnnotPopup *getPopup() const { return popup; }
getOpacity()733   double getOpacity() const { return opacity; }
734   // getRC
getDate()735   GooString *getDate() const { return date; }
getInReplyToID()736   int getInReplyToID() const { return inReplyTo.num; }
getSubject()737   GooString *getSubject() const { return subject; }
getReplyTo()738   AnnotMarkupReplyType getReplyTo() const { return replyTo; }
getExData()739   AnnotExternalDataType getExData() const { return exData; }
740 
741   // The annotation takes the ownership of new_popup
742   void setPopup(AnnotPopup *new_popup);
743   void setLabel(GooString *new_label);
744   void setOpacity(double opacityA);
745   void setDate(GooString *new_date);
746 
747 protected:
748   virtual void removeReferencedObjects();
749 
750   GooString *label;             // T            (Default autor)
751   AnnotPopup *popup;            // Popup
752   double opacity;               // CA           (Default 1.0)
753   // RC
754   GooString *date;              // CreationDate
755   Ref inReplyTo;                // IRT
756   GooString *subject;           // Subj
757   AnnotMarkupReplyType replyTo; // RT           (Default R)
758   // this object is overrided by the custom intent fields defined in some
759   // annotation types.
760   //GooString *intent;          // IT
761   AnnotExternalDataType exData; // ExData
762 
763 private:
764   void initialize(PDFDoc *docA, Dict *dict, Object *obj);
765 };
766 
767 //------------------------------------------------------------------------
768 // AnnotText
769 //------------------------------------------------------------------------
770 
771 class AnnotText: public AnnotMarkup {
772 public:
773   enum AnnotTextState {
774     stateUnknown,
775     // Marked state model
776     stateMarked,    // Marked
777     stateUnmarked,  // Unmarked
778     // Review state model
779     stateAccepted,  // Accepted
780     stateRejected,  // Rejected
781     stateCancelled, // Cancelled
782     stateCompleted, // Completed
783     stateNone       // None
784   };
785 
786   AnnotText(PDFDoc *docA, PDFRectangle *rect);
787   AnnotText(PDFDoc *docA, Dict *dict, Object *obj);
788   ~AnnotText();
789 
790   virtual void draw(Gfx *gfx, GBool printing);
791 
792   // getters
getOpen()793   GBool getOpen() const { return open; }
getIcon()794   GooString *getIcon() const { return icon; }
getState()795   AnnotTextState getState() const { return state; }
796 
797   void setOpen(GBool openA);
798   void setIcon(GooString *new_icon);
799 
800 private:
801 
802   void initialize(PDFDoc *docA, Dict *dict);
803 
804   GBool open;                       // Open       (Default false)
805   GooString *icon;                  // Name       (Default Note)
806   AnnotTextState state;             // State      (Default Umarked if
807                                     //             StateModel Marked
808                                     //             None if StareModel Review)
809 };
810 
811 //------------------------------------------------------------------------
812 // AnnotMovie
813 //------------------------------------------------------------------------
814 
815 
816 
817 class AnnotMovie: public Annot {
818  public:
819   AnnotMovie(PDFDoc *docA, PDFRectangle *rect, Movie *movieA);
820   AnnotMovie(PDFDoc *docA, Dict *dict, Object *obj);
821   ~AnnotMovie();
822 
823   virtual void draw(Gfx *gfx, GBool printing);
824 
getTitle()825   GooString* getTitle() { return title; }
getMovie()826   Movie* getMovie() { return movie; }
827 
828  private:
829   void initialize(PDFDoc *docA, Dict *dict);
830 
831   GooString* title;      // T
832   Movie* movie;          // Movie + A
833 };
834 
835 
836 //------------------------------------------------------------------------
837 // AnnotScreen
838 //------------------------------------------------------------------------
839 
840 class AnnotScreen: public Annot {
841  public:
842 
843   AnnotScreen(PDFDoc *docA, PDFRectangle *rect);
844   AnnotScreen(PDFDoc *docA, Dict *dict, Object *obj);
845   ~AnnotScreen();
846 
getTitle()847   GooString* getTitle() { return title; }
848 
getAppearCharacs()849   AnnotAppearanceCharacs *getAppearCharacs() { return appearCharacs; }
getAction()850   LinkAction* getAction() { return action; } // The caller should now delete the result
851   LinkAction *getAdditionalAction(AdditionalActionsType type); // The caller should delete the result
852 
853  private:
854   void initialize(PDFDoc *docA, Dict *dict);
855 
856 
857   GooString* title;                      // T
858 
859   AnnotAppearanceCharacs* appearCharacs; // MK
860 
861   LinkAction *action;                    // A
862   Object additionalActions;              // AA
863 };
864 
865 //------------------------------------------------------------------------
866 // AnnotLink
867 //------------------------------------------------------------------------
868 
869 class AnnotLink: public Annot {
870 public:
871 
872   enum AnnotLinkEffect {
873     effectNone,     // N
874     effectInvert,   // I
875     effectOutline,  // O
876     effectPush      // P
877   };
878 
879   AnnotLink(PDFDoc *docA, PDFRectangle *rect);
880   AnnotLink(PDFDoc *docA, Dict *dict, Object *obj);
881   virtual ~AnnotLink();
882 
883   virtual void draw(Gfx *gfx, GBool printing);
884 
885   // getters
getAction()886   LinkAction *getAction() const { return action; }
getLinkEffect()887   AnnotLinkEffect getLinkEffect() const { return linkEffect; }
getUriAction()888   Dict *getUriAction() const { return uriAction; }
getQuadrilaterals()889   AnnotQuadrilaterals *getQuadrilaterals() const { return quadrilaterals; }
890 
891 protected:
892 
893   void initialize(PDFDoc *docA, Dict *dict);
894 
895   LinkAction *action;                  // A, Dest
896   AnnotLinkEffect linkEffect;          // H          (Default I)
897   Dict *uriAction;                     // PA
898 
899   AnnotQuadrilaterals *quadrilaterals; // QuadPoints
900 };
901 
902 //------------------------------------------------------------------------
903 // AnnotFreeText
904 //------------------------------------------------------------------------
905 
906 class AnnotFreeText: public AnnotMarkup {
907 public:
908 
909   enum AnnotFreeTextQuadding {
910     quaddingLeftJustified,  // 0
911     quaddingCentered,       // 1
912     quaddingRightJustified  // 2
913   };
914 
915   enum AnnotFreeTextIntent {
916     intentFreeText,           // FreeText
917     intentFreeTextCallout,    // FreeTextCallout
918     intentFreeTextTypeWriter  // FreeTextTypeWriter
919   };
920 
921   AnnotFreeText(PDFDoc *docA, PDFRectangle *rect, GooString *da);
922   AnnotFreeText(PDFDoc *docA, Dict *dict, Object *obj);
923   ~AnnotFreeText();
924 
925   virtual void draw(Gfx *gfx, GBool printing);
926   virtual Object *getAppearanceResDict(Object *dest);
927   virtual void setContents(GooString *new_content);
928 
929   void setAppearanceString(GooString *new_string);
930   void setQuadding(AnnotFreeTextQuadding new_quadding);
931   void setStyleString(GooString *new_string);
932   void setCalloutLine(AnnotCalloutLine *line);
933   void setIntent(AnnotFreeTextIntent new_intent);
934 
935   // getters
getAppearanceString()936   GooString *getAppearanceString() const { return appearanceString; }
getQuadding()937   AnnotFreeTextQuadding getQuadding() const { return quadding; }
938   // return rc
getStyleString()939   GooString *getStyleString() const { return styleString; }
getCalloutLine()940   AnnotCalloutLine *getCalloutLine() const {  return calloutLine; }
getIntent()941   AnnotFreeTextIntent getIntent() const { return intent; }
getBorderEffect()942   AnnotBorderEffect *getBorderEffect() const { return borderEffect; }
getRectangle()943   PDFRectangle *getRectangle() const { return rectangle; }
getEndStyle()944   AnnotLineEndingStyle getEndStyle() const { return endStyle; }
945 
946 protected:
947 
948   void initialize(PDFDoc *docA, Dict *dict);
949   static void parseAppearanceString(GooString *da, double &fontsize, AnnotColor* &fontcolor);
950   void generateFreeTextAppearance();
951 
952   // required
953   GooString *appearanceString;      // DA
954 
955   // optional
956   AnnotFreeTextQuadding quadding;   // Q  (Default 0)
957   // RC
958   GooString *styleString;           // DS
959   AnnotCalloutLine *calloutLine;    // CL
960   AnnotFreeTextIntent intent;       // IT
961   AnnotBorderEffect *borderEffect;  // BE
962   PDFRectangle *rectangle;          // RD
963   // inherited  from Annot
964   // AnnotBorderBS border;          // BS
965   AnnotLineEndingStyle endStyle;    // LE (Default None)
966 };
967 
968 //------------------------------------------------------------------------
969 // AnnotLine
970 //------------------------------------------------------------------------
971 
972 class AnnotLine: public AnnotMarkup {
973 public:
974 
975   enum AnnotLineIntent {
976     intentLineArrow,    // LineArrow
977     intentLineDimension // LineDimension
978   };
979 
980   enum AnnotLineCaptionPos {
981     captionPosInline, // Inline
982     captionPosTop     // Top
983   };
984 
985   AnnotLine(PDFDoc *docA, PDFRectangle *rect);
986   AnnotLine(PDFDoc *docA, Dict *dict, Object *obj);
987   ~AnnotLine();
988 
989   virtual void draw(Gfx *gfx, GBool printing);
990   virtual Object *getAppearanceResDict(Object *dest);
991   virtual void setContents(GooString *new_content);
992 
993   void setVertices(double x1, double y1, double x2, double y2);
994   void setStartEndStyle(AnnotLineEndingStyle start, AnnotLineEndingStyle end);
995   void setInteriorColor(AnnotColor *new_color);
996   void setLeaderLineLength(double len);
997   void setLeaderLineExtension(double len);
998   void setCaption(bool new_cap);
999   void setIntent(AnnotLineIntent new_intent);
1000 
1001   // getters
getStartStyle()1002   AnnotLineEndingStyle getStartStyle() const { return startStyle; }
getEndStyle()1003   AnnotLineEndingStyle getEndStyle() const { return endStyle; }
getInteriorColor()1004   AnnotColor *getInteriorColor() const { return interiorColor; }
getLeaderLineLength()1005   double getLeaderLineLength() const { return leaderLineLength; }
getLeaderLineExtension()1006   double getLeaderLineExtension() const { return leaderLineExtension; }
getCaption()1007   bool getCaption() const { return caption; }
getIntent()1008   AnnotLineIntent getIntent() const { return intent; }
getLeaderLineOffset()1009   double  getLeaderLineOffset() const { return leaderLineOffset; }
getCaptionPos()1010   AnnotLineCaptionPos getCaptionPos() const { return captionPos; }
getMeasure()1011   Dict *getMeasure() const { return measure; }
getCaptionTextHorizontal()1012   double getCaptionTextHorizontal() const { return captionTextHorizontal; }
getCaptionTextVertical()1013   double getCaptionTextVertical() const { return captionTextVertical; }
getX1()1014   double getX1() const { return coord1->getX(); }
getY1()1015   double getY1() const { return coord1->getY(); }
getX2()1016   double getX2() const { return coord2->getX(); }
getY2()1017   double getY2() const { return coord2->getY(); }
1018 
1019 protected:
1020 
1021   void initialize(PDFDoc *docA, Dict *dict);
1022   void generateLineAppearance();
1023 
1024   // required
1025   AnnotCoord *coord1, *coord2;
1026 
1027   // optional
1028   // inherited  from Annot
1029   // AnnotBorderBS border;          // BS
1030   AnnotLineEndingStyle startStyle;  // LE       (Default [/None /None])
1031   AnnotLineEndingStyle endStyle;    //
1032   AnnotColor *interiorColor;        // IC
1033   double leaderLineLength;          // LL       (Default 0)
1034   double leaderLineExtension;       // LLE      (Default 0)
1035   bool caption;                     // Cap      (Default false)
1036   AnnotLineIntent intent;           // IT
1037   double leaderLineOffset;          // LLO
1038   AnnotLineCaptionPos captionPos;   // CP       (Default Inline)
1039   Dict *measure;                    // Measure
1040   double captionTextHorizontal;     // CO       (Default [0, 0])
1041   double captionTextVertical;       //
1042 };
1043 
1044 //------------------------------------------------------------------------
1045 // AnnotTextMarkup
1046 //------------------------------------------------------------------------
1047 
1048 class AnnotTextMarkup: public AnnotMarkup {
1049 public:
1050 
1051   AnnotTextMarkup(PDFDoc *docA, PDFRectangle *rect, AnnotSubtype subType);
1052   AnnotTextMarkup(PDFDoc *docA, Dict *dict, Object *obj);
1053   virtual ~AnnotTextMarkup();
1054 
1055   virtual void draw(Gfx *gfx, GBool printing);
1056 
1057   // typeHighlight, typeUnderline, typeSquiggly or typeStrikeOut
1058   void setType(AnnotSubtype new_type);
1059 
1060   void setQuadrilaterals(AnnotQuadrilaterals *quadPoints);
1061 
getQuadrilaterals()1062   AnnotQuadrilaterals *getQuadrilaterals() const { return quadrilaterals; }
1063 
1064 protected:
1065 
1066   void initialize(PDFDoc *docA, Dict *dict);
1067 
1068   AnnotQuadrilaterals *quadrilaterals; // QuadPoints
1069 };
1070 
1071 //------------------------------------------------------------------------
1072 // AnnotStamp
1073 //------------------------------------------------------------------------
1074 
1075 class AnnotStamp: public AnnotMarkup {
1076 public:
1077 
1078   AnnotStamp(PDFDoc *docA, PDFRectangle *rect);
1079   AnnotStamp(PDFDoc *docA, Dict *dict, Object *obj);
1080   ~AnnotStamp();
1081 
1082   void setIcon(GooString *new_icon);
1083 
1084   // getters
getIcon()1085   GooString *getIcon() const { return icon; }
1086 
1087 private:
1088 
1089   void initialize(PDFDoc *docA, Dict *dict);
1090 
1091   GooString *icon;                  // Name       (Default Draft)
1092 };
1093 
1094 //------------------------------------------------------------------------
1095 // AnnotGeometry
1096 //------------------------------------------------------------------------
1097 
1098 class AnnotGeometry: public AnnotMarkup {
1099 public:
1100 
1101   AnnotGeometry(PDFDoc *docA, PDFRectangle *rect, AnnotSubtype subType);
1102   AnnotGeometry(PDFDoc *docA, Dict *dict, Object *obj);
1103   ~AnnotGeometry();
1104 
1105   virtual void draw(Gfx *gfx, GBool printing);
1106 
1107   void setType(AnnotSubtype new_type); // typeSquare or typeCircle
1108   void setInteriorColor(AnnotColor *new_color);
1109 
1110   // getters
getInteriorColor()1111   AnnotColor *getInteriorColor() const { return interiorColor; }
getBorderEffect()1112   AnnotBorderEffect *getBorderEffect() const { return borderEffect; }
getGeometryRect()1113   PDFRectangle *getGeometryRect() const { return geometryRect; }
1114 
1115 private:
1116 
1117   void initialize(PDFDoc *docA, Dict *dict);
1118 
1119   AnnotColor *interiorColor;        // IC
1120   AnnotBorderEffect *borderEffect;  // BE
1121   PDFRectangle *geometryRect;       // RD (combined with Rect)
1122 };
1123 
1124 //------------------------------------------------------------------------
1125 // AnnotPolygon
1126 //------------------------------------------------------------------------
1127 
1128 class AnnotPolygon: public AnnotMarkup {
1129 public:
1130 
1131   enum AnnotPolygonIntent {
1132     polygonCloud,      // PolygonCloud
1133     polylineDimension, // PolyLineDimension
1134     polygonDimension   // PolygonDimension
1135   };
1136 
1137   AnnotPolygon(PDFDoc *docA, PDFRectangle *rect, AnnotSubtype subType);
1138   AnnotPolygon(PDFDoc *docA, Dict *dict, Object *obj);
1139   ~AnnotPolygon();
1140 
1141   virtual void draw(Gfx *gfx, GBool printing);
1142 
1143   void setType(AnnotSubtype new_type); // typePolygon or typePolyLine
1144   void setVertices(AnnotPath *path);
1145   void setStartEndStyle(AnnotLineEndingStyle start, AnnotLineEndingStyle end);
1146   void setInteriorColor(AnnotColor *new_color);
1147   void setIntent(AnnotPolygonIntent new_intent);
1148 
1149   // getters
getVertices()1150   AnnotPath *getVertices() const { return vertices; }
getStartStyle()1151   AnnotLineEndingStyle getStartStyle() const { return startStyle; }
getEndStyle()1152   AnnotLineEndingStyle getEndStyle() const { return endStyle; }
getInteriorColor()1153   AnnotColor *getInteriorColor() const { return interiorColor; }
getBorderEffect()1154   AnnotBorderEffect *getBorderEffect() const { return borderEffect; }
getIntent()1155   AnnotPolygonIntent getIntent() const { return intent; }
1156 
1157 private:
1158 
1159   void initialize(PDFDoc *docA, Dict *dict);
1160 
1161   // required
1162   AnnotPath *vertices;              // Vertices
1163 
1164   // optional
1165   AnnotLineEndingStyle startStyle;  // LE       (Default [/None /None])
1166   AnnotLineEndingStyle endStyle;    //
1167   // inherited  from Annot
1168   // AnnotBorderBS border;          // BS
1169   AnnotColor *interiorColor;        // IC
1170   AnnotBorderEffect *borderEffect;  // BE
1171   AnnotPolygonIntent intent;        // IT
1172   // Measure
1173 };
1174 
1175 //------------------------------------------------------------------------
1176 // AnnotCaret
1177 //------------------------------------------------------------------------
1178 
1179 class AnnotCaret: public AnnotMarkup {
1180 public:
1181 
1182   enum AnnotCaretSymbol {
1183     symbolNone,     // None
1184     symbolP         // P
1185   };
1186 
1187   AnnotCaret(PDFDoc *docA, PDFRectangle *rect);
1188   AnnotCaret(PDFDoc *docA, Dict *dict, Object *obj);
1189   ~AnnotCaret();
1190 
1191   void setSymbol(AnnotCaretSymbol new_symbol);
1192 
1193   // getters
getSymbol()1194   AnnotCaretSymbol getSymbol() const { return symbol; }
getCaretRect()1195   PDFRectangle *getCaretRect() const { return caretRect; }
1196 
1197 private:
1198 
1199   void initialize(PDFDoc *docA, Dict *dict);
1200 
1201   AnnotCaretSymbol symbol;       // Sy         (Default None)
1202   PDFRectangle *caretRect;       // RD (combined with Rect)
1203 };
1204 
1205 //------------------------------------------------------------------------
1206 // AnnotInk
1207 //------------------------------------------------------------------------
1208 
1209 class AnnotInk: public AnnotMarkup {
1210 public:
1211 
1212   AnnotInk(PDFDoc *docA, PDFRectangle *rect);
1213   AnnotInk(PDFDoc *docA, Dict *dict, Object *obj);
1214   ~AnnotInk();
1215 
1216   virtual void draw(Gfx *gfx, GBool printing);
1217 
1218   void setInkList(AnnotPath **paths, int n_paths);
1219 
1220   // getters
getInkList()1221   AnnotPath **getInkList() const { return inkList; }
getInkListLength()1222   int getInkListLength() const { return inkListLength; }
1223 
1224 private:
1225 
1226   void initialize(PDFDoc *docA, Dict *dict);
1227   void writeInkList(AnnotPath **paths, int n_paths, Array *dest_array);
1228   void parseInkList(Array *src_array);
1229   void freeInkList();
1230 
1231   // required
1232   AnnotPath **inkList;       // InkList
1233   int inkListLength;
1234 
1235   // optional
1236   // inherited from Annot
1237   // AnnotBorderBS border;  // BS
1238 };
1239 
1240 //------------------------------------------------------------------------
1241 // AnnotFileAttachment
1242 //------------------------------------------------------------------------
1243 
1244 class AnnotFileAttachment: public AnnotMarkup {
1245 public:
1246 
1247   AnnotFileAttachment(PDFDoc *docA, PDFRectangle *rect, GooString *filename);
1248   AnnotFileAttachment(PDFDoc *docA, Dict *dict, Object *obj);
1249   ~AnnotFileAttachment();
1250 
1251   virtual void draw(Gfx *gfx, GBool printing);
1252 
1253   // getters
getFile()1254   Object *getFile() { return &file; }
getName()1255   GooString *getName() const { return name; }
1256 
1257 private:
1258 
1259   void initialize(PDFDoc *docA, Dict *dict);
1260 
1261   // required
1262   Object file;      // FS
1263 
1264   // optional
1265   GooString *name;  // Name
1266 };
1267 
1268 //------------------------------------------------------------------------
1269 // AnnotSound
1270 //------------------------------------------------------------------------
1271 
1272 class AnnotSound: public AnnotMarkup {
1273 public:
1274 
1275   AnnotSound(PDFDoc *docA, PDFRectangle *rect, Sound *soundA);
1276   AnnotSound(PDFDoc *docA, Dict *dict, Object *obj);
1277   ~AnnotSound();
1278 
1279   virtual void draw(Gfx *gfx, GBool printing);
1280 
1281   // getters
getSound()1282   Sound *getSound() { return sound; }
getName()1283   GooString *getName() const { return name; }
1284 
1285 private:
1286 
1287   void initialize(PDFDoc *docA, Dict *dict);
1288 
1289   // required
1290   Sound *sound;                  // Sound
1291 
1292   // optional
1293   GooString *name;               // Name
1294 };
1295 
1296 //------------------------------------------------------------------------
1297 // AnnotWidget
1298 //------------------------------------------------------------------------
1299 
1300 class AnnotWidget: public Annot {
1301 public:
1302 
1303   enum AnnotWidgetHighlightMode {
1304     highlightModeNone,    // N
1305     highlightModeInvert,  // I
1306     highlightModeOutline, // O
1307     highlightModePush     // P,T
1308   };
1309 
1310   AnnotWidget(PDFDoc *docA, Dict *dict, Object *obj);
1311   AnnotWidget(PDFDoc *docA, Dict *dict, Object *obj, FormField *fieldA);
1312   virtual ~AnnotWidget();
1313 
1314   virtual void draw(Gfx *gfx, GBool printing);
1315 
1316   void drawBorder();
1317   void drawFormFieldButton(GfxResources *resources, GooString *da);
1318   void drawFormFieldText(GfxResources *resources, GooString *da);
1319   void drawFormFieldChoice(GfxResources *resources, GooString *da);
1320   void generateFieldAppearance ();
1321   void updateAppearanceStream ();
1322 
getMode()1323   AnnotWidgetHighlightMode getMode() { return mode; }
getAppearCharacs()1324   AnnotAppearanceCharacs *getAppearCharacs() { return appearCharacs; }
getAction()1325   LinkAction *getAction() { return action; }  // The caller should not delete the result
1326   LinkAction *getAdditionalAction(AdditionalActionsType type); // The caller should delete the result
1327   LinkAction *getFormAdditionalAction(FormAdditionalActionsType type); // The caller should delete the result
getParent()1328   Dict *getParent() { return parent; }
1329 
1330 private:
1331 
1332   void initialize(PDFDoc *docA, Dict *dict);
1333 
1334   void drawText(GooString *text, GooString *da, GfxResources *resources,
1335 		GBool multiline, int comb, int quadding,
1336 		GBool txField, GBool forceZapfDingbats,
1337 		GBool password=false);
1338   void drawListBox(FormFieldChoice *fieldChoice,
1339 		   GooString *da, GfxResources *resources, int quadding);
1340 
1341   Form *form;
1342   FormField *field;                       // FormField object for this annotation
1343   AnnotWidgetHighlightMode mode;          // H  (Default I)
1344   AnnotAppearanceCharacs *appearCharacs;  // MK
1345   LinkAction *action;                     // A
1346   Object additionalActions;               // AA
1347   // inherited  from Annot
1348   // AnnotBorderBS border;                // BS
1349   Dict *parent;                           // Parent
1350   GBool addDingbatsResource;
1351   Ref updatedAppearanceStream; // {-1,-1} if updateAppearanceStream has never been called
1352 };
1353 
1354 //------------------------------------------------------------------------
1355 // Annot3D
1356 //------------------------------------------------------------------------
1357 
1358 class Annot3D: public Annot {
1359   class Activation {
1360   public:
1361     enum ActivationATrigger {
1362       aTriggerUnknown,
1363       aTriggerPageOpened,  // PO
1364       aTriggerPageVisible, // PV
1365       aTriggerUserAction   // XA
1366     };
1367 
1368     enum ActivationAState {
1369       aStateUnknown,
1370       aStateEnabled, // I
1371       aStateDisabled // L
1372     };
1373 
1374     enum ActivationDTrigger {
1375       dTriggerUnknown,
1376       dTriggerPageClosed,    // PC
1377       dTriggerPageInvisible, // PI
1378       dTriggerUserAction     // XD
1379     };
1380 
1381     enum ActivationDState {
1382       dStateUnknown,
1383       dStateUninstantiaded, // U
1384       dStateInstantiated,   // I
1385       dStateLive            // L
1386     };
1387 
1388     Activation(Dict *dict);
1389   private:
1390 
1391     ActivationATrigger aTrigger;  // A   (Default XA)
1392     ActivationAState aState;      // AIS (Default L)
1393     ActivationDTrigger dTrigger;  // D   (Default PI)
1394     ActivationDState dState;      // DIS (Default U)
1395     GBool displayToolbar;         // TB  (Default true)
1396     GBool displayNavigation;      // NP  (Default false);
1397   };
1398 public:
1399 
1400   Annot3D(PDFDoc *docA, PDFRectangle *rect);
1401   Annot3D(PDFDoc *docA, Dict *dict, Object *obj);
1402   ~Annot3D();
1403 
1404   // getters
1405 
1406 private:
1407 
1408   void initialize(PDFDoc *docA, Dict *dict);
1409 
1410   Activation *activation;  // 3DA
1411 };
1412 
1413 //------------------------------------------------------------------------
1414 // AnnotRichMedia
1415 //------------------------------------------------------------------------
1416 
1417 class AnnotRichMedia: public Annot {
1418 public:
1419   class Params {
1420   public:
1421     Params(Dict *dict);
1422     ~Params();
1423 
1424     GooString* getFlashVars() const;
1425 
1426   private:
1427     // optional
1428     GooString *flashVars; // FlashVars
1429   };
1430 
1431   class Instance {
1432   public:
1433     enum Type {
1434       type3D,       // 3D
1435       typeFlash,    // Flash
1436       typeSound,    // Sound
1437       typeVideo     // Video
1438     };
1439 
1440     Instance(Dict *dict);
1441     ~Instance();
1442 
1443     Type getType() const;
1444     Params* getParams() const;
1445 
1446   private:
1447     // optional
1448     Type type;     // Subtype
1449     Params *params; // Params
1450   };
1451 
1452   class Configuration {
1453   public:
1454     enum Type {
1455       type3D,       // 3D
1456       typeFlash,    // Flash
1457       typeSound,    // Sound
1458       typeVideo     // Video
1459     };
1460 
1461     Configuration(Dict *dict);
1462     ~Configuration();
1463 
1464     Type getType() const;
1465     GooString* getName() const;
1466     int getInstancesCount() const;
1467     Instance* getInstance(int index) const;
1468 
1469   private:
1470     // optional
1471     Type type;            // Subtype
1472     GooString *name;      // Name
1473     Instance **instances; // Instances
1474     int nInstances;
1475   };
1476 
1477   class Content;
1478 
1479   class Asset {
1480   public:
1481     Asset();
1482     ~Asset();
1483 
1484     GooString* getName() const;
1485     Object* getFileSpec() const;
1486 
1487   private:
1488     friend class AnnotRichMedia::Content;
1489 
1490     GooString *name;
1491     Object fileSpec;
1492   };
1493 
1494   class Content {
1495   public:
1496     Content(Dict *dict);
1497     ~Content();
1498 
1499     int getConfigurationsCount() const;
1500     Configuration* getConfiguration(int index) const;
1501 
1502     int getAssetsCount() const;
1503     Asset* getAsset(int index) const;
1504 
1505   private:
1506     // optional
1507     Configuration **configurations; // Configurations
1508     int nConfigurations;
1509 
1510     Asset **assets; // Assets
1511     int nAssets;
1512   };
1513 
1514   class Activation {
1515   public:
1516     enum Condition {
1517       conditionPageOpened,  // PO
1518       conditionPageVisible, // PV
1519       conditionUserAction   // XA
1520     };
1521 
1522     Activation(Dict *dict);
1523 
1524     Condition getCondition() const;
1525 
1526   private:
1527     // optional
1528     Condition condition;
1529   };
1530 
1531   class Deactivation {
1532   public:
1533     enum Condition {
1534       conditionPageClosed,    // PC
1535       conditionPageInvisible, // PI
1536       conditionUserAction     // XD
1537     };
1538 
1539     Deactivation(Dict *dict);
1540 
1541     Condition getCondition() const;
1542 
1543   private:
1544     // optional
1545     Condition condition;
1546   };
1547 
1548   class Settings {
1549   public:
1550     Settings(Dict *dict);
1551     ~Settings();
1552 
1553     Activation* getActivation() const;
1554     Deactivation* getDeactivation() const;
1555 
1556   private:
1557     // optional
1558     Activation *activation;
1559     Deactivation *deactivation;
1560   };
1561 
1562   AnnotRichMedia(PDFDoc *docA, PDFRectangle *rect);
1563   AnnotRichMedia(PDFDoc *docA, Dict *dict, Object *obj);
1564   ~AnnotRichMedia();
1565 
1566   Content* getContent() const;
1567 
1568   Settings* getSettings() const;
1569 
1570 private:
1571   void initialize(PDFDoc *docA, Dict *dict);
1572 
1573   // required
1574   Content *content;     // RichMediaContent
1575 
1576   // optional
1577   Settings *settings;   // RichMediaSettings
1578 };
1579 
1580 
1581 //------------------------------------------------------------------------
1582 // Annots
1583 //------------------------------------------------------------------------
1584 
1585 class Annots {
1586 public:
1587 
1588   // Build a list of Annot objects and call setPage on them
1589   Annots(PDFDoc *docA, int page, Object *annotsObj);
1590 
1591   ~Annots();
1592 
1593   // Iterate through list of annotations.
getNumAnnots()1594   int getNumAnnots() { return nAnnots; }
getAnnot(int i)1595   Annot *getAnnot(int i) { return annots[i]; }
1596   void appendAnnot(Annot *annot);
1597   GBool removeAnnot(Annot *annot);
1598 
1599 private:
1600   Annot* createAnnot(Dict* dict, Object *obj);
1601   Annot *findAnnot(Ref *ref);
1602 
1603   PDFDoc *doc;
1604   Annot **annots;
1605   int nAnnots;
1606   int size;
1607 };
1608 
1609 #endif
1610