Commit 6cdcfae0 authored by Albert Astals Cid's avatar Albert Astals Cid

2006-09-11 Albert Astals Cid <aacid@kde.org>

        * qt4/src/poppler-annotation.cc:
        * qt4/src/poppler-annotation.h:
        * qt4/src/poppler-page.cc: Add support for LinkAnnotation. Patch by
        Pino Toscano
parent 8335c7ee
2006-09-08 Jeff Muizelaar <jeff@infidigm.net>
2006-09-11 Albert Astals Cid <aacid@kde.org>
* poppler/CairoOutputDev.cc: The work-around for 1x1 imagemasks was not
calling cairo_set_source causing the rectangles to be drawn the wrong
colour occasionally. Fix by moving the existing call to
cairo_set_source above the work-around. Fixes #7113.
* qt4/src/poppler-annotation.cc:
* qt4/src/poppler-annotation.h:
* qt4/src/poppler-page.cc: Add support for LinkAnnotation. Patch by
Pino Toscano
2006-09-06 Jeff Muizelaar <jeff@infidigm.net>
......
This diff is collapsed.
......@@ -30,6 +30,7 @@
namespace Poppler {
class Annotation;
class Link;
/**
* @short Helper class for (recoursive) annotation retrieval/storage.
......@@ -70,7 +71,7 @@ struct Annotation
// enum definitions
// WARNING!!! oKular uses that very same values so if you change them notify the author!
enum SubType { AText = 1, ALine = 2, AGeom = 3, AHighlight = 4, AStamp = 5,
AInk = 6, A_BASE = 0 };
AInk = 6, ALink = 7, A_BASE = 0 };
enum Flag { Hidden = 1, FixedSize = 2, FixedRotation = 4, DenyPrint = 8,
DenyWrite = 16, DenyDelete = 32, ToggleHidingOnMouse = 64, External = 128 };
enum LineStyle { Solid = 1, Dashed = 2, Beveled = 4, Inset = 8, Underline = 16 };
......@@ -170,7 +171,7 @@ struct TextAnnotation : public Annotation
// data fields
TextType textType; // Linked
QString textIcon; // 'Comment'
QString textIcon; // 'Note'
QFont textFont; // app def font
int inplaceAlign; // 0:left, 1:center, 2:right
QString inplaceText; // '' overrides contents
......@@ -240,7 +241,7 @@ struct StampAnnotation : public Annotation
AN_COMMONDECL( StampAnnotation, AStamp )
// data fields
QString stampIconName; // 'kpdf'
QString stampIconName; // 'Draft'
};
struct InkAnnotation : public Annotation
......@@ -252,6 +253,21 @@ struct InkAnnotation : public Annotation
QList< QLinkedList<QPointF> > inkPaths;
};
struct LinkAnnotation : public Annotation
{
// common stuff for Annotation derived classes
AN_COMMONDECL( LinkAnnotation, ALink );
virtual ~LinkAnnotation();
// local enums
enum HighlightMode { None, Invert, Outline, Push };
// data fields
Link * linkDestination; //
HighlightMode linkHLMode; // Invert
QPointF linkRegion[4]; //
};
}
#endif
......@@ -39,11 +39,109 @@ namespace Poppler {
class PageData {
public:
Link* convertLinkActionToLink(::LinkAction * a, const QRectF &linkArea, DocumentData * doc);
const Document *parentDoc;
int index;
PageTransition *transition;
};
Link* PageData::convertLinkActionToLink(::LinkAction * a, const QRectF &linkArea, DocumentData * doc)
{
if ( !a )
return NULL;
Link * popplerLink = NULL;
switch ( a->getKind() )
{
case actionGoTo:
{
LinkGoTo * g = (LinkGoTo *) a;
// create link: no ext file, namedDest, object pointer
popplerLink = new LinkGoto( linkArea, QString::null, LinkDestination( LinkDestinationData(g->getDest(), g->getNamedDest(), doc ) ) );
}
break;
case actionGoToR:
{
LinkGoToR * g = (LinkGoToR *) a;
// copy link file
const char * fileName = g->getFileName()->getCString();
// ceate link: fileName, namedDest, object pointer
popplerLink = new LinkGoto( linkArea, (QString)fileName, LinkDestination( LinkDestinationData(g->getDest(), g->getNamedDest(), doc ) ) );
}
break;
case actionLaunch:
{
LinkLaunch * e = (LinkLaunch *)a;
GooString * p = e->getParams();
popplerLink = new LinkExecute( linkArea, e->getFileName()->getCString(), p ? p->getCString() : 0 );
}
break;
case actionNamed:
{
const char * name = ((LinkNamed *)a)->getName()->getCString();
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()->getCString() );
}
break;
case actionMovie:
/* TODO this (Movie link)
m_type = Movie;
LinkMovie * m = (LinkMovie *) a;
// copy Movie parameters (2 IDs and a const char *)
Ref * r = m->getAnnotRef();
m_refNum = r->num;
m_refGen = r->gen;
copyString( m_uri, m->getTitle()->getCString() );
*/ break;
case actionUnknown:
break;
}
return popplerLink;
}
Page::Page(const Document *doc, int index) {
m_page = new PageData();
m_page->index = index;
......@@ -333,97 +431,7 @@ QList<Link*> Page::links() const
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, QString::null, LinkDestination( LinkDestinationData(g->getDest(), g->getNamedDest(), m_page->parentDoc->m_doc ) ) );
}
break;
case actionGoToR:
{
LinkGoToR * g = (LinkGoToR *) a;
// copy link file
const char * fileName = g->getFileName()->getCString();
// ceate link: fileName, namedDest, object pointer
popplerLink = new LinkGoto( linkArea, (QString)fileName, LinkDestination( LinkDestinationData(g->getDest(), g->getNamedDest(), m_page->parentDoc->m_doc ) ) );
}
break;
case actionLaunch:
{
LinkLaunch * e = (LinkLaunch *)a;
GooString * p = e->getParams();
popplerLink = new LinkExecute( linkArea, e->getFileName()->getCString(), p ? p->getCString() : 0 );
}
break;
case actionNamed:
{
const char * name = ((LinkNamed *)a)->getName()->getCString();
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()->getCString() );
}
break;
case actionMovie:
/* TODO this (Movie link)
m_type = Movie;
LinkMovie * m = (LinkMovie *) a;
// copy Movie parameters (2 IDs and a const char *)
Ref * r = m->getAnnotRef();
m_refNum = r->num;
m_refGen = r->gen;
copyString( m_uri, m->getTitle()->getCString() );
*/ break;
case actionUnknown:
break;
}
}
Link *popplerLink = m_page->convertLinkActionToLink(xpdfLink->getAction(), linkArea, m_page->parentDoc->m_doc);
if (popplerLink)
{
popplerLinks.append(popplerLink);
......@@ -790,9 +798,50 @@ QList<Annotation*> Page::annotations() const
}
else if ( subType == "Link" )
{
// ignore links (this may change in future)
annot.free();
continue;
// parse Link params
LinkAnnotation * l = new LinkAnnotation();
annotation = l;
// -> hlMode
QString hlModeString;
XPDFReader::lookupString( annotDict, "H", hlModeString );
if ( hlModeString == "N" )
l->linkHLMode = LinkAnnotation::None;
else if ( hlModeString == "I" )
l->linkHLMode = LinkAnnotation::Invert;
else if ( hlModeString == "O" )
l->linkHLMode = LinkAnnotation::Outline;
else if ( hlModeString == "P" )
l->linkHLMode = LinkAnnotation::Push;
// -> link region
double c[8];
int num = XPDFReader::lookupNumArray( annotDict, "QuadPoints", c, 8 );
if ( num > 0 && num != 8 )
{
qDebug() << "Wrong QuadPoints for a Link annotation." << endl;
delete annotation;
annot.free();
continue;
}
if ( num == 8 )
{
XPDFReader::transform( MTX, c[ 0 ], c[ 1 ], l->linkRegion[ 0 ] );
XPDFReader::transform( MTX, c[ 2 ], c[ 3 ], l->linkRegion[ 1 ] );
XPDFReader::transform( MTX, c[ 4 ], c[ 5 ], l->linkRegion[ 2 ] );
XPDFReader::transform( MTX, c[ 6 ], c[ 7 ], l->linkRegion[ 3 ] );
}
// reading link action
Object objPA;
annotDict->lookup( "PA", &objPA );
::LinkAction * a = ::LinkAction::parseAction( &objPA, m_page->parentDoc->m_doc->doc.getCatalog()->getBaseURI() );
Link * popplerLink = m_page->convertLinkActionToLink( a, QRectF(), m_page->parentDoc->m_doc );
if ( popplerLink )
{
l->linkDestination = popplerLink;
}
objPA.free();
}
else
{
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment