1
0
mirror of https://github.com/pdf2htmlEX/pdf2htmlEX.git synced 2024-12-22 04:50:09 +00:00

Merge pull request #32 from stephengaito/master

update pdf2htmlEX source to work with poppler-0.76.0
This commit is contained in:
stephengaito 2019-09-26 16:19:01 +01:00 committed by GitHub
commit a37f755caf
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 24 additions and 25 deletions

View File

@ -17,7 +17,7 @@
// Copyright (C) 2005-2007 Jeff Muizelaar <jeff@infidigm.net>
// Copyright (C) 2005, 2006 Kristian Høgsberg <krh@redhat.com>
// Copyright (C) 2005 Martin Kretzschmar <martink@gnome.org>
// Copyright (C) 2005, 2009, 2012, 2013, 2015, 2017, 2018 Albert Astals Cid <aacid@kde.org>
// Copyright (C) 2005, 2009, 2012, 2013, 2015, 2017-2019 Albert Astals Cid <aacid@kde.org>
// Copyright (C) 2006, 2007, 2010, 2011 Carlos Garcia Campos <carlosgc@gnome.org>
// Copyright (C) 2007 Koji Otani <sho@bbr.jp>
// Copyright (C) 2008, 2009 Chris Wilson <chris@chris-wilson.co.uk>
@ -80,7 +80,7 @@ CairoFont::~CairoFont() {
bool
CairoFont::matches(Ref &other, bool printingA) {
return (other.num == ref.num && other.gen == ref.gen);
return (other == ref);
}
cairo_font_face_t *
@ -783,7 +783,7 @@ CairoType3Font::~CairoType3Font() { }
bool
CairoType3Font::matches(Ref &other, bool printingA) {
return (other.num == ref.num && other.gen == ref.gen && printing == printingA);
return (other == ref && printing == printingA);
}

View File

@ -34,6 +34,7 @@
// Copyright (C) 2012, 2017 Adrian Johnson <ajohnson@redneon.com>
// Copyright (C) 2018 Adam Reichold <adam.reichold@t-online.de>
// Copyright (C) 2019 Albert Astals Cid <aacid@kde.org>
// Copyright (C) 2019 Marek Kasik <mkasik@redhat.com>
//
// To see a description of the changes please see the Changelog file that
// came with your tarball or type make ChangeLog if you are building from git
@ -61,7 +62,7 @@
static void downsample_row_box_filter (
int start, int width,
uint32_t *src, uint32_t *dest,
uint32_t *src, uint32_t *src_limit, uint32_t *dest,
int coverage[], int pixel_coverage)
{
/* we need an array of the pixel contribution of each destination pixel on the boundaries.
@ -89,13 +90,13 @@ static void downsample_row_box_filter (
/* skip to start */
/* XXX: it might be possible to do this directly instead of iteratively, however
* the iterative solution is simple */
while (x < start)
while (x < start && src < src_limit)
{
int box = 1 << FIXED_SHIFT;
int start_coverage = coverage[x];
box -= start_coverage;
src++;
while (box >= pixel_coverage)
while (box >= pixel_coverage && src < src_limit)
{
src++;
box -= pixel_coverage;
@ -103,7 +104,7 @@ static void downsample_row_box_filter (
x++;
}
while (x < start + width)
while (x < start + width && src < src_limit)
{
uint32_t a = 0;
uint32_t r = 0;
@ -120,7 +121,7 @@ static void downsample_row_box_filter (
x++;
box -= start_coverage;
while (box >= pixel_coverage)
while (box >= pixel_coverage && src < src_limit)
{
a += ((*src >> 24) & 0xff) * pixel_coverage;
r += ((*src >> 16) & 0xff) * pixel_coverage;
@ -134,7 +135,7 @@ static void downsample_row_box_filter (
/* multiply by whatever is leftover
* this ensures that we don't bias down.
* i.e. start_coverage + n*pixel_coverage + box == 1 << 24 */
if (box > 0)
if (box > 0 && src < src_limit)
{
a += ((*src >> 24) & 0xff) * box;
r += ((*src >> 16) & 0xff) * box;
@ -226,10 +227,10 @@ static int compute_coverage (int coverage[], int src_length, int dest_length)
/* I have a proof of this, which this margin is too narrow to contain */
for (i=0; i<dest_length; i++)
{
float left_side = i*scale;
float right_side = (i+1)*scale;
float right_fract = right_side - floor (right_side);
float left_fract = ceil (left_side) - left_side;
double left_side = i*scale;
double right_side = (i+1)*scale;
double right_fract = right_side - floor (right_side);
double left_fract = ceil (left_side) - left_side;
int overage;
/* find out how many source pixels will be used to fill the box */
int count = floor (right_side) - ceil (left_side);
@ -336,7 +337,7 @@ bool CairoRescaleBox::downScaleImage(unsigned orig_width, unsigned orig_height,
int start_coverage_y = y_coverage[dest_y];
getRow(src_y, scanline);
downsample_row_box_filter (start_column, width, scanline, temp_buf + width * columns, x_coverage, pixel_coverage_x);
downsample_row_box_filter (start_column, width, scanline, scanline + orig_width, temp_buf + width * columns, x_coverage, pixel_coverage_x);
columns++;
src_y++;
box -= start_coverage_y;
@ -344,7 +345,7 @@ bool CairoRescaleBox::downScaleImage(unsigned orig_width, unsigned orig_height,
while (box >= pixel_coverage_y)
{
getRow(src_y, scanline);
downsample_row_box_filter (start_column, width, scanline, temp_buf + width * columns, x_coverage, pixel_coverage_x);
downsample_row_box_filter (start_column, width, scanline, scanline + orig_width, temp_buf + width * columns, x_coverage, pixel_coverage_x);
columns++;
src_y++;
box -= pixel_coverage_y;
@ -354,7 +355,7 @@ bool CairoRescaleBox::downScaleImage(unsigned orig_width, unsigned orig_height,
if (box > 0)
{
getRow(src_y, scanline);
downsample_row_box_filter (start_column, width, scanline, temp_buf + width * columns, x_coverage, pixel_coverage_x);
downsample_row_box_filter (start_column, width, scanline, scanline + orig_width, temp_buf + width * columns, x_coverage, pixel_coverage_x);
columns++;
}

View File

@ -16,6 +16,7 @@
#include <GfxState.h>
#include <Stream.h>
#include <PDFDoc.h>
#include <Outline.h>
/************ from goo/gtypes.h ***************/
// #include <goo/gtypes.h>
@ -197,7 +198,7 @@ protected:
void post_process(void);
void process_outline(void);
void process_outline_items(const GooList * items);
void process_outline_items(const std::vector<OutlineItem*> * items);
void process_form(std::ofstream & out);

View File

@ -40,7 +40,7 @@ static string get_linkdest_detail_str(LinkDest * dest, Catalog * catalog, int &
if(dest->isPageRef())
{
auto pageref = dest->getPageRef();
pageno = catalog->findPage(pageref.num, pageref.gen);
pageno = catalog->findPage(pageref);
}
else
{

View File

@ -9,9 +9,6 @@
#include <iostream>
#include <Outline.h>
#include <goo/GooList.h>
#include "HTMLRenderer.h"
#include "util/namespace.h"
#include "util/encoding.h"
@ -21,16 +18,16 @@ namespace pdf2htmlEX {
using std::ostream;
void HTMLRenderer::process_outline_items(const GooList * items)
void HTMLRenderer::process_outline_items(const std::vector<OutlineItem*> * items)
{
if((!items) || (items->getLength() == 0))
if((!items) || (items->size() == 0))
return;
f_outline.fs << "<ul>";
for(int i = 0; i < items->getLength(); ++i)
for(std::size_t i = 0; i < items->size(); ++i)
{
OutlineItem * item = (OutlineItem*)(items->get(i));
OutlineItem * item = items->at(i);
string detail;
string dest = get_linkaction_str(item->getAction(), detail);