Show
Ignore:
Timestamp:
04/14/06 12:36:20 (3 years ago)
Author:
jordi
Message:

I've removed all Poppler stuff from the DocumentOutline? and put it into the PDFDocument, where it should be. Also the previously protected setters DocumentOutline? methods are set to public.

Added the missing documentation comments.

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • trunk/src/DocumentOutline.cxx

    r60 r61  
    1717 
    1818#include <config.h> 
    19  
    20 // Poppler headers 
    21 #include <goo/GooList.h> 
    22 #include <Outline.h> 
    23 #include <PDFDoc.h> 
    24 #include <Link.h> 
    25  
    2619#include "epdfview.h" 
    2720 
     
    3427/// @brief Constructs a new DocumentOutline. 
    3528/// 
    36 DocumentOutline::DocumentOutline (PDFDoc *document) 
     29DocumentOutline::DocumentOutline () 
    3730{ 
    3831    m_Destination = 1; 
    39     m_Document = document; 
    4032    m_Children = NULL; 
    4133    m_LastReturnedChild = NULL; 
     
    4941DocumentOutline::~DocumentOutline () 
    5042{ 
    51     m_Document = NULL; 
    5243    m_Parent = NULL; 
    5344    g_free (m_Title); 
     
    5849 
    5950/// 
    60 /// @brief Get the outline's destination page. 
     51/// @brief Adds a new outline's child. 
     52/// 
     53/// @param child The new child to add. 
     54/// 
     55void 
     56DocumentOutline::addChild (DocumentOutline *child) 
     57{ 
     58    m_Children = g_list_append (m_Children, child); 
     59} 
     60 
     61/// 
     62/// @brief Gets the outline's destination page. 
    6163/// 
    6264/// I'm only using the outlines as a way to go to an specific page, although 
     
    138140} 
    139141 
     142/// 
     143/// @brief Sets the outline item's destination. 
     144/// 
     145/// @see getDestination(). 
     146/// 
     147/// @param destination The page number, starting from 1, that 
     148///                    this outline links to. 
     149/// 
    140150void 
    141151DocumentOutline::setDestination (gint destination) 
     
    144154} 
    145155 
    146 void 
    147 DocumentOutline::setChildren (GooList *childrenList) 
    148 { 
    149     if ( NULL != childrenList ) 
    150     { 
    151         int numChildren = childrenList->getLength (); 
    152         for ( int childIndex = 0; childIndex < numChildren; childIndex++) 
    153         { 
    154             OutlineItem *item = (OutlineItem *)childrenList->get (childIndex); 
    155             // Get the title. 
    156             gchar *title = g_ucs4_to_utf8 (item->getTitle (),  
    157                                            item->getTitleLength (), 
    158                                            NULL, NULL, NULL);             
    159             // The page destination. 
    160             gint destination = 1; 
    161             LinkAction *action = item->getAction (); 
    162             if ( NULL != action ) 
    163             { 
    164                 if ( action->isOk () && actionGoTo == action->getKind () ) 
    165                 { 
    166                     LinkDest *dest = ((LinkGoTo *)action)->getDest (); 
    167                     if ( dest->isOk () && dest->isPageRef () ) 
    168                     { 
    169                         Ref ref = dest->getPageRef (); 
    170                         destination = m_Document->findPage (ref.num, ref.gen); 
    171                     } 
    172                     else if ( dest->isOk () ) 
    173                     { 
    174                         destination = dest->getPageNum (); 
    175                     } 
    176                 } 
    177             } 
    178             // Create the child. 
    179             DocumentOutline *child = new DocumentOutline (m_Document); 
    180             child->setParent (this); 
    181             child->setTitle (title); 
    182             g_free (title); 
    183             child->setDestination (destination); 
    184             // Add to the list of children. 
    185             m_Children = g_list_append (m_Children, child); 
    186             // And add its own children. 
    187             if ( item->hasKids () ) 
    188             { 
    189                 // I need to open the outline because if it's not  
    190                 // open then the getKids() function returns NULL. 
    191                 item->open (); 
    192                 child->setChildren (item->getKids ()); 
    193             } 
    194         } 
    195     } 
    196 } 
    197  
    198 /// 
    199 /// @brief Sets the outline. 
    200 /// 
    201 /// This is only called for the root outline element when loading a document. 
    202 /// Fills in the list of outline items from the document. 
    203 /// 
    204 /// @param outline The outline from the documents. 
    205 /// 
    206 void 
    207 DocumentOutline::setOutline (Outline *outline) 
    208 { 
    209     g_assert (NULL != outline && "Tried to set a NULL outline."); 
    210      
    211     setTitle (""); 
    212     setDestination (1); 
    213          
    214     setChildren (outline->getItems ()); 
    215 } 
    216  
     156/// 
     157/// @brief Sets the item's parent. 
     158/// 
     159/// This is currently not used. 
     160/// 
     161/// @param parent The outline item's parent. 
     162/// 
    217163void 
    218164DocumentOutline::setParent (DocumentOutline *parent) 
     
    221167} 
    222168 
     169/// 
     170/// @brief Sets the outline item's title. 
     171/// 
     172/// @param title The title to set to the outline. 
     173/// 
    223174void 
    224175DocumentOutline::setTitle (const char *title) 
     
    230181} 
    231182 
     183/// 
     184/// @brief Deletes an outline item's child. 
     185/// 
     186/// This function is called by the destructor to delete all childs in 
     187/// the m_Children list. 
     188/// 
     189/// @param child The data element in the list's item. 
     190/// @param userData The data passed to the g_list_foreach() function. 
     191///                 Currently unused. 
     192/// 
    232193void 
    233194deleteChild (gpointer child, gpointer userData)