Make use of okularUtils, and use a Center viewport position for links.

(Luigi Toscano)

svn path=/trunk/playground/graphics/okular/; revision=556625
remotes/origin/old/work/newpageview
Pino Toscano 20 years ago
parent d0b5207bce
commit c82fed6d75
  1. 38
      generators/dvi/generator_dvi.cpp

@ -10,6 +10,7 @@
#include "generator_dvi.h" #include "generator_dvi.h"
#include "core/page.h" #include "core/page.h"
#include "core/link.h" #include "core/link.h"
#include "core/utils.h"
#include "dviFile.h" #include "dviFile.h"
#include "dviPageInfo.h" #include "dviPageInfo.h"
#include "dviRenderer.h" #include "dviRenderer.h"
@ -98,36 +99,6 @@ static void rotateCoordinates( const double iWidth, const double iHeight,
} }
static QRect rotateQRect( QRect source, int pageWidth, int pageHeight, int orientation )
{
QRect tr;
// adapt the coordinates of the boxes to the rotation
switch ( orientation )
{
case 0: /* no modifications */
tr = source;
break;
case 1:
tr = QRect( pageWidth-source.y()-source.height(),
source.x(),
source.height(), source.width() );
break;
case 2:
tr = QRect( pageWidth-source.x()-source.width(),
pageHeight-source.y()-source.height(),
source.width(), source.height() );
break;
case 3:
tr = QRect( source.y(),
pageHeight-source.x()-source.width(),
source.height(), source.width() );
break;
}
return tr;
}
void DviGenerator::fillViewportFromAnchor( DocumentViewport &vp, void DviGenerator::fillViewportFromAnchor( DocumentViewport &vp,
const Anchor &anch, int pW, int pH, const Anchor &anch, int pW, int pH,
int orientation ) int orientation )
@ -151,8 +122,7 @@ void DviGenerator::fillViewportFromAnchor( DocumentViewport &vp,
vp.rePos.normalizedX = vp_x; vp.rePos.normalizedX = vp_x;
vp.rePos.normalizedY = vp_y; vp.rePos.normalizedY = vp_y;
vp.rePos.enabled = true; vp.rePos.enabled = true;
vp.rePos.pos = DocumentViewport::TopLeft; vp.rePos.pos = DocumentViewport::Center;
} }
QLinkedList<ObjectRect*> DviGenerator::generateDviLinks( const dviPageInfo *pageInfo, QLinkedList<ObjectRect*> DviGenerator::generateDviLinks( const dviPageInfo *pageInfo,
@ -167,7 +137,7 @@ QLinkedList<ObjectRect*> DviGenerator::generateDviLinks( const dviPageInfo *page
foreach( const Hyperlink dviLink, pageInfo->hyperLinkList ) foreach( const Hyperlink dviLink, pageInfo->hyperLinkList )
{ {
QRect boxArea = rotateQRect( dviLink.box, pageWidth, pageHeight, QRect boxArea = okularUtils::rotateRect( dviLink.box, pageWidth, pageHeight,
orientation ); orientation );
double nl = (double)boxArea.left() / pageWidth, double nl = (double)boxArea.left() / pageWidth,
nt = (double)boxArea.top() / pageHeight, nt = (double)boxArea.top() / pageHeight,
@ -311,7 +281,7 @@ KPDFTextPage *DviGenerator::extractTextFromPage( dviPageInfo *pageInfo, int orie
{ {
TextBox curTB = *it; TextBox curTB = *it;
tmpRect = rotateQRect( curTB.box, pageWidth, pageHeight, orientation ); tmpRect = okularUtils::rotateRect( curTB.box, pageWidth, pageHeight, orientation );
#if 0 #if 0
kDebug() << "orientation: " << orientation kDebug() << "orientation: " << orientation

Loading…
Cancel
Save