Use the poppler version includes instead of check_cxx_source_compiles

remotes/origin/work/numberformattest
Albert Astals Cid 4 years ago
parent 913d437822
commit 44304b32a5
  1. 2
      autotests/formattest.cpp
  2. 2
      autotests/keystroketest.cpp
  3. 2
      autotests/kjsfunctionstest.cpp
  4. 2
      autotests/parttest.cpp
  5. 2
      autotests/visibilitytest.cpp
  6. 75
      generators/poppler/CMakeLists.txt
  7. 20
      generators/poppler/annots.cpp
  8. 5
      generators/poppler/annots.h
  9. 20
      generators/poppler/config-okular-poppler.h.cmake
  10. 8
      generators/poppler/formfields.cpp
  11. 1
      generators/poppler/formfields.h
  12. 24
      generators/poppler/generator_pdf.cpp
  13. 6
      generators/poppler/generator_pdf.h
  14. 6
      generators/poppler/pdfsettingswidget.cpp
  15. 8
      generators/poppler/pdfsignatureutils.cpp
  16. 8
      generators/poppler/pdfsignatureutils.h

@ -15,8 +15,6 @@
#include <core/form.h> #include <core/form.h>
#include <core/page.h> #include <core/page.h>
#include "../generators/poppler/config-okular-poppler.h"
class FormatTest : public QObject class FormatTest : public QObject
{ {
Q_OBJECT Q_OBJECT

@ -16,8 +16,6 @@
#include <core/page.h> #include <core/page.h>
#include <qtestcase.h> #include <qtestcase.h>
#include "../generators/poppler/config-okular-poppler.h"
class KeystrokeTest : public QObject class KeystrokeTest : public QObject
{ {
Q_OBJECT Q_OBJECT

@ -21,8 +21,6 @@
#include <core/page.h> #include <core/page.h>
#include <core/script/event_p.h> #include <core/script/event_p.h>
#include "../generators/poppler/config-okular-poppler.h"
class MessageBoxHelper : public QObject class MessageBoxHelper : public QObject
{ {
Q_OBJECT Q_OBJECT

@ -24,8 +24,6 @@
#include "../settings.h" #include "../settings.h"
#include "closedialoghelper.h" #include "closedialoghelper.h"
#include "../generators/poppler/config-okular-poppler.h"
#include <KActionCollection> #include <KActionCollection>
#include <KConfigDialog> #include <KConfigDialog>
#include <KParts/OpenUrlArguments> #include <KParts/OpenUrlArguments>

@ -14,8 +14,6 @@
#include <core/form.h> #include <core/form.h>
#include <core/page.h> #include <core/page.h>
#include "../generators/poppler/config-okular-poppler.h"
class VisibilityTest : public QObject class VisibilityTest : public QObject
{ {
Q_OBJECT Q_OBJECT

@ -5,81 +5,6 @@ add_subdirectory( conf )
set(CMAKE_REQUIRED_LIBRARIES Poppler::Qt5 Qt5::Core Qt5::Gui) set(CMAKE_REQUIRED_LIBRARIES Poppler::Qt5 Qt5::Core Qt5::Gui)
check_cxx_source_compiles("
#include <poppler-form.h>
int main()
{
Poppler::FormFieldChoice *ffc = nullptr;
ffc->choicesWithExportValues();
return 0;
}
" HAVE_POPPLER_0_87)
check_cxx_source_compiles("
#include <poppler-qt5.h>
#include <poppler-form.h>
int main()
{
auto f = &Poppler::PDFConverter::sign;
auto g = &Poppler::setNSSDir;
}
" HAVE_POPPLER_SIGNING)
check_cxx_source_compiles("
#include <poppler-qt5.h>
#include <poppler-form.h>
int main()
{
Poppler::PDFConverter::NewSignatureData pData;
pData.setSignatureLeftText(QString());
}
" HAVE_POPPLER_FANCY_SIGNATURE)
check_cxx_source_compiles("
#include <poppler-qt5.h>
int main()
{
Poppler::Document *doc = Poppler::Document::load(\"\", nullptr, nullptr);
doc->xrefWasReconstructed();
return 0;
}
" HAVE_POPPLER_RECONSTRUCTION_CALLBACK)
check_cxx_source_compiles("
#include <poppler-qt5.h>
#include <poppler-form.h>
int main()
{
int a = Poppler::FormFieldSignature::ValidateWithoutOCSPRevocationCheck;
return 0;
}
" HAVE_POPPLER_21_10)
check_cxx_source_compiles("
#include <poppler-qt5.h>
#include <poppler-form.h>
int main()
{
auto us = Poppler::FormFieldSignature::UnsignedSignature;
Poppler::PDFConverter::NewSignatureData pData;
pData.setDocumentOwnerPassword(QByteArray());
}
" HAVE_POPPLER_22_02)
check_cxx_source_compiles("
#include <poppler-qt5.h>
#include <poppler-form.h>
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( include_directories(
${CMAKE_CURRENT_SOURCE_DIR}/../.. ${CMAKE_CURRENT_SOURCE_DIR}/../..
) )

@ -280,7 +280,7 @@ static void setSharedAnnotationPropertiesToPopplerAnnotation(const Okular::Annot
popplerAnnotation->setModificationDate(okularAnnotation->modificationDate()); 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) static void setPopplerStampAnnotationCustomImage(const Poppler::Page *page, Poppler::StampAnnotation *pStampAnnotation, const Okular::StampAnnotation *oStampAnnotation)
{ {
const QSize size = page->pageSize(); const QSize size = page->pageSize();
@ -348,7 +348,7 @@ static void updatePopplerAnnotationFromOkularAnnotation(const Okular::HighlightA
pHighlightAnnotation->setHighlightQuads(pQuads); 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) static void updatePopplerAnnotationFromOkularAnnotation(const Okular::StampAnnotation *oStampAnnotation, Poppler::StampAnnotation *pStampAnnotation, const Poppler::Page *page)
{ {
setPopplerStampAnnotationCustomImage(page, pStampAnnotation, oStampAnnotation); setPopplerStampAnnotationCustomImage(page, pStampAnnotation, oStampAnnotation);
@ -420,7 +420,7 @@ static Poppler::Annotation *createPopplerAnnotationFromOkularAnnotation(const Ok
return pHighlightAnnotation; 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) static Poppler::Annotation *createPopplerAnnotationFromOkularAnnotation(const Okular::StampAnnotation *oStampAnnotation, Poppler::Page *page)
{ {
Poppler::StampAnnotation *pStampAnnotation = new Poppler::StampAnnotation(); Poppler::StampAnnotation *pStampAnnotation = new Poppler::StampAnnotation();
@ -483,7 +483,7 @@ void PopplerAnnotationProxy::notifyAddition(Okular::Annotation *okl_ann, int pag
ppl_ann = createPopplerAnnotationFromOkularAnnotation(static_cast<Okular::HighlightAnnotation *>(okl_ann)); ppl_ann = createPopplerAnnotationFromOkularAnnotation(static_cast<Okular::HighlightAnnotation *>(okl_ann));
break; break;
case Okular::Annotation::AStamp: 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; bool wasDenyWriteEnabled = okl_ann->flags() & Okular::Annotation::DenyWrite;
@ -516,7 +516,7 @@ void PopplerAnnotationProxy::notifyAddition(Okular::Annotation *okl_ann, int pag
return; 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); okl_ann->setFlags(okl_ann->flags() | Okular::Annotation::ExternallyDrawn);
#else #else
// Poppler doesn't render StampAnnotations yet // Poppler doesn't render StampAnnotations yet
@ -595,7 +595,7 @@ void PopplerAnnotationProxy::notifyModification(const Okular::Annotation *okl_an
case Poppler::Annotation::AStamp: { case Poppler::Annotation::AStamp: {
const Okular::StampAnnotation *okl_stampann = static_cast<const Okular::StampAnnotation *>(okl_ann); const Okular::StampAnnotation *okl_stampann = static_cast<const Okular::StampAnnotation *>(okl_ann);
Poppler::StampAnnotation *ppl_stampann = static_cast<Poppler::StampAnnotation *>(ppl_ann); Poppler::StampAnnotation *ppl_stampann = static_cast<Poppler::StampAnnotation *>(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); Poppler::Page *ppl_page = ppl_doc->page(page);
updatePopplerAnnotationFromOkularAnnotation(okl_stampann, ppl_stampann, ppl_page); updatePopplerAnnotationFromOkularAnnotation(okl_stampann, ppl_stampann, ppl_page);
delete 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); Poppler::Page *ppl_page = ppl_doc->page(page);
annotationsOnOpenHash->remove(okl_ann); 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) { if (okl_ann->subType() == Okular::Annotation::AStamp) {
deletedStampsAnnotationAppearance[static_cast<Okular::StampAnnotation *>(okl_ann)] = std::move(ppl_ann->annotationAppearance()); deletedStampsAnnotationAppearance[static_cast<Okular::StampAnnotation *>(okl_ann)] = ppl_ann->annotationAppearance();
} }
#endif #endif
ppl_page->removeAnnotation(ppl_ann); // Also destroys ppl_ann ppl_page->removeAnnotation(ppl_ann); // Also destroys ppl_ann
@ -1070,7 +1070,7 @@ Okular::Annotation *createAnnotationFromPopplerAnnotation(Poppler::Annotation *p
break; break;
} }
case Poppler::Annotation::AStamp: case Poppler::Annotation::AStamp:
#ifdef HAVE_POPPLER_21_10 #if POPPLER_VERSION_MACRO >= QT_VERSION_CHECK(21, 10, 0)
externallyDrawn = true; externallyDrawn = true;
#endif #endif
tieToOkularAnn = true; tieToOkularAnn = true;
@ -1097,7 +1097,7 @@ Okular::Annotation *createAnnotationFromPopplerAnnotation(Poppler::Annotation *p
if (externallyDrawn) { if (externallyDrawn) {
okularAnnotation->setFlags(okularAnnotation->flags() | Okular::Annotation::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) { if (okularAnnotation->subType() == Okular::Annotation::SubType::AStamp) {
Okular::StampAnnotation *oStampAnn = static_cast<Okular::StampAnnotation *>(okularAnnotation); Okular::StampAnnotation *oStampAnn = static_cast<Okular::StampAnnotation *>(okularAnnotation);
Poppler::StampAnnotation *pStampAnn = static_cast<Poppler::StampAnnotation *>(popplerAnnotation); Poppler::StampAnnotation *pStampAnn = static_cast<Poppler::StampAnnotation *>(popplerAnnotation);

@ -12,12 +12,13 @@
#include <poppler-annotation.h> #include <poppler-annotation.h>
#include <poppler-qt5.h> #include <poppler-qt5.h>
#include <poppler-version.h>
#define POPPLER_VERSION_MACRO ((POPPLER_VERSION_MAJOR << 16) | (POPPLER_VERSION_MINOR << 8) | (POPPLER_VERSION_MICRO))
#include <QMutex> #include <QMutex>
#include <unordered_map> #include <unordered_map>
#include "config-okular-poppler.h"
#include "core/annotations.h" #include "core/annotations.h"
extern Okular::Annotation *createAnnotationFromPopplerAnnotation(Poppler::Annotation *popplerAnnotation, const Poppler::Page &popplerPage, bool *doDelete); extern Okular::Annotation *createAnnotationFromPopplerAnnotation(Poppler::Annotation *popplerAnnotation, const Poppler::Page &popplerPage, bool *doDelete);
@ -37,7 +38,7 @@ private:
Poppler::Document *ppl_doc; Poppler::Document *ppl_doc;
QMutex *mutex; QMutex *mutex;
QHash<Okular::Annotation *, Poppler::Annotation *> *annotationsOnOpenHash; QHash<Okular::Annotation *, Poppler::Annotation *> *annotationsOnOpenHash;
#ifdef HAVE_POPPLER_21_10 #if POPPLER_VERSION_MACRO >= QT_VERSION_CHECK(21, 10, 0)
std::unordered_map<Okular::StampAnnotation *, std::unique_ptr<Poppler::AnnotationAppearance>> deletedStampsAnnotationAppearance; std::unordered_map<Okular::StampAnnotation *, std::unique_ptr<Poppler::AnnotationAppearance>> deletedStampsAnnotationAppearance;
#endif #endif
}; };

@ -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

@ -268,7 +268,7 @@ PopplerFormFieldChoice::PopplerFormFieldChoice(std::unique_ptr<Poppler::FormFiel
m_id = m_field->id(); m_id = m_field->id();
SET_ACTIONS SET_ACTIONS
#ifdef HAVE_POPPLER_0_87 #if POPPLER_VERSION_MACRO >= QT_VERSION_CHECK(0, 87, 0)
QMap<QString, QString> values; QMap<QString, QString> values;
const auto fieldChoicesWithExportValues = m_field->choicesWithExportValues(); const auto fieldChoicesWithExportValues = m_field->choicesWithExportValues();
for (const QPair<QString, QString> &value : fieldChoicesWithExportValues) { for (const QPair<QString, QString> &value : fieldChoicesWithExportValues) {
@ -396,7 +396,7 @@ PopplerFormFieldSignature::PopplerFormFieldSignature(std::unique_ptr<Poppler::Fo
m_rect = Okular::NormalizedRect::fromQRectF(m_field->rect()); m_rect = Okular::NormalizedRect::fromQRectF(m_field->rect());
m_id = m_field->id(); m_id = m_field->id();
int validateOptions = Poppler::FormFieldSignature::ValidateVerifyCertificate; int validateOptions = Poppler::FormFieldSignature::ValidateVerifyCertificate;
#ifdef HAVE_POPPLER_21_10 #if POPPLER_VERSION_MACRO >= QT_VERSION_CHECK(21, 10, 0)
if (!PDFSettings::checkOCSPServers()) { if (!PDFSettings::checkOCSPServers()) {
validateOptions = validateOptions | Poppler::FormFieldSignature::ValidateWithoutOCSPRevocationCheck; validateOptions = validateOptions | Poppler::FormFieldSignature::ValidateWithoutOCSPRevocationCheck;
} }
@ -454,7 +454,7 @@ PopplerFormFieldSignature::SignatureType PopplerFormFieldSignature::signatureTyp
return Okular::FormFieldSignature::AdbePkcs7detached; return Okular::FormFieldSignature::AdbePkcs7detached;
case Poppler::FormFieldSignature::EtsiCAdESdetached: case Poppler::FormFieldSignature::EtsiCAdESdetached:
return Okular::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: case Poppler::FormFieldSignature::UnsignedSignature:
return Okular::FormFieldSignature::UnsignedSignature; return Okular::FormFieldSignature::UnsignedSignature;
#endif #endif
@ -470,7 +470,7 @@ const Okular::SignatureInfo &PopplerFormFieldSignature::signatureInfo() const
bool PopplerFormFieldSignature::sign(const Okular::NewSignatureData &oData, const QString &newPath) 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; Poppler::PDFConverter::NewSignatureData pData;
PDFGenerator::okularToPoppler(oData, &pData); PDFGenerator::okularToPoppler(oData, &pData);
return m_field->sign(newPath, pData) == Poppler::FormFieldSignature::SigningSuccess; return m_field->sign(newPath, pData) == Poppler::FormFieldSignature::SigningSuccess;

@ -9,7 +9,6 @@
#define _OKULAR_GENERATOR_PDF_FORMFIELDS_H_ #define _OKULAR_GENERATOR_PDF_FORMFIELDS_H_
#include "core/form.h" #include "core/form.h"
#include <config-okular-poppler.h>
#include <poppler-form.h> #include <poppler-form.h>
class PopplerFormFieldButton : public Okular::FormFieldButton class PopplerFormFieldButton : public Okular::FormFieldButton

@ -51,8 +51,6 @@
#include "pdfsettings.h" #include "pdfsettings.h"
#include <config-okular-poppler.h>
#include <poppler-media.h> #include <poppler-media.h>
#include <poppler-version.h> #include <poppler-version.h>
@ -380,7 +378,7 @@ static Okular::DocumentAction::DocumentActionType popplerToOkular(Poppler::LinkA
return Okular::DocumentAction::Close; return Okular::DocumentAction::Close;
case Poppler::LinkAction::Print: case Poppler::LinkAction::Print:
return Okular::DocumentAction::Print; return Okular::DocumentAction::Print;
#ifdef HAVE_POPPLER_22_04 #if POPPLER_VERSION_MACRO >= QT_VERSION_CHECK(22, 04, 0)
case Poppler::LinkAction::SaveAs: case Poppler::LinkAction::SaveAs:
return Okular::DocumentAction::SaveAs; return Okular::DocumentAction::SaveAs;
#endif #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 // 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 // so doing it all the time won't hurt either
Poppler::setDebugErrorFunction(PDFGeneratorPopplerDebugFunction, QVariant()); Poppler::setDebugErrorFunction(PDFGeneratorPopplerDebugFunction, QVariant());
#ifdef HAVE_POPPLER_SIGNING #if POPPLER_VERSION_MACRO >= QT_VERSION_CHECK(21, 1, 0)
if (!PDFSettings::useDefaultCertDB()) { if (!PDFSettings::useDefaultCertDB()) {
Poppler::setNSSDir(QUrl(PDFSettings::dBCertificatePath()).toLocalFile()); Poppler::setNSSDir(QUrl(PDFSettings::dBCertificatePath()).toLocalFile());
} }
@ -694,7 +692,7 @@ Okular::Document::OpenResult PDFGenerator::init(QVector<Okular::Page *> &pagesVe
} }
xrefReconstructed = false; xrefReconstructed = false;
#ifdef HAVE_POPPLER_RECONSTRUCTION_CALLBACK #if POPPLER_VERSION_MACRO >= QT_VERSION_CHECK(21, 6, 0)
if (pdfdoc->xrefWasReconstructed()) { if (pdfdoc->xrefWasReconstructed()) {
xrefReconstructionHandler(); xrefReconstructionHandler();
} else { } else {
@ -1357,7 +1355,7 @@ QByteArray PDFGenerator::requestFontData(const Okular::FontInfo &font)
return pdfdoc->fontData(fi); 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) void PDFGenerator::okularToPoppler(const Okular::NewSignatureData &oData, Poppler::PDFConverter::NewSignatureData *pData)
{ {
pData->setCertNickname(oData.certNickname()); pData->setCertNickname(oData.certNickname());
@ -1365,14 +1363,14 @@ void PDFGenerator::okularToPoppler(const Okular::NewSignatureData &oData, Popple
pData->setPage(oData.page()); pData->setPage(oData.page());
const QString datetime = QDateTime::currentDateTime().toString(QStringLiteral("yyyy-MM-dd hh:mm:ss t")); 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)); 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()); pData->setSignatureLeftText(oData.certSubjectCommonName());
#endif #endif
const Okular::NormalizedRect bRect = oData.boundingRectangle(); const Okular::NormalizedRect bRect = oData.boundingRectangle();
pData->setBoundingRectangle({bRect.left, bRect.top, bRect.width(), bRect.height()}); pData->setBoundingRectangle({bRect.left, bRect.top, bRect.width(), bRect.height()});
pData->setFontColor(Qt::black); pData->setFontColor(Qt::black);
pData->setBorderColor(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->setDocumentOwnerPassword(oData.documentPassword().toLatin1());
pData->setDocumentUserPassword(oData.documentPassword().toLatin1()); pData->setDocumentUserPassword(oData.documentPassword().toLatin1());
#endif #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)); return i18n("Using Poppler %1\n\nBuilt against Poppler %2", Poppler::Version::string(), QStringLiteral(POPPLER_VERSION));
} }
} else if (key == QLatin1String("ShowStampsWarning")) { } else if (key == QLatin1String("ShowStampsWarning")) {
#ifdef HAVE_POPPLER_21_10 #if POPPLER_VERSION_MACRO >= QT_VERSION_CHECK(21, 10, 0)
return QStringLiteral("no"); return QStringLiteral("no");
#else #else
return QStringLiteral("yes"); return QStringLiteral("yes");
@ -1583,7 +1581,7 @@ QVariant PDFGenerator::metaData(const QString &key, const QVariant &option) cons
} else if (key == QLatin1String("DocumentHasPassword")) { } else if (key == QLatin1String("DocumentHasPassword")) {
return pdfdoc->isEncrypted() ? QStringLiteral("yes") : QStringLiteral("no"); return pdfdoc->isEncrypted() ? QStringLiteral("yes") : QStringLiteral("no");
} else if (key == QLatin1String("CanSignDocumentWithPassword")) { } else if (key == QLatin1String("CanSignDocumentWithPassword")) {
#ifdef HAVE_POPPLER_22_02 #if POPPLER_VERSION_MACRO >= QT_VERSION_CHECK(22, 2, 0)
return QStringLiteral("yes"); return QStringLiteral("yes");
#else #else
return QStringLiteral("no"); return QStringLiteral("no");
@ -2019,7 +2017,7 @@ Okular::AnnotationProxy *PDFGenerator::annotationProxy() const
bool PDFGenerator::canSign() const bool PDFGenerator::canSign() const
{ {
#ifdef HAVE_POPPLER_SIGNING #if POPPLER_VERSION_MACRO >= QT_VERSION_CHECK(21, 1, 0)
return Poppler::hasNSSSupport(); return Poppler::hasNSSSupport();
#else #else
return false; return false;
@ -2028,7 +2026,7 @@ bool PDFGenerator::canSign() const
bool PDFGenerator::sign(const Okular::NewSignatureData &oData, const QString &rFilename) 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 // save to tmp file - poppler doesn't like overwriting in-place
QTemporaryFile tf(QFileInfo(rFilename).absolutePath() + QLatin1String("/okular_XXXXXX.pdf")); QTemporaryFile tf(QFileInfo(rFilename).absolutePath() + QLatin1String("/okular_XXXXXX.pdf"));
tf.setAutoRemove(false); tf.setAutoRemove(false);
@ -2062,7 +2060,7 @@ bool PDFGenerator::sign(const Okular::NewSignatureData &oData, const QString &rF
Okular::CertificateStore *PDFGenerator::certificateStore() const Okular::CertificateStore *PDFGenerator::certificateStore() const
{ {
#ifdef HAVE_POPPLER_SIGNING #if POPPLER_VERSION_MACRO >= QT_VERSION_CHECK(21, 1, 0)
if (!certStore) { if (!certStore) {
certStore = new PopplerCertificateStore(); certStore = new PopplerCertificateStore();
} }

@ -12,9 +12,11 @@
#define _OKULAR_GENERATOR_PDF_H_ #define _OKULAR_GENERATOR_PDF_H_
//#include "synctex/synctex_parser.h" //#include "synctex/synctex_parser.h"
#include <config-okular-poppler.h>
#include <poppler-qt5.h> #include <poppler-qt5.h>
#include <poppler-version.h>
#define POPPLER_VERSION_MACRO ((POPPLER_VERSION_MAJOR << 16) | (POPPLER_VERSION_MINOR << 8) | (POPPLER_VERSION_MICRO))
#include <QBitArray> #include <QBitArray>
#include <QPointer> #include <QPointer>
@ -108,7 +110,7 @@ public:
QByteArray requestFontData(const Okular::FontInfo &font) override; 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); static void okularToPoppler(const Okular::NewSignatureData &oData, Poppler::PDFConverter::NewSignatureData *pData);
#endif #endif

@ -23,7 +23,7 @@ PDFSettingsWidget::PDFSettingsWidget(QWidget *parent)
: QWidget(parent) : QWidget(parent)
{ {
m_pdfsw.setupUi(this); m_pdfsw.setupUi(this);
#ifdef HAVE_POPPLER_SIGNING #if POPPLER_VERSION_MACRO >= QT_VERSION_CHECK(21, 1, 0)
if (Poppler::hasNSSSupport()) { if (Poppler::hasNSSSupport()) {
m_pdfsw.loadSignaturesButton->hide(); m_pdfsw.loadSignaturesButton->hide();
@ -68,7 +68,7 @@ PDFSettingsWidget::PDFSettingsWidget(QWidget *parent)
m_pdfsw.loadSignaturesButton->hide(); m_pdfsw.loadSignaturesButton->hide();
#endif #endif
#ifndef HAVE_POPPLER_21_10 #if POPPLER_VERSION_MACRO >= QT_VERSION_CHECK(21, 10, 0)
m_pdfsw.kcfg_CheckOCSPServers->hide(); m_pdfsw.kcfg_CheckOCSPServers->hide();
#endif #endif
} }
@ -78,7 +78,7 @@ bool PDFSettingsWidget::event(QEvent *e)
if (m_tree && e->type() == QEvent::Paint && !m_certificatesAsked) { if (m_tree && e->type() == QEvent::Paint && !m_certificatesAsked) {
m_certificatesAsked = true; m_certificatesAsked = true;
#ifdef HAVE_POPPLER_SIGNING #if POPPLER_VERSION_MACRO >= QT_VERSION_CHECK(21, 1, 0)
PopplerCertificateStore st; PopplerCertificateStore st;
bool userCancelled; bool userCancelled;
const QList<Okular::CertificateInfo *> certs = st.signingCertificates(&userCancelled); const QList<Okular::CertificateInfo *> certs = st.signingCertificates(&userCancelled);

@ -48,7 +48,7 @@ QString PopplerCertificateInfo::subjectInfo(PopplerCertificateInfo::EntityInfoKe
QString PopplerCertificateInfo::nickName() const QString PopplerCertificateInfo::nickName() const
{ {
#ifdef HAVE_POPPLER_SIGNING #if POPPLER_VERSION_MACRO >= QT_VERSION_CHECK(21, 1, 0)
return m_info.nickName(); return m_info.nickName();
#else #else
return i18n("Not Available"); return i18n("Not Available");
@ -134,7 +134,7 @@ QByteArray PopplerCertificateInfo::certificateData() const
bool PopplerCertificateInfo::checkPassword(const QString &password) 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); return m_info.checkPassword(password);
#else #else
Q_UNUSED(password); Q_UNUSED(password);
@ -264,7 +264,7 @@ const Okular::CertificateInfo &PopplerSignatureInfo::certificateInfo() const
return *m_certfiticateInfo; return *m_certfiticateInfo;
} }
#ifdef HAVE_POPPLER_SIGNING #if POPPLER_VERSION_MACRO >= QT_VERSION_CHECK(21, 1, 0)
PopplerCertificateStore::~PopplerCertificateStore() = default; PopplerCertificateStore::~PopplerCertificateStore() = default;
QList<Okular::CertificateInfo *> PopplerCertificateStore::signingCertificates(bool *userCancelled) const QList<Okular::CertificateInfo *> PopplerCertificateStore::signingCertificates(bool *userCancelled) const
@ -280,7 +280,7 @@ QList<Okular::CertificateInfo *> PopplerCertificateStore::signingCertificates(bo
const QVector<Poppler::CertificateInfo> certs = Poppler::getAvailableSigningCertificates(); const QVector<Poppler::CertificateInfo> certs = Poppler::getAvailableSigningCertificates();
QList<Okular::CertificateInfo *> vReturnCerts; QList<Okular::CertificateInfo *> vReturnCerts;
for (auto cert : certs) { for (const auto &cert : certs) {
vReturnCerts.append(new PopplerCertificateInfo(cert)); vReturnCerts.append(new PopplerCertificateInfo(cert));
} }

@ -8,11 +8,11 @@
#define _OKULAR_GENERATOR_PDF_SIGNATUREUTILS_H_ #define _OKULAR_GENERATOR_PDF_SIGNATUREUTILS_H_
#include <poppler-form.h> #include <poppler-form.h>
#include <poppler-version.h>
#define POPPLER_VERSION_MACRO ((POPPLER_VERSION_MAJOR << 16) | (POPPLER_VERSION_MINOR << 8) | (POPPLER_VERSION_MICRO))
#include "core/signatureutils.h" #include "core/signatureutils.h"
#include <config-okular-poppler.h>
class PopplerCertificateInfo : public Okular::CertificateInfo class PopplerCertificateInfo : public Okular::CertificateInfo
{ {
public: public:
@ -63,12 +63,12 @@ private:
Okular::CertificateInfo *m_certfiticateInfo; Okular::CertificateInfo *m_certfiticateInfo;
}; };
#ifdef HAVE_POPPLER_SIGNING #if POPPLER_VERSION_MACRO >= QT_VERSION_CHECK(21, 1, 0)
class PopplerCertificateStore : public Okular::CertificateStore class PopplerCertificateStore : public Okular::CertificateStore
{ {
public: public:
~PopplerCertificateStore(); ~PopplerCertificateStore() override;
QList<Okular::CertificateInfo *> signingCertificates(bool *userCancelled) const override; QList<Okular::CertificateInfo *> signingCertificates(bool *userCancelled) const override;
}; };

Loading…
Cancel
Save