Code

Added autoconf checks for poppler-cairo and cairo-ft which are needed for PDF preview...
authormiklosh <miklosh@users.sourceforge.net>
Sun, 19 Aug 2007 16:23:36 +0000 (16:23 +0000)
committermiklosh <miklosh@users.sourceforge.net>
Sun, 19 Aug 2007 16:23:36 +0000 (16:23 +0000)
configure.ac
src/extension/internal/pdfinput/pdf-input.cpp
src/extension/internal/pdfinput/pdf-input.h

index 8e063e0ece77e29fdabb7f34532f7a0da3ecf2a0..0210bd507d0d81cc370a434e220b8d4f1c495d5f 100644 (file)
@@ -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
index 75940ff56f2f9ecad8d6c54f2cdde14b7f11bd00..759a84017c81fbe0008aa7de0c40b0cae06457b9 100644 (file)
@@ -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<Gdk::Pixbuf> 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<Gdk::GC>(), 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
 }
 
 ////////////////////////////////////////////////////////////////////////////////
index b7d3de774a600f9ef58498177a6e8735a3dab8bf..6e4388cb176487a28d0498bd1f2f06462b3652de 100644 (file)
@@ -36,7 +36,9 @@
 #include <gdk/gdk.h>
 
 #include "PDFDoc.h"
-#include "CairoOutputDev.h"
+#ifdef HAVE_POPPLER_CAIRO
+#include <CairoOutputDev.h>
+#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
 };