Commit e5018d70 authored by Pino Toscano's avatar Pino Toscano

Complete support for hyperlinks.

Cookies go to Luigi, thanks!

svn path=/trunk/playground/graphics/okular/; revision=555965
parent 39e73f95
......@@ -22,6 +22,7 @@
#include "dviPageInfo.h"
#include "pageSize.h"
#include "anchor.h"
#include "prebookmark.h"
#include <ksharedptr.h>
#include <kurl.h>
......@@ -33,7 +34,7 @@
#include <QTimer>
#include <QMutex>
//class Anchor;
class Anchor;
class DocumentWidget;
class dvifile;
class dviRenderer;
......@@ -169,6 +170,8 @@ public slots:
SimplePageSize sizeOfPage(const PageNumber& page);
Q3ValueVector<PreBookmark> getPrebookmarks() const { return prebookmarks; }
private slots:
/** This method shows a dialog that tells the user that source
information is present, and gives the opportunity to open the
......
......@@ -77,6 +77,24 @@ static void rotateCoordinates( const int iWidth, const int iHeight,
}
static void rotateCoordinates( const double iWidth, const double iHeight,
double &fWidth, double &fHeight, const int orientation)
{
if ( orientation % 2 == 0 )
{
/* portrait */
fWidth = iWidth;
fHeight = iHeight;
}
else
{
/* landscape */
fWidth = iHeight;
fHeight = iWidth;
}
}
static QRect rotateQRect( QRect source, int pageWidth, int pageHeight, int orientation )
{
QRect tr;
......@@ -131,19 +149,41 @@ QLinkedList<ObjectRect*> DviGenerator::generateDviLinks( const dviPageInfo *page
Anchor anch = m_dviRenderer->findAnchor(dviLink.linkText);
if (anch.isValid())
KPDFLink *okuLink = 0;
if (anch.isValid())
{
/* TODO: internal link */
DocumentViewport vp;
vp.pageNumber = anch.page - 1;
double vp_x = 0.0, vp_y = 0.0;
SimplePageSize ps = m_dviRenderer->sizeOfPage( vp.pageNumber );
double resolution = (double)(pageInfo->width)/ps.width().getLength_in_inch();
double py = (double)anch.distance_from_top.getLength_in_inch()*resolution + 0.5;
rotateCoordinates( 0.5, py / (double)pageHeight,
vp_x, vp_y, orientation );
vp.rePos.normalizedX = vp_x;
vp.rePos.normalizedY = vp_y;
vp.rePos.enabled = true;
vp.rePos.pos = DocumentViewport::Center;
okuLink = new KPDFLinkGoto( "", vp );
}
else
{
ObjectRect *olink = new ObjectRect( nl, nt, nr, nb, ObjectRect::Link,
new KPDFLinkBrowse( dviLink.linkText ) );
dviLinks.push_front( olink );
okuLink = new KPDFLinkBrowse( dviLink.linkText );
}
if ( okuLink )
{
ObjectRect *orlink = new ObjectRect( nl, nt, nr, nb, ObjectRect::Link,
okuLink );
dviLinks.push_front( orlink );
}
}
return dviLinks;
}
......
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