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

List:       kde-commits
Subject:    branches/kpdf/annotations/kdegraphics/kpdf
From:       Piotr Szymanski <djurban () pld-dc ! org>
Date:       2005-07-15 15:36:50
Message-ID: 1121441810.688206.11058.nullmailer () svn ! kde ! org
[Download RAW message or body]

SVN commit 434835 by djurban:

- backport
        "SVN commit 429479 by tokoe:
        Add possibility to go to an external pdf document from the TOC."



 M  +11 -0     core/generator_pdf/generator_pdf.cpp  
 M  +1 -1      core/generator_pdf/gp_outputdev.cpp  
 M  +20 -9     ui/toc.cpp  


--- branches/kpdf/annotations/kdegraphics/kpdf/core/generator_pdf/generator_pdf.cpp #434834:434835
@@ -681,6 +681,17 @@
                 // TODO add other attributes to the viewport (taken from link)
                 item.setAttribute( "Viewport", DocumentViewport( pageNumber ).toString() );
             }
+	    }
+	    else if ( a && a->getKind() == actionGoToR )
+        {
+            LinkGoToR * g = static_cast< LinkGoToR * >( a );
+            LinkDest * destination = g->getDest();
+            if ( !destination && g->getNamedDest() )
+            {
+                item.setAttribute( "ViewportName", g->getNamedDest()->getCString() );
+            }
+ 
+            item.setAttribute( "ExternalFileName", g->getFileName()->getCString() );
         }
 
         // 3. recursively descend over children
--- branches/kpdf/annotations/kdegraphics/kpdf/core/generator_pdf/gp_outputdev.cpp #434834:434835
@@ -281,7 +281,7 @@
         case actionGoTo:
             {
             LinkGoTo * g = (LinkGoTo *) a;
-            // ceate link: no ext file, namedDest, object pointer
+            // create link: no ext file, namedDest, object pointer
             link = new KPDFLinkGoto( QString::null, decodeViewport( g->getNamedDest(), g->getDest() ) );
             }
             break;
--- branches/kpdf/annotations/kdegraphics/kpdf/ui/toc.cpp #434834:434835
@@ -15,6 +15,7 @@
 #include "toc.h"
 #include "core/document.h"
 #include "core/page.h"
+#include "core/link.h"
 
 // uncomment following to enable a 2nd column showing the page referred
 // by each tree entry note: PDF uses often references to viewports and
@@ -125,18 +126,28 @@
     if (tocItem == NULL)
         return;
     const QDomElement & e = tocItem->element();
-    if ( e.hasAttribute( "Viewport" ) )
+
+    QString externalFileName = e.attribute( "ExternalFileName" );
+    if ( !externalFileName.isEmpty() )
     {
-        // if the node has a viewport, set it
-        m_document->setViewport( DocumentViewport( e.attribute( "Viewport" ) ), TOC_ID );
+        KPDFLinkGoto link( externalFileName, DocumentViewport() );
+        m_document->processLink( &link );
     }
-    else if ( e.hasAttribute( "ViewportName" ) )
+    else
     {
-        // if the node references a viewport, get the reference and set it
-        const QString & page = e.attribute( "ViewportName" );
-        const QString & viewport = m_document->getMetaData( "NamedViewport", page );
-        if ( !viewport.isNull() )
-            m_document->setViewport( DocumentViewport( viewport ), TOC_ID );
+        if ( e.hasAttribute( "Viewport" ) )
+        {
+            // if the node has a viewport, set it
+            m_document->setViewport( DocumentViewport( e.attribute( "Viewport" ) ), TOC_ID );
+        }
+        else if ( e.hasAttribute( "ViewportName" ) )
+        {
+            // if the node references a viewport, get the reference and set it
+            const QString & page = e.attribute( "ViewportName" );
+            const QString & viewport = m_document->getMetaData( "NamedViewport", page );
+            if ( !viewport.isNull() )
+                m_document->setViewport( DocumentViewport( viewport ), TOC_ID );
+        }
     }
 }
 
[prev in list] [next in list] [prev in thread] [next in thread] 

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