pdf_define.h

Go to the documentation of this file.
00001 /*
00002  * File Name: pdf_define.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_DEFINE_H_
00028 #define PDF_DEFINE_H_
00029 
00030 #include <vector>
00031 #include <string>
00032 #include <stdio.h>
00033 #include <math.h>
00034 #include <algorithm>
00035 #include <list>
00036 #include <cassert>
00037 #include <glib.h>
00038 #include <iconv.h>
00039 #include <iostream>
00040 #include <fstream>
00041 
00042 #ifdef _WIN32
00043 #include <unordered_map>
00044 #else
00045 #include <tr1/unordered_map>
00046 #endif
00047 
00048 #include <goo/GooString.h>
00049 #include <goo/GooList.h>
00050 #include <splash/SplashBitmap.h>
00051 #include <poppler/Link.h>
00052 #include <poppler/TextOutputDev.h>
00053 #include <poppler/PDFDoc.h>
00054 #include <poppler/GlobalParams.h>
00055 #include <poppler/Outline.h>
00056 #include <poppler/Link.h>
00057 
00058 #include "plugin_inc.h"
00059 #include "plugin_type.h"
00060 #include "plugin_render.h"
00061 #include "string_impl.h"
00062 
00063 namespace pdf
00064 {
00065 
00066 using namespace std;
00067 
00068 typedef string string;
00069 typedef vector<std::string> stringlist;
00070 
00071 #ifdef WIN32
00072 #include <windows.h>
00073 #define pdf_printf sprintf_s
00074 #else
00075 #include <sys/time.h>
00076 #define pdf_printf sprintf
00077 #endif
00078 
00079 #define RENDER_TEXT
00080 #define PRERENDER_NUMBER       2
00081 
00082 #define ZERO_RANGE             0.0001
00083 #define PRERENDER_REF_ID       -1
00084 
00085 #define ANCHOR_COMPARE_ERROR   -2
00086 #define DEFAULT_SIZE_LIMIT      30 * 1024 * 1024
00087 
00088 #define MAX_ZOOM               6401.0f
00089 #define MIN_ZOOM               8.0f
00090 
00091 typedef enum
00092 {
00093     PDF_SEARCH_ALL = 0,
00094     PDF_SEARCH_NEXT
00095 }PDFSearchType;
00096 
00097 /// Define the PluginRangeImpl for replacing the reference of PluginRange.
00098 /// This class would destroy the start and end anchor automatically.
00099 class PluginRangeImpl
00100 {
00101 public:
00102     PluginRangeImpl()
00103         : start_anchor(0)
00104         , end_anchor(0)
00105     {}
00106     ~PluginRangeImpl()
00107     {
00108         if (start_anchor != 0)
00109         {
00110             delete (StringImpl*)start_anchor;
00111             start_anchor = 0;
00112         }
00113         if (end_anchor != 0)
00114         {
00115             delete (StringImpl*)end_anchor;
00116             end_anchor = 0;
00117         }
00118     }
00119 public:
00120     UDSString* start_anchor;
00121     UDSString* end_anchor;
00122 };
00123 
00124 /// Get current time
00125 int get_cur_time();
00126 
00127 /// Estimate whether the render area is valid
00128 bool is_render_area_valid(const RenderArea & area);
00129 
00130 /// Get the content area in pixel
00131 void get_content_area_in_pixel(const RenderArea & area,
00132                                const int origin_width,
00133                                const int origin_height,
00134                                PluginRectangle & rect);
00135 
00136 /// Compare two PDF pages
00137 class PDFPage;
00138 bool operator < (const PDFPage & left, const PDFPage & right);
00139 bool operator >= (const PDFPage & left, const PDFPage & right);
00140 
00141 /// Compare the priority of two pages
00142 class PDFPrerenderPolicy;
00143 int compare_priority(const int src_page,
00144                      const int dst_page,
00145                      PDFPrerenderPolicy *policy);
00146 };
00147 
00148 #endif //PDF_DEFINE_H_
00149 
Generated by  doxygen 1.6.2-20100208