[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-commits
Subject:    playground/graphics/okular/generators/djvu
From:       Pino Toscano <toscano.pino () tiscali ! it>
Date:       2006-06-28 22:57:10
Message-ID: 1151535430.810119.12181.nullmailer () svn ! kde ! org
[Download RAW message or body]

SVN commit 556019 by pino:

take correctly into account the rotation of the document, and rotate the link rects \
accordingly


 M  +34 -2     generator_djvu.cpp  


--- trunk/playground/graphics/okular/generators/djvu/generator_djvu.cpp \
#556018:556019 @@ -49,6 +49,30 @@
     }
 }
 
+static QRect rotateRect( const QRect & rect, int width, int height, int rotation )
+{
+    QRect ret;
+    switch ( rotation )
+    {
+        case 0:
+            ret = rect;
+            break;
+        case 1:
+            ret = QRect( width - rect.height() - rect.y(), rect.x(),
+                         rect.height(), rect.width() );
+            break;
+        case 2:
+            ret = QRect( width - rect.width() - rect.x(), height - rect.height() - \
rect.y(), +                         rect.width(), rect.height() );
+            break;
+        case 3:
+            ret = QRect( rect.y(), height - rect.width() - rect.x(),
+                         rect.height(), rect.width() );
+            break;
+    }
+    return ret;
+}
+
 OKULAR_EXPORT_PLUGIN(DjVuGenerator)
 
 DjVuGenerator::DjVuGenerator( KPDFDocument * doc ) : Generator ( doc ),
@@ -175,8 +199,12 @@
                         }
                         KPDFLinkGoto* go = new KPDFLinkGoto( QString::null, vp );
                         const KDjVu::Page* p = m_djvu->pages().at( vp.pageNumber == \
-1 ? page : vp.pageNumber ); +                        int width = p->width();
+                        int height = p->height();
+                        if ( m_request->documentRotation % 2 == 1 )
+                            qSwap( width, height );
                         QRect r( QPoint( l->point().x(), p->height() - \
                l->point().y() - l->size().height() ), l->size() );
-                        newlink = new ObjectRect( NormalizedRect( r, p->width(), \
p->height() ), ObjectRect::Link, go ); +                        newlink = new \
ObjectRect( NormalizedRect( rotateRect( r, width, height, m_request->documentRotation \
), width, height ), ObjectRect::Link, go );  }
                     break;
                 }
@@ -186,8 +214,12 @@
                     QString url = l->url();
                     KPDFLinkBrowse* browse = new KPDFLinkBrowse( url );
                     const KDjVu::Page* p = m_djvu->pages().at( page );
+                    int width = p->width();
+                    int height = p->height();
+                    if ( m_request->documentRotation % 2 == 1 )
+                        qSwap( width, height );
                     QRect r( QPoint( l->point().x(), p->height() - l->point().y() - \
                l->size().height() ), l->size() );
-                    newlink = new ObjectRect( NormalizedRect( r, p->width(), \
p->height() ), ObjectRect::Link, browse ); +                    newlink = new \
ObjectRect( NormalizedRect( rotateRect( r, width, height, m_request->documentRotation \
), width, height ), ObjectRect::Link, browse );  break;
                 }
             }


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic