]>
Commit | Line | Data |
---|---|---|
f7965bac JR |
1 | diff -urN kitinerary-19.04.1/src/CMakeLists.txt kitinerary-19.04.1-poppler-0.83/src/CMakeLists.txt |
2 | --- kitinerary-19.04.1/src/CMakeLists.txt 2019-04-29 07:13:27.000000000 +0200 | |
3 | +++ kitinerary-19.04.1-poppler-0.83/src/CMakeLists.txt 2020-03-23 22:04:40.513590800 +0100 | |
4 | @@ -50,6 +50,7 @@ | |
5 | locationutil.cpp | |
6 | mergeutil.cpp | |
7 | pdfdocument.cpp | |
8 | + popplerglobalparams.cpp | |
9 | qimageluminancesource.cpp | |
10 | qimagepurebinarizer.cpp | |
11 | rct2ticket.cpp | |
12 | diff -urN kitinerary-19.04.1/src/pdfdocument.cpp kitinerary-19.04.1-poppler-0.83/src/pdfdocument.cpp | |
13 | --- kitinerary-19.04.1/src/pdfdocument.cpp 2020-03-23 22:12:02.086930170 +0100 | |
14 | +++ kitinerary-19.04.1-poppler-0.83/src/pdfdocument.cpp 2020-03-23 22:06:52.540259271 +0100 | |
15 | @@ -17,13 +17,13 @@ | |
16 | ||
17 | #include "config-kitinerary.h" | |
18 | #include "pdfdocument.h" | |
19 | +#include "popplerglobalparams_p.h" | |
20 | ||
21 | #include <QDebug> | |
22 | #include <QImage> | |
23 | #include <QScopedValueRollback> | |
24 | ||
25 | #ifdef HAVE_POPPLER | |
26 | -#include <GlobalParams.h> | |
27 | #include <PDFDoc.h> | |
28 | #include <Stream.h> | |
29 | #include <TextOutputDev.h> | |
30 | @@ -81,15 +81,6 @@ | |
31 | }; | |
32 | ||
33 | #ifdef HAVE_POPPLER | |
34 | -static std::unique_ptr<GlobalParams> s_globalParams; | |
35 | -static GlobalParams* popplerGlobalParams() | |
36 | -{ | |
37 | - if (!s_globalParams) { | |
38 | - s_globalParams.reset(new GlobalParams); | |
39 | - } | |
40 | - return s_globalParams.get(); | |
41 | -} | |
42 | - | |
43 | class ExtractorOutputDevice : public TextOutputDev | |
44 | { | |
45 | public: | |
46 | @@ -309,7 +300,7 @@ | |
47 | } | |
48 | ||
49 | #ifdef HAVE_POPPLER | |
50 | - QScopedValueRollback<GlobalParams*> globalParamResetter(globalParams, popplerGlobalParams()); | |
51 | + PopplerGlobalParams gp; | |
52 | ||
53 | #ifdef HAVE_POPPLER_0_69 | |
54 | const auto xref = d->m_page->m_doc->m_popplerDoc->getXRef(); | |
55 | @@ -348,7 +339,7 @@ | |
56 | } | |
57 | ||
58 | #ifdef HAVE_POPPLER | |
59 | - QScopedValueRollback<GlobalParams*> globalParamResetter(globalParams, popplerGlobalParams()); | |
60 | + PopplerGlobalParams gp; | |
61 | ExtractorOutputDevice device; | |
62 | m_doc->m_popplerDoc->displayPageSlice(&device, m_pageNum + 1, 72, 72, 0, false, true, false, -1, -1, -1, -1); | |
63 | const auto pageRect = m_doc->m_popplerDoc->getPage(m_pageNum + 1)->getCropBox(); | |
64 | @@ -392,7 +383,7 @@ | |
65 | QString PdfPage::textInRect(double left, double top, double right, double bottom) const | |
66 | { | |
67 | #ifdef HAVE_POPPLER | |
68 | - QScopedValueRollback<GlobalParams*> globalParamResetter(globalParams, popplerGlobalParams()); | |
69 | + PopplerGlobalParams gp; | |
70 | ||
71 | ExtractorOutputDevice device; | |
72 | d->m_doc->m_popplerDoc->displayPageSlice(&device, d->m_pageNum + 1, 72, 72, 0, false, true, false, -1, -1, -1, -1); | |
73 | @@ -439,7 +430,7 @@ | |
74 | d->load(); | |
75 | QVariantList l; | |
76 | #ifdef HAVE_POPPLER | |
77 | - QScopedValueRollback<GlobalParams*> globalParamResetter(globalParams, popplerGlobalParams()); | |
78 | + PopplerGlobalParams gp; | |
79 | const auto pageRect = d->m_doc->m_popplerDoc->getPage(d->m_pageNum + 1)->getCropBox(); | |
80 | ||
81 | for (const auto &img : d->m_images) { | |
82 | @@ -504,7 +495,7 @@ | |
83 | PdfDocument* PdfDocument::fromData(const QByteArray &data, QObject *parent) | |
84 | { | |
85 | #ifdef HAVE_POPPLER | |
86 | - QScopedValueRollback<GlobalParams*> globalParamResetter(globalParams, popplerGlobalParams()); | |
87 | + PopplerGlobalParams gp; | |
88 | ||
89 | std::unique_ptr<PdfDocument> doc(new PdfDocument(parent)); | |
90 | doc->d->m_pdfData = data; | |
91 | diff -urN kitinerary-19.04.1/src/popplerglobalparams.cpp kitinerary-19.04.1-poppler-0.83/src/popplerglobalparams.cpp | |
92 | --- kitinerary-19.04.1/src/popplerglobalparams.cpp 1970-01-01 01:00:00.000000000 +0100 | |
93 | +++ kitinerary-19.04.1-poppler-0.83/src/popplerglobalparams.cpp 2020-03-23 22:10:40.633595724 +0100 | |
94 | @@ -0,0 +1,55 @@ | |
95 | +/* | |
96 | + Copyright (C) 2019 Volker Krause <vkrause@kde.org> | |
97 | + | |
98 | + This program is free software; you can redistribute it and/or modify it | |
99 | + under the terms of the GNU Library General Public License as published by | |
100 | + the Free Software Foundation; either version 2 of the License, or (at your | |
101 | + option) any later version. | |
102 | + | |
103 | + This program is distributed in the hope that it will be useful, but WITHOUT | |
104 | + ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or | |
105 | + FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public | |
106 | + License for more details. | |
107 | + | |
108 | + You should have received a copy of the GNU General Public License | |
109 | + along with this program. If not, see <https://www.gnu.org/licenses/>. | |
110 | +*/ | |
111 | + | |
112 | +#include "config-kitinerary.h" | |
113 | +#include "popplerglobalparams_p.h" | |
114 | + | |
115 | +#include <qglobal.h> | |
116 | + | |
117 | +#ifdef HAVE_POPPLER | |
118 | +#include <GlobalParams.h> | |
119 | + | |
120 | +using namespace KItinerary; | |
121 | + | |
122 | +static std::unique_ptr<GlobalParams> s_globalParams; | |
123 | + | |
124 | +PopplerGlobalParams::PopplerGlobalParams() | |
125 | +{ | |
126 | + if (!s_globalParams) { | |
127 | + s_globalParams.reset(new GlobalParams); | |
128 | + } | |
129 | + | |
130 | +#ifdef HAVE_POPPLER_0_82 | |
131 | + std::swap(globalParams, m_prev); | |
132 | + std::swap(s_globalParams, globalParams); | |
133 | +#else | |
134 | + m_prev.reset(globalParams); | |
135 | + globalParams = s_globalParams.get(); | |
136 | +#endif | |
137 | +} | |
138 | + | |
139 | +PopplerGlobalParams::~PopplerGlobalParams() | |
140 | +{ | |
141 | +#ifdef HAVE_POPPLER_0_82 | |
142 | + std::swap(s_globalParams, globalParams); | |
143 | + std::swap(globalParams, m_prev); | |
144 | +#else | |
145 | + globalParams = m_prev.release(); | |
146 | +#endif | |
147 | +} | |
148 | + | |
149 | +#endif | |
150 | diff -urN kitinerary-19.04.1/src/popplerglobalparams_p.h kitinerary-19.04.1-poppler-0.83/src/popplerglobalparams_p.h | |
151 | --- kitinerary-19.04.1/src/popplerglobalparams_p.h 1970-01-01 01:00:00.000000000 +0100 | |
152 | +++ kitinerary-19.04.1-poppler-0.83/src/popplerglobalparams_p.h 2020-03-23 22:04:09.146923695 +0100 | |
153 | @@ -0,0 +1,40 @@ | |
154 | +/* | |
155 | + Copyright (C) 2019 Volker Krause <vkrause@kde.org> | |
156 | + | |
157 | + This program is free software; you can redistribute it and/or modify it | |
158 | + under the terms of the GNU Library General Public License as published by | |
159 | + the Free Software Foundation; either version 2 of the License, or (at your | |
160 | + option) any later version. | |
161 | + | |
162 | + This program is distributed in the hope that it will be useful, but WITHOUT | |
163 | + ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or | |
164 | + FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public | |
165 | + License for more details. | |
166 | + | |
167 | + You should have received a copy of the GNU General Public License | |
168 | + along with this program. If not, see <https://www.gnu.org/licenses/>. | |
169 | +*/ | |
170 | + | |
171 | +#ifndef KITINERARY_POPPLERGLOBALPARAMS_H | |
172 | +#define KITINERARY_POPPLERGLOBALPARAMS_H | |
173 | + | |
174 | +#include <memory> | |
175 | + | |
176 | +class GlobalParams; | |
177 | + | |
178 | +namespace KItinerary { | |
179 | + | |
180 | +/** RAII wrapper of the globalParams object. */ | |
181 | +class PopplerGlobalParams | |
182 | +{ | |
183 | +public: | |
184 | + PopplerGlobalParams(); | |
185 | + ~PopplerGlobalParams(); | |
186 | + | |
187 | +private: | |
188 | + std::unique_ptr<GlobalParams> m_prev; | |
189 | +}; | |
190 | + | |
191 | +} | |
192 | + | |
193 | +#endif // KITINERARY_POPPLERGLOBALPARAMS_H |