pdf::PDFToc Class Reference

#include <pdf_toc.h>

Collaboration diagram for pdf::PDFToc:
Collaboration graph
[legend]

Public Member Functions

 PDFToc (PDFController *doc)
 ~PDFToc (void)
bool has_toc ()
TocItemget_toc (void)
void free_toc (TocItem *p_toc)
bool get_goto_anchor_of_toc_idx (int idx, string &anchor)

Detailed Description

Definition at line 51 of file pdf_toc.h.


Constructor & Destructor Documentation

pdf::PDFToc::PDFToc ( PDFController doc  ) 

Definition at line 85 of file pdf_toc.cpp.

00086 : doc_ctrl(doc)
00087 , toc(0)
00088 {
00089 }

pdf::PDFToc::~PDFToc ( void   ) 

Definition at line 91 of file pdf_toc.cpp.

References free_toc().

00092 {
00093     free_toc(toc);
00094 }

Here is the call graph for this function:


Member Function Documentation

void pdf::PDFToc::free_toc ( TocItem p_toc  ) 

Definition at line 276 of file pdf_toc.cpp.

Referenced by ~PDFToc().

00277 {
00278     //if (!p_toc)
00279     //{
00280     //    return;
00281     //}
00282 
00283     //if (p_toc->first_child)
00284     //{
00285     //    free_toc(p_toc->first_child);
00286     //}
00287     //else if (p_toc->sibling)
00288     //{
00289     //    free_toc(p_toc->sibling);
00290     //}
00291     //else 
00292     //{
00293     //    delete p_toc;
00294     //}
00295     if (p_toc != 0)
00296     {
00297         delete p_toc;
00298     }
00299 }

Here is the caller graph for this function:

bool pdf::PDFToc::get_goto_anchor_of_toc_idx ( int  idx,
string anchor 
)

Definition at line 303 of file pdf_toc.cpp.

References pdf::TocItem::first_child, pdf::TocItem::goto_anchor, and pdf::TocItem::sibling.

00304 {
00305     int i = -1;
00306 
00307     typedef list<TocItem *> Stack;
00308     Stack stack;
00309 
00310     TocItem * cur = toc;
00311     stack.push_back(cur);
00312 
00313     while (!stack.empty()) 
00314     {
00315         // Go down to the highest level.
00316         cur = stack.back();
00317         while (cur) 
00318         {
00319             // Visit cur
00320             i++;
00321 
00322             // Condition judgement.
00323             if (i == idx)
00324             {
00325                 /*LOGPRINTF("%d %s", idx, cur->goto_anchor.c_str());*/
00326                 anchor = cur->goto_anchor.c_str();
00327                 return true;
00328             }
00329             
00330             stack.push_back(cur->first_child);
00331             cur = stack.back();
00332         }
00333        
00334         // Popup the empty pointer.
00335         stack.pop_back();
00336 
00337         // Go to the next sibling.
00338         if (!stack.empty()) 
00339         {
00340             cur = stack.back();
00341             stack.pop_back();
00342             stack.push_back(cur->sibling);
00343         }
00344     }
00345 
00346     return false;
00347 }

TocItem * pdf::PDFToc::get_toc ( void   ) 

Definition at line 115 of file pdf_toc.cpp.

References pdf::TocItem::disconnect(), pdf::TocItem::first_child, pdf::PDFController::get_pdf_doc(), and has_toc().

00116 {
00117     if (toc)
00118     {
00119         // return the toc if it exists.
00120         return toc;
00121     }
00122 
00123     if (!has_toc())
00124     {
00125         return 0;
00126     }
00127 
00128     //assert(doc_ctrl != 0);
00129     if (doc_ctrl == 0)
00130     {
00131         return 0;
00132     }
00133 
00134     Outline * outline = doc_ctrl->get_pdf_doc()->getOutline();
00135     GooList * items = outline->getItems();
00136 
00137     int idx = 0;
00138     // construct the invisible root node.
00139     TocItem root;
00140 
00141     append_toc_children(&root, idx, items);
00142     toc = root.first_child;
00143 
00144     // disconnect the root node
00145     root.disconnect();
00146     return toc;
00147 }

Here is the call graph for this function:

bool pdf::PDFToc::has_toc (  ) 

Definition at line 96 of file pdf_toc.cpp.

References pdf::PDFController::get_pdf_doc(), and LOGPRINTF.

Referenced by get_toc().

00097 {
00098     Outline * outline = doc_ctrl->get_pdf_doc()->getOutline();
00099     if (!outline)
00100     {
00101         LOGPRINTF("No table of content.");
00102         return false;
00103     }
00104 
00105     GooList * items = outline->getItems();
00106     if (!items || items->getLength() < 1)
00107     {
00108         LOGPRINTF("No table of content.");
00109         return false;
00110     }
00111 
00112     return true;
00113 }

Here is the call graph for this function:

Here is the caller graph for this function:


The documentation for this class was generated from the following files:
Generated by  doxygen 1.6.2-20100208