File indexing completed on 2025-12-10 10:23:45
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017
0018
0019
0020
0021
0022
0023
0024
0025
0026
0027
0028
0029
0030
0031
0032
0033
0034
0035
0036
0037
0038
0039
0040
0041
0042
0043
0044
0045
0046
0047
0048
0049
0050
0051 #ifndef ANNOT_H
0052 #define ANNOT_H
0053
0054 #include <memory>
0055 #include <atomic>
0056 #include <mutex>
0057 #include <vector>
0058
0059 #include "AnnotStampImageHelper.h"
0060 #include "Object.h"
0061 #include "poppler_private_export.h"
0062
0063 class XRef;
0064 class Gfx;
0065 class CharCodeToUnicode;
0066 class GfxFont;
0067 class GfxResources;
0068 class Page;
0069 class PDFDoc;
0070 class Form;
0071 class FormWidget;
0072 class FormField;
0073 class FormFieldButton;
0074 class FormFieldText;
0075 class FormFieldChoice;
0076 class FormFieldSignature;
0077 class PDFRectangle;
0078 class Movie;
0079 class LinkAction;
0080 class Sound;
0081 class FileSpec;
0082
0083 enum AnnotLineEndingStyle
0084 {
0085 annotLineEndingSquare,
0086 annotLineEndingCircle,
0087 annotLineEndingDiamond,
0088 annotLineEndingOpenArrow,
0089 annotLineEndingClosedArrow,
0090 annotLineEndingNone,
0091 annotLineEndingButt,
0092 annotLineEndingROpenArrow,
0093 annotLineEndingRClosedArrow,
0094 annotLineEndingSlash
0095 };
0096
0097 enum AnnotExternalDataType
0098 {
0099 annotExternalDataMarkupUnknown,
0100 annotExternalDataMarkup3D
0101 };
0102
0103 enum class VariableTextQuadding
0104 {
0105 leftJustified,
0106 centered,
0107 rightJustified
0108 };
0109
0110
0111
0112
0113
0114 class AnnotCoord
0115 {
0116 public:
0117 AnnotCoord() : x(0), y(0) { }
0118 AnnotCoord(double _x, double _y) : x(_x), y(_y) { }
0119
0120 double getX() const { return x; }
0121 double getY() const { return y; }
0122
0123 protected:
0124 double x, y;
0125 };
0126
0127
0128
0129
0130
0131 class POPPLER_PRIVATE_EXPORT AnnotPath
0132 {
0133 public:
0134 AnnotPath();
0135 explicit AnnotPath(Array *array);
0136 explicit AnnotPath(std::vector<AnnotCoord> &&coords);
0137 ~AnnotPath();
0138
0139 AnnotPath(const AnnotPath &) = delete;
0140 AnnotPath &operator=(const AnnotPath &other) = delete;
0141
0142 double getX(int coord) const;
0143 double getY(int coord) const;
0144 AnnotCoord *getCoord(int coord);
0145 int getCoordsLength() const { return coords.size(); }
0146
0147 protected:
0148 std::vector<AnnotCoord> coords;
0149
0150 void parsePathArray(Array *array);
0151 };
0152
0153
0154
0155
0156
0157 class POPPLER_PRIVATE_EXPORT AnnotCalloutLine
0158 {
0159 public:
0160 AnnotCalloutLine(double x1, double y1, double x2, double y2);
0161 virtual ~AnnotCalloutLine();
0162
0163 AnnotCalloutLine(const AnnotCalloutLine &) = delete;
0164 AnnotCalloutLine &operator=(const AnnotCalloutLine &other) = delete;
0165
0166 double getX1() const { return coord1.getX(); }
0167 double getY1() const { return coord1.getY(); }
0168 double getX2() const { return coord2.getX(); }
0169 double getY2() const { return coord2.getY(); }
0170
0171 protected:
0172 AnnotCoord coord1, coord2;
0173 };
0174
0175
0176
0177
0178
0179 class POPPLER_PRIVATE_EXPORT AnnotCalloutMultiLine : public AnnotCalloutLine
0180 {
0181 public:
0182 AnnotCalloutMultiLine(double x1, double y1, double x2, double y2, double x3, double y3);
0183 ~AnnotCalloutMultiLine() override;
0184
0185 double getX3() const { return coord3.getX(); }
0186 double getY3() const { return coord3.getY(); }
0187
0188 protected:
0189 AnnotCoord coord3;
0190 };
0191
0192
0193
0194
0195
0196 class AnnotBorderEffect
0197 {
0198 public:
0199 enum AnnotBorderEffectType
0200 {
0201 borderEffectNoEffect,
0202 borderEffectCloudy
0203 };
0204
0205 explicit AnnotBorderEffect(Dict *dict);
0206
0207 AnnotBorderEffectType getEffectType() const { return effectType; }
0208 double getIntensity() const { return intensity; }
0209
0210 private:
0211 AnnotBorderEffectType effectType;
0212 double intensity;
0213 };
0214
0215
0216
0217
0218
0219 class POPPLER_PRIVATE_EXPORT AnnotQuadrilaterals
0220 {
0221 public:
0222 class POPPLER_PRIVATE_EXPORT AnnotQuadrilateral
0223 {
0224 public:
0225 AnnotQuadrilateral();
0226 AnnotQuadrilateral(double x1, double y1, double x2, double y2, double x3, double y3, double x4, double y4);
0227
0228 AnnotCoord coord1, coord2, coord3, coord4;
0229 };
0230
0231 AnnotQuadrilaterals(Array *array, PDFRectangle *rect);
0232 AnnotQuadrilaterals(std::unique_ptr<AnnotQuadrilateral[]> &&quads, int quadsLength);
0233 ~AnnotQuadrilaterals();
0234
0235 AnnotQuadrilaterals(const AnnotQuadrilaterals &) = delete;
0236 AnnotQuadrilaterals &operator=(const AnnotQuadrilaterals &other) = delete;
0237
0238 double getX1(int quadrilateral);
0239 double getY1(int quadrilateral);
0240 double getX2(int quadrilateral);
0241 double getY2(int quadrilateral);
0242 double getX3(int quadrilateral);
0243 double getY3(int quadrilateral);
0244 double getX4(int quadrilateral);
0245 double getY4(int quadrilateral);
0246 int getQuadrilateralsLength() const { return quadrilateralsLength; }
0247
0248 protected:
0249 std::unique_ptr<AnnotQuadrilateral[]> quadrilaterals;
0250 int quadrilateralsLength;
0251 };
0252
0253
0254
0255
0256
0257 class POPPLER_PRIVATE_EXPORT AnnotBorder
0258 {
0259 public:
0260 enum AnnotBorderType
0261 {
0262 typeArray,
0263 typeBS
0264 };
0265
0266 enum AnnotBorderStyle
0267 {
0268 borderSolid,
0269 borderDashed,
0270 borderBeveled,
0271 borderInset,
0272 borderUnderlined
0273 };
0274
0275 virtual ~AnnotBorder();
0276
0277 AnnotBorder(const AnnotBorder &) = delete;
0278 AnnotBorder &operator=(const AnnotBorder &other) = delete;
0279
0280 virtual void setWidth(double new_width) { width = new_width; }
0281
0282 virtual AnnotBorderType getType() const = 0;
0283 virtual double getWidth() const { return width; }
0284 virtual const std::vector<double> &getDash() const { return dash; }
0285 virtual AnnotBorderStyle getStyle() const { return style; }
0286
0287 virtual Object writeToObject(XRef *xref) const = 0;
0288 virtual std::unique_ptr<AnnotBorder> copy() const = 0;
0289
0290 protected:
0291 AnnotBorder();
0292
0293 bool parseDashArray(Object *dashObj);
0294
0295 AnnotBorderType type;
0296 double width;
0297 static const int DASH_LIMIT = 10;
0298 std::vector<double> dash;
0299 AnnotBorderStyle style;
0300 };
0301
0302
0303
0304
0305
0306 class POPPLER_PRIVATE_EXPORT AnnotBorderArray : public AnnotBorder
0307 {
0308 public:
0309 AnnotBorderArray();
0310 explicit AnnotBorderArray(Array *array);
0311
0312 void setHorizontalCorner(double hc) { horizontalCorner = hc; }
0313 void setVerticalCorner(double vc) { verticalCorner = vc; }
0314
0315 double getHorizontalCorner() const { return horizontalCorner; }
0316 double getVerticalCorner() const { return verticalCorner; }
0317
0318 std::unique_ptr<AnnotBorder> copy() const override;
0319
0320 private:
0321 AnnotBorderType getType() const override { return typeArray; }
0322 Object writeToObject(XRef *xref) const override;
0323
0324 double horizontalCorner;
0325 double verticalCorner;
0326
0327 };
0328
0329
0330
0331
0332
0333 class AnnotBorderBS : public AnnotBorder
0334 {
0335 public:
0336 AnnotBorderBS();
0337 explicit AnnotBorderBS(Dict *dict);
0338
0339 private:
0340 AnnotBorderType getType() const override { return typeBS; }
0341 Object writeToObject(XRef *xref) const override;
0342
0343 const char *getStyleName() const;
0344
0345 std::unique_ptr<AnnotBorder> copy() const override;
0346
0347
0348
0349
0350 };
0351
0352
0353
0354
0355
0356 class POPPLER_PRIVATE_EXPORT AnnotColor
0357 {
0358 public:
0359 enum AnnotColorSpace
0360 {
0361 colorTransparent = 0,
0362 colorGray = 1,
0363 colorRGB = 3,
0364 colorCMYK = 4
0365 };
0366
0367 AnnotColor();
0368 explicit AnnotColor(double gray);
0369 AnnotColor(double r, double g, double b);
0370 AnnotColor(double c, double m, double y, double k);
0371 explicit AnnotColor(Array *array, int adjust = 0);
0372
0373 void adjustColor(int adjust);
0374
0375 AnnotColorSpace getSpace() const { return (AnnotColorSpace)length; }
0376 const double *getValues() const { return values; }
0377
0378 Object writeToObject(XRef *xref) const;
0379
0380 private:
0381 double values[4];
0382 int length;
0383 };
0384
0385
0386
0387
0388
0389 class POPPLER_PRIVATE_EXPORT DefaultAppearance
0390 {
0391 public:
0392 DefaultAppearance(Object &&fontNameA, double fontPtSizeA, std::unique_ptr<AnnotColor> &&fontColorA);
0393 explicit DefaultAppearance(const GooString *da);
0394 void setFontName(Object &&fontNameA);
0395 const Object &getFontName() const { return fontName; }
0396 void setFontPtSize(double fontPtSizeA);
0397 double getFontPtSize() const { return fontPtSize; }
0398 void setFontColor(std::unique_ptr<AnnotColor> fontColorA);
0399 const AnnotColor *getFontColor() const { return fontColor.get(); }
0400 std::string toAppearanceString() const;
0401
0402 DefaultAppearance(const DefaultAppearance &) = delete;
0403 DefaultAppearance &operator=(const DefaultAppearance &) = delete;
0404
0405 private:
0406 Object fontName;
0407 double fontPtSize;
0408 std::unique_ptr<AnnotColor> fontColor;
0409 };
0410
0411
0412
0413
0414
0415 class AnnotIconFit
0416 {
0417 public:
0418 enum AnnotIconFitScaleWhen
0419 {
0420 scaleAlways,
0421 scaleBigger,
0422 scaleSmaller,
0423 scaleNever
0424 };
0425
0426 enum AnnotIconFitScale
0427 {
0428 scaleAnamorphic,
0429 scaleProportional
0430 };
0431
0432 explicit AnnotIconFit(Dict *dict);
0433
0434 AnnotIconFitScaleWhen getScaleWhen() { return scaleWhen; }
0435 AnnotIconFitScale getScale() { return scale; }
0436 double getLeft() { return left; }
0437 double getBottom() { return bottom; }
0438 bool getFullyBounds() { return fullyBounds; }
0439
0440 protected:
0441 AnnotIconFitScaleWhen scaleWhen;
0442 AnnotIconFitScale scale;
0443 double left;
0444 double bottom;
0445 bool fullyBounds;
0446 };
0447
0448
0449
0450
0451
0452 class AnnotAppearance
0453 {
0454 public:
0455 enum AnnotAppearanceType
0456 {
0457 appearNormal,
0458 appearRollover,
0459 appearDown
0460 };
0461
0462 AnnotAppearance(PDFDoc *docA, Object *dict);
0463 ~AnnotAppearance();
0464
0465
0466 Object getAppearanceStream(AnnotAppearanceType type, const char *state);
0467
0468
0469 std::unique_ptr<GooString> getStateKey(int i);
0470 int getNumStates();
0471
0472
0473
0474 void removeAllStreams();
0475
0476
0477 bool referencesStream(Ref refToStream);
0478
0479 private:
0480 static bool referencesStream(const Object *stateObj, Ref refToStream);
0481 void removeStream(Ref refToStream);
0482 void removeStateStreams(const Object *state);
0483
0484 protected:
0485 PDFDoc *doc;
0486 Object appearDict;
0487 };
0488
0489
0490
0491
0492
0493 class POPPLER_PRIVATE_EXPORT AnnotAppearanceCharacs
0494 {
0495 public:
0496 enum AnnotAppearanceCharacsTextPos
0497 {
0498 captionNoIcon,
0499 captionNoCaption,
0500 captionBelow,
0501 captionAbove,
0502 captionRight,
0503 captionLeft,
0504 captionOverlaid
0505 };
0506
0507 explicit AnnotAppearanceCharacs(Dict *dict);
0508 ~AnnotAppearanceCharacs();
0509
0510 AnnotAppearanceCharacs(const AnnotAppearanceCharacs &) = delete;
0511 AnnotAppearanceCharacs &operator=(const AnnotAppearanceCharacs &) = delete;
0512
0513 int getRotation() const { return rotation; }
0514 const AnnotColor *getBorderColor() const { return borderColor.get(); }
0515 void setBorderColor(std::unique_ptr<AnnotColor> &&color) { borderColor = std::move(color); }
0516 const AnnotColor *getBackColor() const { return backColor.get(); }
0517 void setBackColor(std::unique_ptr<AnnotColor> &&color) { backColor = std::move(color); }
0518 const GooString *getNormalCaption() const { return normalCaption.get(); }
0519 const GooString *getRolloverCaption() { return rolloverCaption.get(); }
0520 const GooString *getAlternateCaption() { return alternateCaption.get(); }
0521 const AnnotIconFit *getIconFit() { return iconFit.get(); }
0522 AnnotAppearanceCharacsTextPos getPosition() const { return position; }
0523
0524 std::unique_ptr<AnnotAppearanceCharacs> copy() const;
0525
0526 protected:
0527 int rotation;
0528 std::unique_ptr<AnnotColor> borderColor;
0529 std::unique_ptr<AnnotColor> backColor;
0530 std::unique_ptr<GooString> normalCaption;
0531 std::unique_ptr<GooString> rolloverCaption;
0532 std::unique_ptr<GooString> alternateCaption;
0533
0534
0535
0536 std::unique_ptr<AnnotIconFit> iconFit;
0537 AnnotAppearanceCharacsTextPos position;
0538 };
0539
0540
0541
0542
0543
0544 class AnnotAppearanceBBox
0545 {
0546 public:
0547 explicit AnnotAppearanceBBox(PDFRectangle *rect);
0548
0549 void setBorderWidth(double w) { borderWidth = w; }
0550
0551
0552 void extendTo(double x, double y);
0553 void getBBoxRect(double bbox[4]) const;
0554
0555
0556 double getPageXMin() const;
0557 double getPageYMin() const;
0558 double getPageXMax() const;
0559 double getPageYMax() const;
0560
0561 private:
0562 double origX, origY, borderWidth;
0563 double minX, minY, maxX, maxY;
0564 };
0565
0566
0567
0568
0569 class Matrix;
0570
0571 class AnnotAppearanceBuilder
0572 {
0573 public:
0574 AnnotAppearanceBuilder();
0575 ~AnnotAppearanceBuilder();
0576
0577 AnnotAppearanceBuilder(const AnnotAppearanceBuilder &) = delete;
0578 AnnotAppearanceBuilder &operator=(const AnnotAppearanceBuilder &) = delete;
0579
0580 void setDrawColor(const AnnotColor *color, bool fill);
0581 void setLineStyleForBorder(const AnnotBorder *border);
0582 void setTextFont(const Object &fontName, double fontSize);
0583 void drawCircle(double cx, double cy, double r, bool fill);
0584 void drawEllipse(double cx, double cy, double rx, double ry, bool fill, bool stroke);
0585 void drawCircleTopLeft(double cx, double cy, double r);
0586 void drawCircleBottomRight(double cx, double cy, double r);
0587 void drawLineEnding(AnnotLineEndingStyle endingStyle, double x, double y, double size, bool fill, const Matrix &m);
0588 void drawLineEndSquare(double x, double y, double size, bool fill, const Matrix &m);
0589 void drawLineEndCircle(double x, double y, double size, bool fill, const Matrix &m);
0590 void drawLineEndDiamond(double x, double y, double size, bool fill, const Matrix &m);
0591 void drawLineEndArrow(double x, double y, double size, int orientation, bool isOpen, bool fill, const Matrix &m);
0592 void drawLineEndSlash(double x, double y, double size, const Matrix &m);
0593 void drawFieldBorder(const FormField *field, const AnnotBorder *border, const AnnotAppearanceCharacs *appearCharacs, const PDFRectangle *rect);
0594 bool drawFormField(const FormField *field, const Form *form, const GfxResources *resources, const GooString *da, const AnnotBorder *border, const AnnotAppearanceCharacs *appearCharacs, const PDFRectangle *rect,
0595 const GooString *appearState, XRef *xref, Dict *resourcesDict);
0596 static double lineEndingXShorten(AnnotLineEndingStyle endingStyle, double size);
0597 static double lineEndingXExtendBBox(AnnotLineEndingStyle endingStyle, double size);
0598 void writeString(const std::string &str);
0599
0600 void append(const char *text);
0601 void appendf(const char *fmt, ...) GOOSTRING_FORMAT;
0602
0603 const GooString *buffer() const;
0604
0605 private:
0606 enum DrawTextFlags
0607 {
0608 NoDrawTextFlags = 0,
0609 MultilineDrawTextFlag = 1,
0610 EmitMarkedContentDrawTextFlag = 2,
0611 ForceZapfDingbatsDrawTextFlag = 4,
0612 TurnTextToStarsDrawTextFlag = 8
0613 };
0614
0615 bool drawListBox(const FormFieldChoice *fieldChoice, const AnnotBorder *border, const PDFRectangle *rect, const GooString *da, const GfxResources *resources, VariableTextQuadding quadding, XRef *xref, Dict *resourcesDict);
0616 bool drawFormFieldButton(const FormFieldButton *field, const Form *form, const GfxResources *resources, const GooString *da, const AnnotBorder *border, const AnnotAppearanceCharacs *appearCharacs, const PDFRectangle *rect,
0617 const GooString *appearState, XRef *xref, Dict *resourcesDict);
0618 bool drawFormFieldText(const FormFieldText *fieldText, const Form *form, const GfxResources *resources, const GooString *da, const AnnotBorder *border, const AnnotAppearanceCharacs *appearCharacs, const PDFRectangle *rect, XRef *xref,
0619 Dict *resourcesDict);
0620 bool drawFormFieldChoice(const FormFieldChoice *fieldChoice, const Form *form, const GfxResources *resources, const GooString *da, const AnnotBorder *border, const AnnotAppearanceCharacs *appearCharacs, const PDFRectangle *rect,
0621 XRef *xref, Dict *resourcesDict);
0622 bool drawSignatureFieldText(const FormFieldSignature *field, const Form *form, const GfxResources *resources, const GooString *da, const AnnotBorder *border, const AnnotAppearanceCharacs *appearCharacs, const PDFRectangle *rect,
0623 XRef *xref, Dict *resourcesDict);
0624 void drawSignatureFieldText(const GooString &text, const Form *form, const DefaultAppearance &da, const AnnotBorder *border, const PDFRectangle *rect, XRef *xref, Dict *resourcesDict, double leftMargin, bool centerVertically,
0625 bool centerHorizontally);
0626 bool drawText(const GooString *text, const Form *form, const GooString *da, const GfxResources *resources, const AnnotBorder *border, const AnnotAppearanceCharacs *appearCharacs, const PDFRectangle *rect,
0627 const VariableTextQuadding quadding, XRef *xref, Dict *resourcesDict, const int flags = NoDrawTextFlags, const int nCombs = 0);
0628 void drawArrowPath(double x, double y, const Matrix &m, int orientation = 1);
0629
0630 GooString *appearBuf;
0631 };
0632
0633
0634
0635
0636
0637 class POPPLER_PRIVATE_EXPORT Annot
0638 {
0639 friend class Annots;
0640 friend class Page;
0641
0642 public:
0643 enum AnnotFlag
0644 {
0645 flagUnknown = 0x0000,
0646 flagInvisible = 0x0001,
0647 flagHidden = 0x0002,
0648 flagPrint = 0x0004,
0649 flagNoZoom = 0x0008,
0650 flagNoRotate = 0x0010,
0651 flagNoView = 0x0020,
0652 flagReadOnly = 0x0040,
0653 flagLocked = 0x0080,
0654 flagToggleNoView = 0x0100,
0655 flagLockedContents = 0x0200
0656 };
0657
0658 enum AnnotSubtype
0659 {
0660 typeUnknown,
0661 typeText,
0662 typeLink,
0663 typeFreeText,
0664 typeLine,
0665 typeSquare,
0666 typeCircle,
0667 typePolygon,
0668 typePolyLine,
0669 typeHighlight,
0670 typeUnderline,
0671 typeSquiggly,
0672 typeStrikeOut,
0673 typeStamp,
0674 typeCaret,
0675 typeInk,
0676 typePopup,
0677 typeFileAttachment,
0678 typeSound,
0679 typeMovie,
0680 typeWidget,
0681 typeScreen,
0682 typePrinterMark,
0683 typeTrapNet,
0684 typeWatermark,
0685 type3D,
0686 typeRichMedia
0687 };
0688
0689
0690
0691
0692 enum AdditionalActionsType
0693 {
0694 actionCursorEntering,
0695 actionCursorLeaving,
0696 actionMousePressed,
0697 actionMouseReleased,
0698 actionFocusIn,
0699 actionFocusOut,
0700 actionPageOpening,
0701 actionPageClosing,
0702 actionPageVisible,
0703 actionPageInvisible
0704 };
0705
0706 enum FormAdditionalActionsType
0707 {
0708 actionFieldModified,
0709 actionFormatField,
0710 actionValidateField,
0711 actionCalculateField,
0712 };
0713
0714 Annot(PDFDoc *docA, PDFRectangle *rectA);
0715 Annot(PDFDoc *docA, Object &&dictObject);
0716 Annot(PDFDoc *docA, Object &&dictObject, const Object *obj);
0717 bool isOk() { return ok; }
0718
0719 void incRefCnt();
0720 void decRefCnt();
0721
0722 virtual void draw(Gfx *gfx, bool printing);
0723
0724 virtual Object getAppearanceResDict();
0725
0726 bool match(const Ref *refA) const { return ref == *refA; }
0727
0728 double getXMin();
0729 double getYMin();
0730 double getXMax();
0731 double getYMax();
0732
0733 void setRect(const PDFRectangle *rect);
0734 void setRect(double x1, double y1, double x2, double y2);
0735
0736
0737
0738 virtual void setContents(std::unique_ptr<GooString> &&new_content);
0739 void setName(GooString *new_name);
0740 void setModified(GooString *new_modified);
0741 void setFlags(unsigned int new_flags);
0742
0743 void setBorder(std::unique_ptr<AnnotBorder> &&new_border);
0744 void setColor(std::unique_ptr<AnnotColor> &&new_color);
0745
0746 void setAppearanceState(const char *state);
0747
0748
0749 PDFDoc *getDoc() const { return doc; }
0750 bool getHasRef() const { return hasRef; }
0751 Ref getRef() const { return ref; }
0752 const Object &getAnnotObj() const { return annotObj; }
0753 AnnotSubtype getType() const { return type; }
0754 const PDFRectangle &getRect() const { return *rect; }
0755 void getRect(double *x1, double *y1, double *x2, double *y2) const;
0756 const GooString *getContents() const { return contents.get(); }
0757 int getPageNum() const { return page; }
0758 const GooString *getName() const { return name.get(); }
0759 const GooString *getModified() const { return modified.get(); }
0760 unsigned int getFlags() const { return flags; }
0761 Object getAppearance() const;
0762 void setNewAppearance(Object &&newAppearance);
0763 AnnotAppearance *getAppearStreams() const { return appearStreams.get(); }
0764 const GooString *getAppearState() const { return appearState.get(); }
0765 AnnotBorder *getBorder() const { return border.get(); }
0766 AnnotColor *getColor() const { return color.get(); }
0767 int getTreeKey() const { return treeKey; }
0768
0769 int getId() { return ref.num; }
0770
0771
0772 bool inRect(double x, double y) const;
0773
0774
0775 static void layoutText(const GooString *text, GooString *outBuf, int *i, const GfxFont &font, double *width, double widthLimit, int *charCount, bool noReencode, bool *newFontNeeded = nullptr);
0776
0777 private:
0778 void readArrayNum(Object *pdfArray, int key, double *value);
0779
0780
0781 void initialize(PDFDoc *docA, Dict *dict);
0782 void setPage(int pageIndex, bool updateP);
0783
0784 protected:
0785 virtual ~Annot();
0786 virtual void removeReferencedObjects();
0787 Object createForm(const GooString *appearBuf, const double *bbox, bool transparencyGroup, Dict *resDict);
0788 Object createForm(const GooString *appearBuf, const double *bbox, bool transparencyGroup, Object &&resDictObject);
0789 Dict *createResourcesDict(const char *formName, Object &&formStream, const char *stateName, double opacity, const char *blendMode);
0790 bool isVisible(bool printing);
0791 int getRotation() const;
0792
0793
0794
0795 void update(const char *key, Object &&value);
0796
0797
0798 virtual void invalidateAppearance();
0799
0800 Object annotObj;
0801
0802 std::atomic_int refCnt;
0803
0804
0805 AnnotSubtype type;
0806 std::unique_ptr<PDFRectangle> rect;
0807
0808
0809 std::unique_ptr<GooString> contents;
0810 std::unique_ptr<GooString> name;
0811 std::unique_ptr<GooString> modified;
0812 int page;
0813 unsigned int flags;
0814 std::unique_ptr<AnnotAppearance> appearStreams;
0815 Object appearance;
0816
0817 std::unique_ptr<AnnotAppearanceBBox> appearBBox;
0818 std::unique_ptr<GooString> appearState;
0819 int treeKey;
0820 Object oc;
0821
0822 PDFDoc *doc;
0823 Ref ref;
0824 std::unique_ptr<AnnotBorder> border;
0825 std::unique_ptr<AnnotColor> color;
0826 bool ok;
0827
0828 bool hasRef;
0829 mutable std::recursive_mutex mutex;
0830
0831 bool hasBeenUpdated = false;
0832 };
0833
0834
0835
0836
0837
0838 class POPPLER_PRIVATE_EXPORT AnnotPopup : public Annot
0839 {
0840 public:
0841 AnnotPopup(PDFDoc *docA, PDFRectangle *rect);
0842 AnnotPopup(PDFDoc *docA, Object &&dictObject, const Object *obj);
0843 ~AnnotPopup() override;
0844
0845 bool hasParent() const { return parentRef != Ref::INVALID(); }
0846 void setParent(Annot *parentA);
0847 bool getOpen() const { return open; }
0848 void setOpen(bool openA);
0849
0850 protected:
0851 void initialize(PDFDoc *docA, Dict *dict);
0852
0853 Ref parentRef;
0854 bool open;
0855 };
0856
0857
0858
0859
0860
0861 class POPPLER_PRIVATE_EXPORT AnnotMarkup : public Annot
0862 {
0863 public:
0864 enum AnnotMarkupReplyType
0865 {
0866 replyTypeR,
0867 replyTypeGroup
0868 };
0869
0870 AnnotMarkup(PDFDoc *docA, PDFRectangle *rect);
0871 AnnotMarkup(PDFDoc *docA, Object &&dictObject, const Object *obj);
0872 ~AnnotMarkup() override;
0873
0874
0875 const GooString *getLabel() const { return label.get(); }
0876 AnnotPopup *getPopup() const { return popup.get(); }
0877 double getOpacity() const { return opacity; }
0878
0879 const GooString *getDate() const { return date.get(); }
0880 bool isInReplyTo() const { return inReplyTo != Ref::INVALID(); }
0881 int getInReplyToID() const { return inReplyTo.num; }
0882 const GooString *getSubject() const { return subject.get(); }
0883 AnnotMarkupReplyType getReplyTo() const { return replyTo; }
0884 AnnotExternalDataType getExData() const { return exData; }
0885
0886
0887 void setPopup(std::unique_ptr<AnnotPopup> &&new_popup);
0888 void setLabel(std::unique_ptr<GooString> &&new_label);
0889 void setOpacity(double opacityA);
0890 void setDate(GooString *new_date);
0891
0892 protected:
0893 void removeReferencedObjects() override;
0894
0895 std::unique_ptr<GooString> label;
0896 std::unique_ptr<AnnotPopup> popup;
0897 double opacity;
0898
0899 std::unique_ptr<GooString> date;
0900 Ref inReplyTo;
0901 std::unique_ptr<GooString> subject;
0902 AnnotMarkupReplyType replyTo;
0903
0904
0905
0906 AnnotExternalDataType exData;
0907
0908 private:
0909 void initialize(PDFDoc *docA, Dict *dict);
0910 };
0911
0912
0913
0914
0915
0916 class POPPLER_PRIVATE_EXPORT AnnotText : public AnnotMarkup
0917 {
0918 public:
0919 enum AnnotTextState
0920 {
0921 stateUnknown,
0922
0923 stateMarked,
0924 stateUnmarked,
0925
0926 stateAccepted,
0927 stateRejected,
0928 stateCancelled,
0929 stateCompleted,
0930 stateNone
0931 };
0932
0933 AnnotText(PDFDoc *docA, PDFRectangle *rect);
0934 AnnotText(PDFDoc *docA, Object &&dictObject, const Object *obj);
0935 ~AnnotText() override;
0936
0937 void draw(Gfx *gfx, bool printing) override;
0938
0939
0940 bool getOpen() const { return open; }
0941 const GooString *getIcon() const { return icon.get(); }
0942 AnnotTextState getState() const { return state; }
0943
0944 void setOpen(bool openA);
0945 void setIcon(GooString *new_icon);
0946
0947 private:
0948 void initialize(PDFDoc *docA, Dict *dict);
0949
0950 bool open;
0951 std::unique_ptr<GooString> icon;
0952 AnnotTextState state;
0953
0954
0955 };
0956
0957
0958
0959
0960
0961 class POPPLER_PRIVATE_EXPORT AnnotMovie : public Annot
0962 {
0963 public:
0964 AnnotMovie(PDFDoc *docA, PDFRectangle *rect, Movie *movieA);
0965 AnnotMovie(PDFDoc *docA, Object &&dictObject, const Object *obj);
0966 ~AnnotMovie() override;
0967
0968 void draw(Gfx *gfx, bool printing) override;
0969
0970 const GooString *getTitle() const { return title.get(); }
0971 Movie *getMovie() { return movie.get(); }
0972
0973 private:
0974 void initialize(PDFDoc *docA, Dict *dict);
0975
0976 std::unique_ptr<GooString> title;
0977 std::unique_ptr<Movie> movie;
0978 };
0979
0980
0981
0982
0983
0984 class POPPLER_PRIVATE_EXPORT AnnotScreen : public Annot
0985 {
0986 public:
0987 AnnotScreen(PDFDoc *docA, PDFRectangle *rect);
0988 AnnotScreen(PDFDoc *docA, Object &&dictObject, const Object *obj);
0989 ~AnnotScreen() override;
0990
0991 const GooString *getTitle() const { return title.get(); }
0992
0993 AnnotAppearanceCharacs *getAppearCharacs() { return appearCharacs.get(); }
0994 LinkAction *getAction() { return action.get(); }
0995 std::unique_ptr<LinkAction> getAdditionalAction(AdditionalActionsType type);
0996
0997 private:
0998 void initialize(PDFDoc *docA, Dict *dict);
0999
1000 std::unique_ptr<GooString> title;
1001
1002 std::unique_ptr<AnnotAppearanceCharacs> appearCharacs;
1003
1004 std::unique_ptr<LinkAction> action;
1005 Object additionalActions;
1006 };
1007
1008
1009
1010
1011
1012 class AnnotLink : public Annot
1013 {
1014 public:
1015 enum AnnotLinkEffect
1016 {
1017 effectNone,
1018 effectInvert,
1019 effectOutline,
1020 effectPush
1021 };
1022
1023 AnnotLink(PDFDoc *docA, PDFRectangle *rect);
1024 AnnotLink(PDFDoc *docA, Object &&dictObject, const Object *obj);
1025 ~AnnotLink() override;
1026
1027 void draw(Gfx *gfx, bool printing) override;
1028
1029
1030 LinkAction *getAction() const { return action.get(); }
1031 AnnotLinkEffect getLinkEffect() const { return linkEffect; }
1032 AnnotQuadrilaterals *getQuadrilaterals() const { return quadrilaterals.get(); }
1033
1034 protected:
1035 void initialize(PDFDoc *docA, Dict *dict);
1036
1037 std::unique_ptr<LinkAction> action;
1038 AnnotLinkEffect linkEffect;
1039
1040
1041 std::unique_ptr<AnnotQuadrilaterals> quadrilaterals;
1042 };
1043
1044
1045
1046
1047
1048 class POPPLER_PRIVATE_EXPORT AnnotFreeText : public AnnotMarkup
1049 {
1050 public:
1051 enum AnnotFreeTextIntent
1052 {
1053 intentFreeText,
1054 intentFreeTextCallout,
1055 intentFreeTextTypeWriter
1056 };
1057
1058 static const double undefinedFontPtSize;
1059
1060 AnnotFreeText(PDFDoc *docA, PDFRectangle *rect);
1061 AnnotFreeText(PDFDoc *docA, Object &&dictObject, const Object *obj);
1062 ~AnnotFreeText() override;
1063
1064 void draw(Gfx *gfx, bool printing) override;
1065 Object getAppearanceResDict() override;
1066 void setContents(std::unique_ptr<GooString> &&new_content) override;
1067
1068 void setDefaultAppearance(const DefaultAppearance &da);
1069 void setQuadding(VariableTextQuadding new_quadding);
1070 void setStyleString(GooString *new_string);
1071 void setCalloutLine(AnnotCalloutLine *line);
1072 void setIntent(AnnotFreeTextIntent new_intent);
1073
1074
1075 std::unique_ptr<DefaultAppearance> getDefaultAppearance() const;
1076 VariableTextQuadding getQuadding() const { return quadding; }
1077
1078 const GooString *getStyleString() const { return styleString.get(); }
1079 AnnotCalloutLine *getCalloutLine() const { return calloutLine.get(); }
1080 AnnotFreeTextIntent getIntent() const { return intent; }
1081 AnnotBorderEffect *getBorderEffect() const { return borderEffect.get(); }
1082 PDFRectangle *getRectangle() const { return rectangle.get(); }
1083 AnnotLineEndingStyle getEndStyle() const { return endStyle; }
1084
1085 protected:
1086 void initialize(PDFDoc *docA, Dict *dict);
1087 void generateFreeTextAppearance();
1088
1089
1090 std::unique_ptr<GooString> appearanceString;
1091
1092
1093 VariableTextQuadding quadding;
1094
1095 std::unique_ptr<GooString> styleString;
1096 std::unique_ptr<AnnotCalloutLine> calloutLine;
1097 AnnotFreeTextIntent intent;
1098 std::unique_ptr<AnnotBorderEffect> borderEffect;
1099 std::unique_ptr<PDFRectangle> rectangle;
1100
1101
1102 AnnotLineEndingStyle endStyle;
1103 };
1104
1105
1106
1107
1108
1109 class POPPLER_PRIVATE_EXPORT AnnotLine : public AnnotMarkup
1110 {
1111 public:
1112 enum AnnotLineIntent
1113 {
1114 intentLineArrow,
1115 intentLineDimension
1116 };
1117
1118 enum AnnotLineCaptionPos
1119 {
1120 captionPosInline,
1121 captionPosTop
1122 };
1123
1124 AnnotLine(PDFDoc *docA, PDFRectangle *rect);
1125 AnnotLine(PDFDoc *docA, Object &&dictObject, const Object *obj);
1126 ~AnnotLine() override;
1127
1128 void draw(Gfx *gfx, bool printing) override;
1129 Object getAppearanceResDict() override;
1130 void setContents(std::unique_ptr<GooString> &&new_content) override;
1131
1132 void setVertices(double x1, double y1, double x2, double y2);
1133 void setStartEndStyle(AnnotLineEndingStyle start, AnnotLineEndingStyle end);
1134 void setInteriorColor(std::unique_ptr<AnnotColor> &&new_color);
1135 void setLeaderLineLength(double len);
1136 void setLeaderLineExtension(double len);
1137 void setCaption(bool new_cap);
1138 void setIntent(AnnotLineIntent new_intent);
1139
1140
1141 AnnotLineEndingStyle getStartStyle() const { return startStyle; }
1142 AnnotLineEndingStyle getEndStyle() const { return endStyle; }
1143 AnnotColor *getInteriorColor() const { return interiorColor.get(); }
1144 double getLeaderLineLength() const { return leaderLineLength; }
1145 double getLeaderLineExtension() const { return leaderLineExtension; }
1146 bool getCaption() const { return caption; }
1147 AnnotLineIntent getIntent() const { return intent; }
1148 double getLeaderLineOffset() const { return leaderLineOffset; }
1149 AnnotLineCaptionPos getCaptionPos() const { return captionPos; }
1150 Dict *getMeasure() const { return measure; }
1151 double getCaptionTextHorizontal() const { return captionTextHorizontal; }
1152 double getCaptionTextVertical() const { return captionTextVertical; }
1153 double getX1() const { return coord1->getX(); }
1154 double getY1() const { return coord1->getY(); }
1155 double getX2() const { return coord2->getX(); }
1156 double getY2() const { return coord2->getY(); }
1157
1158 protected:
1159 void initialize(PDFDoc *docA, Dict *dict);
1160 void generateLineAppearance();
1161
1162
1163 std::unique_ptr<AnnotCoord> coord1;
1164 std::unique_ptr<AnnotCoord> coord2;
1165
1166
1167
1168
1169 AnnotLineEndingStyle startStyle;
1170 AnnotLineEndingStyle endStyle;
1171 std::unique_ptr<AnnotColor> interiorColor;
1172 double leaderLineLength;
1173 double leaderLineExtension;
1174 bool caption;
1175 AnnotLineIntent intent;
1176 double leaderLineOffset;
1177 AnnotLineCaptionPos captionPos;
1178 Dict *measure;
1179 double captionTextHorizontal;
1180 double captionTextVertical;
1181 };
1182
1183
1184
1185
1186
1187 class POPPLER_PRIVATE_EXPORT AnnotTextMarkup : public AnnotMarkup
1188 {
1189 public:
1190 AnnotTextMarkup(PDFDoc *docA, PDFRectangle *rect, AnnotSubtype subType);
1191 AnnotTextMarkup(PDFDoc *docA, Object &&dictObject, const Object *obj);
1192 ~AnnotTextMarkup() override;
1193
1194 void draw(Gfx *gfx, bool printing) override;
1195
1196
1197 void setType(AnnotSubtype new_type);
1198
1199 void setQuadrilaterals(AnnotQuadrilaterals *quadPoints);
1200
1201 AnnotQuadrilaterals *getQuadrilaterals() const { return quadrilaterals.get(); }
1202
1203 protected:
1204 void initialize(PDFDoc *docA, Dict *dict);
1205
1206 std::unique_ptr<AnnotQuadrilaterals> quadrilaterals;
1207
1208 private:
1209 bool shouldCreateApperance(Gfx *gfx) const;
1210 };
1211
1212
1213
1214
1215
1216 class POPPLER_PRIVATE_EXPORT AnnotStamp : public AnnotMarkup
1217 {
1218 public:
1219 AnnotStamp(PDFDoc *docA, PDFRectangle *rect);
1220 AnnotStamp(PDFDoc *docA, Object &&dictObject, const Object *obj);
1221 ~AnnotStamp() override;
1222
1223 void draw(Gfx *gfx, bool printing) override;
1224
1225 void setIcon(GooString *new_icon);
1226
1227 void setCustomImage(AnnotStampImageHelper *stampImageHelperA);
1228
1229 void clearCustomImage();
1230
1231
1232 const GooString *getIcon() const { return icon.get(); }
1233
1234 private:
1235 void initialize(PDFDoc *docA, Dict *dict);
1236 void generateStampDefaultAppearance();
1237 void generateStampCustomAppearance();
1238
1239 std::unique_ptr<GooString> icon;
1240 AnnotStampImageHelper *stampImageHelper;
1241 Ref updatedAppearanceStream;
1242 };
1243
1244
1245
1246
1247
1248 class POPPLER_PRIVATE_EXPORT AnnotGeometry : public AnnotMarkup
1249 {
1250 public:
1251 AnnotGeometry(PDFDoc *docA, PDFRectangle *rect, AnnotSubtype subType);
1252 AnnotGeometry(PDFDoc *docA, Object &&dictObject, const Object *obj);
1253 ~AnnotGeometry() override;
1254
1255 void draw(Gfx *gfx, bool printing) override;
1256
1257 void setType(AnnotSubtype new_type);
1258 void setInteriorColor(std::unique_ptr<AnnotColor> &&new_color);
1259
1260
1261 AnnotColor *getInteriorColor() const { return interiorColor.get(); }
1262 AnnotBorderEffect *getBorderEffect() const { return borderEffect.get(); }
1263 PDFRectangle *getGeometryRect() const { return geometryRect.get(); }
1264
1265 private:
1266 void initialize(PDFDoc *docA, Dict *dict);
1267
1268 std::unique_ptr<AnnotColor> interiorColor;
1269 std::unique_ptr<AnnotBorderEffect> borderEffect;
1270 std::unique_ptr<PDFRectangle> geometryRect;
1271 };
1272
1273
1274
1275
1276
1277 class POPPLER_PRIVATE_EXPORT AnnotPolygon : public AnnotMarkup
1278 {
1279 public:
1280 enum AnnotPolygonIntent
1281 {
1282 polygonCloud,
1283 polylineDimension,
1284 polygonDimension
1285 };
1286
1287 AnnotPolygon(PDFDoc *docA, PDFRectangle *rect, AnnotSubtype subType);
1288 AnnotPolygon(PDFDoc *docA, Object &&dictObject, const Object *obj);
1289 ~AnnotPolygon() override;
1290
1291 void draw(Gfx *gfx, bool printing) override;
1292 void generatePolyLineAppearance(AnnotAppearanceBuilder *appearBuilder);
1293 void setType(AnnotSubtype new_type);
1294 void setVertices(AnnotPath *path);
1295 void setStartEndStyle(AnnotLineEndingStyle start, AnnotLineEndingStyle end);
1296 void setInteriorColor(std::unique_ptr<AnnotColor> &&new_color);
1297 void setIntent(AnnotPolygonIntent new_intent);
1298
1299
1300 AnnotPath *getVertices() const { return vertices.get(); }
1301 AnnotLineEndingStyle getStartStyle() const { return startStyle; }
1302 AnnotLineEndingStyle getEndStyle() const { return endStyle; }
1303 AnnotColor *getInteriorColor() const { return interiorColor.get(); }
1304 AnnotBorderEffect *getBorderEffect() const { return borderEffect.get(); }
1305 AnnotPolygonIntent getIntent() const { return intent; }
1306
1307 private:
1308 void initialize(PDFDoc *docA, Dict *dict);
1309
1310
1311 std::unique_ptr<AnnotPath> vertices;
1312
1313
1314 AnnotLineEndingStyle startStyle;
1315 AnnotLineEndingStyle endStyle;
1316
1317
1318 std::unique_ptr<AnnotColor> interiorColor;
1319 std::unique_ptr<AnnotBorderEffect> borderEffect;
1320 AnnotPolygonIntent intent;
1321
1322 };
1323
1324
1325
1326
1327
1328 class POPPLER_PRIVATE_EXPORT AnnotCaret : public AnnotMarkup
1329 {
1330 public:
1331 enum AnnotCaretSymbol
1332 {
1333 symbolNone,
1334 symbolP
1335 };
1336
1337 AnnotCaret(PDFDoc *docA, PDFRectangle *rect);
1338 AnnotCaret(PDFDoc *docA, Object &&dictObject, const Object *obj);
1339 ~AnnotCaret() override;
1340
1341 void setSymbol(AnnotCaretSymbol new_symbol);
1342
1343
1344 AnnotCaretSymbol getSymbol() const { return symbol; }
1345 PDFRectangle *getCaretRect() const { return caretRect.get(); }
1346
1347 private:
1348 void initialize(PDFDoc *docA, Dict *dict);
1349
1350 AnnotCaretSymbol symbol;
1351 std::unique_ptr<PDFRectangle> caretRect;
1352 };
1353
1354
1355
1356
1357
1358 class POPPLER_PRIVATE_EXPORT AnnotInk : public AnnotMarkup
1359 {
1360 public:
1361 AnnotInk(PDFDoc *docA, PDFRectangle *rect);
1362 AnnotInk(PDFDoc *docA, Object &&dictObject, const Object *obj);
1363 ~AnnotInk() override;
1364
1365 void draw(Gfx *gfx, bool printing) override;
1366
1367 void setInkList(AnnotPath **paths, int n_paths);
1368
1369
1370 AnnotPath **getInkList() const { return inkList; }
1371 int getInkListLength() const { return inkListLength; }
1372
1373 private:
1374 void initialize(PDFDoc *docA, Dict *dict);
1375 void writeInkList(AnnotPath **paths, int n_paths, Array *dest_array);
1376 void parseInkList(Array *src_array);
1377 void freeInkList();
1378
1379
1380 AnnotPath **inkList;
1381 int inkListLength;
1382
1383
1384
1385
1386 };
1387
1388
1389
1390
1391
1392 class AnnotFileAttachment : public AnnotMarkup
1393 {
1394 public:
1395 AnnotFileAttachment(PDFDoc *docA, PDFRectangle *rect, GooString *filename);
1396 AnnotFileAttachment(PDFDoc *docA, Object &&dictObject, const Object *obj);
1397 ~AnnotFileAttachment() override;
1398
1399 void draw(Gfx *gfx, bool printing) override;
1400
1401
1402 Object *getFile() { return &file; }
1403 const GooString *getName() const { return name.get(); }
1404
1405 private:
1406 void initialize(PDFDoc *docA, Dict *dict);
1407
1408
1409 Object file;
1410
1411
1412 std::unique_ptr<GooString> name;
1413 };
1414
1415
1416
1417
1418
1419 class AnnotSound : public AnnotMarkup
1420 {
1421 public:
1422 AnnotSound(PDFDoc *docA, PDFRectangle *rect, Sound *soundA);
1423 AnnotSound(PDFDoc *docA, Object &&dictObject, const Object *obj);
1424 ~AnnotSound() override;
1425
1426 void draw(Gfx *gfx, bool printing) override;
1427
1428
1429 Sound *getSound() { return sound.get(); }
1430 const GooString *getName() const { return name.get(); }
1431
1432 private:
1433 void initialize(PDFDoc *docA, Dict *dict);
1434
1435
1436 std::unique_ptr<Sound> sound;
1437
1438
1439 std::unique_ptr<GooString> name;
1440 };
1441
1442
1443
1444
1445
1446 class POPPLER_PRIVATE_EXPORT AnnotWidget : public Annot
1447 {
1448 public:
1449 enum AnnotWidgetHighlightMode
1450 {
1451 highlightModeNone,
1452 highlightModeInvert,
1453 highlightModeOutline,
1454 highlightModePush
1455 };
1456
1457 AnnotWidget(PDFDoc *docA, Object &&dictObject, const Object *obj);
1458 AnnotWidget(PDFDoc *docA, Object *dictObject, Object *obj, FormField *fieldA);
1459 ~AnnotWidget() override;
1460
1461 void draw(Gfx *gfx, bool printing) override;
1462 void invalidateAppearance() override;
1463
1464 void generateFieldAppearance();
1465 void updateAppearanceStream();
1466
1467 AnnotWidgetHighlightMode getMode() { return mode; }
1468 AnnotAppearanceCharacs *getAppearCharacs() { return appearCharacs.get(); }
1469 void setAppearCharacs(std::unique_ptr<AnnotAppearanceCharacs> &&appearCharacsA) { appearCharacs = std::move(appearCharacsA); }
1470 LinkAction *getAction() { return action.get(); }
1471 std::unique_ptr<LinkAction> getAdditionalAction(AdditionalActionsType type);
1472 std::unique_ptr<LinkAction> getFormAdditionalAction(FormAdditionalActionsType type);
1473 Dict *getParent() { return parent; }
1474
1475 bool setFormAdditionalAction(FormAdditionalActionsType type, const GooString &js);
1476
1477 void setField(FormField *f) { field = f; };
1478
1479 private:
1480 void initialize(PDFDoc *docA, Dict *dict);
1481
1482 Form *form;
1483 FormField *field;
1484 AnnotWidgetHighlightMode mode;
1485 std::unique_ptr<AnnotAppearanceCharacs> appearCharacs;
1486 std::unique_ptr<LinkAction> action;
1487 Object additionalActions;
1488
1489
1490 Dict *parent;
1491 Ref updatedAppearanceStream;
1492 };
1493
1494
1495
1496
1497
1498 class Annot3D : public Annot
1499 {
1500 class Activation
1501 {
1502 public:
1503 enum ActivationATrigger
1504 {
1505 aTriggerUnknown,
1506 aTriggerPageOpened,
1507 aTriggerPageVisible,
1508 aTriggerUserAction
1509 };
1510
1511 enum ActivationAState
1512 {
1513 aStateUnknown,
1514 aStateEnabled,
1515 aStateDisabled
1516 };
1517
1518 enum ActivationDTrigger
1519 {
1520 dTriggerUnknown,
1521 dTriggerPageClosed,
1522 dTriggerPageInvisible,
1523 dTriggerUserAction
1524 };
1525
1526 enum ActivationDState
1527 {
1528 dStateUnknown,
1529 dStateUninstantiaded,
1530 dStateInstantiated,
1531 dStateLive
1532 };
1533
1534 explicit Activation(Dict *dict);
1535
1536 private:
1537 ActivationATrigger aTrigger;
1538 ActivationAState aState;
1539 ActivationDTrigger dTrigger;
1540 ActivationDState dState;
1541 bool displayToolbar;
1542 bool displayNavigation;
1543 };
1544
1545 public:
1546 Annot3D(PDFDoc *docA, PDFRectangle *rect);
1547 Annot3D(PDFDoc *docA, Object &&dictObject, const Object *obj);
1548 ~Annot3D() override;
1549
1550
1551
1552 private:
1553 void initialize(PDFDoc *docA, Dict *dict);
1554
1555 std::unique_ptr<Activation> activation;
1556 };
1557
1558
1559
1560
1561
1562 class POPPLER_PRIVATE_EXPORT AnnotRichMedia : public Annot
1563 {
1564 public:
1565 class POPPLER_PRIVATE_EXPORT Params
1566 {
1567 public:
1568 explicit Params(Dict *dict);
1569 ~Params();
1570
1571 Params(const Params &) = delete;
1572 Params &operator=(const Params &) = delete;
1573
1574 const GooString *getFlashVars() const;
1575
1576 private:
1577
1578 std::unique_ptr<GooString> flashVars;
1579 };
1580
1581 class POPPLER_PRIVATE_EXPORT Instance
1582 {
1583 public:
1584 enum Type
1585 {
1586 type3D,
1587 typeFlash,
1588 typeSound,
1589 typeVideo
1590 };
1591
1592 explicit Instance(Dict *dict);
1593 ~Instance();
1594
1595 Instance(const Instance &) = delete;
1596 Instance &operator=(const Instance &) = delete;
1597
1598 Type getType() const;
1599 Params *getParams() const;
1600
1601 private:
1602
1603 Type type;
1604 std::unique_ptr<Params> params;
1605 };
1606
1607 class POPPLER_PRIVATE_EXPORT Configuration
1608 {
1609 public:
1610 enum Type
1611 {
1612 type3D,
1613 typeFlash,
1614 typeSound,
1615 typeVideo
1616 };
1617
1618 explicit Configuration(Dict *dict);
1619 ~Configuration();
1620
1621 Configuration(const Configuration &) = delete;
1622 Configuration &operator=(const Configuration &) = delete;
1623
1624 Type getType() const;
1625 const GooString *getName() const;
1626 int getInstancesCount() const;
1627 Instance *getInstance(int index) const;
1628
1629 private:
1630
1631 Type type;
1632 std::unique_ptr<GooString> name;
1633 Instance **instances;
1634 int nInstances;
1635 };
1636
1637 class Content;
1638
1639 class POPPLER_PRIVATE_EXPORT Asset
1640 {
1641 public:
1642 Asset();
1643 ~Asset();
1644
1645 Asset(const Asset &) = delete;
1646 Asset &operator=(const Asset &) = delete;
1647
1648 const GooString *getName() const;
1649 Object *getFileSpec() const;
1650
1651 private:
1652 friend class AnnotRichMedia::Content;
1653
1654 std::unique_ptr<GooString> name;
1655 Object fileSpec;
1656 };
1657
1658 class POPPLER_PRIVATE_EXPORT Content
1659 {
1660 public:
1661 explicit Content(Dict *dict);
1662 ~Content();
1663
1664 Content(const Content &) = delete;
1665 Content &operator=(const Content &) = delete;
1666
1667 int getConfigurationsCount() const;
1668 Configuration *getConfiguration(int index) const;
1669
1670 int getAssetsCount() const;
1671 Asset *getAsset(int index) const;
1672
1673 private:
1674
1675 Configuration **configurations;
1676 int nConfigurations;
1677
1678 Asset **assets;
1679 int nAssets;
1680 };
1681
1682 class POPPLER_PRIVATE_EXPORT Activation
1683 {
1684 public:
1685 enum Condition
1686 {
1687 conditionPageOpened,
1688 conditionPageVisible,
1689 conditionUserAction
1690 };
1691
1692 explicit Activation(Dict *dict);
1693
1694 Condition getCondition() const;
1695
1696 private:
1697
1698 Condition condition;
1699 };
1700
1701 class POPPLER_PRIVATE_EXPORT Deactivation
1702 {
1703 public:
1704 enum Condition
1705 {
1706 conditionPageClosed,
1707 conditionPageInvisible,
1708 conditionUserAction
1709 };
1710
1711 explicit Deactivation(Dict *dict);
1712
1713 Condition getCondition() const;
1714
1715 private:
1716
1717 Condition condition;
1718 };
1719
1720 class POPPLER_PRIVATE_EXPORT Settings
1721 {
1722 public:
1723 explicit Settings(Dict *dict);
1724 ~Settings();
1725
1726 Settings(const Settings &) = delete;
1727 Settings &operator=(const Settings &) = delete;
1728
1729 Activation *getActivation() const;
1730 Deactivation *getDeactivation() const;
1731
1732 private:
1733
1734 std::unique_ptr<Activation> activation;
1735 std::unique_ptr<Deactivation> deactivation;
1736 };
1737
1738 AnnotRichMedia(PDFDoc *docA, PDFRectangle *rect);
1739 AnnotRichMedia(PDFDoc *docA, Object &&dictObject, const Object *obj);
1740 ~AnnotRichMedia() override;
1741
1742 Content *getContent() const;
1743
1744 Settings *getSettings() const;
1745
1746 private:
1747 void initialize(PDFDoc *docA, Dict *dict);
1748
1749
1750 std::unique_ptr<Content> content;
1751
1752
1753 std::unique_ptr<Settings> settings;
1754 };
1755
1756
1757
1758
1759
1760 class Annots
1761 {
1762 public:
1763
1764 Annots(PDFDoc *docA, int page, Object *annotsObj);
1765
1766 ~Annots();
1767
1768 Annots(const Annots &) = delete;
1769 Annots &operator=(const Annots &) = delete;
1770
1771 const std::vector<Annot *> &getAnnots() { return annots; }
1772
1773 void appendAnnot(Annot *annot);
1774 bool removeAnnot(Annot *annot);
1775
1776 private:
1777 Annot *createAnnot(Object &&dictObject, const Object *obj);
1778 Annot *findAnnot(Ref *ref);
1779
1780 PDFDoc *doc;
1781 std::vector<Annot *> annots;
1782 };
1783
1784 #endif