? qt4/src/poppler-form.loT ? qt4/src/poppler-page.loT Index: glib/poppler-document.cc =================================================================== RCS file: /cvs/poppler/poppler/glib/poppler-document.cc,v retrieving revision 1.41 diff -r1.41 poppler-document.cc 1410c1410,1421 < FormWidget *field = catalog->getPage(pageNum)->getPageWidgets()->getWidget(fieldNum); --- > if (pageNum > catalog->getNumPages()) { > g_warning("_get_form_widget_by_id : pageNum(%i) > catalog num pages", pageNum); > return NULL; > } > > FormPageWidgets* widgets = catalog->getPage(pageNum)->getPageWidgets(); > if (fieldNum > widgets->getNumWidgets()) { > g_warning("_get_form_widget_by_id : fieldNum(%i) > widgets num widgets", fieldNum); > return NULL; > } > > FormWidget *field = widgets->getWidget(fieldNum); 1416a1428,1530 > unsigned > _get_page_num_by_id (PopplerDocument *document, unsigned id) > { > unsigned pageNum; > unsigned fieldNum; > FormWidget::decodeID(id, &pageNum, &fieldNum); > return pageNum; > } > > Page* > _get_page_by_id (PopplerDocument *document, unsigned id) > { > Catalog *catalog = document->doc->getCatalog(); > unsigned pageNum; > unsigned fieldNum; > FormWidget::decodeID(id, &pageNum, &fieldNum); > return catalog->getPage(pageNum); > } > > #ifdef HAVE_CAIRO > void > poppler_document_render_form_field (PopplerDocument *document, unsigned id, cairo_t *cairo) > { > CairoOutputDev *output_dev; > Catalog *catalog = document->doc->getCatalog(); > Gfx *gfx; > FormWidget *field = _get_form_widget_by_id(document, id); > Page *page = _get_page_by_id(document, id); > PDFRectangle cropBox; > > cairo_t* cairo_save; > > output_dev = document->output_dev; > cairo_save = output_dev->getCairo(); > output_dev->setCairo (cairo, false); > > field->getRect(&cropBox.x1, &cropBox.y1, &cropBox.x2, &cropBox.y2); > > gfx = new Gfx(field->getXRef(), output_dev, _get_page_num_by_id(document, id), > page->getResourceDict(), 72.0, 72.0,&cropBox, &cropBox, > /*rotate*/0); > > //RENDER FormWidget::obj > // double xMin, yMin, xMax, yMax; > // field->getRect(&xMin, &yMin, &xMax, &yMax); > //FIXME: call Annot::draw instead of this since the obj given as parameter > // is the appearance stream and not the annot's dict > // This require to map Annot to Widget > // gfx->doAnnot(field->getObj(), xMin, yMin, xMax, yMax); > field->draw(gfx, catalog); > delete gfx; > output_dev->setCairo(cairo_save, false); > } > > cairo_font_face_t* > poppler_document_get_form_field_font_face (PopplerDocument *document, > unsigned id) > { > FormWidget *widget = _get_form_widget_by_id(document, id); > if (widget) { > if (!widget->getCairoFont()) { > g_warning("poppler_document_get_form_widget_font_face, no font face for widget with id %i\n", id); > return NULL; > } > return widget->getCairoFont()->getFontFace(); > } else { > g_warning("poppler_document_get_form_widget_font_face, unknown id: %i\n", id); > return NULL; > } > } > > unsigned long > poppler_document_get_form_field_glyph (PopplerDocument *document, > unsigned id, > unsigned int char_code) > { > FormWidget *field = _get_form_widget_by_id(document, id); > if (field) > return field->getCairoFont()->getGlyph(char_code, NULL, 0); > else { > g_warning("poppler_document_get_form_field_font_face, unknown id: %i\n", id); > return NULL; > } > } > #endif > > > > > void > poppler_document_get_form_field_rect (PopplerDocument *document, > unsigned id, > double *xMin, double *yMin, > double *xMax, double *yMax) > { > FormWidget *field = _get_form_widget_by_id(document, id); > if (field) > field->getRect(xMin, yMin, xMax, yMax); > else > g_warning("poppler_document_get_form_field_rect, unknown id: %i", id); > } > > Index: glib/poppler-document.h =================================================================== RCS file: /cvs/poppler/poppler/glib/poppler-document.h,v retrieving revision 1.23 diff -r1.23 poppler-document.h 24a25,31 > #include "poppler-features.h" > > #ifdef POPPLER_HAS_CAIRO > #include > #include > #endif > 115a123,142 > #ifdef POPPLER_HAS_CAIRO > void poppler_document_render_form_field (PopplerDocument *document, > unsigned id, > cairo_t *cairo); > cairo_font_face_t* > poppler_document_get_form_field_font_face (PopplerDocument *document, > unsigned id); > > unsigned long > poppler_document_get_form_field_glyph (PopplerDocument *document, > unsigned id, > unsigned int char_code); > > #endif > void > poppler_document_get_form_field_rect (PopplerDocument *document, > unsigned id, > double *xMin, double *yMin, > double *xMax, double *yMax); > Index: glib/poppler-page.cc =================================================================== RCS file: /cvs/poppler/poppler/glib/poppler-page.cc,v retrieving revision 1.54 diff -r1.54 poppler-page.cc 1098c1098,1102 < poppler_field->button.state = (gboolean)static_cast(field)->getState(); --- > FormWidgetButton* wid = static_cast(field); > poppler_field->button.state = (gboolean)wid->getState(); > poppler_field->button.check = (wid->getButtonType() == formButtonCheck); > poppler_field->button.push = (wid->getButtonType() == formButtonPush); > poppler_field->button.radio = (wid->getButtonType() == formButtonRadio); Index: glib/poppler-page.h =================================================================== RCS file: /cvs/poppler/poppler/glib/poppler-page.h,v retrieving revision 1.23 diff -r1.23 poppler-page.h 139a140,142 > char check:1; > char push:1; > char radio:1; Index: poppler/Annot.cc =================================================================== RCS file: /cvs/poppler/poppler/poppler/Annot.cc,v retrieving revision 1.9 diff -r1.9 Annot.cc 32c32 < Annot::Annot(XRef *xrefA, Dict *acroForm, Dict *dict, const Ref& aref, Catalog* catalog) --- > Annot::Annot(XRef *xrefA, Dict *acroForm, Dict *dict, const Ref& aref, Catalog* catalog, bool forceAppGeneration) 36c36 < initialize (xrefA, acroForm, dict, catalog); --- > initialize (xrefA, acroForm, dict, catalog, forceAppGeneration); 39c39 < Annot::Annot(XRef *xrefA, Dict *acroForm, Dict *dict, Catalog* catalog) { --- > Annot::Annot(XRef *xrefA, Dict *acroForm, Dict *dict, Catalog* catalog, bool forceAppGeneration) { 41c41 < initialize (xrefA, acroForm, dict, catalog); --- > initialize (xrefA, acroForm, dict, catalog, forceAppGeneration); 44c44 < void Annot::initialize(XRef *xrefA, Dict *acroForm, Dict *dict, Catalog *catalog) { --- > void Annot::initialize(XRef *xrefA, Dict *acroForm, Dict *dict, Catalog *catalog, bool forceAppGeneration) { 52a53 > font = NULL; 97a99 > //FIXME: force appearance regen ? 116c118 < isTextField = false; --- > isTextField = forceAppGeneration; 177a180,181 > if (font) > delete font; 255c259 < GfxFont *font = NULL; --- > //GfxFont *font = NULL; 371c375,376 < font = GfxFont::makeFont(xref, "temp", r, obj3.getDict()); --- > if (!font) > font = GfxFont::makeFont(xref, "temp", r, obj3.getDict()); 473d477 < if (font) delete font; 477a482 > printf("Annot : Min(%f, %f), Max(%f, %f) \n", xMin, yMin, xMax, yMax); 479c484 < gfx->doAnnot(&obj, xMin, yMin, xMax, yMax); --- > gfx->doAnnot(&obj, xMin, yMin, xMax, yMax); Index: poppler/Annot.h =================================================================== RCS file: /cvs/poppler/poppler/poppler/Annot.h,v retrieving revision 1.5 diff -r1.5 Annot.h 30,31c30,31 < Annot(XRef *xrefA, Dict *acroForm, Dict *dict, Catalog *catalog); < Annot(XRef *xrefA, Dict *acroForm, Dict *dict, const Ref& aref, Catalog *catalog); --- > Annot(XRef *xrefA, Dict *acroForm, Dict *dict, Catalog *catalog, bool forceAppGeneration = false); > Annot(XRef *xrefA, Dict *acroForm, Dict *dict, const Ref& aref, Catalog *catalog, bool forceAppGeneration=false); 45a46,47 > GfxFont* getFont() { return font; } > 51c53 < void initialize (XRef *xrefA, Dict *acroForm, Dict *dict, Catalog *catalog); --- > void initialize (XRef *xrefA, Dict *acroForm, Dict *dict, Catalog *catalog, bool forceAppGeneration); 59a62 > GfxFont *font; Index: poppler/CairoOutputDev.cc =================================================================== RCS file: /cvs/poppler/poppler/poppler/CairoOutputDev.cc,v retrieving revision 1.48 diff -r1.48 CairoOutputDev.cc 76c76 < void CairoOutputDev::setCairo(cairo_t *cairo) --- > void CairoOutputDev::setCairo(cairo_t *cairo, bool destroyCurrent) 78c78 < if (this->cairo != NULL) --- > if (this->cairo != NULL && destroyCurrent) Index: poppler/CairoOutputDev.h =================================================================== RCS file: /cvs/poppler/poppler/poppler/CairoOutputDev.h,v retrieving revision 1.17 diff -r1.17 CairoOutputDev.h 148c148,149 < void setCairo (cairo_t *cr); --- > void setCairo (cairo_t *cr, bool destroyCurrent = true); > cairo_t* getCairo () { return cairo; } Index: poppler/Form.cc =================================================================== RCS file: /cvs/poppler/poppler/poppler/Form.cc,v retrieving revision 1.3 diff -r1.3 Form.cc 63a64,69 > #ifdef HAVE_CAIRO > cairoFont = NULL; > FT_Init_FreeType(&ft_lib); > cairoFontEngine = new CairoFontEngine(ft_lib); > #endif > 123a130,135 > #ifdef HAVE_CAIRO > FT_Done_FreeType(ft_lib); > delete cairoFontEngine; > if (cairoFont) delete cairoFont; > #endif > } 124a137,142 > void FormWidget::getRect(double *xa1, double *ya1, double *xa2, double *ya2) > { > *xa1 = x1; > *ya1 = y1; > *xa2 = x2; > *ya2 = y2; 137a156,184 > void FormWidget::draw (Gfx *gfx, Catalog *catalog) > { > Dict *acroForm = catalog->getAcroForm()->isDict() ? > catalog->getAcroForm()->getDict() : NULL; > > if (!obj.isDict()) { > printf("FormWidget::draw not dict\n"); > return; > > } > Annot *annot = new Annot(xref, acroForm, obj.getDict(), ref, catalog); > annot->draw(gfx); > delete annot; > } > > void FormWidget::loadFont (GfxFont *font) > { > #ifdef HAVE_CAIRO > loadCairoFont(font); > #endif > } > > #ifdef HAVE_CAIRO > void FormWidget::loadCairoFont (GfxFont *font) > { > cairoFont = cairoFontEngine->getFont(font, xref); > } > #endif > 182a230,235 > FormButtonType FormWidgetButton::getButtonType() const > { > return parent->getButtonType(); > } > > 1028c1081 < Form::Form(XRef *xrefA, Object* acroForm) --- > Form::Form(XRef *xrefA, Object* aacroForm) 1031a1085 > acroForm = aacroForm; 1168c1222,1226 < Annot* ann = new Annot(xref, NULL ,obj2.getDict(), NULL); --- > Dict* acForm = NULL; > if (form->getAcroForm() && form->getAcroForm()->isDict()) { > acForm = form->getAcroForm()->getDict(); > } > Annot* ann = new Annot(xref, acForm ,obj2.getDict(), NULL, true); 1169a1228,1230 > //why doesn't any annot have a font ? > if (ann->getFont()) > tmp->loadFont(ann->getFont()); Index: poppler/Form.h =================================================================== RCS file: /cvs/poppler/poppler/poppler/Form.h,v retrieving revision 1.2 diff -r1.2 Form.h 15a16 > #include 16a18 > #include "Gfx.h" 17a20,22 > #ifdef HAVE_CAIRO > #include "CairoFontEngine.h" > #endif 65,66c70 < void getRect(double *xa1, double *ya1, double *xa2, double *ya2) < { *xa1 = x1; *ya1 = y1; *xa2 = x2; *ya2 = y2; } --- > void getRect(double *xa1, double *ya1, double *xa2, double *ya2); 73a78 > XRef* getXRef() { return xref; } 88a94,101 > > //draw the widget using its annotation > void draw (Gfx *gfx, Catalog *catalog); > void loadFont (GfxFont *font); > #ifdef HAVE_CAIRO > CairoFont* getCairoFont () { return cairoFont; } > void loadCairoFont (GfxFont *font); > #endif 114c127,131 < --- > #ifdef HAVE_CAIRO > CairoFontEngine *cairoFontEngine; > CairoFont *cairoFont; > FT_Library ft_lib; > #endif 125a143 > FormButtonType getButtonType () const; 425c443 < Form(XRef *xrefA, Object* acroForm); --- > Form(XRef *xrefA, Object* aacroForm); 433a452,453 > Object* getAcroForm () { return acroForm; } > 445c465 < Catalog* catalog; --- > Object *acroForm; Index: poppler/poppler-config.h.in =================================================================== RCS file: /cvs/poppler/poppler/poppler/poppler-config.h.in,v retrieving revision 1.5 diff -r1.5 poppler-config.h.in 16a17,20 > #ifndef HAVE_CAIRO > #undef HAVE_CAIRO > #endif > Index: qt/Makefile.am =================================================================== RCS file: /cvs/poppler/poppler/qt/Makefile.am,v retrieving revision 1.15 diff -r1.15 Makefile.am 3a4 > $(CAIRO_CFLAGS) \ 27a29 > $(top_builddir)/poppler/libpoppler-cairo.la \ 30c32 < $(FONTCONFIG_LIBS) --- > $(FONTCONFIG_LIBS) 45a48 > $(top_builddir)/poppler/libpoppler-cairo.la \ 47c50 < $(FREETYPE_LIBS) --- > $(FREETYPE_LIBS) Index: test/Makefile.am =================================================================== RCS file: /cvs/poppler/poppler/test/Makefile.am,v retrieving revision 1.8 diff -r1.8 Makefile.am 8a9 > $(CAIRO_CFLAGS) \ 45a47 > $(top_builddir)/poppler/libpoppler-cairo.la \ Index: utils/Makefile.am =================================================================== RCS file: /cvs/poppler/poppler/utils/Makefile.am,v retrieving revision 1.10 diff -r1.10 Makefile.am 21a22 > $(top_builddir)/poppler/libpoppler-cairo.la \ 24a26,33 > if BUILD_CAIRO_OUTPUT > LDADD = \ > $(top_builddir)/poppler/libpoppler.la \ > $(CAIRO_LIBS) \ > $(UTILS_LIBS) \ > $(FONTCONFIG_LIBS) > endif >