From 44304b32a57d9e328a3de7538b4560e55f6eec33 Mon Sep 17 00:00:00 2001 From: Albert Astals Cid Date: Fri, 29 Apr 2022 23:57:01 +0200 Subject: [PATCH] Use the poppler version includes instead of check_cxx_source_compiles --- autotests/formattest.cpp | 2 - autotests/keystroketest.cpp | 2 - autotests/kjsfunctionstest.cpp | 2 - autotests/parttest.cpp | 2 - autotests/visibilitytest.cpp | 2 - generators/poppler/CMakeLists.txt | 75 ------------------- generators/poppler/annots.cpp | 20 ++--- generators/poppler/annots.h | 5 +- .../poppler/config-okular-poppler.h.cmake | 20 ----- generators/poppler/formfields.cpp | 8 +- generators/poppler/formfields.h | 1 - generators/poppler/generator_pdf.cpp | 24 +++--- generators/poppler/generator_pdf.h | 6 +- generators/poppler/pdfsettingswidget.cpp | 6 +- generators/poppler/pdfsignatureutils.cpp | 8 +- generators/poppler/pdfsignatureutils.h | 8 +- 16 files changed, 43 insertions(+), 148 deletions(-) delete mode 100644 generators/poppler/config-okular-poppler.h.cmake diff --git a/autotests/formattest.cpp b/autotests/formattest.cpp index 4ef2dc369..af8e46815 100644 --- a/autotests/formattest.cpp +++ b/autotests/formattest.cpp @@ -15,8 +15,6 @@ #include #include -#include "../generators/poppler/config-okular-poppler.h" - class FormatTest : public QObject { Q_OBJECT diff --git a/autotests/keystroketest.cpp b/autotests/keystroketest.cpp index 7aabaddc9..653d93704 100644 --- a/autotests/keystroketest.cpp +++ b/autotests/keystroketest.cpp @@ -16,8 +16,6 @@ #include #include -#include "../generators/poppler/config-okular-poppler.h" - class KeystrokeTest : public QObject { Q_OBJECT diff --git a/autotests/kjsfunctionstest.cpp b/autotests/kjsfunctionstest.cpp index 742d444dd..8d795c8af 100644 --- a/autotests/kjsfunctionstest.cpp +++ b/autotests/kjsfunctionstest.cpp @@ -21,8 +21,6 @@ #include #include -#include "../generators/poppler/config-okular-poppler.h" - class MessageBoxHelper : public QObject { Q_OBJECT diff --git a/autotests/parttest.cpp b/autotests/parttest.cpp index a2e1862a0..f31d1891f 100644 --- a/autotests/parttest.cpp +++ b/autotests/parttest.cpp @@ -24,8 +24,6 @@ #include "../settings.h" #include "closedialoghelper.h" -#include "../generators/poppler/config-okular-poppler.h" - #include #include #include diff --git a/autotests/visibilitytest.cpp b/autotests/visibilitytest.cpp index 9a3d04fff..7cdcc36d5 100644 --- a/autotests/visibilitytest.cpp +++ b/autotests/visibilitytest.cpp @@ -14,8 +14,6 @@ #include #include -#include "../generators/poppler/config-okular-poppler.h" - class VisibilityTest : public QObject { Q_OBJECT diff --git a/generators/poppler/CMakeLists.txt b/generators/poppler/CMakeLists.txt index 87e3e2152..6d946927c 100644 --- a/generators/poppler/CMakeLists.txt +++ b/generators/poppler/CMakeLists.txt @@ -5,81 +5,6 @@ add_subdirectory( conf ) set(CMAKE_REQUIRED_LIBRARIES Poppler::Qt5 Qt5::Core Qt5::Gui) -check_cxx_source_compiles(" -#include -int main() -{ - Poppler::FormFieldChoice *ffc = nullptr; - ffc->choicesWithExportValues(); - return 0; -} -" HAVE_POPPLER_0_87) - -check_cxx_source_compiles(" -#include -#include -int main() -{ - auto f = &Poppler::PDFConverter::sign; - auto g = &Poppler::setNSSDir; -} -" HAVE_POPPLER_SIGNING) - -check_cxx_source_compiles(" -#include -#include -int main() -{ - Poppler::PDFConverter::NewSignatureData pData; - pData.setSignatureLeftText(QString()); -} -" HAVE_POPPLER_FANCY_SIGNATURE) - -check_cxx_source_compiles(" -#include -int main() -{ - Poppler::Document *doc = Poppler::Document::load(\"\", nullptr, nullptr); - doc->xrefWasReconstructed(); - return 0; -} -" HAVE_POPPLER_RECONSTRUCTION_CALLBACK) - -check_cxx_source_compiles(" -#include -#include -int main() -{ - int a = Poppler::FormFieldSignature::ValidateWithoutOCSPRevocationCheck; - return 0; -} -" HAVE_POPPLER_21_10) - -check_cxx_source_compiles(" -#include -#include -int main() -{ - auto us = Poppler::FormFieldSignature::UnsignedSignature; - Poppler::PDFConverter::NewSignatureData pData; - pData.setDocumentOwnerPassword(QByteArray()); -} -" HAVE_POPPLER_22_02) - -check_cxx_source_compiles(" -#include -#include -int main() -{ - (void)Poppler::LinkAction::SaveAs; -} -" HAVE_POPPLER_22_04) - -configure_file( - ${CMAKE_CURRENT_SOURCE_DIR}/config-okular-poppler.h.cmake - ${CMAKE_CURRENT_BINARY_DIR}/config-okular-poppler.h -) - include_directories( ${CMAKE_CURRENT_SOURCE_DIR}/../.. ) diff --git a/generators/poppler/annots.cpp b/generators/poppler/annots.cpp index 3254c21fc..611b9ef96 100644 --- a/generators/poppler/annots.cpp +++ b/generators/poppler/annots.cpp @@ -280,7 +280,7 @@ static void setSharedAnnotationPropertiesToPopplerAnnotation(const Okular::Annot popplerAnnotation->setModificationDate(okularAnnotation->modificationDate()); } -#ifdef HAVE_POPPLER_21_10 +#if POPPLER_VERSION_MACRO >= QT_VERSION_CHECK(21, 10, 0) static void setPopplerStampAnnotationCustomImage(const Poppler::Page *page, Poppler::StampAnnotation *pStampAnnotation, const Okular::StampAnnotation *oStampAnnotation) { const QSize size = page->pageSize(); @@ -348,7 +348,7 @@ static void updatePopplerAnnotationFromOkularAnnotation(const Okular::HighlightA pHighlightAnnotation->setHighlightQuads(pQuads); } -#ifdef HAVE_POPPLER_21_10 +#if POPPLER_VERSION_MACRO >= QT_VERSION_CHECK(21, 10, 0) static void updatePopplerAnnotationFromOkularAnnotation(const Okular::StampAnnotation *oStampAnnotation, Poppler::StampAnnotation *pStampAnnotation, const Poppler::Page *page) { setPopplerStampAnnotationCustomImage(page, pStampAnnotation, oStampAnnotation); @@ -420,7 +420,7 @@ static Poppler::Annotation *createPopplerAnnotationFromOkularAnnotation(const Ok return pHighlightAnnotation; } -#ifdef HAVE_POPPLER_21_10 +#if POPPLER_VERSION_MACRO >= QT_VERSION_CHECK(21, 10, 0) static Poppler::Annotation *createPopplerAnnotationFromOkularAnnotation(const Okular::StampAnnotation *oStampAnnotation, Poppler::Page *page) { Poppler::StampAnnotation *pStampAnnotation = new Poppler::StampAnnotation(); @@ -483,7 +483,7 @@ void PopplerAnnotationProxy::notifyAddition(Okular::Annotation *okl_ann, int pag ppl_ann = createPopplerAnnotationFromOkularAnnotation(static_cast(okl_ann)); break; case Okular::Annotation::AStamp: -#ifdef HAVE_POPPLER_21_10 +#if POPPLER_VERSION_MACRO >= QT_VERSION_CHECK(21, 10, 0) { bool wasDenyWriteEnabled = okl_ann->flags() & Okular::Annotation::DenyWrite; @@ -516,7 +516,7 @@ void PopplerAnnotationProxy::notifyAddition(Okular::Annotation *okl_ann, int pag return; } -#ifdef HAVE_POPPLER_21_10 +#if POPPLER_VERSION_MACRO >= QT_VERSION_CHECK(21, 10, 0) okl_ann->setFlags(okl_ann->flags() | Okular::Annotation::ExternallyDrawn); #else // Poppler doesn't render StampAnnotations yet @@ -595,7 +595,7 @@ void PopplerAnnotationProxy::notifyModification(const Okular::Annotation *okl_an case Poppler::Annotation::AStamp: { const Okular::StampAnnotation *okl_stampann = static_cast(okl_ann); Poppler::StampAnnotation *ppl_stampann = static_cast(ppl_ann); -#ifdef HAVE_POPPLER_21_10 +#if POPPLER_VERSION_MACRO >= QT_VERSION_CHECK(21, 10, 0) Poppler::Page *ppl_page = ppl_doc->page(page); updatePopplerAnnotationFromOkularAnnotation(okl_stampann, ppl_stampann, ppl_page); delete ppl_page; @@ -630,9 +630,9 @@ void PopplerAnnotationProxy::notifyRemoval(Okular::Annotation *okl_ann, int page Poppler::Page *ppl_page = ppl_doc->page(page); annotationsOnOpenHash->remove(okl_ann); -#ifdef HAVE_POPPLER_21_10 +#if POPPLER_VERSION_MACRO >= QT_VERSION_CHECK(21, 10, 0) if (okl_ann->subType() == Okular::Annotation::AStamp) { - deletedStampsAnnotationAppearance[static_cast(okl_ann)] = std::move(ppl_ann->annotationAppearance()); + deletedStampsAnnotationAppearance[static_cast(okl_ann)] = ppl_ann->annotationAppearance(); } #endif ppl_page->removeAnnotation(ppl_ann); // Also destroys ppl_ann @@ -1070,7 +1070,7 @@ Okular::Annotation *createAnnotationFromPopplerAnnotation(Poppler::Annotation *p break; } case Poppler::Annotation::AStamp: -#ifdef HAVE_POPPLER_21_10 +#if POPPLER_VERSION_MACRO >= QT_VERSION_CHECK(21, 10, 0) externallyDrawn = true; #endif tieToOkularAnn = true; @@ -1097,7 +1097,7 @@ Okular::Annotation *createAnnotationFromPopplerAnnotation(Poppler::Annotation *p if (externallyDrawn) { okularAnnotation->setFlags(okularAnnotation->flags() | Okular::Annotation::ExternallyDrawn); } -#ifdef HAVE_POPPLER_21_10 +#if POPPLER_VERSION_MACRO >= QT_VERSION_CHECK(21, 10, 0) if (okularAnnotation->subType() == Okular::Annotation::SubType::AStamp) { Okular::StampAnnotation *oStampAnn = static_cast(okularAnnotation); Poppler::StampAnnotation *pStampAnn = static_cast(popplerAnnotation); diff --git a/generators/poppler/annots.h b/generators/poppler/annots.h index 1f1b0fb9f..05d61fd77 100644 --- a/generators/poppler/annots.h +++ b/generators/poppler/annots.h @@ -12,12 +12,13 @@ #include #include +#include +#define POPPLER_VERSION_MACRO ((POPPLER_VERSION_MAJOR << 16) | (POPPLER_VERSION_MINOR << 8) | (POPPLER_VERSION_MICRO)) #include #include -#include "config-okular-poppler.h" #include "core/annotations.h" extern Okular::Annotation *createAnnotationFromPopplerAnnotation(Poppler::Annotation *popplerAnnotation, const Poppler::Page &popplerPage, bool *doDelete); @@ -37,7 +38,7 @@ private: Poppler::Document *ppl_doc; QMutex *mutex; QHash *annotationsOnOpenHash; -#ifdef HAVE_POPPLER_21_10 +#if POPPLER_VERSION_MACRO >= QT_VERSION_CHECK(21, 10, 0) std::unordered_map> deletedStampsAnnotationAppearance; #endif }; diff --git a/generators/poppler/config-okular-poppler.h.cmake b/generators/poppler/config-okular-poppler.h.cmake deleted file mode 100644 index 39f4ef1f3..000000000 --- a/generators/poppler/config-okular-poppler.h.cmake +++ /dev/null @@ -1,20 +0,0 @@ -/* Defined if we have the 0.87 version of the Poppler library */ -#cmakedefine HAVE_POPPLER_0_87 1 - -/* Defined if we have the pdf signature feature in the Poppler library */ -#cmakedefine HAVE_POPPLER_SIGNING 1 - -/* Defined if we have the pdf fancy signature feature in the Poppler library */ -#cmakedefine HAVE_POPPLER_FANCY_SIGNATURE 1 - -/* Defined if we have Poppler version that notifies for XRef Table reconstruction */ -#cmakedefine HAVE_POPPLER_RECONSTRUCTION_CALLBACK 1 - -/* Defined if we have the 21.10 version of the Poppler library or later */ -#cmakedefine HAVE_POPPLER_21_10 1 - -/* Defined if we have the 22.02 version of the Poppler library or later */ -#cmakedefine HAVE_POPPLER_22_02 1 - -/* Defined if we have the 22.04 version of the Poppler library or later */ -#cmakedefine HAVE_POPPLER_22_04 1 diff --git a/generators/poppler/formfields.cpp b/generators/poppler/formfields.cpp index 6b9d20a8e..34686faef 100644 --- a/generators/poppler/formfields.cpp +++ b/generators/poppler/formfields.cpp @@ -268,7 +268,7 @@ PopplerFormFieldChoice::PopplerFormFieldChoice(std::unique_ptrid(); SET_ACTIONS -#ifdef HAVE_POPPLER_0_87 +#if POPPLER_VERSION_MACRO >= QT_VERSION_CHECK(0, 87, 0) QMap values; const auto fieldChoicesWithExportValues = m_field->choicesWithExportValues(); for (const QPair &value : fieldChoicesWithExportValues) { @@ -396,7 +396,7 @@ PopplerFormFieldSignature::PopplerFormFieldSignature(std::unique_ptrrect()); m_id = m_field->id(); int validateOptions = Poppler::FormFieldSignature::ValidateVerifyCertificate; -#ifdef HAVE_POPPLER_21_10 +#if POPPLER_VERSION_MACRO >= QT_VERSION_CHECK(21, 10, 0) if (!PDFSettings::checkOCSPServers()) { validateOptions = validateOptions | Poppler::FormFieldSignature::ValidateWithoutOCSPRevocationCheck; } @@ -454,7 +454,7 @@ PopplerFormFieldSignature::SignatureType PopplerFormFieldSignature::signatureTyp return Okular::FormFieldSignature::AdbePkcs7detached; case Poppler::FormFieldSignature::EtsiCAdESdetached: return Okular::FormFieldSignature::EtsiCAdESdetached; -#ifdef HAVE_POPPLER_22_02 +#if POPPLER_VERSION_MACRO >= QT_VERSION_CHECK(22, 2, 0) case Poppler::FormFieldSignature::UnsignedSignature: return Okular::FormFieldSignature::UnsignedSignature; #endif @@ -470,7 +470,7 @@ const Okular::SignatureInfo &PopplerFormFieldSignature::signatureInfo() const bool PopplerFormFieldSignature::sign(const Okular::NewSignatureData &oData, const QString &newPath) const { -#ifdef HAVE_POPPLER_22_02 +#if POPPLER_VERSION_MACRO >= QT_VERSION_CHECK(22, 2, 0) Poppler::PDFConverter::NewSignatureData pData; PDFGenerator::okularToPoppler(oData, &pData); return m_field->sign(newPath, pData) == Poppler::FormFieldSignature::SigningSuccess; diff --git a/generators/poppler/formfields.h b/generators/poppler/formfields.h index c9cee593b..91df307b8 100644 --- a/generators/poppler/formfields.h +++ b/generators/poppler/formfields.h @@ -9,7 +9,6 @@ #define _OKULAR_GENERATOR_PDF_FORMFIELDS_H_ #include "core/form.h" -#include #include class PopplerFormFieldButton : public Okular::FormFieldButton diff --git a/generators/poppler/generator_pdf.cpp b/generators/poppler/generator_pdf.cpp index 2c9f11a2f..dea9dab36 100644 --- a/generators/poppler/generator_pdf.cpp +++ b/generators/poppler/generator_pdf.cpp @@ -51,8 +51,6 @@ #include "pdfsettings.h" -#include - #include #include @@ -380,7 +378,7 @@ static Okular::DocumentAction::DocumentActionType popplerToOkular(Poppler::LinkA return Okular::DocumentAction::Close; case Poppler::LinkAction::Print: return Okular::DocumentAction::Print; -#ifdef HAVE_POPPLER_22_04 +#if POPPLER_VERSION_MACRO >= QT_VERSION_CHECK(22, 04, 0) case Poppler::LinkAction::SaveAs: return Okular::DocumentAction::SaveAs; #endif @@ -633,7 +631,7 @@ PDFGenerator::PDFGenerator(QObject *parent, const QVariantList &args) // You only need to do it once not for each of the documents but it is cheap enough // so doing it all the time won't hurt either Poppler::setDebugErrorFunction(PDFGeneratorPopplerDebugFunction, QVariant()); -#ifdef HAVE_POPPLER_SIGNING +#if POPPLER_VERSION_MACRO >= QT_VERSION_CHECK(21, 1, 0) if (!PDFSettings::useDefaultCertDB()) { Poppler::setNSSDir(QUrl(PDFSettings::dBCertificatePath()).toLocalFile()); } @@ -694,7 +692,7 @@ Okular::Document::OpenResult PDFGenerator::init(QVector &pagesVe } xrefReconstructed = false; -#ifdef HAVE_POPPLER_RECONSTRUCTION_CALLBACK +#if POPPLER_VERSION_MACRO >= QT_VERSION_CHECK(21, 6, 0) if (pdfdoc->xrefWasReconstructed()) { xrefReconstructionHandler(); } else { @@ -1357,7 +1355,7 @@ QByteArray PDFGenerator::requestFontData(const Okular::FontInfo &font) return pdfdoc->fontData(fi); } -#ifdef HAVE_POPPLER_SIGNING +#if POPPLER_VERSION_MACRO >= QT_VERSION_CHECK(21, 1, 0) void PDFGenerator::okularToPoppler(const Okular::NewSignatureData &oData, Poppler::PDFConverter::NewSignatureData *pData) { pData->setCertNickname(oData.certNickname()); @@ -1365,14 +1363,14 @@ void PDFGenerator::okularToPoppler(const Okular::NewSignatureData &oData, Popple pData->setPage(oData.page()); const QString datetime = QDateTime::currentDateTime().toString(QStringLiteral("yyyy-MM-dd hh:mm:ss t")); pData->setSignatureText(i18n("Signed by: %1\n\nDate: %2", oData.certSubjectCommonName(), datetime)); -#ifdef HAVE_POPPLER_FANCY_SIGNATURE +#if POPPLER_VERSION_MACRO >= QT_VERSION_CHECK(21, 6, 0) pData->setSignatureLeftText(oData.certSubjectCommonName()); #endif const Okular::NormalizedRect bRect = oData.boundingRectangle(); pData->setBoundingRectangle({bRect.left, bRect.top, bRect.width(), bRect.height()}); pData->setFontColor(Qt::black); pData->setBorderColor(Qt::black); -#ifdef HAVE_POPPLER_22_02 +#if POPPLER_VERSION_MACRO >= QT_VERSION_CHECK(22, 2, 0) pData->setDocumentOwnerPassword(oData.documentPassword().toLatin1()); pData->setDocumentUserPassword(oData.documentPassword().toLatin1()); #endif @@ -1575,7 +1573,7 @@ QVariant PDFGenerator::metaData(const QString &key, const QVariant &option) cons return i18n("Using Poppler %1\n\nBuilt against Poppler %2", Poppler::Version::string(), QStringLiteral(POPPLER_VERSION)); } } else if (key == QLatin1String("ShowStampsWarning")) { -#ifdef HAVE_POPPLER_21_10 +#if POPPLER_VERSION_MACRO >= QT_VERSION_CHECK(21, 10, 0) return QStringLiteral("no"); #else return QStringLiteral("yes"); @@ -1583,7 +1581,7 @@ QVariant PDFGenerator::metaData(const QString &key, const QVariant &option) cons } else if (key == QLatin1String("DocumentHasPassword")) { return pdfdoc->isEncrypted() ? QStringLiteral("yes") : QStringLiteral("no"); } else if (key == QLatin1String("CanSignDocumentWithPassword")) { -#ifdef HAVE_POPPLER_22_02 +#if POPPLER_VERSION_MACRO >= QT_VERSION_CHECK(22, 2, 0) return QStringLiteral("yes"); #else return QStringLiteral("no"); @@ -2019,7 +2017,7 @@ Okular::AnnotationProxy *PDFGenerator::annotationProxy() const bool PDFGenerator::canSign() const { -#ifdef HAVE_POPPLER_SIGNING +#if POPPLER_VERSION_MACRO >= QT_VERSION_CHECK(21, 1, 0) return Poppler::hasNSSSupport(); #else return false; @@ -2028,7 +2026,7 @@ bool PDFGenerator::canSign() const bool PDFGenerator::sign(const Okular::NewSignatureData &oData, const QString &rFilename) { -#ifdef HAVE_POPPLER_SIGNING +#if POPPLER_VERSION_MACRO >= QT_VERSION_CHECK(21, 1, 0) // save to tmp file - poppler doesn't like overwriting in-place QTemporaryFile tf(QFileInfo(rFilename).absolutePath() + QLatin1String("/okular_XXXXXX.pdf")); tf.setAutoRemove(false); @@ -2062,7 +2060,7 @@ bool PDFGenerator::sign(const Okular::NewSignatureData &oData, const QString &rF Okular::CertificateStore *PDFGenerator::certificateStore() const { -#ifdef HAVE_POPPLER_SIGNING +#if POPPLER_VERSION_MACRO >= QT_VERSION_CHECK(21, 1, 0) if (!certStore) { certStore = new PopplerCertificateStore(); } diff --git a/generators/poppler/generator_pdf.h b/generators/poppler/generator_pdf.h index 580fdd612..b87e820ff 100644 --- a/generators/poppler/generator_pdf.h +++ b/generators/poppler/generator_pdf.h @@ -12,9 +12,11 @@ #define _OKULAR_GENERATOR_PDF_H_ //#include "synctex/synctex_parser.h" -#include #include +#include + +#define POPPLER_VERSION_MACRO ((POPPLER_VERSION_MAJOR << 16) | (POPPLER_VERSION_MINOR << 8) | (POPPLER_VERSION_MICRO)) #include #include @@ -108,7 +110,7 @@ public: QByteArray requestFontData(const Okular::FontInfo &font) override; -#ifdef HAVE_POPPLER_SIGNING +#if POPPLER_VERSION_MACRO >= QT_VERSION_CHECK(21, 1, 0) static void okularToPoppler(const Okular::NewSignatureData &oData, Poppler::PDFConverter::NewSignatureData *pData); #endif diff --git a/generators/poppler/pdfsettingswidget.cpp b/generators/poppler/pdfsettingswidget.cpp index 330f4cb19..c6583503e 100644 --- a/generators/poppler/pdfsettingswidget.cpp +++ b/generators/poppler/pdfsettingswidget.cpp @@ -23,7 +23,7 @@ PDFSettingsWidget::PDFSettingsWidget(QWidget *parent) : QWidget(parent) { m_pdfsw.setupUi(this); -#ifdef HAVE_POPPLER_SIGNING +#if POPPLER_VERSION_MACRO >= QT_VERSION_CHECK(21, 1, 0) if (Poppler::hasNSSSupport()) { m_pdfsw.loadSignaturesButton->hide(); @@ -68,7 +68,7 @@ PDFSettingsWidget::PDFSettingsWidget(QWidget *parent) m_pdfsw.loadSignaturesButton->hide(); #endif -#ifndef HAVE_POPPLER_21_10 +#if POPPLER_VERSION_MACRO >= QT_VERSION_CHECK(21, 10, 0) m_pdfsw.kcfg_CheckOCSPServers->hide(); #endif } @@ -78,7 +78,7 @@ bool PDFSettingsWidget::event(QEvent *e) if (m_tree && e->type() == QEvent::Paint && !m_certificatesAsked) { m_certificatesAsked = true; -#ifdef HAVE_POPPLER_SIGNING +#if POPPLER_VERSION_MACRO >= QT_VERSION_CHECK(21, 1, 0) PopplerCertificateStore st; bool userCancelled; const QList certs = st.signingCertificates(&userCancelled); diff --git a/generators/poppler/pdfsignatureutils.cpp b/generators/poppler/pdfsignatureutils.cpp index c6df32777..f749f824f 100644 --- a/generators/poppler/pdfsignatureutils.cpp +++ b/generators/poppler/pdfsignatureutils.cpp @@ -48,7 +48,7 @@ QString PopplerCertificateInfo::subjectInfo(PopplerCertificateInfo::EntityInfoKe QString PopplerCertificateInfo::nickName() const { -#ifdef HAVE_POPPLER_SIGNING +#if POPPLER_VERSION_MACRO >= QT_VERSION_CHECK(21, 1, 0) return m_info.nickName(); #else return i18n("Not Available"); @@ -134,7 +134,7 @@ QByteArray PopplerCertificateInfo::certificateData() const bool PopplerCertificateInfo::checkPassword(const QString &password) const { -#ifdef HAVE_POPPLER_SIGNING +#if POPPLER_VERSION_MACRO >= QT_VERSION_CHECK(21, 1, 0) return m_info.checkPassword(password); #else Q_UNUSED(password); @@ -264,7 +264,7 @@ const Okular::CertificateInfo &PopplerSignatureInfo::certificateInfo() const return *m_certfiticateInfo; } -#ifdef HAVE_POPPLER_SIGNING +#if POPPLER_VERSION_MACRO >= QT_VERSION_CHECK(21, 1, 0) PopplerCertificateStore::~PopplerCertificateStore() = default; QList PopplerCertificateStore::signingCertificates(bool *userCancelled) const @@ -280,7 +280,7 @@ QList PopplerCertificateStore::signingCertificates(bo const QVector certs = Poppler::getAvailableSigningCertificates(); QList vReturnCerts; - for (auto cert : certs) { + for (const auto &cert : certs) { vReturnCerts.append(new PopplerCertificateInfo(cert)); } diff --git a/generators/poppler/pdfsignatureutils.h b/generators/poppler/pdfsignatureutils.h index 48b68f194..118bc3470 100644 --- a/generators/poppler/pdfsignatureutils.h +++ b/generators/poppler/pdfsignatureutils.h @@ -8,11 +8,11 @@ #define _OKULAR_GENERATOR_PDF_SIGNATUREUTILS_H_ #include +#include +#define POPPLER_VERSION_MACRO ((POPPLER_VERSION_MAJOR << 16) | (POPPLER_VERSION_MINOR << 8) | (POPPLER_VERSION_MICRO)) #include "core/signatureutils.h" -#include - class PopplerCertificateInfo : public Okular::CertificateInfo { public: @@ -63,12 +63,12 @@ private: Okular::CertificateInfo *m_certfiticateInfo; }; -#ifdef HAVE_POPPLER_SIGNING +#if POPPLER_VERSION_MACRO >= QT_VERSION_CHECK(21, 1, 0) class PopplerCertificateStore : public Okular::CertificateStore { public: - ~PopplerCertificateStore(); + ~PopplerCertificateStore() override; QList signingCertificates(bool *userCancelled) const override; };