1
0
mirror of https://github.com/pdf2htmlEX/pdf2htmlEX.git synced 2024-12-22 13:00:08 +00:00

Merge pull request #29 from stephengaito/update2poppler0_68_0ubuntu18_10

Update to poppler-0.68.0 on Ubuntu18 10
This commit is contained in:
stephengaito 2019-09-20 06:31:54 +01:00 committed by GitHub
commit b6a4ef9b40
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
16 changed files with 237 additions and 202 deletions

1
.gitignore vendored
View File

@ -22,4 +22,5 @@ test export-ignore
Testing/* Testing/*
DartConfiguration.tcl DartConfiguration.tcl
test/test.py test/test.py
*.swp

View File

@ -17,7 +17,7 @@
// Copyright (C) 2005-2007 Jeff Muizelaar <jeff@infidigm.net> // Copyright (C) 2005-2007 Jeff Muizelaar <jeff@infidigm.net>
// Copyright (C) 2005, 2006 Kristian Høgsberg <krh@redhat.com> // Copyright (C) 2005, 2006 Kristian Høgsberg <krh@redhat.com>
// Copyright (C) 2005 Martin Kretzschmar <martink@gnome.org> // Copyright (C) 2005 Martin Kretzschmar <martink@gnome.org>
// Copyright (C) 2005, 2009, 2012, 2013, 2015, 2017 Albert Astals Cid <aacid@kde.org> // Copyright (C) 2005, 2009, 2012, 2013, 2015, 2017, 2018 Albert Astals Cid <aacid@kde.org>
// Copyright (C) 2006, 2007, 2010, 2011 Carlos Garcia Campos <carlosgc@gnome.org> // Copyright (C) 2006, 2007, 2010, 2011 Carlos Garcia Campos <carlosgc@gnome.org>
// Copyright (C) 2007 Koji Otani <sho@bbr.jp> // Copyright (C) 2007 Koji Otani <sho@bbr.jp>
// Copyright (C) 2008, 2009 Chris Wilson <chris@chris-wilson.co.uk> // Copyright (C) 2008, 2009 Chris Wilson <chris@chris-wilson.co.uk>
@ -34,16 +34,6 @@
// //
//======================================================================== //========================================================================
//========================================================================
//
// Copied from Ubuntu 18.04 apt-get source poppler (poppler-0.62.0)
// Copied on 2019/March/26
// Copied by Stephen Gaito in order to update pdf2htmlEX poppler dependencies
// Corrected <config.h> includes to <poppler-config.h>
//
//========================================================================
#include <poppler-config.h> #include <poppler-config.h>
#include <string.h> #include <string.h>
@ -79,17 +69,17 @@
// CairoFont // CairoFont
//------------------------------------------------------------------------ //------------------------------------------------------------------------
CairoFont::CairoFont(Ref ref, CairoFont::CairoFont(Ref refA,
cairo_font_face_t *cairo_font_face, cairo_font_face_t *cairo_font_faceA,
int *codeToGID, int *codeToGIDA,
Guint codeToGIDLen, Guint codeToGIDLenA,
GBool substitute, GBool substituteA,
GBool printing) : ref(ref), GBool printingA) : ref(refA),
cairo_font_face(cairo_font_face), cairo_font_face(cairo_font_faceA),
codeToGID(codeToGID), codeToGID(codeToGIDA),
codeToGIDLen(codeToGIDLen), codeToGIDLen(codeToGIDLenA),
substitute(substitute), substitute(substituteA),
printing(printing) { } printing(printingA) { }
CairoFont::~CairoFont() { CairoFont::~CairoFont() {
cairo_font_face_destroy (cairo_font_face); cairo_font_face_destroy (cairo_font_face);
@ -190,7 +180,7 @@ _ft_new_face_uncached (FT_Library lib,
FT_Face face; FT_Face face;
cairo_font_face_t *font_face; cairo_font_face_t *font_face;
if (font_data == NULL) { if (font_data == nullptr) {
if (FT_New_Face (lib, filename, 0, &face)) if (FT_New_Face (lib, filename, 0, &face))
return gFalse; return gFalse;
} else { } else {
@ -296,7 +286,7 @@ _ft_new_face (FT_Library lib,
tmpl.fd = -1; tmpl.fd = -1;
if (font_data == NULL) { if (font_data == nullptr) {
/* if we fail to mmap the file, just pass it to FreeType instead */ /* if we fail to mmap the file, just pass it to FreeType instead */
tmpl.fd = open (filename, O_RDONLY); tmpl.fd = open (filename, O_RDONLY);
if (tmpl.fd == -1) if (tmpl.fd == -1)
@ -307,7 +297,7 @@ _ft_new_face (FT_Library lib,
return _ft_new_face_uncached (lib, filename, font_data, font_data_len, face_out, font_face_out); return _ft_new_face_uncached (lib, filename, font_data, font_data_len, face_out, font_face_out);
} }
tmpl.bytes = (unsigned char *) mmap (NULL, st.st_size, tmpl.bytes = (unsigned char *) mmap (nullptr, st.st_size,
PROT_READ, MAP_PRIVATE, PROT_READ, MAP_PRIVATE,
tmpl.fd, 0); tmpl.fd, 0);
if (tmpl.bytes == MAP_FAILED) { if (tmpl.bytes == MAP_FAILED) {
@ -361,7 +351,7 @@ _ft_new_face (FT_Library lib,
l = (struct _ft_face_data *) gmallocn (1, sizeof (struct _ft_face_data)); l = (struct _ft_face_data *) gmallocn (1, sizeof (struct _ft_face_data));
*l = tmpl; *l = tmpl;
l->prev = NULL; l->prev = nullptr;
l->next = _ft_open_faces; l->next = _ft_open_faces;
if (_ft_open_faces) if (_ft_open_faces)
_ft_open_faces->prev = l; _ft_open_faces->prev = l;
@ -388,22 +378,21 @@ _ft_new_face (FT_Library lib,
#define _ft_new_face _ft_new_face_uncached #define _ft_new_face _ft_new_face_uncached
#endif #endif
CairoFreeTypeFont::CairoFreeTypeFont(Ref ref, CairoFreeTypeFont::CairoFreeTypeFont(Ref refA,
cairo_font_face_t *cairo_font_face, cairo_font_face_t *cairo_font_faceA,
int *codeToGID, int *codeToGIDA,
Guint codeToGIDLen, Guint codeToGIDLenA,
GBool substitute) : CairoFont(ref, GBool substituteA) : CairoFont(refA,
cairo_font_face, cairo_font_faceA,
codeToGID, codeToGIDA,
codeToGIDLen, codeToGIDLenA,
substitute, substituteA,
gTrue) { } gTrue) { }
CairoFreeTypeFont::~CairoFreeTypeFont() { } CairoFreeTypeFont::~CairoFreeTypeFont() { }
CairoFreeTypeFont *CairoFreeTypeFont::create(GfxFont *gfxFont, XRef *xref, CairoFreeTypeFont *CairoFreeTypeFont::create(GfxFont *gfxFont, XRef *xref,
FT_Library lib, GBool useCIDs) { FT_Library lib, GBool useCIDs) {
Object refObj, strObj;
GooString *fileName; GooString *fileName;
char *fileNameC; char *fileNameC;
char *font_data; char *font_data;
@ -422,19 +411,19 @@ CairoFreeTypeFont *CairoFreeTypeFont::create(GfxFont *gfxFont, XRef *xref,
int *codeToGID; int *codeToGID;
Guint codeToGIDLen; Guint codeToGIDLen;
codeToGID = NULL; codeToGID = nullptr;
codeToGIDLen = 0; codeToGIDLen = 0;
font_data = NULL; font_data = nullptr;
font_data_len = 0; font_data_len = 0;
fileName = NULL; fileName = nullptr;
fileNameC = NULL; fileNameC = nullptr;
GBool substitute = gFalse; GBool substitute = gFalse;
ref = *gfxFont->getID(); ref = *gfxFont->getID();
fontType = gfxFont->getType(); fontType = gfxFont->getType();
if (!(fontLoc = gfxFont->locateFont(xref, NULL))) { if (!(fontLoc = gfxFont->locateFont(xref, nullptr))) {
error(errSyntaxError, -1, "Couldn't find a font for '{0:s}'", error(errSyntaxError, -1, "Couldn't find a font for '{0:s}'",
gfxFont->getName() ? gfxFont->getName()->getCString() gfxFont->getName() ? gfxFont->getName()->getCString()
: "(unnamed)"); : "(unnamed)");
@ -444,7 +433,7 @@ CairoFreeTypeFont *CairoFreeTypeFont::create(GfxFont *gfxFont, XRef *xref,
// embedded font // embedded font
if (fontLoc->locType == gfxFontLocEmbedded) { if (fontLoc->locType == gfxFontLocEmbedded) {
font_data = gfxFont->readEmbFontFile(xref, &font_data_len); font_data = gfxFont->readEmbFontFile(xref, &font_data_len);
if (NULL == font_data) if (nullptr == font_data)
goto err2; goto err2;
// external font // external font
@ -454,7 +443,7 @@ CairoFreeTypeFont *CairoFreeTypeFont::create(GfxFont *gfxFont, XRef *xref,
substitute = gTrue; substitute = gTrue;
} }
if (fileName != NULL) { if (fileName != nullptr) {
fileNameC = fileName->getCString(); fileNameC = fileName->getCString();
} }
@ -491,7 +480,7 @@ CairoFreeTypeFont *CairoFreeTypeFont::create(GfxFont *gfxFont, XRef *xref,
break; break;
case fontCIDType2: case fontCIDType2:
case fontCIDType2OT: case fontCIDType2OT:
codeToGID = NULL; codeToGID = nullptr;
n = 0; n = 0;
if (((GfxCIDFont *)gfxFont)->getCIDToGID()) { if (((GfxCIDFont *)gfxFont)->getCIDToGID()) {
n = ((GfxCIDFont *)gfxFont)->getCIDToGIDLen(); n = ((GfxCIDFont *)gfxFont)->getCIDToGIDLen();
@ -501,7 +490,7 @@ CairoFreeTypeFont *CairoFreeTypeFont::create(GfxFont *gfxFont, XRef *xref,
n * sizeof(int)); n * sizeof(int));
} }
} else { } else {
if (font_data != NULL) { if (font_data != nullptr) {
ff = FoFiTrueType::make(font_data, font_data_len); ff = FoFiTrueType::make(font_data, font_data_len);
} else { } else {
ff = FoFiTrueType::load(fileNameC); ff = FoFiTrueType::load(fileNameC);
@ -515,7 +504,7 @@ CairoFreeTypeFont *CairoFreeTypeFont::create(GfxFont *gfxFont, XRef *xref,
/* Fall through */ /* Fall through */
case fontTrueType: case fontTrueType:
case fontTrueTypeOT: case fontTrueTypeOT:
if (font_data != NULL) { if (font_data != nullptr) {
ff = FoFiTrueType::make(font_data, font_data_len); ff = FoFiTrueType::make(font_data, font_data_len);
} else { } else {
ff = FoFiTrueType::load(fileNameC); ff = FoFiTrueType::load(fileNameC);
@ -539,12 +528,12 @@ CairoFreeTypeFont *CairoFreeTypeFont::create(GfxFont *gfxFont, XRef *xref,
case fontCIDType0: case fontCIDType0:
case fontCIDType0C: case fontCIDType0C:
codeToGID = NULL; codeToGID = nullptr;
codeToGIDLen = 0; codeToGIDLen = 0;
if (!useCIDs) if (!useCIDs)
{ {
if (font_data != NULL) { if (font_data != nullptr) {
ff1c = FoFiType1C::make(font_data, font_data_len); ff1c = FoFiType1C::make(font_data, font_data_len);
} else { } else {
ff1c = FoFiType1C::load(fileNameC); ff1c = FoFiType1C::load(fileNameC);
@ -562,7 +551,7 @@ CairoFreeTypeFont *CairoFreeTypeFont::create(GfxFont *gfxFont, XRef *xref,
break; break;
case fontCIDType0COT: case fontCIDType0COT:
codeToGID = NULL; codeToGID = nullptr;
n = 0; n = 0;
if (((GfxCIDFont *)gfxFont)->getCIDToGID()) { if (((GfxCIDFont *)gfxFont)->getCIDToGID()) {
n = ((GfxCIDFont *)gfxFont)->getCIDToGIDLen(); n = ((GfxCIDFont *)gfxFont)->getCIDToGIDLen();
@ -576,7 +565,7 @@ CairoFreeTypeFont *CairoFreeTypeFont::create(GfxFont *gfxFont, XRef *xref,
if (!codeToGID) { if (!codeToGID) {
if (!useCIDs) { if (!useCIDs) {
if (font_data != NULL) { if (font_data != nullptr) {
ff = FoFiTrueType::make(font_data, font_data_len); ff = FoFiTrueType::make(font_data, font_data_len);
} else { } else {
ff = FoFiTrueType::load(fileNameC); ff = FoFiTrueType::load(fileNameC);
@ -613,7 +602,7 @@ CairoFreeTypeFont *CairoFreeTypeFont::create(GfxFont *gfxFont, XRef *xref,
gfree (codeToGID); gfree (codeToGID);
gfree (font_data); gfree (font_data);
fprintf (stderr, "some font thing failed\n"); fprintf (stderr, "some font thing failed\n");
return NULL; return nullptr;
} }
//------------------------------------------------------------------------ //------------------------------------------------------------------------
@ -713,7 +702,7 @@ _render_type3_glyph (cairo_scaled_font_t *scaled_font,
box.y1 = mat[1]; box.y1 = mat[1];
box.x2 = mat[2]; box.x2 = mat[2];
box.y2 = mat[3]; box.y2 = mat[3];
gfx = new Gfx(info->doc, output_dev, resDict, &box, NULL); gfx = new Gfx(info->doc, output_dev, resDict, &box, nullptr);
output_dev->startDoc(info->doc, info->fontEngine); output_dev->startDoc(info->doc, info->fontEngine);
output_dev->startPage (1, gfx->getState(), gfx->getXRef()); output_dev->startPage (1, gfx->getState(), gfx->getXRef());
output_dev->setInType3Char(gTrue); output_dev->setInType3Char(gTrue);
@ -745,7 +734,6 @@ _render_type3_glyph (cairo_scaled_font_t *scaled_font,
CairoType3Font *CairoType3Font::create(GfxFont *gfxFont, PDFDoc *doc, CairoType3Font *CairoType3Font::create(GfxFont *gfxFont, PDFDoc *doc,
CairoFontEngine *fontEngine, CairoFontEngine *fontEngine,
GBool printing, XRef *xref) { GBool printing, XRef *xref) {
Object refObj, strObj;
type3_font_info_t *info; type3_font_info_t *info;
cairo_font_face_t *font_face; cairo_font_face_t *font_face;
Ref ref; Ref ref;
@ -788,18 +776,18 @@ CairoType3Font *CairoType3Font::create(GfxFont *gfxFont, PDFDoc *doc,
return new CairoType3Font(ref, doc, font_face, codeToGID, codeToGIDLen, printing, xref); return new CairoType3Font(ref, doc, font_face, codeToGID, codeToGIDLen, printing, xref);
} }
CairoType3Font::CairoType3Font(Ref ref, CairoType3Font::CairoType3Font(Ref refA,
PDFDoc *doc, PDFDoc *docA,
cairo_font_face_t *cairo_font_face, cairo_font_face_t *cairo_font_faceA,
int *codeToGID, int *codeToGIDA,
Guint codeToGIDLen, Guint codeToGIDLenA,
GBool printing, XRef *xref) : CairoFont(ref, GBool printingA, XRef *xref) : CairoFont(refA,
cairo_font_face, cairo_font_faceA,
codeToGID, codeToGIDA,
codeToGIDLen, codeToGIDLenA,
gFalse, gFalse,
printing), printingA),
doc(doc) { } doc(docA) { }
CairoType3Font::~CairoType3Font() { } CairoType3Font::~CairoType3Font() { }
@ -818,7 +806,7 @@ CairoFontEngine::CairoFontEngine(FT_Library libA) {
lib = libA; lib = libA;
for (i = 0; i < cairoFontCacheSize; ++i) { for (i = 0; i < cairoFontCacheSize; ++i) {
fontCache[i] = NULL; fontCache[i] = nullptr;
} }
FT_Int major, minor, patch; FT_Int major, minor, patch;

View File

@ -15,7 +15,7 @@
// under GPL version 2 or later // under GPL version 2 or later
// //
// Copyright (C) 2005, 2006 Kristian Høgsberg <krh@redhat.com> // Copyright (C) 2005, 2006 Kristian Høgsberg <krh@redhat.com>
// Copyright (C) 2005 Albert Astals Cid <aacid@kde.org> // Copyright (C) 2005, 2018 Albert Astals Cid <aacid@kde.org>
// Copyright (C) 2006, 2007 Jeff Muizelaar <jeff@infidigm.net> // Copyright (C) 2006, 2007 Jeff Muizelaar <jeff@infidigm.net>
// Copyright (C) 2006, 2010 Carlos Garcia Campos <carlosgc@gnome.org> // Copyright (C) 2006, 2010 Carlos Garcia Campos <carlosgc@gnome.org>
// Copyright (C) 2008, 2017 Adrian Johnson <ajohnson@redneon.com> // Copyright (C) 2008, 2017 Adrian Johnson <ajohnson@redneon.com>
@ -26,15 +26,6 @@
// //
//======================================================================== //========================================================================
//========================================================================
//
// Copied from Ubuntu 18.04 apt-get source poppler (poppler-0.62.0)
// Copied on 2019/March/26
// Copied by Stephen Gaito in order to update pdf2htmlEX poppler dependencies
// Corrected <config.h> includes to <poppler-config.h>
//
//========================================================================
#ifndef CAIROFONTENGINE_H #ifndef CAIROFONTENGINE_H
#define CAIROFONTENGINE_H #define CAIROFONTENGINE_H
@ -60,6 +51,8 @@ public:
GBool substitute, GBool substitute,
GBool printing); GBool printing);
virtual ~CairoFont(); virtual ~CairoFont();
CairoFont(const CairoFont &) = delete;
CairoFont& operator=(const CairoFont &other) = delete;
virtual GBool matches(Ref &other, GBool printing); virtual GBool matches(Ref &other, GBool printing);
cairo_font_face_t *getFontFace(void); cairo_font_face_t *getFontFace(void);
@ -123,6 +116,8 @@ public:
// Create a font engine. // Create a font engine.
CairoFontEngine(FT_Library libA); CairoFontEngine(FT_Library libA);
~CairoFontEngine(); ~CairoFontEngine();
CairoFontEngine(const CairoFontEngine &) = delete;
CairoFontEngine& operator=(const CairoFontEngine &other) = delete;
CairoFont *getFont(GfxFont *gfxFont, PDFDoc *doc, GBool printing, XRef *xref); CairoFont *getFont(GfxFont *gfxFont, PDFDoc *doc, GBool printing, XRef *xref);

View File

@ -16,9 +16,9 @@
// //
// Copyright (C) 2005-2008 Jeff Muizelaar <jeff@infidigm.net> // Copyright (C) 2005-2008 Jeff Muizelaar <jeff@infidigm.net>
// Copyright (C) 2005, 2006 Kristian Høgsberg <krh@redhat.com> // Copyright (C) 2005, 2006 Kristian Høgsberg <krh@redhat.com>
// Copyright (C) 2005, 2009, 2012, 2017 Albert Astals Cid <aacid@kde.org> // Copyright (C) 2005, 2009, 2012, 2017, 2018 Albert Astals Cid <aacid@kde.org>
// Copyright (C) 2005 Nickolay V. Shmyrev <nshmyrev@yandex.ru> // Copyright (C) 2005 Nickolay V. Shmyrev <nshmyrev@yandex.ru>
// Copyright (C) 2006-2011, 2013, 2014, 2017 Carlos Garcia Campos <carlosgc@gnome.org> // Copyright (C) 2006-2011, 2013, 2014, 2017, 2018 Carlos Garcia Campos <carlosgc@gnome.org>
// Copyright (C) 2008 Carl Worth <cworth@cworth.org> // Copyright (C) 2008 Carl Worth <cworth@cworth.org>
// Copyright (C) 2008-2017 Adrian Johnson <ajohnson@redneon.com> // Copyright (C) 2008-2017 Adrian Johnson <ajohnson@redneon.com>
// Copyright (C) 2008 Michael Vrable <mvrable@cs.ucsd.edu> // Copyright (C) 2008 Michael Vrable <mvrable@cs.ucsd.edu>
@ -29,21 +29,13 @@
// Copyright (C) 2012 Patrick Pfeifer <p2000@mailinator.com> // Copyright (C) 2012 Patrick Pfeifer <p2000@mailinator.com>
// Copyright (C) 2012, 2015, 2016 Jason Crain <jason@aquaticape.us> // Copyright (C) 2012, 2015, 2016 Jason Crain <jason@aquaticape.us>
// Copyright (C) 2015 Suzuki Toshiya <mpsuzuki@hiroshima-u.ac.jp> // Copyright (C) 2015 Suzuki Toshiya <mpsuzuki@hiroshima-u.ac.jp>
// Copyright (C) 2018 Klarälvdalens Datakonsult AB, a KDAB Group company, <info@kdab.com>. Work sponsored by the LiMux project of the city of Munich
// //
// To see a description of the changes please see the Changelog file that // 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 // came with your tarball or type make ChangeLog if you are building from git
// //
//======================================================================== //========================================================================
//========================================================================
//
// Copied from Ubuntu 18.04 apt-get source poppler (poppler-0.62.0)
// Copied on 2019/March/26
// Copied by Stephen Gaito in order to update pdf2htmlEX poppler dependencies
// Corrected <config.h> includes to <poppler-config.h>
//
//========================================================================
#include <poppler-config.h> #include <poppler-config.h>
#ifdef USE_GCC_PRAGMAS #ifdef USE_GCC_PRAGMAS
@ -78,6 +70,11 @@
// #define LOG_CAIRO // #define LOG_CAIRO
// To limit memory usage and improve performance when printing, limit
// cairo images to this size. 8192 is sufficient for an A2 sized
// 300ppi image.
#define MAX_PRINT_IMAGE_SIZE 8192
#ifdef LOG_CAIRO #ifdef LOG_CAIRO
#define LOG(x) (x) #define LOG(x) (x)
#else #else
@ -100,7 +97,7 @@ static inline void printMatrix(cairo_matrix_t *matrix){
//------------------------------------------------------------------------ //------------------------------------------------------------------------
CairoImage::CairoImage (double x1, double y1, double x2, double y2) { CairoImage::CairoImage (double x1, double y1, double x2, double y2) {
this->image = NULL; this->image = nullptr;
this->x1 = x1; this->x1 = x1;
this->y1 = y1; this->y1 = y1;
this->x2 = x2; this->x2 = x2;
@ -132,26 +129,26 @@ FT_Library CairoOutputDev::ft_lib;
GBool CairoOutputDev::ft_lib_initialized = gFalse; GBool CairoOutputDev::ft_lib_initialized = gFalse;
CairoOutputDev::CairoOutputDev() { CairoOutputDev::CairoOutputDev() {
doc = NULL; doc = nullptr;
if (!ft_lib_initialized) { if (!ft_lib_initialized) {
FT_Init_FreeType(&ft_lib); FT_Init_FreeType(&ft_lib);
ft_lib_initialized = gTrue; ft_lib_initialized = gTrue;
} }
fontEngine = NULL; fontEngine = nullptr;
fontEngine_owner = gFalse; fontEngine_owner = gFalse;
glyphs = NULL; glyphs = nullptr;
fill_pattern = NULL; fill_pattern = nullptr;
fill_color.r = fill_color.g = fill_color.b = 0; fill_color.r = fill_color.g = fill_color.b = 0;
stroke_pattern = NULL; stroke_pattern = nullptr;
stroke_color.r = stroke_color.g = stroke_color.b = 0; stroke_color.r = stroke_color.g = stroke_color.b = 0;
stroke_opacity = 1.0; stroke_opacity = 1.0;
fill_opacity = 1.0; fill_opacity = 1.0;
textClipPath = NULL; textClipPath = nullptr;
strokePathClip = NULL; strokePathClip = nullptr;
cairo = NULL; cairo = nullptr;
currentFont = NULL; currentFont = nullptr;
#if CAIRO_VERSION >= CAIRO_VERSION_ENCODE(1, 14, 0) #if CAIRO_VERSION >= CAIRO_VERSION_ENCODE(1, 14, 0)
prescaleImages = gFalse; prescaleImages = gFalse;
#else #else
@ -165,23 +162,23 @@ CairoOutputDev::CairoOutputDev() {
text_matrix_valid = gTrue; text_matrix_valid = gTrue;
antialias = CAIRO_ANTIALIAS_DEFAULT; antialias = CAIRO_ANTIALIAS_DEFAULT;
groupColorSpaceStack = NULL; groupColorSpaceStack = nullptr;
maskStack = NULL; maskStack = nullptr;
group = NULL; group = nullptr;
mask = NULL; mask = nullptr;
shape = NULL; shape = nullptr;
cairo_shape = NULL; cairo_shape = nullptr;
knockoutCount = 0; knockoutCount = 0;
text = NULL; text = nullptr;
actualText = NULL; actualText = nullptr;
// the SA parameter supposedly defaults to false, but Acrobat // the SA parameter supposedly defaults to false, but Acrobat
// apparently hardwires it to true // apparently hardwires it to true
stroke_adjust = gTrue; stroke_adjust = gTrue;
align_stroke_coords = gFalse; align_stroke_coords = gFalse;
adjusted_stroke_width = gFalse; adjusted_stroke_width = gFalse;
xref = NULL; xref = nullptr;
} }
CairoOutputDev::~CairoOutputDev() { CairoOutputDev::~CairoOutputDev() {
@ -207,7 +204,7 @@ CairoOutputDev::~CairoOutputDev() {
void CairoOutputDev::setCairo(cairo_t *cairo) void CairoOutputDev::setCairo(cairo_t *cairo)
{ {
if (this->cairo != NULL) { if (this->cairo != nullptr) {
cairo_status_t status = cairo_status (this->cairo); cairo_status_t status = cairo_status (this->cairo);
if (status) { if (status) {
error(errInternal, -1, "cairo context error: {0:s}\n", cairo_status_to_string(status)); error(errInternal, -1, "cairo context error: {0:s}\n", cairo_status_to_string(status));
@ -215,15 +212,15 @@ void CairoOutputDev::setCairo(cairo_t *cairo)
cairo_destroy (this->cairo); cairo_destroy (this->cairo);
assert(!cairo_shape); assert(!cairo_shape);
} }
if (cairo != NULL) { if (cairo != nullptr) {
this->cairo = cairo_reference (cairo); this->cairo = cairo_reference (cairo);
/* save the initial matrix so that we can use it for type3 fonts. */ /* save the initial matrix so that we can use it for type3 fonts. */
//XXX: is this sufficient? could we miss changes to the matrix somehow? //XXX: is this sufficient? could we miss changes to the matrix somehow?
cairo_get_matrix(cairo, &orig_matrix); cairo_get_matrix(cairo, &orig_matrix);
setContextAntialias(cairo, antialias); setContextAntialias(cairo, antialias);
} else { } else {
this->cairo = NULL; this->cairo = nullptr;
this->cairo_shape = NULL; this->cairo_shape = nullptr;
} }
} }
@ -238,8 +235,8 @@ void CairoOutputDev::setTextPage(TextPage *text)
this->text->incRefCnt(); this->text->incRefCnt();
actualText = new ActualText(text); actualText = new ActualText(text);
} else { } else {
this->text = NULL; this->text = nullptr;
actualText = NULL; actualText = nullptr;
} }
} }
@ -290,7 +287,7 @@ void CairoOutputDev::startPage(int pageNum, GfxState *state, XRef *xrefA) {
if (text) if (text)
text->startPage(state); text->startPage(state);
if (xrefA != NULL) { if (xrefA != nullptr) {
xref = xrefA; xref = xrefA;
} }
} }
@ -349,7 +346,7 @@ void CairoOutputDev::restoreState(GfxState *state) {
if (strokePathClip->dashes) if (strokePathClip->dashes)
gfree (strokePathClip->dashes); gfree (strokePathClip->dashes);
gfree (strokePathClip); gfree (strokePathClip);
strokePathClip = NULL; strokePathClip = nullptr;
} }
} }
@ -959,11 +956,11 @@ GBool CairoOutputDev::tilingPatternFill(GfxState *state, Gfx *gfxA, Catalog *cat
cairo_translate (cairo, -box.x1, -box.y1); cairo_translate (cairo, -box.x1, -box.y1);
strokePathTmp = strokePathClip; strokePathTmp = strokePathClip;
strokePathClip = NULL; strokePathClip = nullptr;
adjusted_stroke_width_tmp = adjusted_stroke_width; adjusted_stroke_width_tmp = adjusted_stroke_width;
maskTmp = mask; maskTmp = mask;
mask = NULL; mask = nullptr;
gfx = new Gfx(doc, this, resDict, &box, NULL, NULL, NULL, gfxA->getXRef()); gfx = new Gfx(doc, this, resDict, &box, nullptr, nullptr, nullptr, gfxA);
if (paintType == 2) if (paintType == 2)
inUncoloredPattern = gTrue; inUncoloredPattern = gTrue;
gfx->display(str); gfx->display(str);
@ -1360,7 +1357,7 @@ void CairoOutputDev::clipToStrokePath(GfxState *state) {
strokePathClip->dashes = (double*) gmallocn (sizeof(double), strokePathClip->dash_count); strokePathClip->dashes = (double*) gmallocn (sizeof(double), strokePathClip->dash_count);
cairo_get_dash (cairo, strokePathClip->dashes, &strokePathClip->dash_offset); cairo_get_dash (cairo, strokePathClip->dashes, &strokePathClip->dash_offset);
} else { } else {
strokePathClip->dashes = NULL; strokePathClip->dashes = nullptr;
} }
strokePathClip->cap = cairo_get_line_cap (cairo); strokePathClip->cap = cairo_get_line_cap (cairo);
strokePathClip->join = cairo_get_line_join (cairo); strokePathClip->join = cairo_get_line_join (cairo);
@ -1383,7 +1380,7 @@ void CairoOutputDev::fillToStrokePathClip(GfxState *state) {
cairo_restore (cairo); cairo_restore (cairo);
} }
void CairoOutputDev::beginString(GfxState *state, GooString *s) void CairoOutputDev::beginString(GfxState *state, const GooString *s)
{ {
int len = s->getLength(); int len = s->getLength();
@ -1512,12 +1509,12 @@ void CairoOutputDev::endString(GfxState *state)
finish: finish:
gfree (glyphs); gfree (glyphs);
glyphs = NULL; glyphs = nullptr;
if (use_show_text_glyphs) { if (use_show_text_glyphs) {
gfree (clusters); gfree (clusters);
clusters = NULL; clusters = nullptr;
gfree (utf8); gfree (utf8);
utf8 = NULL; utf8 = nullptr;
} }
} }
@ -1588,11 +1585,11 @@ void CairoOutputDev::endTextObject(GfxState *state) {
cairo_clip (cairo_shape); cairo_clip (cairo_shape);
} }
cairo_path_destroy (textClipPath); cairo_path_destroy (textClipPath);
textClipPath = NULL; textClipPath = nullptr;
} }
} }
void CairoOutputDev::beginActualText(GfxState *state, GooString *text) void CairoOutputDev::beginActualText(GfxState *state, const GooString *text)
{ {
if (this->text) if (this->text)
actualText->begin(state, text); actualText->begin(state, text);
@ -1620,7 +1617,7 @@ static
cairo_surface_t *cairo_surface_create_similar_clip (cairo_t *cairo, cairo_content_t content) cairo_surface_t *cairo_surface_create_similar_clip (cairo_t *cairo, cairo_content_t content)
{ {
cairo_pattern_t *pattern; cairo_pattern_t *pattern;
cairo_surface_t *surface = NULL; cairo_surface_t *surface = nullptr;
cairo_push_group_with_content (cairo, content); cairo_push_group_with_content (cairo, content);
pattern = cairo_pop_group (cairo); pattern = cairo_pop_group (cairo);
@ -1732,7 +1729,7 @@ void CairoOutputDev::paintTransparencyGroup(GfxState * /*state*/, double * /*bbo
cairo_paint_with_alpha (cairo, fill_opacity); cairo_paint_with_alpha (cairo, fill_opacity);
} }
cairo_pattern_destroy(mask); cairo_pattern_destroy(mask);
mask = NULL; mask = nullptr;
} }
if (shape) { if (shape) {
@ -1742,7 +1739,7 @@ void CairoOutputDev::paintTransparencyGroup(GfxState * /*state*/, double * /*bbo
cairo_set_source_rgb (cairo_shape, 0, 0, 0); cairo_set_source_rgb (cairo_shape, 0, 0, 0);
} }
cairo_pattern_destroy (shape); cairo_pattern_destroy (shape);
shape = NULL; shape = nullptr;
} }
popTransparencyGroup(); popTransparencyGroup();
@ -1890,7 +1887,7 @@ void CairoOutputDev::popTransparencyGroup() {
/* we don't need to track the shape anymore because /* we don't need to track the shape anymore because
* we are not above any knockout groups */ * we are not above any knockout groups */
cairo_destroy(cairo_shape); cairo_destroy(cairo_shape);
cairo_shape = NULL; cairo_shape = nullptr;
} }
} }
groupColorSpaceStack = css->next; groupColorSpaceStack = css->next;
@ -1901,7 +1898,7 @@ void CairoOutputDev::popTransparencyGroup() {
void CairoOutputDev::clearSoftMask(GfxState * /*state*/) { void CairoOutputDev::clearSoftMask(GfxState * /*state*/) {
if (mask) if (mask)
cairo_pattern_destroy(mask); cairo_pattern_destroy(mask);
mask = NULL; mask = nullptr;
} }
/* Taken from cairo/doc/tutorial/src/singular.c */ /* Taken from cairo/doc/tutorial/src/singular.c */
@ -2770,7 +2767,7 @@ void CairoOutputDev::drawSoftMaskedImage(GfxState *state, Object *ref, Stream *s
cairo_surface_mark_dirty (image); cairo_surface_mark_dirty (image);
setMimeData(state, str, ref, colorMap, image); setMimeData(state, str, ref, colorMap, image, height);
pattern = cairo_pattern_create_for_surface (image); pattern = cairo_pattern_create_for_surface (image);
cairo_surface_destroy (image); cairo_surface_destroy (image);
@ -2924,7 +2921,7 @@ GBool CairoOutputDev::setMimeDataForJBIG2Globals(Stream *str,
if (!globalsStr->isStream()) if (!globalsStr->isStream())
return gTrue; return gTrue;
if (setMimeIdFromRef(image, CAIRO_MIME_TYPE_JBIG2_GLOBAL_ID, NULL, if (setMimeIdFromRef(image, CAIRO_MIME_TYPE_JBIG2_GLOBAL_ID, nullptr,
jb2Str->getGlobalsStreamRef())) jb2Str->getGlobalsStreamRef()))
return gFalse; return gFalse;
@ -2944,8 +2941,38 @@ GBool CairoOutputDev::setMimeDataForJBIG2Globals(Stream *str,
} }
#endif #endif
#if CAIRO_VERSION >= CAIRO_VERSION_ENCODE(1, 15, 10)
GBool CairoOutputDev::setMimeDataForCCITTParams(Stream *str,
cairo_surface_t *image, int height)
{
CCITTFaxStream *ccittStr = static_cast<CCITTFaxStream *>(str);
GooString params;
params.appendf("Columns={0:d}", ccittStr->getColumns());
params.appendf(" Rows={0:d}", height);
params.appendf(" K={0:d}", ccittStr->getEncoding());
params.appendf(" EndOfLine={0:d}", ccittStr->getEndOfLine() ? 1 : 0);
params.appendf(" EncodedByteAlign={0:d}", ccittStr->getEncodedByteAlign() ? 1 : 0);
params.appendf(" EndOfBlock={0:d}", ccittStr->getEndOfBlock() ? 1 : 0);
params.appendf(" BlackIs1={0:d}", ccittStr->getBlackIs1() ? 1 : 0);
params.appendf(" DamagedRowsBeforeError={0:d}", ccittStr->getDamagedRowsBeforeError());
char *p = strdup(params.getCString());
if (cairo_surface_set_mime_data (image, CAIRO_MIME_TYPE_CCITT_FAX_PARAMS,
(const unsigned char*)p,
params.getLength(),
gfree, (void*)p))
{
gfree (p);
return gFalse;
}
return gTrue;
}
#endif
void CairoOutputDev::setMimeData(GfxState *state, Stream *str, Object *ref, void CairoOutputDev::setMimeData(GfxState *state, Stream *str, Object *ref,
GfxImageColorMap *colorMap, cairo_surface_t *image) GfxImageColorMap *colorMap, cairo_surface_t *image, int height)
{ {
char *strBuffer; char *strBuffer;
int len; int len;
@ -2968,13 +2995,18 @@ void CairoOutputDev::setMimeData(GfxState *state, Stream *str, Object *ref,
case strJBIG2: case strJBIG2:
mime_type = CAIRO_MIME_TYPE_JBIG2; mime_type = CAIRO_MIME_TYPE_JBIG2;
break; break;
#endif
#if CAIRO_VERSION >= CAIRO_VERSION_ENCODE(1, 15, 10)
case strCCITTFax:
mime_type = CAIRO_MIME_TYPE_CCITT_FAX;
break;
#endif #endif
default: default:
return; return;
} }
obj = str->getDict()->lookup("ColorSpace"); obj = str->getDict()->lookup("ColorSpace");
colorSpace = GfxColorSpace::parse(NULL, &obj, this, state); colorSpace = GfxColorSpace::parse(nullptr, &obj, this, state);
// colorspace in stream dict may be different from colorspace in jpx // colorspace in stream dict may be different from colorspace in jpx
// data // data
@ -3011,6 +3043,11 @@ void CairoOutputDev::setMimeData(GfxState *state, Stream *str, Object *ref,
return; return;
#endif #endif
#if CAIRO_VERSION >= CAIRO_VERSION_ENCODE(1, 15, 10)
if (strKind == strCCITTFax && !setMimeDataForCCITTParams(str, image, height))
return;
#endif
if (getStreamData (str->getNextStream(), &strBuffer, &len)) { if (getStreamData (str->getNextStream(), &strBuffer, &len)) {
cairo_status_t status = CAIRO_STATUS_SUCCESS; cairo_status_t status = CAIRO_STATUS_SUCCESS;
@ -3048,10 +3085,10 @@ public:
GBool printing, GBool printing,
GfxImageColorMap *colorMapA, GfxImageColorMap *colorMapA,
int *maskColorsA) { int *maskColorsA) {
cairo_surface_t *image = NULL; cairo_surface_t *image = nullptr;
int i; int i;
lookup = NULL; lookup = nullptr;
colorMap = colorMapA; colorMap = colorMapA;
maskColors = maskColorsA; maskColors = maskColorsA;
width = widthA; width = widthA;
@ -3094,7 +3131,22 @@ public:
bool needsCustomDownscaling = true; bool needsCustomDownscaling = true;
#endif #endif
if (!needsCustomDownscaling || printing || scaledWidth >= width || scaledHeight >= height) { if (printing) {
if (width > MAX_PRINT_IMAGE_SIZE || height > MAX_PRINT_IMAGE_SIZE) {
if (width > height) {
scaledWidth = MAX_PRINT_IMAGE_SIZE;
scaledHeight = MAX_PRINT_IMAGE_SIZE * (double)height/width;
} else {
scaledHeight = MAX_PRINT_IMAGE_SIZE;
scaledWidth = MAX_PRINT_IMAGE_SIZE * (double)width/height;
}
needsCustomDownscaling = true;
} else {
needsCustomDownscaling = false;
}
}
if (!needsCustomDownscaling || scaledWidth >= width || scaledHeight >= height) {
// No downscaling. Create cairo image containing the source image data. // No downscaling. Create cairo image containing the source image data.
unsigned char *buffer; unsigned char *buffer;
ptrdiff_t stride; ptrdiff_t stride;
@ -3142,7 +3194,6 @@ public:
} }
void getRow(int row_num, uint32_t *row_data) override { void getRow(int row_num, uint32_t *row_data) override {
int i;
Guchar *pix; Guchar *pix;
if (row_num <= current_row) if (row_num <= current_row)
@ -3153,7 +3204,7 @@ public:
current_row++; current_row++;
} }
if (unlikely(pix == NULL)) { if (unlikely(pix == nullptr)) {
memset(row_data, 0, width*4); memset(row_data, 0, width*4);
if (!imageError) { if (!imageError) {
error(errInternal, -1, "Bad image stream"); error(errInternal, -1, "Bad image stream");
@ -3163,7 +3214,7 @@ public:
Guchar *p = pix; Guchar *p = pix;
GfxRGB rgb; GfxRGB rgb;
for (i = 0; i < width; i++) { for (int i = 0; i < width; i++) {
rgb = lookup[*p]; rgb = lookup[*p];
row_data[i] = row_data[i] =
((int) colToByte(rgb.r) << 16) | ((int) colToByte(rgb.r) << 16) |
@ -3224,8 +3275,17 @@ void CairoOutputDev::drawImage(GfxState *state, Object *ref, Stream *str,
if (width == widthA && height == heightA) if (width == widthA && height == heightA)
filter = getFilterForSurface (image, interpolate); filter = getFilterForSurface (image, interpolate);
if (!inlineImg) /* don't read stream twice if it is an inline image */ if (!inlineImg) { /* don't read stream twice if it is an inline image */
setMimeData(state, str, ref, colorMap, image); // cairo 1.15.10 allows mime image data to have different size to cairo image
// mime image size will be scaled to same size as cairo image
#if CAIRO_VERSION >= CAIRO_VERSION_ENCODE(1, 15, 10)
bool requireSameSize = false;
#else
bool requireSameSize = true;
#endif
if (!requireSameSize || (width == widthA && height == heightA))
setMimeData(state, str, ref, colorMap, image, heightA);
}
pattern = cairo_pattern_create_for_surface (image); pattern = cairo_pattern_create_for_surface (image);
cairo_surface_destroy (image); cairo_surface_destroy (image);
@ -3250,7 +3310,7 @@ void CairoOutputDev::drawImage(GfxState *state, Object *ref, Stream *str,
} else if (mask) { } else if (mask) {
maskPattern = cairo_pattern_reference (mask); maskPattern = cairo_pattern_reference (mask);
} else { } else {
maskPattern = NULL; maskPattern = nullptr;
} }
cairo_save (cairo); cairo_save (cairo);
@ -3295,11 +3355,11 @@ void CairoOutputDev::drawImage(GfxState *state, Object *ref, Stream *str,
CairoImageOutputDev::CairoImageOutputDev() CairoImageOutputDev::CairoImageOutputDev()
{ {
images = NULL; images = nullptr;
numImages = 0; numImages = 0;
size = 0; size = 0;
imgDrawCbk = NULL; imgDrawCbk = nullptr;
imgDrawCbkData = NULL; imgDrawCbkData = nullptr;
} }
CairoImageOutputDev::~CairoImageOutputDev() CairoImageOutputDev::~CairoImageOutputDev()
@ -3372,7 +3432,7 @@ void CairoImageOutputDev::drawImageMask(GfxState *state, Object *ref, Stream *st
CairoOutputDev::drawImageMask(state, ref, str, width, height, invert, interpolate, inlineImg); CairoOutputDev::drawImageMask(state, ref, str, width, height, invert, interpolate, inlineImg);
image->setImage (surface); image->setImage (surface);
setCairo (NULL); setCairo (nullptr);
cairo_surface_destroy (surface); cairo_surface_destroy (surface);
cairo_destroy (cr); cairo_destroy (cr);
} }
@ -3405,7 +3465,7 @@ void CairoImageOutputDev::setSoftMaskFromImageMask(GfxState *state, Object *ref,
} }
image->setImage (surface); image->setImage (surface);
setCairo (NULL); setCairo (nullptr);
cairo_surface_destroy (surface); cairo_surface_destroy (surface);
cairo_destroy (cr); cairo_destroy (cr);
} }
@ -3435,7 +3495,7 @@ void CairoImageOutputDev::drawImage(GfxState *state, Object *ref, Stream *str,
CairoOutputDev::drawImage(state, ref, str, width, height, colorMap, interpolate, maskColors, inlineImg); CairoOutputDev::drawImage(state, ref, str, width, height, colorMap, interpolate, maskColors, inlineImg);
image->setImage (surface); image->setImage (surface);
setCairo (NULL); setCairo (nullptr);
cairo_surface_destroy (surface); cairo_surface_destroy (surface);
cairo_destroy (cr); cairo_destroy (cr);
} }
@ -3471,7 +3531,7 @@ void CairoImageOutputDev::drawSoftMaskedImage(GfxState *state, Object *ref, Stre
maskStr, maskWidth, maskHeight, maskColorMap, maskInterpolate); maskStr, maskWidth, maskHeight, maskColorMap, maskInterpolate);
image->setImage (surface); image->setImage (surface);
setCairo (NULL); setCairo (nullptr);
cairo_surface_destroy (surface); cairo_surface_destroy (surface);
cairo_destroy (cr); cairo_destroy (cr);
} }
@ -3506,7 +3566,7 @@ void CairoImageOutputDev::drawMaskedImage(GfxState *state, Object *ref, Stream *
maskStr, maskWidth, maskHeight, maskInvert, maskInterpolate); maskStr, maskWidth, maskHeight, maskInvert, maskInterpolate);
image->setImage (surface); image->setImage (surface);
setCairo (NULL); setCairo (nullptr);
cairo_surface_destroy (surface); cairo_surface_destroy (surface);
cairo_destroy (cr); cairo_destroy (cr);
} }

View File

@ -18,26 +18,19 @@
// Copyright (C) 2005, 2006 Kristian Høgsberg <krh@redhat.com> // Copyright (C) 2005, 2006 Kristian Høgsberg <krh@redhat.com>
// Copyright (C) 2005 Nickolay V. Shmyrev <nshmyrev@yandex.ru> // Copyright (C) 2005 Nickolay V. Shmyrev <nshmyrev@yandex.ru>
// Copyright (C) 2006-2011, 2013 Carlos Garcia Campos <carlosgc@gnome.org> // Copyright (C) 2006-2011, 2013 Carlos Garcia Campos <carlosgc@gnome.org>
// Copyright (C) 2008, 2009, 2011-2016 Adrian Johnson <ajohnson@redneon.com> // Copyright (C) 2008, 2009, 2011-2017 Adrian Johnson <ajohnson@redneon.com>
// Copyright (C) 2008 Michael Vrable <mvrable@cs.ucsd.edu> // Copyright (C) 2008 Michael Vrable <mvrable@cs.ucsd.edu>
// Copyright (C) 2010-2013 Thomas Freitag <Thomas.Freitag@alfa.de> // Copyright (C) 2010-2013 Thomas Freitag <Thomas.Freitag@alfa.de>
// Copyright (C) 2015 Suzuki Toshiya <mpsuzuki@hiroshima-u.ac.jp> // Copyright (C) 2015 Suzuki Toshiya <mpsuzuki@hiroshima-u.ac.jp>
// Copyright (C) 2016 Jason Crain <jason@aquaticape.us> // Copyright (C) 2016 Jason Crain <jason@aquaticape.us>
// Copyright (C) 2018 Albert Astals Cid <aacid@kde.org>
// Copyright (C) 2018 Klarälvdalens Datakonsult AB, a KDAB Group company, <info@kdab.com>. Work sponsored by the LiMux project of the city of Munich
// //
// To see a description of the changes please see the Changelog file that // 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 // came with your tarball or type make ChangeLog if you are building from git
// //
//======================================================================== //========================================================================
//========================================================================
//
// Copied from Ubuntu 18.04 apt-get source poppler (poppler-0.62.0)
// Copied on 2019/March/26
// Copied by Stephen Gaito in order to update pdf2htmlEX poppler dependencies
// Corrected <config.h> includes to <poppler-config.h>
//
//========================================================================
#ifndef CAIROOUTPUTDEV_H #ifndef CAIROOUTPUTDEV_H
#define CAIROOUTPUTDEV_H #define CAIROOUTPUTDEV_H
@ -72,6 +65,9 @@ public:
// Destructor. // Destructor.
~CairoImage (); ~CairoImage ();
CairoImage(const CairoImage &) = delete;
CairoImage& operator=(const CairoImage &) = delete;
// Set the image cairo surface // Set the image cairo surface
void setImage (cairo_surface_t *image); void setImage (cairo_surface_t *image);
@ -196,13 +192,13 @@ public:
void eoClip(GfxState *state) override; void eoClip(GfxState *state) override;
//----- text drawing //----- text drawing
void beginString(GfxState *state, GooString *s) override; void beginString(GfxState *state, const GooString *s) override;
void endString(GfxState *state) override; void endString(GfxState *state) override;
void drawChar(GfxState *state, double x, double y, void drawChar(GfxState *state, double x, double y,
double dx, double dy, double dx, double dy,
double originX, double originY, double originX, double originY,
CharCode code, int nBytes, Unicode *u, int uLen) override; CharCode code, int nBytes, Unicode *u, int uLen) override;
void beginActualText(GfxState *state, GooString *text) override; void beginActualText(GfxState *state, const GooString *text) override;
void endActualText(GfxState *state) override; void endActualText(GfxState *state) override;
GBool beginType3Char(GfxState *state, double x, double y, GBool beginType3Char(GfxState *state, double x, double y,
@ -274,10 +270,10 @@ public:
void setCairo (cairo_t *cr); void setCairo (cairo_t *cr);
void setTextPage (TextPage *text); void setTextPage (TextPage *text);
void setPrinting (GBool printing) { this->printing = printing; needFontUpdate = gTrue; } void setPrinting (GBool printingA) { printing = printingA; needFontUpdate = gTrue; }
void setAntialias(cairo_antialias_t antialias); void setAntialias(cairo_antialias_t antialias);
void setInType3Char(GBool inType3Char) { this->inType3Char = inType3Char; } void setInType3Char(GBool inType3CharA) { inType3Char = inType3CharA; }
void getType3GlyphWidth (double *wx, double *wy) { *wx = t3_glyph_wx; *wy = t3_glyph_wy; } void getType3GlyphWidth (double *wx, double *wy) { *wx = t3_glyph_wx; *wy = t3_glyph_wy; }
GBool hasType3GlyphBBox () { return t3_glyph_has_bbox; } GBool hasType3GlyphBBox () { return t3_glyph_has_bbox; }
double *getType3GlyphBBox () { return t3_glyph_bbox; } double *getType3GlyphBBox () { return t3_glyph_bbox; }
@ -292,11 +288,14 @@ protected:
GBool interpolate); GBool interpolate);
GBool getStreamData (Stream *str, char **buffer, int *length); GBool getStreamData (Stream *str, char **buffer, int *length);
void setMimeData(GfxState *state, Stream *str, Object *ref, void setMimeData(GfxState *state, Stream *str, Object *ref,
GfxImageColorMap *colorMap, cairo_surface_t *image); GfxImageColorMap *colorMap, cairo_surface_t *image, int height);
void fillToStrokePathClip(GfxState *state); void fillToStrokePathClip(GfxState *state);
void alignStrokeCoords(GfxSubpath *subpath, int i, double *x, double *y); void alignStrokeCoords(GfxSubpath *subpath, int i, double *x, double *y);
#if CAIRO_VERSION >= CAIRO_VERSION_ENCODE(1, 14, 0) #if CAIRO_VERSION >= CAIRO_VERSION_ENCODE(1, 14, 0)
GBool setMimeDataForJBIG2Globals (Stream *str, cairo_surface_t *image); GBool setMimeDataForJBIG2Globals (Stream *str, cairo_surface_t *image);
#endif
#if CAIRO_VERSION >= CAIRO_VERSION_ENCODE(1, 15, 10)
GBool setMimeDataForCCITTParams(Stream *str, cairo_surface_t *image, int height);
#endif #endif
static void setContextAntialias(cairo_t *cr, cairo_antialias_t antialias); static void setContextAntialias(cairo_t *cr, cairo_antialias_t antialias);
@ -337,7 +336,6 @@ protected:
GBool printing; GBool printing;
GBool use_show_text_glyphs; GBool use_show_text_glyphs;
GBool text_matrix_valid; GBool text_matrix_valid;
cairo_surface_t *surface;
cairo_glyph_t *glyphs; cairo_glyph_t *glyphs;
int glyphCount; int glyphCount;
cairo_text_cluster_t *clusters; cairo_text_cluster_t *clusters;
@ -361,7 +359,6 @@ protected:
cairo_pattern_t *shape; cairo_pattern_t *shape;
cairo_pattern_t *mask; cairo_pattern_t *mask;
cairo_matrix_t mask_matrix; cairo_matrix_t mask_matrix;
cairo_surface_t *cairo_shape_surface;
cairo_t *cairo_shape; cairo_t *cairo_shape;
int knockoutCount; int knockoutCount;
struct ColorSpaceStack { struct ColorSpaceStack {

View File

@ -38,14 +38,6 @@
// //
//======================================================================== //========================================================================
//========================================================================
//
// Copied from Ubuntu 18.04 apt-get source poppler (poppler-0.62.0)
// Copied on 2019/March/26
// Copied by Stephen Gaito in order to update pdf2htmlEX poppler dependencies
// Corrected <config.h> includes to <poppler-config.h>
//
//========================================================================
/* This implements a box filter that supports non-integer box sizes */ /* This implements a box filter that supports non-integer box sizes */
@ -279,9 +271,9 @@ GBool CairoRescaleBox::downScaleImage(unsigned orig_width, unsigned orig_height,
int dest_y; int dest_y;
int src_y = 0; int src_y = 0;
uint32_t *scanline; uint32_t *scanline;
int *x_coverage = NULL; int *x_coverage = nullptr;
int *y_coverage = NULL; int *y_coverage = nullptr;
uint32_t *temp_buf = NULL; uint32_t *temp_buf = nullptr;
GBool retval = gFalse; GBool retval = gFalse;
unsigned int *dest; unsigned int *dest;
int dst_stride; int dst_stride;

View File

@ -30,21 +30,13 @@
// under GPL version 2 or later // under GPL version 2 or later
// //
// Copyright (C) 2012 Adrian Johnson <ajohnson@redneon.com> // Copyright (C) 2012 Adrian Johnson <ajohnson@redneon.com>
// Copyright (C) 2018 Albert Astals Cid <aacid@kde.org>
// //
// To see a description of the changes please see the Changelog file that // 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 // came with your tarball or type make ChangeLog if you are building from git
// //
//======================================================================== //========================================================================
//========================================================================
//
// Copied from Ubuntu 18.04 apt-get source poppler (poppler-0.62.0)
// Copied on 2019/March/26
// Copied by Stephen Gaito in order to update pdf2htmlEX poppler dependencies
// Corrected <config.h> includes to <poppler-config.h>
//
//========================================================================
#ifndef CAIRO_RESCALE_BOX_H #ifndef CAIRO_RESCALE_BOX_H
#define CAIRO_RESCALE_BOX_H #define CAIRO_RESCALE_BOX_H
@ -57,6 +49,9 @@ public:
CairoRescaleBox() {}; CairoRescaleBox() {};
virtual ~CairoRescaleBox() {}; virtual ~CairoRescaleBox() {};
CairoRescaleBox(const CairoRescaleBox &) = delete;
CairoRescaleBox& operator=(const CairoRescaleBox &) = delete;
virtual GBool downScaleImage(unsigned orig_width, unsigned orig_height, virtual GBool downScaleImage(unsigned orig_width, unsigned orig_height,
signed scaled_width, signed scaled_height, signed scaled_width, signed scaled_height,
unsigned short int start_column, unsigned short int start_row, unsigned short int start_column, unsigned short int start_row,

View File

@ -81,7 +81,7 @@ void CairoBackgroundRenderer::beginTextObject(GfxState *state)
CairoOutputDev::beginTextObject(state); CairoOutputDev::beginTextObject(state);
} }
void CairoBackgroundRenderer::beginString(GfxState *state, GooString * str) void CairoBackgroundRenderer::beginString(GfxState *state, const GooString * str)
{ {
if (param.proof == 2) if (param.proof == 2)
proof_begin_string(state, this); proof_begin_string(state, this);
@ -239,7 +239,7 @@ void CairoBackgroundRenderer::setMimeData(GfxState *state, Stream *str, Object *
{ {
if (param.svg_embed_bitmap) if (param.svg_embed_bitmap)
{ {
CairoOutputDev::setMimeData(state, str, ref, colorMap, image); CairoOutputDev::setMimeData(state, str, ref, colorMap, image, cairo_image_surface_get_height (image));
return; return;
} }

View File

@ -46,7 +46,7 @@ public:
//for proof //for proof
void beginTextObject(GfxState *state); void beginTextObject(GfxState *state);
void beginString(GfxState *state, GooString * str); void beginString(GfxState *state, const GooString * str);
void endTextObject(GfxState *state); void endTextObject(GfxState *state);
void updateRender(GfxState *state); void updateRender(GfxState *state);

View File

@ -80,7 +80,7 @@ void SplashBackgroundRenderer::beginTextObject(GfxState *state)
SplashOutputDev::beginTextObject(state); SplashOutputDev::beginTextObject(state);
} }
void SplashBackgroundRenderer::beginString(GfxState *state, GooString * str) void SplashBackgroundRenderer::beginString(GfxState *state, const GooString * str)
{ {
if (param.proof == 2) if (param.proof == 2)
proof_begin_string(state, this); proof_begin_string(state, this);

View File

@ -48,7 +48,7 @@ public:
//for proof //for proof
void beginTextObject(GfxState *state); void beginTextObject(GfxState *state);
void beginString(GfxState *state, GooString * str); void beginString(GfxState *state, const GooString * str);
void endTextObject(GfxState *state); void endTextObject(GfxState *state);
void updateRender(GfxState *state); void updateRender(GfxState *state);

View File

@ -126,7 +126,7 @@ struct HTMLRenderer : OutputDev
virtual void eoClip(GfxState * state); virtual void eoClip(GfxState * state);
virtual void clipToStrokePath(GfxState * state); virtual void clipToStrokePath(GfxState * state);
virtual void drawString(GfxState * state, GooString * s); virtual void drawString(GfxState * state, const GooString * s);
virtual void drawImage(GfxState * state, Object * ref, Stream * str, int width, int height, GfxImageColorMap * colorMap, GBool interpolate, int *maskColors, GBool inlineImg); virtual void drawImage(GfxState * state, Object * ref, Stream * str, int width, int height, GfxImageColorMap * colorMap, GBool interpolate, int *maskColors, GBool inlineImg);
@ -170,7 +170,7 @@ protected:
void post_process(void); void post_process(void);
void process_outline(void); void process_outline(void);
void process_outline_items(GooList * items); void process_outline_items(const GooList * items);
void process_form(std::ofstream & out); void process_form(std::ofstream & out);
@ -179,7 +179,7 @@ protected:
void dump_css(void); void dump_css(void);
// convert a LinkAction to a string that our Javascript code can understand // convert a LinkAction to a string that our Javascript code can understand
std::string get_linkaction_str(LinkAction *, std::string & detail); std::string get_linkaction_str(const LinkAction *, std::string & detail);
//////////////////////////////////////////////////// ////////////////////////////////////////////////////
/* /*

View File

@ -595,6 +595,11 @@ void HTMLRenderer::embed_font(const string & filepath, GfxFont * font, FontInfo
bool name_conflict_warned = false; bool name_conflict_warned = false;
auto ctu = font->getToUnicode(); auto ctu = font->getToUnicode();
// NOTE: Poppler has changed its effective ABI
// in now expects the USER to increment any ref counters
assert(ctu);
((CharCodeToUnicode *)ctu)->incRefCnt();
std::fill(cur_mapping.begin(), cur_mapping.end(), -1); std::fill(cur_mapping.begin(), cur_mapping.end(), -1);
std::fill(width_list.begin(), width_list.end(), -1); std::fill(width_list.begin(), width_list.end(), -1);
@ -634,7 +639,9 @@ void HTMLRenderer::embed_font(const string & filepath, GfxFont * font, FontInfo
Unicode u, *pu=&u; Unicode u, *pu=&u;
if(info.use_tounicode) if(info.use_tounicode)
{ {
int n = ctu ? (ctu->mapToUnicode(cur_code, &pu)) : 0; int n = ctu ?
(((CharCodeToUnicode *)ctu)->mapToUnicode(cur_code, &pu)) :
0;
u = check_unicode(pu, n, cur_code, font); u = check_unicode(pu, n, cur_code, font);
} }
else else
@ -756,7 +763,7 @@ void HTMLRenderer::embed_font(const string & filepath, GfxFont * font, FontInfo
} }
if(ctu) if(ctu)
ctu->decRefCnt(); ((CharCodeToUnicode *)ctu)->decRefCnt();
} }
/* /*

View File

@ -126,7 +126,7 @@ static string get_linkdest_detail_str(LinkDest * dest, Catalog * catalog, int &
return sout.str(); return sout.str();
} }
string HTMLRenderer::get_linkaction_str(LinkAction * action, string & detail) string HTMLRenderer::get_linkaction_str(const LinkAction * action, string & detail)
{ {
string dest_str; string dest_str;
detail = ""; detail = "";
@ -137,7 +137,7 @@ string HTMLRenderer::get_linkaction_str(LinkAction * action, string & detail)
{ {
case actionGoTo: case actionGoTo:
{ {
auto * real_action = dynamic_cast<LinkGoTo*>(action); auto * real_action = dynamic_cast<const LinkGoTo*>(action);
LinkDest * dest = nullptr; LinkDest * dest = nullptr;
if(auto _ = real_action->getDest()) if(auto _ = real_action->getDest())
dest = _->copy(); dest = _->copy();
@ -162,7 +162,7 @@ string HTMLRenderer::get_linkaction_str(LinkAction * action, string & detail)
break; break;
case actionURI: case actionURI:
{ {
auto * real_action = dynamic_cast<LinkURI*>(action); auto * real_action = dynamic_cast<const LinkURI*>(action);
assert(real_action != nullptr); assert(real_action != nullptr);
dest_str = real_action->getURI()->getCString(); dest_str = real_action->getURI()->getCString();
} }

View File

@ -21,7 +21,7 @@ namespace pdf2htmlEX {
using std::ostream; using std::ostream;
void HTMLRenderer::process_outline_items(GooList * items) void HTMLRenderer::process_outline_items(const GooList * items)
{ {
if((!items) || (items->getLength() == 0)) if((!items) || (items->getLength() == 0))
return; return;

View File

@ -23,7 +23,7 @@ using std::none_of;
using std::cerr; using std::cerr;
using std::endl; using std::endl;
void HTMLRenderer::drawString(GfxState * state, GooString * s) void HTMLRenderer::drawString(GfxState * state, const GooString * s)
{ {
if(s->getLength() == 0) if(s->getLength() == 0)
return; return;
@ -58,7 +58,7 @@ void HTMLRenderer::drawString(GfxState * state, GooString * s)
// Now ready to output // Now ready to output
// get the unicodes // get the unicodes
char *p = s->getCString(); const char *p = s->getCString();
int len = s->getLength(); int len = s->getLength();
//accumulated displacement of chars in this string, in text object space //accumulated displacement of chars in this string, in text object space