Commit ec52e46e authored by Carlos Garcia Campos's avatar Carlos Garcia Campos

xpdf303: Create annots with a doc instead of xref + catalog

parent ce5e620f
......@@ -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;
......
......@@ -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);
}
......
This diff is collapsed.
This diff is collapsed.
......@@ -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();
}
}
......
......@@ -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);
}
}
......
......@@ -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;
......
......@@ -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()) {
......
......@@ -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();
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment