Read correctly the 'poly' links for DjVu documents.

svn path=/trunk/playground/graphics/okular/; revision=561918
remotes/origin/old/work/newpageview
Pino Toscano 20 years ago
parent 67fabc7659
commit 2d64d446d7
  1. 26
      generators/djvu/generator_djvu.cpp
  2. 17
      generators/djvu/kdjvu.cpp
  3. 6
      generators/djvu/kdjvu.h

@ -194,7 +194,8 @@ void DjVuGenerator::djvuPixmapGenerated( int page, const QPixmap & pix )
const KDjVu::Page* p = m_djvu->pages().at( newpage == -1 ? page : newpage );
int width = p->width();
int height = p->height();
if ( m_request->documentRotation % 2 == 1 )
bool scape_orientation = ( m_request->documentRotation % 2 == 1 );
if ( scape_orientation )
qSwap( width, height );
ObjectRect *newrect = 0;
switch ( curlink->areaType() )
@ -207,6 +208,29 @@ void DjVuGenerator::djvuPixmapGenerated( int page, const QPixmap & pix )
newrect = new ObjectRect( NormalizedRect( okularUtils::rotateRect( r, width, height, m_request->documentRotation ), width, height ), ellipse, ObjectRect::Link, newlink );
break;
}
case KDjVu::Link::PolygonArea:
{
QPolygon poly = curlink->polygon();
QPolygonF newpoly;
for ( int i = 0; i < poly.count(); ++i )
{
int x = poly.at(i).x();
int y = poly.at(i).y();
if ( scape_orientation )
qSwap( x, y );
else
{
y = height - y;
}
newpoly << QPointF( (double)(x)/width, (double)(y)/height );
}
if ( !newpoly.isEmpty() )
{
newpoly << newpoly.first();
newrect = new ObjectRect( newpoly, ObjectRect::Link, newlink );
}
break;
}
default: ;
}
if ( newrect )

@ -159,7 +159,7 @@ QSize KDjVu::Link::size() const
return m_size;
}
QPolygonF KDjVu::Link::polygon() const
QPolygon KDjVu::Link::polygon() const
{
return m_poly;
}
@ -498,6 +498,7 @@ QList<KDjVu::Link*> KDjVu::linksForPage( int pageNum ) const
}
if ( link )
{
link->m_area = KDjVu::Link::UnknownArea;
miniexp_t area = miniexp_nth( 3, cur );
int arealength = miniexp_length( area );
if ( ( arealength == 5 ) && miniexp_symbolp( miniexp_nth( 0, area ) ) &&
@ -515,9 +516,21 @@ QList<KDjVu::Link*> KDjVu::linksForPage( int pageNum ) const
link->m_area = KDjVu::Link::EllipseArea;
}
}
else if ( ( arealength > 0 ) && ( arealength % 2 == 1 ) &&
miniexp_symbolp( miniexp_nth( 0, area ) ) &&
( qstrncmp( miniexp_to_name( miniexp_nth( 0, area ) ), "poly", 4 ) == 0 ) )
{
link->m_area = KDjVu::Link::PolygonArea;
QPolygon poly;
for ( int j = 1; j < arealength; j += 2 )
{
poly << QPoint( miniexp_to_int( miniexp_nth( j, area ) ), miniexp_to_int( miniexp_nth( j + 1, area ) ) );
}
link->m_poly = poly;
}
// TODO: other link shapes
if ( !( link->m_point.isNull() || link->m_size.isNull() ) )
if ( link->m_area != KDjVu::Link::UnknownArea )
ret.append( link );
}
}

@ -63,18 +63,18 @@ class KDjVu : public QObject
virtual ~Link();
enum LinkType { PageLink, UrlLink };
enum LinkArea { RectArea, EllipseArea, PolygonArea };
enum LinkArea { UnknownArea, RectArea, EllipseArea, PolygonArea };
virtual int type() const = 0;
LinkArea areaType() const;
QPoint point() const;
QSize size() const;
QPolygonF polygon() const;
QPolygon polygon() const;
private:
LinkArea m_area;
QPoint m_point;
QSize m_size;
QPolygonF m_poly;
QPolygon m_poly;
};
/**

Loading…
Cancel
Save