From d8d3dac5fc3fe519b443d22f74258af4aaf48d0c Mon Sep 17 00:00:00 2001 From: jordi Date: Mon, 11 Oct 2010 15:53:47 +0000 Subject: [PATCH 2/3] Added support for poppler's API changes in 0.15.0 by Michal Schmidt. git-svn-id: svn://svn.emma-soft.com/epdfview@354 cb4bfb15-1111-0410-82e2-95233c8f1c7e --- trunk/configure.ac | 16 ++++++++++------ trunk/src/PDFDocument.cxx | 12 +++++++++++- 2 files changed, 21 insertions(+), 7 deletions(-) diff --git a/trunk/configure.ac b/trunk/configure.ac index 7ce0ddc..6cbd0e2 100644 --- a/trunk/configure.ac +++ b/trunk/configure.ac @@ -40,18 +40,22 @@ PKG_CHECK_MODULES([POPPLER], [poppler-glib >= $POPPLER_REQUIRED gdk-2.0 >= $GTK2 AC_SUBST([POPPLER_CFLAGS]) AC_SUBST([POPPLER_LIBS]) dnl Check if we have poppler version 0.5.2 or higher. -PKG_CHECK_EXISTS([poppler-glib >= 0.5.2], [have_poppler_052=yes]) -if test "x$have_poppler_052" = "xyes"; then +PKG_CHECK_EXISTS([poppler-glib >= 0.5.2], [have_poppler_0_5_2=yes]) +if test "x$have_poppler_0_5_2" = "xyes"; then AC_DEFINE([HAVE_POPPLER_0_5_2], [1], [Define to 1 if you have Poppler version 0.5.2 or higher.]) fi -PKG_CHECK_EXISTS([poppler-glib >= 0.6], [have_poppler_060=yes]) -if test "x$have_poppler_060" = "xyes"; then +PKG_CHECK_EXISTS([poppler-glib >= 0.6], [have_poppler_0_6_0=yes]) +if test "x$have_poppler_0_6_0" = "xyes"; then AC_DEFINE([HAVE_POPPLER_0_6_0], [1], [Define to 1 if you have Poppler version 0.6.0 or higher.]) fi -PKG_CHECK_EXISTS([poppler-glib >= 0.8], [have_poppler_080=yes]) -if test "x$have_poppler_080" = "xyes"; then +PKG_CHECK_EXISTS([poppler-glib >= 0.8], [have_poppler_0_8_0=yes]) +if test "x$have_poppler_0_8_0" = "xyes"; then AC_DEFINE([HAVE_POPPLER_0_8_0], [1], [Define to 1 if you have Poppler version 0.8.0 or higher.]) fi +PKG_CHECK_EXISTS([poppler-glib >= 0.15], [have_poppler_0_15_0=yes]) +if test "x$have_poppler_0_15_0" = "xyes"; then + AC_DEFINE([HAVE_POPPLER_0_15_0], [1], [Define to 1 if you have Poppler version 0.15.0 or higher.]) +fi EPDFVIEW_PATH_CUPS([CUPS], [have_cups=yes]) AM_CONDITIONAL(cups_printing, test "x$have_cups" = "xyes") diff --git a/trunk/src/PDFDocument.cxx b/trunk/src/PDFDocument.cxx index 6567e9b..a590a20 100644 --- a/trunk/src/PDFDocument.cxx +++ b/trunk/src/PDFDocument.cxx @@ -678,14 +678,24 @@ PDFDocument::setTextSelection (DocumentRectangle *rect) gdouble pageWidth, pageHeight; poppler_page_get_size(page, &pageWidth, &pageHeight); +#if defined (HAVE_POPPLER_0_15_0) + PopplerRectangle textRect = { rect->getX1() / getZoom(), + rect->getY1() / getZoom(), + rect->getX2() / getZoom(), + rect->getY2() / getZoom()}; +#else // !HAVE_POPPLER_0_15_0 //for get text we must exchange y coordinate, don't ask me where logic here. PopplerRectangle textRect = { rect->getX1() / getZoom(), (pageHeight - rect->getY2() / getZoom()), rect->getX2() * getZoom() / getZoom(), (pageHeight - rect->getY1() / getZoom())}; +#endif // HAVE_POPPLER_0_15_0 repairEmpty(textRect); -#if defined (HAVE_POPPLER_0_6_0) +#if defined (HAVE_POPPLER_0_15_0) + gchar *text = poppler_page_get_selected_text(page, POPPLER_SELECTION_GLYPH, + &textRect); +#elif defined (HAVE_POPPLER_0_6_0) gchar *text = poppler_page_get_text(page, POPPLER_SELECTION_GLYPH, &textRect); #else // !HAVE_POPPLER_0_6_0 -- 1.7.4