Annot.h 39.6 KB
Newer Older
Kristian Høgsberg's avatar
Kristian Høgsberg committed
1 2 3 4 5 6 7 8
//========================================================================
//
// Annot.h
//
// Copyright 2000-2003 Glyph & Cog, LLC
//
//========================================================================

9 10 11 12
//========================================================================
//
// Modified under the Poppler project - http://poppler.freedesktop.org
//
13 14 15
// All changes made under the Poppler project to this file are licensed
// under GPL version 2 or later
//
16 17
// Copyright (C) 2006 Scott Turner <scotty1024@mac.com>
// Copyright (C) 2007, 2008 Julien Rebetez <julienr@svn.gnome.org>
Albert Astals Cid's avatar
Albert Astals Cid committed
18
// Copyright (C) 2007-2011 Carlos Garcia Campos <carlosgc@gnome.org>
19 20 21 22
// Copyright (C) 2007, 2008 Iñigo Martínez <inigomartinez@gmail.com>
// Copyright (C) 2008 Michael Vrable <mvrable@cs.ucsd.edu>
// Copyright (C) 2008 Hugo Mercier <hmercier31@gmail.com>
// Copyright (C) 2008 Pino Toscano <pino@kde.org>
23
// Copyright (C) 2008 Tomas Are Haavet <tomasare@gmail.com>
24
// Copyright (C) 2009-2011 Albert Astals Cid <aacid@kde.org>
25
// Copyright (C) 2012 Fabio D'Urso <fabiodurso@hotmail.it>
26 27 28 29 30 31
//
// To see a description of the changes please see the Changelog file that
// came with your tarball or type make ChangeLog if you are building from git
//
//========================================================================

Kristian Høgsberg's avatar
Kristian Høgsberg committed
32 33 34 35 36 37 38
#ifndef ANNOT_H
#define ANNOT_H

#ifdef USE_GCC_PRAGMAS
#pragma interface
#endif

39 40
#include "Object.h"

Kristian Høgsberg's avatar
Kristian Høgsberg committed
41 42
class XRef;
class Gfx;
43 44
class CharCodeToUnicode;
class GfxFont;
45
class GfxResources;
46
class PDFDoc;
47
class Form;
48
class FormWidget;
49
class FormField;
50
class FormFieldChoice;
Inigo Martínez's avatar
Inigo Martínez committed
51
class PDFRectangle;
Hugo Mercier's avatar
Hugo Mercier committed
52
class Movie;
53
class LinkAction;
Pino Toscano's avatar
Pino Toscano committed
54
class Sound;
Inigo Martínez's avatar
Inigo Martínez committed
55

Inigo Martínez's avatar
Inigo Martínez committed
56 57 58 59 60 61 62 63 64 65 66 67 68
enum AnnotLineEndingStyle {
  annotLineEndingSquare,        // Square
  annotLineEndingCircle,        // Circle
  annotLineEndingDiamond,       // Diamond
  annotLineEndingOpenArrow,     // OpenArrow
  annotLineEndingClosedArrow,   // ClosedArrow
  annotLineEndingNone,          // None
  annotLineEndingButt,          // Butt
  annotLineEndingROpenArrow,    // ROpenArrow
  annotLineEndingRClosedArrow,  // RClosedArrow
  annotLineEndingSlash          // Slash
};

Inigo Martínez's avatar
Inigo Martínez committed
69 70 71 72 73
enum AnnotExternalDataType {
  annotExternalDataMarkupUnknown,
  annotExternalDataMarkup3D       // Markup3D
};

Inigo Martínez's avatar
Inigo Martínez committed
74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91
//------------------------------------------------------------------------
// AnnotCoord
//------------------------------------------------------------------------

class AnnotCoord {
public:

  AnnotCoord() : x(0), y(0) { }
  AnnotCoord(double _x, double _y) : x(_x), y(_y) { }

  double getX() const { return x; }
  double getY() const { return y; }
  
protected:

  double x, y;
};

Inigo Martínez's avatar
Inigo Martínez committed
92 93 94 95 96 97
//------------------------------------------------------------------------
// AnnotPath
//------------------------------------------------------------------------

class AnnotPath {
public:
98
  AnnotPath();
99
  AnnotPath(Array *array);
Inigo Martínez's avatar
Inigo Martínez committed
100
  AnnotPath(AnnotCoord **coords, int coordLength);
101
  ~AnnotPath();
Inigo Martínez's avatar
Inigo Martínez committed
102

103 104 105
  double getX(int coord) const;
  double getY(int coord) const;
  AnnotCoord *getCoord(int coord) const;
Pino Toscano's avatar
Pino Toscano committed
106
  int getCoordsLength() const { return coordsLength; }
Inigo Martínez's avatar
Inigo Martínez committed
107 108 109
protected:
  AnnotCoord **coords;
  int coordsLength;
110 111

  void parsePathArray(Array *array);
Inigo Martínez's avatar
Inigo Martínez committed
112 113
};
  
Inigo Martínez's avatar
Inigo Martínez committed
114 115 116 117 118 119 120 121 122 123
//------------------------------------------------------------------------
// AnnotCalloutLine
//------------------------------------------------------------------------

class AnnotCalloutLine {
public:

  AnnotCalloutLine(double x1, double y1, double x2, double y2);
  virtual ~AnnotCalloutLine() { }

Inigo Martínez's avatar
Inigo Martínez committed
124 125 126 127
  double getX1() const { return coord1.getX(); }
  double getY1() const { return coord1.getY(); }
  double getX2() const { return coord2.getX(); }
  double getY2() const { return coord2.getY(); }
Inigo Martínez's avatar
Inigo Martínez committed
128 129 130
  
protected:

Inigo Martínez's avatar
Inigo Martínez committed
131
  AnnotCoord coord1, coord2;
Inigo Martínez's avatar
Inigo Martínez committed
132 133 134 135 136 137 138 139 140 141 142 143
};

//------------------------------------------------------------------------
// AnnotCalloutMultiLine
//------------------------------------------------------------------------

class AnnotCalloutMultiLine: public AnnotCalloutLine {
public:

  AnnotCalloutMultiLine(double x1, double y1, double x2, double y2,
    double x3, double y3);

Inigo Martínez's avatar
Inigo Martínez committed
144 145
  double getX3() const { return coord3.getX(); }
  double getY3() const { return coord3.getY(); }
Inigo Martínez's avatar
Inigo Martínez committed
146 147 148

protected:

Inigo Martínez's avatar
Inigo Martínez committed
149
  AnnotCoord coord3;
Inigo Martínez's avatar
Inigo Martínez committed
150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174
};

//------------------------------------------------------------------------
// AnnotBorderEffect
//------------------------------------------------------------------------

class AnnotBorderEffect {
public:

  enum AnnotBorderEffectType {
    borderEffectNoEffect, // S
    borderEffectCloudy    // C
  };

  AnnotBorderEffect(Dict *dict);

  AnnotBorderEffectType getEffectType() const { return effectType; }
  double getIntensity() const { return intensity; }

private:

  AnnotBorderEffectType effectType; // S  (Default S)
  double intensity;                 // I  (Default 0)
};

175
//------------------------------------------------------------------------
176
// AnnotQuadrilateral
177 178
//------------------------------------------------------------------------

179
class AnnotQuadrilaterals {
180
public:
181 182 183
  class AnnotQuadrilateral {
  public:
    AnnotQuadrilateral(double x1, double y1, double x2, double y2, double x3,
Inigo Martínez's avatar
Inigo Martínez committed
184 185
      double y3, double x4, double y4);

Inigo Martínez's avatar
Inigo Martínez committed
186
    AnnotCoord coord1, coord2, coord3, coord4;
187
  };
Inigo Martínez's avatar
Inigo Martínez committed
188

189
  AnnotQuadrilaterals(Array *array, PDFRectangle *rect);
190
  AnnotQuadrilaterals(AnnotQuadrilateral **quads, int quadsLength);
191
  ~AnnotQuadrilaterals();
192 193 194 195 196 197 198 199 200 201

  double getX1(int quadrilateral);
  double getY1(int quadrilateral);
  double getX2(int quadrilateral);
  double getY2(int quadrilateral);
  double getX3(int quadrilateral);
  double getY3(int quadrilateral);
  double getX4(int quadrilateral);
  double getY4(int quadrilateral);
  int getQuadrilateralsLength() const { return quadrilateralsLength; }
Inigo Martínez's avatar
Inigo Martínez committed
202
protected:
203 204 205

  AnnotQuadrilateral** quadrilaterals;
  int quadrilateralsLength;
Inigo Martínez's avatar
Inigo Martínez committed
206 207
};

Inigo Martínez's avatar
Inigo Martínez committed
208 209 210 211 212 213
//------------------------------------------------------------------------
// AnnotBorder
//------------------------------------------------------------------------

class AnnotBorder {
public:
214 215 216
  enum AnnotBorderType {
    typeUnknown,
    typeArray,
217
    typeBS
218 219
  };

Inigo Martínez's avatar
Inigo Martínez committed
220 221 222 223 224
  enum AnnotBorderStyle {
    borderSolid,      // Solid
    borderDashed,     // Dashed
    borderBeveled,    // Beveled
    borderInset,      // Inset
225
    borderUnderlined  // Underlined
Inigo Martínez's avatar
Inigo Martínez committed
226
  };
Inigo Martínez's avatar
Inigo Martínez committed
227

228
  AnnotBorder();
Inigo Martínez's avatar
Inigo Martínez committed
229 230
  virtual ~AnnotBorder();

231 232
  virtual void setWidth(double new_width) { width = new_width; }

233
  virtual AnnotBorderType getType() const { return type; }
Inigo Martínez's avatar
Inigo Martínez committed
234 235 236 237
  virtual double getWidth() const { return width; }
  virtual int getDashLength() const { return dashLength; }
  virtual double *getDash() const { return dash; }
  virtual AnnotBorderStyle getStyle() const { return style; }
Inigo Martínez's avatar
Inigo Martínez committed
238 239

protected:
240
  GBool parseDashArray(Object *dashObj);
241

242
  AnnotBorderType type;
Inigo Martínez's avatar
Inigo Martínez committed
243
  double width;
244
  static const int DASH_LIMIT = 10; // implementation note 82 in Appendix H.
Inigo Martínez's avatar
Inigo Martínez committed
245 246 247 248 249 250 251 252 253 254 255 256 257 258
  int dashLength;
  double *dash;
  AnnotBorderStyle style;
};

//------------------------------------------------------------------------
// AnnotBorderArray
//------------------------------------------------------------------------

class AnnotBorderArray: public AnnotBorder {
public:
  AnnotBorderArray();
  AnnotBorderArray(Array *array);

259 260 261 262 263
  void writeToObject(XRef *xref, Object *dest) const;

  void setHorizontalCorner(double hc) { horizontalCorner = hc; }
  void setVerticalCorner(double vc) { verticalCorner = vc; }

264 265
  double getHorizontalCorner() const { return horizontalCorner; }
  double getVerticalCorner() const { return verticalCorner; }
Inigo Martínez's avatar
Inigo Martínez committed
266 267 268 269 270 271 272 273 274 275 276 277 278

protected:
  double horizontalCorner;          // (Default 0)
  double verticalCorner;            // (Default 0)
  // double width;                  // (Default 1)  (inherited from AnnotBorder)
};

//------------------------------------------------------------------------
// AnnotBorderBS
//------------------------------------------------------------------------

class AnnotBorderBS: public AnnotBorder {
public:
Inigo Martínez's avatar
Inigo Martínez committed
279

Inigo Martínez's avatar
Inigo Martínez committed
280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301
  AnnotBorderBS();
  AnnotBorderBS(Dict *dict);

private:
  // double width;           // W  (Default 1)   (inherited from AnnotBorder)
  // AnnotBorderStyle style; // S  (Default S)   (inherited from AnnotBorder)
  // double *dash;           // D  (Default [3]) (inherited from AnnotBorder)
};

//------------------------------------------------------------------------
// AnnotColor
//------------------------------------------------------------------------

class AnnotColor {
public:

  enum AnnotColorSpace {
    colorTransparent = 0,
    colorGray        = 1,
    colorRGB         = 3,
    colorCMYK        = 4
  };
Inigo Martínez's avatar
Inigo Martínez committed
302

Inigo Martínez's avatar
Inigo Martínez committed
303
  AnnotColor();
304 305 306
  AnnotColor(double gray);
  AnnotColor(double r, double g, double b);
  AnnotColor(double c, double m, double y, double k);
307
  AnnotColor(Array *array, int adjust = 0);
Inigo Martínez's avatar
Inigo Martínez committed
308

309 310
  void adjustColor(int adjust);

311
  AnnotColorSpace getSpace() const { return (AnnotColorSpace) length; }
312
  const double *getValues() const { return values; }
Inigo Martínez's avatar
Inigo Martínez committed
313

314 315
  void writeToObject(XRef *xref, Object *dest) const;

Inigo Martínez's avatar
Inigo Martínez committed
316 317
private:

318
  double values[4];
Inigo Martínez's avatar
Inigo Martínez committed
319 320
  int length;
};
321

322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370
//------------------------------------------------------------------------
// AnnotIconFit
//------------------------------------------------------------------------

class AnnotIconFit {
public:

  enum AnnotIconFitScaleWhen {
    scaleAlways,  // A
    scaleBigger,  // B
    scaleSmaller, // S
    scaleNever    // N
  };

  enum AnnotIconFitScale {
    scaleAnamorphic,  // A
    scaleProportional // P
  };

  AnnotIconFit(Dict *dict);

  AnnotIconFitScaleWhen getScaleWhen() { return scaleWhen; }
  AnnotIconFitScale getScale() { return scale; }
  double getLeft() { return left; }
  double getBottom() { return bottom; }
  bool getFullyBounds() { return fullyBounds; }

protected:

  AnnotIconFitScaleWhen scaleWhen;  // SW (Default A)
  AnnotIconFitScale scale;          // S  (Default P)
  double left;                      // A  (Default [0.5 0.5]
  double bottom;                    // Only if scale is P
  bool fullyBounds;                 // FB (Default false)
};

//------------------------------------------------------------------------
// AnnotAppearance
//------------------------------------------------------------------------

class AnnotAppearance {
public:

  enum AnnotAppearanceType {
    appearNormal,
    appearRollover,
    appearDown
  };

371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390
  AnnotAppearance(PDFDoc *docA, Object *dict);
  ~AnnotAppearance();

  // State is ignored if no subdictionary is present
  void getAppearanceStream(AnnotAppearanceType type, const char *state, Object *dest);

  // Access keys in normal appearance subdictionary (N)
  GooString * getStateKey(int i);
  int getNumStates();

  // Removes all associated streams in the xref table. Caller is required to
  // reset parent annotation's AP and AS after this call.
  void removeAllStreams();

private:
  void removeStateStreams(Object *state);

protected:
  XRef *xref;                   // the xref table for this PDF file
  Object appearDict;            // Annotation's AP
391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436
};

//------------------------------------------------------------------------
// AnnotAppearanceCharacs
//------------------------------------------------------------------------

class AnnotAppearanceCharacs {
public:

  enum AnnotAppearanceCharacsTextPos {
    captionNoIcon,    // 0
    captionNoCaption, // 1
    captionBelow,     // 2
    captionAbove,     // 3
    captionRight,     // 4
    captionLeft,      // 5
    captionOverlaid   // 6
  };

  AnnotAppearanceCharacs(Dict *dict);
  ~AnnotAppearanceCharacs();

  int getRotation() { return rotation; }
  AnnotColor *getBorderColor() { return borderColor; }
  AnnotColor *getBackColor() { return backColor; }
  GooString *getNormalCaption() { return normalCaption; }
  GooString *getRolloverCaption() { return rolloverCaption; }
  GooString *getAlternateCaption() { return alternateCaption; }
  AnnotIconFit *getIconFit() { return iconFit; }
  AnnotAppearanceCharacsTextPos getPosition() { return position; }

protected:

  int rotation;                           // R  (Default 0)
  AnnotColor *borderColor;                // BC
  AnnotColor *backColor;                  // BG
  GooString *normalCaption;               // CA
  GooString *rolloverCaption;             // RC
  GooString *alternateCaption;            // AC
  // I
  // RI
  // IX
  AnnotIconFit *iconFit;                  // IF
  AnnotAppearanceCharacsTextPos position; // TP (Default 0)
};

Kristian Høgsberg's avatar
Kristian Høgsberg committed
437 438 439 440 441 442
//------------------------------------------------------------------------
// Annot
//------------------------------------------------------------------------

class Annot {
public:
Inigo Martínez's avatar
Inigo Martínez committed
443 444 445 446 447 448 449 450 451 452 453 454 455
  enum AnnotFlag {
    flagUnknown        = 0x0000,
    flagInvisible      = 0x0001,
    flagHidden         = 0x0002,
    flagPrint          = 0x0004,
    flagNoZoom         = 0x0008,
    flagNoRotate       = 0x0010,
    flagNoView         = 0x0020,
    flagReadOnly       = 0x0040,
    flagLocked         = 0x0080,
    flagToggleNoView   = 0x0100,
    flagLockedContents = 0x0200
  };
Kristian Høgsberg's avatar
Kristian Høgsberg committed
456

457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485
  enum AnnotSubtype {
    typeUnknown,        //                 0
    typeText,           // Text            1
    typeLink,           // Link            2
    typeFreeText,       // FreeText        3
    typeLine,           // Line            4
    typeSquare,         // Square          5
    typeCircle,         // Circle          6
    typePolygon,        // Polygon         7
    typePolyLine,       // PolyLine        8
    typeHighlight,      // Highlight       9
    typeUnderline,      // Underline      10
    typeSquiggly,       // Squiggly       11
    typeStrikeOut,      // StrikeOut      12
    typeStamp,          // Stamp          13
    typeCaret,          // Caret          14
    typeInk,            // Ink            15
    typePopup,          // Popup          16
    typeFileAttachment, // FileAttachment 17
    typeSound,          // Sound          18
    typeMovie,          // Movie          19
    typeWidget,         // Widget         20
    typeScreen,         // Screen         21
    typePrinterMark,    // PrinterMark    22
    typeTrapNet,        // TrapNet        23
    typeWatermark,      // Watermark      24
    type3D              // 3D             25
  };

486 487 488
  Annot(PDFDoc *docA, PDFRectangle *rectA);
  Annot(PDFDoc *docA, Dict *dict);
  Annot(PDFDoc *docA, Dict *dict, Object *obj);
Kristian Høgsberg's avatar
Kristian Høgsberg committed
489 490
  GBool isOk() { return ok; }

491 492 493
  void incRefCnt();
  void decRefCnt();

494
  virtual void draw(Gfx *gfx, GBool printing);
495 496
  // Get the resource dict of the appearance stream
  virtual Object *getAppearanceResDict(Object *dest);
Kristian Høgsberg's avatar
Kristian Høgsberg committed
497

498 499 500
  GBool match(Ref *refA)
    { return ref.num == refA->num && ref.gen == refA->gen; }

Inigo Martínez's avatar
Inigo Martínez committed
501 502
  double getXMin();
  double getYMin();
503 504

  double getFontSize() { return fontSize; }
Kristian Høgsberg's avatar
Kristian Høgsberg committed
505

506 507 508
  void setRect(PDFRectangle *rect);
  void setRect(double x1, double y1, double x2, double y2);

509
  // Sets the annot contents to new_content
510
  // new_content should never be NULL
511
  void setContents(GooString *new_content);
512 513 514
  void setName(GooString *new_name);
  void setModified(GooString *new_date);
  void setFlags(Guint new_flags);
Carlos Garcia Campos's avatar
Carlos Garcia Campos committed
515

516 517
  void setBorder(AnnotBorderArray *new_border); // Takes ownership

Carlos Garcia Campos's avatar
Carlos Garcia Campos committed
518 519 520 521
  // The annotation takes the ownership of
  // new_color. 
  void setColor(AnnotColor *new_color);

522 523
  void setPage(Ref *pageRef, int pageIndex);

524
  void setAppearanceState(const char *state);
525

526 527 528
  // Delete appearance streams and reset appearance state
  void invalidateAppearance();

529
  // getters
530
  PDFDoc *getDoc() const { return doc; }
531
  XRef *getXRef() const { return xref; }
532
  GBool getHasRef() const { return hasRef; }
533
  Ref getRef() const { return ref; }
Inigo Martínez's avatar
Inigo Martínez committed
534 535
  AnnotSubtype getType() const { return type; }
  PDFRectangle *getRect() const { return rect; }
536
  void getRect(double *x1, double *y1, double *x2, double *y2) const;
Inigo Martínez's avatar
Inigo Martínez committed
537
  GooString *getContents() const { return contents; }
538
  int getPageNum() const { return page; }
Inigo Martínez's avatar
Inigo Martínez committed
539 540 541
  GooString *getName() const { return name; }
  GooString *getModified() const { return modified; }
  Guint getFlags() const { return flags; }
542
  AnnotAppearance *getAppearStreams() const { return appearStreams; }
Inigo Martínez's avatar
Inigo Martínez committed
543 544 545 546
  GooString *getAppearState() const { return appearState; }
  AnnotBorder *getBorder() const { return border; }
  AnnotColor *getColor() const { return color; }
  int getTreeKey() const { return treeKey; }
547

Hugo Mercier's avatar
Hugo Mercier committed
548 549
  int getId() { return ref.num; }

550 551 552
  // Check if point is inside the annot rectangle.
  GBool inRect(double x, double y) const;

553
private:
Albert Astals Cid's avatar
Albert Astals Cid committed
554
  void readArrayNum(Object *pdfArray, int key, double *value);
555
  // write vStr[i:j[ in appearBuf
556

557
  void initialize (PDFDoc *docA, Dict *dict);
558

Hugo Mercier's avatar
Hugo Mercier committed
559

Inigo Martínez's avatar
Inigo Martínez committed
560
protected:
561
  virtual ~Annot();
562
  void setColor(AnnotColor *color, GBool fill);
563 564 565
  void drawCircle(double cx, double cy, double r, GBool fill);
  void drawCircleTopLeft(double cx, double cy, double r);
  void drawCircleBottomRight(double cx, double cy, double r);
566 567 568 569
  void layoutText(GooString *text, GooString *outBuf, int *i, GfxFont *font,
		  double *width, double widthLimit, int *charCount,
		  GBool noReencode);
  void writeString(GooString *str, GooString *appearBuf);
570
  void createForm(double *bbox, GBool transparencyGroup, Object *resDict, Object *aStream);
571 572
  void createResourcesDict(const char *formName, Object *formStream, const char *stateName,
			   double opacity, const char *blendMode, Object *resDict);
573
  GBool isVisible(GBool printing);
574

575 576 577 578
  // Updates the field key of the annotation dictionary
  // and sets M to the current time
  void update(const char *key, Object *value);

579 580
  int refCnt;

581
  Object annotObj;
582
  
Inigo Martínez's avatar
Inigo Martínez committed
583
  // required data
584 585
  AnnotSubtype type;                // Annotation type
  PDFRectangle *rect;               // Rect
Inigo Martínez's avatar
Inigo Martínez committed
586 587 588

  // optional data
  GooString *contents;              // Contents
589
  int       page;                   // P
Inigo Martínez's avatar
Inigo Martínez committed
590 591 592
  GooString *name;                  // NM
  GooString *modified;              // M
  Guint flags;                      // F (must be a 32 bit unsigned int)
593
  AnnotAppearance *appearStreams;   // AP
Inigo Martínez's avatar
Inigo Martínez committed
594 595 596 597
  Object appearance;     // a reference to the Form XObject stream
                         //   for the normal appearance
  GooString *appearState;           // AS
  int treeKey;                      // Struct Parent;
598
  Object oc;                        // OC
Inigo Martínez's avatar
Inigo Martínez committed
599

600
  PDFDoc *doc;
Kristian Høgsberg's avatar
Kristian Høgsberg committed
601
  XRef *xref;			// the xref table for this PDF file
602
  Ref ref;                      // object ref identifying this annotation
603
  GooString *appearBuf;
Inigo Martínez's avatar
Inigo Martínez committed
604 605
  AnnotBorder *border;          // Border, BS
  AnnotColor *color;            // C
606
  double fontSize; 
Kristian Høgsberg's avatar
Kristian Høgsberg committed
607
  GBool ok;
Inigo Martínez's avatar
Inigo Martínez committed
608

609
  bool hasRef;
Kristian Høgsberg's avatar
Kristian Høgsberg committed
610 611
};

Inigo Martínez's avatar
Inigo Martínez committed
612 613 614 615 616 617
//------------------------------------------------------------------------
// AnnotPopup
//------------------------------------------------------------------------

class AnnotPopup: public Annot {
public:
618 619
  AnnotPopup(PDFDoc *docA, PDFRectangle *rect);
  AnnotPopup(PDFDoc *docA, Dict *dict, Object *obj);
620
  ~AnnotPopup();
Inigo Martínez's avatar
Inigo Martínez committed
621

622
  Object *getParent(Object *obj) { return parent.fetch (xref, obj); }
623 624 625
  Object *getParentNF(Object *obj) { return &parent; }
  void setParent(Object *parentA);
  void setParent(Annot *parentA);
Inigo Martínez's avatar
Inigo Martínez committed
626
  GBool getOpen() const { return open; }
627
  void setOpen(GBool openA);
Inigo Martínez's avatar
Inigo Martínez committed
628 629

protected:
630
  void initialize(PDFDoc *docA, Dict *dict);
Inigo Martínez's avatar
Inigo Martínez committed
631

632
  Object parent; // Parent
Inigo Martínez's avatar
Inigo Martínez committed
633
  GBool open;   // Open
Inigo Martínez's avatar
Inigo Martínez committed
634 635
};

Inigo Martínez's avatar
Inigo Martínez committed
636 637 638 639
//------------------------------------------------------------------------
// AnnotMarkup
//------------------------------------------------------------------------

640
class AnnotMarkup: public Annot {
Inigo Martínez's avatar
Inigo Martínez committed
641 642 643 644 645 646
public:
  enum  AnnotMarkupReplyType {
    replyTypeR,     // R
    replyTypeGroup  // Group
  };

647 648
  AnnotMarkup(PDFDoc *docA, PDFRectangle *rect);
  AnnotMarkup(PDFDoc *docA, Dict *dict, Object *obj);
Inigo Martínez's avatar
Inigo Martínez committed
649 650 651
  virtual ~AnnotMarkup();

  // getters
Inigo Martínez's avatar
Inigo Martínez committed
652 653 654
  GooString *getLabel() const { return label; }
  AnnotPopup *getPopup() const { return popup; }
  double getOpacity() const { return opacity; }
Inigo Martínez's avatar
Inigo Martínez committed
655
  // getRC
Inigo Martínez's avatar
Inigo Martínez committed
656
  GooString *getDate() const { return date; }
657
  int getInReplyToID() const { return inReplyTo.num; }
Inigo Martínez's avatar
Inigo Martínez committed
658 659 660
  GooString *getSubject() const { return subject; }
  AnnotMarkupReplyType getReplyTo() const { return replyTo; }
  AnnotExternalDataType getExData() const { return exData; }
Inigo Martínez's avatar
Inigo Martínez committed
661

662 663 664
  // The annotation takes the ownership of new_popup
  void setPopup(AnnotPopup *new_popup);
  void setLabel(GooString *new_label);
665
  void setOpacity(double opacityA);
666
  void setDate(GooString *new_date);
667

Inigo Martínez's avatar
Inigo Martínez committed
668 669 670 671 672 673
protected:
  GooString *label;             // T            (Default autor)
  AnnotPopup *popup;            // Popup
  double opacity;               // CA           (Default 1.0)
  // RC
  GooString *date;              // CreationDate
674
  Ref inReplyTo;                // IRT
Inigo Martínez's avatar
Inigo Martínez committed
675 676 677 678 679 680 681 682
  GooString *subject;           // Subj
  AnnotMarkupReplyType replyTo; // RT           (Default R)
  // this object is overrided by the custom intent fields defined in some
  // annotation types.
  //GooString *intent;          // IT
  AnnotExternalDataType exData; // ExData

private:
683
  void initialize(PDFDoc *docA, Dict *dict, Object *obj);
Inigo Martínez's avatar
Inigo Martínez committed
684 685
};

Inigo Martínez's avatar
Inigo Martínez committed
686 687 688 689
//------------------------------------------------------------------------
// AnnotText
//------------------------------------------------------------------------

690
class AnnotText: public AnnotMarkup {
Inigo Martínez's avatar
Inigo Martínez committed
691 692 693 694 695 696 697 698 699 700 701 702 703 704
public:
  enum AnnotTextState {
    stateUnknown,
    // Marked state model
    stateMarked,    // Marked
    stateUnmarked,  // Unmarked
    // Review state model
    stateAccepted,  // Accepted
    stateRejected,  // Rejected
    stateCancelled, // Cancelled
    stateCompleted, // Completed
    stateNone       // None
  };

705 706
  AnnotText(PDFDoc *docA, PDFRectangle *rect);
  AnnotText(PDFDoc *docA, Dict *dict, Object *obj);
707
  ~AnnotText();
Inigo Martínez's avatar
Inigo Martínez committed
708

709 710
  virtual void draw(Gfx *gfx, GBool printing);

Inigo Martínez's avatar
Inigo Martínez committed
711
  // getters
Inigo Martínez's avatar
Inigo Martínez committed
712
  GBool getOpen() const { return open; }
713
  GooString *getIcon() const { return icon; }
Inigo Martínez's avatar
Inigo Martínez committed
714
  AnnotTextState getState() const { return state; }
Inigo Martínez's avatar
Inigo Martínez committed
715

716 717 718
  void setOpen(GBool openA);
  void setIcon(GooString *new_icon);

Inigo Martínez's avatar
Inigo Martínez committed
719 720
private:

721
  void initialize(PDFDoc *docA, Dict *dict);
Inigo Martínez's avatar
Inigo Martínez committed
722

Inigo Martínez's avatar
Inigo Martínez committed
723
  GBool open;                       // Open       (Default false)
724
  GooString *icon;                  // Name       (Default Note)
Inigo Martínez's avatar
Inigo Martínez committed
725 726 727 728 729
  AnnotTextState state;             // State      (Default Umarked if
                                    //             StateModel Marked
                                    //             None if StareModel Review)
};

Hugo Mercier's avatar
Hugo Mercier committed
730 731 732 733 734 735 736 737
//------------------------------------------------------------------------
// AnnotMovie
//------------------------------------------------------------------------



class AnnotMovie: public Annot {
 public:
738 739
  AnnotMovie(PDFDoc *docA, PDFRectangle *rect, Movie *movieA);
  AnnotMovie(PDFDoc *docA, Dict *dict, Object *obj);
Hugo Mercier's avatar
Hugo Mercier committed
740 741
  ~AnnotMovie();

742 743
  virtual void draw(Gfx *gfx, GBool printing);

Hugo Mercier's avatar
Hugo Mercier committed
744 745 746 747
  GooString* getTitle() { return title; }
  Movie* getMovie() { return movie; }

 private:
748
  void initialize(PDFDoc *docA, Dict *dict);
Hugo Mercier's avatar
Hugo Mercier committed
749 750

  GooString* title;      // T
751
  Movie* movie;          // Movie + A
Hugo Mercier's avatar
Hugo Mercier committed
752 753 754 755 756 757 758 759 760 761
};


//------------------------------------------------------------------------
// AnnotScreen
//------------------------------------------------------------------------

class AnnotScreen: public Annot {
 public:

762 763
  AnnotScreen(PDFDoc *docA, PDFRectangle *rect);
  AnnotScreen(PDFDoc *docA, Dict *dict, Object *obj);
Hugo Mercier's avatar
Hugo Mercier committed
764 765 766 767 768
  ~AnnotScreen();

  GooString* getTitle() { return title; }

  AnnotAppearanceCharacs *getAppearCharacs() { return appearCharacs; }
769
  LinkAction* getAction() { return action; }
Hugo Mercier's avatar
Hugo Mercier committed
770 771 772
  Object* getAdditionActions() { return &additionAction; }

 private:
773
  void initialize(PDFDoc *docA, Dict *dict);
Hugo Mercier's avatar
Hugo Mercier committed
774 775 776 777 778 779


  GooString* title;                      // T

  AnnotAppearanceCharacs* appearCharacs; // MK

780
  LinkAction *action;                    // A
Hugo Mercier's avatar
Hugo Mercier committed
781 782 783
  Object additionAction;                 // AA
};

784 785 786 787 788 789 790
//------------------------------------------------------------------------
// AnnotLink
//------------------------------------------------------------------------

class AnnotLink: public Annot {
public:

791 792 793 794 795 796 797
  enum AnnotLinkEffect {
    effectNone,     // N
    effectInvert,   // I
    effectOutline,  // O
    effectPush      // P
  };

798 799
  AnnotLink(PDFDoc *docA, PDFRectangle *rect);
  AnnotLink(PDFDoc *docA, Dict *dict, Object *obj);
800 801
  virtual ~AnnotLink();

802 803
  virtual void draw(Gfx *gfx, GBool printing);

804
  // getters
805
  LinkAction *getAction() const { return action; }
806 807
  AnnotLinkEffect getLinkEffect() const { return linkEffect; }
  Dict *getUriAction() const { return uriAction; }
808
  AnnotQuadrilaterals *getQuadrilaterals() const { return quadrilaterals; }
809 810 811

protected:

812
  void initialize(PDFDoc *docA, Dict *dict);
813

814
  LinkAction *action;                  // A, Dest
815 816
  AnnotLinkEffect linkEffect;          // H          (Default I)
  Dict *uriAction;                     // PA
817

818
  AnnotQuadrilaterals *quadrilaterals; // QuadPoints
819 820
};

Inigo Martínez's avatar
Inigo Martínez committed
821 822 823 824
//------------------------------------------------------------------------
// AnnotFreeText
//------------------------------------------------------------------------

825
class AnnotFreeText: public AnnotMarkup {
Inigo Martínez's avatar
Inigo Martínez committed
826 827 828 829 830 831 832 833 834 835 836 837 838 839
public:

  enum AnnotFreeTextQuadding {
    quaddingLeftJustified,  // 0
    quaddingCentered,       // 1
    quaddingRightJustified  // 2
  };

  enum AnnotFreeTextIntent {
    intentFreeText,           // FreeText
    intentFreeTextCallout,    // FreeTextCallout
    intentFreeTextTypeWriter  // FreeTextTypeWriter
  };

840 841
  AnnotFreeText(PDFDoc *docA, PDFRectangle *rect, GooString *da);
  AnnotFreeText(PDFDoc *docA, Dict *dict, Object *obj);
842
  ~AnnotFreeText();
Inigo Martínez's avatar
Inigo Martínez committed
843

844
  virtual void draw(Gfx *gfx, GBool printing);
845
  virtual Object *getAppearanceResDict(Object *dest);
846

847
  void setAppearanceString(GooString *new_string);
848 849
  void setQuadding(AnnotFreeTextQuadding new_quadding);
  void setStyleString(GooString *new_string);
850
  void setCalloutLine(AnnotCalloutLine *line);
851 852
  void setIntent(AnnotFreeTextIntent new_intent);

Inigo Martínez's avatar
Inigo Martínez committed
853 854 855 856 857 858 859 860 861 862 863 864 865
  // getters
  GooString *getAppearanceString() const { return appearanceString; }
  AnnotFreeTextQuadding getQuadding() const { return quadding; }
  // return rc
  GooString *getStyleString() const { return styleString; }
  AnnotCalloutLine *getCalloutLine() const {  return calloutLine; }
  AnnotFreeTextIntent getIntent() const { return intent; }
  AnnotBorderEffect *getBorderEffect() const { return borderEffect; }
  PDFRectangle *getRectangle() const { return rectangle; }
  AnnotLineEndingStyle getEndStyle() const { return endStyle; }

protected:

866
  void initialize(PDFDoc *docA, Dict *dict);
867
  void generateFreeTextAppearance();
Inigo Martínez's avatar
Inigo Martínez committed
868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884

  // required
  GooString *appearanceString;      // DA

  // optional
  AnnotFreeTextQuadding quadding;   // Q  (Default 0)
  // RC
  GooString *styleString;           // DS
  AnnotCalloutLine *calloutLine;    // CL
  AnnotFreeTextIntent intent;       // IT
  AnnotBorderEffect *borderEffect;  // BE
  PDFRectangle *rectangle;          // RD
  // inherited  from Annot
  // AnnotBorderBS border;          // BS
  AnnotLineEndingStyle endStyle;    // LE (Default None)
};

885 886 887 888
//------------------------------------------------------------------------
// AnnotLine
//------------------------------------------------------------------------

889
class AnnotLine: public AnnotMarkup {
890 891 892 893 894 895 896 897 898 899 900 901
public:

  enum AnnotLineIntent {
    intentLineArrow,    // LineArrow
    intentLineDimension // LineDimension
  };

  enum AnnotLineCaptionPos {
    captionPosInline, // Inline
    captionPosTop     // Top
  };

902 903
  AnnotLine(PDFDoc *docA, PDFRectangle *rect, PDFRectangle *lRect);
  AnnotLine(PDFDoc *docA, Dict *dict, Object *obj);
904
  ~AnnotLine();
905

906 907
  virtual void draw(Gfx *gfx, GBool printing);

908 909 910 911 912 913 914 915
  void setVertices(double x1, double y1, double x2, double y2);
  void setStartEndStyle(AnnotLineEndingStyle start, AnnotLineEndingStyle end);
  void setInteriorColor(AnnotColor *new_color);
  void setLeaderLineLength(double len);
  void setLeaderLineExtension(double len);
  void setCaption(bool new_cap);
  void setIntent(AnnotLineIntent new_intent);

916 917 918 919 920 921 922 923 924 925 926 927 928
  // getters
  AnnotLineEndingStyle getStartStyle() const { return startStyle; }
  AnnotLineEndingStyle getEndStyle() const { return endStyle; }
  AnnotColor *getInteriorColor() const { return interiorColor; }
  double getLeaderLineLength() const { return leaderLineLength; }
  double getLeaderLineExtension() const { return leaderLineExtension; }
  bool getCaption() const { return caption; }
  AnnotLineIntent getIntent() const { return intent; }
  double  getLeaderLineOffset() const { return leaderLineOffset; }
  AnnotLineCaptionPos getCaptionPos() const { return captionPos; }
  Dict *getMeasure() const { return measure; }
  double getCaptionTextHorizontal() const { return captionTextHorizontal; }
  double getCaptionTextVertical() const { return captionTextVertical; }
Inigo Martínez's avatar
Inigo Martínez committed
929 930 931 932
  double getX1() const { return coord1->getX(); }
  double getY1() const { return coord1->getY(); }
  double getX2() const { return coord2->getX(); }
  double getY2() const { return coord2->getY(); }
933 934 935

protected:

936
  void initialize(PDFDoc *docA, Dict *dict);
937 938

  // required
Inigo Martínez's avatar
Inigo Martínez committed
939
  AnnotCoord *coord1, *coord2;
940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961
  
  // optional
  // inherited  from Annot
  // AnnotBorderBS border;          // BS
  AnnotLineEndingStyle startStyle;  // LE       (Default [/None /None])
  AnnotLineEndingStyle endStyle;    //
  AnnotColor *interiorColor;        // IC
  double leaderLineLength;          // LL       (Default 0)
  double leaderLineExtension;       // LLE      (Default 0)
  bool caption;                     // Cap      (Default false)
  AnnotLineIntent intent;           // IT
  double leaderLineOffset;          // LLO
  AnnotLineCaptionPos captionPos;   // CP       (Default Inline)
  Dict *measure;                    // Measure
  double captionTextHorizontal;     // CO       (Default [0, 0])
  double captionTextVertical;       //
};

//------------------------------------------------------------------------
// AnnotTextMarkup
//------------------------------------------------------------------------

962
class AnnotTextMarkup: public AnnotMarkup {
963 964
public:

965 966 967
  AnnotTextMarkup(PDFDoc *docA, PDFRectangle *rect, AnnotSubtype subType,
		  AnnotQuadrilaterals *quadPoints);
  AnnotTextMarkup(PDFDoc *docA, Dict *dict, Object *obj);
968 969
  virtual ~AnnotTextMarkup();

970 971
  virtual void draw(Gfx *gfx, GBool printing);

972 973 974 975 976
  // typeHighlight, typeUnderline, typeSquiggly or typeStrikeOut
  void setType(AnnotSubtype new_type);

  void setQuadrilaterals(AnnotQuadrilaterals *quadPoints);

977 978 979 980
  AnnotQuadrilaterals *getQuadrilaterals() const { return quadrilaterals; }

protected:

981
  void initialize(PDFDoc *docA, Dict *dict);
982 983 984 985
  
  AnnotQuadrilaterals *quadrilaterals; // QuadPoints
};

986 987 988 989 990 991 992
//------------------------------------------------------------------------
// AnnotStamp
//------------------------------------------------------------------------

class AnnotStamp: public AnnotMarkup {
public:

993 994
  AnnotStamp(PDFDoc *docA, PDFRectangle *rect);
  AnnotStamp(PDFDoc *docA, Dict *dict, Object *obj);
995 996
  ~AnnotStamp();

997 998
  void setIcon(GooString *new_icon);

999 1000 1001 1002 1003
  // getters
  GooString *getIcon() const { return icon; }

private:

1004
  void initialize(PDFDoc *docA, Dict *dict);
1005 1006 1007 1008

  GooString *icon;                  // Name       (Default Draft)
};

1009 1010 1011 1012 1013 1014 1015
//------------------------------------------------------------------------
// AnnotGeometry
//------------------------------------------------------------------------

class AnnotGeometry: public AnnotMarkup {
public:

1016 1017
  AnnotGeometry(PDFDoc *docA, PDFRectangle *rect, AnnotSubtype subType);
  AnnotGeometry(PDFDoc *docA, Dict *dict, Object *obj);
1018 1019
  ~AnnotGeometry();

1020 1021
  virtual void draw(Gfx *gfx, GBool printing);

1022 1023 1024
  void setType(AnnotSubtype new_type); // typeSquare or typeCircle
  void setInteriorColor(AnnotColor *new_color);

1025 1026 1027 1028 1029 1030 1031
  // getters
  AnnotColor *getInteriorColor() const { return interiorColor; }
  AnnotBorderEffect *getBorderEffect() const { return borderEffect; }
  PDFRectangle *getGeometryRect() const { return geometryRect; }

private:

1032
  void initialize(PDFDoc *docA, Dict *dict);
1033 1034 1035 1036 1037 1038

  AnnotColor *interiorColor;        // IC
  AnnotBorderEffect *borderEffect;  // BE
  PDFRectangle *geometryRect;       // RD (combined with Rect)
};

1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051
//------------------------------------------------------------------------
// AnnotPolygon
//------------------------------------------------------------------------

class AnnotPolygon: public AnnotMarkup {
public:

  enum AnnotPolygonIntent {
    polygonCloud,      // PolygonCloud
    polylineDimension, // PolyLineDimension
    polygonDimension   // PolygonDimension
  };

1052 1053
  AnnotPolygon(PDFDoc *docA, PDFRectangle *rect, AnnotSubtype subType, AnnotPath *path);
  AnnotPolygon(PDFDoc *docA, Dict *dict, Object *obj);
1054 1055
  ~AnnotPolygon();

Fabio D'Urso's avatar
Fabio D'Urso committed
1056 1057
  virtual void draw(Gfx *gfx, GBool printing);

1058 1059 1060 1061 1062 1063
  void setType(AnnotSubtype new_type); // typePolygon or typePolyLine
  void setVertices(AnnotPath *path);
  void setStartEndStyle(AnnotLineEndingStyle start, AnnotLineEndingStyle end);
  void setInteriorColor(AnnotColor *new_color);
  void setIntent(AnnotPolygonIntent new_intent);

1064
  // getters
1065 1066 1067 1068 1069 1070
  AnnotPath *getVertices() const { return vertices; }
  AnnotLineEndingStyle getStartStyle() const { return startStyle; }
  AnnotLineEndingStyle getEndStyle() const { return endStyle; }
  AnnotColor *getInteriorColor() const { return interiorColor; }
  AnnotBorderEffect *getBorderEffect() const { return borderEffect; }
  AnnotPolygonIntent getIntent() const { return intent; }
1071 1072 1073

private:

1074
  void initialize(PDFDoc *docA, Dict *dict);
1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089

  // required
  AnnotPath *vertices;              // Vertices

  // optional
  AnnotLineEndingStyle startStyle;  // LE       (Default [/None /None])
  AnnotLineEndingStyle endStyle;    //
  // inherited  from Annot
  // AnnotBorderBS border;          // BS
  AnnotColor *interiorColor;        // IC
  AnnotBorderEffect *borderEffect;  // BE
  AnnotPolygonIntent intent;        // IT
  // Measure
};

Pino Toscano's avatar
Pino Toscano committed
1090
//------------------------------------------------------------------------
Pino Toscano's avatar
Pino Toscano committed
1091
// AnnotCaret
Pino Toscano's avatar
Pino Toscano committed
1092 1093 1094 1095 1096
//------------------------------------------------------------------------

class AnnotCaret: public AnnotMarkup {
public:

1097 1098 1099 1100 1101
  enum AnnotCaretSymbol {
    symbolNone,     // None
    symbolP         // P
  };

1102 1103
  AnnotCaret(PDFDoc *docA, PDFRectangle *rect);
  AnnotCaret(PDFDoc *docA, Dict *dict, Object *obj);
Pino Toscano's avatar
Pino Toscano committed
1104 1105
  ~AnnotCaret();

1106 1107
  void setSymbol(AnnotCaretSymbol new_symbol);

Pino Toscano's avatar
Pino Toscano committed
1108
  // getters
1109
  AnnotCaretSymbol getSymbol() const { return symbol; }
Pino Toscano's avatar
Pino Toscano committed
1110 1111 1112 1113
  PDFRectangle *getCaretRect() const { return caretRect; }

private:

1114
  void initialize(PDFDoc *docA, Dict *dict);
Pino Toscano's avatar
Pino Toscano committed
1115

1116
  AnnotCaretSymbol symbol;       // Sy         (Default None)
Pino Toscano's avatar
Pino Toscano committed
1117 1118 1119
  PDFRectangle *caretRect;       // RD (combined with Rect)
};

Inigo Martínez's avatar
Inigo Martínez committed
1120 1121 1122 1123 1124 1125 1126
//------------------------------------------------------------------------
// AnnotInk
//------------------------------------------------------------------------

class AnnotInk: public AnnotMarkup {
public:

1127 1128
  AnnotInk(PDFDoc *docA, PDFRectangle *rect, AnnotPath **paths, int n_paths);
  AnnotInk(PDFDoc *docA, Dict *dict, Object *obj);
Inigo Martínez's avatar
Inigo Martínez committed
1129 1130
  ~AnnotInk();

Fabio D'Urso's avatar
Fabio D'Urso committed
1131 1132
  virtual void draw(Gfx *gfx, GBool printing);

1133 1134
  void setInkList(AnnotPath **paths, int n_paths);

Inigo Martínez's avatar
Inigo Martínez committed
1135
  // getters
1136 1137
  AnnotPath **getInkList() const { return inkList; }
  int getInkListLength() const { return inkListLength; }
Inigo Martínez's avatar
Inigo Martínez committed
1138 1139 1140

private:

1141
  void initialize(PDFDoc *docA, Dict *dict);
1142 1143 1144
  void writeInkList(AnnotPath **paths, int n_paths, Array *dest_array);
  void parseInkList(Array *src_array);
  void freeInkList();
Inigo Martínez's avatar
Inigo Martínez committed
1145 1146 1147 1148 1149 1150 1151 1152 1153 1154

  // required
  AnnotPath **inkList;       // InkList
  int inkListLength;

  // optional
  // inherited from Annot
  // AnnotBorderBS border;  // BS
};

1155 1156 1157 1158 1159 1160 1161
//------------------------------------------------------------------------
// AnnotFileAttachment
//------------------------------------------------------------------------

class AnnotFileAttachment: public AnnotMarkup {
public:

1162 1163
  AnnotFileAttachment(PDFDoc *docA, PDFRectangle *rect, GooString *filename);
  AnnotFileAttachment(PDFDoc *docA, Dict *dict, Object *obj);
1164 1165
  ~AnnotFileAttachment();

1166 1167
  virtual void draw(Gfx *gfx, GBool printing);

1168
  // getters
1169
  Object *getFile() { return &file; }
1170
  GooString *getName() const { return name; }
1171 1172 1173

private:

1174
  void initialize(PDFDoc *docA, Dict *dict);
1175 1176 1177 1178 1179 1180 1181 1182

  // required
  Object file;      // FS

  // optional
  GooString *name;  // Name
};

Pino Toscano's avatar
Pino Toscano committed
1183 1184 1185 1186 1187 1188 1189
//------------------------------------------------------------------------
// AnnotSound
//------------------------------------------------------------------------

class AnnotSound: public AnnotMarkup {
public:

1190 1191
  AnnotSound(PDFDoc *docA, PDFRectangle *rect, Sound *soundA);
  AnnotSound(PDFDoc *docA, Dict *dict, Object *obj);
Pino Toscano's avatar
Pino Toscano committed
1192 1193
  ~AnnotSound();

1194 1195
  virtual void draw(Gfx *gfx, GBool printing);

Pino Toscano's avatar
Pino Toscano committed
1196 1197 1198 1199 1200 1201
  // getters
  Sound *getSound() { return sound; }
  GooString *getName() const { return name; }

private:

1202
  void initialize(PDFDoc *docA, Dict *dict);
Pino Toscano's avatar
Pino Toscano committed
1203 1204 1205 1206 1207 1208 1209 1210

  // required
  Sound *sound;                  // Sound

  // optional
  GooString *name;               // Name
};

1211 1212 1213 1214 1215 1216 1217 1218 1219 1220 1221 1222 1223 1224
//------------------------------------------------------------------------
// AnnotWidget
//------------------------------------------------------------------------

class AnnotWidget: public Annot {
public:

  enum AnnotWidgetHighlightMode {
    highlightModeNone,    // N
    highlightModeInvert,  // I
    highlightModeOutline, // O
    highlightModePush     // P,T
  };

1225 1226
  AnnotWidget(PDFDoc *docA, Dict *dict, Object *obj);
  AnnotWidget(PDFDoc *docA, Dict *dict, Object *obj, FormField *fieldA);
1227 1228
  virtual ~AnnotWidget();

1229 1230
  virtual void draw(Gfx *gfx, GBool printing);

1231
  void drawBorder();
1232 1233 1234
  void drawFormFieldButton(GfxResources *resources, GooString *da);
  void drawFormFieldText(GfxResources *resources, GooString *da);
  void drawFormFieldChoice(GfxResources *resources, GooString *da);
1235 1236
  void generateFieldAppearance ();

1237 1238
  AnnotWidgetHighlightMode getMode() { return mode; }
  AnnotAppearanceCharacs *getAppearCharacs() { return appearCharacs; }
1239
  LinkAction *getAction() { return action; }
1240 1241 1242
  Dict *getAdditionActions() { return additionActions; }
  Dict *getParent() { return parent; }

1243
private:
1244

1245
  void initialize(PDFDoc *docA, Dict *dict);
1246

1247
  void drawText(GooString *text, GooString *da, GfxResources *resources,
1248 1249 1250
		GBool multiline, int comb, int quadding,
		GBool txField, GBool forceZapfDingbats,
		GBool password=false);
1251
  void drawListBox(FormFieldChoice *fieldChoice,
1252
		   GooString *da, GfxResources *resources, int quadding);
1253 1254

  Form *form;
1255
  FormField *field;                       // FormField object for this annotation
1256 1257
  AnnotWidgetHighlightMode mode;          // H  (Default I)
  AnnotAppearanceCharacs *appearCharacs;  // MK
1258
  LinkAction *action;                     // A
1259 1260 1261 1262
  Dict *additionActions;                  // AA
  // inherited  from Annot
  // AnnotBorderBS border;                // BS
  Dict *parent;                           // Parent
1263
  GBool addDingbatsResource;
1264 1265
};

1266 1267 1268 1269 1270 1271 1272 1273 1274 1275 1276 1277 1278 1279 1280 1281 1282 1283 1284 1285 1286 1287 1288 1289 1290 1291 1292 1293 1294 1295 1296 1297 1298 1299 1300 1301 1302 1303 1304 1305 1306 1307 1308 1309 1310 1311
//------------------------------------------------------------------------
// Annot3D
//------------------------------------------------------------------------

class Annot3D: public Annot {
  class Activation {
  public:
    enum ActivationATrigger {
      aTriggerUnknown,
      aTriggerPageOpened,  // PO
      aTriggerPageVisible, // PV
      aTriggerUserAction   // XA
    };

    enum ActivationAState {
      aStateUnknown,
      aStateEnabled, // I
      aStateDisabled // L
    };

    enum ActivationDTrigger {
      dTriggerUnknown,
      dTriggerPageClosed,    // PC
      dTriggerPageInvisible, // PI
      dTriggerUserAction     // XD
    };

    enum ActivationDState {
      dStateUnknown,
      dStateUninstantiaded, // U
      dStateInstantiated,   // I
      dStateLive            // L
    };

    Activation(Dict *dict);
  private:
    
    ActivationATrigger aTrigger;  // A   (Default XA)
    ActivationAState aState;      // AIS (Default L)
    ActivationDTrigger dTrigger;  // D   (Default PI)
    ActivationDState dState;      // DIS (Default U)
    GBool displayToolbar;         // TB  (Default true)
    GBool displayNavigation;      // NP  (Default false);
  };
public:

1312 1313
  Annot3D(PDFDoc *docA, PDFRectangle *rect);
  Annot3D(PDFDoc *docA, Dict *dict, Object *obj);
1314 1315 1316 1317 1318 1319
  ~Annot3D();

  // getters

private:

1320
  void initialize(PDFDoc *docA, Dict *dict);
1321 1322 1323 1324

  Activation *activation;  // 3DA
};

Kristian Høgsberg's avatar
Kristian Høgsberg committed
1325 1326 1327 1328 1329 1330 1331
//------------------------------------------------------------------------
// Annots
//------------------------------------------------------------------------

class Annots {
public:

1332
  // Build a list of Annot objects.
1333
  Annots(PDFDoc *docA, Object *annotsObj);
Kristian Høgsberg's avatar
Kristian Høgsberg committed
1334 1335