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