Simplify poppler version definitions.

Signed-off-by: Slávek Banko <slavek.banko@axis.cz>
pull/87/head
Slávek Banko 9 months ago
parent 6b9d7271f3
commit 108c4a3a4a
No known key found for this signature in database
GPG Key ID: 608F5293A04BE668

@ -1,23 +1,7 @@
#cmakedefine VERSION "@VERSION@" #cmakedefine VERSION "@VERSION@"
// poppler-tqt // poppler-tqt
#cmakedefine HAVE_POPPLER_2402 #cmakedefine POPPLER_VERSION_C @POPPLER_VERSION_C@
#cmakedefine HAVE_POPPLER_2203
#cmakedefine HAVE_POPPLER_2112
#cmakedefine HAVE_POPPLER_2111
#cmakedefine HAVE_POPPLER_2108
#cmakedefine HAVE_POPPLER_086
#cmakedefine HAVE_POPPLER_083
#cmakedefine HAVE_POPPLER_082
#cmakedefine HAVE_POPPLER_076
#cmakedefine HAVE_POPPLER_072
#cmakedefine HAVE_POPPLER_071
#cmakedefine HAVE_POPPLER_070
#cmakedefine HAVE_POPPLER_064
#cmakedefine HAVE_POPPLER_058
#cmakedefine HAVE_POPPLER_030
#cmakedefine HAVE_POPPLER_020
#cmakedefine HAVE_POPPLER_016
// kpdf, kdvi // kpdf, kdvi
#cmakedefine HAVE_FREETYPE 1 #cmakedefine HAVE_FREETYPE 1

@ -6,38 +6,14 @@ else( )
tde_message_fatal( "poppler is required, but was not found on your system" ) tde_message_fatal( "poppler is required, but was not found on your system" )
endif( ) endif( )
tde_save( CMAKE_REQUIRED_INCLUDES CMAKE_REQUIRED_LIBRARIES ) string( REGEX MATCH "^([0-9]+)\\.([0-9]+)\\.([0-9]+)"
set( CMAKE_REQUIRED_INCLUDES ${DBUS_TQT_INCLUDE_DIRS} ${TQT_INCLUDE_DIRS} ${TQT_INCLUDE_DIRS} ${POPPLER_INCLUDE_DIRS}) POPPLER_VERSION_SPLIT ${POPPLER_VERSION} )
set( CMAKE_REQUIRED_LIBRARIES ${DBUS_TQT_LDFLAGS} ${TQT_LDFLAGS} ${QT_LDFLAGS} ${POPPLER_LDFLAGS} ) set( POPPLER_VERSION_MAJOR ${CMAKE_MATCH_1} )
check_cxx_source_compiles(" set( POPPLER_VERSION_MINOR ${CMAKE_MATCH_2} )
#include <PSOutputDev.h> set( POPPLER_VERSION_PATCH ${CMAKE_MATCH_3} )
int main(int, char**) { int a; int b; PSOutputDev *psOut = new PSOutputDev(\"test\", (PDFDoc*)0, (XRef*)0, (Catalog*)0, NULL, 0, 0, psModePS, a, b); } " math( EXPR POPPLER_VERSION_C "(${POPPLER_VERSION_MAJOR}*1000000) + (${POPPLER_VERSION_MINOR}*1000) + ${POPPLER_VERSION_PATCH}" )
HAVE_POPPLER_016 ) set( POPPLER_VERSION_C ${POPPLER_VERSION_C} CACHE INTERNAL "Poppler library version as code number" )
check_cxx_source_compiles("
#include <PSOutputDev.h>
int main(int, char**) { int a; int b; PSOutputDev *psOut = new PSOutputDev(\"test\", (PDFDoc*)0, NULL, 0, 0, psModePS, a, b); } "
HAVE_POPPLER_020 )
check_cxx_source_compiles("
#include <vector>
#include <PSOutputDev.h>
int main(int, char**) { int a; int b; std::vector<int> p; PSOutputDev *psOut = new PSOutputDev(\"test\", (PDFDoc*)0, NULL, p, psModePS, a, b); } "
HAVE_POPPLER_030 )
tde_restore( CMAKE_REQUIRED_INCLUDES CMAKE_REQUIRED_LIBRARIES )
foreach( _poppler_ver 0.58 0.64 0.70 0.71 0.72 0.76 0.82 0.83 0.86 21.08 21.11 21.12 22.03 24.02 ) if( NOT POPPLER_VERSION_C LESS 21012000 )
string( REPLACE "." "" _poppler_str "${_poppler_ver}" )
if( NOT DEFINED HAVE_POPPLER_${_poppler_str} )
message( STATUS "Performing Test HAVE_POPPLER_${_poppler_str}" )
if( NOT POPPLER_VERSION VERSION_LESS "${_poppler_ver}" )
set( HAVE_POPPLER_${_poppler_str} 1 CACHE INTERNAL "" FORCE )
message( STATUS "Performing Test HAVE_POPPLER_${_poppler_str} - Success" )
else( )
set( HAVE_POPPLER_${_poppler_str} "" CACHE INTERNAL "" FORCE )
message( STATUS "Performing Test HAVE_POPPLER_${_poppler_str} - Failed" )
endif( )
endif( )
endforeach( )
if( HAVE_POPPLER_2112 )
set( POPPLER_CXX_FEATURES cxx_std_17 CACHE INTERNAL "C++ standard required by Poppler" ) set( POPPLER_CXX_FEATURES cxx_std_17 CACHE INTERNAL "C++ standard required by Poppler" )
endif() endif()

@ -33,7 +33,7 @@
#include <DateInfo.h> #include <DateInfo.h>
#include "poppler-private.h" #include "poppler-private.h"
#if !defined(HAVE_POPPLER_071) #if (POPPLER_VERSION_C < 71000)
#undef bool #undef bool
#endif #endif
@ -43,14 +43,14 @@ Document *Document::load(const TQString &filePath)
{ {
if (!globalParams) { if (!globalParams) {
globalParams = globalParams =
#if defined(HAVE_POPPLER_083) #if (POPPLER_VERSION_C >= 83000)
std::make_unique<GlobalParams>(); std::make_unique<GlobalParams>();
#else #else
new GlobalParams(); new GlobalParams();
#endif #endif
} }
# if defined(HAVE_POPPLER_2203) # if (POPPLER_VERSION_C >= 22003000)
DocumentData *doc = new DocumentData(std::make_unique<GooString>(TQFile::encodeName(filePath)), {}); DocumentData *doc = new DocumentData(std::make_unique<GooString>(TQFile::encodeName(filePath)), {});
# else # else
DocumentData *doc = new DocumentData(new GooString(TQFile::encodeName(filePath)), NULL); DocumentData *doc = new DocumentData(new GooString(TQFile::encodeName(filePath)), NULL);
@ -88,7 +88,7 @@ bool Document::unlock(const TQCString &password)
{ {
if (data->locked) { if (data->locked) {
/* racier then it needs to be */ /* racier then it needs to be */
# if defined(HAVE_POPPLER_2203) # if (POPPLER_VERSION_C >= 22003000)
DocumentData *doc2 = new DocumentData(std::make_unique<GooString>(data->doc.getFileName()), DocumentData *doc2 = new DocumentData(std::make_unique<GooString>(data->doc.getFileName()),
GooString(password.data())); GooString(password.data()));
# else # else
@ -143,15 +143,13 @@ bool Document::scanForFonts( int numPages, TQValueList<FontInfo> *fontList ) con
{ {
FONTS_LIST_TYPE items = data->m_fontInfoScanner->scan( numPages ); FONTS_LIST_TYPE items = data->m_fontInfoScanner->scan( numPages );
#if !defined(HAVE_POPPLER_082) #if (POPPLER_VERSION_C < 82000)
if ( NULL == items ) if ( NULL == items )
return false; return false;
#endif #endif
#if !defined(HAVE_POPPLER_076) #if (POPPLER_VERSION_C < 76000)
if ( FONTS_LIST_IS_EMPTY(items) ) { if ( FONTS_LIST_IS_EMPTY(items) ) {
# if !defined(HAVE_POPPLER_082)
delete items; delete items;
# endif
return false; return false;
} }
#endif #endif
@ -168,16 +166,16 @@ bool Document::scanForFonts( int numPages, TQValueList<FontInfo> *fontList ) con
(Poppler::FontInfo::Type)(fontInfo->getType())); (Poppler::FontInfo::Type)(fontInfo->getType()));
fontList->append(font); fontList->append(font);
} }
# if defined(HAVE_POPPLER_082) # if (POPPLER_VERSION_C >= 82000)
for (auto entry : items) { for (auto entry : items) {
delete entry; delete entry;
} }
# elif defined(HAVE_POPPLER_076) # elif (POPPLER_VERSION_C >= 76000)
for (auto entry : *items) { for (auto entry : *items) {
delete entry; delete entry;
} }
delete items; delete items;
# elif defined(HAVE_POPPLER_070) # elif (POPPLER_VERSION_C >= 70000)
deleteGooList<::FontInfo>(items); deleteGooList<::FontInfo>(items);
# else # else
deleteGooList(items, ::FontInfo); deleteGooList(items, ::FontInfo);
@ -193,7 +191,7 @@ TQString Document::getInfo( const TQString & type ) const
if ( data->locked ) if ( data->locked )
return NULL; return NULL;
# if defined(HAVE_POPPLER_058) # if (POPPLER_VERSION_C >= 58000)
info = data->doc.getDocInfo(); info = data->doc.getDocInfo();
# else # else
data->doc.getDocInfo( &info ); data->doc.getDocInfo( &info );
@ -209,7 +207,7 @@ TQString Document::getInfo( const TQString & type ) const
int i; int i;
Dict *infoDict = info.getDict(); Dict *infoDict = info.getDict();
#if defined(HAVE_POPPLER_058) #if (POPPLER_VERSION_C >= 58000)
obj = infoDict->lookup( (char*)type.latin1() ); obj = infoDict->lookup( (char*)type.latin1() );
#else #else
infoDict->lookup( (char*)type.latin1(), &obj ); infoDict->lookup( (char*)type.latin1(), &obj );
@ -241,13 +239,13 @@ TQString Document::getInfo( const TQString & type ) const
} }
result += unicodeToTQString( &u, 1 ); result += unicodeToTQString( &u, 1 );
} }
# if !defined(HAVE_POPPLER_058) # if (POPPLER_VERSION_C < 58000)
obj.free(); obj.free();
info.free(); info.free();
# endif # endif
return result; return result;
} }
# if !defined(HAVE_POPPLER_058) # if (POPPLER_VERSION_C < 58000)
obj.free(); obj.free();
info.free(); info.free();
# endif # endif
@ -262,13 +260,13 @@ TQDateTime Document::getDate( const TQString & type ) const
return TQDateTime(); return TQDateTime();
Object info; Object info;
# if defined(HAVE_POPPLER_058) # if (POPPLER_VERSION_C >= 58000)
info = data->doc.getDocInfo(); info = data->doc.getDocInfo();
# else # else
data->doc.getDocInfo( &info ); data->doc.getDocInfo( &info );
# endif # endif
if ( !info.isDict() ) { if ( !info.isDict() ) {
# if !defined(HAVE_POPPLER_058) # if (POPPLER_VERSION_C < 58000)
info.free(); info.free();
# endif # endif
return TQDateTime(); return TQDateTime();
@ -280,14 +278,14 @@ TQDateTime Document::getDate( const TQString & type ) const
Dict *infoDict = info.getDict(); Dict *infoDict = info.getDict();
TQString result; TQString result;
#if defined(HAVE_POPPLER_058) #if (POPPLER_VERSION_C >= 58000)
obj = infoDict->lookup( (char*)type.latin1() ); obj = infoDict->lookup( (char*)type.latin1() );
#else #else
infoDict->lookup( (char*)type.latin1(), &obj ); infoDict->lookup( (char*)type.latin1(), &obj );
#endif #endif
if (!obj.isNull() && obj.isString()) if (!obj.isNull() && obj.isString())
{ {
# if defined(HAVE_POPPLER_2108) # if (POPPLER_VERSION_C >= 21008000)
const GooString *s = obj.getString(); const GooString *s = obj.getString();
# else # else
TQString tqs = UnicodeParsedString(obj.getString()); TQString tqs = UnicodeParsedString(obj.getString());
@ -299,7 +297,7 @@ TQDateTime Document::getDate( const TQString & type ) const
TQDate d( year, mon, day ); //CHECK: it was mon-1, Jan->0 (??) TQDate d( year, mon, day ); //CHECK: it was mon-1, Jan->0 (??)
TQTime t( hour, min, sec ); TQTime t( hour, min, sec );
if ( d.isValid() && t.isValid() ) { if ( d.isValid() && t.isValid() ) {
# if !defined(HAVE_POPPLER_058) # if (POPPLER_VERSION_C < 58000)
obj.free(); obj.free();
info.free(); info.free();
# endif # endif
@ -307,7 +305,7 @@ TQDateTime Document::getDate( const TQString & type ) const
} }
} }
} }
# if !defined(HAVE_POPPLER_058) # if (POPPLER_VERSION_C < 58000)
obj.free(); obj.free();
info.free(); info.free();
# endif # endif
@ -390,16 +388,16 @@ bool Document::print(const TQString &fileName, TQValueList<int> pageList, double
bool Document::print(const TQString &file, TQValueList<int> pageList, double hDPI, double vDPI, int rotate, int paperWidth, int paperHeight) bool Document::print(const TQString &file, TQValueList<int> pageList, double hDPI, double vDPI, int rotate, int paperWidth, int paperHeight)
{ {
#if defined(HAVE_POPPLER_058) || defined(HAVE_POPPLER_030) #if (POPPLER_VERSION_C >= 30000)
std::vector<int> pages; std::vector<int> pages;
TQValueList<int>::iterator it; TQValueList<int>::iterator it;
for (it = pageList.begin(); it != pageList.end(); ++it ) { for (it = pageList.begin(); it != pageList.end(); ++it ) {
pages.push_back(*it); pages.push_back(*it);
} }
PSOutputDev *psOut = new PSOutputDev(file.latin1(), &(data->doc), NULL, pages, psModePS, paperWidth, paperHeight); PSOutputDev *psOut = new PSOutputDev(file.latin1(), &(data->doc), NULL, pages, psModePS, paperWidth, paperHeight);
#elif defined(HAVE_POPPLER_020) #elif (POPPLER_VERSION_C >= 20000)
PSOutputDev *psOut = new PSOutputDev(file.latin1(), &(data->doc), NULL, 1, data->doc.getNumPages(), psModePS, paperWidth, paperHeight); PSOutputDev *psOut = new PSOutputDev(file.latin1(), &(data->doc), NULL, 1, data->doc.getNumPages(), psModePS, paperWidth, paperHeight);
#elif defined(HAVE_POPPLER_016) #elif (POPPLER_VERSION_C >= 16000)
PSOutputDev *psOut = new PSOutputDev(file.latin1(), &(data->doc), data->doc.getXRef(), data->doc.getCatalog(), NULL, 1, data->doc.getNumPages(), psModePS, paperWidth, paperHeight); PSOutputDev *psOut = new PSOutputDev(file.latin1(), &(data->doc), data->doc.getXRef(), data->doc.getCatalog(), NULL, 1, data->doc.getNumPages(), psModePS, paperWidth, paperHeight);
#else #else
PSOutputDev *psOut = new PSOutputDev(file.latin1(), data->doc.getXRef(), data->doc.getCatalog(), NULL, 1, data->doc.getNumPages(), psModePS, paperWidth, paperHeight); PSOutputDev *psOut = new PSOutputDev(file.latin1(), data->doc.getXRef(), data->doc.getCatalog(), NULL, 1, data->doc.getNumPages(), psModePS, paperWidth, paperHeight);

@ -35,7 +35,7 @@ namespace Poppler {
if ( data.namedDest && !ld ) if ( data.namedDest && !ld )
{ {
deleteDest = true; deleteDest = true;
# if defined(HAVE_POPPLER_086) # if (POPPLER_VERSION_C >= 86000)
ld = data.doc->doc.findDest( data.namedDest ).get(); ld = data.doc->doc.findDest( data.namedDest ).get();
# else # else
ld = data.doc->doc.findDest( data.namedDest ); ld = data.doc->doc.findDest( data.namedDest );
@ -81,7 +81,7 @@ namespace Poppler {
m_right = rightAux; m_right = rightAux;
m_bottom = bottomAux; m_bottom = bottomAux;
# if !defined(HAVE_POPPLER_086) # if (POPPLER_VERSION_C < 86000)
if (deleteDest) delete ld; if (deleteDest) delete ld;
# endif # endif
} }

@ -129,7 +129,7 @@ TQString Page::getText(const Rectangle &r) const
TQString result; TQString result;
::Page *p; ::Page *p;
#if defined(HAVE_POPPLER_058) || defined(HAVE_POPPLER_030) || defined(HAVE_POPPLER_020) #if (POPPLER_VERSION_C >= 20000)
output_dev = new TextOutputDev(0, gFalse, 0, gFalse, gFalse); output_dev = new TextOutputDev(0, gFalse, 0, gFalse, gFalse);
#else #else
output_dev = new TextOutputDev(0, gFalse, gFalse, gFalse); output_dev = new TextOutputDev(0, gFalse, gFalse, gFalse);
@ -164,7 +164,7 @@ TQValueList<TextBox*> Page::textList() const
TQValueList<TextBox*> output_list; TQValueList<TextBox*> output_list;
#if defined(HAVE_POPPLER_058) || defined(HAVE_POPPLER_030) || defined(HAVE_POPPLER_020) #if (POPPLER_VERSION_C >= 20000)
output_dev = new TextOutputDev(0, gFalse, 0, gFalse, gFalse); output_dev = new TextOutputDev(0, gFalse, 0, gFalse, gFalse);
#else #else
output_dev = new TextOutputDev(0, gFalse, gFalse, gFalse); output_dev = new TextOutputDev(0, gFalse, gFalse, gFalse);
@ -173,7 +173,7 @@ TQValueList<TextBox*> Page::textList() const
data->doc->data->doc.displayPageSlice(output_dev, data->index + 1, 72, 72, data->doc->data->doc.displayPageSlice(output_dev, data->index + 1, 72, 72,
0, false, false, false, -1, -1, -1, -1); 0, false, false, false, -1, -1, -1, -1);
# if defined(HAVE_POPPLER_2111) # if (POPPLER_VERSION_C >= 21011000)
std::unique_ptr<TextWordList> word_list = output_dev->makeWordList(); std::unique_ptr<TextWordList> word_list = output_dev->makeWordList();
# else # else
TextWordList *word_list = output_dev->makeWordList(); TextWordList *word_list = output_dev->makeWordList();
@ -197,7 +197,7 @@ TQValueList<TextBox*> Page::textList() const
output_list.append(text_box); output_list.append(text_box);
} }
# if !defined(HAVE_POPPLER_2111) # if (POPPLER_VERSION_C < 21011000)
delete word_list; delete word_list;
# endif # endif
delete output_dev; delete output_dev;
@ -211,14 +211,14 @@ PageTransition *Page::getTransition() const
{ {
Object o; Object o;
PageTransitionParams params; PageTransitionParams params;
# if defined(HAVE_POPPLER_058) # if (POPPLER_VERSION_C >= 58000)
o = data->doc->data->doc.getCatalog()->getPage(data->index + 1)->getTrans(); o = data->doc->data->doc.getCatalog()->getPage(data->index + 1)->getTrans();
# else # else
data->doc->data->doc.getCatalog()->getPage(data->index + 1)->getTrans(&o); data->doc->data->doc.getCatalog()->getPage(data->index + 1)->getTrans(&o);
# endif # endif
params.dictObj = &o; params.dictObj = &o;
data->transition = new PageTransition(params); data->transition = new PageTransition(params);
# if !defined(HAVE_POPPLER_058) # if (POPPLER_VERSION_C < 58000)
o.free(); o.free();
# endif # endif
} }

@ -93,7 +93,7 @@ void DocumentData::addTocChildren( TQDomDocument * docSyn, TQDomNode * parent, O
{ {
// iterate over every object in 'items' // iterate over every object in 'items'
OutlineItem * outlineItem = OutlineItem * outlineItem =
#ifdef HAVE_POPPLER_076 #if (POPPLER_VERSION_C >= 76000)
(*items)[i]; (*items)[i];
#else #else
(OutlineItem *)items->get( i ); (OutlineItem *)items->get( i );
@ -101,7 +101,7 @@ void DocumentData::addTocChildren( TQDomDocument * docSyn, TQDomNode * parent, O
// 1. create element using outlineItem's title as tagName // 1. create element using outlineItem's title as tagName
TQString name; TQString name;
#ifdef HAVE_POPPLER_2402 #if (POPPLER_VERSION_C >= 24002000)
const std::vector<Unicode> &uVec = outlineItem->getTitle(); const std::vector<Unicode> &uVec = outlineItem->getTitle();
name = unicodeToTQString( uVec.data(), uVec.size() ); name = unicodeToTQString( uVec.data(), uVec.size() );
#else #else

@ -39,27 +39,27 @@
#else #else
class SplashOutputDev; class SplashOutputDev;
#endif #endif
#if defined(HAVE_POPPLER_064) #if (POPPLER_VERSION_C >= 64000)
#define CONST_064 const #define CONST_064 const
#else #else
#define CONST_064 #define CONST_064
#endif #endif
#if defined(HAVE_POPPLER_071) #if (POPPLER_VERSION_C >= 71000)
#define GBool bool #define GBool bool
#define gTrue true #define gTrue true
#define gFalse false #define gFalse false
#endif #endif
#if defined(HAVE_POPPLER_072) #if (POPPLER_VERSION_C >= 72000)
#define GOO_GET_CSTR c_str #define GOO_GET_CSTR c_str
#else #else
#define GOO_GET_CSTR getCString #define GOO_GET_CSTR getCString
#endif #endif
#if defined(HAVE_POPPLER_076) #if (POPPLER_VERSION_C >= 76000)
#include <vector> #include <vector>
class OutlineItem; class OutlineItem;
#define OUTLINE_ITEMS_TYPE const std::vector<OutlineItem*> #define OUTLINE_ITEMS_TYPE const std::vector<OutlineItem*>
#define OUTLINE_ITEMS_LENGTH(goo) goo->size() #define OUTLINE_ITEMS_LENGTH(goo) goo->size()
# if defined(HAVE_POPPLER_082) # if (POPPLER_VERSION_C >= 82000)
#define FONTS_LIST_TYPE std::vector<::FontInfo*> #define FONTS_LIST_TYPE std::vector<::FontInfo*>
#define FONTS_LIST_LENGTH(goo) goo.size() #define FONTS_LIST_LENGTH(goo) goo.size()
#define FONTS_LIST_IS_EMPTY(goo) goo.empty() #define FONTS_LIST_IS_EMPTY(goo) goo.empty()
@ -104,7 +104,7 @@ class LinkDestinationData {
class DocumentData { class DocumentData {
public: public:
# if defined(HAVE_POPPLER_2203) # if (POPPLER_VERSION_C >= 22003000)
DocumentData(std::unique_ptr<GooString> &&filePath, const std::optional<GooString> &password) : doc(std::move(filePath), password), m_fontInfoScanner(0), m_outputDev(0) {} DocumentData(std::unique_ptr<GooString> &&filePath, const std::optional<GooString> &password) : doc(std::move(filePath), password), m_fontInfoScanner(0), m_outputDev(0) {}
# else # else
DocumentData(GooString *filePath, GooString *password) : doc(filePath,password), m_fontInfoScanner(0), m_outputDev(0) {} DocumentData(GooString *filePath, GooString *password) : doc(filePath,password), m_fontInfoScanner(0), m_outputDev(0) {}

Loading…
Cancel
Save