Changeset 203

Show
Ignore:
Timestamp:
06/05/06 13:09:33 (2 years ago)
Author:
jordi
Message:

Some PDF files use named links in the index and GoTo? links. Aparently poppler 0.5.1 and earlier gave the page number anyway but in versions 0.5.2 and upper I need to find the destination for links to work properly. See ticket #28, which this commit fixes.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/src/PDFDocument.cxx

    r200 r203  
    8686        { 
    8787            PopplerActionGotoDest *actionGoTo = (PopplerActionGotoDest *)action; 
     88            int pageNum = 0; 
     89            PopplerDest *destination = actionGoTo->dest; 
     90            if ( POPPLER_DEST_NAMED == destination->type ) 
     91            { 
     92                destination = 
     93                    poppler_document_find_dest (m_Document, 
     94                                                destination->named_dest); 
     95                if ( NULL != destination ) 
     96                { 
     97                    pageNum = destination->page_num; 
     98                    poppler_dest_free (destination); 
     99                } 
     100            } 
     101            else 
     102            { 
     103                pageNum = destination->page_num; 
     104            } 
     105 
    88106            documentLink = new DocumentLinkGoto ( 
    89107                    topLeft, bottomLeft, topRight, bottomRight, 
    90                     actionGoTo->dest->page_num); 
     108                    pageNum); 
    91109            break; 
    92110        } 
     
    377395            if ( POPPLER_ACTION_GOTO_DEST == action->type ) 
    378396            { 
    379                 PopplerActionGotoDest *actionGoTo =  
     397                PopplerActionGotoDest *actionGoTo = 
    380398                    (PopplerActionGotoDest *)action; 
    381399                DocumentOutline *child = new DocumentOutline (); 
     
    383401                child->setTitle (actionGoTo->title); 
    384402                PopplerDest *destination = actionGoTo->dest; 
    385                 child->setDestination (destination->page_num); 
    386                 outline->addChild (child); 
     403                if ( POPPLER_DEST_NAMED == destination->type ) 
     404                { 
     405                    destination = 
     406                        poppler_document_find_dest (m_Document, 
     407                                                    destination->named_dest); 
     408                    if ( NULL != destination ) 
     409                    { 
     410                        child->setDestination (destination->page_num); 
     411                        poppler_dest_free (destination); 
     412                        destination = NULL; 
     413                    } 
     414                } 
     415                else 
     416                { 
     417                    child->setDestination (destination->page_num); 
     418                } 
     419 
     420                    outline->addChild (child); 
    387421                PopplerIndexIter *childIter =  
    388422                    poppler_index_iter_get_child (childrenList);