[poppler] 4 commits - qt4/src
Pino Toscano
pino at kemper.freedesktop.org
Sun Nov 30 07:58:23 PST 2008
qt4/src/poppler-form.cc | 1
qt4/src/poppler-page.cc | 1
qt4/src/poppler-private.cc | 104 +++++++++++++++++++++++++++++++++++++++++++++
qt4/src/poppler-private.h | 64 ---------------------------
4 files changed, 108 insertions(+), 62 deletions(-)
New commits:
commit 4cd364c179ae91ed383a8237ba1ad263952fd7aa
Author: Pino Toscano <pino at kde.org>
Date: Sun Nov 30 16:57:52 2008 +0100
add my copyright here
diff --git a/qt4/src/poppler-private.cc b/qt4/src/poppler-private.cc
index 7d2d586..d5a0191 100644
--- a/qt4/src/poppler-private.cc
+++ b/qt4/src/poppler-private.cc
@@ -1,6 +1,7 @@
/* poppler-private.cc: qt interface to poppler
* Copyright (C) 2005, Net Integration Technologies, Inc.
* Copyright (C) 2006 by Albert Astals Cid <aacid at kde.org>
+ * Copyright (C) 2008 by Pino Toscano <pino at kde.org>
* Inspired on code by
* Copyright (C) 2004 by Albert Astals Cid <tsdgeos at terra.es>
* Copyright (C) 2004 by Enrico Ros <eros.kde at email.it>
commit 6b1676deb773675d90469adc84c3de8dcdaf174c
Author: Pino Toscano <pino at kde.org>
Date: Sun Nov 30 16:56:43 2008 +0100
[Qt4] support URI actions for TOC items
diff --git a/qt4/src/poppler-private.cc b/qt4/src/poppler-private.cc
index 80871e7..7d2d586 100644
--- a/qt4/src/poppler-private.cc
+++ b/qt4/src/poppler-private.cc
@@ -174,6 +174,11 @@ namespace Poppler {
e->setAttribute( "ExternalFileName", g->getFileName()->getCString() );
break;
}
+ case actionURI:
+ {
+ LinkURI * u = static_cast< LinkURI * >( a );
+ e->setAttribute( "DestinationURI", u->getURI()->getCString() );
+ }
default: ;
}
}
commit b5cd58b5565055fd0c13771461245ddcd80edfcf
Author: Pino Toscano <pino at kde.org>
Date: Sun Nov 30 16:34:57 2008 +0100
extract the LinkAction "serialization" in an own function, and make it more safe
diff --git a/qt4/src/poppler-private.cc b/qt4/src/poppler-private.cc
index 7b6e2a0..80871e7 100644
--- a/qt4/src/poppler-private.cc
+++ b/qt4/src/poppler-private.cc
@@ -118,28 +118,14 @@ namespace Poppler {
return ret;
}
- void DocumentData::addTocChildren( QDomDocument * docSyn, QDomNode * parent, GooList * items )
+ void linkActionToTocItem( ::LinkAction * a, DocumentData * doc, QDomElement * e )
{
- 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 );
+ if ( !a || !e )
+ return;
- // 2. find the page the link refers to
- ::LinkAction * a = outlineItem->getAction();
- if ( a && ( a->getKind() == actionGoTo || a->getKind() == actionGoToR ) )
+ switch ( a->getKind() )
+ {
+ case actionGoTo:
{
// page number is contained/referenced in a LinkGoTo
LinkGoTo * g = static_cast< LinkGoTo * >( a );
@@ -153,20 +139,67 @@ namespace Poppler {
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 );
+ e->setAttribute( "DestinationName", aux );
delete[] charArray;
}
else if ( destination && destination->isOk() )
{
- LinkDestinationData ldd(destination, NULL, this);
- item.setAttribute( "Destination", LinkDestination(ldd).toString() );
+ LinkDestinationData ldd(destination, NULL, doc);
+ e->setAttribute( "Destination", LinkDestination(ldd).toString() );
}
- if ( a->getKind() == actionGoToR )
+ break;
+ }
+ case actionGoToR:
+ {
+ // page number is contained/referenced in a LinkGoToR
+ LinkGoToR * g = static_cast< LinkGoToR * >( a );
+ LinkDest * destination = g->getDest();
+ if ( !destination && g->getNamedDest() )
{
- LinkGoToR * g2 = static_cast< LinkGoToR * >( a );
- item.setAttribute( "ExternalFileName", g2->getFileName()->getCString() );
+ // 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());
+ e->setAttribute( "DestinationName", aux );
+ delete[] charArray;
+ }
+ else if ( destination && destination->isOk() )
+ {
+ LinkDestinationData ldd(destination, NULL, doc);
+ e->setAttribute( "Destination", LinkDestination(ldd).toString() );
}
+ e->setAttribute( "ExternalFileName", g->getFileName()->getCString() );
+ break;
}
+ default: ;
+ }
+ }
+
+ 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();
+ linkActionToTocItem( a, this, &item );
item.setAttribute( "Open", QVariant( (bool)outlineItem->isOpen() ).toString() );
commit ee191363e22940ae7b06945e68c4738b17c78348
Author: Pino Toscano <pino at kde.org>
Date: Sun Nov 30 16:17:32 2008 +0100
move the addTocChildren() implementation in the cpp
diff --git a/qt4/src/poppler-form.cc b/qt4/src/poppler-form.cc
index 772cdd9..d9ef0bc 100644
--- a/qt4/src/poppler-form.cc
+++ b/qt4/src/poppler-form.cc
@@ -22,6 +22,7 @@
#include <Form.h>
#include <Object.h>
+#include <Link.h>
#include "poppler-form.h"
#include "poppler-page-private.h"
diff --git a/qt4/src/poppler-page.cc b/qt4/src/poppler-page.cc
index f5f1281..e6d5ed9 100644
--- a/qt4/src/poppler-page.cc
+++ b/qt4/src/poppler-page.cc
@@ -34,6 +34,7 @@
#include <ErrorCodes.h>
#include <TextOutputDev.h>
#include <Annot.h>
+#include <Link.h>
#if defined(HAVE_SPLASH)
#include <SplashOutputDev.h>
#include <splash/SplashBitmap.h>
diff --git a/qt4/src/poppler-private.cc b/qt4/src/poppler-private.cc
index d525e56..7b6e2a0 100644
--- a/qt4/src/poppler-private.cc
+++ b/qt4/src/poppler-private.cc
@@ -24,6 +24,10 @@
#include <QtCore/QByteArray>
#include <QtCore/QDebug>
+#include <QtCore/QVariant>
+
+#include <Link.h>
+#include <Outline.h>
namespace Poppler {
@@ -113,4 +117,65 @@ namespace Poppler {
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() );
+ }
+ }
+
+ item.setAttribute( "Open", QVariant( (bool)outlineItem->isOpen() ).toString() );
+
+ // 3. recursively descend over children
+ outlineItem->open();
+ GooList * children = outlineItem->getKids();
+ if ( children )
+ addTocChildren( docSyn, &item, children );
+ }
+ }
+
}
diff --git a/qt4/src/poppler-private.h b/qt4/src/poppler-private.h
index 4ac9094..941f3d6 100644
--- a/qt4/src/poppler-private.h
+++ b/qt4/src/poppler-private.h
@@ -26,14 +26,11 @@
#define _POPPLER_PRIVATE_H_
#include <QtCore/QPointer>
-#include <QtCore/QVariant>
#include <QtCore/QVector>
#include <config.h>
#include <GfxState.h>
#include <GlobalParams.h>
-#include <Link.h>
-#include <Outline.h>
#include <PDFDoc.h>
#include <FontInfo.h>
#include <OutputDev.h>
@@ -44,6 +41,7 @@
#include "poppler-qt4.h"
+class LinkDest;
class FormWidget;
namespace Poppler {
@@ -150,65 +148,7 @@ namespace Poppler {
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() );
- }
- }
-
- item.setAttribute( "Open", QVariant( (bool)outlineItem->isOpen() ).toString() );
-
- // 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 );
void setPaperColor(const QColor &color)
{
More information about the poppler
mailing list