From: miklosh Date: Sun, 19 Aug 2007 16:23:36 +0000 (+0000) Subject: Added autoconf checks for poppler-cairo and cairo-ft which are needed for PDF preview... X-Git-Url: https://git.tokkee.org/?a=commitdiff_plain;h=94f60477a78a3372ef321871523c0739bff29388;p=inkscape.git Added autoconf checks for poppler-cairo and cairo-ft which are needed for PDF preview to work --- diff --git a/configure.ac b/configure.ac index 8e063e0ec..0210bd507 100644 --- a/configure.ac +++ b/configure.ac @@ -499,13 +499,13 @@ dnl Libpoppler checking dnl ****************************** POPPLER_CFLAGS="" -PKG_CHECK_MODULES(POPPLER, poppler >= 0.5.5, poppler=yes, poppler=no) +PKG_CHECK_MODULES(POPPLER, poppler >= 0.5.9, poppler=yes, poppler=no) if test "x$poppler" = "xyes"; then dnl Working libpoppler POPPLER_LIBS="-lpoppler " dnl Have to test libpoppler-glib presence - PKG_CHECK_MODULES(POPPLER_GLIB, poppler-glib >= 0.5.5, poppler_glib=yes, poppler_glib=no) + PKG_CHECK_MODULES(POPPLER_GLIB, poppler-glib >= 0.5.9, poppler_glib=yes, poppler_glib=no) if test "x$poppler_glib" = "xyes"; then dnl Working libpoppler-glib found dnl Check whether the Cairo SVG backend is available @@ -514,12 +514,22 @@ if test "x$poppler" = "xyes"; then POPPLER_LIBS="$POPPLER_LIBS -lpoppler-glib " fi fi + dnl Have to test libpoppler-cairo presence for PDF preview + PKG_CHECK_MODULES(POPPLER_CAIRO, poppler-cairo >= 0.5.9, poppler_cairo=yes, poppler_cairo=no) + if test "x$poppler_cairo" = "xyes"; then + dnl Working libpoppler-cairo found + dnl Check whether the Cairo FreeType backend is available + PKG_CHECK_MODULES(CAIRO_FT, cairo-ft, cairo_ft=yes, cairo_ft=no) + fi fi if test "x$poppler" = "xyes"; then LIBS="$LIBS $POPPLER_LIBS" AC_DEFINE(HAVE_POPPLER, 1, [Use libpoppler for direct PDF import]) fi +if test "x$cairo_ft" = "xyes"; then + AC_DEFINE(HAVE_POPPLER_CAIRO, 1, [Use libpoppler-cairo for rendering PDF preview]) +fi if test "x$poppler_glib" = "xyes" -a "x$cairo_svg" = "xyes"; then AC_DEFINE(HAVE_POPPLER_GLIB, 1, [Use libpoppler-glib and Cairo-SVG for PDF import]) fi diff --git a/src/extension/internal/pdfinput/pdf-input.cpp b/src/extension/internal/pdfinput/pdf-input.cpp index 75940ff56..759a84017 100644 --- a/src/extension/internal/pdfinput/pdf-input.cpp +++ b/src/extension/internal/pdfinput/pdf-input.cpp @@ -243,9 +243,12 @@ PdfImportDialog::PdfImportDialog(PDFDoc *doc) _cropCheck->signal_toggled().connect(sigc::mem_fun(*this, &PdfImportDialog::_onToggleCropping)); _fallbackPrecisionSlider_adj->signal_value_changed().connect(sigc::mem_fun(*this, &PdfImportDialog::_onPrecisionChanged)); +#ifdef HAVE_POPPLER_CAIRO // Create an OutputDev _preview_output_dev = new CairoOutputDev(); _preview_output_dev->startDoc(_pdf_doc->getXRef()); + _cairo_surface = NULL; +#endif // Set default preview size _preview_width = 200; @@ -253,17 +256,18 @@ PdfImportDialog::PdfImportDialog(PDFDoc *doc) // Init preview _thumb_data = NULL; - _cairo_surface = NULL; _pageNumberSpin_adj->set_value(1.0); } PdfImportDialog::~PdfImportDialog() { +#ifdef HAVE_POPPLER_CAIRO if (_preview_output_dev) { delete _preview_output_dev; } if (_cairo_surface) { cairo_surface_destroy(_cairo_surface); } +#endif if (_thumb_data) { delete _thumb_data; } @@ -344,6 +348,7 @@ void PdfImportDialog::_onPageNumberChanged() { _setPreviewPage(_current_page); } +#ifdef HAVE_POPPLER_CAIRO /** * \brief Copies image data from a Cairo surface to a pixbuf * @@ -390,12 +395,14 @@ static void copy_cairo_surface_to_pixbuf (cairo_surface_t *surface, } } } +#endif /** * \brief Updates the preview area with the previously rendered thumbnail */ bool PdfImportDialog::_onExposePreview(GdkEventExpose *event) { +#ifdef HAVE_POPPLER_CAIRO Glib::RefPtr thumb = Gdk::Pixbuf::create(Gdk::COLORSPACE_RGB, true, 8, _thumb_width, _thumb_height); // Set background to white @@ -413,6 +420,7 @@ bool PdfImportDialog::_onExposePreview(GdkEventExpose *event) { _previewArea->get_window()->draw_pixbuf(Glib::RefPtr(), thumb, 0, 0, 0, 0, -1, -1, Gdk::RGB_DITHER_NONE, 0, 0); +#endif return true; } @@ -422,6 +430,7 @@ bool PdfImportDialog::_onExposePreview(GdkEventExpose *event) { */ void PdfImportDialog::_setPreviewPage(int page) { +#ifdef HAVE_POPPLER_CAIRO _previewed_page = _pdf_doc->getCatalog()->getPage(page); // TODO: When available, obtain the thumbnail from the PDF document itself // Get page size by accounting for rotation @@ -470,6 +479,7 @@ void PdfImportDialog::_setPreviewPage(int page) { // Redraw preview area _previewArea->set_size_request(_preview_width, _preview_height); _previewArea->queue_draw(); +#endif } //////////////////////////////////////////////////////////////////////////////// diff --git a/src/extension/internal/pdfinput/pdf-input.h b/src/extension/internal/pdfinput/pdf-input.h index b7d3de774..6e4388cb1 100644 --- a/src/extension/internal/pdfinput/pdf-input.h +++ b/src/extension/internal/pdfinput/pdf-input.h @@ -36,7 +36,9 @@ #include #include "PDFDoc.h" -#include "CairoOutputDev.h" +#ifdef HAVE_POPPLER_CAIRO +#include +#endif namespace Inkscape { namespace Extension { @@ -96,8 +98,10 @@ private: unsigned char *_thumb_data; // Thumbnail image data int _thumb_width, _thumb_height; // Thumbnail size int _preview_width, _preview_height; // Size of the preview area +#ifdef HAVE_POPPLER_CAIRO cairo_surface_t *_cairo_surface; CairoOutputDev *_preview_output_dev; +#endif };