summaryrefslogtreecommitdiffstats
path: root/src/extension/internal/pdfinput/poppler-transition-api.h
blob: dc9e47e45bbcada1e9b9058b875f55a383a57a5b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
// SPDX-License-Identifier: GPL-2.0-or-later
/** @file
 * TODO short description
 *//*
 * Authors:
 *   see git history
 *
 * Copyright (C) 2018 Authors
 * Released under GNU GPL v2+, read the file 'COPYING' for more information.
 */

#ifndef SEEN_POPPLER_TRANSITION_API_H
#define SEEN_POPPLER_TRANSITION_API_H

#include <glib/poppler-features.h>

#if POPPLER_CHECK_VERSION(22, 4, 0)
#define _POPPLER_FONTPTR_TO_GFX8(font_ptr) ((Gfx8BitFont *)font_ptr.get())
#else
#define _POPPLER_FONTPTR_TO_GFX8(font_ptr) ((Gfx8BitFont *)font_ptr)
#endif

#if POPPLER_CHECK_VERSION(22, 3, 0)
#define _POPPLER_MAKE_SHARED_PDFDOC(uri) std::make_shared<PDFDoc>(std::make_unique<GooString>(uri))
#else
#define _POPPLER_MAKE_SHARED_PDFDOC(uri) std::make_shared<PDFDoc>(new GooString(uri), nullptr, nullptr, nullptr)
#endif

#if POPPLER_CHECK_VERSION(0, 83, 0)
#define _POPPLER_CONST_83 const
#else
#define _POPPLER_CONST_83
#endif

#if POPPLER_CHECK_VERSION(0, 82, 0)
#define _POPPLER_CONST_82 const
#else
#define _POPPLER_CONST_82
#endif

#if POPPLER_CHECK_VERSION(0, 76, 0)
#define _POPPLER_NEW_PARSER(xref, obj) Parser(xref, obj, gFalse)
#else
#define _POPPLER_NEW_PARSER(xref, obj) Parser(xref, new Lexer(xref, obj), gFalse)
#endif

#if POPPLER_CHECK_VERSION(0, 83, 0)
#define _POPPLER_NEW_GLOBAL_PARAMS(args...) std::unique_ptr<GlobalParams>(new GlobalParams(args))
#else
#define _POPPLER_NEW_GLOBAL_PARAMS(args...) new GlobalParams(args)
#endif


#if POPPLER_CHECK_VERSION(0, 72, 0)
#define getCString c_str
#endif

#if POPPLER_CHECK_VERSION(0,71,0)
typedef bool GBool;
#define gTrue true
#define gFalse false
#endif

#if POPPLER_CHECK_VERSION(0,70,0)
#define _POPPLER_CONST const
#else
#define _POPPLER_CONST
#endif

#if POPPLER_CHECK_VERSION(0,69,0)
#define _POPPLER_DICTADD(dict, key, obj) (dict).dictAdd(key, std::move(obj))
#elif POPPLER_CHECK_VERSION(0,58,0)
#define _POPPLER_DICTADD(dict, key, obj) (dict).dictAdd(copyString(key), std::move(obj))
#else
#define _POPPLER_DICTADD(dict, key, obj) (dict).dictAdd(copyString(key), &obj)
#endif

#if POPPLER_CHECK_VERSION(0,58,0)
#define POPPLER_NEW_OBJECT_API
#define _POPPLER_FREE(obj)
#define _POPPLER_CALL(ret, func) (ret = func())
#define _POPPLER_CALL_ARGS(ret, func, ...) (ret = func(__VA_ARGS__))
#define _POPPLER_CALL_ARGS_DEREF _POPPLER_CALL_ARGS
#else
#define _POPPLER_FREE(obj) (obj).free()
#define _POPPLER_CALL(ret, func) (*func(&ret))
#define _POPPLER_CALL_ARGS(ret, func, ...) (func(__VA_ARGS__, &ret))
#define _POPPLER_CALL_ARGS_DEREF(...) (*_POPPLER_CALL_ARGS(__VA_ARGS__))
#endif

#if !POPPLER_CHECK_VERSION(0, 29, 0)
#error "Requires poppler >= 0.29"
#endif

#endif