From 14d0fbe96c6abdb9da80e99953aec672f999948c Mon Sep 17 00:00:00 2001 From: Michele Calgaro Date: Sun, 13 Dec 2020 19:22:19 +0900 Subject: Renaming of files in preparation for code style tools. Signed-off-by: Michele Calgaro --- .../dependencies/poppler-tqt/CMakeLists.txt | 8 +- .../dependencies/poppler-tqt/Makefile.am | 12 +- .../dependencies/poppler-tqt/poppler-document.cc | 407 --------------------- .../dependencies/poppler-tqt/poppler-document.cpp | 407 +++++++++++++++++++++ .../dependencies/poppler-tqt/poppler-fontinfo.cc | 83 ----- .../dependencies/poppler-tqt/poppler-fontinfo.cpp | 83 +++++ .../dependencies/poppler-tqt/poppler-link.cc | 273 -------------- .../dependencies/poppler-tqt/poppler-link.cpp | 273 ++++++++++++++ .../poppler-tqt/poppler-page-transition.cc | 95 ----- .../poppler-tqt/poppler-page-transition.cpp | 95 +++++ .../dependencies/poppler-tqt/poppler-page.cc | 377 ------------------- .../dependencies/poppler-tqt/poppler-page.cpp | 377 +++++++++++++++++++ .../dependencies/poppler-tqt/poppler-private.cc | 152 -------- .../dependencies/poppler-tqt/poppler-private.cpp | 152 ++++++++ 14 files changed, 1397 insertions(+), 1397 deletions(-) delete mode 100644 tdefile-plugins/dependencies/poppler-tqt/poppler-document.cc create mode 100644 tdefile-plugins/dependencies/poppler-tqt/poppler-document.cpp delete mode 100644 tdefile-plugins/dependencies/poppler-tqt/poppler-fontinfo.cc create mode 100644 tdefile-plugins/dependencies/poppler-tqt/poppler-fontinfo.cpp delete mode 100644 tdefile-plugins/dependencies/poppler-tqt/poppler-link.cc create mode 100644 tdefile-plugins/dependencies/poppler-tqt/poppler-link.cpp delete mode 100644 tdefile-plugins/dependencies/poppler-tqt/poppler-page-transition.cc create mode 100644 tdefile-plugins/dependencies/poppler-tqt/poppler-page-transition.cpp delete mode 100644 tdefile-plugins/dependencies/poppler-tqt/poppler-page.cc create mode 100644 tdefile-plugins/dependencies/poppler-tqt/poppler-page.cpp delete mode 100644 tdefile-plugins/dependencies/poppler-tqt/poppler-private.cc create mode 100644 tdefile-plugins/dependencies/poppler-tqt/poppler-private.cpp (limited to 'tdefile-plugins') diff --git a/tdefile-plugins/dependencies/poppler-tqt/CMakeLists.txt b/tdefile-plugins/dependencies/poppler-tqt/CMakeLists.txt index 2ce99412..28be343b 100644 --- a/tdefile-plugins/dependencies/poppler-tqt/CMakeLists.txt +++ b/tdefile-plugins/dependencies/poppler-tqt/CMakeLists.txt @@ -45,10 +45,10 @@ install( FILES tde_add_library( poppler-tqt SHARED AUTOMOC SOURCES - poppler-document.cc poppler-fontinfo.cc - poppler-link.cc poppler-page.cc - poppler-page-transition.cc poppler-page-transition-private.h - poppler-private.cc poppler-private.h + poppler-document.cpp poppler-fontinfo.cpp + poppler-link.cpp poppler-page.cpp + poppler-page-transition.cpp poppler-page-transition-private.h + poppler-private.cpp poppler-private.h VERSION 0.0.0 LINK ${POPPLER_LIBRARIES} ${TQT_LIBRARIES} DESTINATION ${LIB_INSTALL_DIR} diff --git a/tdefile-plugins/dependencies/poppler-tqt/Makefile.am b/tdefile-plugins/dependencies/poppler-tqt/Makefile.am index 7de8524c..09bc6fbe 100644 --- a/tdefile-plugins/dependencies/poppler-tqt/Makefile.am +++ b/tdefile-plugins/dependencies/poppler-tqt/Makefile.am @@ -15,13 +15,13 @@ poppler_include_HEADERS = \ lib_LTLIBRARIES = libpoppler-tqt.la libpoppler_tqt_la_SOURCES = \ - poppler-document.cc \ - poppler-fontinfo.cc \ - poppler-link.cc \ - poppler-page.cc \ - poppler-page-transition.cc \ + poppler-document.cpp \ + poppler-fontinfo.cpp \ + poppler-link.cpp \ + poppler-page.cpp \ + poppler-page-transition.cpp \ poppler-page-transition-private.h \ - poppler-private.cc \ + poppler-private.cpp \ poppler-private.h libpoppler_tqt_la_LIBADD = \ diff --git a/tdefile-plugins/dependencies/poppler-tqt/poppler-document.cc b/tdefile-plugins/dependencies/poppler-tqt/poppler-document.cc deleted file mode 100644 index db403c5e..00000000 --- a/tdefile-plugins/dependencies/poppler-tqt/poppler-document.cc +++ /dev/null @@ -1,407 +0,0 @@ -/* poppler-document.cc: qt interface to poppler - * Copyright (C) 2005, Net Integration Technologies, Inc. - * Copyright (C) 2005-2009, Albert Astals Cid - * Copyright (C) 2006, Stefan Kebekus - * Copyright (C) 2006, Wilfried Huss - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2, or (at your option) - * any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA. - */ - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include "poppler-private.h" - -#if !defined(HAVE_POPPLER_071) -#undef bool -#endif - -namespace Poppler { - -Document *Document::load(const TQString &filePath) -{ - if (!globalParams) { - globalParams = -#if defined(HAVE_POPPLER_083) - std::make_unique(); -#else - new GlobalParams(); -#endif - } - - DocumentData *doc = new DocumentData(new GooString(TQFile::encodeName(filePath)), NULL); - Document *pdoc; - if (doc->doc.isOk() || doc->doc.getErrorCode() == errEncrypted) { - pdoc = new Document(doc); - if (doc->doc.getErrorCode() == errEncrypted) - pdoc->data->locked = true; - else - pdoc->data->locked = false; - pdoc->data->m_fontInfoScanner = new FontInfoScanner(&(doc->doc)); - return pdoc; - } - else - return NULL; -} - -Document::Document(DocumentData *dataA) -{ - data = dataA; -} - -Document::~Document() -{ - delete data; -} - -bool Document::isLocked() const -{ - return data->locked; -} - -bool Document::unlock(const TQCString &password) -{ - if (data->locked) { - /* racier then it needs to be */ - GooString *filename = new GooString(data->doc.getFileName()); - GooString *pwd = new GooString(password.data()); - DocumentData *doc2 = new DocumentData(filename, pwd); - delete pwd; - if (!doc2->doc.isOk()) { - delete doc2; - } else { - delete data; - data = doc2; - data->locked = false; - data->m_fontInfoScanner = new FontInfoScanner(&(data->doc)); - } - } - return data->locked; -} - -Document::PageMode Document::getPageMode(void) const -{ - switch (data->doc.getCatalog()->getPageMode()) { - case Catalog::pageModeNone: - return UseNone; - case Catalog::pageModeOutlines: - return UseOutlines; - case Catalog::pageModeThumbs: - return UseThumbs; - case Catalog::pageModeFullScreen: - return FullScreen; - case Catalog::pageModeOC: - return UseOC; - default: - return UseNone; - } -} - -int Document::getNumPages() const -{ - return data->doc.getNumPages(); -} - -TQValueList Document::fonts() const -{ - TQValueList ourList; - scanForFonts(getNumPages(), &ourList); - return ourList; -} - -bool Document::scanForFonts( int numPages, TQValueList *fontList ) const -{ - FONTS_LIST_TYPE items = data->m_fontInfoScanner->scan( numPages ); - -#if !defined(HAVE_POPPLER_082) - if ( NULL == items ) - return false; -#endif -#if !defined(HAVE_POPPLER_076) - if ( FONTS_LIST_IS_EMPTY(items) ) { -# if !defined(HAVE_POPPLER_082) - delete items; -# endif - return false; - } -#endif - - for ( int i = 0; i < FONTS_LIST_LENGTH(items); ++i ) { - TQString fontName; - ::FontInfo *fontInfo = FONTS_LIST_GET(items, i); - if (fontInfo->getName()) - fontName = fontInfo->getName()->GOO_GET_CSTR(); - - FontInfo font(fontName, - fontInfo->getEmbedded(), - fontInfo->getSubset(), - (Poppler::FontInfo::Type)(fontInfo->getType())); - fontList->append(font); - } -# if defined(HAVE_POPPLER_082) - for (auto entry : items) { - delete entry; - } -# elif defined(HAVE_POPPLER_076) - for (auto entry : *items) { - delete entry; - } - delete items; -# elif defined(HAVE_POPPLER_070) - deleteGooList<::FontInfo>(items); -# else - deleteGooList(items, ::FontInfo); -# endif - return true; -} - -/* borrowed from kpdf */ -TQString Document::getInfo( const TQString & type ) const -{ - // [Albert] Code adapted from pdfinfo.cc on xpdf - Object info; - if ( data->locked ) - return NULL; - -# if defined(HAVE_POPPLER_058) - info = data->doc.getDocInfo(); -# else - data->doc.getDocInfo( &info ); -# endif - if ( !info.isDict() ) - return NULL; - - TQString result; - Object obj; - CONST_064 GooString *s1; - GBool isUnicode; - Unicode u; - int i; - Dict *infoDict = info.getDict(); - -#if defined(HAVE_POPPLER_058) - obj = infoDict->lookup( (char*)type.latin1() ); -#else - infoDict->lookup( (char*)type.latin1(), &obj ); -#endif - if (!obj.isNull() && obj.isString()) - { - s1 = obj.getString(); - if ( ( s1->getChar(0) & 0xff ) == 0xfe && ( s1->getChar(1) & 0xff ) == 0xff ) - { - isUnicode = gTrue; - i = 2; - } - else - { - isUnicode = gFalse; - i = 0; - } - while ( i < obj.getString()->getLength() ) - { - if ( isUnicode ) - { - u = ( ( s1->getChar(i) & 0xff ) << 8 ) | ( s1->getChar(i+1) & 0xff ); - i += 2; - } - else - { - u = s1->getChar(i) & 0xff; - ++i; - } - result += unicodeToTQString( &u, 1 ); - } -# if !defined(HAVE_POPPLER_058) - obj.free(); - info.free(); -# endif - return result; - } -# if !defined(HAVE_POPPLER_058) - obj.free(); - info.free(); -# endif - return NULL; -} - -/* borrowed from kpdf */ -TQDateTime Document::getDate( const TQString & type ) const -{ - // [Albert] Code adapted from pdfinfo.cc on xpdf - if ( data->locked ) - return TQDateTime(); - - Object info; -# if defined(HAVE_POPPLER_058) - info = data->doc.getDocInfo(); -# else - data->doc.getDocInfo( &info ); -# endif - if ( !info.isDict() ) { -# if !defined(HAVE_POPPLER_058) - info.free(); -# endif - return TQDateTime(); - } - - Object obj; - int year, mon, day, hour, min, sec, tz_hour, tz_minute; - char tz; - Dict *infoDict = info.getDict(); - TQString result; - -#if defined(HAVE_POPPLER_058) - obj = infoDict->lookup( (char*)type.latin1() ); -#else - infoDict->lookup( (char*)type.latin1(), &obj ); -#endif - if (!obj.isNull() && obj.isString()) - { - TQString s = UnicodeParsedString(obj.getString()); - // TODO do something with the timezone information - if ( parseDateString( s.latin1(), &year, &mon, &day, &hour, &min, &sec, &tz, &tz_hour, &tz_minute ) ) - { - 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_058) - obj.free(); - info.free(); -# endif - return TQDateTime( d, t ); - } - } - } -# if !defined(HAVE_POPPLER_058) - obj.free(); - info.free(); -# endif - return TQDateTime(); -} - -bool Document::isEncrypted() const -{ - return data->doc.isEncrypted(); -} - -bool Document::isLinearized() const -{ - return data->doc.isLinearized(); -} - -bool Document::okToPrint() const -{ - return data->doc.okToPrint(); -} - -bool Document::okToChange() const -{ - return data->doc.okToChange(); -} - -bool Document::okToCopy() const -{ - return data->doc.okToCopy(); -} - -bool Document::okToAddNotes() const -{ - return data->doc.okToAddNotes(); -} - -double Document::getPDFVersion() const -{ - return data->doc.getPDFMajorVersion () + data->doc.getPDFMinorVersion() / 10.0; -} - -void Document::getPdfVersion(int *major, int *minor) const -{ - if (major) - *major = data->doc.getPDFMajorVersion(); - if (minor) - *minor = data->doc.getPDFMinorVersion(); -} - -TQDomDocument *Document::toc() const -{ - Outline * outline = data->doc.getOutline(); - if ( !outline ) - return NULL; - - OUTLINE_ITEMS_TYPE * items = outline->getItems(); - if ( !items || OUTLINE_ITEMS_LENGTH(items) < 1 ) - return NULL; - - TQDomDocument *toc = new TQDomDocument(); - if ( OUTLINE_ITEMS_LENGTH(items) > 0 ) - data->addTocChildren( toc, toc, items ); - - return toc; -} - -LinkDestination *Document::linkDestination( const TQString &name ) -{ - GooString * namedDest = TQStringToGooString( name ); - LinkDestinationData ldd(NULL, namedDest, data); - LinkDestination *ld = new LinkDestination(ldd); - delete namedDest; - return ld; -} - -bool Document::print(const TQString &fileName, TQValueList pageList, double hDPI, double vDPI, int rotate) -{ - return print(fileName, pageList, hDPI, vDPI, rotate, -1, -1); -} - -bool Document::print(const TQString &file, TQValueList pageList, double hDPI, double vDPI, int rotate, int paperWidth, int paperHeight) -{ -#if defined(HAVE_POPPLER_058) || defined(HAVE_POPPLER_030) - std::vector pages; - TQValueList::iterator it; - for (it = pageList.begin(); it != pageList.end(); ++it ) { - pages.push_back(*it); - } - PSOutputDev *psOut = new PSOutputDev(file.latin1(), &(data->doc), NULL, pages, psModePS, paperWidth, paperHeight); -#elif defined(HAVE_POPPLER_020) - PSOutputDev *psOut = new PSOutputDev(file.latin1(), &(data->doc), NULL, 1, data->doc.getNumPages(), psModePS, paperWidth, paperHeight); -#elif defined(HAVE_POPPLER_016) - PSOutputDev *psOut = new PSOutputDev(file.latin1(), &(data->doc), data->doc.getXRef(), data->doc.getCatalog(), NULL, 1, data->doc.getNumPages(), psModePS, paperWidth, paperHeight); -#else - PSOutputDev *psOut = new PSOutputDev(file.latin1(), data->doc.getXRef(), data->doc.getCatalog(), NULL, 1, data->doc.getNumPages(), psModePS, paperWidth, paperHeight); -#endif - - if (psOut->isOk()) { - TQValueList::iterator it; - for (it = pageList.begin(); it != pageList.end(); ++it ) - data->doc.displayPage(psOut, *it, hDPI, vDPI, rotate, gFalse, gTrue, gTrue); - - delete psOut; - return true; - } else { - delete psOut; - return false; - } -} - -} diff --git a/tdefile-plugins/dependencies/poppler-tqt/poppler-document.cpp b/tdefile-plugins/dependencies/poppler-tqt/poppler-document.cpp new file mode 100644 index 00000000..fac02a4b --- /dev/null +++ b/tdefile-plugins/dependencies/poppler-tqt/poppler-document.cpp @@ -0,0 +1,407 @@ +/* poppler-document.cpp: qt interface to poppler + * Copyright (C) 2005, Net Integration Technologies, Inc. + * Copyright (C) 2005-2009, Albert Astals Cid + * Copyright (C) 2006, Stefan Kebekus + * Copyright (C) 2006, Wilfried Huss + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2, or (at your option) + * any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA. + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include "poppler-private.h" + +#if !defined(HAVE_POPPLER_071) +#undef bool +#endif + +namespace Poppler { + +Document *Document::load(const TQString &filePath) +{ + if (!globalParams) { + globalParams = +#if defined(HAVE_POPPLER_083) + std::make_unique(); +#else + new GlobalParams(); +#endif + } + + DocumentData *doc = new DocumentData(new GooString(TQFile::encodeName(filePath)), NULL); + Document *pdoc; + if (doc->doc.isOk() || doc->doc.getErrorCode() == errEncrypted) { + pdoc = new Document(doc); + if (doc->doc.getErrorCode() == errEncrypted) + pdoc->data->locked = true; + else + pdoc->data->locked = false; + pdoc->data->m_fontInfoScanner = new FontInfoScanner(&(doc->doc)); + return pdoc; + } + else + return NULL; +} + +Document::Document(DocumentData *dataA) +{ + data = dataA; +} + +Document::~Document() +{ + delete data; +} + +bool Document::isLocked() const +{ + return data->locked; +} + +bool Document::unlock(const TQCString &password) +{ + if (data->locked) { + /* racier then it needs to be */ + GooString *filename = new GooString(data->doc.getFileName()); + GooString *pwd = new GooString(password.data()); + DocumentData *doc2 = new DocumentData(filename, pwd); + delete pwd; + if (!doc2->doc.isOk()) { + delete doc2; + } else { + delete data; + data = doc2; + data->locked = false; + data->m_fontInfoScanner = new FontInfoScanner(&(data->doc)); + } + } + return data->locked; +} + +Document::PageMode Document::getPageMode(void) const +{ + switch (data->doc.getCatalog()->getPageMode()) { + case Catalog::pageModeNone: + return UseNone; + case Catalog::pageModeOutlines: + return UseOutlines; + case Catalog::pageModeThumbs: + return UseThumbs; + case Catalog::pageModeFullScreen: + return FullScreen; + case Catalog::pageModeOC: + return UseOC; + default: + return UseNone; + } +} + +int Document::getNumPages() const +{ + return data->doc.getNumPages(); +} + +TQValueList Document::fonts() const +{ + TQValueList ourList; + scanForFonts(getNumPages(), &ourList); + return ourList; +} + +bool Document::scanForFonts( int numPages, TQValueList *fontList ) const +{ + FONTS_LIST_TYPE items = data->m_fontInfoScanner->scan( numPages ); + +#if !defined(HAVE_POPPLER_082) + if ( NULL == items ) + return false; +#endif +#if !defined(HAVE_POPPLER_076) + if ( FONTS_LIST_IS_EMPTY(items) ) { +# if !defined(HAVE_POPPLER_082) + delete items; +# endif + return false; + } +#endif + + for ( int i = 0; i < FONTS_LIST_LENGTH(items); ++i ) { + TQString fontName; + ::FontInfo *fontInfo = FONTS_LIST_GET(items, i); + if (fontInfo->getName()) + fontName = fontInfo->getName()->GOO_GET_CSTR(); + + FontInfo font(fontName, + fontInfo->getEmbedded(), + fontInfo->getSubset(), + (Poppler::FontInfo::Type)(fontInfo->getType())); + fontList->append(font); + } +# if defined(HAVE_POPPLER_082) + for (auto entry : items) { + delete entry; + } +# elif defined(HAVE_POPPLER_076) + for (auto entry : *items) { + delete entry; + } + delete items; +# elif defined(HAVE_POPPLER_070) + deleteGooList<::FontInfo>(items); +# else + deleteGooList(items, ::FontInfo); +# endif + return true; +} + +/* borrowed from kpdf */ +TQString Document::getInfo( const TQString & type ) const +{ + // [Albert] Code adapted from pdfinfo.cpp on xpdf + Object info; + if ( data->locked ) + return NULL; + +# if defined(HAVE_POPPLER_058) + info = data->doc.getDocInfo(); +# else + data->doc.getDocInfo( &info ); +# endif + if ( !info.isDict() ) + return NULL; + + TQString result; + Object obj; + CONST_064 GooString *s1; + GBool isUnicode; + Unicode u; + int i; + Dict *infoDict = info.getDict(); + +#if defined(HAVE_POPPLER_058) + obj = infoDict->lookup( (char*)type.latin1() ); +#else + infoDict->lookup( (char*)type.latin1(), &obj ); +#endif + if (!obj.isNull() && obj.isString()) + { + s1 = obj.getString(); + if ( ( s1->getChar(0) & 0xff ) == 0xfe && ( s1->getChar(1) & 0xff ) == 0xff ) + { + isUnicode = gTrue; + i = 2; + } + else + { + isUnicode = gFalse; + i = 0; + } + while ( i < obj.getString()->getLength() ) + { + if ( isUnicode ) + { + u = ( ( s1->getChar(i) & 0xff ) << 8 ) | ( s1->getChar(i+1) & 0xff ); + i += 2; + } + else + { + u = s1->getChar(i) & 0xff; + ++i; + } + result += unicodeToTQString( &u, 1 ); + } +# if !defined(HAVE_POPPLER_058) + obj.free(); + info.free(); +# endif + return result; + } +# if !defined(HAVE_POPPLER_058) + obj.free(); + info.free(); +# endif + return NULL; +} + +/* borrowed from kpdf */ +TQDateTime Document::getDate( const TQString & type ) const +{ + // [Albert] Code adapted from pdfinfo.cpp on xpdf + if ( data->locked ) + return TQDateTime(); + + Object info; +# if defined(HAVE_POPPLER_058) + info = data->doc.getDocInfo(); +# else + data->doc.getDocInfo( &info ); +# endif + if ( !info.isDict() ) { +# if !defined(HAVE_POPPLER_058) + info.free(); +# endif + return TQDateTime(); + } + + Object obj; + int year, mon, day, hour, min, sec, tz_hour, tz_minute; + char tz; + Dict *infoDict = info.getDict(); + TQString result; + +#if defined(HAVE_POPPLER_058) + obj = infoDict->lookup( (char*)type.latin1() ); +#else + infoDict->lookup( (char*)type.latin1(), &obj ); +#endif + if (!obj.isNull() && obj.isString()) + { + TQString s = UnicodeParsedString(obj.getString()); + // TODO do something with the timezone information + if ( parseDateString( s.latin1(), &year, &mon, &day, &hour, &min, &sec, &tz, &tz_hour, &tz_minute ) ) + { + 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_058) + obj.free(); + info.free(); +# endif + return TQDateTime( d, t ); + } + } + } +# if !defined(HAVE_POPPLER_058) + obj.free(); + info.free(); +# endif + return TQDateTime(); +} + +bool Document::isEncrypted() const +{ + return data->doc.isEncrypted(); +} + +bool Document::isLinearized() const +{ + return data->doc.isLinearized(); +} + +bool Document::okToPrint() const +{ + return data->doc.okToPrint(); +} + +bool Document::okToChange() const +{ + return data->doc.okToChange(); +} + +bool Document::okToCopy() const +{ + return data->doc.okToCopy(); +} + +bool Document::okToAddNotes() const +{ + return data->doc.okToAddNotes(); +} + +double Document::getPDFVersion() const +{ + return data->doc.getPDFMajorVersion () + data->doc.getPDFMinorVersion() / 10.0; +} + +void Document::getPdfVersion(int *major, int *minor) const +{ + if (major) + *major = data->doc.getPDFMajorVersion(); + if (minor) + *minor = data->doc.getPDFMinorVersion(); +} + +TQDomDocument *Document::toc() const +{ + Outline * outline = data->doc.getOutline(); + if ( !outline ) + return NULL; + + OUTLINE_ITEMS_TYPE * items = outline->getItems(); + if ( !items || OUTLINE_ITEMS_LENGTH(items) < 1 ) + return NULL; + + TQDomDocument *toc = new TQDomDocument(); + if ( OUTLINE_ITEMS_LENGTH(items) > 0 ) + data->addTocChildren( toc, toc, items ); + + return toc; +} + +LinkDestination *Document::linkDestination( const TQString &name ) +{ + GooString * namedDest = TQStringToGooString( name ); + LinkDestinationData ldd(NULL, namedDest, data); + LinkDestination *ld = new LinkDestination(ldd); + delete namedDest; + return ld; +} + +bool Document::print(const TQString &fileName, TQValueList pageList, double hDPI, double vDPI, int rotate) +{ + return print(fileName, pageList, hDPI, vDPI, rotate, -1, -1); +} + +bool Document::print(const TQString &file, TQValueList pageList, double hDPI, double vDPI, int rotate, int paperWidth, int paperHeight) +{ +#if defined(HAVE_POPPLER_058) || defined(HAVE_POPPLER_030) + std::vector pages; + TQValueList::iterator it; + for (it = pageList.begin(); it != pageList.end(); ++it ) { + pages.push_back(*it); + } + PSOutputDev *psOut = new PSOutputDev(file.latin1(), &(data->doc), NULL, pages, psModePS, paperWidth, paperHeight); +#elif defined(HAVE_POPPLER_020) + PSOutputDev *psOut = new PSOutputDev(file.latin1(), &(data->doc), NULL, 1, data->doc.getNumPages(), psModePS, paperWidth, paperHeight); +#elif defined(HAVE_POPPLER_016) + PSOutputDev *psOut = new PSOutputDev(file.latin1(), &(data->doc), data->doc.getXRef(), data->doc.getCatalog(), NULL, 1, data->doc.getNumPages(), psModePS, paperWidth, paperHeight); +#else + PSOutputDev *psOut = new PSOutputDev(file.latin1(), data->doc.getXRef(), data->doc.getCatalog(), NULL, 1, data->doc.getNumPages(), psModePS, paperWidth, paperHeight); +#endif + + if (psOut->isOk()) { + TQValueList::iterator it; + for (it = pageList.begin(); it != pageList.end(); ++it ) + data->doc.displayPage(psOut, *it, hDPI, vDPI, rotate, gFalse, gTrue, gTrue); + + delete psOut; + return true; + } else { + delete psOut; + return false; + } +} + +} diff --git a/tdefile-plugins/dependencies/poppler-tqt/poppler-fontinfo.cc b/tdefile-plugins/dependencies/poppler-tqt/poppler-fontinfo.cc deleted file mode 100644 index c0e777a7..00000000 --- a/tdefile-plugins/dependencies/poppler-tqt/poppler-fontinfo.cc +++ /dev/null @@ -1,83 +0,0 @@ -/* poppler-qt.h: qt interface to poppler - * Copyright (C) 2005, Albert Astals Cid - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2, or (at your option) - * any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA. - */ - -#include "poppler-qt.h" - -namespace Poppler { - -class FontInfoData -{ - public: - TQString fontName; - bool isEmbedded; - bool isSubset; - FontInfo::Type type; -}; - -FontInfo::FontInfo( const TQString &fontName, const bool isEmbedded, const bool isSubset, Type type ) -{ - data = new FontInfoData(); - data->fontName = fontName; - data->isEmbedded = isEmbedded; - data->isSubset = isSubset; - data->type = type; -} - -FontInfo::FontInfo( const FontInfo &fi ) -{ - data = new FontInfoData(); - data->fontName = fi.data->fontName; - data->isEmbedded = fi.data->isEmbedded; - data->isSubset = fi.data->isSubset; - data->type = fi.data->type; -} - -FontInfo::FontInfo() -{ - data = new FontInfoData(); - data->isEmbedded = false; - data->isSubset = false; - data->type = unknown; -} - -FontInfo::~FontInfo() -{ - delete data; -} - -const TQString &FontInfo::name() const -{ - return data->fontName; -} - -bool FontInfo::isEmbedded() const -{ - return data->isEmbedded; -} - -bool FontInfo::isSubset() const -{ - return data->isSubset; -} - -FontInfo::Type FontInfo::type() const -{ - return data->type; -} - -} diff --git a/tdefile-plugins/dependencies/poppler-tqt/poppler-fontinfo.cpp b/tdefile-plugins/dependencies/poppler-tqt/poppler-fontinfo.cpp new file mode 100644 index 00000000..c0e777a7 --- /dev/null +++ b/tdefile-plugins/dependencies/poppler-tqt/poppler-fontinfo.cpp @@ -0,0 +1,83 @@ +/* poppler-qt.h: qt interface to poppler + * Copyright (C) 2005, Albert Astals Cid + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2, or (at your option) + * any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA. + */ + +#include "poppler-qt.h" + +namespace Poppler { + +class FontInfoData +{ + public: + TQString fontName; + bool isEmbedded; + bool isSubset; + FontInfo::Type type; +}; + +FontInfo::FontInfo( const TQString &fontName, const bool isEmbedded, const bool isSubset, Type type ) +{ + data = new FontInfoData(); + data->fontName = fontName; + data->isEmbedded = isEmbedded; + data->isSubset = isSubset; + data->type = type; +} + +FontInfo::FontInfo( const FontInfo &fi ) +{ + data = new FontInfoData(); + data->fontName = fi.data->fontName; + data->isEmbedded = fi.data->isEmbedded; + data->isSubset = fi.data->isSubset; + data->type = fi.data->type; +} + +FontInfo::FontInfo() +{ + data = new FontInfoData(); + data->isEmbedded = false; + data->isSubset = false; + data->type = unknown; +} + +FontInfo::~FontInfo() +{ + delete data; +} + +const TQString &FontInfo::name() const +{ + return data->fontName; +} + +bool FontInfo::isEmbedded() const +{ + return data->isEmbedded; +} + +bool FontInfo::isSubset() const +{ + return data->isSubset; +} + +FontInfo::Type FontInfo::type() const +{ + return data->type; +} + +} diff --git a/tdefile-plugins/dependencies/poppler-tqt/poppler-link.cc b/tdefile-plugins/dependencies/poppler-tqt/poppler-link.cc deleted file mode 100644 index ee05eb06..00000000 --- a/tdefile-plugins/dependencies/poppler-tqt/poppler-link.cc +++ /dev/null @@ -1,273 +0,0 @@ -/* poppler-link.cc: qt interface to poppler - * Copyright (C) 2006, 2008 Albert Astals Cid - * Adapting code from - * Copyright (C) 2004 by Enrico Ros - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2, or (at your option) - * any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA. - */ - -#include -#include - -#include - -#include - -namespace Poppler { - - LinkDestination::LinkDestination(const LinkDestinationData &data) - { - bool deleteDest = false; - CONST_064 LinkDest *ld = data.ld; - - if ( data.namedDest && !ld ) - { - deleteDest = true; -# if defined(HAVE_POPPLER_086) - ld = data.doc->doc.findDest( data.namedDest ).get(); -# else - ld = data.doc->doc.findDest( data.namedDest ); -# endif - } - - if (!ld) return; - - if (ld->getKind() == ::destXYZ) m_kind = destXYZ; - else if (ld->getKind() == ::destFit) m_kind = destFit; - else if (ld->getKind() == ::destFitH) m_kind = destFitH; - else if (ld->getKind() == ::destFitV) m_kind = destFitV; - else if (ld->getKind() == ::destFitR) m_kind = destFitR; - else if (ld->getKind() == ::destFitB) m_kind = destFitB; - else if (ld->getKind() == ::destFitBH) m_kind = destFitBH; - else if (ld->getKind() == ::destFitBV) m_kind = destFitBV; - - if ( !ld->isPageRef() ) m_pageNum = ld->getPageNum(); - else - { - Ref ref = ld->getPageRef(); - m_pageNum = data.doc->doc.findPage(FIND_PAGE_ARGS(ref)); - } - double left = ld->getLeft(); - double bottom = ld->getBottom(); - double right = ld->getRight(); - double top = ld->getTop(); - m_zoom = ld->getZoom(); - m_changeLeft = ld->getChangeLeft(); - m_changeTop = ld->getChangeTop(); - m_changeZoom = ld->getChangeZoom(); - - int leftAux = 0, topAux = 0, rightAux = 0, bottomAux = 0; - -#if defined(HAVE_SPLASH) - SplashOutputDev *sod = data.doc->getOutputDev(); - sod->cvtUserToDev( left, top, &leftAux, &topAux ); - sod->cvtUserToDev( right, bottom, &rightAux, &bottomAux ); -#endif - - m_left = leftAux; - m_top = topAux; - m_right = rightAux; - m_bottom = bottomAux; - -# if !defined(HAVE_POPPLER_086) - if (deleteDest) delete ld; -# endif - } - - LinkDestination::LinkDestination(const TQString &description) - { - TQStringList tokens = TQStringList::split(';', description); - m_kind = static_cast(tokens[0].toInt()); - m_pageNum = tokens[1].toInt(); - m_left = tokens[2].toDouble(); - m_bottom = tokens[3].toDouble(); - m_right = tokens[4].toDouble(); - m_top = tokens[5].toDouble(); - m_zoom = tokens[6].toDouble(); - m_changeLeft = static_cast(tokens[7].toInt()); - m_changeTop = static_cast(tokens[8].toInt()); - m_changeZoom = static_cast(tokens[9].toInt()); - } - - LinkDestination::Kind LinkDestination::kind() const - { - return m_kind; - } - - int LinkDestination::pageNumber() const - { - return m_pageNum; - } - - double LinkDestination::left() const - { - return m_left; - } - - double LinkDestination::bottom() const - { - return m_bottom; - } - - double LinkDestination::right() const - { - return m_right; - } - - double LinkDestination::top() const - { - return m_top; - } - - double LinkDestination::zoom() const - { - return m_zoom; - } - - bool LinkDestination::isChangeLeft() const - { - return m_changeLeft; - } - - bool LinkDestination::isChangeTop() const - { - return m_changeTop; - } - - bool LinkDestination::isChangeZoom() const - { - return m_changeZoom; - } - - TQString LinkDestination::toString() const - { - TQString s = TQString::number( (TQ_INT8)m_kind ); - s += ";" + TQString::number( m_pageNum ); - s += ";" + TQString::number( m_left ); - s += ";" + TQString::number( m_bottom ); - s += ";" + TQString::number( m_right ); - s += ";" + TQString::number( m_top ); - s += ";" + TQString::number( m_zoom ); - s += ";" + TQString::number( (TQ_INT8)m_changeLeft ); - s += ";" + TQString::number( (TQ_INT8)m_changeTop ); - s += ";" + TQString::number( (TQ_INT8)m_changeZoom ); - return s; - } - - - // Link - Link::~Link() - { - } - - Link::Link(const TQRect &linkArea) : m_linkArea(linkArea) - { - } - - Link::LinkType Link::linkType() const - { - return None; - } - - TQRect Link::linkArea() const - { - return m_linkArea; - } - - // LinkGoto - LinkGoto::LinkGoto( const TQRect &linkArea, TQString extFileName, const LinkDestination & destination ) : Link(linkArea), m_extFileName(extFileName), m_destination(destination) - { - } - - bool LinkGoto::isExternal() const - { - return !m_extFileName.isEmpty(); - } - - const TQString &LinkGoto::fileName() const - { - return m_extFileName; - } - - const LinkDestination &LinkGoto::destination() const - { - return m_destination; - } - - Link::LinkType LinkGoto::linkType() const - { - return Goto; - } - - // LinkExecute - LinkExecute::LinkExecute( const TQRect &linkArea, const TQString & file, const TQString & params ) : Link(linkArea), m_fileName(file), m_parameters(params) - { - } - - const TQString & LinkExecute::fileName() const - { - return m_fileName; - } - const TQString & LinkExecute::parameters() const - { - return m_parameters; - } - - Link::LinkType LinkExecute::linkType() const - { - return Execute; - } - - // LinkBrowse - LinkBrowse::LinkBrowse( const TQRect &linkArea, const TQString &url ) : Link(linkArea), m_url(url) - { - } - - const TQString & LinkBrowse::url() const - { - return m_url; - } - - Link::LinkType LinkBrowse::linkType() const - { - return Browse; - } - - // LinkAction - LinkAction::LinkAction( const TQRect &linkArea, ActionType actionType ) : Link(linkArea), m_type(actionType) - { - } - - LinkAction::ActionType LinkAction::actionType() const - { - return m_type; - } - - Link::LinkType LinkAction::linkType() const - { - return Action; - } - - // LinkMovie - LinkMovie::LinkMovie( const TQRect &linkArea ) : Link(linkArea) - { - } - - Link::LinkType LinkMovie::linkType() const - { - return Movie; - } - -} diff --git a/tdefile-plugins/dependencies/poppler-tqt/poppler-link.cpp b/tdefile-plugins/dependencies/poppler-tqt/poppler-link.cpp new file mode 100644 index 00000000..99cd8cc9 --- /dev/null +++ b/tdefile-plugins/dependencies/poppler-tqt/poppler-link.cpp @@ -0,0 +1,273 @@ +/* poppler-link.cpp: qt interface to poppler + * Copyright (C) 2006, 2008 Albert Astals Cid + * Adapting code from + * Copyright (C) 2004 by Enrico Ros + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2, or (at your option) + * any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA. + */ + +#include +#include + +#include + +#include + +namespace Poppler { + + LinkDestination::LinkDestination(const LinkDestinationData &data) + { + bool deleteDest = false; + CONST_064 LinkDest *ld = data.ld; + + if ( data.namedDest && !ld ) + { + deleteDest = true; +# if defined(HAVE_POPPLER_086) + ld = data.doc->doc.findDest( data.namedDest ).get(); +# else + ld = data.doc->doc.findDest( data.namedDest ); +# endif + } + + if (!ld) return; + + if (ld->getKind() == ::destXYZ) m_kind = destXYZ; + else if (ld->getKind() == ::destFit) m_kind = destFit; + else if (ld->getKind() == ::destFitH) m_kind = destFitH; + else if (ld->getKind() == ::destFitV) m_kind = destFitV; + else if (ld->getKind() == ::destFitR) m_kind = destFitR; + else if (ld->getKind() == ::destFitB) m_kind = destFitB; + else if (ld->getKind() == ::destFitBH) m_kind = destFitBH; + else if (ld->getKind() == ::destFitBV) m_kind = destFitBV; + + if ( !ld->isPageRef() ) m_pageNum = ld->getPageNum(); + else + { + Ref ref = ld->getPageRef(); + m_pageNum = data.doc->doc.findPage(FIND_PAGE_ARGS(ref)); + } + double left = ld->getLeft(); + double bottom = ld->getBottom(); + double right = ld->getRight(); + double top = ld->getTop(); + m_zoom = ld->getZoom(); + m_changeLeft = ld->getChangeLeft(); + m_changeTop = ld->getChangeTop(); + m_changeZoom = ld->getChangeZoom(); + + int leftAux = 0, topAux = 0, rightAux = 0, bottomAux = 0; + +#if defined(HAVE_SPLASH) + SplashOutputDev *sod = data.doc->getOutputDev(); + sod->cvtUserToDev( left, top, &leftAux, &topAux ); + sod->cvtUserToDev( right, bottom, &rightAux, &bottomAux ); +#endif + + m_left = leftAux; + m_top = topAux; + m_right = rightAux; + m_bottom = bottomAux; + +# if !defined(HAVE_POPPLER_086) + if (deleteDest) delete ld; +# endif + } + + LinkDestination::LinkDestination(const TQString &description) + { + TQStringList tokens = TQStringList::split(';', description); + m_kind = static_cast(tokens[0].toInt()); + m_pageNum = tokens[1].toInt(); + m_left = tokens[2].toDouble(); + m_bottom = tokens[3].toDouble(); + m_right = tokens[4].toDouble(); + m_top = tokens[5].toDouble(); + m_zoom = tokens[6].toDouble(); + m_changeLeft = static_cast(tokens[7].toInt()); + m_changeTop = static_cast(tokens[8].toInt()); + m_changeZoom = static_cast(tokens[9].toInt()); + } + + LinkDestination::Kind LinkDestination::kind() const + { + return m_kind; + } + + int LinkDestination::pageNumber() const + { + return m_pageNum; + } + + double LinkDestination::left() const + { + return m_left; + } + + double LinkDestination::bottom() const + { + return m_bottom; + } + + double LinkDestination::right() const + { + return m_right; + } + + double LinkDestination::top() const + { + return m_top; + } + + double LinkDestination::zoom() const + { + return m_zoom; + } + + bool LinkDestination::isChangeLeft() const + { + return m_changeLeft; + } + + bool LinkDestination::isChangeTop() const + { + return m_changeTop; + } + + bool LinkDestination::isChangeZoom() const + { + return m_changeZoom; + } + + TQString LinkDestination::toString() const + { + TQString s = TQString::number( (TQ_INT8)m_kind ); + s += ";" + TQString::number( m_pageNum ); + s += ";" + TQString::number( m_left ); + s += ";" + TQString::number( m_bottom ); + s += ";" + TQString::number( m_right ); + s += ";" + TQString::number( m_top ); + s += ";" + TQString::number( m_zoom ); + s += ";" + TQString::number( (TQ_INT8)m_changeLeft ); + s += ";" + TQString::number( (TQ_INT8)m_changeTop ); + s += ";" + TQString::number( (TQ_INT8)m_changeZoom ); + return s; + } + + + // Link + Link::~Link() + { + } + + Link::Link(const TQRect &linkArea) : m_linkArea(linkArea) + { + } + + Link::LinkType Link::linkType() const + { + return None; + } + + TQRect Link::linkArea() const + { + return m_linkArea; + } + + // LinkGoto + LinkGoto::LinkGoto( const TQRect &linkArea, TQString extFileName, const LinkDestination & destination ) : Link(linkArea), m_extFileName(extFileName), m_destination(destination) + { + } + + bool LinkGoto::isExternal() const + { + return !m_extFileName.isEmpty(); + } + + const TQString &LinkGoto::fileName() const + { + return m_extFileName; + } + + const LinkDestination &LinkGoto::destination() const + { + return m_destination; + } + + Link::LinkType LinkGoto::linkType() const + { + return Goto; + } + + // LinkExecute + LinkExecute::LinkExecute( const TQRect &linkArea, const TQString & file, const TQString & params ) : Link(linkArea), m_fileName(file), m_parameters(params) + { + } + + const TQString & LinkExecute::fileName() const + { + return m_fileName; + } + const TQString & LinkExecute::parameters() const + { + return m_parameters; + } + + Link::LinkType LinkExecute::linkType() const + { + return Execute; + } + + // LinkBrowse + LinkBrowse::LinkBrowse( const TQRect &linkArea, const TQString &url ) : Link(linkArea), m_url(url) + { + } + + const TQString & LinkBrowse::url() const + { + return m_url; + } + + Link::LinkType LinkBrowse::linkType() const + { + return Browse; + } + + // LinkAction + LinkAction::LinkAction( const TQRect &linkArea, ActionType actionType ) : Link(linkArea), m_type(actionType) + { + } + + LinkAction::ActionType LinkAction::actionType() const + { + return m_type; + } + + Link::LinkType LinkAction::linkType() const + { + return Action; + } + + // LinkMovie + LinkMovie::LinkMovie( const TQRect &linkArea ) : Link(linkArea) + { + } + + Link::LinkType LinkMovie::linkType() const + { + return Movie; + } + +} diff --git a/tdefile-plugins/dependencies/poppler-tqt/poppler-page-transition.cc b/tdefile-plugins/dependencies/poppler-tqt/poppler-page-transition.cc deleted file mode 100644 index cde8818d..00000000 --- a/tdefile-plugins/dependencies/poppler-tqt/poppler-page-transition.cc +++ /dev/null @@ -1,95 +0,0 @@ -/* PageTransition.cc - * Copyright (C) 2005, Net Integration Technologies, Inc. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2, or (at your option) - * any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA. - */ - -#include "PageTransition.h" -#include "poppler-page-transition.h" -#include "poppler-page-transition-private.h" - -namespace Poppler { - -class PageTransitionData -{ - public: - PageTransitionData(Object *trans) - { - pt = new ::PageTransition(trans); - } - - PageTransitionData(const PageTransitionData &ptd) - { - pt = new ::PageTransition(*ptd.pt); - } - - ~PageTransitionData() - { - delete pt; - } - - ::PageTransition *pt; -}; - -PageTransition::PageTransition(const PageTransitionParams ¶ms) -{ - data = new PageTransitionData(params.dictObj); -} - -PageTransition::PageTransition(const PageTransition &pt) -{ - data = new PageTransitionData(*pt.data); -} - -PageTransition::~PageTransition() -{ - delete data; -} - -PageTransition::Type PageTransition::type() const -{ - return (Poppler::PageTransition::Type)data->pt->getType(); -} - -int PageTransition::duration() const -{ - return data->pt->getDuration(); -} - -PageTransition::Alignment PageTransition::alignment() const -{ - return (Poppler::PageTransition::Alignment)data->pt->getAlignment(); -} - -PageTransition::Direction PageTransition::direction() const -{ - return (Poppler::PageTransition::Direction)data->pt->getDirection(); -} - -int PageTransition::angle() const -{ - return data->pt->getAngle(); -} - -double PageTransition::scale() const -{ - return data->pt->getScale(); -} -bool PageTransition::isRectangular() const -{ - return data->pt->isRectangular(); -} - -} diff --git a/tdefile-plugins/dependencies/poppler-tqt/poppler-page-transition.cpp b/tdefile-plugins/dependencies/poppler-tqt/poppler-page-transition.cpp new file mode 100644 index 00000000..015d17eb --- /dev/null +++ b/tdefile-plugins/dependencies/poppler-tqt/poppler-page-transition.cpp @@ -0,0 +1,95 @@ +/* PageTransition.cpp + * Copyright (C) 2005, Net Integration Technologies, Inc. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2, or (at your option) + * any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA. + */ + +#include "PageTransition.h" +#include "poppler-page-transition.h" +#include "poppler-page-transition-private.h" + +namespace Poppler { + +class PageTransitionData +{ + public: + PageTransitionData(Object *trans) + { + pt = new ::PageTransition(trans); + } + + PageTransitionData(const PageTransitionData &ptd) + { + pt = new ::PageTransition(*ptd.pt); + } + + ~PageTransitionData() + { + delete pt; + } + + ::PageTransition *pt; +}; + +PageTransition::PageTransition(const PageTransitionParams ¶ms) +{ + data = new PageTransitionData(params.dictObj); +} + +PageTransition::PageTransition(const PageTransition &pt) +{ + data = new PageTransitionData(*pt.data); +} + +PageTransition::~PageTransition() +{ + delete data; +} + +PageTransition::Type PageTransition::type() const +{ + return (Poppler::PageTransition::Type)data->pt->getType(); +} + +int PageTransition::duration() const +{ + return data->pt->getDuration(); +} + +PageTransition::Alignment PageTransition::alignment() const +{ + return (Poppler::PageTransition::Alignment)data->pt->getAlignment(); +} + +PageTransition::Direction PageTransition::direction() const +{ + return (Poppler::PageTransition::Direction)data->pt->getDirection(); +} + +int PageTransition::angle() const +{ + return data->pt->getAngle(); +} + +double PageTransition::scale() const +{ + return data->pt->getScale(); +} +bool PageTransition::isRectangular() const +{ + return data->pt->isRectangular(); +} + +} diff --git a/tdefile-plugins/dependencies/poppler-tqt/poppler-page.cc b/tdefile-plugins/dependencies/poppler-tqt/poppler-page.cc deleted file mode 100644 index 4293b7ce..00000000 --- a/tdefile-plugins/dependencies/poppler-tqt/poppler-page.cc +++ /dev/null @@ -1,377 +0,0 @@ -/* poppler-page.cc: qt interface to poppler - * Copyright (C) 2005, Net Integration Technologies, Inc. - * Copyright (C) 2005-2006, Albert Astals Cid - * Copyright (C) 2005, Tobias Koening - * Copyright (C) 2005, Stefan Kebekus - * Copyright (C) 2006, Wilfried Huss - * Copyright (C) 2006, Jerry Epplin - * Copyright (C) 2007, 2010, Pino Toscano - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2, or (at your option) - * any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA. - */ - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#if defined(HAVE_SPLASH) -#include -#include -#endif - -#include "poppler-private.h" -#include "poppler-page-transition-private.h" - -namespace Poppler { - -class PageData { - public: - const Document *doc; - int index; - PageTransition *transition; -}; - -Page::Page(const Document *doc, int index) { - data = new PageData(); - data->index = index; - data->doc = doc; - data->transition = 0; -} - -Page::~Page() -{ - delete data->transition; - delete data; -} - -void Page::renderToPixmap(TQPixmap **q, int x, int y, int w, int h, bool doLinks) const -{ - renderToPixmap(q, x, y, w, h, 72.0, 72.0, doLinks); -} - -void Page::renderToPixmap(TQPixmap **q, int x, int y, int w, int h, double xres, double yres, bool doLinks) const -{ - TQImage img = renderToImage(xres, yres, doLinks); - *q = new TQPixmap( img ); -} - -TQImage Page::renderToImage(double xres, double yres, bool doLinks) const -{ -#if defined(HAVE_SPLASH) - SplashOutputDev *output_dev; - SplashBitmap *bitmap; - SplashColorPtr color_ptr; - output_dev = data->doc->data->getOutputDev(); - - data->doc->data->doc.displayPageSlice(output_dev, data->index + 1, xres, yres, - 0, false, true, false, -1, -1, -1, -1); - bitmap = output_dev->getBitmap (); - color_ptr = bitmap->getDataPtr (); - int bw = output_dev->getBitmap()->getWidth(); - int bh = output_dev->getBitmap()->getHeight(); - SplashColorPtr dataPtr = output_dev->getBitmap()->getDataPtr(); - - if (TQImage::BigEndian == TQImage::systemByteOrder()) - { - uchar c; - int count = bw * bh * 4; - for (int k = 0; k < count; k += 4) - { - c = dataPtr[k]; - dataPtr[k] = dataPtr[k+3]; - dataPtr[k+3] = c; - - c = dataPtr[k+1]; - dataPtr[k+1] = dataPtr[k+2]; - dataPtr[k+2] = c; - } - } - - // construct a qimage SHARING the raw bitmap data in memory - TQImage img( dataPtr, bw, bh, 32, 0, 0, TQImage::IgnoreEndian ); - img = img.copy(); - // unload underlying xpdf bitmap - output_dev->startPage( 0, NULL ); - - return img; -#else - (void)xres; - (void)xres; - (void)doLinks; - - return TQImage(); -#endif -} - -TQString Page::getText(const Rectangle &r) const -{ - TextOutputDev *output_dev; - GooString *s; - const PDFRectangle *rect; - TQString result; - ::Page *p; - -#if defined(HAVE_POPPLER_058) || 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); -#endif - data->doc->data->doc.displayPageSlice(output_dev, data->index + 1, 72, 72, - 0, false, false, false, -1, -1, -1, -1); - p = data->doc->data->doc.getCatalog()->getPage(data->index + 1); - if (r.isNull()) - { - rect = p->getCropBox(); - s = output_dev->getText(rect->x1, rect->y1, rect->x2, rect->y2); - } - else - { - double height, y1, y2; - height = p->getCropHeight(); - y1 = height - r.m_y2; - y2 = height - r.m_y1; - s = output_dev->getText(r.m_x1, y1, r.m_x2, y2); - } - - result = TQString::fromUtf8(s->GOO_GET_CSTR()); - - delete output_dev; - delete s; - return result; -} - -TQValueList Page::textList() const -{ - TextOutputDev *output_dev; - - TQValueList output_list; - -#if defined(HAVE_POPPLER_058) || 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); -#endif - - data->doc->data->doc.displayPageSlice(output_dev, data->index + 1, 72, 72, - 0, false, false, false, -1, -1, -1, -1); - - TextWordList *word_list = output_dev->makeWordList(); - - if (!word_list) { - delete output_dev; - return output_list; - } - - for (int i = 0; i < word_list->getLength(); i++) { - TextWord *word = word_list->get(i); - GooString *word_str = word->getText(); - TQString string = TQString::fromUtf8(word_str->GOO_GET_CSTR()); - delete word_str; - double xMin, yMin, xMax, yMax; - word->getBBox(&xMin, &yMin, &xMax, &yMax); - - TextBox* text_box = new TextBox(string, Rectangle(xMin, yMin, xMax, yMax)); - - output_list.append(text_box); - } - - delete word_list; - delete output_dev; - - return output_list; -} - -PageTransition *Page::getTransition() const -{ - if (!data->transition) - { - Object o; - PageTransitionParams params; -# if defined(HAVE_POPPLER_058) - 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_058) - o.free(); -# endif - } - return data->transition; -} - -TQSize Page::pageSize() const -{ - ::Page *p; - - p = data->doc->data->doc.getCatalog()->getPage(data->index + 1); - if ( ( Page::Landscape == orientation() ) || (Page::Seascape == orientation() ) ) { - return TQSize( (int)p->getCropHeight(), (int)p->getCropWidth() ); - } else { - return TQSize( (int)p->getCropWidth(), (int)p->getCropHeight() ); - } -} - -Page::Orientation Page::orientation() const -{ - ::Page *p = data->doc->data->doc.getCatalog()->getPage(data->index + 1); - - int rotation = p->getRotate(); - switch (rotation) { - case 90: - return Page::Landscape; - break; - case 180: - return Page::UpsideDown; - break; - case 270: - return Page::Seascape; - break; - default: - return Page::Portrait; - } -} - -TQValueList Page::links() const -{ - TQValueList popplerLinks; - -#if defined(HAVE_SPLASH) - Links *xpdfLinks = data->doc->data->doc.getLinks(data->index + 1); - for (int i = 0; i < xpdfLinks->getNumLinks(); ++i) - { - ::Link *xpdfLink = xpdfLinks->getLink(i); - - double left, top, right, bottom; - int leftAux, topAux, rightAux, bottomAux; - xpdfLink->getRect( &left, &top, &right, &bottom ); - TQRect linkArea; - - data->doc->data->m_outputDev->cvtUserToDev( left, top, &leftAux, &topAux ); - data->doc->data->m_outputDev->cvtUserToDev( right, bottom, &rightAux, &bottomAux ); - linkArea.setLeft(leftAux); - linkArea.setTop(topAux); - linkArea.setRight(rightAux); - linkArea.setBottom(bottomAux); - - if (!xpdfLink->isOk()) continue; - - Link *popplerLink = NULL; - ::LinkAction *a = xpdfLink->getAction(); - if ( a ) - { - switch ( a->getKind() ) - { - case actionGoTo: - { - LinkGoTo * g = (LinkGoTo *) a; - // create link: no ext file, namedDest, object pointer - popplerLink = new LinkGoto( linkArea, TQString(), LinkDestination( LinkDestinationData(g->getDest(), g->getNamedDest(), data->doc->data ) ) ); - } - break; - - case actionGoToR: - { - LinkGoToR * g = (LinkGoToR *) a; - // copy link file - const TQString fileName = UnicodeParsedString( g->getFileName() ); - // ceate link: fileName, namedDest, object pointer - popplerLink = new LinkGoto( linkArea, fileName, LinkDestination( LinkDestinationData(g->getDest(), g->getNamedDest(), data->doc->data ) ) ); - } - break; - - case actionLaunch: - { - LinkLaunch * e = (LinkLaunch *)a; - GooString * p = e->getParams(); - popplerLink = new LinkExecute( linkArea, e->getFileName()->GOO_GET_CSTR(), p ? p->GOO_GET_CSTR() : 0 ); - } - break; - - case actionNamed: - { - const char * name = ((LinkNamed *)a)->getName()->GOO_GET_CSTR(); - if ( !strcmp( name, "NextPage" ) ) - popplerLink = new LinkAction( linkArea, LinkAction::PageNext ); - else if ( !strcmp( name, "PrevPage" ) ) - popplerLink = new LinkAction( linkArea, LinkAction::PagePrev ); - else if ( !strcmp( name, "FirstPage" ) ) - popplerLink = new LinkAction( linkArea, LinkAction::PageFirst ); - else if ( !strcmp( name, "LastPage" ) ) - popplerLink = new LinkAction( linkArea, LinkAction::PageLast ); - else if ( !strcmp( name, "GoBack" ) ) - popplerLink = new LinkAction( linkArea, LinkAction::HistoryBack ); - else if ( !strcmp( name, "GoForward" ) ) - popplerLink = new LinkAction( linkArea, LinkAction::HistoryForward ); - else if ( !strcmp( name, "Quit" ) ) - popplerLink = new LinkAction( linkArea, LinkAction::Quit ); - else if ( !strcmp( name, "GoToPage" ) ) - popplerLink = new LinkAction( linkArea, LinkAction::GoToPage ); - else if ( !strcmp( name, "Find" ) ) - popplerLink = new LinkAction( linkArea, LinkAction::Find ); - else if ( !strcmp( name, "FullScreen" ) ) - popplerLink = new LinkAction( linkArea, LinkAction::Presentation ); - else if ( !strcmp( name, "Close" ) ) - { - // acroread closes the document always, doesnt care whether - // its presentation mode or not - // popplerLink = new LinkAction( linkArea, LinkAction::EndPresentation ); - popplerLink = new LinkAction( linkArea, LinkAction::Close ); - } - else - { - // TODO - } - } - break; - - case actionURI: - { - popplerLink = new LinkBrowse( linkArea, ((LinkURI *)a)->getURI()->GOO_GET_CSTR() ); - } - break; - - case actionMovie: - case actionSound: - case actionRendition: - case actionJavaScript: - case actionOCGState: - break; - - case actionUnknown: - break; - } - } - - if (popplerLink) - { - popplerLinks.append(popplerLink); - } - } - - delete xpdfLinks; -#endif - - return popplerLinks; -} - -} diff --git a/tdefile-plugins/dependencies/poppler-tqt/poppler-page.cpp b/tdefile-plugins/dependencies/poppler-tqt/poppler-page.cpp new file mode 100644 index 00000000..426b750f --- /dev/null +++ b/tdefile-plugins/dependencies/poppler-tqt/poppler-page.cpp @@ -0,0 +1,377 @@ +/* poppler-page.cpp: qt interface to poppler + * Copyright (C) 2005, Net Integration Technologies, Inc. + * Copyright (C) 2005-2006, Albert Astals Cid + * Copyright (C) 2005, Tobias Koening + * Copyright (C) 2005, Stefan Kebekus + * Copyright (C) 2006, Wilfried Huss + * Copyright (C) 2006, Jerry Epplin + * Copyright (C) 2007, 2010, Pino Toscano + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2, or (at your option) + * any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA. + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#if defined(HAVE_SPLASH) +#include +#include +#endif + +#include "poppler-private.h" +#include "poppler-page-transition-private.h" + +namespace Poppler { + +class PageData { + public: + const Document *doc; + int index; + PageTransition *transition; +}; + +Page::Page(const Document *doc, int index) { + data = new PageData(); + data->index = index; + data->doc = doc; + data->transition = 0; +} + +Page::~Page() +{ + delete data->transition; + delete data; +} + +void Page::renderToPixmap(TQPixmap **q, int x, int y, int w, int h, bool doLinks) const +{ + renderToPixmap(q, x, y, w, h, 72.0, 72.0, doLinks); +} + +void Page::renderToPixmap(TQPixmap **q, int x, int y, int w, int h, double xres, double yres, bool doLinks) const +{ + TQImage img = renderToImage(xres, yres, doLinks); + *q = new TQPixmap( img ); +} + +TQImage Page::renderToImage(double xres, double yres, bool doLinks) const +{ +#if defined(HAVE_SPLASH) + SplashOutputDev *output_dev; + SplashBitmap *bitmap; + SplashColorPtr color_ptr; + output_dev = data->doc->data->getOutputDev(); + + data->doc->data->doc.displayPageSlice(output_dev, data->index + 1, xres, yres, + 0, false, true, false, -1, -1, -1, -1); + bitmap = output_dev->getBitmap (); + color_ptr = bitmap->getDataPtr (); + int bw = output_dev->getBitmap()->getWidth(); + int bh = output_dev->getBitmap()->getHeight(); + SplashColorPtr dataPtr = output_dev->getBitmap()->getDataPtr(); + + if (TQImage::BigEndian == TQImage::systemByteOrder()) + { + uchar c; + int count = bw * bh * 4; + for (int k = 0; k < count; k += 4) + { + c = dataPtr[k]; + dataPtr[k] = dataPtr[k+3]; + dataPtr[k+3] = c; + + c = dataPtr[k+1]; + dataPtr[k+1] = dataPtr[k+2]; + dataPtr[k+2] = c; + } + } + + // construct a qimage SHARING the raw bitmap data in memory + TQImage img( dataPtr, bw, bh, 32, 0, 0, TQImage::IgnoreEndian ); + img = img.copy(); + // unload underlying xpdf bitmap + output_dev->startPage( 0, NULL ); + + return img; +#else + (void)xres; + (void)xres; + (void)doLinks; + + return TQImage(); +#endif +} + +TQString Page::getText(const Rectangle &r) const +{ + TextOutputDev *output_dev; + GooString *s; + const PDFRectangle *rect; + TQString result; + ::Page *p; + +#if defined(HAVE_POPPLER_058) || 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); +#endif + data->doc->data->doc.displayPageSlice(output_dev, data->index + 1, 72, 72, + 0, false, false, false, -1, -1, -1, -1); + p = data->doc->data->doc.getCatalog()->getPage(data->index + 1); + if (r.isNull()) + { + rect = p->getCropBox(); + s = output_dev->getText(rect->x1, rect->y1, rect->x2, rect->y2); + } + else + { + double height, y1, y2; + height = p->getCropHeight(); + y1 = height - r.m_y2; + y2 = height - r.m_y1; + s = output_dev->getText(r.m_x1, y1, r.m_x2, y2); + } + + result = TQString::fromUtf8(s->GOO_GET_CSTR()); + + delete output_dev; + delete s; + return result; +} + +TQValueList Page::textList() const +{ + TextOutputDev *output_dev; + + TQValueList output_list; + +#if defined(HAVE_POPPLER_058) || 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); +#endif + + data->doc->data->doc.displayPageSlice(output_dev, data->index + 1, 72, 72, + 0, false, false, false, -1, -1, -1, -1); + + TextWordList *word_list = output_dev->makeWordList(); + + if (!word_list) { + delete output_dev; + return output_list; + } + + for (int i = 0; i < word_list->getLength(); i++) { + TextWord *word = word_list->get(i); + GooString *word_str = word->getText(); + TQString string = TQString::fromUtf8(word_str->GOO_GET_CSTR()); + delete word_str; + double xMin, yMin, xMax, yMax; + word->getBBox(&xMin, &yMin, &xMax, &yMax); + + TextBox* text_box = new TextBox(string, Rectangle(xMin, yMin, xMax, yMax)); + + output_list.append(text_box); + } + + delete word_list; + delete output_dev; + + return output_list; +} + +PageTransition *Page::getTransition() const +{ + if (!data->transition) + { + Object o; + PageTransitionParams params; +# if defined(HAVE_POPPLER_058) + 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_058) + o.free(); +# endif + } + return data->transition; +} + +TQSize Page::pageSize() const +{ + ::Page *p; + + p = data->doc->data->doc.getCatalog()->getPage(data->index + 1); + if ( ( Page::Landscape == orientation() ) || (Page::Seascape == orientation() ) ) { + return TQSize( (int)p->getCropHeight(), (int)p->getCropWidth() ); + } else { + return TQSize( (int)p->getCropWidth(), (int)p->getCropHeight() ); + } +} + +Page::Orientation Page::orientation() const +{ + ::Page *p = data->doc->data->doc.getCatalog()->getPage(data->index + 1); + + int rotation = p->getRotate(); + switch (rotation) { + case 90: + return Page::Landscape; + break; + case 180: + return Page::UpsideDown; + break; + case 270: + return Page::Seascape; + break; + default: + return Page::Portrait; + } +} + +TQValueList Page::links() const +{ + TQValueList popplerLinks; + +#if defined(HAVE_SPLASH) + Links *xpdfLinks = data->doc->data->doc.getLinks(data->index + 1); + for (int i = 0; i < xpdfLinks->getNumLinks(); ++i) + { + ::Link *xpdfLink = xpdfLinks->getLink(i); + + double left, top, right, bottom; + int leftAux, topAux, rightAux, bottomAux; + xpdfLink->getRect( &left, &top, &right, &bottom ); + TQRect linkArea; + + data->doc->data->m_outputDev->cvtUserToDev( left, top, &leftAux, &topAux ); + data->doc->data->m_outputDev->cvtUserToDev( right, bottom, &rightAux, &bottomAux ); + linkArea.setLeft(leftAux); + linkArea.setTop(topAux); + linkArea.setRight(rightAux); + linkArea.setBottom(bottomAux); + + if (!xpdfLink->isOk()) continue; + + Link *popplerLink = NULL; + ::LinkAction *a = xpdfLink->getAction(); + if ( a ) + { + switch ( a->getKind() ) + { + case actionGoTo: + { + LinkGoTo * g = (LinkGoTo *) a; + // create link: no ext file, namedDest, object pointer + popplerLink = new LinkGoto( linkArea, TQString(), LinkDestination( LinkDestinationData(g->getDest(), g->getNamedDest(), data->doc->data ) ) ); + } + break; + + case actionGoToR: + { + LinkGoToR * g = (LinkGoToR *) a; + // copy link file + const TQString fileName = UnicodeParsedString( g->getFileName() ); + // ceate link: fileName, namedDest, object pointer + popplerLink = new LinkGoto( linkArea, fileName, LinkDestination( LinkDestinationData(g->getDest(), g->getNamedDest(), data->doc->data ) ) ); + } + break; + + case actionLaunch: + { + LinkLaunch * e = (LinkLaunch *)a; + GooString * p = e->getParams(); + popplerLink = new LinkExecute( linkArea, e->getFileName()->GOO_GET_CSTR(), p ? p->GOO_GET_CSTR() : 0 ); + } + break; + + case actionNamed: + { + const char * name = ((LinkNamed *)a)->getName()->GOO_GET_CSTR(); + if ( !strcmp( name, "NextPage" ) ) + popplerLink = new LinkAction( linkArea, LinkAction::PageNext ); + else if ( !strcmp( name, "PrevPage" ) ) + popplerLink = new LinkAction( linkArea, LinkAction::PagePrev ); + else if ( !strcmp( name, "FirstPage" ) ) + popplerLink = new LinkAction( linkArea, LinkAction::PageFirst ); + else if ( !strcmp( name, "LastPage" ) ) + popplerLink = new LinkAction( linkArea, LinkAction::PageLast ); + else if ( !strcmp( name, "GoBack" ) ) + popplerLink = new LinkAction( linkArea, LinkAction::HistoryBack ); + else if ( !strcmp( name, "GoForward" ) ) + popplerLink = new LinkAction( linkArea, LinkAction::HistoryForward ); + else if ( !strcmp( name, "Quit" ) ) + popplerLink = new LinkAction( linkArea, LinkAction::Quit ); + else if ( !strcmp( name, "GoToPage" ) ) + popplerLink = new LinkAction( linkArea, LinkAction::GoToPage ); + else if ( !strcmp( name, "Find" ) ) + popplerLink = new LinkAction( linkArea, LinkAction::Find ); + else if ( !strcmp( name, "FullScreen" ) ) + popplerLink = new LinkAction( linkArea, LinkAction::Presentation ); + else if ( !strcmp( name, "Close" ) ) + { + // acroread closes the document always, doesnt care whether + // its presentation mode or not + // popplerLink = new LinkAction( linkArea, LinkAction::EndPresentation ); + popplerLink = new LinkAction( linkArea, LinkAction::Close ); + } + else + { + // TODO + } + } + break; + + case actionURI: + { + popplerLink = new LinkBrowse( linkArea, ((LinkURI *)a)->getURI()->GOO_GET_CSTR() ); + } + break; + + case actionMovie: + case actionSound: + case actionRendition: + case actionJavaScript: + case actionOCGState: + break; + + case actionUnknown: + break; + } + } + + if (popplerLink) + { + popplerLinks.append(popplerLink); + } + } + + delete xpdfLinks; +#endif + + return popplerLinks; +} + +} diff --git a/tdefile-plugins/dependencies/poppler-tqt/poppler-private.cc b/tdefile-plugins/dependencies/poppler-tqt/poppler-private.cc deleted file mode 100644 index 059bf1c0..00000000 --- a/tdefile-plugins/dependencies/poppler-tqt/poppler-private.cc +++ /dev/null @@ -1,152 +0,0 @@ -/* poppler-private.h: qt interface to poppler - * Copyright (C) 2005, Net Integration Technologies, Inc. - * Copyright (C) 2005-2008, Albert Astals Cid - * Copyright (C) 2006, Kristian Høgsberg - * Copyright (C) 2006, Wilfried Huss - * Copyright (C) 2007, Pino Toscano - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2, or (at your option) - * any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA. - */ - -#include "poppler-private.h" -#include "poppler-link-qt3.h" - -#include - -#include -#include - -namespace Poppler { - -/* borrowed from kpdf */ -TQString unicodeToTQString(CONST_064 Unicode* u, int len) -{ - TQString ret; - ret.setLength(len); - TQChar* qch = (TQChar*) ret.unicode(); - for (;len;--len) - *qch++ = (TQChar) *u++; - return ret; -} - -TQString UnicodeParsedString(CONST_064 GooString *s1) -{ - GBool isUnicode; - int i; - Unicode u; - TQString result; - if ( ( s1->getChar(0) & 0xff ) == 0xfe && ( s1->getChar(1) & 0xff ) == 0xff ) - { - isUnicode = gTrue; - i = 2; - } - else - { - isUnicode = gFalse; - i = 0; - } - while ( i < s1->getLength() ) - { - if ( isUnicode ) - { - u = ( ( s1->getChar(i) & 0xff ) << 8 ) | ( s1->getChar(i+1) & 0xff ); - i += 2; - } - else - { - u = s1->getChar(i) & 0xff; - ++i; - } - result += unicodeToTQString( &u, 1 ); - } - return result; -} - -GooString *TQStringToGooString(const TQString &s) -{ - int len = s.length(); - char *cstring = (char *)gmallocn(s.length(), sizeof(char)); - for (int i = 0; i < len; ++i) - cstring[i] = s.at(i).unicode(); - GooString *ret = new GooString(cstring, len); - gfree(cstring); - return ret; -} - - -void DocumentData::addTocChildren( TQDomDocument * docSyn, TQDomNode * parent, OUTLINE_ITEMS_TYPE * items ) -{ - int numItems = OUTLINE_ITEMS_LENGTH(items); - for ( int i = 0; i < numItems; ++i ) - { - // iterate over every object in 'items' - OutlineItem * outlineItem = -#ifdef HAVE_POPPLER_076 - (*items)[i]; -#else - (OutlineItem *)items->get( i ); -#endif - - // 1. create element using outlineItem's title as tagName - TQString name; - CONST_064 Unicode * uniChar = outlineItem->getTitle(); - int titleLength = outlineItem->getTitleLength(); - name = unicodeToTQString(uniChar, titleLength); - if ( name.isEmpty() ) - continue; - - TQDomElement item = docSyn->createElement( name ); - parent->appendChild( item ); - - // 2. find the page the link refers to - CONST_064 ::LinkAction * a = outlineItem->getAction(); - if ( a && ( a->getKind() == actionGoTo || a->getKind() == actionGoToR ) ) - { - // page number is contained/referenced in a LinkGoTo - CONST_064 LinkGoTo * g = static_cast< CONST_064 LinkGoTo * >( a ); - CONST_064 LinkDest * destination = g->getDest(); - if ( !destination && g->getNamedDest() ) - { - // no 'destination' but an internal 'named reference'. we could - // get the destination for the page now, but it's VERY time consuming, - // so better storing the reference and provide the viewport on demand - CONST_064 GooString *s = g->getNamedDest(); - TQChar *charArray = new TQChar[s->getLength()]; - for (int i = 0; i < s->getLength(); ++i) charArray[i] = TQChar(s->GOO_GET_CSTR()[i]); - TQString aux(charArray, s->getLength()); - item.setAttribute( "DestinationName", aux ); - delete[] charArray; - } - else if ( destination && destination->isOk() ) - { - LinkDestinationData ldd(destination, NULL, this); - item.setAttribute( "Destination", LinkDestination(ldd).toString() ); - } - if ( a->getKind() == actionGoToR ) - { - CONST_064 LinkGoToR * g2 = static_cast< CONST_064 LinkGoToR * >( a ); - item.setAttribute( "ExternalFileName", g2->getFileName()->GOO_GET_CSTR() ); - } - } - - // 3. recursively descend over children - outlineItem->open(); - OUTLINE_ITEMS_TYPE * children = outlineItem->getKids(); - if ( children ) - addTocChildren( docSyn, &item, children ); - } -} - -} diff --git a/tdefile-plugins/dependencies/poppler-tqt/poppler-private.cpp b/tdefile-plugins/dependencies/poppler-tqt/poppler-private.cpp new file mode 100644 index 00000000..059bf1c0 --- /dev/null +++ b/tdefile-plugins/dependencies/poppler-tqt/poppler-private.cpp @@ -0,0 +1,152 @@ +/* poppler-private.h: qt interface to poppler + * Copyright (C) 2005, Net Integration Technologies, Inc. + * Copyright (C) 2005-2008, Albert Astals Cid + * Copyright (C) 2006, Kristian Høgsberg + * Copyright (C) 2006, Wilfried Huss + * Copyright (C) 2007, Pino Toscano + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2, or (at your option) + * any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA. + */ + +#include "poppler-private.h" +#include "poppler-link-qt3.h" + +#include + +#include +#include + +namespace Poppler { + +/* borrowed from kpdf */ +TQString unicodeToTQString(CONST_064 Unicode* u, int len) +{ + TQString ret; + ret.setLength(len); + TQChar* qch = (TQChar*) ret.unicode(); + for (;len;--len) + *qch++ = (TQChar) *u++; + return ret; +} + +TQString UnicodeParsedString(CONST_064 GooString *s1) +{ + GBool isUnicode; + int i; + Unicode u; + TQString result; + if ( ( s1->getChar(0) & 0xff ) == 0xfe && ( s1->getChar(1) & 0xff ) == 0xff ) + { + isUnicode = gTrue; + i = 2; + } + else + { + isUnicode = gFalse; + i = 0; + } + while ( i < s1->getLength() ) + { + if ( isUnicode ) + { + u = ( ( s1->getChar(i) & 0xff ) << 8 ) | ( s1->getChar(i+1) & 0xff ); + i += 2; + } + else + { + u = s1->getChar(i) & 0xff; + ++i; + } + result += unicodeToTQString( &u, 1 ); + } + return result; +} + +GooString *TQStringToGooString(const TQString &s) +{ + int len = s.length(); + char *cstring = (char *)gmallocn(s.length(), sizeof(char)); + for (int i = 0; i < len; ++i) + cstring[i] = s.at(i).unicode(); + GooString *ret = new GooString(cstring, len); + gfree(cstring); + return ret; +} + + +void DocumentData::addTocChildren( TQDomDocument * docSyn, TQDomNode * parent, OUTLINE_ITEMS_TYPE * items ) +{ + int numItems = OUTLINE_ITEMS_LENGTH(items); + for ( int i = 0; i < numItems; ++i ) + { + // iterate over every object in 'items' + OutlineItem * outlineItem = +#ifdef HAVE_POPPLER_076 + (*items)[i]; +#else + (OutlineItem *)items->get( i ); +#endif + + // 1. create element using outlineItem's title as tagName + TQString name; + CONST_064 Unicode * uniChar = outlineItem->getTitle(); + int titleLength = outlineItem->getTitleLength(); + name = unicodeToTQString(uniChar, titleLength); + if ( name.isEmpty() ) + continue; + + TQDomElement item = docSyn->createElement( name ); + parent->appendChild( item ); + + // 2. find the page the link refers to + CONST_064 ::LinkAction * a = outlineItem->getAction(); + if ( a && ( a->getKind() == actionGoTo || a->getKind() == actionGoToR ) ) + { + // page number is contained/referenced in a LinkGoTo + CONST_064 LinkGoTo * g = static_cast< CONST_064 LinkGoTo * >( a ); + CONST_064 LinkDest * destination = g->getDest(); + if ( !destination && g->getNamedDest() ) + { + // no 'destination' but an internal 'named reference'. we could + // get the destination for the page now, but it's VERY time consuming, + // so better storing the reference and provide the viewport on demand + CONST_064 GooString *s = g->getNamedDest(); + TQChar *charArray = new TQChar[s->getLength()]; + for (int i = 0; i < s->getLength(); ++i) charArray[i] = TQChar(s->GOO_GET_CSTR()[i]); + TQString aux(charArray, s->getLength()); + item.setAttribute( "DestinationName", aux ); + delete[] charArray; + } + else if ( destination && destination->isOk() ) + { + LinkDestinationData ldd(destination, NULL, this); + item.setAttribute( "Destination", LinkDestination(ldd).toString() ); + } + if ( a->getKind() == actionGoToR ) + { + CONST_064 LinkGoToR * g2 = static_cast< CONST_064 LinkGoToR * >( a ); + item.setAttribute( "ExternalFileName", g2->getFileName()->GOO_GET_CSTR() ); + } + } + + // 3. recursively descend over children + outlineItem->open(); + OUTLINE_ITEMS_TYPE * children = outlineItem->getKids(); + if ( children ) + addTocChildren( docSyn, &item, children ); + } +} + +} -- cgit v1.2.1