Ignore:
Timestamp:
Dec 30, 2009, 7:13:45 PM (12 years ago)
Author:
rbri
Message:

PDF plugin: Poppler library updated to version 0.12.3

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/poppler/mypoppler/poppler/Annot.cc

    r263 r277  
    1717// Copyright (C) 2007, 2008 Julien Rebetez <julienr@svn.gnome.org>
    1818// Copyright (C) 2007-2009 Albert Astals Cid <aacid@kde.org>
    19 // Copyright (C) 2007, 2008 Carlos Garcia Campos <carlosgc@gnome.org>
     19// Copyright (C) 2007-2009 Carlos Garcia Campos <carlosgc@gnome.org>
    2020// Copyright (C) 2007, 2008 Iñigo Martínez <inigomartinez@gmail.com>
    2121// Copyright (C) 2007 Jeff Muizelaar <jeff@infidigm.net>
     
    3838#include <stdlib.h>
    3939#include <math.h>
     40#include <assert.h>
    4041#include "goo/gmem.h"
     42#include "goo/gstrtod.h"
    4143#include "GooList.h"
    4244#include "Error.h"
     
    5759#include "Sound.h"
    5860#include "FileSpec.h"
     61#include "DateInfo.h"
    5962#include <string.h>
    6063
     
    457460  int arrayLength = array->getLength();
    458461
    459   if (arrayLength >= 3) {
     462  GBool correct = gTrue;
     463  if (arrayLength == 3 || arrayLength == 4) {
    460464    // implementation note 81 in Appendix H.
    461465
    462466    if (array->get(0, &obj1)->isNum())
    463467      horizontalCorner = obj1.getNum();
     468    else
     469      correct = gFalse;
    464470    obj1.free();
    465471
    466472    if (array->get(1, &obj1)->isNum())
    467473      verticalCorner = obj1.getNum();
     474    else
     475      correct = gFalse;
    468476    obj1.free();
    469477
    470478    if (array->get(2, &obj1)->isNum())
    471479      width = obj1.getNum();
     480    else
     481      correct = gFalse;
    472482    obj1.free();
    473483
    474484    // TODO: check not all zero ? (Line Dash Pattern Page 217 PDF 8.1)
    475     if (arrayLength > 3) {
    476       GBool correct = gTrue;
    477       int tempLength = array->getLength() - 3;
    478       double *tempDash = (double *) gmallocn (tempLength, sizeof (double));
    479 
    480       for(int i = 0; i < tempLength && i < DASH_LIMIT && correct; i++) {
    481 
    482         if (array->get((i + 3), &obj1)->isNum()) {
    483           tempDash[i] = obj1.getNum();
    484 
    485           if (tempDash[i] < 0)
     485    if (arrayLength == 4) {
     486      if (array->get(3, &obj1)->isArray()) {
     487        Array *dashPattern = obj1.getArray();
     488        int tempLength = dashPattern->getLength();
     489        double *tempDash = (double *) gmallocn (tempLength, sizeof (double));
     490
     491        for(int i = 0; i < tempLength && i < DASH_LIMIT && correct; i++) {
     492
     493          if (dashPattern->get(i, &obj1)->isNum()) {
     494            tempDash[i] = obj1.getNum();
     495
     496            if (tempDash[i] < 0)
     497              correct = gFalse;
     498
     499          } else {
    486500            correct = gFalse;
    487 
     501          }
     502          obj1.free();
     503        }
     504
     505        if (correct) {
     506          dashLength = tempLength;
     507          dash = tempDash;
     508          style = borderDashed;
    488509        } else {
    489           correct = gFalse;
     510          gfree (tempDash);
    490511        }
    491         obj1.free();
    492       }
    493 
    494       if (correct) {
    495         dashLength = tempLength;
    496         dash = tempDash;
    497         style = borderDashed;
    498512      } else {
    499         gfree (tempDash);
    500       }
    501     }
     513        correct = gFalse;
     514      }
     515      obj1.free();
     516    }
     517  } else {
     518    correct = gFalse;
     519  }
     520 
     521  if (!correct) {
     522    width = 0;
    502523  }
    503524}
     
    594615}
    595616
     617AnnotColor::AnnotColor(double gray) {
     618  length = 1;
     619  values = (double *) gmallocn (length, sizeof(double));
     620
     621  values[0] = gray;
     622}
     623
     624AnnotColor::AnnotColor(double r, double g, double b) {
     625  length = 3;
     626  values = (double *) gmallocn (length, sizeof(double));
     627
     628  values[0] = r;
     629  values[1] = g;
     630  values[2] = b;
     631}
     632
     633AnnotColor::AnnotColor(double c, double m, double y, double k) {
     634  length = 4;
     635  values = (double *) gmallocn (length, sizeof(double));
     636
     637  values[0] = c;
     638  values[1] = m;
     639  values[2] = y;
     640  values[3] = k;
     641}
     642
    596643AnnotColor::AnnotColor(Array *array) {
    597644  // TODO: check what Acrobat does in the case of having more than 5 numbers.
     
    613660      obj1.free();
    614661    }
     662  } else {
     663    values = NULL;
     664    length = 0;
    615665  }
    616666}
     
    796846//------------------------------------------------------------------------
    797847
     848Annot::Annot(XRef *xrefA, PDFRectangle *rectA, Catalog *catalog) {
     849  Object obj1;
     850
     851  flags = flagUnknown;
     852  type = typeUnknown;
     853
     854  obj1.initArray (xrefA);
     855  Object obj2;
     856  obj1.arrayAdd (obj2.initReal (rectA->x1));
     857  obj1.arrayAdd (obj2.initReal (rectA->y1));
     858  obj1.arrayAdd (obj2.initReal (rectA->x2));
     859  obj1.arrayAdd (obj2.initReal (rectA->y2));
     860  obj2.free ();
     861
     862  annotObj.initDict (xrefA);
     863  annotObj.dictSet ("Type", obj2.initName ("Annot"));
     864  annotObj.dictSet ("Rect", &obj1);
     865  // obj1 is owned by the dict
     866
     867  ref = xrefA->addIndirectObject (&annotObj);
     868
     869  initialize (xrefA, annotObj.getDict(), catalog);
     870}
     871
    798872Annot::Annot(XRef *xrefA, Dict *dict, Catalog* catalog) {
    799873  hasRef = false;
    800874  flags = flagUnknown;
    801875  type = typeUnknown;
     876  annotObj.initDict (dict);
    802877  initialize (xrefA, dict, catalog);
    803878}
     
    812887  flags = flagUnknown;
    813888  type = typeUnknown;
     889  annotObj.initDict (dict);
    814890  initialize (xrefA, dict, catalog);
    815891}
     
    9671043}
    9681044
     1045void Annot::update(const char *key, Object *value) {
     1046  /* Set M to current time */
     1047  delete modified;
     1048  modified = timeToDateString(NULL);
     1049
     1050  Object obj1;
     1051  obj1.initString (modified->copy());
     1052  annotObj.dictSet("M", &obj1);
     1053
     1054  annotObj.dictSet(const_cast<char*>(key), value);
     1055 
     1056  xref->setModifiedObject(&annotObj, ref);
     1057}
     1058
     1059void Annot::setContents(GooString *new_content) {
     1060  delete contents;
     1061
     1062  if (new_content) {
     1063    contents = new GooString(new_content);
     1064    //append the unicode marker <FE FF> if needed       
     1065    if (!contents->hasUnicodeMarker()) {
     1066      contents->insert(0, 0xff);
     1067      contents->insert(0, 0xfe);
     1068    }
     1069  } else {
     1070    contents = new GooString();
     1071  }
     1072 
     1073  Object obj1;
     1074  obj1.initString(contents->copy());
     1075  update ("Contents", &obj1);
     1076}
     1077
     1078void Annot::setColor(AnnotColor *new_color) {
     1079  delete color;
     1080
     1081  if (new_color) {
     1082    Object obj1, obj2;
     1083    double *values = new_color->getValues();
     1084
     1085    obj1.initArray(xref);
     1086    for (int i = 0; i < (int)new_color->getSpace(); i++)
     1087      obj1.arrayAdd(obj2.initReal (values[i]));
     1088    update ("C", &obj1);
     1089    color = new_color;
     1090  } else {
     1091    color = NULL;
     1092  }
     1093}
     1094
    9691095double Annot::getXMin() {
    9701096  return rect->x1;
     
    9891115
    9901116Annot::~Annot() {
     1117  annotObj.free();
     1118 
    9911119  delete rect;
    992 
     1120 
    9931121  if (contents)
    9941122    delete contents;
     
    11661294//------------------------------------------------------------------------
    11671295
     1296AnnotPopup::AnnotPopup(XRef *xrefA, PDFRectangle *rect, Catalog *catalog) :
     1297    Annot(xrefA, rect, catalog) {
     1298  Object obj1;
     1299
     1300  type = typePopup;
     1301
     1302  annotObj.dictSet ("Subtype", obj1.initName ("Popup"));
     1303  initialize (xrefA, annotObj.getDict(), catalog);
     1304}
     1305
    11681306AnnotPopup::AnnotPopup(XRef *xrefA, Dict *dict, Catalog *catalog, Object *obj) :
    11691307    Annot(xrefA, dict, catalog, obj) {
     
    11731311
    11741312AnnotPopup::~AnnotPopup() {
    1175   /*
    1176   if (parent)
    1177     delete parent;
    1178   */
     1313  parent.free();
    11791314}
    11801315
    11811316void AnnotPopup::initialize(XRef *xrefA, Dict *dict, Catalog *catalog) {
    11821317  Object obj1;
    1183   /*
    1184   if (dict->lookup("Parent", &obj1)->isDict()) {
    1185     parent = NULL;
    1186   } else {
    1187     parent = NULL;
    1188   }
    1189   obj1.free();
    1190   */
     1318
     1319  if (!dict->lookupNF("Parent", &parent)->isRef()) {
     1320    parent.initNull();
     1321  }
     1322
    11911323  if (dict->lookup("Open", &obj1)->isBool()) {
    11921324    open = obj1.getBool();
     
    11971329}
    11981330
     1331void AnnotPopup::setParent(Object *parentA) {
     1332  parentA->copy(&parent);
     1333  update ("Parent", &parent);
     1334}
     1335
     1336void AnnotPopup::setParent(Annot *parentA) {
     1337  Ref parentRef = parentA->getRef();
     1338  parent.initRef(parentRef.num, parentRef.gen);
     1339  update ("Parent", &parent);
     1340}
     1341
     1342void AnnotPopup::setOpen(GBool openA) {
     1343  Object obj1;
     1344
     1345  open = openA;
     1346  obj1.initBool(open);
     1347  update ("Open", &obj1);
     1348}
     1349
    11991350//------------------------------------------------------------------------
    12001351// AnnotMarkup
    12011352//------------------------------------------------------------------------
    1202  
     1353AnnotMarkup::AnnotMarkup(XRef *xrefA, PDFRectangle *rect, Catalog *catalog) :
     1354    Annot(xrefA, rect, catalog) {
     1355  initialize(xrefA, annotObj.getDict(), catalog, &annotObj);
     1356}
     1357
    12031358AnnotMarkup::AnnotMarkup(XRef *xrefA, Dict *dict, Catalog *catalog, Object *obj) :
    12041359    Annot(xrefA, dict, catalog, obj) {
     
    12901445}
    12911446
     1447void AnnotMarkup::setLabel(GooString *new_label) {
     1448  delete label;
     1449
     1450  if (new_label) {
     1451    label = new GooString(new_label);
     1452    //append the unicode marker <FE FF> if needed
     1453    if (!label->hasUnicodeMarker()) {
     1454      label->insert(0, 0xff);
     1455      label->insert(0, 0xfe);
     1456    }
     1457  } else {
     1458    label = new GooString();
     1459  }
     1460
     1461  Object obj1;
     1462  obj1.initString(label->copy());
     1463  update ("T", &obj1);
     1464}
     1465
     1466void AnnotMarkup::setPopup(AnnotPopup *new_popup) {
     1467  delete popup;
     1468
     1469  if (new_popup) {
     1470    Object obj1;
     1471    Ref popupRef = new_popup->getRef();
     1472
     1473    obj1.initRef (popupRef.num, popupRef.gen);
     1474    update ("Popup", &obj1);
     1475
     1476    new_popup->setParent(this);
     1477    popup = new_popup;
     1478  } else {
     1479    popup = NULL;
     1480  }
     1481}
     1482
    12921483//------------------------------------------------------------------------
    12931484// AnnotText
    12941485//------------------------------------------------------------------------
     1486
     1487AnnotText::AnnotText(XRef *xrefA, PDFRectangle *rect, Catalog *catalog) :
     1488    AnnotMarkup(xrefA, rect, catalog) {
     1489  Object obj1;
     1490
     1491  type = typeText;
     1492  flags |= flagNoZoom | flagNoRotate;
     1493
     1494  annotObj.dictSet ("Subtype", obj1.initName ("Text"));
     1495  initialize (xrefA, catalog, annotObj.getDict());
     1496}
    12951497
    12961498AnnotText::AnnotText(XRef *xrefA, Dict *dict, Catalog *catalog, Object *obj) :
     
    13041506AnnotText::~AnnotText() {
    13051507  delete icon;
    1306 }
    1307 
    1308 void AnnotText::setModified(GooString *date) {
    1309   if (date) {
    1310     delete modified;
    1311     modified = new GooString(date);
    1312   }
    13131508}
    13141509
     
    13941589}
    13951590
     1591void AnnotText::setOpen(GBool openA) {
     1592  Object obj1;
     1593
     1594  open = openA;
     1595  obj1.initBool(open);
     1596  update ("Open", &obj1);
     1597}
     1598
     1599void AnnotText::setIcon(GooString *new_icon) {
     1600  if (new_icon && icon->cmp(new_icon) == 0)
     1601    return;
     1602
     1603  delete icon;
     1604
     1605  if (new_icon) {
     1606    icon = new GooString (new_icon);
     1607  } else {
     1608    icon = new GooString("Note");
     1609  }
     1610
     1611  Object obj1;
     1612  obj1.initName (icon->getCString());
     1613  update("Name", &obj1);
     1614}
     1615
    13961616//------------------------------------------------------------------------
    13971617// AnnotLink
    13981618//------------------------------------------------------------------------
     1619AnnotLink::AnnotLink(XRef *xrefA, PDFRectangle *rect, Catalog *catalog) :
     1620    Annot(xrefA, rect, catalog) {
     1621  Object obj1;
     1622
     1623  type = typeLink;
     1624  annotObj.dictSet ("Subtype", obj1.initName ("Link"));
     1625  initialize (xrefA, catalog, annotObj.getDict());
     1626}
    13991627
    14001628AnnotLink::AnnotLink(XRef *xrefA, Dict *dict, Catalog *catalog, Object *obj) :
     
    14851713// AnnotFreeText
    14861714//------------------------------------------------------------------------
     1715AnnotFreeText::AnnotFreeText(XRef *xrefA, PDFRectangle *rect, GooString *da, Catalog *catalog) :
     1716    AnnotMarkup(xrefA, rect, catalog) {
     1717  Object obj1;
     1718
     1719  type = typeFreeText;
     1720
     1721  annotObj.dictSet ("Subtype", obj1.initName ("FreeText"));
     1722
     1723  Object obj2;
     1724  obj2.initString (da->copy());
     1725  annotObj.dictSet("DA", &obj2);
     1726
     1727  initialize (xrefA, catalog, annotObj.getDict());
     1728}
    14871729
    14881730AnnotFreeText::AnnotFreeText(XRef *xrefA, Dict *dict, Catalog *catalog, Object *obj) :
     
    16081850//------------------------------------------------------------------------
    16091851
     1852AnnotLine::AnnotLine(XRef *xrefA, PDFRectangle *rect, PDFRectangle *lRect, Catalog *catalog) :
     1853    AnnotMarkup(xrefA, rect, catalog) {
     1854  Object obj1;
     1855
     1856  type = typeLine;
     1857  annotObj.dictSet ("Subtype", obj1.initName ("Line"));
     1858
     1859  Object obj2, obj3;
     1860  obj2.initArray (xrefA);
     1861  obj2.arrayAdd (obj3.initReal (lRect->x1));
     1862  obj2.arrayAdd (obj3.initReal (lRect->y1));
     1863  obj2.arrayAdd (obj3.initReal (lRect->x2));
     1864  obj2.arrayAdd (obj3.initReal (lRect->y2));
     1865  annotObj.dictSet ("L", &obj2);
     1866
     1867  initialize (xrefA, catalog, annotObj.getDict());
     1868}
     1869
    16101870AnnotLine::AnnotLine(XRef *xrefA, Dict *dict, Catalog *catalog, Object *obj) :
    16111871    AnnotMarkup(xrefA, dict, catalog, obj) {
     
    17672027// AnnotTextMarkup
    17682028//------------------------------------------------------------------------
     2029AnnotTextMarkup::AnnotTextMarkup(XRef *xrefA, PDFRectangle *rect, AnnotSubtype subType,
     2030                                 AnnotQuadrilaterals *quadPoints, Catalog *catalog) :
     2031    AnnotMarkup(xrefA, rect, catalog) {
     2032  Object obj1;
     2033
     2034  switch (subType) {
     2035    case typeHighlight:
     2036      annotObj.dictSet ("Subtype", obj1.initName ("Highlight"));
     2037      break;
     2038    case typeUnderline:
     2039      annotObj.dictSet ("Subtype", obj1.initName ("Underline"));
     2040      break;
     2041    case typeSquiggly:
     2042      annotObj.dictSet ("Subtype", obj1.initName ("Squiggly"));
     2043      break;
     2044    case typeStrikeOut:
     2045      annotObj.dictSet ("Subtype", obj1.initName ("StrikeOut"));
     2046      break;
     2047    default:
     2048      assert (0 && "Invalid subtype for AnnotTextMarkup\n");
     2049  }
     2050
     2051  Object obj2;
     2052  obj2.initArray (xrefA);
     2053
     2054  for (int i = 0; i < quadPoints->getQuadrilateralsLength(); ++i) {
     2055    Object obj3;
     2056
     2057    obj2.arrayAdd (obj3.initReal (quadPoints->getX1(i)));
     2058    obj2.arrayAdd (obj3.initReal (quadPoints->getY1(i)));
     2059    obj2.arrayAdd (obj3.initReal (quadPoints->getX2(i)));
     2060    obj2.arrayAdd (obj3.initReal (quadPoints->getY2(i)));
     2061    obj2.arrayAdd (obj3.initReal (quadPoints->getX3(i)));
     2062    obj2.arrayAdd (obj3.initReal (quadPoints->getY3(i)));
     2063    obj2.arrayAdd (obj3.initReal (quadPoints->getX4(i)));
     2064    obj2.arrayAdd (obj3.initReal (quadPoints->getY4(i)));
     2065  }
     2066
     2067  annotObj.dictSet ("QuadPoints", &obj2);
     2068
     2069  initialize(xrefA, catalog, annotObj.getDict());
     2070}
    17692071
    17702072AnnotTextMarkup::AnnotTextMarkup(XRef *xrefA, Dict *dict, Catalog *catalog, Object *obj) :
     
    19312233  double dx, dy, ox, oy;
    19322234  GBool unicode = text->hasUnicodeMarker();
    1933   CharCodeToUnicode *ccToUnicode = font->getToUnicode();
    1934   ccToUnicode->decRefCnt();
    19352235  GBool spacePrev;              // previous character was a space
    19362236
     
    19962296    if (noReencode) {
    19972297      outBuf->append(uChar);
    1998     } else if (ccToUnicode->mapToCharCode(&uChar, &c, 1)) {
    1999       if (font->isCIDFont()) {
    2000         // TODO: This assumes an identity CMap.  It should be extended to
    2001         // handle the general case.
    2002         outBuf->append((c >> 8) & 0xff);
    2003         outBuf->append(c & 0xff);
     2298    } else {
     2299      CharCodeToUnicode *ccToUnicode = font->getToUnicode();
     2300      if (!ccToUnicode) {
     2301        // This assumes an identity CMap.
     2302        outBuf->append((uChar >> 8) & 0xff);
     2303        outBuf->append(uChar & 0xff);
     2304      } else if (ccToUnicode->mapToCharCode(&uChar, &c, 1)) {
     2305        ccToUnicode->decRefCnt();
     2306        if (font->isCIDFont()) {
     2307          // TODO: This assumes an identity CMap.  It should be extended to
     2308          // handle the general case.
     2309          outBuf->append((c >> 8) & 0xff);
     2310          outBuf->append(c & 0xff);
     2311        } else {
     2312          // 8-bit font
     2313          outBuf->append(c);
     2314        }
    20042315      } else {
    2005         // 8-bit font
    2006         outBuf->append(c);
    2007       }
    2008     } else {
    2009       fprintf(stderr,
    2010               "warning: layoutText: cannot convert U+%04X\n", uChar);
     2316        ccToUnicode->decRefCnt();
     2317        fprintf(stderr,
     2318                "warning: layoutText: cannot convert U+%04X\n", uChar);
     2319      }
    20112320    }
    20122321
     
    22112520    }
    22122521    tok = (GooString *)daToks->get(tfPos + 1);
    2213     fontSize = atof(tok->getCString());
     2522    fontSize = gatof(tok->getCString());
    22142523  } else {
    22152524    error(-1, "Missing 'Tf' operator in field's DA string");
     
    25702879    }
    25712880    tok = (GooString *)daToks->get(tfPos + 1);
    2572     fontSize = atof(tok->getCString());
     2881    fontSize = gatof(tok->getCString());
    25732882  } else {
    25742883    error(-1, "Missing 'Tf' operator in field's DA string");
     
    31613470// AnnotMovie
    31623471//------------------------------------------------------------------------
    3163  
     3472AnnotMovie::AnnotMovie(XRef *xrefA, PDFRectangle *rect, Movie *movieA, Catalog *catalog) :
     3473    Annot(xrefA, rect, catalog) {
     3474  Object obj1;
     3475
     3476  type = typeMovie;
     3477  annotObj.dictSet ("Subtype", obj1.initName ("Movie"));
     3478
     3479  movie = movieA->copy();
     3480  // TODO: create movie dict from movieA
     3481
     3482  initialize(xrefA, catalog, annotObj.getDict());
     3483}
     3484
    31643485AnnotMovie::AnnotMovie(XRef *xrefA, Dict *dict, Catalog *catalog, Object *obj) :
    31653486  Annot(xrefA, dict, catalog, obj) {
     
    32163537  if (dict->lookup("Movie", &movieDict)->isDict()) {
    32173538    Object obj2;
    3218     getFileSpecNameForPlatform(movieDict.dictLookup("F", &obj1), &obj2);
    3219     fileName = obj2.getString()->copy();
    3220     obj2.free();
     3539    if (getFileSpecNameForPlatform(movieDict.dictLookup("F", &obj1), &obj2)) {
     3540      fileName = obj2.getString()->copy();
     3541      obj2.free();
     3542    }
    32213543    obj1.free();
    32223544
     
    32253547      if (aspect->getLength() >= 2) {
    32263548        Object tmp;
    3227         width = aspect->get(0, &tmp)->getInt();
     3549        if( aspect->get(0, &tmp)->isNum() ) {
     3550          width = (int)floor( aspect->get(0, &tmp)->getNum() + 0.5 );
     3551        }
    32283552        tmp.free();
    3229         height = aspect->get(1, &tmp)->getInt();
     3553        if( aspect->get(1, &tmp)->isNum() ) {
     3554          height = (int)floor( aspect->get(1, &tmp)->getNum() + 0.5 );
     3555        }
    32303556        tmp.free();
    32313557      }
     
    34263752// AnnotScreen
    34273753//------------------------------------------------------------------------
    3428  
     3754AnnotScreen::AnnotScreen(XRef *xrefA, PDFRectangle *rect, Catalog *catalog) :
     3755    Annot(xrefA, rect, catalog) {
     3756  Object obj1;
     3757
     3758  type = typeScreen;
     3759
     3760  annotObj.dictSet ("Subtype", obj1.initName ("Screen"));
     3761  initialize(xrefA, catalog, annotObj.getDict());
     3762}
     3763
    34293764AnnotScreen::AnnotScreen(XRef *xrefA, Dict *dict, Catalog *catalog, Object *obj) :
    34303765  Annot(xrefA, dict, catalog, obj) {
     
    34673802// AnnotStamp
    34683803//------------------------------------------------------------------------
    3469  
     3804AnnotStamp::AnnotStamp(XRef *xrefA, PDFRectangle *rect, Catalog *catalog) :
     3805  AnnotMarkup(xrefA, rect, catalog) {
     3806  Object obj1;
     3807
     3808  type = typeStamp;
     3809  annotObj.dictSet ("Subtype", obj1.initName ("Stamp"));
     3810  initialize(xrefA, catalog, annotObj.getDict());
     3811}
     3812
    34703813AnnotStamp::AnnotStamp(XRef *xrefA, Dict *dict, Catalog *catalog, Object *obj) :
    34713814  AnnotMarkup(xrefA, dict, catalog, obj) {
     
    34933836// AnnotGeometry
    34943837//------------------------------------------------------------------------
     3838AnnotGeometry::AnnotGeometry(XRef *xrefA, PDFRectangle *rect, AnnotSubtype subType, Catalog *catalog) :
     3839    AnnotMarkup(xrefA, rect, catalog) {
     3840  Object obj1;
     3841
     3842  switch (subType) {
     3843    case typeSquare:
     3844      annotObj.dictSet ("Subtype", obj1.initName ("Square"));
     3845      break;
     3846    case typeCircle:
     3847      annotObj.dictSet ("Subtype", obj1.initName ("Circle"));
     3848      break;
     3849    default:
     3850      assert (0 && "Invalid subtype for AnnotGeometry\n");
     3851  }
     3852
     3853  initialize(xrefA, catalog, annotObj.getDict());
     3854}
    34953855
    34963856AnnotGeometry::AnnotGeometry(XRef *xrefA, Dict *dict, Catalog *catalog, Object *obj) :
     
    35453905// AnnotPolygon
    35463906//------------------------------------------------------------------------
     3907AnnotPolygon::AnnotPolygon(XRef *xrefA, PDFRectangle *rect, AnnotSubtype subType,
     3908                           AnnotPath *path, Catalog *catalog) :
     3909    AnnotMarkup(xrefA, rect, catalog) {
     3910  Object obj1;
     3911
     3912  switch (subType) {
     3913    case typePolygon:
     3914      annotObj.dictSet ("Subtype", obj1.initName ("Polygon"));
     3915      break;
     3916    case typePolyLine:
     3917      annotObj.dictSet ("Subtype", obj1.initName ("PolyLine"));
     3918      break;
     3919    default:
     3920      assert (0 && "Invalid subtype for AnnotGeometry\n");
     3921  }
     3922
     3923  Object obj2;
     3924  obj2.initArray (xrefA);
     3925
     3926  for (int i = 0; i < path->getCoordsLength(); ++i) {
     3927    Object obj3;
     3928
     3929    obj2.arrayAdd (obj3.initReal (path->getX(i)));
     3930    obj2.arrayAdd (obj3.initReal (path->getY(i)));
     3931  }
     3932
     3933  annotObj.dictSet ("Vertices", &obj2);
     3934
     3935  initialize(xrefA, catalog, annotObj.getDict());
     3936}
    35473937
    35483938AnnotPolygon::AnnotPolygon(XRef *xrefA, Dict *dict, Catalog *catalog, Object *obj) :
     
    36394029// AnnotCaret
    36404030//------------------------------------------------------------------------
     4031AnnotCaret::AnnotCaret(XRef *xrefA, PDFRectangle *rect, Catalog *catalog) :
     4032    AnnotMarkup(xrefA, rect, catalog) {
     4033  Object obj1;
     4034
     4035  type = typeCaret;
     4036
     4037  annotObj.dictSet ("Subtype", obj1.initName ("Caret"));
     4038  initialize(xrefA, catalog, annotObj.getDict());
     4039}
    36414040
    36424041AnnotCaret::AnnotCaret(XRef *xrefA, Dict *dict, Catalog *catalog, Object *obj) :
     
    36764075// AnnotInk
    36774076//------------------------------------------------------------------------
     4077AnnotInk::AnnotInk(XRef *xrefA, PDFRectangle *rect, AnnotPath **paths, int n_paths, Catalog *catalog) :
     4078    AnnotMarkup(xrefA, rect, catalog) {
     4079  Object obj1;
     4080
     4081  type = typeInk;
     4082
     4083  annotObj.dictSet ("Subtype", obj1.initName ("Ink"));
     4084
     4085  Object obj2;
     4086  obj2.initArray (xrefA);
     4087
     4088  for (int i = 0; i < n_paths; ++i) {
     4089    AnnotPath *path = paths[i];
     4090    Object obj3;
     4091    obj3.initArray (xrefA);
     4092
     4093    for (int j = 0; j < path->getCoordsLength(); ++j) {
     4094      Object obj4;
     4095
     4096      obj3.arrayAdd (obj4.initReal (path->getX(j)));
     4097      obj3.arrayAdd (obj4.initReal (path->getY(j)));
     4098    }
     4099
     4100    obj2.arrayAdd (&obj3);
     4101  }
     4102
     4103  annotObj.dictSet ("InkList", &obj2);
     4104
     4105  initialize(xrefA, catalog, annotObj.getDict());
     4106}
    36784107
    36794108AnnotInk::AnnotInk(XRef *xrefA, Dict *dict, Catalog *catalog, Object *obj) :
     
    37174146// AnnotFileAttachment
    37184147//------------------------------------------------------------------------
     4148AnnotFileAttachment::AnnotFileAttachment(XRef *xrefA, PDFRectangle *rect, GooString *filename, Catalog *catalog) :
     4149    AnnotMarkup(xrefA, rect, catalog) {
     4150  Object obj1;
     4151
     4152  type = typeFileAttachment;
     4153
     4154  annotObj.dictSet ("Subtype", obj1.initName ("FileAttachment"));
     4155
     4156  Object obj2;
     4157  obj2.initString(filename->copy());
     4158  annotObj.dictSet ("FS", &obj2);
     4159
     4160  initialize(xrefA, catalog, annotObj.getDict());
     4161}
    37194162
    37204163AnnotFileAttachment::AnnotFileAttachment(XRef *xrefA, Dict *dict, Catalog *catalog, Object *obj) :
     
    37344177  Object obj1;
    37354178
    3736   if (dict->lookup("FS", &obj1)->isDict()) {
     4179  if (dict->lookup("FS", &obj1)->isDict() || dict->lookup("FS", &obj1)->isString()) {
    37374180    obj1.copy(&file);
    37384181  } else {
     
    37534196// AnnotSound
    37544197//------------------------------------------------------------------------
     4198AnnotSound::AnnotSound(XRef *xrefA, PDFRectangle *rect, Sound *soundA, Catalog *catalog) :
     4199    AnnotMarkup(xrefA, rect, catalog) {
     4200  Object obj1;
     4201
     4202  type = typeSound;
     4203
     4204  annotObj.dictSet ("Subtype", obj1.initName ("Sound"));
     4205
     4206  Object obj2;
     4207  Stream *str = soundA->getStream();
     4208  obj2.initStream (str);
     4209  str->incRef(); //FIXME: initStream should do this?
     4210  annotObj.dictSet ("Sound", &obj2);
     4211
     4212  initialize(xrefA, catalog, annotObj.getDict());
     4213}
    37554214
    37564215AnnotSound::AnnotSound(XRef *xrefA, Dict *dict, Catalog *catalog, Object *obj) :
     
    37874246// Annot3D
    37884247//------------------------------------------------------------------------
     4248Annot3D::Annot3D(XRef *xrefA, PDFRectangle *rect, Catalog *catalog) :
     4249    Annot(xrefA, rect, catalog) {
     4250  Object obj1;
     4251
     4252  type = type3D;
     4253
     4254  annotObj.dictSet ("Subtype", obj1.initName ("3D"));
     4255
     4256  initialize(xrefA, catalog, annotObj.getDict());
     4257}
    37894258
    37904259Annot3D::Annot3D(XRef *xrefA, Dict *dict, Catalog *catalog, Object *obj) :
     
    39924461    } else if (!typeName->cmp("3D")) {
    39934462      annot = new Annot3D(xref, dict, catalog, obj);
     4463    } else if (!typeName->cmp("Popup")) {
     4464      /* Popup annots are already handled by markup annots
     4465       * Here we only care about popup annots without a
     4466       * markup annotation associated
     4467       */
     4468      Object obj2;
     4469
     4470      if (dict->lookup("Parent", &obj2)->isNull())
     4471        annot = new AnnotPopup(xref, dict, catalog, obj);
     4472      else
     4473        annot = NULL;
     4474     
     4475      obj2.free();
    39944476    } else {
    39954477      annot = new Annot(xref, dict, catalog, obj);
Note: See TracChangeset for help on using the changeset viewer.