1 commit 402c0274420fe39fd2f3393bc7d8d8879d436358
2 Author: Thomas Holder <thomas@thomas-holder.de>
3 Date: Fri Sep 28 18:05:30 2018 +0000
5 fix 1789208 poppler 0.69
7 diff --git a/CMakeScripts/DefineDependsandFlags.cmake b/CMakeScripts/DefineDependsandFlags.cmake
8 index 40ca7aa65c..9457d58df0 100644
9 --- a/CMakeScripts/DefineDependsandFlags.cmake
10 +++ b/CMakeScripts/DefineDependsandFlags.cmake
11 @@ -126,18 +126,6 @@ if(ENABLE_POPPLER)
12 set(HAVE_POPPLER_GLIB ON)
15 - if(POPPLER_VERSION VERSION_GREATER "0.26.0" OR
16 - POPPLER_VERSION VERSION_EQUAL "0.26.0")
17 - set(POPPLER_EVEN_NEWER_COLOR_SPACE_API ON)
19 - if(POPPLER_VERSION VERSION_GREATER "0.29.0" OR
20 - POPPLER_VERSION VERSION_EQUAL "0.29.0")
21 - set(POPPLER_EVEN_NEWER_NEW_COLOR_SPACE_API ON)
23 - if(POPPLER_VERSION VERSION_GREATER "0.58.0" OR
24 - POPPLER_VERSION VERSION_EQUAL "0.58.0")
25 - set(POPPLER_NEW_OBJECT_API ON)
28 set(ENABLE_POPPLER_CAIRO OFF)
30 diff --git a/src/extension/internal/pdfinput/pdf-input.cpp b/src/extension/internal/pdfinput/pdf-input.cpp
31 index fa9942230b..21a91fa34f 100644
32 --- a/src/extension/internal/pdfinput/pdf-input.cpp
33 +++ b/src/extension/internal/pdfinput/pdf-input.cpp
34 @@ -804,7 +804,7 @@ PdfInput::open(::Inkscape::Extension::Input * /*mod*/, const gchar * uri) {
35 dlg->getImportSettings(prefs);
37 // Apply crop settings
38 - PDFRectangle *clipToBox = NULL;
39 + _POPPLER_CONST PDFRectangle *clipToBox = nullptr;
41 sp_repr_get_double(prefs, "cropTo", &crop_setting);
43 diff --git a/src/extension/internal/pdfinput/pdf-input.h b/src/extension/internal/pdfinput/pdf-input.h
44 index ddcb8f222b..88a894f1c0 100644
45 --- a/src/extension/internal/pdfinput/pdf-input.h
46 +++ b/src/extension/internal/pdfinput/pdf-input.h
51 +#include "poppler-transition-api.h"
53 #include <gtkmm/dialog.h>
55 diff --git a/src/extension/internal/pdfinput/pdf-parser.cpp b/src/extension/internal/pdfinput/pdf-parser.cpp
56 index a3a8ff25a6..96313e1f19 100644
57 --- a/src/extension/internal/pdfinput/pdf-parser.cpp
58 +++ b/src/extension/internal/pdfinput/pdf-parser.cpp
59 @@ -291,8 +291,8 @@ PdfParser::PdfParser(XRef *xrefA,
64 - PDFRectangle *cropBox) :
65 + _POPPLER_CONST PDFRectangle *box,
66 + _POPPLER_CONST PDFRectangle *cropBox) :
70 @@ -314,7 +314,7 @@ PdfParser::PdfParser(XRef *xrefA,
71 builder->setDocumentSize(Inkscape::Util::Quantity::convert(state->getPageWidth(), "pt", "px"),
72 Inkscape::Util::Quantity::convert(state->getPageHeight(), "pt", "px"));
74 - double *ctm = state->getCTM();
75 + const double *ctm = state->getCTM();
77 for (int i = 0; i < 6; ++i) {
78 baseMatrix[i] = ctm[i];
79 @@ -349,7 +349,7 @@ PdfParser::PdfParser(XRef *xrefA,
80 PdfParser::PdfParser(XRef *xrefA,
81 Inkscape::Extension::Internal::SvgBuilder *builderA,
83 - PDFRectangle *box) :
84 + _POPPLER_CONST PDFRectangle *box) :
88 @@ -568,7 +568,7 @@ const char *PdfParser::getPreviousOperator(unsigned int look_back) {
90 void PdfParser::execOp(Object *cmd, Object args[], int numArgs) {
97 @@ -616,7 +616,7 @@ void PdfParser::execOp(Object *cmd, Object args[], int numArgs) {
98 (this->*op->func)(argPtr, numArgs);
101 -PdfOperator* PdfParser::findOp(char *name) {
102 +PdfOperator* PdfParser::findOp(const char *name) {
106 @@ -1748,7 +1748,7 @@ void PdfParser::doShadingPatternFillFallback(GfxShadingPattern *sPat,
107 GBool stroke, GBool eoFill) {
110 - double *ctm, *btm, *ptm;
111 + const double *ctm, *btm, *ptm;
112 double m[6], ictm[6], m1[6];
113 double xMin, yMin, xMax, yMax;
115 @@ -1990,7 +1990,7 @@ void PdfParser::doFunctionShFill1(GfxFunctionShading *shading,
116 GfxColor color0M, color1M, colorM0, colorM1, colorMM;
118 double functionColorDelta = colorDeltas[pdfFunctionShading-1];
120 + const double *matrix;
124 @@ -2170,7 +2170,7 @@ void PdfParser::doPatchMeshShFill(GfxPatchMeshShading *shading) {
128 -void PdfParser::fillPatch(GfxPatch *patch, int nComps, int depth) {
129 +void PdfParser::fillPatch(_POPPLER_CONST GfxPatch *patch, int nComps, int depth) {
130 GfxPatch patch00 = blankPatch();
131 GfxPatch patch01 = blankPatch();
132 GfxPatch patch10 = blankPatch();
133 @@ -2591,7 +2591,7 @@ void PdfParser::doShowText(GooString *s) {
134 double x, y, dx, dy, tdx, tdy;
135 double originX, originY, tOriginX, tOriginY;
136 double oldCTM[6], newCTM[6];
142 @@ -3665,7 +3665,6 @@ void PdfParser::opBeginImage(Object /*args*/[], int /*numArgs*/)
143 Stream *PdfParser::buildImageStream() {
150 @@ -3683,26 +3682,17 @@ Stream *PdfParser::buildImageStream() {
154 - key = copyString(obj.getName());
155 -#if defined(POPPLER_NEW_OBJECT_API)
156 - obj = parser->getObj();
159 - parser->getObj(&obj);
161 - if (obj.isEOF() || obj.isError()) {
164 + _POPPLER_CALL(obj2, parser->getObj);
165 + if (obj2.isEOF() || obj2.isError()) {
166 + _POPPLER_FREE(obj);
169 -#if defined(POPPLER_NEW_OBJECT_API)
170 - dict.dictAdd(key, std::move(obj));
171 + _POPPLER_DICTADD(dict, obj.getName(), obj2);
172 + _POPPLER_FREE(obj);
173 + _POPPLER_FREE(obj2);
175 - obj = parser->getObj();
177 - dict.dictAdd(key, &obj);
179 - parser->getObj(&obj);
181 + _POPPLER_CALL(obj, parser->getObj);
184 error(errSyntaxError, getPos(), "End of file in inline image");
185 diff --git a/src/extension/internal/pdfinput/pdf-parser.h b/src/extension/internal/pdfinput/pdf-parser.h
186 index b27a29cfbf..17eb025468 100644
187 --- a/src/extension/internal/pdfinput/pdf-parser.h
188 +++ b/src/extension/internal/pdfinput/pdf-parser.h
193 +#include "poppler-transition-api.h"
195 #ifdef USE_GCC_PRAGMAS
197 @@ -128,11 +129,14 @@ public:
199 // Constructor for regular output.
200 PdfParser(XRef *xrefA, SvgBuilder *builderA, int pageNum, int rotate,
201 - Dict *resDict, PDFRectangle *box, PDFRectangle *cropBox);
203 + _POPPLER_CONST PDFRectangle *box,
204 + _POPPLER_CONST PDFRectangle *cropBox);
206 // Constructor for a sub-page object.
207 PdfParser(XRef *xrefA, Inkscape::Extension::Internal::SvgBuilder *builderA,
208 - Dict *resDict, PDFRectangle *box);
210 + _POPPLER_CONST PDFRectangle *box);
212 virtual ~PdfParser();
214 @@ -186,7 +190,7 @@ private:
216 void go(GBool topLevel);
217 void execOp(Object *cmd, Object args[], int numArgs);
218 - PdfOperator *findOp(char *name);
219 + PdfOperator *findOp(const char *name);
220 GBool checkArg(Object *arg, TchkType type);
223 @@ -257,7 +261,7 @@ private:
224 double x2, double y2, GfxColor *color2,
225 int nComps, int depth);
226 void doPatchMeshShFill(GfxPatchMeshShading *shading);
227 - void fillPatch(GfxPatch *patch, int nComps, int depth);
228 + void fillPatch(_POPPLER_CONST GfxPatch *patch, int nComps, int depth);
231 // path clipping operators
232 diff --git a/src/extension/internal/pdfinput/poppler-transition-api.h b/src/extension/internal/pdfinput/poppler-transition-api.h
234 index 0000000000..898e64bf2b
236 +++ b/src/extension/internal/pdfinput/poppler-transition-api.h
238 +#ifndef SEEN_POPPLER_TRANSITION_API_H
239 +#define SEEN_POPPLER_TRANSITION_API_H
241 +#include <glib/poppler-features.h>
243 +#if POPPLER_CHECK_VERSION(0,70,0)
244 +#define _POPPLER_CONST const
246 +#define _POPPLER_CONST
249 +#if POPPLER_CHECK_VERSION(0,69,0)
250 +#define _POPPLER_DICTADD(dict, key, obj) (dict).dictAdd(key, std::move(obj))
251 +#elif POPPLER_CHECK_VERSION(0,58,0)
252 +#define _POPPLER_DICTADD(dict, key, obj) (dict).dictAdd(copyString(key), std::move(obj))
254 +#define _POPPLER_DICTADD(dict, key, obj) (dict).dictAdd(copyString(key), &obj)
257 +#if POPPLER_CHECK_VERSION(0,58,0)
258 +#define POPPLER_NEW_OBJECT_API
259 +#define _POPPLER_FREE(obj)
260 +#define _POPPLER_CALL(ret, func) (ret = func())
261 +#define _POPPLER_CALL_ARGS(ret, func, ...) (ret = func(__VA_ARGS__))
263 +#define _POPPLER_FREE(obj) (obj).free()
264 +#define _POPPLER_CALL(ret, func) (*func(&ret))
265 +#define _POPPLER_CALL_ARGS(ret, func, ...) (*func(__VA_ARGS__, &ret))
268 +#if POPPLER_CHECK_VERSION(0, 29, 0)
269 +#define POPPLER_EVEN_NEWER_NEW_COLOR_SPACE_API
272 +#if POPPLER_CHECK_VERSION(0, 25, 0)
273 +#define POPPLER_EVEN_NEWER_COLOR_SPACE_API
277 diff --git a/src/extension/internal/pdfinput/svg-builder.cpp b/src/extension/internal/pdfinput/svg-builder.cpp
278 index 9d0df7c04d..a59397a100 100644
279 --- a/src/extension/internal/pdfinput/svg-builder.cpp
280 +++ b/src/extension/internal/pdfinput/svg-builder.cpp
281 @@ -625,7 +625,7 @@ gchar *SvgBuilder::_createPattern(GfxPattern *pattern, GfxState *state, bool is_
282 if ( pattern != nullptr ) {
283 if ( pattern->getType() == 2 ) { // Shading pattern
284 GfxShadingPattern *shading_pattern = static_cast<GfxShadingPattern *>(pattern);
287 double m[6] = {1, 0, 0, 1, 0, 0};
290 @@ -672,7 +672,7 @@ gchar *SvgBuilder::_createTilingPattern(GfxTilingPattern *tiling_pattern,
292 Inkscape::XML::Node *pattern_node = _xml_doc->createElement("svg:pattern");
293 // Set pattern transform matrix
294 - double *p2u = tiling_pattern->getMatrix();
295 + const double *p2u = tiling_pattern->getMatrix();
296 double m[6] = {1, 0, 0, 1, 0, 0};
298 det = _ttm[0] * _ttm[3] - _ttm[1] * _ttm[2]; // see LP Bug 1168908
299 @@ -698,7 +698,7 @@ gchar *SvgBuilder::_createTilingPattern(GfxTilingPattern *tiling_pattern,
300 pattern_node->setAttribute("patternUnits", "userSpaceOnUse");
301 // Set pattern tiling
302 // FIXME: don't ignore XStep and YStep
303 - double *bbox = tiling_pattern->getBBox();
304 + const double *bbox = tiling_pattern->getBBox();
305 sp_repr_set_svg_double(pattern_node, "x", 0.0);
306 sp_repr_set_svg_double(pattern_node, "y", 0.0);
307 sp_repr_set_svg_double(pattern_node, "width", bbox[2] - bbox[0]);
308 @@ -751,7 +751,7 @@ gchar *SvgBuilder::_createTilingPattern(GfxTilingPattern *tiling_pattern,
310 gchar *SvgBuilder::_createGradient(GfxShading *shading, double *matrix, bool for_shading) {
311 Inkscape::XML::Node *gradient;
313 + _POPPLER_CONST Function *func;
315 bool extend0, extend1;
317 @@ -865,7 +865,7 @@ static bool svgGetShadingColorRGB(GfxShading *shading, double offset, GfxRGB *re
319 #define INT_EPSILON 8
320 bool SvgBuilder::_addGradientStops(Inkscape::XML::Node *gradient, GfxShading *shading,
322 + _POPPLER_CONST Function *func) {
323 int type = func->getType();
324 if ( type == 0 || type == 2 ) { // Sampled or exponential function
326 @@ -877,9 +877,9 @@ bool SvgBuilder::_addGradientStops(Inkscape::XML::Node *gradient, GfxShading *sh
327 _addStopToGradient(gradient, 1.0, &stop2, 1.0);
329 } else if ( type == 3 ) { // Stitching
330 - StitchingFunction *stitchingFunc = static_cast<StitchingFunction*>(func);
331 - double *bounds = stitchingFunc->getBounds();
332 - double *encode = stitchingFunc->getEncode();
333 + auto stitchingFunc = static_cast<_POPPLER_CONST StitchingFunction*>(func);
334 + const double *bounds = stitchingFunc->getBounds();
335 + const double *encode = stitchingFunc->getEncode();
336 int num_funcs = stitchingFunc->getNumFuncs();
338 // Add stops from all the stitched functions
339 @@ -890,7 +890,7 @@ bool SvgBuilder::_addGradientStops(Inkscape::XML::Node *gradient, GfxShading *sh
340 svgGetShadingColorRGB(shading, bounds[i + 1], &color);
342 if (stitchingFunc->getFunc(i)->getType() == 2) { // process exponential fxn
343 - double expE = (static_cast<ExponentialFunction*>(stitchingFunc->getFunc(i)))->getE();
344 + double expE = (static_cast<_POPPLER_CONST ExponentialFunction*>(stitchingFunc->getFunc(i)))->getE();
346 expE = (bounds[i + 1] - bounds[i])/expE; // approximate exponential as a single straight line at x=1
347 if (encode[2*i] == 0) { // normal sequence
348 @@ -1148,7 +1148,7 @@ void SvgBuilder::updateFont(GfxState *state) {
349 Inkscape::CSSOStringStream os_font_size;
350 double css_font_size = _font_scaling * state->getFontSize();
351 if ( font->getType() == fontType3 ) {
352 - double *font_matrix = font->getFontMatrix();
353 + const double *font_matrix = font->getFontMatrix();
354 if ( font_matrix[0] != 0.0 ) {
355 css_font_size *= font_matrix[3] / font_matrix[0];
357 @@ -1193,7 +1193,7 @@ void SvgBuilder::updateTextPosition(double tx, double ty) {
358 void SvgBuilder::updateTextMatrix(GfxState *state) {
360 // Update text matrix
361 - double *text_matrix = state->getTextMat();
362 + const double *text_matrix = state->getTextMat();
363 double w_scale = sqrt( text_matrix[0] * text_matrix[0] + text_matrix[2] * text_matrix[2] );
364 double h_scale = sqrt( text_matrix[1] * text_matrix[1] + text_matrix[3] * text_matrix[3] );
366 diff --git a/src/extension/internal/pdfinput/svg-builder.h b/src/extension/internal/pdfinput/svg-builder.h
367 index 729cdc944c..7fdb0b5fcd 100644
368 --- a/src/extension/internal/pdfinput/svg-builder.h
369 +++ b/src/extension/internal/pdfinput/svg-builder.h
374 +#include "poppler-transition-api.h"
378 @@ -174,7 +175,7 @@ private:
379 void _addStopToGradient(Inkscape::XML::Node *gradient, double offset,
380 GfxRGB *color, double opacity);
381 bool _addGradientStops(Inkscape::XML::Node *gradient, GfxShading *shading,
383 + _POPPLER_CONST Function *func);
384 gchar *_createTilingPattern(GfxTilingPattern *tiling_pattern, GfxState *state,
385 bool is_stroke=false);
386 // Image/mask creation