diff --git a/cmake/modules/FindPoppler.cmake b/cmake/modules/FindPoppler.cmake deleted file mode 100644 index 11af41eef..000000000 --- a/cmake/modules/FindPoppler.cmake +++ /dev/null @@ -1,181 +0,0 @@ -# - Try to find the poppler PDF library -# Once done this will define -# -# POPPLER_FOUND - system has poppler -# POPPLER_INCLUDE_DIR - the poppler include directory -# POPPLER_LIBRARY - Link this to use poppler -# - -# Copyright (c) 2006-2010, Pino Toscano, -# -# Redistribution and use is allowed according to the terms of the BSD license. -# For details see the accompanying COPYING-CMAKE-SCRIPTS file. - -if(POPPLER_INCLUDE_DIR AND POPPLER_LIBRARY) - - # in cache already - set(POPPLER_FOUND TRUE) - -else(POPPLER_INCLUDE_DIR AND POPPLER_LIBRARY) - -set(_poppler_version_bad FALSE) - -if(NOT WIN32) - # use pkg-config to get the directories and then use these values - # in the FIND_PATH() and FIND_LIBRARY() calls - include(FindPkgConfig) - pkg_check_modules(_pc_poppler poppler-qt4) - if(_pc_poppler_FOUND) - if(NOT "${_pc_poppler_VERSION}" VERSION_GREATER 0.5.3) - set(_poppler_version_bad TRUE) - endif(NOT "${_pc_poppler_VERSION}" VERSION_GREATER 0.5.3) - endif(_pc_poppler_FOUND) -endif(NOT WIN32) - -if(NOT _poppler_version_bad) - set(POPPLER_FOUND FALSE) - - find_library(POPPLER_LIBRARY poppler-qt4 - HINTS ${_pc_poppler_LIBRARY_DIRS} - ) - - find_path(POPPLER_INCLUDE_DIR poppler-qt4.h - HINTS ${_pc_poppler_INCLUDE_DIRS} - PATH_SUFFIXES poppler/qt4 - ) - find_path(POPPLER_INCLUDE_DIR_core qt4/poppler-qt4.h - HINTS ${_pc_poppler_INCLUDE_DIRS} - PATH_SUFFIXES poppler - ) - - if(POPPLER_LIBRARY AND POPPLER_INCLUDE_DIR AND POPPLER_INCLUDE_DIR_core) - list(APPEND POPPLER_INCLUDE_DIR "${POPPLER_INCLUDE_DIR_core}") - set(POPPLER_FOUND TRUE) - endif(POPPLER_LIBRARY AND POPPLER_INCLUDE_DIR AND POPPLER_INCLUDE_DIR_core) -endif(NOT _poppler_version_bad) - -if (POPPLER_FOUND) - include(CheckCXXSourceCompiles) - - # check whether we're using poppler 0.6 - set(CMAKE_REQUIRED_INCLUDES ${POPPLER_INCLUDE_DIR} ${QT_INCLUDE_DIR}) - set(CMAKE_REQUIRED_LIBRARIES ${POPPLER_LIBRARY} ${QT_QTCORE_LIBRARY} ${QT_QTGUI_LIBRARY} ${QT_QTXML_LIBRARY}) - -check_cxx_source_compiles(" -#include -int main() -{ - Poppler::Document::RenderHint hint = Poppler::Document::TextHinting; - return 0; -} -" HAVE_POPPLER_0_12_1) - -check_cxx_source_compiles(" -#include - -void debugFunction(const QString &message, const QVariant &closure) -{ -} - -int main() -{ - Poppler::setDebugErrorFunction(debugFunction, QVariant()); - return 0; -} -" HAVE_POPPLER_0_16) - -check_cxx_source_compiles(" -#include -#include - -int main() -{ - Poppler::ScreenAnnotation *annot = 0; - Poppler::LinkRendition *link = 0; - const Poppler::LinkMovie::Operation operation = Poppler::LinkMovie::Play; - return 0; -} -" HAVE_POPPLER_0_20) - -check_cxx_source_compiles(" -#include -#include -#include - -int main() -{ - Poppler::MovieObject *movie = 0; - Poppler::Document *doc = 0; - movie->showPosterImage(); - - const Poppler::Annotation::AdditionalActionType type = Poppler::Annotation::PageOpeningAction; - const Poppler::LinkRendition::RenditionAction action = Poppler::LinkRendition::NoRendition; - const Poppler::Document::FormType formType = doc->formType(); - - return 0; -} -" HAVE_POPPLER_0_22) - -check_cxx_source_compiles(" -#include -int main() -{ - Poppler::Document::RenderHint hint = Poppler::Document::ThinLineSolid; - return 0; -} -" HAVE_POPPLER_0_24) - -check_cxx_source_compiles(" -#include -int main() -{ - Poppler::Page *p = 0; - p->annotations( QSet() << Poppler::Annotation::ASound ); - return 0; -} -" HAVE_POPPLER_0_28) - -check_cxx_source_compiles(" -#include -int main() -{ - Poppler::PageTransition *p = 0; - return p->durationReal(); -} -" HAVE_POPPLER_0_37) - - set(CMAKE_REQUIRED_INCLUDES) - set(CMAKE_REQUIRED_LIBRARIES) - if (HAVE_POPPLER_0_37) - set(popplerVersionMessage "0.37") - elseif (HAVE_POPPLER_0_28) - set(popplerVersionMessage "0.28") - elseif (HAVE_POPPLER_0_24) - set(popplerVersionMessage "0.24") - elseif (HAVE_POPPLER_0_22) - set(popplerVersionMessage "0.22") - elseif (HAVE_POPPLER_0_20) - set(popplerVersionMessage "0.20") - elseif (HAVE_POPPLER_0_16) - set(popplerVersionMessage "0.16") - elseif (HAVE_POPPLER_0_12_1) - set(popplerVersionMessage "0.12.1") - else (HAVE_POPPLER_0_28) - set(popplerVersionMessage "0.5.4") - endif () - if (NOT Poppler_FIND_QUIETLY) - message(STATUS "Found Poppler-Qt4: ${POPPLER_LIBRARY}, (>= ${popplerVersionMessage})") - endif (NOT Poppler_FIND_QUIETLY) -else (POPPLER_FOUND) - if (Poppler_FIND_REQUIRED) - message(FATAL_ERROR "Could NOT find Poppler-Qt4") - endif (Poppler_FIND_REQUIRED) - message(STATUS "Could not find OPTIONAL package Poppler-Qt4") -endif (POPPLER_FOUND) - -# ensure that they are cached -set(POPPLER_INCLUDE_DIR ${POPPLER_INCLUDE_DIR} CACHE INTERNAL "The Poppler-Qt4 include path") -set(POPPLER_LIBRARY ${POPPLER_LIBRARY} CACHE INTERNAL "The Poppler-Qt4 library") -set(HAVE_POPPLER_0_12_1 ${HAVE_POPPLER_0_12_1} CACHE INTERNAL "Whether the version of Poppler-Qt4 is >= 0.12.1") - -endif(POPPLER_INCLUDE_DIR AND POPPLER_LIBRARY) diff --git a/core/action.cpp b/core/action.cpp index a15710e7e..30728e082 100644 --- a/core/action.cpp +++ b/core/action.cpp @@ -558,3 +558,13 @@ ScreenAnnotation* RenditionAction::annotation() const Q_D( const Okular::RenditionAction ); return d->m_annotation; } + +BackendOpaqueAction::BackendOpaqueAction() + : Action( *new ActionPrivate() ) +{ +} + +Action::ActionType BackendOpaqueAction::actionType() const +{ + return BackendOpaque; +} diff --git a/core/action.h b/core/action.h index eb3f2e9ac..3aa9f773b 100644 --- a/core/action.h +++ b/core/action.h @@ -54,7 +54,8 @@ class OKULARCORE_EXPORT Action Sound, ///< Play a sound Movie, ///< Play a movie Script, ///< Executes a Script code - Rendition ///< Play a movie and/or execute a Script code @since 0.16 (KDE 4.10) + Rendition, ///< Play a movie and/or execute a Script code @since 0.16 (KDE 4.10) + BackendOpaque ///< Calls back to the backend with the action @since 1.1 }; /** @@ -562,6 +563,20 @@ class OKULARCORE_EXPORT RenditionAction : public Action Q_DISABLE_COPY( RenditionAction ) }; +class OKULARCORE_EXPORT BackendOpaqueAction : public Action +{ + public: + BackendOpaqueAction(); + + /** + * Returns the action type. + */ + ActionType actionType() const; + + private: + Q_DISABLE_COPY( BackendOpaqueAction ) +}; + } #endif diff --git a/core/document.cpp b/core/document.cpp index ff9253acb..7ec5d52f5 100644 --- a/core/document.cpp +++ b/core/document.cpp @@ -3970,6 +3970,10 @@ void Document::processAction( const Action * action ) emit processRenditionAction( static_cast< const RenditionAction * >( action ) ); } break; + case Action::BackendOpaque: { + d->m_generator->opaqueAction( static_cast< const BackendOpaqueAction * >( action ) ); + } break; + } } diff --git a/core/generator.cpp b/core/generator.cpp index b7edabc7c..cd9d93cac 100644 --- a/core/generator.cpp +++ b/core/generator.cpp @@ -347,6 +347,10 @@ Generator::PrintError Generator::printError() const return UnknownPrintError; } +void Generator::opaqueAction( const BackendOpaqueAction * /*action*/ ) +{ +} + QVariant Generator::metaData( const QString &key, const QVariant &option ) const { Q_D( const Generator ); diff --git a/core/generator.h b/core/generator.h index 79ef99adf..1e27411a1 100644 --- a/core/generator.h +++ b/core/generator.h @@ -41,6 +41,7 @@ class QIcon; namespace Okular { +class BackendOpaqueAction; class DocumentFonts; class DocumentInfo; class DocumentObserver; @@ -440,6 +441,11 @@ class OKULARCORE_EXPORT Generator : public QObject */ virtual QAbstractItemModel * layersModel() const; + /** + * Calls the backend to execute an BackendOpaqueAction + */ + virtual void opaqueAction( const BackendOpaqueAction *action ); + Q_SIGNALS: /** * This signal should be emitted whenever an error occurred in the generator. diff --git a/generators/poppler/CMakeLists.txt b/generators/poppler/CMakeLists.txt index 3e0c935a0..04e765435 100644 --- a/generators/poppler/CMakeLists.txt +++ b/generators/poppler/CMakeLists.txt @@ -16,6 +16,17 @@ if (Poppler_VERSION VERSION_GREATER "0.36.99") set (HAVE_POPPLER_0_37 1) endif() +set(CMAKE_REQUIRED_LIBRARIES Poppler::Qt5 Qt5::Core) + +check_cxx_source_compiles(" +#include +int main() +{ + Poppler::LinkOCGState *l = 0; + return 0; +} +" HAVE_POPPLER_0_50) + configure_file( ${CMAKE_CURRENT_SOURCE_DIR}/config-okular-poppler.h.cmake ${CMAKE_CURRENT_BINARY_DIR}/config-okular-poppler.h diff --git a/generators/poppler/config-okular-poppler.h.cmake b/generators/poppler/config-okular-poppler.h.cmake index ecfb9c7a3..a0f3b6de9 100644 --- a/generators/poppler/config-okular-poppler.h.cmake +++ b/generators/poppler/config-okular-poppler.h.cmake @@ -9,3 +9,6 @@ /* 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 diff --git a/generators/poppler/generator_pdf.cpp b/generators/poppler/generator_pdf.cpp index 8d3fce29c..2e07eb557 100644 --- a/generators/poppler/generator_pdf.cpp +++ b/generators/poppler/generator_pdf.cpp @@ -853,6 +853,17 @@ QAbstractItemModel* PDFGenerator::layersModel() const return pdfdoc->hasOptionalContent() ? pdfdoc->optionalContentModel() : NULL; } +void PDFGenerator::opaqueAction( const Okular::BackendOpaqueAction *action ) +{ +#ifdef HAVE_POPPLER_0_50 +a + const Poppler::LinkOCGState *popplerLink = action->nativeId().value(); + pdfdoc->optionalContentModel()->applyLink( const_cast< Poppler::LinkOCGState* >( popplerLink ) ); +#else + (void)action; +#endif +} + bool PDFGenerator::isAllowed( Okular::Permission permission ) const { bool b = true; diff --git a/generators/poppler/generator_pdf.h b/generators/poppler/generator_pdf.h index f79791644..5a438379e 100644 --- a/generators/poppler/generator_pdf.h +++ b/generators/poppler/generator_pdf.h @@ -68,6 +68,7 @@ class PDFGenerator : public Okular::Generator, public Okular::ConfigInterface, p const QList * embeddedFiles() const Q_DECL_OVERRIDE; PageSizeMetric pagesSizeMetric() const Q_DECL_OVERRIDE{ return Pixels; } QAbstractItemModel * layersModel() const Q_DECL_OVERRIDE; + void opaqueAction( const Okular::BackendOpaqueAction *action ) Q_DECL_OVERRIDE; // [INHERITED] document information bool isAllowed( Okular::Permission permission ) const Q_DECL_OVERRIDE;