00001 /* 00002 * Copyright (C) 2006, iRex Technologies B.V. 00003 * 00004 * This program is free software; you can redistribute it and/or modify 00005 * it under the terms of the GNU General Public License as published by 00006 * the Free Software Foundation; either version 2, or (at your option) 00007 * any later version. 00008 * 00009 * This program is distributed in the hope that it will be useful, 00010 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00011 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00012 * GNU General Public License for more details. 00013 * 00014 * You should have received a copy of the GNU General Public License 00015 * along with this program; if not, write to the Free Software 00016 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 00017 */ 00018 00019 #ifndef PAGEINFO_H_ 00020 #define PAGEINFO_H_ 00021 00022 #include <X11/Xlib.h> 00023 #include <gdk/gdkx.h> 00024 00025 #include "splash/SplashBitmap.h" 00026 #include "poppler/Object.h" 00027 #include "poppler/SplashOutputDev.h" 00028 #include "goo/GooList.h" 00029 #include "poppler/Link.h" 00030 #include "poppler/TextOutputDev.h" 00031 #include "poppler/Gfx.h" 00032 #include <signal.h> 00033 #include "utils.h" 00034 00036 // pageinfo stores all information used to 00037 // 1. render a pdf page 00038 // 2. display a pdf page 00039 // 3. calculat a pdf page (A4,..., A0) 00040 // 4. something related to state 00042 class CPageInfo 00043 { 00044 public: 00045 CPageInfo(void); 00046 ~CPageInfo(void); 00047 00048 public: 00049 double pageDx; // getPageCropWidth 00050 double pageDy; // getPageCropHeight 00051 int pageRotate; // getPageRotate 00052 double pageZoom; // always >0, real zoom 00053 double hDPI; // out 00054 double vDPI; // out 00055 int rotate; // rotate, global setting 00056 int pageNumber; 00057 int timestamp; // pre-rendering 00058 int attributes; // used to protect page 00059 00060 // render result 00061 SplashBitmap * bitmap; // by SplashOutputDev 00062 Links * links; 00063 TextPage * text; 00064 double ctm[6]; // for hyperlink 00065 double ictm[6]; // for hyperlink 00066 00067 public: 00068 // methods 00069 void initialize(); 00070 void clear(); 00071 GBool isSame(const int pn, const double zoom, const int rotate); 00072 double calZoom(); 00073 }; 00074 typedef CPageInfo * PageInfoPtr; 00075 00077 // page list management. It should be thread-safe 00079 class TodoItem; 00080 class PageList 00081 { 00082 private: 00083 pthread_mutex_t mutex; // protect the list 00084 PageInfoPtr * list; 00085 int length; 00086 00087 void initialize(); 00088 00089 public: 00090 PageList(); 00091 ~PageList(); 00092 00093 void reset(const int size); 00094 void clear(); 00095 void addPage(CPageInfo * info); 00096 void removeOldestOne(const int center); 00097 CPageInfo * getPage(const int number); 00098 CPageInfo * checkPage(const CPageInfo & info); 00099 CPageInfo * checkPage(const TodoItem * pItem); 00100 void dump(); // for debug 00101 }; 00102 00104 // todo list management. It should be thread-safe 00106 class TodoItem 00107 { 00108 public: 00109 TodoItem(); 00110 ~TodoItem(); 00111 TodoItem(const TodoItem & right); 00112 00113 public: 00114 double zoom; 00115 int rotate; 00116 int pageNumber; 00117 int timeStamp; // time stamp when request is issued 00118 }; 00119 00120 class TodoList 00121 { 00122 private: 00123 pthread_mutex_t mutex; // protect the list 00124 GooList * list; 00125 00126 void initialize(); 00127 void removeDup(TodoItem * item); // remove duplicated items by time stamp 00128 00129 public: 00130 TodoList(); 00131 ~TodoList(); 00132 00133 void clear(); 00134 void pushItem(TodoItem * item, GBool bHead = gFalse, GBool bRemoveDup = gTrue); 00135 TodoItem * popItem(); 00136 }; 00137 00138 #endif