qt/CMakeLists.txt | 1 qt/Makefile.am | 1 qt/poppler-document.cc | 10 --- qt/poppler-link.cc | 11 ++- qt/poppler-page.cc | 1 qt/poppler-private.cc | 147 +++++++++++++++++++++++++++++++++++++++++++++++++ qt/poppler-private.h | 106 ++--------------------------------- 7 files changed, 163 insertions(+), 114 deletions(-)
New commits: commit bfb975466f0ff78e9e292b6af7cac66e4c331456 Merge: 3e27892... ea3546f... Author: Pino Toscano <[email protected]> Date: Mon Dec 22 00:29:38 2008 +0100 Merge branch 'master' of ssh://[email protected]/git/poppler/poppler commit 3e2789257f5fc4ae0573a0c62ea380d8e83a5bb5 Author: Pino Toscano <[email protected]> Date: Mon Dec 22 00:24:23 2008 +0100 [Qt] deserialize also the value of 'right' diff --git a/qt/poppler-link.cc b/qt/poppler-link.cc index 1be7437..af6d645 100644 --- a/qt/poppler-link.cc +++ b/qt/poppler-link.cc @@ -87,11 +87,12 @@ namespace Poppler { m_pageNum = tokens[1].toInt(); m_left = tokens[2].toDouble(); m_bottom = tokens[3].toDouble(); - m_top = tokens[4].toDouble(); - m_zoom = tokens[5].toDouble(); - m_changeLeft = static_cast<bool>(tokens[6].toInt()); - m_changeTop = static_cast<bool>(tokens[7].toInt()); - m_changeZoom = static_cast<bool>(tokens[8].toInt()); + m_right = tokens[4].toDouble(); + m_top = tokens[5].toDouble(); + m_zoom = tokens[6].toDouble(); + m_changeLeft = static_cast<bool>(tokens[7].toInt()); + m_changeTop = static_cast<bool>(tokens[8].toInt()); + m_changeZoom = static_cast<bool>(tokens[9].toInt()); } LinkDestination::Kind LinkDestination::kind() const commit 7c053ab7623cea1ac650d3e960d2d91a1ef21557 Author: Pino Toscano <[email protected]> Date: Mon Dec 22 00:19:02 2008 +0100 [Qt] move in a .cc file the implementation of the QString<->GooString functions and DocumentData::addTocChildren() diff --git a/qt/CMakeLists.txt b/qt/CMakeLists.txt index f3d0916..b97089b 100644 --- a/qt/CMakeLists.txt +++ b/qt/CMakeLists.txt @@ -11,6 +11,7 @@ set(poppler_qt_SRCS poppler-link.cc poppler-page.cc poppler-page-transition.cc + poppler-private.cc ) add_library(poppler-qt SHARED ${poppler_qt_SRCS}) set_target_properties(poppler-qt PROPERTIES VERSION 2.0.0 SOVERSION 2) diff --git a/qt/Makefile.am b/qt/Makefile.am index 1297659..8827d65 100644 --- a/qt/Makefile.am +++ b/qt/Makefile.am @@ -21,6 +21,7 @@ libpoppler_qt_la_SOURCES = \ poppler-page.cc \ poppler-page-transition.cc \ poppler-page-transition-private.h \ + poppler-private.cc \ poppler-private.h libpoppler_qt_la_LIBADD = \ diff --git a/qt/poppler-document.cc b/qt/poppler-document.cc index 50600ad..4c47e62 100644 --- a/qt/poppler-document.cc +++ b/qt/poppler-document.cc @@ -34,16 +34,6 @@ namespace Poppler { -static GooString *QStringToGooString(const QString &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; -} - Document *Document::load(const QString &filePath) { if (!globalParams) { diff --git a/qt/poppler-page.cc b/qt/poppler-page.cc index 67a8aa7..536babb 100644 --- a/qt/poppler-page.cc +++ b/qt/poppler-page.cc @@ -31,6 +31,7 @@ #include <Catalog.h> #include <ErrorCodes.h> #include <TextOutputDev.h> +#include <Link.h> #if defined(HAVE_SPLASH) #include <SplashOutputDev.h> #include <splash/SplashBitmap.h> diff --git a/qt/poppler-private.cc b/qt/poppler-private.cc new file mode 100644 index 0000000..2388a1b --- /dev/null +++ b/qt/poppler-private.cc @@ -0,0 +1,147 @@ +/* poppler-private.h: qt interface to poppler + * Copyright (C) 2005, Net Integration Technologies, Inc. + * Copyright (C) 2005-2008, Albert Astals Cid <[email protected]> + * Copyright (C) 2006, Kristian Høgsberg <[email protected]> + * Copyright (C) 2006, Wilfried Huss <[email protected]> + * Copyright (C) 2007, Pino Toscano <[email protected]> + * + * 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 <qstring.h> + +#include <Outline.h> +#include <Link.h> + +namespace Poppler { + +/* borrowed from kpdf */ +QString unicodeToQString(Unicode* u, int len) +{ + QString ret; + ret.setLength(len); + QChar* qch = (QChar*) ret.unicode(); + for (;len;--len) + *qch++ = (QChar) *u++; + return ret; +} + +QString UnicodeParsedString(GooString *s1) +{ + GBool isUnicode; + int i; + Unicode u; + QString 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 += unicodeToQString( &u, 1 ); + } + return result; +} + +GooString *QStringToGooString(const QString &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( QDomDocument * docSyn, QDomNode * parent, GooList * items ) +{ + int numItems = items->getLength(); + for ( int i = 0; i < numItems; ++i ) + { + // iterate over every object in 'items' + OutlineItem * outlineItem = (OutlineItem *)items->get( i ); + + // 1. create element using outlineItem's title as tagName + QString name; + Unicode * uniChar = outlineItem->getTitle(); + int titleLength = outlineItem->getTitleLength(); + name = unicodeToQString(uniChar, titleLength); + if ( name.isEmpty() ) + continue; + + QDomElement item = docSyn->createElement( name ); + parent->appendChild( item ); + + // 2. find the page the link refers to + ::LinkAction * a = outlineItem->getAction(); + if ( a && ( a->getKind() == actionGoTo || a->getKind() == actionGoToR ) ) + { + // page number is contained/referenced in a LinkGoTo + LinkGoTo * g = static_cast< LinkGoTo * >( a ); + 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 + GooString *s = g->getNamedDest(); + QChar *charArray = new QChar[s->getLength()]; + for (int i = 0; i < s->getLength(); ++i) charArray[i] = QChar(s->getCString()[i]); + QString 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 ) + { + LinkGoToR * g2 = static_cast< LinkGoToR * >( a ); + item.setAttribute( "ExternalFileName", g2->getFileName()->getCString() ); + } + } + + // 3. recursively descend over children + outlineItem->open(); + GooList * children = outlineItem->getKids(); + if ( children ) + addTocChildren( docSyn, &item, children ); + } +} + +} diff --git a/qt/poppler-private.h b/qt/poppler-private.h index 21a147f..4351d68 100644 --- a/qt/poppler-private.h +++ b/qt/poppler-private.h @@ -24,8 +24,6 @@ #include <config.h> #include <Object.h> -#include <Outline.h> -#include <Link.h> #include <PDFDoc.h> #include <FontInfo.h> #if defined(HAVE_SPLASH) @@ -36,47 +34,13 @@ class SplashOutputDev; namespace Poppler { -/* borrowed from kpdf */ -static QString unicodeToQString(Unicode* u, int len) { - QString ret; - ret.setLength(len); - QChar* qch = (QChar*) ret.unicode(); - for (;len;--len) - *qch++ = (QChar) *u++; - return ret; -} +class DocumentData; -static QString UnicodeParsedString(GooString *s1) { - GBool isUnicode; - int i; - Unicode u; - QString 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 += unicodeToQString( &u, 1 ); - } - return result; -} +QString unicodeToQString(Unicode* u, int len); + +QString UnicodeParsedString(GooString *s1); + +GooString *QStringToGooString(const QString &s); class LinkDestinationData { public: @@ -117,63 +81,7 @@ class DocumentData { return m_outputDev; } - void addTocChildren( QDomDocument * docSyn, QDomNode * parent, GooList * items ) - { - int numItems = items->getLength(); - for ( int i = 0; i < numItems; ++i ) - { - // iterate over every object in 'items' - OutlineItem * outlineItem = (OutlineItem *)items->get( i ); - - // 1. create element using outlineItem's title as tagName - QString name; - Unicode * uniChar = outlineItem->getTitle(); - int titleLength = outlineItem->getTitleLength(); - name = unicodeToQString(uniChar, titleLength); - if ( name.isEmpty() ) - continue; - - QDomElement item = docSyn->createElement( name ); - parent->appendChild( item ); - - // 2. find the page the link refers to - ::LinkAction * a = outlineItem->getAction(); - if ( a && ( a->getKind() == actionGoTo || a->getKind() == actionGoToR ) ) - { - // page number is contained/referenced in a LinkGoTo - LinkGoTo * g = static_cast< LinkGoTo * >( a ); - 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 - GooString *s = g->getNamedDest(); - QChar *charArray = new QChar[s->getLength()]; - for (int i = 0; i < s->getLength(); ++i) charArray[i] = QChar(s->getCString()[i]); - QString 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 ) - { - LinkGoToR * g2 = static_cast< LinkGoToR * >( a ); - item.setAttribute( "ExternalFileName", g2->getFileName()->getCString() ); - } - } - - // 3. recursively descend over children - outlineItem->open(); - GooList * children = outlineItem->getKids(); - if ( children ) - addTocChildren( docSyn, &item, children ); - } - } + void addTocChildren( QDomDocument * docSyn, QDomNode * parent, GooList * items ); class PDFDoc doc; bool locked;
_______________________________________________ poppler mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/poppler
