Commit be8e5710 authored by Albert Astals Cid's avatar Albert Astals Cid
Browse files

Require poppler >= 0.62

It's the one that comes with our "minimum" requirement Ubuntu 16.04

Cleans up the code a bit
parent ca2df229
Pipeline #12983 passed with stage
in 15 minutes and 43 seconds
......@@ -121,7 +121,7 @@ set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${CMAKE_SOURCE_DIR}/cmake/modules)
find_package(ZLIB REQUIRED)
# This is here instead of in generators since we use if(Poppler_Qt5_FOUND) in autotests/
find_package(Poppler "0.12.1" COMPONENTS Qt5)
find_package(Poppler "0.62.0" COMPONENTS Qt5)
set_package_properties("Poppler" PROPERTIES
TYPE RECOMMENDED
PURPOSE "Support for PDF files in okular.")
......
......@@ -3,83 +3,8 @@ add_definitions(-DTRANSLATION_DOMAIN="okular_poppler")
add_subdirectory( conf )
if (Poppler_VERSION VERSION_GREATER "0.23.99")
set (HAVE_POPPLER_0_24 1)
endif()
if (Poppler_VERSION VERSION_GREATER "0.27.99")
set (HAVE_POPPLER_0_28 1)
endif()
if (Poppler_VERSION VERSION_GREATER "0.35.99")
set (HAVE_POPPLER_0_36 1)
endif()
if (Poppler_VERSION VERSION_GREATER "0.36.99")
set (HAVE_POPPLER_0_37 1)
endif()
set(CMAKE_REQUIRED_LIBRARIES Poppler::Qt5 Qt5::Core Qt5::Gui)
check_cxx_source_compiles("
#include <poppler-qt5.h>
int main()
{
Poppler::LinkOCGState *l = 0;
return 0;
}
" HAVE_POPPLER_0_50)
check_cxx_source_compiles("
#include <poppler-qt5.h>
#include <poppler-form.h>
int main()
{
Poppler::SignatureValidationInfo *l = 0;
return 0;
}
" HAVE_POPPLER_0_51)
check_cxx_source_compiles("
#include <poppler-qt5.h>
#include <poppler-form.h>
int main()
{
Poppler::FormFieldButton *ff = 0;
Poppler::Link *l = ff->additionalAction(Poppler::FormField::CalculateField);
return 0;
}
" HAVE_POPPLER_0_53)
check_cxx_source_compiles("
#include <poppler-qt5.h>
#include <poppler-form.h>
int main()
{
auto s = &Poppler::SignatureValidationInfo::signsTotalDocument;
}
" HAVE_POPPLER_0_58)
check_cxx_source_compiles("
#include <poppler-qt5.h>
int main()
{
Poppler::Document::RenderHint hint = Poppler::Document::HideAnnotations;
return 0;
}
" HAVE_POPPLER_0_60)
check_cxx_source_compiles("
#include <poppler-qt5.h>
#include <QImage>
int main()
{
Poppler::Page *p;
p->renderToImage(0, 0, 0, 0, 0, 0, Poppler::Page::Rotate0, nullptr, nullptr, QVariant());
return 0;
}
" HAVE_POPPLER_0_62)
check_cxx_source_compiles("
#include <poppler-qt5.h>
#include <QImage>
......
......@@ -32,9 +32,7 @@ Q_DECLARE_METATYPE( Poppler::Annotation* )
extern Okular::Sound* createSoundFromPopplerSound( const Poppler::SoundObject *popplerSound );
extern Okular::Movie* createMovieFromPopplerMovie( const Poppler::MovieObject *popplerMovie );
extern Okular::Movie* createMovieFromPopplerScreen( const Poppler::LinkRendition *popplerScreen );
#ifdef HAVE_POPPLER_0_36
extern QPair<Okular::Movie*, Okular::EmbeddedFile*> createMovieFromPopplerRichMedia( const Poppler::RichMediaAnnotation *popplerRichMedia );
#endif
static void disposeAnnotation( const Okular::Annotation *ann )
......@@ -334,7 +332,6 @@ Okular::Annotation* createAnnotationFromPopplerAnnotation( Poppler::Annotation *
*doDelete = false;
break;
}
#ifdef HAVE_POPPLER_0_36
case Poppler::Annotation::ARichMedia:
{
Poppler::RichMediaAnnotation * richmediaann = static_cast< Poppler::RichMediaAnnotation * >( ann );
......@@ -352,7 +349,6 @@ Okular::Annotation* createAnnotationFromPopplerAnnotation( Poppler::Annotation *
break;
}
#endif
case Poppler::Annotation::AText:
case Poppler::Annotation::ALine:
case Poppler::Annotation::AGeom:
......
/* Defined if we have the 0.24 version of the Poppler library */
#cmakedefine HAVE_POPPLER_0_24 1
/* Defined if we have the 0.28 version of the Poppler library */
#cmakedefine HAVE_POPPLER_0_28 1
/* Defined if we have the 0.36 version of the Poppler library */
#cmakedefine HAVE_POPPLER_0_36 1
/* Defined if we have the 0.37 version of the Poppler library */
#cmakedefine HAVE_POPPLER_0_37 1
/* Defined if we have the 0.50 version of the Poppler library */
#cmakedefine HAVE_POPPLER_0_50 1
/* Defined if we have the 0.51 version of the Poppler library */
#cmakedefine HAVE_POPPLER_0_51 1
/* Defined if we have the 0.53 version of the Poppler library */
#cmakedefine HAVE_POPPLER_0_53 1
/* Defined if we have the 0.58 version of the Poppler library */
#cmakedefine HAVE_POPPLER_0_58 1
/* Defined if we have the 0.60 version of the Poppler library */
#cmakedefine HAVE_POPPLER_0_60 1
/* Defined if we have the 0.62 version of the Poppler library */
#cmakedefine HAVE_POPPLER_0_62 1
/* Defined if we have the 0.63 version of the Poppler library */
#cmakedefine HAVE_POPPLER_0_63 1
......
......@@ -32,7 +32,6 @@ extern Okular::Action* createLinkFromPopplerLink(const Poppler::Link *popplerLin
# define SET_ANNOT_ACTIONS
#endif
#ifdef HAVE_POPPLER_0_53
#define SET_ACTIONS \
setActivationAction( createLinkFromPopplerLink( m_field->activationAction() ) ); \
setAdditionalAction( Okular::FormField::FieldModified, createLinkFromPopplerLink( m_field->additionalAction( Poppler::FormField::FieldModified ) ) ); \
......@@ -40,10 +39,6 @@ extern Okular::Action* createLinkFromPopplerLink(const Poppler::Link *popplerLin
setAdditionalAction( Okular::FormField::ValidateField, createLinkFromPopplerLink( m_field->additionalAction( Poppler::FormField::ValidateField ) ) ); \
setAdditionalAction( Okular::FormField::CalculateField, createLinkFromPopplerLink( m_field->additionalAction( Poppler::FormField::CalculateField ) ) ); \
SET_ANNOT_ACTIONS
#else
#define SET_ACTIONS \
setActivationAction( createLinkFromPopplerLink( m_field->activationAction() ) );
#endif
PopplerFormFieldButton::PopplerFormFieldButton( std::unique_ptr<Poppler::FormFieldButton> field )
: Okular::FormFieldButton(), m_field( std::move( field ) )
......@@ -455,25 +450,12 @@ bool PopplerFormFieldChoice::canBeSpellChecked() const
return m_field->canBeSpellChecked();
}
#ifndef HAVE_POPPLER_0_51
class DummySignatureInfo : public Okular::SignatureInfo
{
};
#endif
PopplerFormFieldSignature::PopplerFormFieldSignature( std::unique_ptr<Poppler::FormFieldSignature> field )
: Okular::FormFieldSignature(), m_field( std::move( field ) )
{
m_rect = Okular::NormalizedRect::fromQRectF( m_field->rect() );
m_id = m_field->id();
#ifdef HAVE_POPPLER_0_51
m_info = new PopplerSignatureInfo( m_field->validate( Poppler::FormFieldSignature::ValidateVerifyCertificate ) );
#else
m_info = new DummySignatureInfo();
#endif
SET_ACTIONS
}
......@@ -519,7 +501,6 @@ bool PopplerFormFieldSignature::isVisible() const
PopplerFormFieldSignature::SignatureType PopplerFormFieldSignature::signatureType() const
{
#ifdef HAVE_POPPLER_0_58
switch ( m_field->signatureType() )
{
case Poppler::FormFieldSignature::AdbePkcs7sha1:
......@@ -531,9 +512,6 @@ PopplerFormFieldSignature::SignatureType PopplerFormFieldSignature::signatureTyp
default:
return Okular::FormFieldSignature::UnknownType;
}
#else
return Okular::FormFieldSignature::UnknownType;
#endif
}
const Okular::SignatureInfo &PopplerFormFieldSignature::signatureInfo() const
......
......@@ -71,9 +71,7 @@ Q_DECLARE_METATYPE(Poppler::Annotation*)
Q_DECLARE_METATYPE(Poppler::FontInfo)
Q_DECLARE_METATYPE(const Poppler::LinkMovie*)
Q_DECLARE_METATYPE(const Poppler::LinkRendition*)
#ifdef HAVE_POPPLER_0_50
Q_DECLARE_METATYPE(const Poppler::LinkOCGState*)
#endif
static const int defaultPageWidth = 595;
static const int defaultPageHeight = 842;
......@@ -117,9 +115,6 @@ class PDFOptionsPage : public Okular::PrintOptionsWidget
layout->addStretch(1);
#if defined(Q_OS_WIN) && !defined HAVE_POPPLER_0_60
m_printAnnots->setVisible( false );
#endif
setPrintAnnots( true ); // Default value
}
......@@ -250,7 +245,6 @@ Okular::Movie* createMovieFromPopplerScreen( const Poppler::LinkRendition *poppl
return movie;
}
#ifdef HAVE_POPPLER_0_36
QPair<Okular::Movie*, Okular::EmbeddedFile*> createMovieFromPopplerRichMedia( const Poppler::RichMediaAnnotation *popplerRichMedia )
{
const QPair<Okular::Movie*, Okular::EmbeddedFile*> emptyResult(0, 0);
......@@ -344,7 +338,6 @@ QPair<Okular::Movie*, Okular::EmbeddedFile*> createMovieFromPopplerRichMedia( co
return qMakePair(movie, pdfEmbeddedFile);
}
#endif
/**
* Note: the function will take ownership of the popplerLink object.
......@@ -514,13 +507,11 @@ Okular::Action* createLinkFromPopplerLink(const Poppler::Link *popplerLink, bool
break;
#endif
#ifdef HAVE_POPPLER_0_50
case Poppler::Link::OCGState:
link = new Okular::BackendOpaqueAction();
link->setNativeId( QVariant::fromValue( static_cast<const Poppler::LinkOCGState*>( popplerLink ) ) );
deletePopplerLink = false;
break;
#endif
}
#ifdef HAVE_POPPLER_0_64
......@@ -988,12 +979,8 @@ QAbstractItemModel* PDFGenerator::layersModel() const
void PDFGenerator::opaqueAction( const Okular::BackendOpaqueAction *action )
{
#ifdef HAVE_POPPLER_0_50
const Poppler::LinkOCGState *popplerLink = action->nativeId().value<const Poppler::LinkOCGState *>();
pdfdoc->optionalContentModel()->applyLink( const_cast< Poppler::LinkOCGState* >( popplerLink ) );
#else
(void)action;
#endif
}
bool PDFGenerator::isAllowed( Okular::Permission permission ) const
......@@ -1021,7 +1008,6 @@ bool PDFGenerator::isAllowed( Okular::Permission permission ) const
return b;
}
#ifdef HAVE_POPPLER_0_62
struct RenderImagePayload
{
RenderImagePayload(PDFGenerator *g, Okular::PixmapRequest *r) :
......@@ -1057,7 +1043,6 @@ static void partialUpdateCallback(const QImage &image, const QVariant &vPayload)
auto payload = vPayload.value<RenderImagePayload *>();
QMetaObject::invokeMethod(payload->generator, "signalPartialPixmapRequest", Qt::QueuedConnection, Q_ARG(Okular::PixmapRequest*, payload->request), Q_ARG(QImage, image));
}
#endif
#ifdef HAVE_POPPLER_0_63
static bool shouldAbortRenderCallback(const QVariant &vPayload)
......@@ -1137,7 +1122,7 @@ QImage PDFGenerator::image( Okular::PixmapRequest * request )
}
}
#elif defined(HAVE_POPPLER_0_62)
#else
if ( request->isTile() )
{
const QRect rect = request->normalizedRect().geometry( request->width(), request->height() );
......@@ -1166,16 +1151,6 @@ QImage PDFGenerator::image( Okular::PixmapRequest * request )
}
}
#else
if ( request->isTile() )
{
const QRect rect = request->normalizedRect().geometry( request->width(), request->height() );
img = p->renderToImage( fakeDpiX, fakeDpiY, rect.x(), rect.y(), rect.width(), rect.height(), Poppler::Page::Rotate0 );
}
else
{
img = p->renderToImage( fakeDpiX, fakeDpiY, -1, -1, -1, -1, Poppler::Page::Rotate0 );
}
#endif
}
else
......@@ -1355,20 +1330,11 @@ bool PDFGenerator::print( QPrinter& printer )
// currently the only way Okular implements printing without using UNIX-specific
// tools like 'lpr'.
forceRasterize = true;
#ifndef HAVE_POPPLER_0_60
// The Document::HideAnnotations flags was introduced in poppler 0.60
printAnnots = true;
#endif
#endif
#ifdef HAVE_POPPLER_0_60
if ( forceRasterize )
{
pdfdoc->setRenderHint(Poppler::Document::HideAnnotations, !printAnnots);
#else
if ( forceRasterize && printAnnots)
{
#endif
if ( pdfOptionsPage )
{
......@@ -1571,10 +1537,8 @@ QVariant PDFGenerator::metaData( const QString & key, const QVariant & option )
}
else if ( key == QLatin1String("FormCalculateOrder") )
{
#ifdef HAVE_POPPLER_0_53
QMutexLocker ml(userMutex());
return QVariant::fromValue<QVector<int>>(pdfdoc->formCalculateOrder());
#endif
}
else if ( key == QLatin1String("GeneratorExtraDescription") )
{
......@@ -1629,12 +1593,10 @@ bool PDFGenerator::reparseConfig()
void PDFGenerator::addPages( KConfigDialog *dlg )
{
#ifdef HAVE_POPPLER_0_24
Ui_PDFSettingsWidget pdfsw;
QWidget* w = new QWidget(dlg);
pdfsw.setupUi(w);
dlg->addPage(w, PDFSettings::self(), i18n("PDF"), QStringLiteral("application-pdf"), i18n("PDF Backend Configuration") );
#endif
}
bool PDFGenerator::setDocumentRenderHints()
......@@ -1654,7 +1616,6 @@ bool PDFGenerator::setDocumentRenderHints()
SET_HINT(TextAntialiasMetaData, true, Poppler::Document::TextAntialiasing)
SET_HINT(TextHintingMetaData, false, Poppler::Document::TextHinting)
#undef SET_HINT
#ifdef HAVE_POPPLER_0_24
// load thin line mode
const int thinLineMode = PDFSettings::enhanceThinLines();
const bool enableThinLineSolid = thinLineMode == PDFSettings::EnumEnhanceThinLines::Solid;
......@@ -1669,7 +1630,6 @@ bool PDFGenerator::setDocumentRenderHints()
pdfdoc->setRenderHint(Poppler::Document::ThinLineShape, enableShapeLineSolid);
changed = true;
}
#endif
return changed;
}
......@@ -1818,7 +1778,6 @@ void PDFGenerator::addSynopsisChildren( QDomNode * parent, QDomNode * parentDest
void PDFGenerator::addAnnotations( Poppler::Page * popplerPage, Okular::Page * page )
{
#ifdef HAVE_POPPLER_0_28
QSet<Poppler::Annotation::SubType> subtypes;
subtypes << Poppler::Annotation::AFileAttachment
<< Poppler::Annotation::ASound
......@@ -1834,9 +1793,6 @@ void PDFGenerator::addAnnotations( Poppler::Page * popplerPage, Okular::Page * p
<< Poppler::Annotation::ACaret;
const QList<Poppler::Annotation*> popplerAnnotations = popplerPage->annotations( subtypes );
#else
const QList<Poppler::Annotation*> popplerAnnotations = popplerPage->annotations();
#endif
for (Poppler::Annotation *a : popplerAnnotations)
{
......@@ -1936,11 +1892,7 @@ void PDFGenerator::addTransition( Poppler::Page * pdfPage, Okular::Page * page )
break;
}
#ifdef HAVE_POPPLER_0_37
transition->setDuration( pdfTransition->durationReal() );
#else
transition->setDuration( pdfTransition->duration() );
#endif
switch ( pdfTransition->alignment() ) {
case Poppler::PageTransition::Horizontal:
......
......@@ -128,8 +128,6 @@ class DummyCertificateInfo : public Okular::CertificateInfo
#endif
#ifdef HAVE_POPPLER_0_51
PopplerSignatureInfo::PopplerSignatureInfo( const Poppler::SignatureValidationInfo &info )
: m_info( info )
{
......@@ -193,7 +191,6 @@ PopplerSignatureInfo::CertificateStatus PopplerSignatureInfo::certificateStatus(
PopplerSignatureInfo::HashAlgorithm PopplerSignatureInfo::hashAlgorithm() const
{
#ifdef HAVE_POPPLER_0_58
switch ( m_info.hashAlgorithm() )
{
case Poppler::SignatureValidationInfo::HashAlgorithmMd2:
......@@ -213,9 +210,6 @@ PopplerSignatureInfo::HashAlgorithm PopplerSignatureInfo::hashAlgorithm() const
default:
return HashAlgorithmUnknown;
}
#else
return HashAlgorithmUnknown;
#endif
}
QString PopplerSignatureInfo::signerName() const
......@@ -225,11 +219,7 @@ QString PopplerSignatureInfo::signerName() const
QString PopplerSignatureInfo::signerSubjectDN() const
{
#ifdef HAVE_POPPLER_0_58
return m_info.signerSubjectDN();
#else
return {};
#endif
}
QString PopplerSignatureInfo::location() const
......@@ -257,34 +247,20 @@ QDateTime PopplerSignatureInfo::signingTime() const
QByteArray PopplerSignatureInfo::signature() const
{
#ifdef HAVE_POPPLER_0_58
return m_info.signature();
#else
return {};
#endif
}
QList<qint64> PopplerSignatureInfo::signedRangeBounds() const
{
#ifdef HAVE_POPPLER_0_58
return m_info.signedRangeBounds();
#else
return {};
#endif
}
bool PopplerSignatureInfo::signsTotalDocument() const
{
#ifdef HAVE_POPPLER_0_58
return m_info.signsTotalDocument();
#else
return false;
#endif
}
const Okular::CertificateInfo &PopplerSignatureInfo::certificateInfo() const
{
return *m_certfiticateInfo;
}
#endif
......@@ -44,8 +44,6 @@ class PopplerCertificateInfo : public Okular::CertificateInfo
#endif
#ifdef HAVE_POPPLER_0_51
class PopplerSignatureInfo : public Okular::SignatureInfo
{
public:
......@@ -71,5 +69,3 @@ class PopplerSignatureInfo : public Okular::SignatureInfo
};
#endif
#endif
Markdown is supported
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