Ignore:
Timestamp:
Oct 19, 2008, 4:08:46 PM (13 years ago)
Author:
Eugene Romanenko
Message:

PDF plugin: Poppler library updated to version 0.10.0

File:
1 edited

Legend:

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

    r256 r257  
    44//
    55// Copyright 2000-2003 Glyph & Cog, LLC
     6//
     7//========================================================================
     8
     9//========================================================================
     10//
     11// Modified under the Poppler project - http://poppler.freedesktop.org
     12//
     13// All changes made under the Poppler project to this file are licensed
     14// under GPL version 2 or later
     15//
     16// Copyright (C) 2006 Scott Turner <scotty1024@mac.com>
     17// Copyright (C) 2007, 2008 Julien Rebetez <julienr@svn.gnome.org>
     18// Copyright (C) 2007, 2008 Albert Astals Cid <aacid@kde.org>
     19// Copyright (C) 2007, 2008 Carlos Garcia Campos <carlosgc@gnome.org>
     20// Copyright (C) 2007, 2008 Iñigo Martínez <inigomartinez@gmail.com>
     21// Copyright (C) 2007 Jeff Muizelaar <jeff@infidigm.net>
     22// Copyright (C) 2008 Pino Toscano <pino@kde.org>
     23// Copyright (C) 2008 Michael Vrable <mvrable@cs.ucsd.edu>
     24// Copyright (C) 2008 Hugo Mercier <hmercier31@gmail.com>
     25//
     26// To see a description of the changes please see the Changelog file that
     27// came with your tarball or type make ChangeLog if you are building from git
    628//
    729//========================================================================
     
    3153#include "XRef.h"
    3254#include "Movie.h"
     55#include "OptionalContent.h"
     56#include "Sound.h"
     57#include "FileSpec.h"
    3358#include <string.h>
    3459
     
    93118}
    94119
    95 AnnotExternalDataType parseAnnotExternalData(Dict* dict) {
     120static AnnotExternalDataType parseAnnotExternalData(Dict* dict) {
    96121  Object obj1;
    97122  AnnotExternalDataType type;
     
    112137
    113138  return type;
     139}
     140
     141PDFRectangle *parseDiffRectangle(Array *array, PDFRectangle *rect) {
     142  PDFRectangle *newRect = NULL;
     143  if (array->getLength() == 4) {
     144    // deltas
     145    Object obj1;
     146    double dx1 = (array->get(0, &obj1)->isNum() ? obj1.getNum() : 0);
     147    obj1.free();
     148    double dy1 = (array->get(1, &obj1)->isNum() ? obj1.getNum() : 0);
     149    obj1.free();
     150    double dx2 = (array->get(2, &obj1)->isNum() ? obj1.getNum() : 0);
     151    obj1.free();
     152    double dy2 = (array->get(3, &obj1)->isNum() ? obj1.getNum() : 0);
     153    obj1.free();
     154
     155    // checking that the numbers are valid (i.e. >= 0),
     156    // and that applying the differences still give us a valid rect
     157    if (dx1 >= 0 && dy1 >= 0 && dx2 >= 0 && dy2
     158        && (rect->x2 - rect->x1 - dx1 - dx2) >= 0
     159        && (rect->y2 - rect->y1 - dy1 - dy2) >= 0) {
     160      newRect = new PDFRectangle();
     161      newRect->x1 = rect->x1 + dx1;
     162      newRect->y1 = rect->y1 + dy1;
     163      newRect->x2 = rect->x2 - dx2;
     164      newRect->y2 = rect->y2 - dy2;
     165    }
     166  }
     167  return newRect;
    114168}
    115169
     
    143197
    144198//------------------------------------------------------------------------
     199// AnnotPath
     200//------------------------------------------------------------------------
     201
     202AnnotPath::AnnotPath() {
     203  coords = NULL;
     204  coordsLength = 0;
     205}
     206
     207AnnotPath::AnnotPath(Array *array) {
     208  coords = NULL;
     209  coordsLength = 0;
     210  parsePathArray(array);
     211}
     212
     213AnnotPath::AnnotPath(AnnotCoord **coords, int coordsLength) {
     214  this->coords = coords;
     215  this->coordsLength = coordsLength;
     216}
     217
     218AnnotPath::~AnnotPath() {
     219  if (coords) {
     220    for (int i = 0; i < coordsLength; ++i)
     221      delete coords[i];
     222    gfree(coords);
     223  }
     224}
     225
     226double AnnotPath::getX(int coord) const {
     227  if (coord >= 0 && coord < coordsLength)
     228    return coords[coord]->getX();
     229  return 0;
     230}
     231
     232double AnnotPath::getY(int coord) const {
     233  if (coord >= 0 && coord < coordsLength)
     234    return coords[coord]->getY();
     235  return 0;
     236}
     237
     238AnnotCoord *AnnotPath::getCoord(int coord) const {
     239  if (coord >= 0 && coord < coordsLength)
     240    return coords[coord];
     241  return NULL;
     242}
     243
     244void AnnotPath::parsePathArray(Array *array) {
     245  int tempLength;
     246  AnnotCoord **tempCoords;
     247  GBool correct = gTrue;
     248
     249  if (array->getLength() % 2) {
     250    error(-1, "Bad Annot Path");
     251    return;
     252  }
     253
     254  tempLength = array->getLength() / 2;
     255  tempCoords = (AnnotCoord **) gmallocn (tempLength, sizeof(AnnotCoord *));
     256  memset(tempCoords, 0, tempLength * sizeof(AnnotCoord *));
     257  for (int i = 0; i < tempLength && correct; i++) {
     258    Object obj1;
     259    double x = 0, y = 0;
     260
     261    if (array->get(i * 2, &obj1)->isNum()) {
     262      x = obj1.getNum();
     263    } else {
     264      correct = gFalse;
     265    }
     266    obj1.free();
     267
     268    if (array->get((i * 2) + 1, &obj1)->isNum()) {
     269      y = obj1.getNum();
     270    } else {
     271      correct = gFalse;
     272    }
     273    obj1.free();
     274
     275    if (!correct) {
     276      for (int j = i - 1; j >= 0; j--)
     277        delete tempCoords[j];
     278      gfree (tempCoords);
     279      return;
     280    }
     281
     282    tempCoords[i] = new AnnotCoord(x, y);
     283  }
     284
     285  coords = tempCoords;
     286  coordsLength = tempLength;
     287}
     288
     289//------------------------------------------------------------------------
    145290// AnnotCalloutLine
    146291//------------------------------------------------------------------------
    147292
    148 AnnotCalloutLine::AnnotCalloutLine(double x1, double y1, double x2, double y2) {
    149   this->x1 = x1;
    150   this->y1 = y1;
    151   this->x2 = x2;
    152   this->y2 = y2;
     293AnnotCalloutLine::AnnotCalloutLine(double x1, double y1, double x2, double y2)
     294    :  coord1(x1, y1), coord2(x2, y2) {
    153295}
    154296
     
    158300
    159301AnnotCalloutMultiLine::AnnotCalloutMultiLine(double x1, double y1, double x2,
    160     double y2, double x3, double y3) : AnnotCalloutLine(x1, y1, x2, y2) {
    161   this->x3 = x3;
    162   this->y3 = y3;
     302                                             double y2, double x3, double y3)
     303    : AnnotCalloutLine(x1, y1, x2, y2), coord3(x3, y3) {
    163304}
    164305
     
    234375double AnnotQuadrilaterals::getX1(int quadrilateral) {
    235376  if (quadrilateral >= 0  && quadrilateral < quadrilateralsLength)
    236     return quadrilaterals[quadrilateral]->x1;
     377    return quadrilaterals[quadrilateral]->coord1.getX();
    237378  return 0;
    238379}
     
    240381double AnnotQuadrilaterals::getY1(int quadrilateral) {
    241382  if (quadrilateral >= 0  && quadrilateral < quadrilateralsLength)
    242     return quadrilaterals[quadrilateral]->y1;
     383    return quadrilaterals[quadrilateral]->coord1.getY();
    243384  return 0;
    244385}
     
    246387double AnnotQuadrilaterals::getX2(int quadrilateral) {
    247388  if (quadrilateral >= 0  && quadrilateral < quadrilateralsLength)
    248     return quadrilaterals[quadrilateral]->x2;
     389    return quadrilaterals[quadrilateral]->coord2.getX();
    249390  return 0;
    250391}
     
    252393double AnnotQuadrilaterals::getY2(int quadrilateral) {
    253394  if (quadrilateral >= 0  && quadrilateral < quadrilateralsLength)
    254     return quadrilaterals[quadrilateral]->y2;
     395    return quadrilaterals[quadrilateral]->coord2.getY();
    255396  return 0;
    256397}
     
    258399double AnnotQuadrilaterals::getX3(int quadrilateral) {
    259400  if (quadrilateral >= 0  && quadrilateral < quadrilateralsLength)
    260     return quadrilaterals[quadrilateral]->x3;
     401    return quadrilaterals[quadrilateral]->coord3.getX();
    261402  return 0;
    262403}
     
    264405double AnnotQuadrilaterals::getY3(int quadrilateral) {
    265406  if (quadrilateral >= 0  && quadrilateral < quadrilateralsLength)
    266     return quadrilaterals[quadrilateral]->y3;
     407    return quadrilaterals[quadrilateral]->coord3.getY();
    267408  return 0;
    268409}
     
    270411double AnnotQuadrilaterals::getX4(int quadrilateral) {
    271412  if (quadrilateral >= 0  && quadrilateral < quadrilateralsLength)
    272     return quadrilaterals[quadrilateral]->x4;
     413    return quadrilaterals[quadrilateral]->coord4.getX();
    273414  return 0;
    274415}
     
    276417double AnnotQuadrilaterals::getY4(int quadrilateral) {
    277418  if (quadrilateral >= 0  && quadrilateral < quadrilateralsLength)
    278     return quadrilaterals[quadrilateral]->y4;
     419    return quadrilaterals[quadrilateral]->coord4.getY();
    279420  return 0;
    280421}
    281422
    282423AnnotQuadrilaterals::AnnotQuadrilateral::AnnotQuadrilateral(double x1, double y1,
    283         double x2, double y2, double x3, double y3, double x4, double y4) {
    284   this->x1 = x1;
    285   this->y1 = y1;
    286   this->x2 = x2;
    287   this->y2 = y2;
    288   this->x3 = x3;
    289   this->y3 = y3;
    290   this->x4 = x4;
    291   this->y4 = y4;
    292 }
    293 
    294 //------------------------------------------------------------------------
    295 // AnnotQuadPoints
    296 //------------------------------------------------------------------------
    297 
    298 AnnotQuadPoints::AnnotQuadPoints(double x1, double y1, double x2, double y2,
    299     double x3, double y3, double x4, double y4) {
    300   this->x1 = x1;
    301   this->y1 = y1;
    302   this->x2 = x2;
    303   this->y2 = y2;
    304   this->x3 = x3;
    305   this->y3 = y3;
    306   this->x4 = x4;
    307   this->y4 = y4;
     424    double x2, double y2, double x3, double y3, double x4, double y4)
     425    : coord1(x1, y1), coord2(x2, y2), coord3(x3, y3), coord4(x4, y4) {
    308426}
    309427
     
    697815
    698816void Annot::initialize(XRef *xrefA, Dict *dict, Catalog *catalog) {
    699   Object apObj, asObj, obj1, obj2, obj3;
     817  Object asObj, obj1, obj2, obj3;
    700818
    701819  appRef.num = 0;
     
    840958  }
    841959  obj1.free();
    842 
    843   /* TODO: optional content should be parsed */
    844   optionalContent = NULL;
    845960 
    846   /*if (dict->lookup("OC", &obj1)->isDict()) {
     961  if (dict->lookup("OC", &obj1)->isDict()) {
     962    optionalContent = new OCGs(&obj1, xrefA);
     963  } else {
    847964    optionalContent = NULL;
    848   } else {
    849     optionalContent = NULL;
    850   }
    851   obj1.free();
    852   */
     965  }
     966  obj1.free();
    853967}
    854968
     
    10971211    delete date;
    10981212
    1099   if (inReplyTo)
    1100     delete inReplyTo;
    1101 
    11021213  if (subject)
    11031214    delete subject;
     
    11351246  obj1.free();
    11361247
    1137   if (dict->lookup("IRT", &obj1)->isDict()) {
    1138     inReplyTo = new Dict(obj1.getDict());
    1139   } else {
    1140     inReplyTo = NULL;
     1248  if (dict->lookupNF("IRT", &obj1)->isRef()) {
     1249    inReplyTo = obj1.getRef();
     1250  } else {
     1251    inReplyTo.num = 0;
     1252    inReplyTo.gen = 0;
    11411253  }
    11421254  obj1.free();
     
    11851297}
    11861298
     1299AnnotText::~AnnotText() {
     1300  delete icon;
     1301}
     1302
    11871303void AnnotText::setModified(GooString *date) {
    11881304  if (date) {
     
    12021318
    12031319  if (dict->lookup("Name", &obj1)->isName()) {
    1204     GooString *iconName = new GooString(obj1.getName());
    1205 
    1206     if (!iconName->cmp("Comment")) {
    1207       icon = iconComment;
    1208     } else if (!iconName->cmp("Key")) {
    1209       icon = iconKey;
    1210     } else if (!iconName->cmp("Help")) {
    1211       icon = iconHelp;
    1212     } else if (!iconName->cmp("NewParagraph")) {
    1213       icon = iconNewParagraph;
    1214     } else if (!iconName->cmp("Paragraph")) {
    1215       icon = iconParagraph;
    1216     } else if (!iconName->cmp("Insert")) {
    1217       icon = iconInsert;
    1218     } else {
    1219       icon = iconNote;
    1220     }
    1221     delete iconName;
    1222   } else {
    1223     icon = iconNote;
     1320    icon = new GooString(obj1.getName());
     1321  } else {
     1322    icon = new GooString("Note");
    12241323  }
    12251324  obj1.free();
     
    12491348        state = stateUnknown;
    12501349      }
    1251 
    12521350    } else {
    12531351      state = stateUnknown;
     
    12851383      state = stateUnknown;
    12861384    }
    1287 
    12881385  } else {
    12891386    state = stateUnknown;
     
    13071404  if (actionDict)
    13081405    delete actionDict;
    1309 
     1406  */
     1407  dest.free();
     1408  /*
    13101409  if (uriAction)
    13111410    delete uriAction;
     
    13251424  obj1.free();
    13261425  */
     1426  dict->lookup("Dest", &dest);
    13271427  if (dict->lookup("H", &obj1)->isName()) {
    13281428    GooString *effect = new GooString(obj1.getName());
     
    14821582  obj1.free();
    14831583
    1484   if (dict->lookup("RD", &obj1)->isArray() && obj1.arrayGetLength() == 4) {
    1485     Object obj2;
    1486     rectangle = new PDFRectangle();
    1487 
    1488     (obj1.arrayGet(0, &obj2)->isNum() ? rectangle->x1 = obj2.getNum() :
    1489       rectangle->x1 = 0);
    1490     obj2.free();
    1491     (obj1.arrayGet(1, &obj2)->isNum() ? rectangle->y1 = obj2.getNum() :
    1492       rectangle->y1 = 0);
    1493     obj2.free();
    1494     (obj1.arrayGet(2, &obj2)->isNum() ? rectangle->x2 = obj2.getNum() :
    1495       rectangle->x2 = 1);
    1496     obj2.free();
    1497     (obj1.arrayGet(3, &obj2)->isNum() ? rectangle->y2 = obj2.getNum() :
    1498       rectangle->y2 = 1);
    1499     obj2.free();
    1500 
    1501     if (rectangle->x1 > rectangle->x2) {
    1502       double t = rectangle->x1;
    1503       rectangle->x1 = rectangle->x2;
    1504       rectangle->x2 = t;
    1505     }
    1506     if (rectangle->y1 > rectangle->y2) {
    1507       double t = rectangle->y1;
    1508       rectangle->y1 = rectangle->y2;
    1509       rectangle->y2 = t;
    1510     }
    1511 
    1512     if ((rectangle->x1 + rectangle->x2) > (rect->x2 - rect->x1))
    1513       rectangle->x1 = rectangle->x2 = 0;
    1514 
    1515     if ((rectangle->y1 + rectangle->y2) > (rect->y2 - rect->y1))
    1516       rectangle->y1 = rectangle->y2 = 0;
     1584  if (dict->lookup("RD", &obj1)->isArray()) {
     1585    rectangle = parseDiffRectangle(obj1.getArray(), rect);
    15171586  } else {
    15181587    rectangle = NULL;
     
    15411610
    15421611AnnotLine::~AnnotLine() {
     1612  delete coord1;
     1613  delete coord2;
     1614
    15431615  if (interiorColor)
    15441616    delete interiorColor;
     
    15531625  if (dict->lookup("L", &obj1)->isArray() && obj1.arrayGetLength() == 4) {
    15541626    Object obj2;
     1627    double x1, y1, x2, y2;
    15551628
    15561629    (obj1.arrayGet(0, &obj2)->isNum() ? x1 = obj2.getNum() : x1 = 0);
     
    15631636    obj2.free();
    15641637
    1565   } else {
    1566     x1 = y1 = x2 = y2 = 0;
     1638    coord1 = new AnnotCoord(x1, y1);
     1639    coord2 = new AnnotCoord(x2, y2);
     1640  } else {
     1641    coord1 = new AnnotCoord();
     1642    coord2 = new AnnotCoord();
    15671643  }
    15681644  obj1.free();
     
    16871763//------------------------------------------------------------------------
    16881764
     1765AnnotTextMarkup::AnnotTextMarkup(XRef *xrefA, Dict *dict, Catalog *catalog, Object *obj) :
     1766  AnnotMarkup(xrefA, dict, catalog, obj) {
     1767  // the real type will be read in initialize()
     1768  type = typeHighlight;
     1769  initialize(xrefA, catalog, dict);
     1770}
     1771
    16891772void AnnotTextMarkup::initialize(XRef *xrefA, Catalog *catalog, Dict *dict) {
    16901773  Object obj1;
     1774
     1775  if (dict->lookup("Subtype", &obj1)->isName()) {
     1776    GooString typeName(obj1.getName());
     1777    if (!typeName.cmp("Highlight")) {
     1778      type = typeHighlight;
     1779    } else if (!typeName.cmp("Underline")) {
     1780      type = typeUnderline;
     1781    } else if (!typeName.cmp("Squiggly")) {
     1782      type = typeSquiggly;
     1783    } else if (!typeName.cmp("StrikeOut")) {
     1784      type = typeStrikeOut;
     1785    }
     1786  }
     1787  obj1.free();
    16911788
    16921789  if(dict->lookup("QuadPoints", &obj1)->isArray()) {
     
    17321829  Object obj1;
    17331830
    1734   form = catalog->getForm ();
    1735   widget = form->findWidgetByRef (ref);
    1736 
    1737   // check if field apperances need to be regenerated
    1738   // Only text or choice fields needs to have appearance regenerated
    1739   // see section 8.6.2 "Variable Text" of PDFReference
    1740   regen = gFalse;
    1741   if (widget != NULL && (widget->getType () == formText || widget->getType () == formChoice)) {
    1742     regen = form->getNeedAppearances ();
     1831  if ((form = catalog->getForm ())) {
     1832    widget = form->findWidgetByRef (ref);
     1833
     1834    // check if field apperances need to be regenerated
     1835    // Only text or choice fields needs to have appearance regenerated
     1836    // see section 8.6.2 "Variable Text" of PDFReference
     1837    regen = gFalse;
     1838    if (widget != NULL && (widget->getType () == formText || widget->getType () == formChoice)) {
     1839      regen = form->getNeedAppearances ();
     1840    }
    17431841  }
    17441842
     
    30643162
    30653163  if (dict->lookup("Movie", &movieDict)->isDict()) {
    3066     if (movieDict.dictLookup("F", &obj1)->isString()) {
    3067       fileName = obj1.getString()->copy();
    3068     }
     3164    Object obj2;
     3165    getFileSpecNameForPlatform(movieDict.dictLookup("F", &obj1), &obj2);
     3166    fileName = obj2.getString()->copy();
     3167    obj2.free();
    30693168    obj1.free();
    30703169
     
    33073406  obj1.free();
    33083407
     3408}
     3409
     3410//------------------------------------------------------------------------
     3411// AnnotStamp
     3412//------------------------------------------------------------------------
     3413 
     3414AnnotStamp::AnnotStamp(XRef *xrefA, Dict *dict, Catalog *catalog, Object *obj) :
     3415  AnnotMarkup(xrefA, dict, catalog, obj) {
     3416  type = typeStamp;
     3417  initialize(xrefA, catalog, dict);
     3418}
     3419
     3420AnnotStamp::~AnnotStamp() {
     3421  delete icon;
     3422}
     3423
     3424void AnnotStamp::initialize(XRef *xrefA, Catalog *catalog, Dict* dict) {
     3425  Object obj1;
     3426
     3427  if (dict->lookup("Name", &obj1)->isName()) {
     3428    icon = new GooString(obj1.getName());
     3429  } else {
     3430    icon = new GooString("Draft");
     3431  }
     3432  obj1.free();
     3433
     3434}
     3435
     3436//------------------------------------------------------------------------
     3437// AnnotGeometry
     3438//------------------------------------------------------------------------
     3439
     3440AnnotGeometry::AnnotGeometry(XRef *xrefA, Dict *dict, Catalog *catalog, Object *obj) :
     3441  AnnotMarkup(xrefA, dict, catalog, obj) {
     3442  // the real type will be read in initialize()
     3443  type = typeSquare;
     3444  initialize(xrefA, catalog, dict);
     3445}
     3446
     3447AnnotGeometry::~AnnotGeometry() {
     3448  delete interiorColor;
     3449  delete borderEffect;
     3450  delete geometryRect;
     3451}
     3452
     3453void AnnotGeometry::initialize(XRef *xrefA, Catalog *catalog, Dict* dict) {
     3454  Object obj1;
     3455
     3456  if (dict->lookup("Subtype", &obj1)->isName()) {
     3457    GooString typeName(obj1.getName());
     3458    if (!typeName.cmp("Square")) {
     3459      type = typeSquare;
     3460    } else if (!typeName.cmp("Circle")) {
     3461      type = typeCircle;
     3462    }
     3463  }
     3464  obj1.free();
     3465
     3466  if (dict->lookup("IC", &obj1)->isArray()) {
     3467    interiorColor = new AnnotColor(obj1.getArray());
     3468  } else {
     3469    interiorColor = NULL;
     3470  }
     3471  obj1.free();
     3472
     3473  if (dict->lookup("BE", &obj1)->isDict()) {
     3474    borderEffect = new AnnotBorderEffect(obj1.getDict());
     3475  } else {
     3476    borderEffect = NULL;
     3477  }
     3478  obj1.free();
     3479
     3480  geometryRect = NULL;
     3481  if (dict->lookup("RD", &obj1)->isArray()) {
     3482    geometryRect = parseDiffRectangle(obj1.getArray(), rect);
     3483  }
     3484  obj1.free();
     3485
     3486}
     3487
     3488//------------------------------------------------------------------------
     3489// AnnotPolygon
     3490//------------------------------------------------------------------------
     3491
     3492AnnotPolygon::AnnotPolygon(XRef *xrefA, Dict *dict, Catalog *catalog, Object *obj) :
     3493  AnnotMarkup(xrefA, dict, catalog, obj) {
     3494  // the real type will be read in initialize()
     3495  type = typePolygon;
     3496  initialize(xrefA, catalog, dict);
     3497}
     3498
     3499AnnotPolygon::~AnnotPolygon() {
     3500  delete vertices;
     3501
     3502  if (interiorColor)
     3503    delete interiorColor;
     3504
     3505  if (borderEffect)
     3506    delete borderEffect;
     3507}
     3508
     3509void AnnotPolygon::initialize(XRef *xrefA, Catalog *catalog, Dict* dict) {
     3510  Object obj1;
     3511
     3512  if (dict->lookup("Subtype", &obj1)->isName()) {
     3513    GooString typeName(obj1.getName());
     3514    if (!typeName.cmp("Polygon")) {
     3515      type = typePolygon;
     3516    } else if (!typeName.cmp("PolyLine")) {
     3517      type = typePolyLine;
     3518    }
     3519  }
     3520  obj1.free();
     3521
     3522  if (dict->lookup("Vertices", &obj1)->isArray()) {
     3523    vertices = new AnnotPath(obj1.getArray());
     3524  } else {
     3525    vertices = new AnnotPath();
     3526    error(-1, "Bad Annot Polygon Vertices");
     3527    ok = gFalse;
     3528  }
     3529  obj1.free();
     3530
     3531  if (dict->lookup("LE", &obj1)->isArray() && obj1.arrayGetLength() == 2) {
     3532    Object obj2;
     3533
     3534    if(obj1.arrayGet(0, &obj2)->isString())
     3535      startStyle = parseAnnotLineEndingStyle(obj2.getString());
     3536    else
     3537      startStyle = annotLineEndingNone;
     3538    obj2.free();
     3539
     3540    if(obj1.arrayGet(1, &obj2)->isString())
     3541      endStyle = parseAnnotLineEndingStyle(obj2.getString());
     3542    else
     3543      endStyle = annotLineEndingNone;
     3544    obj2.free();
     3545
     3546  } else {
     3547    startStyle = endStyle = annotLineEndingNone;
     3548  }
     3549  obj1.free();
     3550
     3551  if (dict->lookup("IC", &obj1)->isArray()) {
     3552    interiorColor = new AnnotColor(obj1.getArray());
     3553  } else {
     3554    interiorColor = NULL;
     3555  }
     3556  obj1.free();
     3557
     3558  if (dict->lookup("BE", &obj1)->isDict()) {
     3559    borderEffect = new AnnotBorderEffect(obj1.getDict());
     3560  } else {
     3561    borderEffect = NULL;
     3562  }
     3563  obj1.free();
     3564
     3565  if (dict->lookup("IT", &obj1)->isName()) {
     3566    GooString *intentName = new GooString(obj1.getName());
     3567
     3568    if(!intentName->cmp("PolygonCloud")) {
     3569      intent = polygonCloud;
     3570    } else if(!intentName->cmp("PolyLineDimension")) {
     3571      intent = polylineDimension;
     3572    } else {
     3573      intent = polygonDimension;
     3574    }
     3575    delete intentName;
     3576  } else {
     3577    intent = polygonCloud;
     3578  }
     3579  obj1.free();
     3580}
     3581
     3582//------------------------------------------------------------------------
     3583// AnnotCaret
     3584//------------------------------------------------------------------------
     3585
     3586AnnotCaret::AnnotCaret(XRef *xrefA, Dict *dict, Catalog *catalog, Object *obj) :
     3587  AnnotMarkup(xrefA, dict, catalog, obj) {
     3588  type = typeCaret;
     3589  initialize(xrefA, catalog, dict);
     3590}
     3591
     3592AnnotCaret::~AnnotCaret() {
     3593  delete caretRect;
     3594}
     3595
     3596void AnnotCaret::initialize(XRef *xrefA, Catalog *catalog, Dict* dict) {
     3597  Object obj1;
     3598
     3599  symbol = symbolNone;
     3600  if (dict->lookup("Sy", &obj1)->isName()) {
     3601    GooString typeName(obj1.getName());
     3602    if (!typeName.cmp("P")) {
     3603      symbol = symbolP;
     3604    } else if (!typeName.cmp("None")) {
     3605      symbol = symbolNone;
     3606    }
     3607  }
     3608  obj1.free();
     3609
     3610  if (dict->lookup("RD", &obj1)->isArray()) {
     3611    caretRect = parseDiffRectangle(obj1.getArray(), rect);
     3612  } else {
     3613    caretRect = NULL;
     3614  }
     3615  obj1.free();
     3616
     3617}
     3618
     3619//------------------------------------------------------------------------
     3620// AnnotInk
     3621//------------------------------------------------------------------------
     3622
     3623AnnotInk::AnnotInk(XRef *xrefA, Dict *dict, Catalog *catalog, Object *obj) :
     3624  AnnotMarkup(xrefA, dict, catalog, obj) {
     3625  type = typeInk;
     3626  initialize(xrefA, catalog, dict);
     3627}
     3628
     3629AnnotInk::~AnnotInk() {
     3630  if (inkList) {
     3631    for (int i = 0; i < inkListLength; ++i)
     3632      delete inkList[i];
     3633    gfree(inkList);
     3634  }
     3635}
     3636
     3637void AnnotInk::initialize(XRef *xrefA, Catalog *catalog, Dict* dict) {
     3638  Object obj1;
     3639
     3640  if (dict->lookup("InkList", &obj1)->isArray()) {
     3641    Array *array = obj1.getArray();
     3642    inkListLength = array->getLength();
     3643    inkList = (AnnotPath **) gmallocn ((inkListLength), sizeof(AnnotPath *));
     3644    memset(inkList, 0, inkListLength * sizeof(AnnotPath *));
     3645    for (int i = 0; i < inkListLength; i++) {
     3646      Object obj2;
     3647      if (array->get(i, &obj2)->isArray())
     3648        inkList[i] = new AnnotPath(obj2.getArray());
     3649      obj2.free();
     3650    }
     3651  } else {
     3652    inkListLength = 0;
     3653    inkList = NULL;
     3654    error(-1, "Bad Annot Ink List");
     3655    ok = gFalse;
     3656  }
     3657  obj1.free();
     3658}
     3659
     3660//------------------------------------------------------------------------
     3661// AnnotFileAttachment
     3662//------------------------------------------------------------------------
     3663
     3664AnnotFileAttachment::AnnotFileAttachment(XRef *xrefA, Dict *dict, Catalog *catalog, Object *obj) :
     3665  AnnotMarkup(xrefA, dict, catalog, obj) {
     3666  type = typeFileAttachment;
     3667  initialize(xrefA, catalog, dict);
     3668}
     3669
     3670AnnotFileAttachment::~AnnotFileAttachment() {
     3671  file.free();
     3672
     3673  if (name)
     3674    delete name;
     3675}
     3676
     3677void AnnotFileAttachment::initialize(XRef *xrefA, Catalog *catalog, Dict* dict) {
     3678  Object obj1;
     3679
     3680  if (dict->lookup("FS", &obj1)->isDict()) {
     3681    obj1.copy(&file);
     3682  } else {
     3683    error(-1, "Bad Annot File Attachment");
     3684    ok = gFalse;
     3685  }
     3686  obj1.free();
     3687
     3688  if (dict->lookup("Name", &obj1)->isName()) {
     3689    name = new GooString(obj1.getName());
     3690  } else {
     3691    name = new GooString("PushPin");
     3692  }
     3693  obj1.free();
     3694}
     3695
     3696//------------------------------------------------------------------------
     3697// AnnotSound
     3698//------------------------------------------------------------------------
     3699
     3700AnnotSound::AnnotSound(XRef *xrefA, Dict *dict, Catalog *catalog, Object *obj) :
     3701  AnnotMarkup(xrefA, dict, catalog, obj) {
     3702  type = typeSound;
     3703  initialize(xrefA, catalog, dict);
     3704}
     3705
     3706AnnotSound::~AnnotSound() {
     3707  delete sound;
     3708
     3709  delete name;
     3710}
     3711
     3712void AnnotSound::initialize(XRef *xrefA, Catalog *catalog, Dict* dict) {
     3713  Object obj1;
     3714
     3715  sound = Sound::parseSound(dict->lookup("Sound", &obj1));
     3716  if (!sound) {
     3717    error(-1, "Bad Annot Sound");
     3718    ok = gFalse;
     3719  }
     3720  obj1.free();
     3721
     3722  if (dict->lookup("Name", &obj1)->isName()) {
     3723    name = new GooString(obj1.getName());
     3724  } else {
     3725    name = new GooString("Speaker");
     3726  }
     3727  obj1.free();
     3728}
     3729
     3730//------------------------------------------------------------------------
     3731// Annot3D
     3732//------------------------------------------------------------------------
     3733
     3734Annot3D::Annot3D(XRef *xrefA, Dict *dict, Catalog *catalog, Object *obj) :
     3735  Annot(xrefA, dict, catalog, obj) {
     3736  type = type3D;
     3737  initialize(xrefA, catalog, dict);
     3738}
     3739
     3740Annot3D::~Annot3D() {
     3741  if (activation)
     3742    delete activation;
     3743}
     3744
     3745void Annot3D::initialize(XRef *xrefA, Catalog *catalog, Dict* dict) {
     3746  Object obj1;
     3747
     3748  if (dict->lookup("3DA", &obj1)->isDict()) {
     3749    activation = new Activation(obj1.getDict());
     3750  } else {
     3751    activation = NULL;
     3752  }
     3753  obj1.free();
     3754}
     3755
     3756Annot3D::Activation::Activation(Dict *dict) {
     3757  Object obj1;
     3758
     3759  if (dict->lookup("A", &obj1)->isName()) {
     3760    GooString *name = new GooString(obj1.getName());
     3761
     3762    if(!name->cmp("PO")) {
     3763      aTrigger = aTriggerPageOpened;
     3764    } else if(!name->cmp("PV")) {
     3765      aTrigger = aTriggerPageVisible;
     3766    } else if(!name->cmp("XA")) {
     3767      aTrigger = aTriggerUserAction;
     3768    } else {
     3769      aTrigger = aTriggerUnknown;
     3770    }
     3771    delete name;
     3772  } else {
     3773    aTrigger = aTriggerUnknown;
     3774  }
     3775  obj1.free();
     3776
     3777  if(dict->lookup("AIS", &obj1)->isName()) {
     3778    GooString *name = new GooString(obj1.getName());
     3779
     3780    if(!name->cmp("I")) {
     3781      aState = aStateEnabled;
     3782    } else if(!name->cmp("L")) {
     3783      aState = aStateDisabled;
     3784    } else {
     3785      aState = aStateUnknown;
     3786    }
     3787    delete name;
     3788  } else {
     3789    aState = aStateUnknown;
     3790  }
     3791  obj1.free();
     3792
     3793  if(dict->lookup("D", &obj1)->isName()) {
     3794    GooString *name = new GooString(obj1.getName());
     3795
     3796    if(!name->cmp("PC")) {
     3797      dTrigger = dTriggerPageClosed;
     3798    } else if(!name->cmp("PI")) {
     3799      dTrigger = dTriggerPageInvisible;
     3800    } else if(!name->cmp("XD")) {
     3801      dTrigger = dTriggerUserAction;
     3802    } else {
     3803      dTrigger = dTriggerUnknown;
     3804    }
     3805    delete name;
     3806  } else {
     3807    dTrigger = dTriggerUnknown;
     3808  }
     3809  obj1.free();
     3810
     3811  if(dict->lookup("DIS", &obj1)->isName()) {
     3812    GooString *name = new GooString(obj1.getName());
     3813
     3814    if(!name->cmp("U")) {
     3815      dState = dStateUninstantiaded;
     3816    } else if(!name->cmp("I")) {
     3817      dState = dStateInstantiated;
     3818    } else if(!name->cmp("L")) {
     3819      dState = dStateLive;
     3820    } else {
     3821      dState = dStateUnknown;
     3822    }
     3823    delete name;
     3824  } else {
     3825    dState = dStateUnknown;
     3826  }
     3827  obj1.free();
     3828
     3829  if (dict->lookup("TB", &obj1)->isBool()) {
     3830    displayToolbar = obj1.getBool();
     3831  } else {
     3832    displayToolbar = gTrue;
     3833  }
     3834  obj1.free();
     3835
     3836  if (dict->lookup("NP", &obj1)->isBool()) {
     3837    displayNavigation = obj1.getBool();
     3838  } else {
     3839    displayNavigation = gFalse;
     3840  }
     3841  obj1.free();
    33093842}
    33103843
     
    33643897      annot = new AnnotLine(xref, dict, catalog, obj);
    33653898    } else if (!typeName->cmp("Square")) {
    3366       annot = new Annot(xref, dict, catalog, obj);
     3899      annot = new AnnotGeometry(xref, dict, catalog, obj);
    33673900    } else if (!typeName->cmp("Circle")) {
    3368       annot = new Annot(xref, dict, catalog, obj);
     3901      annot = new AnnotGeometry(xref, dict, catalog, obj);
    33693902    } else if (!typeName->cmp("Polygon")) {
    3370       annot = new Annot(xref, dict, catalog, obj);
     3903      annot = new AnnotPolygon(xref, dict, catalog, obj);
    33713904    } else if (!typeName->cmp("PolyLine")) {
    3372       annot = new Annot(xref, dict, catalog, obj);
     3905      annot = new AnnotPolygon(xref, dict, catalog, obj);
    33733906    } else if (!typeName->cmp("Highlight")) {
    3374       annot = new Annot(xref, dict, catalog, obj);
     3907      annot = new AnnotTextMarkup(xref, dict, catalog, obj);
    33753908    } else if (!typeName->cmp("Underline")) {
    3376       annot = new Annot(xref, dict, catalog, obj);
     3909      annot = new AnnotTextMarkup(xref, dict, catalog, obj);
    33773910    } else if (!typeName->cmp("Squiggly")) {
    3378       annot = new Annot(xref, dict, catalog, obj);
     3911      annot = new AnnotTextMarkup(xref, dict, catalog, obj);
    33793912    } else if (!typeName->cmp("StrikeOut")) {
    3380       annot = new Annot(xref, dict, catalog, obj);
     3913      annot = new AnnotTextMarkup(xref, dict, catalog, obj);
    33813914    } else if (!typeName->cmp("Stamp")) {
    3382       annot = new Annot(xref, dict, catalog, obj);
     3915      annot = new AnnotStamp(xref, dict, catalog, obj);
    33833916    } else if (!typeName->cmp("Caret")) {
    3384       annot = new Annot(xref, dict, catalog, obj);
     3917      annot = new AnnotCaret(xref, dict, catalog, obj);
    33853918    } else if (!typeName->cmp("Ink")) {
    3386       annot = new Annot(xref, dict, catalog, obj);
     3919      annot = new AnnotInk(xref, dict, catalog, obj);
    33873920    } else if (!typeName->cmp("FileAttachment")) {
    3388       annot = new Annot(xref, dict, catalog, obj);
     3921      annot = new AnnotFileAttachment(xref, dict, catalog, obj);
    33893922    } else if (!typeName->cmp("Sound")) {
    3390       annot = new Annot(xref, dict, catalog, obj);
     3923      annot = new AnnotSound(xref, dict, catalog, obj);
    33913924    } else if(!typeName->cmp("Movie")) {
    33923925      annot = new AnnotMovie(xref, dict, catalog, obj);
     
    34023935      annot = new Annot(xref, dict, catalog, obj);
    34033936    } else if (!typeName->cmp("3D")) {
    3404       annot = new Annot(xref, dict, catalog, obj);
     3937      annot = new Annot3D(xref, dict, catalog, obj);
    34053938    } else {
    34063939      annot = new Annot(xref, dict, catalog, obj);
Note: See TracChangeset for help on using the changeset viewer.