00001 /* 00002 * File Name: pdf_toc.h 00003 */ 00004 00005 /* 00006 * This file is part of uds-plugin-pdf. 00007 * 00008 * uds-plugin-pdf is free software: you can redistribute it and/or modify 00009 * it under the terms of the GNU General Public License as published by 00010 * the Free Software Foundation, either version 2 of the License, or 00011 * (at your option) any later version. 00012 * 00013 * uds-plugin-pdf is distributed in the hope that it will be useful, 00014 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00015 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00016 * GNU General Public License for more details. 00017 * 00018 * You should have received a copy of the GNU General Public License 00019 * along with this program. If not, see <http://www.gnu.org/licenses/>. 00020 */ 00021 00022 /** 00023 * Copyright (C) 2008 iRex Technologies B.V. 00024 * All rights reserved. 00025 */ 00026 00027 #ifndef _PDF_TOC_H_ 00028 #define _PDF_TOC_H_ 00029 00030 #include "pdf_define.h" 00031 00032 namespace pdf 00033 { 00034 00035 struct TocItem 00036 { 00037 string anchor; ///< The anchor. 00038 string text; ///< The display text. 00039 string goto_anchor; ///< The anchor of destination. 00040 struct TocItem * sibling; ///< The next sibling. 00041 struct TocItem * first_child; ///< The first child. 00042 00043 TocItem(); 00044 ~TocItem(); 00045 00046 bool is_invisible_root(); 00047 void disconnect(); 00048 }; 00049 00050 class PDFController; 00051 class PDFToc 00052 { 00053 public: 00054 PDFToc(PDFController *doc); 00055 ~PDFToc(void); 00056 00057 // check, get and free table of content 00058 bool has_toc(); 00059 TocItem * get_toc(void); 00060 void free_toc(TocItem * p_toc); 00061 00062 bool get_goto_anchor_of_toc_idx(int idx, string & anchor); 00063 00064 private: 00065 /// Create a new toc item 00066 TocItem * create_new_item(OutlineItem * data, int idx); 00067 00068 /// Append children of current toc item to toc tree 00069 /// This function will return the first child of the parent 00070 void append_toc_children(TocItem * parent, int & idx, GooList * items); 00071 00072 /// Get the goto anchor of a toc item 00073 bool get_dest_page_of_toc_item(OutlineItem * item, int & page_num); 00074 00075 PDFController *document() { return doc_ctrl; } 00076 00077 private: 00078 PDFController *doc_ctrl; ///< Reference to the PDFDoc. 00079 TocItem *toc; ///< The result of getting toc. 00080 }; 00081 00082 }; 00083 #endif // _PDF_TOC_H_ 00084 00085