glib/poppler-action.cc | 2 glib/poppler-annot.cc | 4 poppler/Annot.cc | 364 ++++++++++++++++++++++++------------------------- poppler/Annot.h | 128 ++++++++--------- poppler/Catalog.cc | 9 - poppler/Form.cc | 22 +- poppler/Form.h | 11 - poppler/PSOutputDev.cc | 2 poppler/Page.cc | 2 9 files changed, 274 insertions(+), 270 deletions(-)
New commits: commit ec52e46e309a0307fdf12113a1b7d41a760f9d6c Author: Carlos Garcia Campos <[email protected]> Date: Sun Sep 4 11:32:38 2011 +0200 xpdf303: Create annots with a doc instead of xref + catalog diff --git a/glib/poppler-action.cc b/glib/poppler-action.cc index c7ebcdd..384530f 100644 --- a/glib/poppler-action.cc +++ b/glib/poppler-action.cc @@ -480,7 +480,7 @@ find_annot_movie_for_action (PopplerDocument *document, if (annotObj.isDict ()) { Object tmp; - annot = new AnnotMovie (xref, annotObj.getDict(), document->doc->getCatalog (), &tmp); + annot = new AnnotMovie (document->doc, annotObj.getDict(), &tmp); if (!annot->isOk ()) { delete annot; annot = NULL; diff --git a/glib/poppler-annot.cc b/glib/poppler-annot.cc index a69644d..4ad5f5d 100644 --- a/glib/poppler-annot.cc +++ b/glib/poppler-annot.cc @@ -199,7 +199,7 @@ poppler_annot_text_new (PopplerDocument *doc, PDFRectangle pdf_rect(rect->x1, rect->y1, rect->x2, rect->y2); - annot = new AnnotText (doc->doc->getXRef(), &pdf_rect, doc->doc->getCatalog()); + annot = new AnnotText (doc->doc, &pdf_rect); return _poppler_annot_text_new (annot); } @@ -708,7 +708,7 @@ poppler_annot_markup_set_popup (PopplerAnnotMarkup *poppler_annot, g_return_if_fail (POPPLER_IS_ANNOT_MARKUP (poppler_annot)); annot = static_cast<AnnotMarkup *>(POPPLER_ANNOT (poppler_annot)->annot); - popup = new AnnotPopup (annot->getXRef(), &pdf_rect, (Catalog *)NULL); + popup = new AnnotPopup (annot->getDoc(), &pdf_rect); annot->setPopup (popup); } diff --git a/poppler/Annot.cc b/poppler/Annot.cc index 3e0fb3e..30ce86a 100644 --- a/poppler/Annot.cc +++ b/poppler/Annot.cc @@ -47,6 +47,7 @@ #include "Catalog.h" #include "Gfx.h" #include "Lexer.h" +#include "PDFDoc.h" #include "Page.h" #include "Annot.h" #include "GfxFont.h" @@ -808,14 +809,14 @@ AnnotAppearanceCharacs::~AnnotAppearanceCharacs() { // Annot //------------------------------------------------------------------------ -Annot::Annot(XRef *xrefA, PDFRectangle *rectA, Catalog *catalog) { +Annot::Annot(PDFDoc *docA, PDFRectangle *rectA) { Object obj1; refCnt = 1; flags = flagUnknown; type = typeUnknown; - obj1.initArray (xrefA); + obj1.initArray (docA->getXRef()); Object obj2; obj1.arrayAdd (obj2.initReal (rectA->x1)); obj1.arrayAdd (obj2.initReal (rectA->y1)); @@ -823,26 +824,26 @@ Annot::Annot(XRef *xrefA, PDFRectangle *rectA, Catalog *catalog) { obj1.arrayAdd (obj2.initReal (rectA->y2)); obj2.free (); - annotObj.initDict (xrefA); + annotObj.initDict (docA->getXRef()); annotObj.dictSet ("Type", obj2.initName ("Annot")); annotObj.dictSet ("Rect", &obj1); // obj1 is owned by the dict - ref = xrefA->addIndirectObject (&annotObj); + ref = docA->getXRef()->addIndirectObject (&annotObj); - initialize (xrefA, annotObj.getDict(), catalog); + initialize (docA, annotObj.getDict()); } -Annot::Annot(XRef *xrefA, Dict *dict, Catalog* catalog) { +Annot::Annot(PDFDoc *docA, Dict *dict) { refCnt = 1; hasRef = false; flags = flagUnknown; type = typeUnknown; annotObj.initDict (dict); - initialize (xrefA, dict, catalog); + initialize (docA, dict); } -Annot::Annot(XRef *xrefA, Dict *dict, Catalog* catalog, Object *obj) { +Annot::Annot(PDFDoc *docA, Dict *dict, Object *obj) { refCnt = 1; if (obj->isRef()) { hasRef = gTrue; @@ -853,16 +854,17 @@ Annot::Annot(XRef *xrefA, Dict *dict, Catalog* catalog, Object *obj) { flags = flagUnknown; type = typeUnknown; annotObj.initDict (dict); - initialize (xrefA, dict, catalog); + initialize (docA, dict); } -void Annot::initialize(XRef *xrefA, Dict *dict, Catalog *catalog) { +void Annot::initialize(PDFDoc *docA, Dict *dict) { Object asObj, obj1, obj2, obj3; appRef.num = 0; appRef.gen = 65535; ok = gTrue; - xref = xrefA; + doc = docA; + xref = doc->getXRef(); appearBuf = NULL; fontSize = 0; @@ -910,7 +912,7 @@ void Annot::initialize(XRef *xrefA, Dict *dict, Catalog *catalog) { if (dict->lookupNF("P", &obj1)->isRef()) { Ref ref = obj1.getRef(); - page = catalog ? catalog->findPage (ref.num, ref.gen) : -1; + page = doc->getCatalog()->findPage (ref.num, ref.gen); } else { page = 0; } @@ -1002,7 +1004,7 @@ void Annot::initialize(XRef *xrefA, Dict *dict, Catalog *catalog) { } obj1.free(); - optContentConfig = catalog ? catalog->getOptContentConfig() : NULL; + optContentConfig = doc->getCatalog()->getOptContentConfig(); dict->lookupNF("OC", &oc); if (!oc.isRef() && !oc.isNull()) { error (errSyntaxError, -1, "Annotation OC value not null or dict: {0:d}", oc.getType()); @@ -1355,27 +1357,27 @@ void Annot::draw(Gfx *gfx, GBool printing) { // AnnotPopup //------------------------------------------------------------------------ -AnnotPopup::AnnotPopup(XRef *xrefA, PDFRectangle *rect, Catalog *catalog) : - Annot(xrefA, rect, catalog) { +AnnotPopup::AnnotPopup(PDFDoc *docA, PDFRectangle *rect) : + Annot(docA, rect) { Object obj1; type = typePopup; annotObj.dictSet ("Subtype", obj1.initName ("Popup")); - initialize (xrefA, annotObj.getDict(), catalog); + initialize (docA, annotObj.getDict()); } -AnnotPopup::AnnotPopup(XRef *xrefA, Dict *dict, Catalog *catalog, Object *obj) : - Annot(xrefA, dict, catalog, obj) { +AnnotPopup::AnnotPopup(PDFDoc *docA, Dict *dict, Object *obj) : + Annot(docA, dict, obj) { type = typePopup; - initialize(xrefA, dict, catalog); + initialize(docA, dict); } AnnotPopup::~AnnotPopup() { parent.free(); } -void AnnotPopup::initialize(XRef *xrefA, Dict *dict, Catalog *catalog) { +void AnnotPopup::initialize(PDFDoc *docA, Dict *dict) { Object obj1; if (!dict->lookupNF("Parent", &parent)->isRef()) { @@ -1412,14 +1414,14 @@ void AnnotPopup::setOpen(GBool openA) { //------------------------------------------------------------------------ // AnnotMarkup //------------------------------------------------------------------------ -AnnotMarkup::AnnotMarkup(XRef *xrefA, PDFRectangle *rect, Catalog *catalog) : - Annot(xrefA, rect, catalog) { - initialize(xrefA, annotObj.getDict(), catalog, &annotObj); +AnnotMarkup::AnnotMarkup(PDFDoc *docA, PDFRectangle *rect) : + Annot(docA, rect) { + initialize(docA, annotObj.getDict(), &annotObj); } -AnnotMarkup::AnnotMarkup(XRef *xrefA, Dict *dict, Catalog *catalog, Object *obj) : - Annot(xrefA, dict, catalog, obj) { - initialize(xrefA, dict, catalog, obj); +AnnotMarkup::AnnotMarkup(PDFDoc *docA, Dict *dict, Object *obj) : + Annot(docA, dict, obj) { + initialize(docA, dict, obj); } AnnotMarkup::~AnnotMarkup() { @@ -1436,7 +1438,7 @@ AnnotMarkup::~AnnotMarkup() { delete subject; } -void AnnotMarkup::initialize(XRef *xrefA, Dict *dict, Catalog *catalog, Object *obj) { +void AnnotMarkup::initialize(PDFDoc *docA, Dict *dict, Object *obj) { Object obj1; if (dict->lookup("T", &obj1)->isString()) { @@ -1447,7 +1449,7 @@ void AnnotMarkup::initialize(XRef *xrefA, Dict *dict, Catalog *catalog, Object * obj1.free(); if (dict->lookup("Popup", &obj1)->isDict()) { - popup = new AnnotPopup(xrefA, obj1.getDict(), catalog, obj); + popup = new AnnotPopup(docA, obj1.getDict(), obj); } else { popup = NULL; } @@ -1553,30 +1555,30 @@ void AnnotMarkup::setOpacity(double opacityA) { // AnnotText //------------------------------------------------------------------------ -AnnotText::AnnotText(XRef *xrefA, PDFRectangle *rect, Catalog *catalog) : - AnnotMarkup(xrefA, rect, catalog) { +AnnotText::AnnotText(PDFDoc *docA, PDFRectangle *rect) : + AnnotMarkup(docA, rect) { Object obj1; type = typeText; flags |= flagNoZoom | flagNoRotate; annotObj.dictSet ("Subtype", obj1.initName ("Text")); - initialize (xrefA, catalog, annotObj.getDict()); + initialize (docA, annotObj.getDict()); } -AnnotText::AnnotText(XRef *xrefA, Dict *dict, Catalog *catalog, Object *obj) : - AnnotMarkup(xrefA, dict, catalog, obj) { +AnnotText::AnnotText(PDFDoc *docA, Dict *dict, Object *obj) : + AnnotMarkup(docA, dict, obj) { type = typeText; flags |= flagNoZoom | flagNoRotate; - initialize (xrefA, catalog, dict); + initialize (docA, dict); } AnnotText::~AnnotText() { delete icon; } -void AnnotText::initialize(XRef *xrefA, Catalog *catalog, Dict *dict) { +void AnnotText::initialize(PDFDoc *docA, Dict *dict) { Object obj1; if (dict->lookup("Open", &obj1)->isBool()) @@ -1996,20 +1998,20 @@ void AnnotText::draw(Gfx *gfx, GBool printing) { //------------------------------------------------------------------------ // AnnotLink //------------------------------------------------------------------------ -AnnotLink::AnnotLink(XRef *xrefA, PDFRectangle *rect, Catalog *catalog) : - Annot(xrefA, rect, catalog) { +AnnotLink::AnnotLink(PDFDoc *docA, PDFRectangle *rect) : + Annot(docA, rect) { Object obj1; type = typeLink; annotObj.dictSet ("Subtype", obj1.initName ("Link")); - initialize (xrefA, catalog, annotObj.getDict()); + initialize (docA, annotObj.getDict()); } -AnnotLink::AnnotLink(XRef *xrefA, Dict *dict, Catalog *catalog, Object *obj) : - Annot(xrefA, dict, catalog, obj) { +AnnotLink::AnnotLink(PDFDoc *docA, Dict *dict, Object *obj) : + Annot(docA, dict, obj) { type = typeLink; - initialize (xrefA, catalog, dict); + initialize (docA, dict); } AnnotLink::~AnnotLink() { @@ -2022,7 +2024,7 @@ AnnotLink::~AnnotLink() { delete quadrilaterals; } -void AnnotLink::initialize(XRef *xrefA, Catalog *catalog, Dict *dict) { +void AnnotLink::initialize(PDFDoc *docA, Dict *dict) { Object obj1; action = NULL; @@ -2034,7 +2036,7 @@ void AnnotLink::initialize(XRef *xrefA, Catalog *catalog, Dict *dict) { } else { obj1.free(); if (dict->lookup("A", &obj1)->isDict()) { - action = LinkAction::parseAction(&obj1, catalog->getBaseURI()); + action = LinkAction::parseAction(&obj1, doc->getCatalog()->getBaseURI()); } } obj1.free(); @@ -2089,8 +2091,8 @@ void AnnotLink::draw(Gfx *gfx, GBool printing) { //------------------------------------------------------------------------ // AnnotFreeText //------------------------------------------------------------------------ -AnnotFreeText::AnnotFreeText(XRef *xrefA, PDFRectangle *rect, GooString *da, Catalog *catalog) : - AnnotMarkup(xrefA, rect, catalog) { +AnnotFreeText::AnnotFreeText(PDFDoc *docA, PDFRectangle *rect, GooString *da) : + AnnotMarkup(docA, rect) { Object obj1; type = typeFreeText; @@ -2101,13 +2103,13 @@ AnnotFreeText::AnnotFreeText(XRef *xrefA, PDFRectangle *rect, GooString *da, Cat obj2.initString (da->copy()); annotObj.dictSet("DA", &obj2); - initialize (xrefA, catalog, annotObj.getDict()); + initialize (docA, annotObj.getDict()); } -AnnotFreeText::AnnotFreeText(XRef *xrefA, Dict *dict, Catalog *catalog, Object *obj) : - AnnotMarkup(xrefA, dict, catalog, obj) { +AnnotFreeText::AnnotFreeText(PDFDoc *docA, Dict *dict, Object *obj) : + AnnotMarkup(docA, dict, obj) { type = typeFreeText; - initialize(xrefA, catalog, dict); + initialize(docA, dict); } AnnotFreeText::~AnnotFreeText() { @@ -2126,7 +2128,7 @@ AnnotFreeText::~AnnotFreeText() { delete rectangle; } -void AnnotFreeText::initialize(XRef *xrefA, Catalog *catalog, Dict *dict) { +void AnnotFreeText::initialize(PDFDoc *docA, Dict *dict) { Object obj1; if (dict->lookup("DA", &obj1)->isString()) { @@ -2224,28 +2226,28 @@ void AnnotFreeText::initialize(XRef *xrefA, Catalog *catalog, Dict *dict) { // AnnotLine //------------------------------------------------------------------------ -AnnotLine::AnnotLine(XRef *xrefA, PDFRectangle *rect, PDFRectangle *lRect, Catalog *catalog) : - AnnotMarkup(xrefA, rect, catalog) { +AnnotLine::AnnotLine(PDFDoc *docA, PDFRectangle *rect, PDFRectangle *lRect) : + AnnotMarkup(docA, rect) { Object obj1; type = typeLine; annotObj.dictSet ("Subtype", obj1.initName ("Line")); Object obj2, obj3; - obj2.initArray (xrefA); + obj2.initArray (doc->getXRef()); obj2.arrayAdd (obj3.initReal (lRect->x1)); obj2.arrayAdd (obj3.initReal (lRect->y1)); obj2.arrayAdd (obj3.initReal (lRect->x2)); obj2.arrayAdd (obj3.initReal (lRect->y2)); annotObj.dictSet ("L", &obj2); - initialize (xrefA, catalog, annotObj.getDict()); + initialize (docA, annotObj.getDict()); } -AnnotLine::AnnotLine(XRef *xrefA, Dict *dict, Catalog *catalog, Object *obj) : - AnnotMarkup(xrefA, dict, catalog, obj) { +AnnotLine::AnnotLine(PDFDoc *docA, Dict *dict, Object *obj) : + AnnotMarkup(docA, dict, obj) { type = typeLine; - initialize(xrefA, catalog, dict); + initialize(docA, dict); } AnnotLine::~AnnotLine() { @@ -2259,7 +2261,7 @@ AnnotLine::~AnnotLine() { delete measure; } -void AnnotLine::initialize(XRef *xrefA, Catalog *catalog, Dict *dict) { +void AnnotLine::initialize(PDFDoc *docA, Dict *dict) { Object obj1; if (dict->lookup("L", &obj1)->isArray() && obj1.arrayGetLength() == 4) { @@ -2475,9 +2477,9 @@ void AnnotLine::draw(Gfx *gfx, GBool printing) { //------------------------------------------------------------------------ // AnnotTextMarkup //------------------------------------------------------------------------ -AnnotTextMarkup::AnnotTextMarkup(XRef *xrefA, PDFRectangle *rect, AnnotSubtype subType, - AnnotQuadrilaterals *quadPoints, Catalog *catalog) : - AnnotMarkup(xrefA, rect, catalog) { +AnnotTextMarkup::AnnotTextMarkup(PDFDoc *docA, PDFRectangle *rect, AnnotSubtype subType, + AnnotQuadrilaterals *quadPoints) : + AnnotMarkup(docA, rect) { Object obj1; switch (subType) { @@ -2498,7 +2500,7 @@ AnnotTextMarkup::AnnotTextMarkup(XRef *xrefA, PDFRectangle *rect, AnnotSubtype s } Object obj2; - obj2.initArray (xrefA); + obj2.initArray (doc->getXRef()); for (int i = 0; i < quadPoints->getQuadrilateralsLength(); ++i) { Object obj3; @@ -2515,17 +2517,17 @@ AnnotTextMarkup::AnnotTextMarkup(XRef *xrefA, PDFRectangle *rect, AnnotSubtype s annotObj.dictSet ("QuadPoints", &obj2); - initialize(xrefA, catalog, annotObj.getDict()); + initialize(docA, annotObj.getDict()); } -AnnotTextMarkup::AnnotTextMarkup(XRef *xrefA, Dict *dict, Catalog *catalog, Object *obj) : - AnnotMarkup(xrefA, dict, catalog, obj) { +AnnotTextMarkup::AnnotTextMarkup(PDFDoc *docA, Dict *dict, Object *obj) : + AnnotMarkup(docA, dict, obj) { // the real type will be read in initialize() type = typeHighlight; - initialize(xrefA, catalog, dict); + initialize(docA, dict); } -void AnnotTextMarkup::initialize(XRef *xrefA, Catalog *catalog, Dict *dict) { +void AnnotTextMarkup::initialize(PDFDoc *docA, Dict *dict) { Object obj1; if (dict->lookup("Subtype", &obj1)->isName()) { @@ -2691,18 +2693,18 @@ void AnnotTextMarkup::draw(Gfx *gfx, GBool printing) { // AnnotWidget //------------------------------------------------------------------------ -AnnotWidget::AnnotWidget(XRef *xrefA, Dict *dict, Catalog *catalog, Object *obj) : - Annot(xrefA, dict, catalog, obj) { +AnnotWidget::AnnotWidget(PDFDoc *docA, Dict *dict, Object *obj) : + Annot(docA, dict, obj) { type = typeWidget; field = NULL; - initialize(xrefA, catalog, dict); + initialize(docA, dict); } -AnnotWidget::AnnotWidget(XRef *xrefA, Dict *dict, Catalog *catalog, Object *obj, FormField *fieldA) : - Annot(xrefA, dict, catalog, obj) { +AnnotWidget::AnnotWidget(PDFDoc *docA, Dict *dict, Object *obj, FormField *fieldA) : + Annot(docA, dict, obj) { type = typeWidget; field = fieldA; - initialize(xrefA, catalog, dict); + initialize(docA, dict); } AnnotWidget::~AnnotWidget() { @@ -2719,10 +2721,10 @@ AnnotWidget::~AnnotWidget() { delete parent; } -void AnnotWidget::initialize(XRef *xrefA, Catalog *catalog, Dict *dict) { +void AnnotWidget::initialize(PDFDoc *docA, Dict *dict) { Object obj1; - form = catalog->getForm(); + form = doc->getCatalog()->getForm(); if(dict->lookup("H", &obj1)->isName()) { const char *modeName = obj1.getName(); @@ -2750,7 +2752,7 @@ void AnnotWidget::initialize(XRef *xrefA, Catalog *catalog, Dict *dict) { action = NULL; if(dict->lookup("A", &obj1)->isDict()) { - action = LinkAction::parseAction(&obj1, catalog->getBaseURI()); + action = LinkAction::parseAction(&obj1, doc->getCatalog()->getBaseURI()); } obj1.free(); @@ -3885,8 +3887,8 @@ void AnnotWidget::draw(Gfx *gfx, GBool printing) { //------------------------------------------------------------------------ // AnnotMovie //------------------------------------------------------------------------ -AnnotMovie::AnnotMovie(XRef *xrefA, PDFRectangle *rect, Movie *movieA, Catalog *catalog) : - Annot(xrefA, rect, catalog) { +AnnotMovie::AnnotMovie(PDFDoc *docA, PDFRectangle *rect, Movie *movieA) : + Annot(docA, rect) { Object obj1; type = typeMovie; @@ -3895,13 +3897,13 @@ AnnotMovie::AnnotMovie(XRef *xrefA, PDFRectangle *rect, Movie *movieA, Catalog * movie = movieA->copy(); // TODO: create movie dict from movieA - initialize(xrefA, catalog, annotObj.getDict()); + initialize(docA, annotObj.getDict()); } -AnnotMovie::AnnotMovie(XRef *xrefA, Dict *dict, Catalog *catalog, Object *obj) : - Annot(xrefA, dict, catalog, obj) { +AnnotMovie::AnnotMovie(PDFDoc *docA, Dict *dict, Object *obj) : + Annot(docA, dict, obj) { type = typeMovie; - initialize(xrefA, catalog, dict); + initialize(docA, dict); } AnnotMovie::~AnnotMovie() { @@ -3910,7 +3912,7 @@ AnnotMovie::~AnnotMovie() { delete movie; } -void AnnotMovie::initialize(XRef *xrefA, Catalog *catalog, Dict* dict) { +void AnnotMovie::initialize(PDFDoc *docA, Dict* dict) { Object obj1; if (dict->lookup("T", &obj1)->isString()) { @@ -4036,20 +4038,20 @@ void AnnotMovie::draw(Gfx *gfx, GBool printing) { //------------------------------------------------------------------------ // AnnotScreen //------------------------------------------------------------------------ -AnnotScreen::AnnotScreen(XRef *xrefA, PDFRectangle *rect, Catalog *catalog) : - Annot(xrefA, rect, catalog) { +AnnotScreen::AnnotScreen(PDFDoc *docA, PDFRectangle *rect) : + Annot(docA, rect) { Object obj1; type = typeScreen; annotObj.dictSet ("Subtype", obj1.initName ("Screen")); - initialize(xrefA, catalog, annotObj.getDict()); + initialize(docA, annotObj.getDict()); } -AnnotScreen::AnnotScreen(XRef *xrefA, Dict *dict, Catalog *catalog, Object *obj) : - Annot(xrefA, dict, catalog, obj) { +AnnotScreen::AnnotScreen(PDFDoc *docA, Dict *dict, Object *obj) : + Annot(docA, dict, obj) { type = typeScreen; - initialize(xrefA, catalog, dict); + initialize(docA, dict); } AnnotScreen::~AnnotScreen() { @@ -4063,7 +4065,7 @@ AnnotScreen::~AnnotScreen() { additionAction.free(); } -void AnnotScreen::initialize(XRef *xrefA, Catalog *catalog, Dict* dict) { +void AnnotScreen::initialize(PDFDoc *docA, Dict* dict) { Object obj1; title = NULL; @@ -4074,7 +4076,7 @@ void AnnotScreen::initialize(XRef *xrefA, Catalog *catalog, Dict* dict) { action = NULL; if (dict->lookup("A", &obj1)->isDict()) { - action = LinkAction::parseAction(&obj1, catalog->getBaseURI()); + action = LinkAction::parseAction(&obj1, doc->getCatalog()->getBaseURI()); if (action->getKind() == actionRendition && page == 0) { error (errSyntaxError, -1, "Invalid Rendition action: associated screen annotation without P"); delete action; @@ -4097,26 +4099,26 @@ void AnnotScreen::initialize(XRef *xrefA, Catalog *catalog, Dict* dict) { //------------------------------------------------------------------------ // AnnotStamp //------------------------------------------------------------------------ -AnnotStamp::AnnotStamp(XRef *xrefA, PDFRectangle *rect, Catalog *catalog) : - AnnotMarkup(xrefA, rect, catalog) { +AnnotStamp::AnnotStamp(PDFDoc *docA, PDFRectangle *rect) : + AnnotMarkup(docA, rect) { Object obj1; type = typeStamp; annotObj.dictSet ("Subtype", obj1.initName ("Stamp")); - initialize(xrefA, catalog, annotObj.getDict()); + initialize(docA, annotObj.getDict()); } -AnnotStamp::AnnotStamp(XRef *xrefA, Dict *dict, Catalog *catalog, Object *obj) : - AnnotMarkup(xrefA, dict, catalog, obj) { +AnnotStamp::AnnotStamp(PDFDoc *docA, Dict *dict, Object *obj) : + AnnotMarkup(docA, dict, obj) { type = typeStamp; - initialize(xrefA, catalog, dict); + initialize(docA, dict); } AnnotStamp::~AnnotStamp() { delete icon; } -void AnnotStamp::initialize(XRef *xrefA, Catalog *catalog, Dict* dict) { +void AnnotStamp::initialize(PDFDoc *docA, Dict* dict) { Object obj1; if (dict->lookup("Name", &obj1)->isName()) { @@ -4131,8 +4133,8 @@ void AnnotStamp::initialize(XRef *xrefA, Catalog *catalog, Dict* dict) { //------------------------------------------------------------------------ // AnnotGeometry //------------------------------------------------------------------------ -AnnotGeometry::AnnotGeometry(XRef *xrefA, PDFRectangle *rect, AnnotSubtype subType, Catalog *catalog) : - AnnotMarkup(xrefA, rect, catalog) { +AnnotGeometry::AnnotGeometry(PDFDoc *docA, PDFRectangle *rect, AnnotSubtype subType) : + AnnotMarkup(docA, rect) { Object obj1; switch (subType) { @@ -4146,14 +4148,14 @@ AnnotGeometry::AnnotGeometry(XRef *xrefA, PDFRectangle *rect, AnnotSubtype subTy assert (0 && "Invalid subtype for AnnotGeometry\n"); } - initialize(xrefA, catalog, annotObj.getDict()); + initialize(docA, annotObj.getDict()); } -AnnotGeometry::AnnotGeometry(XRef *xrefA, Dict *dict, Catalog *catalog, Object *obj) : - AnnotMarkup(xrefA, dict, catalog, obj) { +AnnotGeometry::AnnotGeometry(PDFDoc *docA, Dict *dict, Object *obj) : + AnnotMarkup(docA, dict, obj) { // the real type will be read in initialize() type = typeSquare; - initialize(xrefA, catalog, dict); + initialize(docA, dict); } AnnotGeometry::~AnnotGeometry() { @@ -4162,7 +4164,7 @@ AnnotGeometry::~AnnotGeometry() { delete geometryRect; } -void AnnotGeometry::initialize(XRef *xrefA, Catalog *catalog, Dict* dict) { +void AnnotGeometry::initialize(PDFDoc *docA, Dict* dict) { Object obj1; if (dict->lookup("Subtype", &obj1)->isName()) { @@ -4326,9 +4328,8 @@ void AnnotGeometry::draw(Gfx *gfx, GBool printing) { //------------------------------------------------------------------------ // AnnotPolygon //------------------------------------------------------------------------ -AnnotPolygon::AnnotPolygon(XRef *xrefA, PDFRectangle *rect, AnnotSubtype subType, - AnnotPath *path, Catalog *catalog) : - AnnotMarkup(xrefA, rect, catalog) { +AnnotPolygon::AnnotPolygon(PDFDoc *docA, PDFRectangle *rect, AnnotSubtype subType, AnnotPath *path) : + AnnotMarkup(docA, rect) { Object obj1; switch (subType) { @@ -4343,7 +4344,7 @@ AnnotPolygon::AnnotPolygon(XRef *xrefA, PDFRectangle *rect, AnnotSubtype subType } Object obj2; - obj2.initArray (xrefA); + obj2.initArray (doc->getXRef()); for (int i = 0; i < path->getCoordsLength(); ++i) { Object obj3; @@ -4354,14 +4355,14 @@ AnnotPolygon::AnnotPolygon(XRef *xrefA, PDFRectangle *rect, AnnotSubtype subType annotObj.dictSet ("Vertices", &obj2); - initialize(xrefA, catalog, annotObj.getDict()); + initialize(docA, annotObj.getDict()); } -AnnotPolygon::AnnotPolygon(XRef *xrefA, Dict *dict, Catalog *catalog, Object *obj) : - AnnotMarkup(xrefA, dict, catalog, obj) { +AnnotPolygon::AnnotPolygon(PDFDoc *docA, Dict *dict, Object *obj) : + AnnotMarkup(docA, dict, obj) { // the real type will be read in initialize() type = typePolygon; - initialize(xrefA, catalog, dict); + initialize(docA, dict); } AnnotPolygon::~AnnotPolygon() { @@ -4374,7 +4375,7 @@ AnnotPolygon::~AnnotPolygon() { delete borderEffect; } -void AnnotPolygon::initialize(XRef *xrefA, Catalog *catalog, Dict* dict) { +void AnnotPolygon::initialize(PDFDoc *docA, Dict* dict) { Object obj1; if (dict->lookup("Subtype", &obj1)->isName()) { @@ -4449,27 +4450,27 @@ void AnnotPolygon::initialize(XRef *xrefA, Catalog *catalog, Dict* dict) { //------------------------------------------------------------------------ // AnnotCaret //------------------------------------------------------------------------ -AnnotCaret::AnnotCaret(XRef *xrefA, PDFRectangle *rect, Catalog *catalog) : - AnnotMarkup(xrefA, rect, catalog) { +AnnotCaret::AnnotCaret(PDFDoc *docA, PDFRectangle *rect) : + AnnotMarkup(docA, rect) { Object obj1; type = typeCaret; annotObj.dictSet ("Subtype", obj1.initName ("Caret")); - initialize(xrefA, catalog, annotObj.getDict()); + initialize(docA, annotObj.getDict()); } -AnnotCaret::AnnotCaret(XRef *xrefA, Dict *dict, Catalog *catalog, Object *obj) : - AnnotMarkup(xrefA, dict, catalog, obj) { +AnnotCaret::AnnotCaret(PDFDoc *docA, Dict *dict, Object *obj) : + AnnotMarkup(docA, dict, obj) { type = typeCaret; - initialize(xrefA, catalog, dict); + initialize(docA, dict); } AnnotCaret::~AnnotCaret() { delete caretRect; } -void AnnotCaret::initialize(XRef *xrefA, Catalog *catalog, Dict* dict) { +void AnnotCaret::initialize(PDFDoc *docA, Dict* dict) { Object obj1; symbol = symbolNone; @@ -4495,8 +4496,8 @@ void AnnotCaret::initialize(XRef *xrefA, Catalog *catalog, Dict* dict) { //------------------------------------------------------------------------ // AnnotInk //------------------------------------------------------------------------ -AnnotInk::AnnotInk(XRef *xrefA, PDFRectangle *rect, AnnotPath **paths, int n_paths, Catalog *catalog) : - AnnotMarkup(xrefA, rect, catalog) { +AnnotInk::AnnotInk(PDFDoc *docA, PDFRectangle *rect, AnnotPath **paths, int n_paths) : + AnnotMarkup(docA, rect) { Object obj1; type = typeInk; @@ -4504,12 +4505,12 @@ AnnotInk::AnnotInk(XRef *xrefA, PDFRectangle *rect, AnnotPath **paths, int n_pat annotObj.dictSet ("Subtype", obj1.initName ("Ink")); Object obj2; - obj2.initArray (xrefA); + obj2.initArray (doc->getXRef()); for (int i = 0; i < n_paths; ++i) { AnnotPath *path = paths[i]; Object obj3; - obj3.initArray (xrefA); + obj3.initArray (doc->getXRef()); for (int j = 0; j < path->getCoordsLength(); ++j) { Object obj4; @@ -4523,13 +4524,13 @@ AnnotInk::AnnotInk(XRef *xrefA, PDFRectangle *rect, AnnotPath **paths, int n_pat annotObj.dictSet ("InkList", &obj2); - initialize(xrefA, catalog, annotObj.getDict()); + initialize(docA, annotObj.getDict()); } -AnnotInk::AnnotInk(XRef *xrefA, Dict *dict, Catalog *catalog, Object *obj) : - AnnotMarkup(xrefA, dict, catalog, obj) { +AnnotInk::AnnotInk(PDFDoc *docA, Dict *dict, Object *obj) : + AnnotMarkup(docA, dict, obj) { type = typeInk; - initialize(xrefA, catalog, dict); + initialize(docA, dict); } AnnotInk::~AnnotInk() { @@ -4540,7 +4541,7 @@ AnnotInk::~AnnotInk() { } } -void AnnotInk::initialize(XRef *xrefA, Catalog *catalog, Dict* dict) { +void AnnotInk::initialize(PDFDoc *docA, Dict* dict) { Object obj1; if (dict->lookup("InkList", &obj1)->isArray()) { @@ -4566,8 +4567,8 @@ void AnnotInk::initialize(XRef *xrefA, Catalog *catalog, Dict* dict) { //------------------------------------------------------------------------ // AnnotFileAttachment //------------------------------------------------------------------------ -AnnotFileAttachment::AnnotFileAttachment(XRef *xrefA, PDFRectangle *rect, GooString *filename, Catalog *catalog) : - AnnotMarkup(xrefA, rect, catalog) { +AnnotFileAttachment::AnnotFileAttachment(PDFDoc *docA, PDFRectangle *rect, GooString *filename) : + AnnotMarkup(docA, rect) { Object obj1; type = typeFileAttachment; @@ -4578,13 +4579,13 @@ AnnotFileAttachment::AnnotFileAttachment(XRef *xrefA, PDFRectangle *rect, GooStr obj2.initString(filename->copy()); annotObj.dictSet ("FS", &obj2); - initialize(xrefA, catalog, annotObj.getDict()); + initialize(docA, annotObj.getDict()); } -AnnotFileAttachment::AnnotFileAttachment(XRef *xrefA, Dict *dict, Catalog *catalog, Object *obj) : - AnnotMarkup(xrefA, dict, catalog, obj) { +AnnotFileAttachment::AnnotFileAttachment(PDFDoc *docA, Dict *dict, Object *obj) : + AnnotMarkup(docA, dict, obj) { type = typeFileAttachment; - initialize(xrefA, catalog, dict); + initialize(docA, dict); } AnnotFileAttachment::~AnnotFileAttachment() { @@ -4594,7 +4595,7 @@ AnnotFileAttachment::~AnnotFileAttachment() { delete name; } -void AnnotFileAttachment::initialize(XRef *xrefA, Catalog *catalog, Dict* dict) { +void AnnotFileAttachment::initialize(PDFDoc *docA, Dict* dict) { Object obj1; if (dict->lookup("FS", &obj1)->isDict() || dict->lookup("FS", &obj1)->isString()) { @@ -4781,8 +4782,8 @@ void AnnotFileAttachment::draw(Gfx *gfx, GBool printing) { //------------------------------------------------------------------------ // AnnotSound //------------------------------------------------------------------------ -AnnotSound::AnnotSound(XRef *xrefA, PDFRectangle *rect, Sound *soundA, Catalog *catalog) : - AnnotMarkup(xrefA, rect, catalog) { +AnnotSound::AnnotSound(PDFDoc *docA, PDFRectangle *rect, Sound *soundA) : + AnnotMarkup(docA, rect) { Object obj1; type = typeSound; @@ -4795,13 +4796,13 @@ AnnotSound::AnnotSound(XRef *xrefA, PDFRectangle *rect, Sound *soundA, Catalog * str->incRef(); //FIXME: initStream should do this? annotObj.dictSet ("Sound", &obj2); - initialize(xrefA, catalog, annotObj.getDict()); + initialize(docA, annotObj.getDict()); } -AnnotSound::AnnotSound(XRef *xrefA, Dict *dict, Catalog *catalog, Object *obj) : - AnnotMarkup(xrefA, dict, catalog, obj) { +AnnotSound::AnnotSound(PDFDoc *docA, Dict *dict, Object *obj) : + AnnotMarkup(docA, dict, obj) { type = typeSound; - initialize(xrefA, catalog, dict); + initialize(docA, dict); } AnnotSound::~AnnotSound() { @@ -4810,7 +4811,7 @@ AnnotSound::~AnnotSound() { delete name; } -void AnnotSound::initialize(XRef *xrefA, Catalog *catalog, Dict* dict) { +void AnnotSound::initialize(PDFDoc *docA, Dict* dict) { Object obj1; sound = Sound::parseSound(dict->lookup("Sound", &obj1)); @@ -4942,21 +4943,21 @@ void AnnotSound::draw(Gfx *gfx, GBool printing) { //------------------------------------------------------------------------ // Annot3D //------------------------------------------------------------------------ -Annot3D::Annot3D(XRef *xrefA, PDFRectangle *rect, Catalog *catalog) : - Annot(xrefA, rect, catalog) { +Annot3D::Annot3D(PDFDoc *docA, PDFRectangle *rect) : + Annot(docA, rect) { Object obj1; type = type3D; annotObj.dictSet ("Subtype", obj1.initName ("3D")); - initialize(xrefA, catalog, annotObj.getDict()); + initialize(docA, annotObj.getDict()); } -Annot3D::Annot3D(XRef *xrefA, Dict *dict, Catalog *catalog, Object *obj) : - Annot(xrefA, dict, catalog, obj) { +Annot3D::Annot3D(PDFDoc *docA, Dict *dict, Object *obj) : + Annot(docA, dict, obj) { type = type3D; - initialize(xrefA, catalog, dict); + initialize(docA, dict); } Annot3D::~Annot3D() { @@ -4964,7 +4965,7 @@ Annot3D::~Annot3D() { delete activation; } -void Annot3D::initialize(XRef *xrefA, Catalog *catalog, Dict* dict) { +void Annot3D::initialize(PDFDoc *docA, Dict* dict) { Object obj1; if (dict->lookup("3DA", &obj1)->isDict()) { @@ -5063,11 +5064,12 @@ Annot3D::Activation::Activation(Dict *dict) { // Annots //------------------------------------------------------------------------ -Annots::Annots(XRef *xref, Catalog *catalog, Object *annotsObj) { +Annots::Annots(PDFDoc *docA, Object *annotsObj) { Annot *annot; Object obj1; int i; + doc = docA; annots = NULL; size = 0; nAnnots = 0; @@ -5080,7 +5082,7 @@ Annots::Annots(XRef *xref, Catalog *catalog, Object *annotsObj) { Object obj2; if (annotsObj->arrayGet(i, &obj1)->isDict()) { annotsObj->arrayGetNF(i, &obj2); - annot = createAnnot (xref, obj1.getDict(), catalog, &obj2); + annot = createAnnot (obj1.getDict(), &obj2); if (annot) { if (annot->isOk()) { appendAnnot(annot); @@ -5105,7 +5107,7 @@ void Annots::appendAnnot(Annot *annot) { } } -Annot *Annots::createAnnot(XRef *xref, Dict* dict, Catalog *catalog, Object *obj) { +Annot *Annots::createAnnot(Dict* dict, Object *obj) { Annot *annot = NULL; Object obj1; @@ -5113,45 +5115,45 @@ Annot *Annots::createAnnot(XRef *xref, Dict* dict, Catalog *catalog, Object *obj const char *typeName = obj1.getName(); if (!strcmp(typeName, "Text")) { - annot = new AnnotText(xref, dict, catalog, obj); + annot = new AnnotText(doc, dict, obj); } else if (!strcmp(typeName, "Link")) { - annot = new AnnotLink(xref, dict, catalog, obj); + annot = new AnnotLink(doc, dict, obj); } else if (!strcmp(typeName, "FreeText")) { - annot = new AnnotFreeText(xref, dict, catalog, obj); + annot = new AnnotFreeText(doc, dict, obj); } else if (!strcmp(typeName, "Line")) { - annot = new AnnotLine(xref, dict, catalog, obj); + annot = new AnnotLine(doc, dict, obj); } else if (!strcmp(typeName, "Square")) { - annot = new AnnotGeometry(xref, dict, catalog, obj); + annot = new AnnotGeometry(doc, dict, obj); } else if (!strcmp(typeName, "Circle")) { - annot = new AnnotGeometry(xref, dict, catalog, obj); + annot = new AnnotGeometry(doc, dict, obj); } else if (!strcmp(typeName, "Polygon")) { - annot = new AnnotPolygon(xref, dict, catalog, obj); + annot = new AnnotPolygon(doc, dict, obj); } else if (!strcmp(typeName, "PolyLine")) { - annot = new AnnotPolygon(xref, dict, catalog, obj); + annot = new AnnotPolygon(doc, dict, obj); } else if (!strcmp(typeName, "Highlight")) { - annot = new AnnotTextMarkup(xref, dict, catalog, obj); + annot = new AnnotTextMarkup(doc, dict, obj); } else if (!strcmp(typeName, "Underline")) { - annot = new AnnotTextMarkup(xref, dict, catalog, obj); + annot = new AnnotTextMarkup(doc, dict, obj); } else if (!strcmp(typeName, "Squiggly")) { - annot = new AnnotTextMarkup(xref, dict, catalog, obj); + annot = new AnnotTextMarkup(doc, dict, obj); } else if (!strcmp(typeName, "StrikeOut")) { - annot = new AnnotTextMarkup(xref, dict, catalog, obj); + annot = new AnnotTextMarkup(doc, dict, obj); } else if (!strcmp(typeName, "Stamp")) { - annot = new AnnotStamp(xref, dict, catalog, obj); + annot = new AnnotStamp(doc, dict, obj); } else if (!strcmp(typeName, "Caret")) { - annot = new AnnotCaret(xref, dict, catalog, obj); + annot = new AnnotCaret(doc, dict, obj); } else if (!strcmp(typeName, "Ink")) { - annot = new AnnotInk(xref, dict, catalog, obj); + annot = new AnnotInk(doc, dict, obj); } else if (!strcmp(typeName, "FileAttachment")) { - annot = new AnnotFileAttachment(xref, dict, catalog, obj); + annot = new AnnotFileAttachment(doc, dict, obj); } else if (!strcmp(typeName, "Sound")) { - annot = new AnnotSound(xref, dict, catalog, obj); + annot = new AnnotSound(doc, dict, obj); } else if(!strcmp(typeName, "Movie")) { - annot = new AnnotMovie(xref, dict, catalog, obj); + annot = new AnnotMovie(doc, dict, obj); } else if(!strcmp(typeName, "Widget")) { // Find the annot in forms if (obj->isRef()) { - Form *form = catalog->getForm(); + Form *form = doc->getCatalog()->getForm(); if (form) { FormWidget *widget = form->findWidgetByRef(obj->getRef()); if (widget) { @@ -5161,17 +5163,17 @@ Annot *Annots::createAnnot(XRef *xref, Dict* dict, Catalog *catalog, Object *obj } } if (!annot) - annot = new AnnotWidget(xref, dict, catalog, obj); + annot = new AnnotWidget(doc, dict, obj); } else if(!strcmp(typeName, "Screen")) { - annot = new AnnotScreen(xref, dict, catalog, obj); + annot = new AnnotScreen(doc, dict, obj); } else if(!strcmp(typeName, "PrinterMark")) { - annot = new Annot(xref, dict, catalog, obj); + annot = new Annot(doc, dict, obj); } else if (!strcmp(typeName, "TrapNet")) { - annot = new Annot(xref, dict, catalog, obj); + annot = new Annot(doc, dict, obj); } else if (!strcmp(typeName, "Watermark")) { - annot = new Annot(xref, dict, catalog, obj); + annot = new Annot(doc, dict, obj); } else if (!strcmp(typeName, "3D")) { - annot = new Annot3D(xref, dict, catalog, obj); + annot = new Annot3D(doc, dict, obj); } else if (!strcmp(typeName, "Popup")) { /* Popup annots are already handled by markup annots * Here we only care about popup annots without a @@ -5180,13 +5182,13 @@ Annot *Annots::createAnnot(XRef *xref, Dict* dict, Catalog *catalog, Object *obj Object obj2; if (dict->lookup("Parent", &obj2)->isNull()) - annot = new AnnotPopup(xref, dict, catalog, obj); + annot = new AnnotPopup(doc, dict, obj); else annot = NULL; obj2.free(); } else { - annot = new Annot(xref, dict, catalog, obj); + annot = new Annot(doc, dict, obj); } } obj1.free(); diff --git a/poppler/Annot.h b/poppler/Annot.h index 5796acb..64ad7f0 100644 --- a/poppler/Annot.h +++ b/poppler/Annot.h @@ -39,10 +39,10 @@ class XRef; class Gfx; -class Catalog; class CharCodeToUnicode; class GfxFont; class GfxResources; +class PDFDoc; class Form; class FormWidget; class FormField; @@ -455,9 +455,9 @@ public: type3D // 3D 25 }; - Annot(XRef *xrefA, PDFRectangle *rectA, Catalog *catalog); - Annot(XRef *xrefA, Dict *dict, Catalog *catalog); - Annot(XRef *xrefA, Dict *dict, Catalog *catalog, Object *obj); + Annot(PDFDoc *docA, PDFRectangle *rectA); + Annot(PDFDoc *docA, Dict *dict); + Annot(PDFDoc *docA, Dict *dict, Object *obj); GBool isOk() { return ok; } void incRefCnt(); @@ -488,6 +488,7 @@ public: void setAppearanceState(const char *state); // getters + PDFDoc *getDoc() const { return doc; } XRef *getXRef() const { return xref; } GBool getHasRef() const { return hasRef; } Ref getRef() const { return ref; } @@ -514,7 +515,7 @@ private: void readArrayNum(Object *pdfArray, int key, double *value); // write vStr[i:j[ in appearBuf - void initialize (XRef *xrefA, Dict *dict, Catalog *catalog); + void initialize (PDFDoc *docA, Dict *dict); protected: @@ -555,6 +556,7 @@ protected: OCGs *optContentConfig; // Optional content config Object oc; // OC + PDFDoc *doc; XRef *xref; // the xref table for this PDF file Ref ref; // object ref identifying this annotation GooString *appearBuf; @@ -572,8 +574,8 @@ protected: class AnnotPopup: public Annot { public: - AnnotPopup(XRef *xrefA, PDFRectangle *rect, Catalog *catalog); - AnnotPopup(XRef *xrefA, Dict *dict, Catalog *catalog, Object *obj); + AnnotPopup(PDFDoc *docA, PDFRectangle *rect); + AnnotPopup(PDFDoc *docA, Dict *dict, Object *obj); ~AnnotPopup(); Object *getParent(Object *obj) { return parent.fetch (xref, obj); } @@ -584,7 +586,7 @@ public: void setOpen(GBool openA); protected: - void initialize(XRef *xrefA, Dict *dict, Catalog *catalog); + void initialize(PDFDoc *docA, Dict *dict); Object parent; // Parent GBool open; // Open @@ -601,8 +603,8 @@ public: replyTypeGroup // Group }; - AnnotMarkup(XRef *xrefA, PDFRectangle *rect, Catalog *catalog); - AnnotMarkup(XRef *xrefA, Dict *dict, Catalog *catalog, Object *obj); + AnnotMarkup(PDFDoc *docA, PDFRectangle *rect); + AnnotMarkup(PDFDoc *docA, Dict *dict, Object *obj); virtual ~AnnotMarkup(); // getters @@ -636,7 +638,7 @@ protected: AnnotExternalDataType exData; // ExData private: - void initialize(XRef *xrefA, Dict *dict, Catalog *catalog, Object *obj); + void initialize(PDFDoc *docA, Dict *dict, Object *obj); }; //------------------------------------------------------------------------ @@ -658,8 +660,8 @@ public: stateNone // None }; - AnnotText(XRef *xrefA, PDFRectangle *rect, Catalog *catalog); - AnnotText(XRef *xrefA, Dict *dict, Catalog *catalog, Object *obj); + AnnotText(PDFDoc *docA, PDFRectangle *rect); + AnnotText(PDFDoc *docA, Dict *dict, Object *obj); ~AnnotText(); virtual void draw(Gfx *gfx, GBool printing); @@ -674,7 +676,7 @@ public: private: - void initialize(XRef *xrefA, Catalog *catalog, Dict *dict); + void initialize(PDFDoc *docA, Dict *dict); GBool open; // Open (Default false) GooString *icon; // Name (Default Note) @@ -691,8 +693,8 @@ private: class AnnotMovie: public Annot { public: - AnnotMovie(XRef *xrefA, PDFRectangle *rect, Movie *movieA, Catalog *catalog); - AnnotMovie(XRef *xrefA, Dict *dict, Catalog *catalog, Object *obj); + AnnotMovie(PDFDoc *docA, PDFRectangle *rect, Movie *movieA); + AnnotMovie(PDFDoc *docA, Dict *dict, Object *obj); ~AnnotMovie(); virtual void draw(Gfx *gfx, GBool printing); @@ -701,7 +703,7 @@ class AnnotMovie: public Annot { Movie* getMovie() { return movie; } private: - void initialize(XRef *xrefA, Catalog *catalog, Dict *dict); + void initialize(PDFDoc *docA, Dict *dict); GooString* title; // T Movie* movie; // Movie + A @@ -715,8 +717,8 @@ class AnnotMovie: public Annot { class AnnotScreen: public Annot { public: - AnnotScreen(XRef *xrefA, PDFRectangle *rect, Catalog *catalog); - AnnotScreen(XRef *xrefA, Dict *dict, Catalog *catalog, Object *obj); + AnnotScreen(PDFDoc *docA, PDFRectangle *rect); + AnnotScreen(PDFDoc *docA, Dict *dict, Object *obj); ~AnnotScreen(); GooString* getTitle() { return title; } @@ -726,7 +728,7 @@ class AnnotScreen: public Annot { Object* getAdditionActions() { return &additionAction; } private: - void initialize(XRef *xrefA, Catalog *catalog, Dict *dict); + void initialize(PDFDoc *docA, Dict *dict); GooString* title; // T @@ -751,8 +753,8 @@ public: effectPush // P }; - AnnotLink(XRef *xrefA, PDFRectangle *rect, Catalog *catalog); - AnnotLink(XRef *xrefA, Dict *dict, Catalog *catalog, Object *obj); + AnnotLink(PDFDoc *docA, PDFRectangle *rect); + AnnotLink(PDFDoc *docA, Dict *dict, Object *obj); virtual ~AnnotLink(); virtual void draw(Gfx *gfx, GBool printing); @@ -765,7 +767,7 @@ public: protected: - void initialize(XRef *xrefA, Catalog *catalog, Dict *dict); + void initialize(PDFDoc *docA, Dict *dict); LinkAction *action; // A, Dest AnnotLinkEffect linkEffect; // H (Default I) @@ -793,8 +795,8 @@ public: intentFreeTextTypeWriter // FreeTextTypeWriter }; - AnnotFreeText(XRef *xrefA, PDFRectangle *rect, GooString *da, Catalog *catalog); - AnnotFreeText(XRef *xrefA, Dict *dict, Catalog *catalog, Object *obj); + AnnotFreeText(PDFDoc *docA, PDFRectangle *rect, GooString *da); + AnnotFreeText(PDFDoc *docA, Dict *dict, Object *obj); ~AnnotFreeText(); // getters @@ -810,7 +812,7 @@ public: protected: - void initialize(XRef *xrefA, Catalog *catalog, Dict *dict); + void initialize(PDFDoc *docA, Dict *dict); // required GooString *appearanceString; // DA @@ -845,8 +847,8 @@ public: captionPosTop // Top }; - AnnotLine(XRef *xrefA, PDFRectangle *rect, PDFRectangle *lRect, Catalog *catalog); - AnnotLine(XRef *xrefA, Dict *dict, Catalog *catalog, Object *obj); + AnnotLine(PDFDoc *docA, PDFRectangle *rect, PDFRectangle *lRect); + AnnotLine(PDFDoc *docA, Dict *dict, Object *obj); ~AnnotLine(); virtual void draw(Gfx *gfx, GBool printing); @@ -871,7 +873,7 @@ public: protected: - void initialize(XRef *xrefA, Catalog *catalog, Dict *dict); + void initialize(PDFDoc *docA, Dict *dict); // required AnnotCoord *coord1, *coord2; @@ -900,9 +902,9 @@ protected: class AnnotTextMarkup: public AnnotMarkup { public: - AnnotTextMarkup(XRef *xrefA, PDFRectangle *rect, AnnotSubtype subType, - AnnotQuadrilaterals *quadPoints, Catalog *catalog); - AnnotTextMarkup(XRef *xrefA, Dict *dict, Catalog *catalog, Object *obj); + AnnotTextMarkup(PDFDoc *docA, PDFRectangle *rect, AnnotSubtype subType, + AnnotQuadrilaterals *quadPoints); + AnnotTextMarkup(PDFDoc *docA, Dict *dict, Object *obj); virtual ~AnnotTextMarkup(); virtual void draw(Gfx *gfx, GBool printing); @@ -911,7 +913,7 @@ public: protected: - void initialize(XRef *xrefA, Catalog *catalog, Dict *dict); + void initialize(PDFDoc *docA, Dict *dict); AnnotQuadrilaterals *quadrilaterals; // QuadPoints }; @@ -923,8 +925,8 @@ protected: class AnnotStamp: public AnnotMarkup { public: - AnnotStamp(XRef *xrefA, PDFRectangle *rect, Catalog *catalog); - AnnotStamp(XRef *xrefA, Dict *dict, Catalog *catalog, Object *obj); + AnnotStamp(PDFDoc *docA, PDFRectangle *rect); + AnnotStamp(PDFDoc *docA, Dict *dict, Object *obj); ~AnnotStamp(); // getters @@ -932,7 +934,7 @@ public: private: - void initialize(XRef *xrefA, Catalog *catalog, Dict *dict); + void initialize(PDFDoc *docA, Dict *dict); GooString *icon; // Name (Default Draft) }; @@ -944,8 +946,8 @@ private: class AnnotGeometry: public AnnotMarkup { public: - AnnotGeometry(XRef *xrefA, PDFRectangle *rect, AnnotSubtype subType, Catalog *catalog); - AnnotGeometry(XRef *xrefA, Dict *dict, Catalog *catalog, Object *obj); + AnnotGeometry(PDFDoc *docA, PDFRectangle *rect, AnnotSubtype subType); + AnnotGeometry(PDFDoc *docA, Dict *dict, Object *obj); ~AnnotGeometry(); virtual void draw(Gfx *gfx, GBool printing); @@ -957,7 +959,7 @@ public: private: - void initialize(XRef *xrefA, Catalog *catalog, Dict *dict); + void initialize(PDFDoc *docA, Dict *dict); AnnotColor *interiorColor; // IC AnnotBorderEffect *borderEffect; // BE @@ -977,9 +979,8 @@ public: polygonDimension // PolygonDimension }; - AnnotPolygon(XRef *xrefA, PDFRectangle *rect, AnnotSubtype subType, - AnnotPath *path, Catalog *catalog); - AnnotPolygon(XRef *xrefA, Dict *dict, Catalog *catalog, Object *obj); + AnnotPolygon(PDFDoc *docA, PDFRectangle *rect, AnnotSubtype subType, AnnotPath *path); + AnnotPolygon(PDFDoc *docA, Dict *dict, Object *obj); ~AnnotPolygon(); // getters @@ -992,7 +993,7 @@ public: private: - void initialize(XRef *xrefA, Catalog *catalog, Dict *dict); + void initialize(PDFDoc *docA, Dict *dict); // required AnnotPath *vertices; // Vertices @@ -1020,8 +1021,8 @@ public: symbolP // P }; - AnnotCaret(XRef *xrefA, PDFRectangle *rect, Catalog *catalog); - AnnotCaret(XRef *xrefA, Dict *dict, Catalog *catalog, Object *obj); + AnnotCaret(PDFDoc *docA, PDFRectangle *rect); + AnnotCaret(PDFDoc *docA, Dict *dict, Object *obj); ~AnnotCaret(); // getters @@ -1030,7 +1031,7 @@ public: private: - void initialize(XRef *xrefA, Catalog *catalog, Dict *dict); + void initialize(PDFDoc *docA, Dict *dict); AnnotCaretSymbol symbol; // Sy (Default None) PDFRectangle *caretRect; // RD (combined with Rect) @@ -1043,8 +1044,8 @@ private: class AnnotInk: public AnnotMarkup { public: - AnnotInk(XRef *xrefA, PDFRectangle *rect, AnnotPath **paths, int n_paths, Catalog *catalog); - AnnotInk(XRef *xrefA, Dict *dict, Catalog *catalog, Object *obj); + AnnotInk(PDFDoc *docA, PDFRectangle *rect, AnnotPath **paths, int n_paths); + AnnotInk(PDFDoc *docA, Dict *dict, Object *obj); ~AnnotInk(); // getters @@ -1053,7 +1054,7 @@ public: private: - void initialize(XRef *xrefA, Catalog *catalog, Dict *dict); + void initialize(PDFDoc *docA, Dict *dict); // required AnnotPath **inkList; // InkList @@ -1071,8 +1072,8 @@ private: class AnnotFileAttachment: public AnnotMarkup { public: - AnnotFileAttachment(XRef *xrefA, PDFRectangle *rect, GooString *filename, Catalog *catalog); - AnnotFileAttachment(XRef *xrefA, Dict *dict, Catalog *catalog, Object *obj); + AnnotFileAttachment(PDFDoc *docA, PDFRectangle *rect, GooString *filename); + AnnotFileAttachment(PDFDoc *docA, Dict *dict, Object *obj); ~AnnotFileAttachment(); virtual void draw(Gfx *gfx, GBool printing); @@ -1083,7 +1084,7 @@ public: private: - void initialize(XRef *xrefA, Catalog *catalog, Dict *dict); + void initialize(PDFDoc *docA, Dict *dict); // required Object file; // FS @@ -1099,8 +1100,8 @@ private: class AnnotSound: public AnnotMarkup { public: - AnnotSound(XRef *xrefA, PDFRectangle *rect, Sound *soundA, Catalog *catalog); - AnnotSound(XRef *xrefA, Dict *dict, Catalog *catalog, Object *obj); + AnnotSound(PDFDoc *docA, PDFRectangle *rect, Sound *soundA); + AnnotSound(PDFDoc *docA, Dict *dict, Object *obj); ~AnnotSound(); virtual void draw(Gfx *gfx, GBool printing); @@ -1111,7 +1112,7 @@ public: private: - void initialize(XRef *xrefA, Catalog *catalog, Dict *dict); + void initialize(PDFDoc *docA, Dict *dict); // required Sound *sound; // Sound @@ -1134,8 +1135,8 @@ public: highlightModePush // P,T }; - AnnotWidget(XRef *xrefA, Dict *dict, Catalog *catalog, Object *obj); - AnnotWidget(XRef *xrefA, Dict *dict, Catalog *catalog, Object *obj, FormField *fieldA); + AnnotWidget(PDFDoc *docA, Dict *dict, Object *obj); + AnnotWidget(PDFDoc *docA, Dict *dict, Object *obj, FormField *fieldA); virtual ~AnnotWidget(); virtual void draw(Gfx *gfx, GBool printing); @@ -1154,7 +1155,7 @@ public: private: - void initialize(XRef *xrefA, Catalog *catalog, Dict *dict); + void initialize(PDFDoc *docA, Dict *dict); void drawText(GooString *text, GooString *da, GfxResources *resources, GBool multiline, int comb, int quadding, @@ -1225,15 +1226,15 @@ class Annot3D: public Annot { }; public: - Annot3D(XRef *xrefA, PDFRectangle *rect, Catalog *catalog); - Annot3D(XRef *xrefA, Dict *dict, Catalog *catalog, Object *obj); + Annot3D(PDFDoc *docA, PDFRectangle *rect); + Annot3D(PDFDoc *docA, Dict *dict, Object *obj); ~Annot3D(); // getters private: - void initialize(XRef *xrefA, Catalog *catalog, Dict *dict); + void initialize(PDFDoc *docA, Dict *dict); Activation *activation; // 3DA }; @@ -1246,7 +1247,7 @@ class Annots { public: // Build a list of Annot objects. - Annots(XRef *xref, Catalog *catalog, Object *annotsObj); + Annots(PDFDoc *docA, Object *annotsObj); ~Annots(); @@ -1256,9 +1257,10 @@ public: void appendAnnot(Annot *annot); private: - Annot* createAnnot(XRef *xref, Dict* dict, Catalog *catalog, Object *obj); + Annot* createAnnot(Dict* dict, Object *obj); Annot *findAnnot(Ref *ref); + PDFDoc *doc; Annot **annots; int nAnnots; int size; diff --git a/poppler/Catalog.cc b/poppler/Catalog.cc index fd418b0..664c421 100644 --- a/poppler/Catalog.cc +++ b/poppler/Catalog.cc @@ -116,11 +116,6 @@ Catalog::Catalog(PDFDoc *docA) { // get the ViewerPreferences dictionary catDict.dictLookup("ViewerPreferences", &viewerPreferences); - - // perform form-related loading after all widgets have been loaded - if (getForm()) - getForm()->postWidgetsLoad(this); - catDict.free(); return; @@ -871,7 +866,9 @@ Form *Catalog::getForm() { if (!form) { if (acroForm.isDict()) { - form = new Form(xref,&acroForm); + form = new Form(doc, &acroForm); + // perform form-related loading after all widgets have been loaded + form->postWidgetsLoad(); } } diff --git a/poppler/Form.cc b/poppler/Form.cc index 80ff935..f2b6604 100644 --- a/poppler/Form.cc +++ b/poppler/Form.cc @@ -34,6 +34,7 @@ #include "Dict.h" #include "Gfx.h" #include "Form.h" +#include "PDFDoc.h" #include "XRef.h" #include "PDFDocEncoding.h" #include "Annot.h" @@ -86,13 +87,13 @@ void FormWidget::print(int indent) { } #endif -void FormWidget::createWidgetAnnotation(Catalog *catalog) { +void FormWidget::createWidgetAnnotation(PDFDoc *docA) { if (widget) return; Object obj1; obj1.initRef(ref.num, ref.gen); - widget = new AnnotWidget(xref, obj.getDict(), catalog, &obj1, field); + widget = new AnnotWidget(docA, obj.getDict(), &obj1, field); obj1.free(); } @@ -612,13 +613,13 @@ void FormField::fillChildrenSiblingsID() } } -void FormField::createWidgetAnnotations(Catalog *catalog) { +void FormField::createWidgetAnnotations(PDFDoc *docA) { if (terminal) { for (int i = 0; i < numChildren; i++) - widgets[i]->createWidgetAnnotation(catalog); + widgets[i]->createWidgetAnnotation(docA); } else { for (int i = 0; i < numChildren; i++) - children[i]->createWidgetAnnotations(catalog); + children[i]->createWidgetAnnotations(docA); } } @@ -1241,11 +1242,12 @@ void FormFieldSignature::print(int indent) // Form //------------------------------------------------------------------------ -Form::Form(XRef *xrefA, Object* acroFormA) +Form::Form(PDFDoc *docA, Object* acroFormA) { Object obj1; - xref = xrefA; + doc = docA; + xref = doc->getXRef(); acroForm = acroFormA; size = 0; @@ -1308,7 +1310,7 @@ Form::Form(XRef *xrefA, Object* acroFormA) } std::set<int> usedParents; - rootFields[numFields++] = createFieldFromDict (&obj2, xrefA, oref.getRef(), NULL, &usedParents); + rootFields[numFields++] = createFieldFromDict (&obj2, xref, oref.getRef(), NULL, &usedParents); obj2.free(); oref.free(); @@ -1394,7 +1396,7 @@ FormField *Form::createFieldFromDict (Object* obj, XRef *xrefA, const Ref& pref, return field; } -void Form::postWidgetsLoad (Catalog *catalog) +void Form::postWidgetsLoad() { // We create the widget annotations associated to // every form widget here, because the AnnotWidget constructor @@ -1402,7 +1404,7 @@ void Form::postWidgetsLoad (Catalog *catalog) // a FormWidget the Catalog is still creating the form object for (int i = 0; i < numFields; i++) { rootFields[i]->fillChildrenSiblingsID(); - rootFields[i]->createWidgetAnnotations(catalog); + rootFields[i]->createWidgetAnnotations(doc); } } diff --git a/poppler/Form.h b/poppler/Form.h index ba802ec..3fb6a4a 100644 --- a/poppler/Form.h +++ b/poppler/Form.h @@ -29,9 +29,9 @@ class Dict; class Annot; class AnnotWidget; class Annots; -class Catalog; class LinkAction; class GfxResources; +class PDFDoc; enum FormFieldType { formButton, @@ -106,7 +106,7 @@ public: // decode id and retrieve pageNum and fieldNum static void decodeID (unsigned id, unsigned* pageNum, unsigned* fieldNum); - void createWidgetAnnotation(Catalog *catalog); + void createWidgetAnnotation(PDFDoc *docA); AnnotWidget *getWidgetAnnotation() const { return widget; } #ifdef DEBUG_FORMS @@ -285,7 +285,7 @@ public: // only implemented in FormFieldButton virtual void fillChildrenSiblingsID (); - void createWidgetAnnotations(Catalog *catalog); + void createWidgetAnnotations(PDFDoc *docA); #ifdef DEBUG_FORMS void printTree(int indent = 0); @@ -489,7 +489,7 @@ public: class Form { public: - Form(XRef *xrefA, Object* acroForm); + Form(PDFDoc *docA, Object* acroForm); ~Form(); @@ -511,11 +511,12 @@ public: FormWidget* findWidgetByRef (Ref aref); - void postWidgetsLoad(Catalog *catalog); + void postWidgetsLoad(); private: FormField** rootFields; int numFields; int size; + PDFDoc *doc; XRef* xref; Object *acroForm; GBool needAppearances; diff --git a/poppler/PSOutputDev.cc b/poppler/PSOutputDev.cc index ae08570..9c9c109 100644 --- a/poppler/PSOutputDev.cc +++ b/poppler/PSOutputDev.cc @@ -1453,7 +1453,7 @@ void PSOutputDev::writeDocSetup(PDFDoc *doc, Catalog *catalog, if ((resDict = page->getResourceDict())) { setupResources(resDict); } - annots = new Annots(xref, catalog, page->getAnnots(&obj1)); + annots = new Annots(doc, page->getAnnots(&obj1)); obj1.free(); for (i = 0; i < annots->getNumAnnots(); ++i) { if (annots->getAnnot(i)->getAppearance(&obj1)->isStream()) { diff --git a/poppler/Page.cc b/poppler/Page.cc index 7c48aad..2650d5c 100644 --- a/poppler/Page.cc +++ b/poppler/Page.cc @@ -349,7 +349,7 @@ Page::~Page() { Annots *Page::getAnnots() { if (!annots) { Object obj; - annots = new Annots(xref, doc->getCatalog(), getAnnots(&obj)); + annots = new Annots(doc, getAnnots(&obj)); obj.free(); } _______________________________________________ poppler mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/poppler
