From 369803e65b76368a8bccd9b48e57949d416e35ab Mon Sep 17 00:00:00 2001 From: Piotr Szymanski Date: Fri, 15 Jul 2005 17:32:46 +0000 Subject: [PATCH] - forwardport the support for external linkage in toc svn path=/trunk/playground/graphics/oKular/kpdf/; revision=434864 --- core/generator_pdf/generator_pdf.cpp | 11 +++++++++ core/generator_pdf/gp_outputdev.cpp | 2 +- ui/toc.cpp | 36 +++++++++++++++++++++------- 3 files changed, 39 insertions(+), 10 deletions(-) diff --git a/core/generator_pdf/generator_pdf.cpp b/core/generator_pdf/generator_pdf.cpp index 0b58f7c20..43369480e 100644 --- a/core/generator_pdf/generator_pdf.cpp +++ b/core/generator_pdf/generator_pdf.cpp @@ -681,6 +681,17 @@ void PDFGenerator::addSynopsisChildren( QDomNode * parent, GList * items ) // 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 diff --git a/core/generator_pdf/gp_outputdev.cpp b/core/generator_pdf/gp_outputdev.cpp index 0ae394da6..699d8d834 100644 --- a/core/generator_pdf/gp_outputdev.cpp +++ b/core/generator_pdf/gp_outputdev.cpp @@ -291,7 +291,7 @@ KPDFLink * KPDFOutputDev::generateLink( LinkAction * a ) LinkGoToR * g = (LinkGoToR *) a; // copy link file const char * fileName = g->getFileName()->getCString(); - // ceate link: fileName, namedDest, object pointer + // create link: fileName, namedDest, object pointer link = new KPDFLinkGoto( (QString)fileName, decodeViewport( g->getNamedDest(), g->getDest() ) ); } break; diff --git a/ui/toc.cpp b/ui/toc.cpp index 020668b93..148741d1d 100644 --- a/ui/toc.cpp +++ b/ui/toc.cpp @@ -119,18 +119,36 @@ void TOC::slotExecuted( QListViewItem *i ) if (tocItem == NULL) return; const QDomElement & e = tocItem->element(); - if ( e.hasAttribute( "Viewport" ) ) + + QString externalFileName = e.attribute( "ExternalFileName" ); + if ( !externalFileName.isEmpty() ) + { + KPDFLinkGoto link( externalFileName, DocumentViewport() ); + m_document->processLink( &link ); + } + else + { + 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 ); + } } }