]> git.pld-linux.org Git - packages/inkscape.git/blob - poppler0.69.patch
- fix building with poppler 0.69
[packages/inkscape.git] / poppler0.69.patch
1 commit 402c0274420fe39fd2f3393bc7d8d8879d436358
2 Author: Thomas Holder <thomas@thomas-holder.de>
3 Date:   Fri Sep 28 18:05:30 2018 +0000
4
5     fix 1789208 poppler 0.69
6
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)
13             endif()
14         endif()
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)
18 -       endif()
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)
22 -       endif()
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)
26 -       endif()
27      else()
28         set(ENABLE_POPPLER_CAIRO OFF)
29      endif()
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);
36  
37          // Apply crop settings
38 -        PDFRectangle *clipToBox = NULL;
39 +        _POPPLER_CONST PDFRectangle *clipToBox = nullptr;
40          double crop_setting;
41          sp_repr_get_double(prefs, "cropTo", &crop_setting);
42  
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
47 @@ -15,6 +15,7 @@
48  #endif
49  
50  #ifdef HAVE_POPPLER
51 +#include "poppler-transition-api.h"
52  
53  #include <gtkmm/dialog.h>
54  
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,
60                       int /*pageNum*/,
61                      int rotate,
62                      Dict *resDict,
63 -                     PDFRectangle *box,
64 -                    PDFRectangle *cropBox) :
65 +                     _POPPLER_CONST PDFRectangle *box,
66 +                     _POPPLER_CONST PDFRectangle *cropBox) :
67      xref(xrefA),
68      builder(builderA),
69      subPage(gFalse),
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"));
73  
74 -  double *ctm = state->getCTM();
75 +  const double *ctm = state->getCTM();
76    double scaledCTM[6];
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,
82                       Dict *resDict,
83 -                    PDFRectangle *box) :
84 +                    _POPPLER_CONST PDFRectangle *box) :
85      xref(xrefA),
86      builder(builderA),
87      subPage(gTrue),
88 @@ -568,7 +568,7 @@ const char *PdfParser::getPreviousOperator(unsigned int look_back) {
89  
90  void PdfParser::execOp(Object *cmd, Object args[], int numArgs) {
91    PdfOperator *op;
92 -  char *name;
93 +  const char *name;
94    Object *argPtr;
95    int i;
96  
97 @@ -616,7 +616,7 @@ void PdfParser::execOp(Object *cmd, Object args[], int numArgs) {
98    (this->*op->func)(argPtr, numArgs);
99  }
100  
101 -PdfOperator* PdfParser::findOp(char *name) {
102 +PdfOperator* PdfParser::findOp(const char *name) {
103    int a = -1;
104    int b = numOps;
105    int cmp = -1;
106 @@ -1748,7 +1748,7 @@ void PdfParser::doShadingPatternFillFallback(GfxShadingPattern *sPat,
107                                               GBool stroke, GBool eoFill) {
108    GfxShading *shading;
109    GfxPath *savedPath;
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;
114    double det;
115 @@ -1990,7 +1990,7 @@ void PdfParser::doFunctionShFill1(GfxFunctionShading *shading,
116    GfxColor color0M, color1M, colorM0, colorM1, colorMM;
117    GfxColor colors2[4];
118    double functionColorDelta = colorDeltas[pdfFunctionShading-1];
119 -  double *matrix;
120 +  const double *matrix;
121    double xM, yM;
122    int nComps, i, j;
123  
124 @@ -2170,7 +2170,7 @@ void PdfParser::doPatchMeshShFill(GfxPatchMeshShading *shading) {
125    }
126  }
127  
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];
137 -  double *mat;
138 +  const double *mat;
139    Object charProc;
140    Dict *resDict;
141    Parser *oldParser;
142 @@ -3665,7 +3665,6 @@ void PdfParser::opBeginImage(Object /*args*/[], int /*numArgs*/)
143  Stream *PdfParser::buildImageStream() {
144    Object dict;
145    Object obj;
146 -  char *key;
147    Stream *str;
148  
149    // build dictionary
150 @@ -3683,26 +3682,17 @@ Stream *PdfParser::buildImageStream() {
151        obj.free();
152  #endif
153      } else {
154 -      key = copyString(obj.getName());
155 -#if defined(POPPLER_NEW_OBJECT_API)
156 -      obj = parser->getObj();
157 -#else
158 -      obj.free();
159 -      parser->getObj(&obj);
160 -#endif
161 -      if (obj.isEOF() || obj.isError()) {
162 -       gfree(key);
163 +      Object obj2;
164 +      _POPPLER_CALL(obj2, parser->getObj);
165 +      if (obj2.isEOF() || obj2.isError()) {
166 +        _POPPLER_FREE(obj);
167         break;
168        }
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);
174      }
175 -    obj = parser->getObj();
176 -#else
177 -      dict.dictAdd(key, &obj);
178 -    }
179 -    parser->getObj(&obj);
180 -#endif
181 +    _POPPLER_CALL(obj, parser->getObj);
182    }
183    if (obj.isEOF()) {
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
189 @@ -9,6 +9,7 @@
190  #define PDF_PARSER_H
191  
192  #ifdef HAVE_POPPLER
193 +#include "poppler-transition-api.h"
194  
195  #ifdef USE_GCC_PRAGMAS
196  #pragma interface
197 @@ -128,11 +129,14 @@ public:
198  
199    // Constructor for regular output.
200    PdfParser(XRef *xrefA, SvgBuilder *builderA, int pageNum, int rotate,
201 -            Dict *resDict, PDFRectangle *box, PDFRectangle *cropBox);
202 +            Dict *resDict,
203 +            _POPPLER_CONST PDFRectangle *box,
204 +            _POPPLER_CONST PDFRectangle *cropBox);
205  
206    // Constructor for a sub-page object.
207    PdfParser(XRef *xrefA, Inkscape::Extension::Internal::SvgBuilder *builderA,
208 -            Dict *resDict, PDFRectangle *box);
209 +            Dict *resDict,
210 +            _POPPLER_CONST PDFRectangle *box);
211  
212    virtual ~PdfParser();
213  
214 @@ -186,7 +190,7 @@ private:
215  
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);
221    int getPos();
222  
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);
229    void doEndPath();
230  
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
233 new file mode 100644
234 index 0000000000..898e64bf2b
235 --- /dev/null
236 +++ b/src/extension/internal/pdfinput/poppler-transition-api.h
237 @@ -0,0 +1,39 @@
238 +#ifndef SEEN_POPPLER_TRANSITION_API_H
239 +#define SEEN_POPPLER_TRANSITION_API_H
240 +
241 +#include <glib/poppler-features.h>
242 +
243 +#if POPPLER_CHECK_VERSION(0,70,0)
244 +#define _POPPLER_CONST const
245 +#else
246 +#define _POPPLER_CONST
247 +#endif
248 +
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))
253 +#else
254 +#define _POPPLER_DICTADD(dict, key, obj) (dict).dictAdd(copyString(key), &obj)
255 +#endif
256 +
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__))
262 +#else
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))
266 +#endif
267 +
268 +#if POPPLER_CHECK_VERSION(0, 29, 0)
269 +#define POPPLER_EVEN_NEWER_NEW_COLOR_SPACE_API
270 +#endif
271 +
272 +#if POPPLER_CHECK_VERSION(0, 25, 0)
273 +#define POPPLER_EVEN_NEWER_COLOR_SPACE_API
274 +#endif
275 +
276 +#endif
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);
285 -            double *ptm;
286 +            const double *ptm;
287              double m[6] = {1, 0, 0, 1, 0, 0};
288              double det;
289  
290 @@ -672,7 +672,7 @@ gchar *SvgBuilder::_createTilingPattern(GfxTilingPattern *tiling_pattern,
291  
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};
297      double det;
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,
309   */
310  gchar *SvgBuilder::_createGradient(GfxShading *shading, double *matrix, bool for_shading) {
311      Inkscape::XML::Node *gradient;
312 -    Function *func;
313 +    _POPPLER_CONST Function *func;
314      int num_funcs;
315      bool extend0, extend1;
316  
317 @@ -865,7 +865,7 @@ static bool svgGetShadingColorRGB(GfxShading *shading, double offset, GfxRGB *re
318  
319  #define INT_EPSILON 8
320  bool SvgBuilder::_addGradientStops(Inkscape::XML::Node *gradient, GfxShading *shading,
321 -                                   Function *func) {
322 +                                   _POPPLER_CONST Function *func) {
323      int type = func->getType();
324      if ( type == 0 || type == 2 ) {  // Sampled or exponential function
325          GfxRGB stop1, stop2;
326 @@ -877,9 +877,9 @@ bool SvgBuilder::_addGradientStops(Inkscape::XML::Node *gradient, GfxShading *sh
327              _addStopToGradient(gradient, 1.0, &stop2, 1.0);
328          }
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();
337  
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);
341              // Add stops
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();
345                  if (expE > 1.0) {
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];
356          }
357 @@ -1193,7 +1193,7 @@ void SvgBuilder::updateTextPosition(double tx, double ty) {
358  void SvgBuilder::updateTextMatrix(GfxState *state) {
359      _flushText();
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] );
365      double max_scale;
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
370 @@ -15,6 +15,7 @@
371  #endif
372  
373  #ifdef HAVE_POPPLER
374 +#include "poppler-transition-api.h"
375  
376  class SPDocument;
377  namespace Inkscape {
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,
382 -                           Function *func);
383 +                           _POPPLER_CONST Function *func);
384      gchar *_createTilingPattern(GfxTilingPattern *tiling_pattern, GfxState *state,
385                                  bool is_stroke=false);
386      // Image/mask creation
This page took 0.073418 seconds and 3 git commands to generate.