pdf_anchor.h

Go to the documentation of this file.
00001 /*
00002  * File Name: pdf_anchor.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_ANCHOR_H_
00028 #define PDF_ANCHOR_H_
00029 
00030 #include "pdf_define.h"
00031 
00032 namespace pdf
00033 {
00034 
00035 class PDFAnchor
00036 {
00037 public:
00038     int     page_num;      ///< The page number, default as 1
00039     int     word_num;      ///< The word offset, default as -1
00040     int     char_idx;      ///< The index of the charactor, default as -1
00041     int     link_idx;      ///< The link number, default as -1
00042     int     toc_idx;       ///< The index of the toc item
00043     string  file_name;     ///< Name of the file which is pointed by the anchor
00044 
00045 public:
00046     PDFAnchor();
00047     PDFAnchor(const string &anchor);
00048     ~PDFAnchor();
00049 
00050     bool operator == (const PDFAnchor &right) const;
00051 
00052     /// Estimate whether it is an end anchor
00053     bool is_end_anchor() const;
00054 
00055     /// Set this anchor to be end anchor
00056     void set_end_anchor();
00057 
00058     /// Get the string of this anchor
00059     const string& get_string();
00060 
00061     /// return 1 means a1 > a2
00062     /// return -1 means a1 < a2
00063     /// return 0 means a1 = a2
00064     /// return ANCHOR_COMPARE_ERROR means error
00065     static int compare(const PDFAnchor &a1, const PDFAnchor &a2);
00066 
00067     void validate_for_getting_text(void);
00068 
00069 private:
00070     string    anchor_str;
00071 
00072 private:
00073     bool operator < (const PDFAnchor &right) const;
00074     bool operator > (const PDFAnchor &right) const;
00075 
00076     /// Parse the anchor string to pdf parameters
00077     bool parse(const string &anchor);
00078 
00079     /// Package the pdf parameters into anchor string
00080     bool pack(string &anchor);
00081 
00082     /// Reset all of the parameters to default value
00083     void reset();
00084 
00085     /// Get number of a sub string
00086     int get_num(const string &page_sub_str);
00087 
00088     /// Get prefix of a sub string
00089     const string get_prefix(const string &str);
00090 
00091     /// Get postfix of a sub string
00092     const string get_postfix(const string &str);
00093 
00094 };
00095 
00096 };//namespace pdf
00097 
00098 #endif //PDF_ANCHOR_H_
00099 
Generated by  doxygen 1.6.2-20100208