1 From a600c6438fef2f4c06f9a4a7d933d99fb054a973 Mon Sep 17 00:00:00 2001
2 From: Eduard Braun <eduard.braun2@gmx.de>
3 Date: Tue, 24 Apr 2018 19:18:26 +0200
4 Subject: [PATCH] Fix compilation with poppler 0.64
7 src/extension/internal/pdfinput/pdf-parser.cpp | 10 +++++-----
8 src/extension/internal/pdfinput/pdf-parser.h | 2 +-
9 src/extension/internal/pdfinput/svg-builder.cpp | 4 ++--
10 src/extension/internal/pdfinput/svg-builder.h | 3 +--
11 4 files changed, 9 insertions(+), 10 deletions(-)
13 diff --git a/src/extension/internal/pdfinput/pdf-parser.cpp b/src/extension/internal/pdfinput/pdf-parser.cpp
14 index 15bc2d746d..6c498f9812 100644
15 --- a/src/extension/internal/pdfinput/pdf-parser.cpp
16 +++ b/src/extension/internal/pdfinput/pdf-parser.cpp
17 @@ -2582,7 +2582,7 @@ void PdfParser::opShowSpaceText(Object args[], int /*numArgs*/)
21 -void PdfParser::doShowText(GooString *s) {
22 +void PdfParser::doShowText(const GooString *s) {
26 @@ -2601,7 +2601,7 @@ void PdfParser::doShowText(GooString *s) {
27 font = state->getFont();
28 wMode = font->getWMode();
30 - builder->beginString(state, s);
31 + builder->beginString(state);
33 // handle a Type 3 char
34 if (font->getType() == fontType3 && 0) {//out->interpretType3Chars()) {
35 @@ -2631,7 +2631,7 @@ void PdfParser::doShowText(GooString *s) {
36 double lineX = state->getLineX();
37 double lineY = state->getLineY();
39 - p = s->getCString();
40 + p = g_strdup(s->getCString());
43 n = font->getNextChar(p, len, &code,
44 @@ -2686,7 +2686,7 @@ void PdfParser::doShowText(GooString *s) {
47 state->textTransformDelta(0, state->getRise(), &riseX, &riseY);
48 - p = s->getCString();
49 + p = g_strdup(s->getCString());
52 n = font->getNextChar(p, len, &code,
53 @@ -2732,7 +2732,7 @@ void PdfParser::opXObject(Object args[], int /*numArgs*/)
55 Object obj1, obj2, obj3, refObj;
57 - char *name = args[0].getName();
58 + char *name = g_strdup(args[0].getName());
59 #if defined(POPPLER_NEW_OBJECT_API)
60 if ((obj1 = res->lookupXObject(name)).isNull()) {
62 diff --git a/src/extension/internal/pdfinput/pdf-parser.h b/src/extension/internal/pdfinput/pdf-parser.h
63 index e28fecc2e1..f985b15cad 100644
64 --- a/src/extension/internal/pdfinput/pdf-parser.h
65 +++ b/src/extension/internal/pdfinput/pdf-parser.h
66 @@ -287,7 +287,7 @@ private:
67 void opMoveShowText(Object args[], int numArgs);
68 void opMoveSetShowText(Object args[], int numArgs);
69 void opShowSpaceText(Object args[], int numArgs);
70 - void doShowText(GooString *s);
71 + void doShowText(const GooString *s);
74 void opXObject(Object args[], int numArgs);
75 diff --git a/src/extension/internal/pdfinput/svg-builder.cpp b/src/extension/internal/pdfinput/svg-builder.cpp
76 index 158c5ae068..8e5a5f6396 100644
77 --- a/src/extension/internal/pdfinput/svg-builder.cpp
78 +++ b/src/extension/internal/pdfinput/svg-builder.cpp
79 @@ -1021,7 +1021,7 @@ void SvgBuilder::updateFont(GfxState *state) {
80 GfxFont *font = state->getFont();
81 // Store original name
82 if (font->getName()) {
83 - _font_specification = font->getName()->getCString();
84 + _font_specification = g_strdup(font->getName()->getCString());
86 _font_specification = (char*) "Arial";
88 @@ -1362,7 +1362,7 @@ void SvgBuilder::_flushText() {
92 -void SvgBuilder::beginString(GfxState *state, GooString * /*s*/) {
93 +void SvgBuilder::beginString(GfxState *state) {
94 if (_need_font_update) {
97 diff --git a/src/extension/internal/pdfinput/svg-builder.h b/src/extension/internal/pdfinput/svg-builder.h
98 index ad15c9c06f..ed2a4d48e0 100644
99 --- a/src/extension/internal/pdfinput/svg-builder.h
100 +++ b/src/extension/internal/pdfinput/svg-builder.h
101 @@ -29,7 +29,6 @@ namespace Inkscape {
102 #include <glibmm/ustring.h>
104 #include "CharTypes.h"
109 @@ -136,7 +135,7 @@ public:
110 void clearSoftMask(GfxState *state);
113 - void beginString(GfxState *state, GooString *s);
114 + void beginString(GfxState *state);
115 void endString(GfxState *state);
116 void addChar(GfxState *state, double x, double y,
117 double dx, double dy,
121 From 722e121361d0f784083d10e897155b7d4e44e515 Mon Sep 17 00:00:00 2001
122 From: Eduard Braun <eduard.braun2@gmx.de>
123 Date: Wed, 5 Sep 2018 00:31:06 +0200
124 Subject: [PATCH] Modified fix for compatibility with poppler 0.64
126 This is slightly uglier than a600c6438fef2f4c06f9a4a7d933d99fb054a973
127 but avoids duplicating strings (which is unnecessary and leaked memory).
129 It's also closer to what upstream intended with the changes in 0.64.
131 .../internal/pdfinput/pdf-parser.cpp | 19 ++++++++++++++++---
132 src/extension/internal/pdfinput/pdf-parser.h | 6 ++++++
133 .../internal/pdfinput/svg-builder.cpp | 6 +++---
134 src/extension/internal/pdfinput/svg-builder.h | 4 ++--
135 4 files changed, 27 insertions(+), 8 deletions(-)
137 diff --git a/src/extension/internal/pdfinput/pdf-parser.cpp b/src/extension/internal/pdfinput/pdf-parser.cpp
138 index 5fa21263ab..a3a8ff25a6 100644
139 --- a/src/extension/internal/pdfinput/pdf-parser.cpp
140 +++ b/src/extension/internal/pdfinput/pdf-parser.cpp
142 #include "pdf-parser.h"
143 #include "util/units.h"
145 +#include "glib/poppler-features.h"
146 #include "goo/gmem.h"
147 #include "goo/GooString.h"
148 #include "GlobalParams.h"
149 @@ -2577,7 +2578,11 @@ void PdfParser::opShowSpaceText(Object args[], int /*numArgs*/)
153 +#if POPPLER_CHECK_VERSION(0,64,0)
154 void PdfParser::doShowText(const GooString *s) {
156 +void PdfParser::doShowText(GooString *s) {
161 @@ -2590,7 +2595,11 @@ void PdfParser::doShowText(const GooString *s) {
165 +#if POPPLER_CHECK_VERSION(0,64,0)
172 font = state->getFont();
173 @@ -2626,7 +2635,7 @@ void PdfParser::doShowText(const GooString *s) {
174 double lineX = state->getLineX();
175 double lineY = state->getLineY();
177 - p = g_strdup(s->getCString());
178 + p = s->getCString();
179 len = s->getLength();
181 n = font->getNextChar(p, len, &code,
182 @@ -2681,7 +2690,7 @@ void PdfParser::doShowText(const GooString *s) {
185 state->textTransformDelta(0, state->getRise(), &riseX, &riseY);
186 - p = g_strdup(s->getCString());
187 + p = s->getCString();
188 len = s->getLength();
190 n = font->getNextChar(p, len, &code,
191 @@ -2727,7 +2736,11 @@ void PdfParser::opXObject(Object args[], int /*numArgs*/)
193 Object obj1, obj2, obj3, refObj;
195 - char *name = g_strdup(args[0].getName());
196 +#if POPPLER_CHECK_VERSION(0,64,0)
197 + const char *name = args[0].getName();
199 + char *name = args[0].getName();
201 #if defined(POPPLER_NEW_OBJECT_API)
202 if ((obj1 = res->lookupXObject(name)).isNull()) {
204 diff --git a/src/extension/internal/pdfinput/pdf-parser.h b/src/extension/internal/pdfinput/pdf-parser.h
205 index 755e6741b0..b27a29cfbf 100644
206 --- a/src/extension/internal/pdfinput/pdf-parser.h
207 +++ b/src/extension/internal/pdfinput/pdf-parser.h
208 @@ -25,6 +25,7 @@ namespace Inkscape {
209 // TODO clean up and remove using:
210 using Inkscape::Extension::Internal::SvgBuilder;
212 +#include "glib/poppler-features.h"
213 #include "goo/gtypes.h"
216 @@ -287,7 +288,12 @@ private:
217 void opMoveShowText(Object args[], int numArgs);
218 void opMoveSetShowText(Object args[], int numArgs);
219 void opShowSpaceText(Object args[], int numArgs);
220 +#if POPPLER_CHECK_VERSION(0,64,0)
221 void doShowText(const GooString *s);
223 + void doShowText(GooString *s);
228 void opXObject(Object args[], int numArgs);
229 diff --git a/src/extension/internal/pdfinput/svg-builder.cpp b/src/extension/internal/pdfinput/svg-builder.cpp
230 index 50a7685b89..9d0df7c04d 100644
231 --- a/src/extension/internal/pdfinput/svg-builder.cpp
232 +++ b/src/extension/internal/pdfinput/svg-builder.cpp
233 @@ -1020,9 +1020,9 @@ void SvgBuilder::updateFont(GfxState *state) {
234 GfxFont *font = state->getFont();
235 // Store original name
236 if (font->getName()) {
237 - _font_specification = g_strdup(font->getName()->getCString());
238 + _font_specification = font->getName()->getCString();
240 - _font_specification = (char*) "Arial";
241 + _font_specification = "Arial";
244 // Prune the font name to get the correct font family name
245 @@ -1030,7 +1030,7 @@ void SvgBuilder::updateFont(GfxState *state) {
246 char *font_family = NULL;
247 char *font_style = NULL;
248 char *font_style_lowercase = NULL;
249 - char *plus_sign = strstr(_font_specification, "+");
250 + const char *plus_sign = strstr(_font_specification, "+");
252 font_family = g_strdup(plus_sign + 1);
253 _font_specification = plus_sign + 1;
254 diff --git a/src/extension/internal/pdfinput/svg-builder.h b/src/extension/internal/pdfinput/svg-builder.h
255 index 499724a4cd..729cdc944c 100644
256 --- a/src/extension/internal/pdfinput/svg-builder.h
257 +++ b/src/extension/internal/pdfinput/svg-builder.h
258 @@ -80,7 +80,7 @@ struct SvgGlyph {
259 bool style_changed; // Set to true if style has to be reset
261 int render_mode; // Text render mode
262 - char *font_specification; // Pointer to current font specification
263 + const char *font_specification; // Pointer to current font specification
267 @@ -202,7 +202,7 @@ private:
269 SPCSSAttr *_font_style; // Current font style
270 GfxFont *_current_font;
271 - char *_font_specification;
272 + const char *_font_specification;
273 double _font_scaling;
274 bool _need_font_update;
275 Geom::Affine _text_matrix;
279 From 402c0274420fe39fd2f3393bc7d8d8879d436358 Mon Sep 17 00:00:00 2001
280 From: Thomas Holder <thomas@thomas-holder.de>
281 Date: Fri, 28 Sep 2018 18:05:30 +0000
282 Subject: [PATCH] fix 1789208 poppler 0.69
285 CMakeScripts/DefineDependsandFlags.cmake | 12 -----
286 src/extension/internal/pdfinput/pdf-input.cpp | 2 +-
287 src/extension/internal/pdfinput/pdf-input.h | 1 +
288 .../internal/pdfinput/pdf-parser.cpp | 46 ++++++++-----------
289 src/extension/internal/pdfinput/pdf-parser.h | 12 +++--
290 .../pdfinput/poppler-transition-api.h | 39 ++++++++++++++++
291 .../internal/pdfinput/svg-builder.cpp | 22 ++++-----
292 src/extension/internal/pdfinput/svg-builder.h | 3 +-
293 8 files changed, 80 insertions(+), 57 deletions(-)
294 create mode 100644 src/extension/internal/pdfinput/poppler-transition-api.h
296 diff --git a/CMakeScripts/DefineDependsandFlags.cmake b/CMakeScripts/DefineDependsandFlags.cmake
297 index 40ca7aa65c..9457d58df0 100644
298 --- a/CMakeScripts/DefineDependsandFlags.cmake
299 +++ b/CMakeScripts/DefineDependsandFlags.cmake
300 @@ -126,18 +126,6 @@ if(ENABLE_POPPLER)
301 set(HAVE_POPPLER_GLIB ON)
304 - if(POPPLER_VERSION VERSION_GREATER "0.26.0" OR
305 - POPPLER_VERSION VERSION_EQUAL "0.26.0")
306 - set(POPPLER_EVEN_NEWER_COLOR_SPACE_API ON)
308 - if(POPPLER_VERSION VERSION_GREATER "0.29.0" OR
309 - POPPLER_VERSION VERSION_EQUAL "0.29.0")
310 - set(POPPLER_EVEN_NEWER_NEW_COLOR_SPACE_API ON)
312 - if(POPPLER_VERSION VERSION_GREATER "0.58.0" OR
313 - POPPLER_VERSION VERSION_EQUAL "0.58.0")
314 - set(POPPLER_NEW_OBJECT_API ON)
317 set(ENABLE_POPPLER_CAIRO OFF)
319 diff --git a/src/extension/internal/pdfinput/pdf-input.cpp b/src/extension/internal/pdfinput/pdf-input.cpp
320 index fa9942230b..21a91fa34f 100644
321 --- a/src/extension/internal/pdfinput/pdf-input.cpp
322 +++ b/src/extension/internal/pdfinput/pdf-input.cpp
323 @@ -804,7 +804,7 @@ PdfInput::open(::Inkscape::Extension::Input * /*mod*/, const gchar * uri) {
324 dlg->getImportSettings(prefs);
326 // Apply crop settings
327 - PDFRectangle *clipToBox = NULL;
328 + _POPPLER_CONST PDFRectangle *clipToBox = NULL;
330 sp_repr_get_double(prefs, "cropTo", &crop_setting);
332 diff --git a/src/extension/internal/pdfinput/pdf-input.h b/src/extension/internal/pdfinput/pdf-input.h
333 index ddcb8f222b..88a894f1c0 100644
334 --- a/src/extension/internal/pdfinput/pdf-input.h
335 +++ b/src/extension/internal/pdfinput/pdf-input.h
340 +#include "poppler-transition-api.h"
342 #include <gtkmm/dialog.h>
344 diff --git a/src/extension/internal/pdfinput/pdf-parser.cpp b/src/extension/internal/pdfinput/pdf-parser.cpp
345 index a3a8ff25a6..96313e1f19 100644
346 --- a/src/extension/internal/pdfinput/pdf-parser.cpp
347 +++ b/src/extension/internal/pdfinput/pdf-parser.cpp
348 @@ -291,8 +291,8 @@ PdfParser::PdfParser(XRef *xrefA,
353 - PDFRectangle *cropBox) :
354 + _POPPLER_CONST PDFRectangle *box,
355 + _POPPLER_CONST PDFRectangle *cropBox) :
359 @@ -314,7 +314,7 @@ PdfParser::PdfParser(XRef *xrefA,
360 builder->setDocumentSize(Inkscape::Util::Quantity::convert(state->getPageWidth(), "pt", "px"),
361 Inkscape::Util::Quantity::convert(state->getPageHeight(), "pt", "px"));
363 - double *ctm = state->getCTM();
364 + const double *ctm = state->getCTM();
366 for (int i = 0; i < 6; ++i) {
367 baseMatrix[i] = ctm[i];
368 @@ -349,7 +349,7 @@ PdfParser::PdfParser(XRef *xrefA,
369 PdfParser::PdfParser(XRef *xrefA,
370 Inkscape::Extension::Internal::SvgBuilder *builderA,
372 - PDFRectangle *box) :
373 + _POPPLER_CONST PDFRectangle *box) :
377 @@ -568,7 +568,7 @@ const char *PdfParser::getPreviousOperator(unsigned int look_back) {
379 void PdfParser::execOp(Object *cmd, Object args[], int numArgs) {
386 @@ -616,7 +616,7 @@ void PdfParser::execOp(Object *cmd, Object args[], int numArgs) {
387 (this->*op->func)(argPtr, numArgs);
390 -PdfOperator* PdfParser::findOp(char *name) {
391 +PdfOperator* PdfParser::findOp(const char *name) {
395 @@ -1748,7 +1748,7 @@ void PdfParser::doShadingPatternFillFallback(GfxShadingPattern *sPat,
396 GBool stroke, GBool eoFill) {
399 - double *ctm, *btm, *ptm;
400 + const double *ctm, *btm, *ptm;
401 double m[6], ictm[6], m1[6];
402 double xMin, yMin, xMax, yMax;
404 @@ -1990,7 +1990,7 @@ void PdfParser::doFunctionShFill1(GfxFunctionShading *shading,
405 GfxColor color0M, color1M, colorM0, colorM1, colorMM;
407 double functionColorDelta = colorDeltas[pdfFunctionShading-1];
409 + const double *matrix;
413 @@ -2170,7 +2170,7 @@ void PdfParser::doPatchMeshShFill(GfxPatchMeshShading *shading) {
417 -void PdfParser::fillPatch(GfxPatch *patch, int nComps, int depth) {
418 +void PdfParser::fillPatch(_POPPLER_CONST GfxPatch *patch, int nComps, int depth) {
419 GfxPatch patch00 = blankPatch();
420 GfxPatch patch01 = blankPatch();
421 GfxPatch patch10 = blankPatch();
422 @@ -2591,7 +2591,7 @@ void PdfParser::doShowText(GooString *s) {
423 double x, y, dx, dy, tdx, tdy;
424 double originX, originY, tOriginX, tOriginY;
425 double oldCTM[6], newCTM[6];
431 @@ -3665,7 +3665,6 @@ void PdfParser::opBeginImage(Object /*args*/[], int /*numArgs*/)
432 Stream *PdfParser::buildImageStream() {
439 @@ -3683,26 +3682,17 @@ Stream *PdfParser::buildImageStream() {
443 - key = copyString(obj.getName());
444 -#if defined(POPPLER_NEW_OBJECT_API)
445 - obj = parser->getObj();
448 - parser->getObj(&obj);
450 - if (obj.isEOF() || obj.isError()) {
453 + _POPPLER_CALL(obj2, parser->getObj);
454 + if (obj2.isEOF() || obj2.isError()) {
455 + _POPPLER_FREE(obj);
458 -#if defined(POPPLER_NEW_OBJECT_API)
459 - dict.dictAdd(key, std::move(obj));
460 + _POPPLER_DICTADD(dict, obj.getName(), obj2);
461 + _POPPLER_FREE(obj);
462 + _POPPLER_FREE(obj2);
464 - obj = parser->getObj();
466 - dict.dictAdd(key, &obj);
468 - parser->getObj(&obj);
470 + _POPPLER_CALL(obj, parser->getObj);
473 error(errSyntaxError, getPos(), "End of file in inline image");
474 diff --git a/src/extension/internal/pdfinput/pdf-parser.h b/src/extension/internal/pdfinput/pdf-parser.h
475 index b27a29cfbf..17eb025468 100644
476 --- a/src/extension/internal/pdfinput/pdf-parser.h
477 +++ b/src/extension/internal/pdfinput/pdf-parser.h
482 +#include "poppler-transition-api.h"
484 #ifdef USE_GCC_PRAGMAS
486 @@ -128,11 +129,14 @@ public:
488 // Constructor for regular output.
489 PdfParser(XRef *xrefA, SvgBuilder *builderA, int pageNum, int rotate,
490 - Dict *resDict, PDFRectangle *box, PDFRectangle *cropBox);
492 + _POPPLER_CONST PDFRectangle *box,
493 + _POPPLER_CONST PDFRectangle *cropBox);
495 // Constructor for a sub-page object.
496 PdfParser(XRef *xrefA, Inkscape::Extension::Internal::SvgBuilder *builderA,
497 - Dict *resDict, PDFRectangle *box);
499 + _POPPLER_CONST PDFRectangle *box);
501 virtual ~PdfParser();
503 @@ -186,7 +190,7 @@ private:
505 void go(GBool topLevel);
506 void execOp(Object *cmd, Object args[], int numArgs);
507 - PdfOperator *findOp(char *name);
508 + PdfOperator *findOp(const char *name);
509 GBool checkArg(Object *arg, TchkType type);
512 @@ -257,7 +261,7 @@ private:
513 double x2, double y2, GfxColor *color2,
514 int nComps, int depth);
515 void doPatchMeshShFill(GfxPatchMeshShading *shading);
516 - void fillPatch(GfxPatch *patch, int nComps, int depth);
517 + void fillPatch(_POPPLER_CONST GfxPatch *patch, int nComps, int depth);
520 // path clipping operators
521 diff --git a/src/extension/internal/pdfinput/poppler-transition-api.h b/src/extension/internal/pdfinput/poppler-transition-api.h
523 index 0000000000..898e64bf2b
525 +++ b/src/extension/internal/pdfinput/poppler-transition-api.h
527 +#ifndef SEEN_POPPLER_TRANSITION_API_H
528 +#define SEEN_POPPLER_TRANSITION_API_H
530 +#include <glib/poppler-features.h>
532 +#if POPPLER_CHECK_VERSION(0,70,0)
533 +#define _POPPLER_CONST const
535 +#define _POPPLER_CONST
538 +#if POPPLER_CHECK_VERSION(0,69,0)
539 +#define _POPPLER_DICTADD(dict, key, obj) (dict).dictAdd(key, std::move(obj))
540 +#elif POPPLER_CHECK_VERSION(0,58,0)
541 +#define _POPPLER_DICTADD(dict, key, obj) (dict).dictAdd(copyString(key), std::move(obj))
543 +#define _POPPLER_DICTADD(dict, key, obj) (dict).dictAdd(copyString(key), &obj)
546 +#if POPPLER_CHECK_VERSION(0,58,0)
547 +#define POPPLER_NEW_OBJECT_API
548 +#define _POPPLER_FREE(obj)
549 +#define _POPPLER_CALL(ret, func) (ret = func())
550 +#define _POPPLER_CALL_ARGS(ret, func, ...) (ret = func(__VA_ARGS__))
552 +#define _POPPLER_FREE(obj) (obj).free()
553 +#define _POPPLER_CALL(ret, func) (*func(&ret))
554 +#define _POPPLER_CALL_ARGS(ret, func, ...) (*func(__VA_ARGS__, &ret))
557 +#if POPPLER_CHECK_VERSION(0, 29, 0)
558 +#define POPPLER_EVEN_NEWER_NEW_COLOR_SPACE_API
561 +#if POPPLER_CHECK_VERSION(0, 25, 0)
562 +#define POPPLER_EVEN_NEWER_COLOR_SPACE_API
566 diff --git a/src/extension/internal/pdfinput/svg-builder.cpp b/src/extension/internal/pdfinput/svg-builder.cpp
567 index 9d0df7c04d..a59397a100 100644
568 --- a/src/extension/internal/pdfinput/svg-builder.cpp
569 +++ b/src/extension/internal/pdfinput/svg-builder.cpp
570 @@ -625,7 +625,7 @@ gchar *SvgBuilder::_createPattern(GfxPattern *pattern, GfxState *state, bool is_
571 if ( pattern != nullptr ) {
572 if ( pattern->getType() == 2 ) { // Shading pattern
573 GfxShadingPattern *shading_pattern = static_cast<GfxShadingPattern *>(pattern);
576 double m[6] = {1, 0, 0, 1, 0, 0};
579 @@ -672,7 +672,7 @@ gchar *SvgBuilder::_createTilingPattern(GfxTilingPattern *tiling_pattern,
581 Inkscape::XML::Node *pattern_node = _xml_doc->createElement("svg:pattern");
582 // Set pattern transform matrix
583 - double *p2u = tiling_pattern->getMatrix();
584 + const double *p2u = tiling_pattern->getMatrix();
585 double m[6] = {1, 0, 0, 1, 0, 0};
587 det = _ttm[0] * _ttm[3] - _ttm[1] * _ttm[2]; // see LP Bug 1168908
588 @@ -698,7 +698,7 @@ gchar *SvgBuilder::_createTilingPattern(GfxTilingPattern *tiling_pattern,
589 pattern_node->setAttribute("patternUnits", "userSpaceOnUse");
590 // Set pattern tiling
591 // FIXME: don't ignore XStep and YStep
592 - double *bbox = tiling_pattern->getBBox();
593 + const double *bbox = tiling_pattern->getBBox();
594 sp_repr_set_svg_double(pattern_node, "x", 0.0);
595 sp_repr_set_svg_double(pattern_node, "y", 0.0);
596 sp_repr_set_svg_double(pattern_node, "width", bbox[2] - bbox[0]);
597 @@ -751,7 +751,7 @@ gchar *SvgBuilder::_createTilingPattern(GfxTilingPattern *tiling_pattern,
599 gchar *SvgBuilder::_createGradient(GfxShading *shading, double *matrix, bool for_shading) {
600 Inkscape::XML::Node *gradient;
602 + _POPPLER_CONST Function *func;
604 bool extend0, extend1;
606 @@ -865,7 +865,7 @@ static bool svgGetShadingColorRGB(GfxShading *shading, double offset, GfxRGB *re
608 #define INT_EPSILON 8
609 bool SvgBuilder::_addGradientStops(Inkscape::XML::Node *gradient, GfxShading *shading,
611 + _POPPLER_CONST Function *func) {
612 int type = func->getType();
613 if ( type == 0 || type == 2 ) { // Sampled or exponential function
615 @@ -877,9 +877,9 @@ bool SvgBuilder::_addGradientStops(Inkscape::XML::Node *gradient, GfxShading *sh
616 _addStopToGradient(gradient, 1.0, &stop2, 1.0);
618 } else if ( type == 3 ) { // Stitching
619 - StitchingFunction *stitchingFunc = static_cast<StitchingFunction*>(func);
620 - double *bounds = stitchingFunc->getBounds();
621 - double *encode = stitchingFunc->getEncode();
622 + auto stitchingFunc = static_cast<_POPPLER_CONST StitchingFunction*>(func);
623 + const double *bounds = stitchingFunc->getBounds();
624 + const double *encode = stitchingFunc->getEncode();
625 int num_funcs = stitchingFunc->getNumFuncs();
627 // Add stops from all the stitched functions
628 @@ -890,7 +890,7 @@ bool SvgBuilder::_addGradientStops(Inkscape::XML::Node *gradient, GfxShading *sh
629 svgGetShadingColorRGB(shading, bounds[i + 1], &color);
631 if (stitchingFunc->getFunc(i)->getType() == 2) { // process exponential fxn
632 - double expE = (static_cast<ExponentialFunction*>(stitchingFunc->getFunc(i)))->getE();
633 + double expE = (static_cast<_POPPLER_CONST ExponentialFunction*>(stitchingFunc->getFunc(i)))->getE();
635 expE = (bounds[i + 1] - bounds[i])/expE; // approximate exponential as a single straight line at x=1
636 if (encode[2*i] == 0) { // normal sequence
637 @@ -1148,7 +1148,7 @@ void SvgBuilder::updateFont(GfxState *state) {
638 Inkscape::CSSOStringStream os_font_size;
639 double css_font_size = _font_scaling * state->getFontSize();
640 if ( font->getType() == fontType3 ) {
641 - double *font_matrix = font->getFontMatrix();
642 + const double *font_matrix = font->getFontMatrix();
643 if ( font_matrix[0] != 0.0 ) {
644 css_font_size *= font_matrix[3] / font_matrix[0];
646 @@ -1193,7 +1193,7 @@ void SvgBuilder::updateTextPosition(double tx, double ty) {
647 void SvgBuilder::updateTextMatrix(GfxState *state) {
649 // Update text matrix
650 - double *text_matrix = state->getTextMat();
651 + const double *text_matrix = state->getTextMat();
652 double w_scale = sqrt( text_matrix[0] * text_matrix[0] + text_matrix[2] * text_matrix[2] );
653 double h_scale = sqrt( text_matrix[1] * text_matrix[1] + text_matrix[3] * text_matrix[3] );
655 diff --git a/src/extension/internal/pdfinput/svg-builder.h b/src/extension/internal/pdfinput/svg-builder.h
656 index 729cdc944c..7fdb0b5fcd 100644
657 --- a/src/extension/internal/pdfinput/svg-builder.h
658 +++ b/src/extension/internal/pdfinput/svg-builder.h
663 +#include "poppler-transition-api.h"
667 @@ -174,7 +175,7 @@ private:
668 void _addStopToGradient(Inkscape::XML::Node *gradient, double offset,
669 GfxRGB *color, double opacity);
670 bool _addGradientStops(Inkscape::XML::Node *gradient, GfxShading *shading,
672 + _POPPLER_CONST Function *func);
673 gchar *_createTilingPattern(GfxTilingPattern *tiling_pattern, GfxState *state,
674 bool is_stroke=false);
675 // Image/mask creation
679 From 0ab3449247d9356f57c75893e1ecfa195d43b681 Mon Sep 17 00:00:00 2001
680 From: Thomas Holder <thomas@thomas-holder.de>
681 Date: Sun, 30 Sep 2018 19:05:48 +0200
682 Subject: [PATCH] use poppler-transition-api instead of ifdefs
685 .../internal/pdfinput/pdf-parser.cpp | 906 ++++--------------
686 .../pdfinput/poppler-transition-api.h | 4 +-
687 2 files changed, 208 insertions(+), 702 deletions(-)
689 diff --git a/src/extension/internal/pdfinput/pdf-parser.cpp b/src/extension/internal/pdfinput/pdf-parser.cpp
690 index 96313e1f19..9e4cd583fa 100644
691 --- a/src/extension/internal/pdfinput/pdf-parser.cpp
692 +++ b/src/extension/internal/pdfinput/pdf-parser.cpp
693 @@ -410,21 +410,13 @@ void PdfParser::parse(Object *obj, GBool topLevel) {
695 if (obj->isArray()) {
696 for (int i = 0; i < obj->arrayGetLength(); ++i) {
697 -#if defined(POPPLER_NEW_OBJECT_API)
698 - obj2 = obj->arrayGet(i);
700 - obj->arrayGet(i, &obj2);
702 + _POPPLER_CALL_ARGS(obj2, obj->arrayGet, i);
703 if (!obj2.isStream()) {
704 error(errInternal, -1, "Weird page contents");
705 -#if !defined(POPPLER_NEW_OBJECT_API)
708 + _POPPLER_FREE(obj2);
711 -#if !defined(POPPLER_NEW_OBJECT_API)
714 + _POPPLER_FREE(obj2);
716 } else if (!obj->isStream()) {
717 error(errInternal, -1, "Weird page contents");
718 @@ -443,11 +435,7 @@ void PdfParser::go(GBool /*topLevel*/)
720 // scan a sequence of objects
722 -#if defined(POPPLER_NEW_OBJECT_API)
723 - obj = parser->getObj();
725 - parser->getObj(&obj);
727 + _POPPLER_CALL(obj, parser->getObj);
728 while (!obj.isEOF()) {
730 // got a command - execute it
731 @@ -466,19 +454,15 @@ void PdfParser::go(GBool /*topLevel*/)
732 execOp(&obj, args, numArgs);
734 #if !defined(POPPLER_NEW_OBJECT_API)
736 + _POPPLER_FREE(obj);
737 for (int i = 0; i < numArgs; ++i)
739 + _POPPLER_FREE(args[i]);
743 // got an argument - save it
744 } else if (numArgs < maxArgs) {
745 -#if defined(POPPLER_NEW_OBJECT_API)
746 args[numArgs++] = std::move(obj);
748 - args[numArgs++] = obj;
751 // too many arguments - something is wrong
753 @@ -489,21 +473,13 @@ void PdfParser::go(GBool /*topLevel*/)
757 -#if !defined(POPPLER_NEW_OBJECT_API)
760 + _POPPLER_FREE(obj);
763 // grab the next object
764 -#if defined(POPPLER_NEW_OBJECT_API)
765 - obj = parser->getObj();
767 - parser->getObj(&obj);
769 + _POPPLER_CALL(obj, parser->getObj);
771 -#if !defined(POPPLER_NEW_OBJECT_API)
774 + _POPPLER_FREE(obj);
776 // args at end with no command
778 @@ -519,7 +495,7 @@ void PdfParser::go(GBool /*topLevel*/)
780 #if !defined(POPPLER_NEW_OBJECT_API)
781 for (int i = 0; i < numArgs; ++i)
783 + _POPPLER_FREE(args[i]);
787 @@ -716,13 +692,9 @@ void PdfParser::opSetDash(Object args[], int /*numArgs*/)
789 dash = (double *)gmallocn(length, sizeof(double));
790 for (int i = 0; i < length; ++i) {
791 -#if defined(POPPLER_NEW_OBJECT_API)
792 - dash[i] = a->get(i).getNum();
795 - dash[i] = a->get(i, &obj)->getNum();
798 + dash[i] = _POPPLER_CALL_ARGS_DEREF(obj, a->get, i).getNum();
799 + _POPPLER_FREE(obj);
802 state->setLineDash(dash, length, args[1].getNum());
803 @@ -772,18 +744,13 @@ void PdfParser::opSetExtGState(Object args[], int /*numArgs*/)
804 GBool haveBackdropColor = gFalse;
805 GBool alpha = gFalse;
807 -#if defined(POPPLER_NEW_OBJECT_API)
808 - if ((obj1 = res->lookupGState(args[0].getName())).isNull()) {
810 - if (!res->lookupGState(args[0].getName(), &obj1)) {
812 + _POPPLER_CALL_ARGS(obj1, res->lookupGState, args[0].getName());
813 + if (obj1.isNull()) {
816 if (!obj1.isDict()) {
817 error(errSyntaxError, getPos(), "ExtGState '{0:s}' is wrong type"), args[0].getName();
818 -#if !defined(POPPLER_NEW_OBJECT_API)
821 + _POPPLER_FREE(obj1);
825 @@ -793,11 +760,7 @@ void PdfParser::opSetExtGState(Object args[], int /*numArgs*/)
828 // transparency support: blend mode, fill/stroke opacity
829 -#if defined(POPPLER_NEW_OBJECT_API)
830 - if (!((obj2 = obj1.dictLookup(const_cast<char*>("BM"))).isNull())) {
832 - if (!obj1.dictLookup(const_cast<char*>("BM"), &obj2)->isNull()) {
834 + if (!_POPPLER_CALL_ARGS_DEREF(obj2, obj1.dictLookup, "BM").isNull()) {
835 GfxBlendMode mode = gfxBlendNormal;
836 if (state->parseBlendMode(&obj2, &mode)) {
837 state->setBlendMode(mode);
838 @@ -805,71 +768,40 @@ void PdfParser::opSetExtGState(Object args[], int /*numArgs*/)
839 error(errSyntaxError, getPos(), "Invalid blend mode in ExtGState");
842 -#if defined(POPPLER_NEW_OBJECT_API)
843 - if ((obj2 = obj1.dictLookup(const_cast<char*>("ca"))).isNum()) {
846 - if (obj1.dictLookup(const_cast<char*>("ca"), &obj2)->isNum()) {
848 + _POPPLER_FREE(obj2);
849 + if (_POPPLER_CALL_ARGS_DEREF(obj2, obj1.dictLookup, "ca").isNum()) {
850 state->setFillOpacity(obj2.getNum());
852 -#if defined(POPPLER_NEW_OBJECT_API)
853 - if ((obj2 = obj1.dictLookup(const_cast<char*>("CA"))).isNum()) {
856 - if (obj1.dictLookup(const_cast<char*>("CA"), &obj2)->isNum()) {
858 + _POPPLER_FREE(obj2);
859 + if (_POPPLER_CALL_ARGS_DEREF(obj2, obj1.dictLookup, "CA").isNum()) {
860 state->setStrokeOpacity(obj2.getNum());
862 -#if !defined(POPPLER_NEW_OBJECT_API)
865 + _POPPLER_FREE(obj2);
867 // fill/stroke overprint
868 GBool haveFillOP = gFalse;
869 -#if defined(POPPLER_NEW_OBJECT_API)
870 - if ((haveFillOP = (obj2 = obj1.dictLookup(const_cast<char*>("op"))).isBool())) {
872 - if ((haveFillOP = (obj1.dictLookup(const_cast<char*>("op"), &obj2)->isBool()))) {
874 + if ((haveFillOP = _POPPLER_CALL_ARGS_DEREF(obj2, obj1.dictLookup, "op").isBool())) {
875 state->setFillOverprint(obj2.getBool());
877 -#if defined(POPPLER_NEW_OBJECT_API)
878 - if ((obj2 = obj1.dictLookup(const_cast<char*>("OP"))).isBool()) {
881 - if (obj1.dictLookup(const_cast<char*>("OP"), &obj2)->isBool()) {
883 + _POPPLER_FREE(obj2);
884 + if (_POPPLER_CALL_ARGS_DEREF(obj2, obj1.dictLookup, "OP").isBool()) {
885 state->setStrokeOverprint(obj2.getBool());
887 state->setFillOverprint(obj2.getBool());
890 -#if !defined(POPPLER_NEW_OBJECT_API)
893 + _POPPLER_FREE(obj2);
896 -#if defined(POPPLER_NEW_OBJECT_API)
897 - if ((obj2 = obj1.dictLookup(const_cast<char*>("SA"))).isBool()) {
899 - if (obj1.dictLookup(const_cast<char*>("SA"), &obj2)->isBool()) {
901 + if (_POPPLER_CALL_ARGS_DEREF(obj2, obj1.dictLookup, "SA").isBool()) {
902 state->setStrokeAdjust(obj2.getBool());
904 -#if !defined(POPPLER_NEW_OBJECT_API)
907 + _POPPLER_FREE(obj2);
910 -#if defined(POPPLER_NEW_OBJECT_API)
911 - if ((obj2 = obj1.dictLookup(const_cast<char*>("TR2"))).isNull()) {
912 - obj2 = obj1.dictLookup(const_cast<char*>("TR"));
914 - if (obj1.dictLookup(const_cast<char*>("TR2"), &obj2)->isNull()) {
916 - obj1.dictLookup(const_cast<char*>("TR"), &obj2);
918 + if (_POPPLER_CALL_ARGS_DEREF(obj2, obj1.dictLookup, "TR2").isNull()) {
919 + _POPPLER_FREE(obj2);
920 + _POPPLER_CALL_ARGS(obj2, obj1.dictLookup, "TR");
922 if (obj2.isName(const_cast<char*>("Default")) ||
923 obj2.isName(const_cast<char*>("Identity"))) {
924 @@ -878,15 +810,9 @@ void PdfParser::opSetExtGState(Object args[], int /*numArgs*/)
925 } else if (obj2.isArray() && obj2.arrayGetLength() == 4) {
927 for (int i = 0; i < 4; ++i) {
928 -#if defined(POPPLER_NEW_OBJECT_API)
929 - obj3 = obj2.arrayGet(i);
931 - obj2.arrayGet(i, &obj3);
933 + _POPPLER_CALL_ARGS(obj3, obj2.arrayGet, i);
934 funcs[i] = Function::parse(&obj3);
935 -#if !defined(POPPLER_NEW_OBJECT_API)
938 + _POPPLER_FREE(obj3);
942 @@ -903,37 +829,21 @@ void PdfParser::opSetExtGState(Object args[], int /*numArgs*/)
943 } else if (!obj2.isNull()) {
944 error(errSyntaxError, getPos(), "Invalid transfer function in ExtGState");
946 -#if !defined(POPPLER_NEW_OBJECT_API)
949 + _POPPLER_FREE(obj2);
952 -#if defined(POPPLER_NEW_OBJECT_API)
953 - if (!((obj2 = obj1.dictLookup(const_cast<char*>("SMask"))).isNull())) {
955 - if (!obj1.dictLookup(const_cast<char*>("SMask"), &obj2)->isNull()) {
957 + if (!_POPPLER_CALL_ARGS_DEREF(obj2, obj1.dictLookup, "SMask").isNull()) {
958 if (obj2.isName(const_cast<char*>("None"))) {
959 builder->clearSoftMask(state);
960 } else if (obj2.isDict()) {
961 -#if defined(POPPLER_NEW_OBJECT_API)
962 - if ((obj3 = obj2.dictLookup(const_cast<char*>("S"))).isName(const_cast<char*>("Alpha"))) {
964 - if (obj2.dictLookup(const_cast<char*>("S"), &obj3)->isName(const_cast<char*>("Alpha"))) {
966 + if (_POPPLER_CALL_ARGS_DEREF(obj3, obj2.dictLookup, "S").isName("Alpha")) {
968 } else { // "Luminosity"
971 -#if !defined(POPPLER_NEW_OBJECT_API)
974 + _POPPLER_FREE(obj3);
976 -#if defined(POPPLER_NEW_OBJECT_API)
977 - if (!((obj3 = obj2.dictLookup(const_cast<char*>("TR"))).isNull())) {
979 - if (!obj2.dictLookup(const_cast<char*>("TR"), &obj3)->isNull()) {
981 + if (!_POPPLER_CALL_ARGS_DEREF(obj3, obj2.dictLookup, "TR").isNull()) {
982 funcs[0] = Function::parse(&obj3);
983 if (funcs[0]->getInputSize() != 1 ||
984 funcs[0]->getOutputSize() != 1) {
985 @@ -942,45 +852,26 @@ void PdfParser::opSetExtGState(Object args[], int /*numArgs*/)
989 -#if defined(POPPLER_NEW_OBJECT_API)
990 - if ((haveBackdropColor = (obj3 = obj2.dictLookup(const_cast<char*>("BC"))).isArray())) {
993 - if ((haveBackdropColor = obj2.dictLookup(const_cast<char*>("BC"), &obj3)->isArray())) {
995 + _POPPLER_FREE(obj3);
996 + if ((haveBackdropColor = _POPPLER_CALL_ARGS_DEREF(obj3, obj2.dictLookup, "BC").isArray())) {
997 for (int i = 0; i < gfxColorMaxComps; ++i) {
998 backdropColor.c[i] = 0;
1000 for (int i = 0; i < obj3.arrayGetLength() && i < gfxColorMaxComps; ++i) {
1001 -#if defined(POPPLER_NEW_OBJECT_API)
1002 - obj4 = obj3.arrayGet(i);
1004 - obj3.arrayGet(i, &obj4);
1006 + _POPPLER_CALL_ARGS(obj4, obj3.arrayGet, i);
1008 backdropColor.c[i] = dblToCol(obj4.getNum());
1010 -#if !defined(POPPLER_NEW_OBJECT_API)
1013 + _POPPLER_FREE(obj4);
1016 -#if defined(POPPLER_NEW_OBJECT_API)
1017 - if ((obj3 = obj2.dictLookup(const_cast<char*>("G"))).isStream()) {
1018 - if ((obj4 = obj3.streamGetDict()->lookup(const_cast<char*>("Group"))).isDict()) {
1021 - if (obj2.dictLookup(const_cast<char*>("G"), &obj3)->isStream()) {
1022 - if (obj3.streamGetDict()->lookup(const_cast<char*>("Group"), &obj4)->isDict()) {
1024 + _POPPLER_FREE(obj3);
1025 + if (_POPPLER_CALL_ARGS_DEREF(obj3, obj2.dictLookup, "G").isStream()) {
1026 + if (_POPPLER_CALL_ARGS_DEREF(obj4, obj3.streamGetDict()->lookup, "Group").isDict()) {
1027 GfxColorSpace *blendingColorSpace = 0;
1028 GBool isolated = gFalse;
1029 GBool knockout = gFalse;
1030 -#if defined(POPPLER_NEW_OBJECT_API)
1031 - if (!((obj5 = obj4.dictLookup(const_cast<char*>("CS"))).isNull())) {
1033 - if (!obj4.dictLookup(const_cast<char*>("CS"), &obj5)->isNull()) {
1035 + if (!_POPPLER_CALL_ARGS_DEREF(obj5, obj4.dictLookup, "CS").isNull()) {
1036 #if defined(POPPLER_EVEN_NEWER_NEW_COLOR_SPACE_API)
1037 blendingColorSpace = GfxColorSpace::parse(NULL, &obj5, NULL, NULL);
1038 #elif defined(POPPLER_EVEN_NEWER_COLOR_SPACE_API)
1039 @@ -989,25 +880,15 @@ void PdfParser::opSetExtGState(Object args[], int /*numArgs*/)
1040 blendingColorSpace = GfxColorSpace::parse(&obj5, NULL, NULL);
1043 -#if defined(POPPLER_NEW_OBJECT_API)
1044 - if ((obj5 = obj4.dictLookup(const_cast<char*>("I"))).isBool()) {
1047 - if (obj4.dictLookup(const_cast<char*>("I"), &obj5)->isBool()) {
1049 + _POPPLER_FREE(obj5);
1050 + if (_POPPLER_CALL_ARGS_DEREF(obj5, obj4.dictLookup, "I").isBool()) {
1051 isolated = obj5.getBool();
1053 -#if defined(POPPLER_NEW_OBJECT_API)
1054 - if ((obj5 = obj4.dictLookup(const_cast<char*>("K"))).isBool()) {
1057 - if (obj4.dictLookup(const_cast<char*>("K"), &obj5)->isBool()) {
1059 + _POPPLER_FREE(obj5);
1060 + if (_POPPLER_CALL_ARGS_DEREF(obj5, obj4.dictLookup, "K").isBool()) {
1061 knockout = obj5.getBool();
1063 -#if !defined(POPPLER_NEW_OBJECT_API)
1066 + _POPPLER_FREE(obj5);
1067 if (!haveBackdropColor) {
1068 if (blendingColorSpace) {
1069 blendingColorSpace->getDefaultColor(&backdropColor);
1070 @@ -1026,24 +907,18 @@ void PdfParser::opSetExtGState(Object args[], int /*numArgs*/)
1072 error(errSyntaxError, getPos(), "Invalid soft mask in ExtGState - missing group");
1074 -#if !defined(POPPLER_NEW_OBJECT_API)
1077 + _POPPLER_FREE(obj4);
1079 error(errSyntaxError, getPos(), "Invalid soft mask in ExtGState - missing group");
1081 -#if !defined(POPPLER_NEW_OBJECT_API)
1084 + _POPPLER_FREE(obj3);
1085 } else if (!obj2.isNull()) {
1086 error(errSyntaxError, getPos(), "Invalid soft mask in ExtGState");
1089 -#if !defined(POPPLER_NEW_OBJECT_API)
1091 + _POPPLER_FREE(obj2);
1095 + _POPPLER_FREE(obj1);
1098 void PdfParser::doSoftMask(Object *str, GBool alpha,
1099 @@ -1064,79 +939,43 @@ void PdfParser::doSoftMask(Object *str, GBool alpha,
1100 dict = str->streamGetDict();
1103 -#if defined(POPPLER_NEW_OBJECT_API)
1104 - obj1 = dict->lookup(const_cast<char*>("FormType"));
1106 - dict->lookup(const_cast<char*>("FormType"), &obj1);
1108 + _POPPLER_CALL_ARGS(obj1, dict->lookup, "FormType");
1109 if (!(obj1.isNull() || (obj1.isInt() && obj1.getInt() == 1))) {
1110 error(errSyntaxError, getPos(), "Unknown form type");
1112 -#if !defined(POPPLER_NEW_OBJECT_API)
1115 + _POPPLER_FREE(obj1);
1118 -#if defined(POPPLER_NEW_OBJECT_API)
1119 - obj1 = dict->lookup(const_cast<char*>("BBox"));
1121 - dict->lookup(const_cast<char*>("BBox"), &obj1);
1123 + _POPPLER_CALL_ARGS(obj1, dict->lookup, "BBox");
1124 if (!obj1.isArray()) {
1125 -#if !defined(POPPLER_NEW_OBJECT_API)
1128 + _POPPLER_FREE(obj1);
1129 error(errSyntaxError, getPos(), "Bad form bounding box");
1132 for (i = 0; i < 4; ++i) {
1133 -#if defined(POPPLER_NEW_OBJECT_API)
1134 - obj2 = obj1.arrayGet(i);
1136 - obj1.arrayGet(i, &obj2);
1138 + _POPPLER_CALL_ARGS(obj2, obj1.arrayGet, i);
1139 bbox[i] = obj2.getNum();
1140 -#if defined(POPPLER_NEW_OBJECT_API)
1144 + _POPPLER_FREE(obj2);
1148 + _POPPLER_FREE(obj1);
1151 -#if defined(POPPLER_NEW_OBJECT_API)
1152 - obj1 = dict->lookup(const_cast<char*>("Matrix"));
1154 - dict->lookup(const_cast<char*>("Matrix"), &obj1);
1156 + _POPPLER_CALL_ARGS(obj1, dict->lookup, "Matrix");
1157 if (obj1.isArray()) {
1158 for (i = 0; i < 6; ++i) {
1159 -#if defined(POPPLER_NEW_OBJECT_API)
1160 - obj2 = obj1.arrayGet(i);
1162 - obj1.arrayGet(i, &obj2);
1164 + _POPPLER_CALL_ARGS(obj2, obj1.arrayGet, i);
1165 m[i] = obj2.getNum();
1166 -#if !defined(POPPLER_NEW_OBJECT_API)
1169 + _POPPLER_FREE(obj2);
1176 -#if !defined(POPPLER_NEW_OBJECT_API)
1179 + _POPPLER_FREE(obj1);
1182 -#if defined(POPPLER_NEW_OBJECT_API)
1183 - obj1 = dict->lookup(const_cast<char*>("Resources"));
1185 - dict->lookup(const_cast<char*>("Resources"), &obj1);
1187 + _POPPLER_CALL_ARGS(obj1, dict->lookup, "Resources");
1188 resDict = obj1.isDict() ? obj1.getDict() : (Dict *)NULL;
1191 @@ -1149,9 +988,7 @@ void PdfParser::doSoftMask(Object *str, GBool alpha,
1192 if (blendingColorSpace) {
1193 delete blendingColorSpace;
1195 -#if !defined(POPPLER_NEW_OBJECT_API)
1198 + _POPPLER_FREE(obj1);
1201 void PdfParser::opSetRenderingIntent(Object /*args*/[], int /*numArgs*/)
1202 @@ -1248,11 +1085,7 @@ void PdfParser::opSetFillColorSpace(Object args[], int /*numArgs*/)
1205 state->setFillPattern(NULL);
1206 -#if defined(POPPLER_NEW_OBJECT_API)
1207 - obj = res->lookupColorSpace(args[0].getName());
1209 - res->lookupColorSpace(args[0].getName(), &obj);
1211 + _POPPLER_CALL_ARGS(obj, res->lookupColorSpace, args[0].getName());
1213 GfxColorSpace *colorSpace = NULL;
1214 #if defined(POPPLER_EVEN_NEWER_NEW_COLOR_SPACE_API)
1215 @@ -1274,9 +1107,7 @@ void PdfParser::opSetFillColorSpace(Object args[], int /*numArgs*/)
1216 colorSpace = GfxColorSpace::parse(&obj, NULL);
1219 -#if !defined(POPPLER_NEW_OBJECT_API)
1222 + _POPPLER_FREE(obj);
1225 state->setFillColorSpace(colorSpace);
1226 @@ -1295,11 +1126,7 @@ void PdfParser::opSetStrokeColorSpace(Object args[], int /*numArgs*/)
1227 GfxColorSpace *colorSpace = NULL;
1229 state->setStrokePattern(NULL);
1230 -#if defined(POPPLER_NEW_OBJECT_API)
1231 - obj = res->lookupColorSpace(args[0].getName());
1233 - res->lookupColorSpace(args[0].getName(), &obj);
1235 + _POPPLER_CALL_ARGS(obj, res->lookupColorSpace, args[0].getName());
1236 #if defined(POPPLER_EVEN_NEWER_NEW_COLOR_SPACE_API)
1238 colorSpace = GfxColorSpace::parse(NULL, &args[0], NULL, NULL);
1239 @@ -1319,9 +1146,7 @@ void PdfParser::opSetStrokeColorSpace(Object args[], int /*numArgs*/)
1240 colorSpace = GfxColorSpace::parse(&obj, NULL);
1243 -#if !defined(POPPLER_NEW_OBJECT_API)
1246 + _POPPLER_FREE(obj);
1249 state->setStrokeColorSpace(colorSpace);
1250 @@ -2551,11 +2376,7 @@ void PdfParser::opShowSpaceText(Object args[], int /*numArgs*/)
1251 wMode = state->getFont()->getWMode();
1252 a = args[0].getArray();
1253 for (int i = 0; i < a->getLength(); ++i) {
1254 -#if defined(POPPLER_NEW_OBJECT_API)
1259 + _POPPLER_CALL_ARGS(obj, a->get, i);
1261 // this uses the absolute value of the font size to match
1262 // Acrobat's behavior
1263 @@ -2572,9 +2393,7 @@ void PdfParser::opShowSpaceText(Object args[], int /*numArgs*/)
1265 error(errSyntaxError, getPos(), "Element of show/space array must be number or string");
1267 -#if !defined(POPPLER_NEW_OBJECT_API)
1270 + _POPPLER_FREE(obj);
1274 @@ -2655,11 +2474,7 @@ void PdfParser::doShowText(GooString *s) {
1275 //out->updateCTM(state, 1, 0, 0, 1, 0, 0);
1276 if (false){ /*!out->beginType3Char(state, curX + riseX, curY + riseY, tdx, tdy,
1278 -#if defined(POPPLER_NEW_OBJECT_API)
1279 - charProc = ((Gfx8BitFont *)font)->getCharProc(code);
1281 - ((Gfx8BitFont *)font)->getCharProc(code, &charProc);
1283 + _POPPLER_CALL_ARGS(charProc, ((Gfx8BitFont *)font)->getCharProc, code);
1284 if ((resDict = ((Gfx8BitFont *)font)->getResources())) {
1285 pushResources(resDict);
1287 @@ -2672,9 +2487,7 @@ void PdfParser::doShowText(GooString *s) {
1291 -#if !defined(POPPLER_NEW_OBJECT_API)
1294 + _POPPLER_FREE(charProc);
1297 // GfxState::restore() does *not* restore the current position,
1298 @@ -2741,43 +2554,24 @@ void PdfParser::opXObject(Object args[], int /*numArgs*/)
1300 char *name = args[0].getName();
1302 -#if defined(POPPLER_NEW_OBJECT_API)
1303 - if ((obj1 = res->lookupXObject(name)).isNull()) {
1305 - if (!res->lookupXObject(name, &obj1)) {
1307 + _POPPLER_CALL_ARGS(obj1, res->lookupXObject, name);
1308 + if (obj1.isNull()) {
1311 if (!obj1.isStream()) {
1312 error(errSyntaxError, getPos(), "XObject '{0:s}' is wrong type", name);
1313 -#if !defined(POPPLER_NEW_OBJECT_API)
1316 + _POPPLER_FREE(obj1);
1319 -#if defined(POPPLER_NEW_OBJECT_API)
1320 - obj2 = obj1.streamGetDict()->lookup(const_cast<char*>("Subtype"));
1322 - obj1.streamGetDict()->lookup(const_cast<char*>("Subtype"), &obj2);
1324 + _POPPLER_CALL_ARGS(obj2, obj1.streamGetDict()->lookup, "Subtype");
1325 if (obj2.isName(const_cast<char*>("Image"))) {
1326 -#if defined(POPPLER_NEW_OBJECT_API)
1327 - refObj = res->lookupXObjectNF(name);
1329 - res->lookupXObjectNF(name, &refObj);
1331 + _POPPLER_CALL_ARGS(refObj, res->lookupXObjectNF, name);
1332 doImage(&refObj, obj1.getStream(), gFalse);
1333 -#if !defined(POPPLER_NEW_OBJECT_API)
1336 + _POPPLER_FREE(refObj);
1337 } else if (obj2.isName(const_cast<char*>("Form"))) {
1339 } else if (obj2.isName(const_cast<char*>("PS"))) {
1340 -#if defined(POPPLER_NEW_OBJECT_API)
1341 - obj3 = obj1.streamGetDict()->lookup(const_cast<char*>("Level1"));
1343 - obj1.streamGetDict()->lookup(const_cast<char*>("Level1"), &obj3);
1345 + _POPPLER_CALL_ARGS(obj3, obj1.streamGetDict()->lookup, "Level1");
1346 /* out->psXObject(obj1.getStream(),
1347 obj3.isStream() ? obj3.getStream() : (Stream *)NULL);*/
1348 } else if (obj2.isName()) {
1349 @@ -2785,10 +2579,8 @@ void PdfParser::opXObject(Object args[], int /*numArgs*/)
1351 error(errSyntaxError, getPos(), "XObject subtype is missing or wrong type");
1353 -#if !defined(POPPLER_NEW_OBJECT_API)
1357 + _POPPLER_FREE(obj2);
1358 + _POPPLER_FREE(obj1);
1361 void PdfParser::doImage(Object * /*ref*/, Stream *str, GBool inlineImg)
1362 @@ -2815,18 +2607,10 @@ void PdfParser::doImage(Object * /*ref*/, Stream *str, GBool inlineImg)
1363 dict = str->getDict();
1366 -#if defined(POPPLER_NEW_OBJECT_API)
1367 - obj1 = dict->lookup(const_cast<char*>("Width"));
1369 - dict->lookup(const_cast<char*>("Width"), &obj1);
1371 + _POPPLER_CALL_ARGS(obj1, dict->lookup, "Width");
1372 if (obj1.isNull()) {
1373 -#if defined(POPPLER_NEW_OBJECT_API)
1374 - obj1 = dict->lookup(const_cast<char*>("W"));
1377 - dict->lookup(const_cast<char*>("W"), &obj1);
1379 + _POPPLER_FREE(obj1);
1380 + _POPPLER_CALL_ARGS(obj1, dict->lookup, "W");
1383 width = obj1.getInt();
1384 @@ -2837,19 +2621,11 @@ void PdfParser::doImage(Object * /*ref*/, Stream *str, GBool inlineImg)
1388 -#if defined(POPPLER_NEW_OBJECT_API)
1389 - obj1 = dict->lookup(const_cast<char*>("Height"));
1392 - dict->lookup(const_cast<char*>("Height"), &obj1);
1394 + _POPPLER_FREE(obj1);
1395 + _POPPLER_CALL_ARGS(obj1, dict->lookup, "Height");
1396 if (obj1.isNull()) {
1397 -#if defined(POPPLER_NEW_OBJECT_API)
1398 - obj1 = dict->lookup(const_cast<char*>("H"));
1401 - dict->lookup(const_cast<char*>("H"), &obj1);
1403 + _POPPLER_FREE(obj1);
1404 + _POPPLER_CALL_ARGS(obj1, dict->lookup, "H");
1407 height = obj1.getInt();
1408 @@ -2860,46 +2636,26 @@ void PdfParser::doImage(Object * /*ref*/, Stream *str, GBool inlineImg)
1412 -#if !defined(POPPLER_NEW_OBJECT_API)
1415 + _POPPLER_FREE(obj1);
1417 // image interpolation
1418 -#if defined(POPPLER_NEW_OBJECT_API)
1419 - obj1 = dict->lookup("Interpolate");
1421 - dict->lookup("Interpolate", &obj1);
1423 + _POPPLER_CALL_ARGS(obj1, dict->lookup, "Interpolate");
1424 if (obj1.isNull()) {
1425 -#if defined(POPPLER_NEW_OBJECT_API)
1426 - obj1 = dict->lookup("I");
1429 - dict->lookup("I", &obj1);
1431 + _POPPLER_FREE(obj1);
1432 + _POPPLER_CALL_ARGS(obj1, dict->lookup, "I");
1435 interpolate = obj1.getBool();
1437 interpolate = gFalse;
1438 -#if !defined(POPPLER_NEW_OBJECT_API)
1441 + _POPPLER_FREE(obj1);
1442 maskInterpolate = gFalse;
1445 -#if defined(POPPLER_NEW_OBJECT_API)
1446 - obj1 = dict->lookup(const_cast<char*>("ImageMask"));
1448 - dict->lookup(const_cast<char*>("ImageMask"), &obj1);
1450 + _POPPLER_CALL_ARGS(obj1, dict->lookup, "ImageMask");
1451 if (obj1.isNull()) {
1452 -#if defined(POPPLER_NEW_OBJECT_API)
1453 - obj1 = dict->lookup(const_cast<char*>("IM"));
1456 - dict->lookup(const_cast<char*>("IM"), &obj1);
1458 + _POPPLER_FREE(obj1);
1459 + _POPPLER_CALL_ARGS(obj1, dict->lookup, "IM");
1462 if (obj1.isBool()) {
1463 @@ -2908,24 +2664,14 @@ void PdfParser::doImage(Object * /*ref*/, Stream *str, GBool inlineImg)
1464 else if (!obj1.isNull()) {
1467 -#if !defined(POPPLER_NEW_OBJECT_API)
1470 + _POPPLER_FREE(obj1);
1474 -#if defined(POPPLER_NEW_OBJECT_API)
1475 - obj1 = dict->lookup(const_cast<char*>("BitsPerComponent"));
1477 - dict->lookup(const_cast<char*>("BitsPerComponent"), &obj1);
1479 + _POPPLER_CALL_ARGS(obj1, dict->lookup, "BitsPerComponent");
1480 if (obj1.isNull()) {
1481 -#if defined(POPPLER_NEW_OBJECT_API)
1482 - obj1 = dict->lookup(const_cast<char*>("BPC"));
1485 - dict->lookup(const_cast<char*>("BPC"), &obj1);
1487 + _POPPLER_FREE(obj1);
1488 + _POPPLER_CALL_ARGS(obj1, dict->lookup, "BPC");
1491 bits = obj1.getInt();
1492 @@ -2934,9 +2680,7 @@ void PdfParser::doImage(Object * /*ref*/, Stream *str, GBool inlineImg)
1496 -#if !defined(POPPLER_NEW_OBJECT_API)
1499 + _POPPLER_FREE(obj1);
1503 @@ -2946,37 +2690,21 @@ void PdfParser::doImage(Object * /*ref*/, Stream *str, GBool inlineImg)
1507 -#if defined(POPPLER_NEW_OBJECT_API)
1508 - obj1 = dict->lookup(const_cast<char*>("Decode"));
1510 - dict->lookup(const_cast<char*>("Decode"), &obj1);
1512 + _POPPLER_CALL_ARGS(obj1, dict->lookup, "Decode");
1513 if (obj1.isNull()) {
1514 -#if defined(POPPLER_NEW_OBJECT_API)
1515 - obj1 = dict->lookup(const_cast<char*>("D"));
1518 - dict->lookup(const_cast<char*>("D"), &obj1);
1520 + _POPPLER_FREE(obj1);
1521 + _POPPLER_CALL_ARGS(obj1, dict->lookup, "D");
1523 if (obj1.isArray()) {
1524 -#if defined(POPPLER_NEW_OBJECT_API)
1525 - obj2 = obj1.arrayGet(0);
1527 - obj1.arrayGet(0, &obj2);
1529 + _POPPLER_CALL_ARGS(obj2, obj1.arrayGet, 0);
1530 if (obj2.isInt() && obj2.getInt() == 1) {
1533 -#if !defined(POPPLER_NEW_OBJECT_API)
1536 + _POPPLER_FREE(obj2);
1537 } else if (!obj1.isNull()) {
1540 -#if !defined(POPPLER_NEW_OBJECT_API)
1543 + _POPPLER_FREE(obj1);
1546 builder->addImageMask(state, str, width, height, invert, interpolate);
1547 @@ -2984,36 +2712,18 @@ void PdfParser::doImage(Object * /*ref*/, Stream *str, GBool inlineImg)
1549 // get color space and color map
1550 GfxColorSpace *colorSpace;
1551 -#if defined(POPPLER_NEW_OBJECT_API)
1552 - obj1 = dict->lookup(const_cast<char*>("ColorSpace"));
1554 - dict->lookup(const_cast<char*>("ColorSpace"), &obj1);
1556 + _POPPLER_CALL_ARGS(obj1, dict->lookup, "ColorSpace");
1557 if (obj1.isNull()) {
1558 -#if defined(POPPLER_NEW_OBJECT_API)
1559 - obj1 = dict->lookup(const_cast<char*>("CS"));
1562 - dict->lookup(const_cast<char*>("CS"), &obj1);
1564 + _POPPLER_FREE(obj1);
1565 + _POPPLER_CALL_ARGS(obj1, dict->lookup, "CS");
1567 if (obj1.isName()) {
1568 -#if defined(POPPLER_NEW_OBJECT_API)
1569 - obj2 = res->lookupColorSpace(obj1.getName());
1571 - res->lookupColorSpace(obj1.getName(), &obj2);
1573 + _POPPLER_CALL_ARGS(obj2, res->lookupColorSpace, obj1.getName());
1574 if (!obj2.isNull()) {
1575 -#if defined(POPPLER_NEW_OBJECT_API)
1576 + _POPPLER_FREE(obj1);
1577 obj1 = std::move(obj2);
1583 -#if !defined(POPPLER_NEW_OBJECT_API)
1586 + _POPPLER_FREE(obj2);
1589 if (!obj1.isNull()) {
1590 @@ -3033,29 +2743,17 @@ void PdfParser::doImage(Object * /*ref*/, Stream *str, GBool inlineImg)
1594 -#if !defined(POPPLER_NEW_OBJECT_API)
1597 + _POPPLER_FREE(obj1);
1601 -#if defined(POPPLER_NEW_OBJECT_API)
1602 - obj1 = dict->lookup(const_cast<char*>("Decode"));
1604 - dict->lookup(const_cast<char*>("Decode"), &obj1);
1606 + _POPPLER_CALL_ARGS(obj1, dict->lookup, "Decode");
1607 if (obj1.isNull()) {
1608 -#if defined(POPPLER_NEW_OBJECT_API)
1609 - obj1 = dict->lookup(const_cast<char*>("D"));
1612 - dict->lookup(const_cast<char*>("D"), &obj1);
1614 + _POPPLER_FREE(obj1);
1615 + _POPPLER_CALL_ARGS(obj1, dict->lookup, "D");
1617 GfxImageColorMap *colorMap = new GfxImageColorMap(bits, &obj1, colorSpace);
1618 -#if !defined(POPPLER_NEW_OBJECT_API)
1621 + _POPPLER_FREE(obj1);
1622 if (!colorMap->isOk()) {
1625 @@ -3069,13 +2767,8 @@ void PdfParser::doImage(Object * /*ref*/, Stream *str, GBool inlineImg)
1627 maskInvert = gFalse;
1628 GfxImageColorMap *maskColorMap = NULL;
1629 -#if defined(POPPLER_NEW_OBJECT_API)
1630 - maskObj = dict->lookup(const_cast<char*>("Mask"));
1631 - smaskObj = dict->lookup(const_cast<char*>("SMask"));
1633 - dict->lookup(const_cast<char*>("Mask"), &maskObj);
1634 - dict->lookup(const_cast<char*>("SMask"), &smaskObj);
1636 + _POPPLER_CALL_ARGS(maskObj, dict->lookup, "Mask");
1637 + _POPPLER_CALL_ARGS(smaskObj, dict->lookup, "SMask");
1639 if (smaskObj.isStream()) {
1641 @@ -3084,108 +2777,58 @@ void PdfParser::doImage(Object * /*ref*/, Stream *str, GBool inlineImg)
1643 maskStr = smaskObj.getStream();
1644 maskDict = smaskObj.streamGetDict();
1645 -#if defined(POPPLER_NEW_OBJECT_API)
1646 - obj1 = maskDict->lookup(const_cast<char*>("Width"));
1648 - maskDict->lookup(const_cast<char*>("Width"), &obj1);
1650 + _POPPLER_CALL_ARGS(obj1, maskDict->lookup, "Width");
1651 if (obj1.isNull()) {
1652 -#if defined(POPPLER_NEW_OBJECT_API)
1653 - obj1 = maskDict->lookup(const_cast<char*>("W"));
1656 - maskDict->lookup(const_cast<char*>("W"), &obj1);
1658 + _POPPLER_FREE(obj1);
1659 + _POPPLER_CALL_ARGS(obj1, maskDict->lookup, "W");
1661 if (!obj1.isInt()) {
1664 maskWidth = obj1.getInt();
1665 -#if defined(POPPLER_NEW_OBJECT_API)
1666 - obj1 = maskDict->lookup(const_cast<char*>("Height"));
1669 - maskDict->lookup(const_cast<char*>("Height"), &obj1);
1671 + _POPPLER_FREE(obj1);
1672 + _POPPLER_CALL_ARGS(obj1, maskDict->lookup, "Height");
1673 if (obj1.isNull()) {
1674 -#if defined(POPPLER_NEW_OBJECT_API)
1675 - obj1 = maskDict->lookup(const_cast<char*>("H"));
1678 - maskDict->lookup(const_cast<char*>("H"), &obj1);
1680 + _POPPLER_FREE(obj1);
1681 + _POPPLER_CALL_ARGS(obj1, maskDict->lookup, "H");
1683 if (!obj1.isInt()) {
1686 maskHeight = obj1.getInt();
1687 -#if defined(POPPLER_NEW_OBJECT_API)
1688 - obj1 = maskDict->lookup(const_cast<char*>("BitsPerComponent"));
1691 - maskDict->lookup(const_cast<char*>("BitsPerComponent"), &obj1);
1693 + _POPPLER_FREE(obj1);
1694 + _POPPLER_CALL_ARGS(obj1, maskDict->lookup, "BitsPerComponent");
1695 if (obj1.isNull()) {
1696 -#if defined(POPPLER_NEW_OBJECT_API)
1697 - obj1 = maskDict->lookup(const_cast<char*>("BPC"));
1700 - maskDict->lookup(const_cast<char*>("BPC"), &obj1);
1702 + _POPPLER_FREE(obj1);
1703 + _POPPLER_CALL_ARGS(obj1, maskDict->lookup, "BPC");
1705 if (!obj1.isInt()) {
1708 int maskBits = obj1.getInt();
1709 -#if defined(POPPLER_NEW_OBJECT_API)
1710 - obj1 = maskDict->lookup(const_cast<char*>("Interpolate"));
1713 - maskDict->lookup("Interpolate", &obj1);
1715 + _POPPLER_FREE(obj1);
1716 + _POPPLER_CALL_ARGS(obj1, maskDict->lookup, "Interpolate");
1717 if (obj1.isNull()) {
1718 -#if defined(POPPLER_NEW_OBJECT_API)
1719 - obj1 = maskDict->lookup(const_cast<char*>("I"));
1722 - maskDict->lookup("I", &obj1);
1724 + _POPPLER_FREE(obj1);
1725 + _POPPLER_CALL_ARGS(obj1, maskDict->lookup, "I");
1728 maskInterpolate = obj1.getBool();
1730 maskInterpolate = gFalse;
1731 -#if defined(POPPLER_NEW_OBJECT_API)
1732 - obj1 = maskDict->lookup(const_cast<char*>("ColorSpace"));
1735 - maskDict->lookup(const_cast<char*>("ColorSpace"), &obj1);
1737 + _POPPLER_FREE(obj1);
1738 + _POPPLER_CALL_ARGS(obj1, maskDict->lookup, "ColorSpace");
1739 if (obj1.isNull()) {
1740 -#if defined(POPPLER_NEW_OBJECT_API)
1741 - obj1 = maskDict->lookup(const_cast<char*>("CS"));
1744 - maskDict->lookup(const_cast<char*>("CS"), &obj1);
1746 + _POPPLER_FREE(obj1);
1747 + _POPPLER_CALL_ARGS(obj1, maskDict->lookup, "CS");
1749 if (obj1.isName()) {
1750 -#if defined(POPPLER_NEW_OBJECT_API)
1751 - obj2 = res->lookupColorSpace(obj1.getName());
1753 - res->lookupColorSpace(obj1.getName(), &obj2);
1755 + _POPPLER_CALL_ARGS(obj2, res->lookupColorSpace, obj1.getName());
1756 if (!obj2.isNull()) {
1757 -#if defined(POPPLER_NEW_OBJECT_API)
1758 + _POPPLER_FREE(obj1);
1759 obj1 = std::move(obj2);
1765 -#if !defined(POPPLER_NEW_OBJECT_API)
1768 + _POPPLER_FREE(obj2);
1771 #if defined(POPPLER_EVEN_NEWER_NEW_COLOR_SPACE_API)
1772 @@ -3195,29 +2838,17 @@ void PdfParser::doImage(Object * /*ref*/, Stream *str, GBool inlineImg)
1774 GfxColorSpace *maskColorSpace = GfxColorSpace::parse(&obj1, NULL);
1776 -#if !defined(POPPLER_NEW_OBJECT_API)
1779 + _POPPLER_FREE(obj1);
1780 if (!maskColorSpace || maskColorSpace->getMode() != csDeviceGray) {
1783 -#if defined(POPPLER_NEW_OBJECT_API)
1784 - obj1 = maskDict->lookup(const_cast<char*>("Decode"));
1786 - maskDict->lookup(const_cast<char*>("Decode"), &obj1);
1788 + _POPPLER_CALL_ARGS(obj1, maskDict->lookup, "Decode");
1789 if (obj1.isNull()) {
1790 -#if defined(POPPLER_NEW_OBJECT_API)
1791 - obj1 = maskDict->lookup(const_cast<char*>("D"));
1794 - maskDict->lookup(const_cast<char*>("D"), &obj1);
1796 + _POPPLER_FREE(obj1);
1797 + _POPPLER_CALL_ARGS(obj1, maskDict->lookup, "D");
1799 maskColorMap = new GfxImageColorMap(maskBits, &obj1, maskColorSpace);
1800 -#if !defined(POPPLER_NEW_OBJECT_API)
1803 + _POPPLER_FREE(obj1);
1804 if (!maskColorMap->isOk()) {
1805 delete maskColorMap;
1807 @@ -3228,15 +2859,9 @@ void PdfParser::doImage(Object * /*ref*/, Stream *str, GBool inlineImg)
1810 for (i = 0; i < maskObj.arrayGetLength() && i < 2*gfxColorMaxComps; ++i) {
1811 -#if defined(POPPLER_NEW_OBJECT_API)
1812 - obj1 = maskObj.arrayGet(i);
1814 - maskObj.arrayGet(i, &obj1);
1816 + _POPPLER_CALL_ARGS(obj1, maskObj.arrayGet, i);
1817 maskColors[i] = obj1.getInt();
1818 -#if !defined(POPPLER_NEW_OBJECT_API)
1821 + _POPPLER_FREE(obj1);
1823 haveColorKeyMask = gTrue;
1824 } else if (maskObj.isStream()) {
1825 @@ -3246,111 +2871,61 @@ void PdfParser::doImage(Object * /*ref*/, Stream *str, GBool inlineImg)
1827 maskStr = maskObj.getStream();
1828 maskDict = maskObj.streamGetDict();
1829 -#if defined(POPPLER_NEW_OBJECT_API)
1830 - obj1 = maskDict->lookup(const_cast<char*>("Width"));
1832 - maskDict->lookup(const_cast<char*>("Width"), &obj1);
1834 + _POPPLER_CALL_ARGS(obj1, maskDict->lookup, "Width");
1835 if (obj1.isNull()) {
1836 -#if defined(POPPLER_NEW_OBJECT_API)
1837 - obj1 = maskDict->lookup(const_cast<char*>("W"));
1840 - maskDict->lookup(const_cast<char*>("W"), &obj1);
1842 + _POPPLER_FREE(obj1);
1843 + _POPPLER_CALL_ARGS(obj1, maskDict->lookup, "W");
1845 if (!obj1.isInt()) {
1848 maskWidth = obj1.getInt();
1849 -#if defined(POPPLER_NEW_OBJECT_API)
1850 - obj1 = maskDict->lookup(const_cast<char*>("Height"));
1853 - maskDict->lookup(const_cast<char*>("Height"), &obj1);
1855 + _POPPLER_FREE(obj1);
1856 + _POPPLER_CALL_ARGS(obj1, maskDict->lookup, "Height");
1857 if (obj1.isNull()) {
1858 -#if defined(POPPLER_NEW_OBJECT_API)
1859 - obj1 = maskDict->lookup(const_cast<char*>("H"));
1862 - maskDict->lookup(const_cast<char*>("H"), &obj1);
1864 + _POPPLER_FREE(obj1);
1865 + _POPPLER_CALL_ARGS(obj1, maskDict->lookup, "H");
1867 if (!obj1.isInt()) {
1870 maskHeight = obj1.getInt();
1871 -#if defined(POPPLER_NEW_OBJECT_API)
1872 - obj1 = maskDict->lookup(const_cast<char*>("ImageMask"));
1875 - maskDict->lookup(const_cast<char*>("ImageMask"), &obj1);
1877 + _POPPLER_FREE(obj1);
1878 + _POPPLER_CALL_ARGS(obj1, maskDict->lookup, "ImageMask");
1879 if (obj1.isNull()) {
1880 -#if defined(POPPLER_NEW_OBJECT_API)
1881 - obj1 = maskDict->lookup(const_cast<char*>("IM"));
1884 - maskDict->lookup(const_cast<char*>("IM"), &obj1);
1886 + _POPPLER_FREE(obj1);
1887 + _POPPLER_CALL_ARGS(obj1, maskDict->lookup, "IM");
1889 if (!obj1.isBool() || !obj1.getBool()) {
1892 -#if defined(POPPLER_NEW_OBJECT_API)
1893 - obj1 = maskDict->lookup("Interpolate");
1896 - maskDict->lookup("Interpolate", &obj1);
1898 + _POPPLER_FREE(obj1);
1899 + _POPPLER_CALL_ARGS(obj1, maskDict->lookup, "Interpolate");
1900 if (obj1.isNull()) {
1901 -#if defined(POPPLER_NEW_OBJECT_API)
1902 - obj1 = maskDict->lookup("I");
1905 - maskDict->lookup("I", &obj1);
1907 + _POPPLER_FREE(obj1);
1908 + _POPPLER_CALL_ARGS(obj1, maskDict->lookup, "I");
1911 maskInterpolate = obj1.getBool();
1913 maskInterpolate = gFalse;
1914 -#if !defined(POPPLER_NEW_OBJECT_API)
1917 + _POPPLER_FREE(obj1);
1918 maskInvert = gFalse;
1919 -#if defined(POPPLER_NEW_OBJECT_API)
1920 - obj1 = maskDict->lookup(const_cast<char*>("Decode"));
1922 - maskDict->lookup(const_cast<char*>("Decode"), &obj1);
1924 + _POPPLER_CALL_ARGS(obj1, maskDict->lookup, "Decode");
1925 if (obj1.isNull()) {
1926 -#if defined(POPPLER_NEW_OBJECT_API)
1927 - obj1 = maskDict->lookup(const_cast<char*>("D"));
1930 - maskDict->lookup(const_cast<char*>("D"), &obj1);
1932 + _POPPLER_FREE(obj1);
1933 + _POPPLER_CALL_ARGS(obj1, maskDict->lookup, "D");
1935 if (obj1.isArray()) {
1936 -#if defined(POPPLER_NEW_OBJECT_API)
1937 - obj2 = obj1.arrayGet(0);
1939 - obj1.arrayGet(0, &obj2);
1941 + _POPPLER_CALL_ARGS(obj2, obj1.arrayGet, 0);
1942 if (obj2.isInt() && obj2.getInt() == 1) {
1945 -#if !defined(POPPLER_NEW_OBJECT_API)
1948 + _POPPLER_FREE(obj2);
1949 } else if (!obj1.isNull()) {
1952 -#if !defined(POPPLER_NEW_OBJECT_API)
1955 + _POPPLER_FREE(obj1);
1956 haveExplicitMask = gTrue;
1959 @@ -3368,18 +2943,14 @@ void PdfParser::doImage(Object * /*ref*/, Stream *str, GBool inlineImg)
1963 -#if !defined(POPPLER_NEW_OBJECT_API)
1967 + _POPPLER_FREE(maskObj);
1968 + _POPPLER_FREE(smaskObj);
1974 -#if !defined(POPPLER_NEW_OBJECT_API)
1977 + _POPPLER_FREE(obj1);
1979 error(errSyntaxError, getPos(), "Bad image parameters");
1981 @@ -3404,97 +2975,52 @@ void PdfParser::doForm(Object *str) {
1982 dict = str->streamGetDict();
1985 -#if defined(POPPLER_NEW_OBJECT_API)
1986 - obj1 = dict->lookup(const_cast<char*>("FormType"));
1988 - dict->lookup(const_cast<char*>("FormType"), &obj1);
1990 + _POPPLER_CALL_ARGS(obj1, dict->lookup, "FormType");
1991 if (!(obj1.isNull() || (obj1.isInt() && obj1.getInt() == 1))) {
1992 error(errSyntaxError, getPos(), "Unknown form type");
1994 -#if !defined(POPPLER_NEW_OBJECT_API)
1997 + _POPPLER_FREE(obj1);
2000 -#if defined(POPPLER_NEW_OBJECT_API)
2001 - bboxObj = dict->lookup(const_cast<char*>("BBox"));
2003 - dict->lookup(const_cast<char*>("BBox"), &bboxObj);
2005 + _POPPLER_CALL_ARGS(bboxObj, dict->lookup, "BBox");
2006 if (!bboxObj.isArray()) {
2007 -#if !defined(POPPLER_NEW_OBJECT_API)
2010 + _POPPLER_FREE(bboxObj);
2011 error(errSyntaxError, getPos(), "Bad form bounding box");
2014 for (i = 0; i < 4; ++i) {
2015 -#if defined(POPPLER_NEW_OBJECT_API)
2016 - obj1 = bboxObj.arrayGet(i);
2018 - bboxObj.arrayGet(i, &obj1);
2020 + _POPPLER_CALL_ARGS(obj1, bboxObj.arrayGet, i);
2021 bbox[i] = obj1.getNum();
2022 -#if defined(POPPLER_NEW_OBJECT_API)
2026 + _POPPLER_FREE(obj1);
2030 + _POPPLER_FREE(bboxObj);
2033 -#if defined(POPPLER_NEW_OBJECT_API)
2034 - matrixObj = dict->lookup(const_cast<char*>("Matrix"));
2036 - dict->lookup(const_cast<char*>("Matrix"), &matrixObj);
2038 + _POPPLER_CALL_ARGS(matrixObj, dict->lookup, "Matrix");
2039 if (matrixObj.isArray()) {
2040 for (i = 0; i < 6; ++i) {
2041 -#if defined(POPPLER_NEW_OBJECT_API)
2042 - obj1 = matrixObj.arrayGet(i);
2044 - matrixObj.arrayGet(i, &obj1);
2046 + _POPPLER_CALL_ARGS(obj1, matrixObj.arrayGet, i);
2047 m[i] = obj1.getNum();
2048 -#if !defined(POPPLER_NEW_OBJECT_API)
2051 + _POPPLER_FREE(obj1);
2058 -#if !defined(POPPLER_NEW_OBJECT_API)
2061 + _POPPLER_FREE(matrixObj);
2064 -#if defined(POPPLER_NEW_OBJECT_API)
2065 - resObj = dict->lookup(const_cast<char*>("Resources"));
2067 - dict->lookup(const_cast<char*>("Resources"), &resObj);
2069 + _POPPLER_CALL_ARGS(resObj, dict->lookup, "Resources");
2070 resDict = resObj.isDict() ? resObj.getDict() : (Dict *)NULL;
2072 // check for a transparency group
2073 transpGroup = isolated = knockout = gFalse;
2074 blendingColorSpace = NULL;
2075 -#if defined(POPPLER_NEW_OBJECT_API)
2076 - if ((obj1 = dict->lookup(const_cast<char*>("Group"))).isDict()) {
2077 - if ((obj2 = obj1.dictLookup(const_cast<char*>("S"))).isName(const_cast<char*>("Transparency"))) {
2079 - if (dict->lookup(const_cast<char*>("Group"), &obj1)->isDict()) {
2080 - if (obj1.dictLookup(const_cast<char*>("S"), &obj2)->isName(const_cast<char*>("Transparency"))) {
2082 + if (_POPPLER_CALL_ARGS_DEREF(obj1, dict->lookup, "Group").isDict()) {
2083 + if (_POPPLER_CALL_ARGS_DEREF(obj2, obj1.dictLookup, "S").isName("Transparency")) {
2084 transpGroup = gTrue;
2085 -#if defined(POPPLER_NEW_OBJECT_API)
2086 - if (!((obj3 = obj1.dictLookup(const_cast<char*>("CS"))).isNull())) {
2088 - if (!obj1.dictLookup(const_cast<char*>("CS"), &obj3)->isNull()) {
2090 + if (!_POPPLER_CALL_ARGS_DEREF(obj3, obj1.dictLookup, "CS").isNull()) {
2091 #if defined(POPPLER_EVEN_NEWER_NEW_COLOR_SPACE_API)
2092 blendingColorSpace = GfxColorSpace::parse(NULL, &obj3, NULL, NULL);
2093 #elif defined(POPPLER_EVEN_NEWER_COLOR_SPACE_API)
2094 @@ -3503,32 +3029,19 @@ void PdfParser::doForm(Object *str) {
2095 blendingColorSpace = GfxColorSpace::parse(&obj3, NULL);
2098 -#if defined(POPPLER_NEW_OBJECT_API)
2099 - if ((obj3 = obj1.dictLookup(const_cast<char*>("I"))).isBool()) {
2102 - if (obj1.dictLookup(const_cast<char*>("I"), &obj3)->isBool()) {
2104 + _POPPLER_FREE(obj3);
2105 + if (_POPPLER_CALL_ARGS_DEREF(obj3, obj1.dictLookup, "I").isBool()) {
2106 isolated = obj3.getBool();
2108 -#if defined(POPPLER_NEW_OBJECT_API)
2109 - if ((obj3 = obj1.dictLookup(const_cast<char*>("K"))).isBool()) {
2112 - if (obj1.dictLookup(const_cast<char*>("K"), &obj3)->isBool()) {
2114 + _POPPLER_FREE(obj3);
2115 + if (_POPPLER_CALL_ARGS_DEREF(obj3, obj1.dictLookup, "K").isBool()) {
2116 knockout = obj3.getBool();
2118 -#if defined(POPPLER_NEW_OBJECT_API)
2119 + _POPPLER_FREE(obj3);
2121 + _POPPLER_FREE(obj2);
2130 + _POPPLER_FREE(obj1);
2134 @@ -3539,9 +3052,7 @@ void PdfParser::doForm(Object *str) {
2135 if (blendingColorSpace) {
2136 delete blendingColorSpace;
2138 -#if !defined(POPPLER_NEW_OBJECT_API)
2141 + _POPPLER_FREE(resObj);
2144 void PdfParser::doForm1(Object *str, Dict *resDict, double *matrix, double *bbox,
2145 @@ -3670,17 +3181,14 @@ Stream *PdfParser::buildImageStream() {
2147 #if defined(POPPLER_NEW_OBJECT_API)
2148 dict = Object(new Dict(xref));
2149 - obj = parser->getObj();
2151 dict.initDict(xref);
2152 - parser->getObj(&obj);
2154 + _POPPLER_CALL(obj, parser->getObj);
2155 while (!obj.isCmd(const_cast<char*>("ID")) && !obj.isEOF()) {
2156 if (!obj.isName()) {
2157 error(errSyntaxError, getPos(), "Inline image dictionary key must be a name object");
2158 -#if !defined(POPPLER_NEW_OBJECT_API)
2161 + _POPPLER_FREE(obj);
2164 _POPPLER_CALL(obj2, parser->getObj);
2165 @@ -3696,15 +3204,11 @@ Stream *PdfParser::buildImageStream() {
2168 error(errSyntaxError, getPos(), "End of file in inline image");
2169 -#if !defined(POPPLER_NEW_OBJECT_API)
2173 + _POPPLER_FREE(obj);
2174 + _POPPLER_FREE(dict);
2177 -#if !defined(POPPLER_NEW_OBJECT_API)
2180 + _POPPLER_FREE(obj);
2183 #if defined(POPPLER_NEW_OBJECT_API)
2184 diff --git a/src/extension/internal/pdfinput/poppler-transition-api.h b/src/extension/internal/pdfinput/poppler-transition-api.h
2185 index 898e64bf2b..6ed911b04b 100644
2186 --- a/src/extension/internal/pdfinput/poppler-transition-api.h
2187 +++ b/src/extension/internal/pdfinput/poppler-transition-api.h
2189 #define _POPPLER_FREE(obj)
2190 #define _POPPLER_CALL(ret, func) (ret = func())
2191 #define _POPPLER_CALL_ARGS(ret, func, ...) (ret = func(__VA_ARGS__))
2192 +#define _POPPLER_CALL_ARGS_DEREF _POPPLER_CALL_ARGS
2194 #define _POPPLER_FREE(obj) (obj).free()
2195 #define _POPPLER_CALL(ret, func) (*func(&ret))
2196 -#define _POPPLER_CALL_ARGS(ret, func, ...) (*func(__VA_ARGS__, &ret))
2197 +#define _POPPLER_CALL_ARGS(ret, func, ...) (func(__VA_ARGS__, &ret))
2198 +#define _POPPLER_CALL_ARGS_DEREF(...) (*_POPPLER_CALL_ARGS(__VA_ARGS__))
2201 #if POPPLER_CHECK_VERSION(0, 29, 0)
2205 From d047859d90cef3784e2d13e40887a70d8d517897 Mon Sep 17 00:00:00 2001
2206 From: =?UTF-8?q?Bart=C5=82omiej=20Szczepaniak?=
2207 <szczepaniak.bartek@gmail.com>
2208 Date: Tue, 6 Nov 2018 07:41:40 +0000
2209 Subject: [PATCH] fix poppler 0.71.0 build.
2212 src/extension/internal/pdfinput/poppler-transition-api.h | 6 ++++++
2213 1 file changed, 6 insertions(+)
2215 diff --git a/src/extension/internal/pdfinput/poppler-transition-api.h b/src/extension/internal/pdfinput/poppler-transition-api.h
2216 index 6ed911b04b..4437052593 100644
2217 --- a/src/extension/internal/pdfinput/poppler-transition-api.h
2218 +++ b/src/extension/internal/pdfinput/poppler-transition-api.h
2221 #include <glib/poppler-features.h>
2223 +#if POPPLER_CHECK_VERSION(0,71,0)
2224 +typedef bool GBool;
2226 +#define gFalse false
2229 #if POPPLER_CHECK_VERSION(0,70,0)
2230 #define _POPPLER_CONST const
2235 From b3d59cc8106da3bf6020a6c47eeb3b8a7bbae1a9 Mon Sep 17 00:00:00 2001
2236 From: Thomas Holder <thomas@thomas-holder.de>
2237 Date: Sun, 9 Dec 2018 10:21:34 +0100
2238 Subject: [PATCH] fix poppler 0.72.0 build
2241 src/extension/internal/pdfinput/pdf-parser.h | 1 -
2242 src/extension/internal/pdfinput/poppler-transition-api.h | 4 ++++
2243 2 files changed, 4 insertions(+), 1 deletion(-)
2245 diff --git a/src/extension/internal/pdfinput/pdf-parser.h b/src/extension/internal/pdfinput/pdf-parser.h
2246 index 2d4441a22c..31c84d51bb 100644
2247 --- a/src/extension/internal/pdfinput/pdf-parser.h
2248 +++ b/src/extension/internal/pdfinput/pdf-parser.h
2249 @@ -37,7 +37,6 @@ namespace Inkscape {
2250 using Inkscape::Extension::Internal::SvgBuilder;
2252 #include "glib/poppler-features.h"
2253 -#include "goo/gtypes.h"
2257 diff --git a/src/extension/internal/pdfinput/poppler-transition-api.h b/src/extension/internal/pdfinput/poppler-transition-api.h
2258 index 5141bf8a73..61a15083a0 100644
2259 --- a/src/extension/internal/pdfinput/poppler-transition-api.h
2260 +++ b/src/extension/internal/pdfinput/poppler-transition-api.h
2263 #include <glib/poppler-features.h>
2265 +#if POPPLER_CHECK_VERSION(0, 72, 0)
2266 +#define getCString c_str
2269 #if POPPLER_CHECK_VERSION(0,71,0)