[apvlv] support for poppler 0.17

Pierre Carrier pcarrier at fedoraproject.org
Mon Aug 1 23:52:04 UTC 2011


commit e570d0008c5a360e42d0faa609e5c9fa78c8c462
Author: Pierre Carrier <pierre at gcarrier.fr>
Date:   Tue Aug 2 03:35:17 2011 +0400

    support for poppler 0.17

 apvlv-poppler015.patch |   20 +++++--
 apvlv-poppler017.patch |  152 ++++++++++++++++++++++++++++++++++++++++++++++++
 apvlv.spec             |    9 ++-
 3 files changed, 172 insertions(+), 9 deletions(-)
---
diff --git a/apvlv-poppler015.patch b/apvlv-poppler015.patch
index 96cb099..bb960df 100644
--- a/apvlv-poppler015.patch
+++ b/apvlv-poppler015.patch
@@ -1,12 +1,20 @@
-diff -aur src/ApvlvFile.cpp.orig src/ApvlvFile.cpp
---- src/ApvlvFile.cpp.orig	2010-09-14 07:28:44.000000000 +0100
-+++ src/ApvlvFile.cpp		2010-10-29 22:29:21.128949529 +0100
-@@ -275,7 +275,7 @@
+diff -up ./src/ApvlvFile.cpp.old ./src/ApvlvFile.cpp
+--- ./src/ApvlvFile.cpp.old	2011-08-02 03:11:15.000000000 +0400
++++ ./src/ApvlvFile.cpp	2011-08-02 03:12:18.000000000 +0400
+@@ -273,9 +273,15 @@ ApvlvPDF::ApvlvPDF (const char *filename
+ 
+   bool ApvlvPDF::pagetext (int pn, int x1, int y1, int x2, int y2, char **out)
    {
-     PopplerRectangle rect = { x1, y1, x2, y2 };
+-    PopplerRectangle rect = { x1, y1, x2, y2 };
      PopplerPage *page = poppler_document_get_page (mDoc, pn);
--    *out = poppler_page_get_text (page, POPPLER_SELECTION_WORD, &rect);
++#if POPPLER_CHECK_VERSION(0, 15, 1)
++    PopplerRectangle rect = { x1, y2, x2, y1 };
 +    *out = poppler_page_get_selected_text (page, POPPLER_SELECTION_WORD, &rect);
++#else
++    PopplerRectangle rect = { x1, y1, x2, y2 };
+     *out = poppler_page_get_text (page, POPPLER_SELECTION_WORD, &rect);
++#endif
++
      if (*out != NULL)
        {
  	return true;
diff --git a/apvlv-poppler017.patch b/apvlv-poppler017.patch
new file mode 100644
index 0000000..7f8b69b
--- /dev/null
+++ b/apvlv-poppler017.patch
@@ -0,0 +1,152 @@
+diff -up ./src/ApvlvFile.cpp.old ./src/ApvlvFile.cpp
+--- ./src/ApvlvFile.cpp.old	2011-08-02 03:14:08.000000000 +0400
++++ ./src/ApvlvFile.cpp	2011-08-02 03:16:32.000000000 +0400
+@@ -28,6 +28,7 @@
+ #include "ApvlvFile.hpp"
+ #include "ApvlvUtil.hpp"
+ #include "ApvlvView.hpp"
++#include "poppler_page_render_to_pixbuf.c"
+ 
+ #include <iostream>
+ #include <fstream>
+
+diff -up /dev/null ./src/poppler_page_render_to_pixbuf.c
+--- ./src/poppler_page_render_to_pixbuf.c.new	2011-08-02 00:58:46.000000000 +0400
++++ ./src/poppler_page_render_to_pixbuf.c	2011-08-02 03:28:02.000000000 +0400
+@@ -0,0 +1,136 @@
++#if POPPLER_CHECK_VERSION(0, 17, 0)
++typedef bool GBool;
++#define gTrue true
++#define gFalse false
++
++static void
++copy_cairo_surface_to_pixbuf (cairo_surface_t *surface,
++			      GdkPixbuf       *pixbuf)
++{
++  int cairo_width, cairo_height, cairo_rowstride;
++  unsigned char *pixbuf_data, *dst, *cairo_data;
++  int pixbuf_rowstride, pixbuf_n_channels;
++  unsigned int *src;
++  int x, y;
++
++  cairo_width = cairo_image_surface_get_width (surface);
++  cairo_height = cairo_image_surface_get_height (surface);
++  cairo_rowstride = cairo_image_surface_get_stride (surface);
++  cairo_data = cairo_image_surface_get_data (surface);
++
++  pixbuf_data = gdk_pixbuf_get_pixels (pixbuf);
++  pixbuf_rowstride = gdk_pixbuf_get_rowstride (pixbuf);
++  pixbuf_n_channels = gdk_pixbuf_get_n_channels (pixbuf);
++
++  if (cairo_width > gdk_pixbuf_get_width (pixbuf))
++    cairo_width = gdk_pixbuf_get_width (pixbuf);
++  if (cairo_height > gdk_pixbuf_get_height (pixbuf))
++    cairo_height = gdk_pixbuf_get_height (pixbuf);
++  for (y = 0; y < cairo_height; y++)
++    {
++      src = (unsigned int *) (cairo_data + y * cairo_rowstride);
++      dst = pixbuf_data + y * pixbuf_rowstride;
++      for (x = 0; x < cairo_width; x++) 
++	{
++	  dst[0] = (*src >> 16) & 0xff;
++	  dst[1] = (*src >> 8) & 0xff; 
++	  dst[2] = (*src >> 0) & 0xff;
++	  if (pixbuf_n_channels == 4)
++	      dst[3] = (*src >> 24) & 0xff;
++	  dst += pixbuf_n_channels;
++	  src++;
++	}
++    }
++}
++
++static void
++_poppler_page_render_to_pixbuf (PopplerPage *page,
++				int src_x, int src_y,
++				int src_width, int src_height,
++				double scale,
++				int rotation,
++				GBool printing,
++				GdkPixbuf *pixbuf)
++{
++  cairo_t *cr;
++  cairo_surface_t *surface;
++
++  surface = cairo_image_surface_create (CAIRO_FORMAT_ARGB32,
++					src_width, src_height);
++  cr = cairo_create (surface);
++  cairo_save (cr);
++  switch (rotation) {
++  case 90:
++	  cairo_translate (cr, src_x + src_width, -src_y);
++	  break;
++  case 180:
++	  cairo_translate (cr, src_x + src_width, src_y + src_height);
++	  break;
++  case 270:
++	  cairo_translate (cr, -src_x, src_y + src_height);
++	  break;
++  default:
++	  cairo_translate (cr, -src_x, -src_y);
++  }
++
++  if (scale != 1.0)
++	  cairo_scale (cr, scale, scale);
++
++  if (rotation != 0)
++	  cairo_rotate (cr, rotation * G_PI / 180.0);
++
++  if (printing)
++	  poppler_page_render_for_printing (page, cr);
++  else
++	  poppler_page_render (page, cr);
++  cairo_restore (cr);
++
++  cairo_set_operator (cr, CAIRO_OPERATOR_DEST_OVER);
++  cairo_set_source_rgb (cr, 1., 1., 1.);
++  cairo_paint (cr);
++
++  cairo_destroy (cr);
++
++  copy_cairo_surface_to_pixbuf (surface, pixbuf);
++  cairo_surface_destroy (surface);
++}
++
++/**
++ * poppler_page_render_to_pixbuf:
++ * @page: the page to render from
++ * @src_x: x coordinate of upper left corner  
++ * @src_y: y coordinate of upper left corner  
++ * @src_width: width of rectangle to render  
++ * @src_height: height of rectangle to render
++ * @scale: scale specified as pixels per point
++ * @rotation: rotate the document by the specified degree
++ * @pixbuf: pixbuf to render into
++ *
++ * First scale the document to match the specified pixels per point,
++ * then render the rectangle given by the upper left corner at
++ * (src_x, src_y) and src_width and src_height.
++ * This function is for rendering a page that will be displayed.
++ * If you want to render a page that will be printed use
++ * poppler_page_render_to_pixbuf_for_printing() instead
++ *
++ * Deprecated: 0.16
++ **/
++void
++poppler_page_render_to_pixbuf (PopplerPage *page,
++			       int src_x, int src_y,
++			       int src_width, int src_height,
++			       double scale,
++			       int rotation,
++			       GdkPixbuf *pixbuf)
++{
++  g_return_if_fail (POPPLER_IS_PAGE (page));
++  g_return_if_fail (scale > 0.0);
++  g_return_if_fail (pixbuf != NULL);
++
++  _poppler_page_render_to_pixbuf (page, src_x, src_y,
++				  src_width, src_height,
++				  scale, rotation,
++				  gFalse,
++				  pixbuf);
++}
++#endif
diff --git a/apvlv.spec b/apvlv.spec
index 65e90e6..8792b8c 100644
--- a/apvlv.spec
+++ b/apvlv.spec
@@ -1,6 +1,6 @@
 Name:		apvlv
 Version:	0.0.9.8
-Release:	4%{?dist}
+Release:	5%{?dist}
 Summary:	PDF viewer which behaves like Vim
 
 Group:		Applications/Publishing
@@ -9,6 +9,7 @@ URL:		http://code.google.com/p/apvlv/
 Source0:	http://%{name}.googlecode.com/files/%{name}-%{version}.tar.gz
 Source1:	%{name}.desktop
 Patch0:		apvlv-poppler015.patch
+Patch1:		apvlv-poppler017.patch
 
 BuildRequires:	gtk2-devel poppler-glib-devel
 # Build-time optional support for DjVu
@@ -22,9 +23,8 @@ It can also browse through directories of such documents.
 %prep
 %setup -q
 chmod -x src/*
-%if 0%{?fedora} >= 15
 %patch0
-%endif
+%patch1
 
 %build
 # Specific options are used for the doc and man paths.
@@ -53,6 +53,9 @@ rm $RPM_BUILD_ROOT/%{_datadir}/%{name}/%{name}rc.example
 %doc %{name}rc.example
 
 %changelog
+* Tue Aug 02 2011 Pierre Carrier <pierre at spotify.com> 0.0.9.8-5
+- Patch for poppler 0.17+
+
 * Sun Mar 13 2011 Marek Kasik <mkasik at redhat.com> - 0.0.9.8-4
 - Rebuild (poppler-0.16.3)
 


More information about the scm-commits mailing list