1 //========================================================================
5 // Copyright 2000-2003 Glyph & Cog, LLC
7 //========================================================================
9 //========================================================================
11 // Modified under the Poppler project - http://poppler.freedesktop.org
13 // All changes made under the Poppler project to this file are licensed
14 // under GPL version 2 or later
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 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>
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
33 //========================================================================
38 #ifdef USE_GCC_PRAGMAS
46 class CharCodeToUnicode
;
54 class FormFieldChoice
;
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
74 enum AnnotExternalDataType
{
75 annotExternalDataMarkupUnknown
,
76 annotExternalDataMarkup3D
// Markup3D
79 //------------------------------------------------------------------------
81 //------------------------------------------------------------------------
86 AnnotCoord() : x(0), y(0) { }
87 AnnotCoord(double _x
, double _y
) : x(_x
), y(_y
) { }
89 double getX() const { return x
; }
90 double getY() const { return y
; }
97 //------------------------------------------------------------------------
99 //------------------------------------------------------------------------
104 AnnotPath(Array
*array
);
105 AnnotPath(AnnotCoord
**coords
, int coordLength
);
108 double getX(int coord
) const;
109 double getY(int coord
) const;
110 AnnotCoord
*getCoord(int coord
) const;
111 int getCoordsLength() const { return coordsLength
; }
116 void parsePathArray(Array
*array
);
119 //------------------------------------------------------------------------
121 //------------------------------------------------------------------------
123 class AnnotCalloutLine
{
126 AnnotCalloutLine(double x1
, double y1
, double x2
, double y2
);
127 virtual ~AnnotCalloutLine() { }
129 double getX1() const { return coord1
.getX(); }
130 double getY1() const { return coord1
.getY(); }
131 double getX2() const { return coord2
.getX(); }
132 double getY2() const { return coord2
.getY(); }
136 AnnotCoord coord1
, coord2
;
139 //------------------------------------------------------------------------
140 // AnnotCalloutMultiLine
141 //------------------------------------------------------------------------
143 class AnnotCalloutMultiLine
: public AnnotCalloutLine
{
146 AnnotCalloutMultiLine(double x1
, double y1
, double x2
, double y2
,
147 double x3
, double y3
);
149 double getX3() const { return coord3
.getX(); }
150 double getY3() const { return coord3
.getY(); }
157 //------------------------------------------------------------------------
159 //------------------------------------------------------------------------
161 class AnnotBorderEffect
{
164 enum AnnotBorderEffectType
{
165 borderEffectNoEffect
, // S
166 borderEffectCloudy
// C
169 AnnotBorderEffect(Dict
*dict
);
171 AnnotBorderEffectType
getEffectType() const { return effectType
; }
172 double getIntensity() const { return intensity
; }
176 AnnotBorderEffectType effectType
; // S (Default S)
177 double intensity
; // I (Default 0)
180 //------------------------------------------------------------------------
181 // AnnotQuadrilateral
182 //------------------------------------------------------------------------
184 class AnnotQuadrilaterals
{
186 class AnnotQuadrilateral
{
188 AnnotQuadrilateral(double x1
, double y1
, double x2
, double y2
, double x3
,
189 double y3
, double x4
, double y4
);
191 AnnotCoord coord1
, coord2
, coord3
, coord4
;
194 AnnotQuadrilaterals(Array
*array
, PDFRectangle
*rect
);
195 AnnotQuadrilaterals(AnnotQuadrilateral
**quads
, int quadsLength
);
196 ~AnnotQuadrilaterals();
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
);
206 int getQuadrilateralsLength() const { return quadrilateralsLength
; }
209 AnnotQuadrilateral
** quadrilaterals
;
210 int quadrilateralsLength
;
213 //------------------------------------------------------------------------
215 //------------------------------------------------------------------------
219 enum AnnotBorderType
{
224 enum AnnotBorderStyle
{
225 borderSolid
, // Solid
226 borderDashed
, // Dashed
227 borderBeveled
, // Beveled
228 borderInset
, // Inset
229 borderUnderlined
// Underlined
232 virtual ~AnnotBorder();
234 virtual void setWidth(double new_width
) { width
= new_width
; }
236 virtual AnnotBorderType
getType() const = 0;
237 virtual double getWidth() const { return width
; }
238 virtual int getDashLength() const { return dashLength
; }
239 virtual double *getDash() const { return dash
; }
240 virtual AnnotBorderStyle
getStyle() const { return style
; }
242 virtual void writeToObject(XRef
*xref
, Object
*obj1
) const = 0;
247 GBool
parseDashArray(Object
*dashObj
);
249 AnnotBorderType type
;
251 static const int DASH_LIMIT
= 10; // implementation note 82 in Appendix H.
254 AnnotBorderStyle style
;
257 //------------------------------------------------------------------------
259 //------------------------------------------------------------------------
261 class AnnotBorderArray
: public AnnotBorder
{
264 AnnotBorderArray(Array
*array
);
266 void setHorizontalCorner(double hc
) { horizontalCorner
= hc
; }
267 void setVerticalCorner(double vc
) { verticalCorner
= vc
; }
269 double getHorizontalCorner() const { return horizontalCorner
; }
270 double getVerticalCorner() const { return verticalCorner
; }
273 virtual AnnotBorderType
getType() const { return typeArray
; }
274 virtual void writeToObject(XRef
*xref
, Object
*obj1
) const;
276 double horizontalCorner
; // (Default 0)
277 double verticalCorner
; // (Default 0)
278 // double width; // (Default 1) (inherited from AnnotBorder)
281 //------------------------------------------------------------------------
283 //------------------------------------------------------------------------
285 class AnnotBorderBS
: public AnnotBorder
{
289 AnnotBorderBS(Dict
*dict
);
292 virtual AnnotBorderType
getType() const { return typeBS
; }
293 virtual void writeToObject(XRef
*xref
, Object
*obj1
) const;
295 const char *getStyleName() const;
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)
302 //------------------------------------------------------------------------
304 //------------------------------------------------------------------------
309 enum AnnotColorSpace
{
310 colorTransparent
= 0,
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);
322 void adjustColor(int adjust
);
324 AnnotColorSpace
getSpace() const { return (AnnotColorSpace
) length
; }
325 const double *getValues() const { return values
; }
327 void writeToObject(XRef
*xref
, Object
*dest
) const;
335 //------------------------------------------------------------------------
337 //------------------------------------------------------------------------
342 enum AnnotIconFitScaleWhen
{
349 enum AnnotIconFitScale
{
350 scaleAnamorphic
, // A
351 scaleProportional
// P
354 AnnotIconFit(Dict
*dict
);
356 AnnotIconFitScaleWhen
getScaleWhen() { return scaleWhen
; }
357 AnnotIconFitScale
getScale() { return scale
; }
358 double getLeft() { return left
; }
359 double getBottom() { return bottom
; }
360 bool getFullyBounds() { return fullyBounds
; }
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)
371 //------------------------------------------------------------------------
373 //------------------------------------------------------------------------
375 class AnnotAppearance
{
378 enum AnnotAppearanceType
{
384 AnnotAppearance(PDFDoc
*docA
, Object
*dict
);
387 // State is ignored if no subdictionary is present
388 void getAppearanceStream(AnnotAppearanceType type
, const char *state
, Object
*dest
);
390 // Access keys in normal appearance subdictionary (N)
391 GooString
* getStateKey(int i
);
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();
398 // Test if this AnnotAppearance references the specified stream
399 GBool
referencesStream(Ref targetStreamRef
);
402 static GBool
referencesStream(Object
*stateObj
, Ref targetStreamRef
);
403 void removeStream(Ref refToStream
);
404 void removeStateStreams(Object
*state
);
408 XRef
*xref
; // the xref table for this PDF file
409 Object appearDict
; // Annotation's AP
412 //------------------------------------------------------------------------
413 // AnnotAppearanceCharacs
414 //------------------------------------------------------------------------
416 class AnnotAppearanceCharacs
{
419 enum AnnotAppearanceCharacsTextPos
{
421 captionNoCaption
, // 1
429 AnnotAppearanceCharacs(Dict
*dict
);
430 ~AnnotAppearanceCharacs();
432 int getRotation() { return rotation
; }
433 AnnotColor
*getBorderColor() { return borderColor
; }
434 AnnotColor
*getBackColor() { return backColor
; }
435 GooString
*getNormalCaption() { return normalCaption
; }
436 GooString
*getRolloverCaption() { return rolloverCaption
; }
437 GooString
*getAlternateCaption() { return alternateCaption
; }
438 AnnotIconFit
*getIconFit() { return iconFit
; }
439 AnnotAppearanceCharacsTextPos
getPosition() { return position
; }
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
452 AnnotIconFit
*iconFit
; // IF
453 AnnotAppearanceCharacsTextPos position
; // TP (Default 0)
456 //------------------------------------------------------------------------
457 // AnnotAppearanceBBox
458 //------------------------------------------------------------------------
460 class AnnotAppearanceBBox
463 AnnotAppearanceBBox(PDFRectangle
*init
);
465 void setBorderWidth(double w
) { borderWidth
= w
; }
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;
471 // Get boundaries in page coordinates
472 double getPageXMin() const;
473 double getPageYMin() const;
474 double getPageXMax() const;
475 double getPageYMax() const;
478 double origX
, origY
, borderWidth
;
479 double minX
, minY
, maxX
, maxY
;
482 //------------------------------------------------------------------------
484 //------------------------------------------------------------------------
491 flagUnknown
= 0x0000,
492 flagInvisible
= 0x0001,
496 flagNoRotate
= 0x0010,
498 flagReadOnly
= 0x0040,
500 flagToggleNoView
= 0x0100,
501 flagLockedContents
= 0x0200
508 typeFreeText
, // FreeText 3
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
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
531 typeRichMedia
// RichMedia 26
535 * Describes the additional actions of a screen or widget annotation.
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
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
557 Annot(PDFDoc
*docA
, PDFRectangle
*rectA
);
558 Annot(PDFDoc
*docA
, Dict
*dict
);
559 Annot(PDFDoc
*docA
, Dict
*dict
, Object
*obj
);
560 GBool
isOk() { return ok
; }
565 virtual void draw(Gfx
*gfx
, GBool printing
);
566 // Get the resource dict of the appearance stream
567 virtual Object
*getAppearanceResDict(Object
*dest
);
569 GBool
match(Ref
*refA
)
570 { return ref
.num
== refA
->num
&& ref
.gen
== refA
->gen
; }
577 double getFontSize() { return fontSize
; }
579 void setRect(PDFRectangle
*rect
);
580 void setRect(double x1
, double y1
, double x2
, double y2
);
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
);
589 void setBorder(AnnotBorder
*new_border
); // Takes ownership
591 // The annotation takes the ownership of
593 void setColor(AnnotColor
*new_color
);
595 void setAppearanceState(const char *state
);
598 PDFDoc
*getDoc() const { return doc
; }
599 XRef
*getXRef() const { return xref
; }
600 GBool
getHasRef() const { return hasRef
; }
601 Ref
getRef() const { return ref
; }
602 AnnotSubtype
getType() const { return type
; }
603 PDFRectangle
*getRect() const { return rect
; }
604 void getRect(double *x1
, double *y1
, double *x2
, double *y2
) const;
605 GooString
*getContents() const { return contents
; }
606 int getPageNum() const { return page
; }
607 GooString
*getName() const { return name
; }
608 GooString
*getModified() const { return modified
; }
609 Guint
getFlags() const { return flags
; }
610 AnnotAppearance
*getAppearStreams() const { return appearStreams
; }
611 GooString
*getAppearState() const { return appearState
; }
612 AnnotBorder
*getBorder() const { return border
; }
613 AnnotColor
*getColor() const { return color
; }
614 int getTreeKey() const { return treeKey
; }
616 int getId() { return ref
.num
; }
618 // Check if point is inside the annot rectangle.
619 GBool
inRect(double x
, double y
) const;
622 void readArrayNum(Object
*pdfArray
, int key
, double *value
);
623 // write vStr[i:j[ in appearBuf
625 void initialize (PDFDoc
*docA
, Dict
*dict
);
626 void setPage (int new_page
, GBool updateP
); // Called by Page::addAnnot and Annots ctor
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
,
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;
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
);
651 // Delete appearance streams and reset appearance state
652 void invalidateAppearance();
659 AnnotSubtype type
; // Annotation type
660 PDFRectangle
*rect
; // Rect
663 GooString
*contents
; // Contents
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;
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
691 //------------------------------------------------------------------------
693 //------------------------------------------------------------------------
695 class AnnotPopup
: public Annot
{
697 AnnotPopup(PDFDoc
*docA
, PDFRectangle
*rect
);
698 AnnotPopup(PDFDoc
*docA
, Dict
*dict
, Object
*obj
);
701 Object
*getParent(Object
*obj
) { return parent
.fetch (xref
, obj
); }
702 Object
*getParentNF() { return &parent
; }
703 void setParent(Object
*parentA
);
704 void setParent(Annot
*parentA
);
705 GBool
getOpen() const { return open
; }
706 void setOpen(GBool openA
);
709 void initialize(PDFDoc
*docA
, Dict
*dict
);
711 Object parent
; // Parent
715 //------------------------------------------------------------------------
717 //------------------------------------------------------------------------
719 class AnnotMarkup
: public Annot
{
721 enum AnnotMarkupReplyType
{
723 replyTypeGroup
// Group
726 AnnotMarkup(PDFDoc
*docA
, PDFRectangle
*rect
);
727 AnnotMarkup(PDFDoc
*docA
, Dict
*dict
, Object
*obj
);
728 virtual ~AnnotMarkup();
731 GooString
*getLabel() const { return label
; }
732 AnnotPopup
*getPopup() const { return popup
; }
733 double getOpacity() const { return opacity
; }
735 GooString
*getDate() const { return date
; }
736 int getInReplyToID() const { return inReplyTo
.num
; }
737 GooString
*getSubject() const { return subject
; }
738 AnnotMarkupReplyType
getReplyTo() const { return replyTo
; }
739 AnnotExternalDataType
getExData() const { return exData
; }
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
);
748 virtual void removeReferencedObjects();
750 GooString
*label
; // T (Default autor)
751 AnnotPopup
*popup
; // Popup
752 double opacity
; // CA (Default 1.0)
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
760 //GooString *intent; // IT
761 AnnotExternalDataType exData
; // ExData
764 void initialize(PDFDoc
*docA
, Dict
*dict
, Object
*obj
);
767 //------------------------------------------------------------------------
769 //------------------------------------------------------------------------
771 class AnnotText
: public AnnotMarkup
{
773 enum AnnotTextState
{
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
786 AnnotText(PDFDoc
*docA
, PDFRectangle
*rect
);
787 AnnotText(PDFDoc
*docA
, Dict
*dict
, Object
*obj
);
790 virtual void draw(Gfx
*gfx
, GBool printing
);
793 GBool
getOpen() const { return open
; }
794 GooString
*getIcon() const { return icon
; }
795 AnnotTextState
getState() const { return state
; }
797 void setOpen(GBool openA
);
798 void setIcon(GooString
*new_icon
);
802 void initialize(PDFDoc
*docA
, Dict
*dict
);
804 GBool open
; // Open (Default false)
805 GooString
*icon
; // Name (Default Note)
806 AnnotTextState state
; // State (Default Umarked if
808 // None if StareModel Review)
811 //------------------------------------------------------------------------
813 //------------------------------------------------------------------------
817 class AnnotMovie
: public Annot
{
819 AnnotMovie(PDFDoc
*docA
, PDFRectangle
*rect
, Movie
*movieA
);
820 AnnotMovie(PDFDoc
*docA
, Dict
*dict
, Object
*obj
);
823 virtual void draw(Gfx
*gfx
, GBool printing
);
825 GooString
* getTitle() { return title
; }
826 Movie
* getMovie() { return movie
; }
829 void initialize(PDFDoc
*docA
, Dict
*dict
);
831 GooString
* title
; // T
832 Movie
* movie
; // Movie + A
836 //------------------------------------------------------------------------
838 //------------------------------------------------------------------------
840 class AnnotScreen
: public Annot
{
843 AnnotScreen(PDFDoc
*docA
, PDFRectangle
*rect
);
844 AnnotScreen(PDFDoc
*docA
, Dict
*dict
, Object
*obj
);
847 GooString
* getTitle() { return title
; }
849 AnnotAppearanceCharacs
*getAppearCharacs() { return appearCharacs
; }
850 LinkAction
* getAction() { return action
; }
851 LinkAction
*getAdditionalAction(AdditionalActionsType type
);
854 void initialize(PDFDoc
*docA
, Dict
*dict
);
857 GooString
* title
; // T
859 AnnotAppearanceCharacs
* appearCharacs
; // MK
861 LinkAction
*action
; // A
862 Object additionalActions
; // AA
865 //------------------------------------------------------------------------
867 //------------------------------------------------------------------------
869 class AnnotLink
: public Annot
{
872 enum AnnotLinkEffect
{
879 AnnotLink(PDFDoc
*docA
, PDFRectangle
*rect
);
880 AnnotLink(PDFDoc
*docA
, Dict
*dict
, Object
*obj
);
881 virtual ~AnnotLink();
883 virtual void draw(Gfx
*gfx
, GBool printing
);
886 LinkAction
*getAction() const { return action
; }
887 AnnotLinkEffect
getLinkEffect() const { return linkEffect
; }
888 Dict
*getUriAction() const { return uriAction
; }
889 AnnotQuadrilaterals
*getQuadrilaterals() const { return quadrilaterals
; }
893 void initialize(PDFDoc
*docA
, Dict
*dict
);
895 LinkAction
*action
; // A, Dest
896 AnnotLinkEffect linkEffect
; // H (Default I)
897 Dict
*uriAction
; // PA
899 AnnotQuadrilaterals
*quadrilaterals
; // QuadPoints
902 //------------------------------------------------------------------------
904 //------------------------------------------------------------------------
906 class AnnotFreeText
: public AnnotMarkup
{
909 enum AnnotFreeTextQuadding
{
910 quaddingLeftJustified
, // 0
911 quaddingCentered
, // 1
912 quaddingRightJustified
// 2
915 enum AnnotFreeTextIntent
{
916 intentFreeText
, // FreeText
917 intentFreeTextCallout
, // FreeTextCallout
918 intentFreeTextTypeWriter
// FreeTextTypeWriter
921 AnnotFreeText(PDFDoc
*docA
, PDFRectangle
*rect
, GooString
*da
);
922 AnnotFreeText(PDFDoc
*docA
, Dict
*dict
, Object
*obj
);
925 virtual void draw(Gfx
*gfx
, GBool printing
);
926 virtual Object
*getAppearanceResDict(Object
*dest
);
927 virtual void setContents(GooString
*new_content
);
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
);
936 GooString
*getAppearanceString() const { return appearanceString
; }
937 AnnotFreeTextQuadding
getQuadding() const { return quadding
; }
939 GooString
*getStyleString() const { return styleString
; }
940 AnnotCalloutLine
*getCalloutLine() const { return calloutLine
; }
941 AnnotFreeTextIntent
getIntent() const { return intent
; }
942 AnnotBorderEffect
*getBorderEffect() const { return borderEffect
; }
943 PDFRectangle
*getRectangle() const { return rectangle
; }
944 AnnotLineEndingStyle
getEndStyle() const { return endStyle
; }
948 void initialize(PDFDoc
*docA
, Dict
*dict
);
949 static void parseAppearanceString(GooString
*da
, double &fontsize
, AnnotColor
* &fontcolor
);
950 void generateFreeTextAppearance();
953 GooString
*appearanceString
; // DA
956 AnnotFreeTextQuadding quadding
; // Q (Default 0)
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)
968 //------------------------------------------------------------------------
970 //------------------------------------------------------------------------
972 class AnnotLine
: public AnnotMarkup
{
975 enum AnnotLineIntent
{
976 intentLineArrow
, // LineArrow
977 intentLineDimension
// LineDimension
980 enum AnnotLineCaptionPos
{
981 captionPosInline
, // Inline
985 AnnotLine(PDFDoc
*docA
, PDFRectangle
*rect
);
986 AnnotLine(PDFDoc
*docA
, Dict
*dict
, Object
*obj
);
989 virtual void draw(Gfx
*gfx
, GBool printing
);
990 virtual Object
*getAppearanceResDict(Object
*dest
);
991 virtual void setContents(GooString
*new_content
);
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
);
1002 AnnotLineEndingStyle
getStartStyle() const { return startStyle
; }
1003 AnnotLineEndingStyle
getEndStyle() const { return endStyle
; }
1004 AnnotColor
*getInteriorColor() const { return interiorColor
; }
1005 double getLeaderLineLength() const { return leaderLineLength
; }
1006 double getLeaderLineExtension() const { return leaderLineExtension
; }
1007 bool getCaption() const { return caption
; }
1008 AnnotLineIntent
getIntent() const { return intent
; }
1009 double getLeaderLineOffset() const { return leaderLineOffset
; }
1010 AnnotLineCaptionPos
getCaptionPos() const { return captionPos
; }
1011 Dict
*getMeasure() const { return measure
; }
1012 double getCaptionTextHorizontal() const { return captionTextHorizontal
; }
1013 double getCaptionTextVertical() const { return captionTextVertical
; }
1014 double getX1() const { return coord1
->getX(); }
1015 double getY1() const { return coord1
->getY(); }
1016 double getX2() const { return coord2
->getX(); }
1017 double getY2() const { return coord2
->getY(); }
1021 void initialize(PDFDoc
*docA
, Dict
*dict
);
1022 void generateLineAppearance();
1025 AnnotCoord
*coord1
, *coord2
;
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
; //
1044 //------------------------------------------------------------------------
1046 //------------------------------------------------------------------------
1048 class AnnotTextMarkup
: public AnnotMarkup
{
1051 AnnotTextMarkup(PDFDoc
*docA
, PDFRectangle
*rect
, AnnotSubtype subType
);
1052 AnnotTextMarkup(PDFDoc
*docA
, Dict
*dict
, Object
*obj
);
1053 virtual ~AnnotTextMarkup();
1055 virtual void draw(Gfx
*gfx
, GBool printing
);
1057 // typeHighlight, typeUnderline, typeSquiggly or typeStrikeOut
1058 void setType(AnnotSubtype new_type
);
1060 void setQuadrilaterals(AnnotQuadrilaterals
*quadPoints
);
1062 AnnotQuadrilaterals
*getQuadrilaterals() const { return quadrilaterals
; }
1066 void initialize(PDFDoc
*docA
, Dict
*dict
);
1068 AnnotQuadrilaterals
*quadrilaterals
; // QuadPoints
1071 //------------------------------------------------------------------------
1073 //------------------------------------------------------------------------
1075 class AnnotStamp
: public AnnotMarkup
{
1078 AnnotStamp(PDFDoc
*docA
, PDFRectangle
*rect
);
1079 AnnotStamp(PDFDoc
*docA
, Dict
*dict
, Object
*obj
);
1082 void setIcon(GooString
*new_icon
);
1085 GooString
*getIcon() const { return icon
; }
1089 void initialize(PDFDoc
*docA
, Dict
*dict
);
1091 GooString
*icon
; // Name (Default Draft)
1094 //------------------------------------------------------------------------
1096 //------------------------------------------------------------------------
1098 class AnnotGeometry
: public AnnotMarkup
{
1101 AnnotGeometry(PDFDoc
*docA
, PDFRectangle
*rect
, AnnotSubtype subType
);
1102 AnnotGeometry(PDFDoc
*docA
, Dict
*dict
, Object
*obj
);
1105 virtual void draw(Gfx
*gfx
, GBool printing
);
1107 void setType(AnnotSubtype new_type
); // typeSquare or typeCircle
1108 void setInteriorColor(AnnotColor
*new_color
);
1111 AnnotColor
*getInteriorColor() const { return interiorColor
; }
1112 AnnotBorderEffect
*getBorderEffect() const { return borderEffect
; }
1113 PDFRectangle
*getGeometryRect() const { return geometryRect
; }
1117 void initialize(PDFDoc
*docA
, Dict
*dict
);
1119 AnnotColor
*interiorColor
; // IC
1120 AnnotBorderEffect
*borderEffect
; // BE
1121 PDFRectangle
*geometryRect
; // RD (combined with Rect)
1124 //------------------------------------------------------------------------
1126 //------------------------------------------------------------------------
1128 class AnnotPolygon
: public AnnotMarkup
{
1131 enum AnnotPolygonIntent
{
1132 polygonCloud
, // PolygonCloud
1133 polylineDimension
, // PolyLineDimension
1134 polygonDimension
// PolygonDimension
1137 AnnotPolygon(PDFDoc
*docA
, PDFRectangle
*rect
, AnnotSubtype subType
);
1138 AnnotPolygon(PDFDoc
*docA
, Dict
*dict
, Object
*obj
);
1141 virtual void draw(Gfx
*gfx
, GBool printing
);
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
);
1150 AnnotPath
*getVertices() const { return vertices
; }
1151 AnnotLineEndingStyle
getStartStyle() const { return startStyle
; }
1152 AnnotLineEndingStyle
getEndStyle() const { return endStyle
; }
1153 AnnotColor
*getInteriorColor() const { return interiorColor
; }
1154 AnnotBorderEffect
*getBorderEffect() const { return borderEffect
; }
1155 AnnotPolygonIntent
getIntent() const { return intent
; }
1159 void initialize(PDFDoc
*docA
, Dict
*dict
);
1162 AnnotPath
*vertices
; // Vertices
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
1175 //------------------------------------------------------------------------
1177 //------------------------------------------------------------------------
1179 class AnnotCaret
: public AnnotMarkup
{
1182 enum AnnotCaretSymbol
{
1187 AnnotCaret(PDFDoc
*docA
, PDFRectangle
*rect
);
1188 AnnotCaret(PDFDoc
*docA
, Dict
*dict
, Object
*obj
);
1191 void setSymbol(AnnotCaretSymbol new_symbol
);
1194 AnnotCaretSymbol
getSymbol() const { return symbol
; }
1195 PDFRectangle
*getCaretRect() const { return caretRect
; }
1199 void initialize(PDFDoc
*docA
, Dict
*dict
);
1201 AnnotCaretSymbol symbol
; // Sy (Default None)
1202 PDFRectangle
*caretRect
; // RD (combined with Rect)
1205 //------------------------------------------------------------------------
1207 //------------------------------------------------------------------------
1209 class AnnotInk
: public AnnotMarkup
{
1212 AnnotInk(PDFDoc
*docA
, PDFRectangle
*rect
);
1213 AnnotInk(PDFDoc
*docA
, Dict
*dict
, Object
*obj
);
1216 virtual void draw(Gfx
*gfx
, GBool printing
);
1218 void setInkList(AnnotPath
**paths
, int n_paths
);
1221 AnnotPath
**getInkList() const { return inkList
; }
1222 int getInkListLength() const { return inkListLength
; }
1226 void initialize(PDFDoc
*docA
, Dict
*dict
);
1227 void writeInkList(AnnotPath
**paths
, int n_paths
, Array
*dest_array
);
1228 void parseInkList(Array
*src_array
);
1232 AnnotPath
**inkList
; // InkList
1236 // inherited from Annot
1237 // AnnotBorderBS border; // BS
1240 //------------------------------------------------------------------------
1241 // AnnotFileAttachment
1242 //------------------------------------------------------------------------
1244 class AnnotFileAttachment
: public AnnotMarkup
{
1247 AnnotFileAttachment(PDFDoc
*docA
, PDFRectangle
*rect
, GooString
*filename
);
1248 AnnotFileAttachment(PDFDoc
*docA
, Dict
*dict
, Object
*obj
);
1249 ~AnnotFileAttachment();
1251 virtual void draw(Gfx
*gfx
, GBool printing
);
1254 Object
*getFile() { return &file
; }
1255 GooString
*getName() const { return name
; }
1259 void initialize(PDFDoc
*docA
, Dict
*dict
);
1265 GooString
*name
; // Name
1268 //------------------------------------------------------------------------
1270 //------------------------------------------------------------------------
1272 class AnnotSound
: public AnnotMarkup
{
1275 AnnotSound(PDFDoc
*docA
, PDFRectangle
*rect
, Sound
*soundA
);
1276 AnnotSound(PDFDoc
*docA
, Dict
*dict
, Object
*obj
);
1279 virtual void draw(Gfx
*gfx
, GBool printing
);
1282 Sound
*getSound() { return sound
; }
1283 GooString
*getName() const { return name
; }
1287 void initialize(PDFDoc
*docA
, Dict
*dict
);
1290 Sound
*sound
; // Sound
1293 GooString
*name
; // Name
1296 //------------------------------------------------------------------------
1298 //------------------------------------------------------------------------
1300 class AnnotWidget
: public Annot
{
1303 enum AnnotWidgetHighlightMode
{
1304 highlightModeNone
, // N
1305 highlightModeInvert
, // I
1306 highlightModeOutline
, // O
1307 highlightModePush
// P,T
1310 AnnotWidget(PDFDoc
*docA
, Dict
*dict
, Object
*obj
);
1311 AnnotWidget(PDFDoc
*docA
, Dict
*dict
, Object
*obj
, FormField
*fieldA
);
1312 virtual ~AnnotWidget();
1314 virtual void draw(Gfx
*gfx
, GBool printing
);
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 ();
1323 AnnotWidgetHighlightMode
getMode() { return mode
; }
1324 AnnotAppearanceCharacs
*getAppearCharacs() { return appearCharacs
; }
1325 LinkAction
*getAction() { return action
; }
1326 LinkAction
*getAdditionalAction(AdditionalActionsType type
);
1327 LinkAction
*getFormAdditionalAction(FormAdditionalActionsType type
);
1328 Dict
*getParent() { return parent
; }
1332 void initialize(PDFDoc
*docA
, Dict
*dict
);
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
);
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
1354 //------------------------------------------------------------------------
1356 //------------------------------------------------------------------------
1358 class Annot3D
: public Annot
{
1361 enum ActivationATrigger
{
1363 aTriggerPageOpened
, // PO
1364 aTriggerPageVisible
, // PV
1365 aTriggerUserAction
// XA
1368 enum ActivationAState
{
1374 enum ActivationDTrigger
{
1376 dTriggerPageClosed
, // PC
1377 dTriggerPageInvisible
, // PI
1378 dTriggerUserAction
// XD
1381 enum ActivationDState
{
1383 dStateUninstantiaded
, // U
1384 dStateInstantiated
, // I
1388 Activation(Dict
*dict
);
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);
1400 Annot3D(PDFDoc
*docA
, PDFRectangle
*rect
);
1401 Annot3D(PDFDoc
*docA
, Dict
*dict
, Object
*obj
);
1408 void initialize(PDFDoc
*docA
, Dict
*dict
);
1410 Activation
*activation
; // 3DA
1413 //------------------------------------------------------------------------
1415 //------------------------------------------------------------------------
1417 class AnnotRichMedia
: public Annot
{
1424 GooString
* getFlashVars() const;
1428 GooString
*flashVars
; // FlashVars
1440 Instance(Dict
*dict
);
1443 Type
getType() const;
1444 Params
* getParams() const;
1448 Type type
; // Subtype
1449 Params
*params
; // Params
1452 class Configuration
{
1461 Configuration(Dict
*dict
);
1464 Type
getType() const;
1465 GooString
* getName() const;
1466 int getInstancesCount() const;
1467 Instance
* getInstance(int index
) const;
1471 Type type
; // Subtype
1472 GooString
*name
; // Name
1473 Instance
**instances
; // Instances
1484 GooString
* getName() const;
1485 Object
* getFileSpec() const;
1488 friend class AnnotRichMedia::Content
;
1496 Content(Dict
*dict
);
1499 int getConfigurationsCount() const;
1500 Configuration
* getConfiguration(int index
) const;
1502 int getAssetsCount() const;
1503 Asset
* getAsset(int index
) const;
1507 Configuration
**configurations
; // Configurations
1508 int nConfigurations
;
1510 Asset
**assets
; // Assets
1517 conditionPageOpened
, // PO
1518 conditionPageVisible
, // PV
1519 conditionUserAction
// XA
1522 Activation(Dict
*dict
);
1524 Condition
getCondition() const;
1528 Condition condition
;
1531 class Deactivation
{
1534 conditionPageClosed
, // PC
1535 conditionPageInvisible
, // PI
1536 conditionUserAction
// XD
1539 Deactivation(Dict
*dict
);
1541 Condition
getCondition() const;
1545 Condition condition
;
1550 Settings(Dict
*dict
);
1553 Activation
* getActivation() const;
1554 Deactivation
* getDeactivation() const;
1558 Activation
*activation
;
1559 Deactivation
*deactivation
;
1562 AnnotRichMedia(PDFDoc
*docA
, PDFRectangle
*rect
);
1563 AnnotRichMedia(PDFDoc
*docA
, Dict
*dict
, Object
*obj
);
1566 Content
* getContent() const;
1568 Settings
* getSettings() const;
1571 void initialize(PDFDoc
*docA
, Dict
*dict
);
1574 Content
*content
; // RichMediaContent
1577 Settings
*settings
; // RichMediaSettings
1581 //------------------------------------------------------------------------
1583 //------------------------------------------------------------------------
1588 // Build a list of Annot objects and call setPage on them
1589 Annots(PDFDoc
*docA
, int page
, Object
*annotsObj
);
1593 // Iterate through list of annotations.
1594 int getNumAnnots() { return nAnnots
; }
1595 Annot
*getAnnot(int i
) { return annots
[i
]; }
1596 void appendAnnot(Annot
*annot
);
1597 GBool
removeAnnot(Annot
*annot
);
1600 Annot
* createAnnot(Dict
* dict
, Object
*obj
);
1601 Annot
*findAnnot(Ref
*ref
);