From 9dd187337acce50e168b06571dfa315c41a1b628 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sl=C3=A1vek=20Banko?= Date: Tue, 26 Dec 2017 17:03:04 +0100 Subject: Add support for Poppler >= 0.60 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Slávek Banko --- config.h.cmake | 1 + .../dependencies/poppler-tqt/ConfigureChecks.cmake | 10 ++++++ .../dependencies/poppler-tqt/poppler-document.cc | 36 ++++++++++++++++++++-- .../dependencies/poppler-tqt/poppler-page.cc | 13 ++++++-- 4 files changed, 54 insertions(+), 6 deletions(-) diff --git a/config.h.cmake b/config.h.cmake index 3e51ef68..a45ebc35 100644 --- a/config.h.cmake +++ b/config.h.cmake @@ -1,6 +1,7 @@ #cmakedefine VERSION "@VERSION@" // poppler-tqt +#cmakedefine HAVE_POPPLER_060 #cmakedefine HAVE_POPPLER_030 #cmakedefine HAVE_POPPLER_020 #cmakedefine HAVE_POPPLER_016 diff --git a/tdefile-plugins/dependencies/poppler-tqt/ConfigureChecks.cmake b/tdefile-plugins/dependencies/poppler-tqt/ConfigureChecks.cmake index 7714f5e3..725a19c6 100644 --- a/tdefile-plugins/dependencies/poppler-tqt/ConfigureChecks.cmake +++ b/tdefile-plugins/dependencies/poppler-tqt/ConfigureChecks.cmake @@ -24,3 +24,13 @@ check_cxx_source_compiles(" HAVE_POPPLER_030 ) tde_restore( CMAKE_REQUIRED_INCLUDES CMAKE_REQUIRED_LIBRARIES ) +if( NOT DEFINED HAVE_POPPLER_060 ) + message( STATUS "Performing Test HAVE_POPPLER_060" ) + if( POPPLER_VERSION VERSION_GREATER_EQUAL "0.60" ) + set( HAVE_POPPLER_060 1 CACHE INTERNAL "" FORCE ) + message( STATUS "Performing Test HAVE_POPPLER_060 - Success" ) + else( ) + set( HAVE_POPPLER_060 "" CACHE INTERNAL "" FORCE ) + message( STATUS "Performing Test HAVE_POPPLER_060 - Failed" ) + endif( ) +endif( ) diff --git a/tdefile-plugins/dependencies/poppler-tqt/poppler-document.cc b/tdefile-plugins/dependencies/poppler-tqt/poppler-document.cc index 081e1035..5998ae24 100644 --- a/tdefile-plugins/dependencies/poppler-tqt/poppler-document.cc +++ b/tdefile-plugins/dependencies/poppler-tqt/poppler-document.cc @@ -153,7 +153,11 @@ TQString Document::getInfo( const TQString & type ) const if ( data->locked ) return NULL; +# if defined(HAVE_POPPLER_060) + info = data->doc.getDocInfo(); +# else data->doc.getDocInfo( &info ); +# endif if ( !info.isDict() ) return NULL; @@ -165,7 +169,13 @@ TQString Document::getInfo( const TQString & type ) const int i; Dict *infoDict = info.getDict(); - if ( infoDict->lookup( (char*)type.latin1(), &obj )->isString() ) + if ( +# if defined(HAVE_POPPLER_060) + infoDict->lookup( (char*)type.latin1() ).isString() +# else + infoDict->lookup( (char*)type.latin1(), &obj )->isString() +# endif + ) { s1 = obj.getString(); if ( ( s1->getChar(0) & 0xff ) == 0xfe && ( s1->getChar(1) & 0xff ) == 0xff ) @@ -192,12 +202,16 @@ TQString Document::getInfo( const TQString & type ) const } result += unicodeToTQString( &u, 1 ); } +# if !defined(HAVE_POPPLER_060) obj.free(); info.free(); +# endif return result; } +# if !defined(HAVE_POPPLER_060) obj.free(); info.free(); +# endif return NULL; } @@ -209,9 +223,15 @@ TQDateTime Document::getDate( const TQString & type ) const return TQDateTime(); Object info; +# if defined(HAVE_POPPLER_060) + info = data->doc.getDocInfo(); +# else data->doc.getDocInfo( &info ); +# endif if ( !info.isDict() ) { +# if !defined(HAVE_POPPLER_060) info.free(); +# endif return TQDateTime(); } @@ -221,7 +241,13 @@ TQDateTime Document::getDate( const TQString & type ) const Dict *infoDict = info.getDict(); TQString result; - if ( infoDict->lookup( (char*)type.latin1(), &obj )->isString() ) + if ( +# if defined(HAVE_POPPLER_060) + infoDict->lookup( (char*)type.latin1() ).isString() +# else + infoDict->lookup( (char*)type.latin1(), &obj )->isString() +# endif + ) { TQString s = UnicodeParsedString(obj.getString()); // TODO do something with the timezone information @@ -230,14 +256,18 @@ TQDateTime Document::getDate( const TQString & type ) const TQDate d( year, mon, day ); //CHECK: it was mon-1, Jan->0 (??) TQTime t( hour, min, sec ); if ( d.isValid() && t.isValid() ) { +# if !defined(HAVE_POPPLER_060) obj.free(); info.free(); +# endif return TQDateTime( d, t ); } } } +# if !defined(HAVE_POPPLER_060) obj.free(); info.free(); +# endif return TQDateTime(); } @@ -317,7 +347,7 @@ bool Document::print(const TQString &fileName, TQValueList pageList, double bool Document::print(const TQString &file, TQValueList pageList, double hDPI, double vDPI, int rotate, int paperWidth, int paperHeight) { -#if defined(HAVE_POPPLER_030) +#if defined(HAVE_POPPLER_060) || defined(HAVE_POPPLER_030) std::vector pages; TQValueList::iterator it; for (it = pageList.begin(); it != pageList.end(); ++it ) { diff --git a/tdefile-plugins/dependencies/poppler-tqt/poppler-page.cc b/tdefile-plugins/dependencies/poppler-tqt/poppler-page.cc index 2c6a5f0e..3c6bafca 100644 --- a/tdefile-plugins/dependencies/poppler-tqt/poppler-page.cc +++ b/tdefile-plugins/dependencies/poppler-tqt/poppler-page.cc @@ -129,7 +129,7 @@ TQString Page::getText(const Rectangle &r) const TQString result; ::Page *p; -#if defined(HAVE_POPPLER_030) || defined(HAVE_POPPLER_020) +#if defined(HAVE_POPPLER_060) || defined(HAVE_POPPLER_030) || defined(HAVE_POPPLER_020) output_dev = new TextOutputDev(0, gFalse, 0, gFalse, gFalse); #else output_dev = new TextOutputDev(0, gFalse, gFalse, gFalse); @@ -164,7 +164,7 @@ TQValueList Page::textList() const TQValueList output_list; -#if defined(HAVE_POPPLER_030) || defined(HAVE_POPPLER_020) +#if defined(HAVE_POPPLER_060) || defined(HAVE_POPPLER_030) || defined(HAVE_POPPLER_020) output_dev = new TextOutputDev(0, gFalse, 0, gFalse, gFalse); #else output_dev = new TextOutputDev(0, gFalse, gFalse, gFalse); @@ -205,9 +205,16 @@ PageTransition *Page::getTransition() const { Object o; PageTransitionParams params; - params.dictObj = data->doc->data->doc.getCatalog()->getPage(data->index + 1)->getTrans(&o); +# if defined(HAVE_POPPLER_060) + o = data->doc->data->doc.getCatalog()->getPage(data->index + 1)->getTrans(); +# else + data->doc->data->doc.getCatalog()->getPage(data->index + 1)->getTrans(&o); +# endif + params.dictObj = &o; data->transition = new PageTransition(params); +# if !defined(HAVE_POPPLER_060) o.free(); +# endif } return data->transition; } -- cgit v1.2.3