Commit 0d0f8cd1 authored by Volker Krause's avatar Volker Krause
Browse files

Remove conditionals used for building without Poppler

Poppler is nowadays forced as a mandatory dependency in CMake, so this is
no longer needed and just unecessarily complicates the code.
parent 732fc54b
Pipeline #170554 passed with stage
in 5 minutes and 51 seconds
......@@ -72,17 +72,12 @@ if(TARGET Poppler::Core)
find_file(HAVE_POPPLER_UNSTABLE_HEADERS "OutputDev.h" PATHS ${Poppler_INCLUDE_DIRS} NO_DEFAULT_PATH)
if (NOT HAVE_POPPLER_UNSTABLE_HEADERS)
message(FATAL_ERROR "Poppler was not build with ENABLE_UNSTABLE_API_ABI_HEADER!")
set(HAVE_POPPLER FALSE)
else()
set(HAVE_POPPLER TRUE)
endif()
endif()
if (HAVE_POPPLER)
string(REGEX MATCH "([0-9]+)\.0*([0-9]+)\.0*([0-9]+)" _match ${Poppler_VERSION})
set(POPPLER_VERSION_MAJOR ${CMAKE_MATCH_1})
set(POPPLER_VERSION_MINOR ${CMAKE_MATCH_2})
set(POPPLER_VERSION_PATCH ${CMAKE_MATCH_3})
endif()
string(REGEX MATCH "([0-9]+)\.0*([0-9]+)\.0*([0-9]+)" _match ${Poppler_VERSION})
set(POPPLER_VERSION_MAJOR ${CMAKE_MATCH_1})
set(POPPLER_VERSION_MINOR ${CMAKE_MATCH_2})
set(POPPLER_VERSION_PATCH ${CMAKE_MATCH_3})
if (TARGET ZXing::ZXing OR TARGET ZXing::Core)
set(HAVE_ZXING ON)
......
......@@ -15,9 +15,7 @@ find_dependency(KPimPkPass "@PIM_PKPASS@")
if (NOT @BUILD_SHARED_LIBS@)
find_dependency(ZLIB)
if (@HAVE_POPPLER@)
find_dependency(Poppler)
endif()
find_dependency(Poppler)
if (@HAVE_ZXING@)
find_dependency(ZXing)
endif()
......
......@@ -60,9 +60,6 @@ private Q_SLOTS:
QFile f(QStringLiteral(SOURCE_DIR "/misc/test.pdf"));
QVERIFY(f.open(QFile::ReadOnly));
#ifndef HAVE_POPPLER
QSKIP("No Poppler support");
#endif
auto root = engine.documentNodeFactory()->createNode(f.readAll());
QVERIFY(!root.isNull());
QCOMPARE(root.mimeType(), QLatin1String("application/pdf"));
......@@ -103,9 +100,6 @@ private Q_SLOTS:
QFile f(QStringLiteral(SOURCE_DIR "/misc/test.pdf"));
QVERIFY(f.open(QFile::ReadOnly));
#ifndef HAVE_POPPLER
QSKIP("No Poppler support");
#endif
std::unique_ptr<PdfDocument> pdf(PdfDocument::fromData(f.readAll()));
auto root = engine.documentNodeFactory()->createNode(QVariant::fromValue(pdf.get()), u"application/pdf");
QVERIFY(!root.isNull());
......
......@@ -129,9 +129,6 @@ private Q_SLOTS:
QFile f(s(SOURCE_DIR "/extractordata/synthetic/iata-bcbp-demo.pdf"));
QVERIFY(f.open(QFile::ReadOnly));
#ifndef HAVE_POPPLER
QSKIP("No Poppler support");
#endif
ExtractorEngine engine;
engine.setData(f.readAll());
engine.extract();
......
......@@ -55,13 +55,11 @@ private Q_SLOTS:
QTest::newRow("text/plain") << s(SOURCE_DIR "/scriptenginedata/plain-text.txt") << s(SOURCE_DIR "/scriptenginedata/plain-text.txt.json");
QTest::newRow("pkpass") << s(SOURCE_DIR "/pkpassdata/swiss.pkpass") << s(SOURCE_DIR "/scriptenginedata/swiss.pkpass.json");
#ifdef HAVE_POPPLER
QTest::newRow("IATA BCBP PDF") << s(SOURCE_DIR "/extractordata/synthetic/iata-bcbp-demo.pdf")
#ifdef HAVE_ZXING
<< s(SOURCE_DIR "/scriptenginedata/iata-bcbp-demo.pdf.json");
#else
<< s(SOURCE_DIR "/scriptenginedata/iata-bcbp-demo.pdf-no-zxing.json");
#endif
#endif
QTest::newRow("ical") << s(SOURCE_DIR "/extractordata/ical/eventreservation.ics") << s(SOURCE_DIR "/scriptenginedata/eventreservation.ics.json");
QTest::newRow("uic9183") << s(SOURCE_DIR "/uic918-3/valid/Testw_VOW8XG6_A9E8DXL_0.bin") << s(SOURCE_DIR "/scriptenginedata/Testw_VOW8XG6_A9E8DXL_0.bin.json");
......
......@@ -5,7 +5,6 @@
*/
#include <KItinerary/PdfDocument>
#include <config-kitinerary.h>
#include <QFile>
#include <QObject>
......@@ -32,7 +31,6 @@ private Q_SLOTS:
{
QFile f(QStringLiteral(SOURCE_DIR "/misc/test.pdf"));
QVERIFY(f.open(QFile::ReadOnly));
#ifdef HAVE_POPPLER
QVERIFY(PdfDocument::maybePdf(f.readAll()));
f.seek(0);
std::unique_ptr<PdfDocument> doc(PdfDocument::fromData(f.readAll()));
......@@ -73,7 +71,6 @@ private Q_SLOTS:
QCOMPARE(doc->creationTime(), QDateTime({2018, 4, 29}, {11, 41, 28}, Qt::OffsetFromUTC, 7200));
QCOMPARE(doc->modificationTime(), QDateTime());
#endif
}
void testInvalidPdfDocument()
......
......@@ -183,9 +183,7 @@ target_link_libraries(KPimItinerary
OpenSSL::Crypto
ZLIB::ZLIB
)
if (HAVE_POPPLER)
target_link_libraries(KPimItinerary PRIVATE Poppler::Core)
endif()
target_link_libraries(KPimItinerary PRIVATE Poppler::Core)
if (TARGET KF5::I18nLocaleData)
target_link_libraries(KPimItinerary PRIVATE KF5::I18nLocaleData)
endif()
......
......@@ -7,7 +7,6 @@
#ifndef CONFIG_KITINERARY_H
#define CONFIG_KITINERARY_H
#cmakedefine HAVE_POPPLER
// namespaced by "K" to not interfere with defines poppler provides itself
#define KPOPPLER_VERSION_STRING "@Poppler_VERSION@"
#define KPOPPLER_VERSION_MAJOR @POPPLER_VERSION_MAJOR@
......
......@@ -33,13 +33,7 @@ QString ExtractorCapabilities::capabilitiesString()
#endif
"\n"
"PDF support : "
#ifdef HAVE_POPPLER
"poppler (" KPOPPLER_VERSION_STRING ")"
#else
"not available"
#endif
"\n"
"PDF support : poppler (" KPOPPLER_VERSION_STRING ")\n"
"iCal support : "
#ifdef HAVE_KCAL
......
......@@ -17,11 +17,9 @@
#include <QImage>
#include <QScopedValueRollback>
#ifdef HAVE_POPPLER
#include <DateInfo.h>
#include <PDFDoc.h>
#include <Stream.h>
#endif
#include <cmath>
......@@ -33,7 +31,6 @@ void PdfPagePrivate::load()
return;
}
#ifdef HAVE_POPPLER
PopplerGlobalParams gp;
PdfExtractorOutputDevice device;
m_doc->m_popplerDoc->displayPageSlice(&device, m_pageNum + 1, 72, 72, 0, false, true, false, -1, -1, -1, -1);
......@@ -50,7 +47,6 @@ void PdfPagePrivate::load()
for (auto it = m_images.begin(); it != m_images.end(); ++it) {
(*it).d->m_page = this;
}
#endif
m_loaded = true;
}
......@@ -69,16 +65,13 @@ QString PdfPage::text() const
return d->m_text;
}
#ifdef HAVE_POPPLER
static double ratio(double begin, double end, double ratio)
{
return begin + (end - begin) * ratio;
}
#endif
QString PdfPage::textInRect(double left, double top, double right, double bottom) const
{
#ifdef HAVE_POPPLER
PopplerGlobalParams gp;
const auto page = d->m_doc->m_popplerDoc->getPage(d->m_pageNum + 1);
......@@ -114,13 +107,6 @@ QString PdfPage::textInRect(double left, double top, double right, double bottom
#else
return QString::fromUtf8(s->getCString());
#endif
#else
Q_UNUSED(left)
Q_UNUSED(top)
Q_UNUSED(right)
Q_UNUSED(bottom)
return {};
#endif
}
int PdfPage::imageCount() const
......@@ -148,7 +134,6 @@ QVariantList PdfPage::imagesInRect(double left, double top, double right, double
{
d->load();
QVariantList l;
#ifdef HAVE_POPPLER
PopplerGlobalParams gp;
const auto pageRect = d->m_doc->m_popplerDoc->getPage(d->m_pageNum + 1)->getCropBox();
......@@ -159,12 +144,6 @@ QVariantList PdfPage::imagesInRect(double left, double top, double right, double
l.push_back(QVariant::fromValue(img));
}
}
#else
Q_UNUSED(left)
Q_UNUSED(top)
Q_UNUSED(right)
Q_UNUSED(bottom)
#endif
return l;
}
......@@ -186,11 +165,7 @@ QString PdfDocument::text() const
int PdfDocument::pageCount() const
{
#ifdef HAVE_POPPLER
return d->m_popplerDoc->getNumPages();
#else
return 0;
#endif
}
PdfPage PdfDocument::page(int index) const
......@@ -203,7 +178,6 @@ int PdfDocument::fileSize() const
return d->m_pdfData.size();
}
#ifdef HAVE_POPPLER
#if KPOPPLER_VERSION >= QT_VERSION_CHECK(21, 8, 0)
static QDateTime parsePdfDateTime(const GooString *str)
#else
......@@ -238,11 +212,9 @@ static QDateTime parsePdfDateTime(const char *str)
}
return QDateTime(date, time, Qt::UTC);
}
#endif
QDateTime PdfDocument::creationTime() const
{
#ifdef HAVE_POPPLER
std::unique_ptr<GooString> dt(d->m_popplerDoc->getDocInfoCreatDate());
if (!dt) {
return {};
......@@ -254,14 +226,10 @@ QDateTime PdfDocument::creationTime() const
#else
return parsePdfDateTime(dt->getCString());
#endif
#else
return {};
#endif
}
QDateTime PdfDocument::modificationTime() const
{
#ifdef HAVE_POPPLER
std::unique_ptr<GooString> dt(d->m_popplerDoc->getDocInfoModDate());
if (!dt) {
return {};
......@@ -273,9 +241,6 @@ QDateTime PdfDocument::modificationTime() const
#else
return parsePdfDateTime(dt->getCString());
#endif
#else
return {};
#endif
}
QVariantList PdfDocument::pagesVariant() const
......@@ -288,7 +253,6 @@ QVariantList PdfDocument::pagesVariant() const
PdfDocument* PdfDocument::fromData(const QByteArray &data, QObject *parent)
{
#ifdef HAVE_POPPLER
PopplerGlobalParams gp;
std::unique_ptr<PdfDocument> doc(new PdfDocument(parent));
......@@ -317,11 +281,6 @@ PdfDocument* PdfDocument::fromData(const QByteArray &data, QObject *parent)
doc->d->m_popplerDoc = std::move(popplerDoc);
return doc.release();
#else
Q_UNUSED(data)
Q_UNUSED(parent)
return nullptr;
#endif
}
bool PdfDocument::maybePdf(const QByteArray &data)
......
......@@ -45,9 +45,7 @@ public:
// image data in here is stored in its source form, without applied transformations
std::unordered_map<int, QImage> m_imageData;
std::vector<PdfPage> m_pages;
#ifdef HAVE_POPPLER
std::unique_ptr<PDFDoc> m_popplerDoc;
#endif
};
}
......
......@@ -13,7 +13,6 @@
using namespace KItinerary;
#ifdef HAVE_POPPLER
PdfExtractorOutputDevice::PdfExtractorOutputDevice()
: TextOutputDev(nullptr, false, 0, false, false)
{
......@@ -233,5 +232,3 @@ void PdfExtractorOutputDevice::addVectorImage(const PdfVectorPicture &pic)
img.d->m_vectorPicture = pic;
m_images.push_back(img);
}
#endif
......@@ -6,14 +6,10 @@
#pragma once
#include <config-kitinerary.h>
#include "pdfvectorpicture_p.h"
#include "popplertypes_p.h"
#ifdef HAVE_POPPLER
#include <TextOutputDev.h>
#endif
#include <vector>
......@@ -22,7 +18,6 @@ namespace KItinerary {
class PdfImage;
class PdfVectorPicture;
#ifdef HAVE_POPPLER
class PdfExtractorOutputDevice : public TextOutputDev
{
public:
......@@ -55,7 +50,5 @@ public:
std::vector<VectorOp> m_vectorOps;
};
#endif
}
......@@ -13,17 +13,14 @@
#include <QDebug>
#include <QScopedValueRollback>
#ifdef HAVE_POPPLER
#include <Gfx.h>
#include <GlobalParams.h>
#include <PDFDoc.h>
#include <Stream.h>
#include <OutputDev.h>
#endif
using namespace KItinerary;
#ifdef HAVE_POPPLER
// legacy image loading
#if KPOPPLER_VERSION < QT_VERSION_CHECK(0, 69, 0)
namespace KItinerary {
......@@ -128,7 +125,6 @@ QImage PdfImagePrivate::load(Stream* str, GfxImageColorMap* colorMap)
m_page->m_doc->m_imageData[m_refNum] = img;
return img;
}
#endif
QImage PdfImagePrivate::load()
{
......@@ -137,7 +133,6 @@ QImage PdfImagePrivate::load()
return (*it).second;
}
#ifdef HAVE_POPPLER
PopplerGlobalParams gp;
#if KPOPPLER_VERSION >= QT_VERSION_CHECK(0, 69, 0)
......@@ -149,10 +144,6 @@ QImage PdfImagePrivate::load()
m_page->m_doc->m_popplerDoc->displayPageSlice(device.get(), m_page->m_pageNum + 1, 72, 72, 0, false, true, false, -1, -1, -1, -1);
return device->image();
#endif
#else
return {};
#endif
}
......
......@@ -6,8 +6,6 @@
#pragma once
#include <config-kitinerary.h>
#include "pdfimage.h"
#include "pdfvectorpicture_p.h"
......@@ -27,18 +25,14 @@ class PdfPagePrivate;
class PdfImagePrivate : public QSharedData {
public:
QImage load();
#ifdef HAVE_POPPLER
QImage load(Stream *str, GfxImageColorMap *colorMap);
#endif
// pixel data
int m_refNum = -1;
int m_refGen = -1;
QImage::Format m_format = QImage::Format_Invalid;
PdfPagePrivate *m_page = nullptr;
#ifdef HAVE_POPPLER
std::unique_ptr<GfxImageColorMap> m_colorMap;
#endif
// vector data
PdfVectorPicture m_vectorPicture;
......
......@@ -9,7 +9,6 @@
#include <qglobal.h>
#ifdef HAVE_POPPLER
#include <GlobalParams.h>
#include <memory>
......@@ -42,5 +41,3 @@ PopplerGlobalParams::~PopplerGlobalParams()
std::swap(globalParams, m_prev);
#endif
}
#endif
......@@ -9,11 +9,8 @@
#include <config-kitinerary.h>
#include <qglobal.h>
#ifdef HAVE_POPPLER
#if KPOPPLER_VERSION >= QT_VERSION_CHECK(0, 82, 0)
using PopplerMaskColors = const int;
#else
using PopplerMaskColors = int;
#endif
#endif
......@@ -14,8 +14,6 @@
#include <memory>
#ifdef HAVE_POPPLER
#include <GfxState.h>
using namespace KItinerary;
......@@ -98,5 +96,3 @@ QPainterPath PopplerUtils::convertPath(const GfxPath *path, Qt::FillRule fillRul
}
return qpp;
}
#endif
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment