diff --git a/generators/djvu/generator_djvu.cpp b/generators/djvu/generator_djvu.cpp index 2521f06a9..86d8973d7 100644 --- a/generators/djvu/generator_djvu.cpp +++ b/generators/djvu/generator_djvu.cpp @@ -260,12 +260,22 @@ void DjVuGenerator::djvuImageGenerated( int page, const QImage & img ) { KDjVu::Annotation *ann = (*it); Okular::Annotation *newann = 0; + const KDjVu::Page* p = m_djvu->pages().at( page ); + int width = p->width(); + int height = p->height(); + bool scape_orientation = false; // hack by tokoe, should always create default page + if ( scape_orientation ) + qSwap( width, height ); switch ( ann->type() ) { case KDjVu::Annotation::TextAnnotation: { KDjVu::TextAnnotation* txtann = static_cast( ann ); Okular::TextAnnotation * newtxtann = new Okular::TextAnnotation(); + // boundary + QRect rect( QPoint( txtann->point().x(), height - txtann->point().y() - txtann->size().height() ), txtann->size() ); + newtxtann->boundary = Okular::NormalizedRect( Okular::Utils::rotateRect( rect, width, height, 0 ), width, height ); + // type newtxtann->textType = txtann->inlineText() ? Okular::TextAnnotation::InPlace : Okular::TextAnnotation::Linked; newtxtann->style.opacity = txtann->color().alphaF(); newann = newtxtann; @@ -275,17 +285,18 @@ void DjVuGenerator::djvuImageGenerated( int page, const QImage & img ) { KDjVu::LineAnnotation* lineann = static_cast( ann ); Okular::LineAnnotation * newlineann = new Okular::LineAnnotation(); - const KDjVu::Page* p = m_djvu->pages().at( page ); - int width = p->width(); - int height = p->height(); - bool scape_orientation = false; // hack by tokoe, should always create default page - if ( scape_orientation ) - qSwap( width, height ); - Okular::NormalizedRect tmprect( ann->rect(), width, height ); - newlineann->linePoints.append( Okular::NormalizedPoint( tmprect.left, tmprect.top ) ); - newlineann->linePoints.append( Okular::NormalizedPoint( tmprect.right, tmprect.bottom ) ); + // boundary + QPoint a( lineann->point().x(), height - lineann->point().y() ); + QPoint b( lineann->point2().x(), height - lineann->point2().y() ); + QRect rect = QRect( a, b ).normalized(); + newlineann->boundary = Okular::NormalizedRect( Okular::Utils::rotateRect( rect, width, height, 0 ), width, height ); + // line points + newlineann->linePoints.append( Okular::NormalizedPoint( a.x(), a.y(), width, height ) ); + newlineann->linePoints.append( Okular::NormalizedPoint( b.x(), b.y(), width, height ) ); + // arrow? if ( lineann->isArrow() ) newlineann->lineEndStyle = Okular::LineAnnotation::OpenArrow; + // width newlineann->style.width = lineann->width(); newann = newlineann; break; @@ -294,13 +305,6 @@ void DjVuGenerator::djvuImageGenerated( int page, const QImage & img ) if ( newann ) { // setting the common parameters - const KDjVu::Page* p = m_djvu->pages().at( page ); - int width = p->width(); - int height = p->height(); - bool scape_orientation = false; // hack by tokoe, should always create default page - if ( scape_orientation ) - qSwap( width, height ); - newann->boundary = Okular::NormalizedRect( ann->rect(), width, height ); newann->style.color = ann->color(); newann->contents = ann->comment(); diff --git a/generators/djvu/kdjvu.cpp b/generators/djvu/kdjvu.cpp index 6b24d7b84..3bfca57df 100644 --- a/generators/djvu/kdjvu.cpp +++ b/generators/djvu/kdjvu.cpp @@ -201,9 +201,9 @@ KDjVu::Annotation::~Annotation() { } -QRect KDjVu::Annotation::rect() const +QPoint KDjVu::Annotation::point() const { - return m_rect; + return m_point; } QString KDjVu::Annotation::comment() const @@ -223,6 +223,11 @@ KDjVu::TextAnnotation::TextAnnotation() { } +QSize KDjVu::TextAnnotation::size() const +{ + return m_size; +} + int KDjVu::TextAnnotation::type() const { return KDjVu::Annotation::TextAnnotation; @@ -245,6 +250,11 @@ int KDjVu::LineAnnotation::type() const return KDjVu::Annotation::LineAnnotation; } +QPoint KDjVu::LineAnnotation::point2() const +{ + return m_point2; +} + bool KDjVu::LineAnnotation::isArrow() const { return m_isArrow; @@ -577,14 +587,17 @@ void KDjVu::linksAndAnnotationsForPage( int pageNum, QList& links, int d = miniexp_to_int( miniexp_nth( 4, area ) ); if ( type == QLatin1String( "text" ) ) { - ann = new KDjVu::TextAnnotation(); - ann->m_rect = QRect( a, b - d, c, d ); + KDjVu::TextAnnotation * textann = new KDjVu::TextAnnotation(); + textann->m_size = QSize( c, d ); + ann = textann; } else if ( type == QLatin1String( "line" ) ) { - ann = new KDjVu::LineAnnotation(); - ann->m_rect = QRect( a, b, c - a, b - d ); + KDjVu::LineAnnotation * lineann = new KDjVu::LineAnnotation(); + lineann->m_point2 = QPoint( c, d ); + ann = lineann; } + ann->m_point = QPoint( a, b ); ann->m_comment = QString::fromUtf8( miniexp_to_str( miniexp_nth( 2, cur ) ) ); } if ( link ) diff --git a/generators/djvu/kdjvu.h b/generators/djvu/kdjvu.h index 7225cc2b3..1c847f79d 100644 --- a/generators/djvu/kdjvu.h +++ b/generators/djvu/kdjvu.h @@ -124,12 +124,12 @@ class KDjVu : public QObject enum AnnotationType { TextAnnotation, LineAnnotation }; virtual int type() const = 0; - QRect rect() const; + QPoint point() const; QString comment() const; QColor color() const; private: - QRect m_rect; + QPoint m_point; QString m_comment; QColor m_color; }; @@ -143,10 +143,12 @@ class KDjVu : public QObject public: virtual int type() const; + QSize size() const; bool inlineText() const; private: TextAnnotation(); + QSize m_size; bool m_inlineText; }; @@ -159,11 +161,13 @@ class KDjVu : public QObject public: virtual int type() const; + QPoint point2() const; bool isArrow() const; int width() const; private: LineAnnotation(); + QPoint m_point2; bool m_isArrow; int m_width; };