Follow incompatible API change in poppler-0.16 and fix an old bug in

text selection.
While here, adjust WANTLIB.

Brynet (maintainer) will work on a real update of this port.
This commit is contained in:
kili 2011-06-04 19:05:23 +00:00
parent 6147e12c60
commit 76fe7d65b4
2 changed files with 46 additions and 23 deletions

View File

@ -1,9 +1,9 @@
# $OpenBSD: Makefile,v 1.21 2010/12/06 10:06:48 stsp Exp $
# $OpenBSD: Makefile,v 1.22 2011/06/04 19:05:23 kili Exp $
COMMENT= lightweight PDF document viewer
DISTNAME= epdfview-0.1.7
REVISION= 7
REVISION= 8
CATEGORIES= print
HOMEPAGE= http://trac.emma-soft.com/epdfview/
@ -19,19 +19,19 @@ PERMIT_PACKAGE_FTP= Yes
PERMIT_DISTFILES_CDROM= Yes
PERMIT_DISTFILES_FTP= Yes
WANTLIB+= X11 Xau Xcomposite Xcursor Xdamage Xdmcp Xext Xfixes
WANTLIB+= Xi Xinerama Xrandr Xrender atk-1.0 c cairo expat fontconfig
WANTLIB+= freetype gdk-x11-2.0>=0.14 gdk_pixbuf-2.0>=0.14 gio-2.0 glib-2.0
WANTLIB+= gmodule-2.0 gobject-2.0 gthread-2.0 gtk-x11-2.0>=0.14 m
WANTLIB+= pango-1.0 pangocairo-1.0 pangoft2-1.0 pixman-1 png poppler>=3
WANTLIB+= GL X11 Xau Xcomposite Xcursor Xdamage Xdmcp Xext Xfixes
WANTLIB+= Xi Xinerama Xrandr Xrender Xxf86vm atk-1.0 c cairo drm expat
WANTLIB+= fontconfig freetype gdk-x11-2.0>=0.14 gdk_pixbuf-2.0>=0.14 gio-2.0
WANTLIB+= glib-2.0 gmodule-2.0 gobject-2.0 gthread-2.0 gtk-x11-2.0>=0.14 m
WANTLIB+= pango-1.0 pangocairo-1.0 pangoft2-1.0 pixman-1 png poppler>=10
WANTLIB+= poppler-glib>=3 pthread pthread-stubs stdc++ xcb xcb-render
WANTLIB+= xcb-render-util z
WANTLIB+= xcb-shm z
MODULES= devel/gettext
RUN_DEPENDS= devel/desktop-file-utils
LIB_DEPENDS= x11/gtk+2 \
print/poppler
print/poppler>=0.16
CONFIGURE_STYLE=gnu

View File

@ -1,10 +1,12 @@
$OpenBSD: patch-src_PDFDocument_cxx,v 1.1 2010/01/12 21:45:20 jasper Exp $
$OpenBSD: patch-src_PDFDocument_cxx,v 1.2 2011/06/04 19:05:23 kili Exp $
Fixes error handling, bogus encrypted files, r339.
Fix API breakage introduced with poppler-0.16, and a stupid bug
calculating the value of x2.
--- src/PDFDocument.cxx.orig Sat Feb 28 16:00:35 2009
+++ src/PDFDocument.cxx Tue Dec 29 23:00:29 2009
@@ -246,23 +246,25 @@ PDFDocument::loadFile (const gchar *filename, const gc
--- src/PDFDocument.cxx.orig Sat Feb 28 22:00:35 2009
+++ src/PDFDocument.cxx Sat May 14 12:43:43 2011
@@ -246,24 +246,26 @@ PDFDocument::loadFile (const gchar *filename, const gc
// Check if the document couldn't be opened successfully and why.
if ( NULL == newDocument )
{
@ -16,16 +18,6 @@ Fixes error handling, bogus encrypted files, r339.
+ switch ( loadError->code )
{
- errorCode = DocumentErrorEncrypted;
- }
- else
- {
- // OK, the glib's wrapper don't pass the error code directly
- // from Poppler. Instead returns G_FILE_ERROR_FAILED and a
- // non translated string.
- // Maybe I'm wrong (very probable) but that's a wrong way.
- // So I'm reading the error code from the error string...
- sscanf (loadError->message, "Failed to load document (error %d)",
- (gint *)&errorCode);
+ case POPPLER_ERROR_OPEN_FILE:
+ case POPPLER_ERROR_INVALID:
+ errorCode = DocumentErrorOpenFile;
@ -43,5 +35,36 @@ Fixes error handling, bogus encrypted files, r339.
+ errorCode = DocumentErrorEncrypted;
+ break;
}
- else
- {
- // OK, the glib's wrapper don't pass the error code directly
- // from Poppler. Instead returns G_FILE_ERROR_FAILED and a
- // non translated string.
- // Maybe I'm wrong (very probable) but that's a wrong way.
- // So I'm reading the error code from the error string...
- sscanf (loadError->message, "Failed to load document (error %d)",
- (gint *)&errorCode);
- }
g_error_free (loadError);
// Get our error message.
gchar *errorMessage = IDocument::getErrorMessage (errorCode);
@@ -678,15 +680,14 @@ PDFDocument::setTextSelection (DocumentRectangle *rect
gdouble pageWidth, pageHeight;
poppler_page_get_size(page, &pageWidth, &pageHeight);
- //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())};
+ rect->getY1() / getZoom(),
+ rect->getX2() / getZoom(),
+ rect->getY2() / getZoom()};
repairEmpty(textRect);
#if defined (HAVE_POPPLER_0_6_0)
- gchar *text = poppler_page_get_text(page, POPPLER_SELECTION_GLYPH,
+ gchar *text = poppler_page_get_selected_text(page, POPPLER_SELECTION_GLYPH,
&textRect);
#else // !HAVE_POPPLER_0_6_0
gchar *text = poppler_page_get_text(page, &textRect);