#include <PDFApp.h>
Public Member Functions | |
CPDFApp (int *argc, char *argv[]) | |
~CPDFApp (void) | |
GBool | open (GooString *fileName, GooString *ownerPassword=NULL, GooString *userPassword=NULL) |
void | run () |
void | close () |
void | quit (GBool bNormal=gTrue) |
void * | getAuthData () |
Protected Member Functions | |
void | initialize () |
void | setupX (int *argc, char *argv[]) |
void | clear () |
void | loadSettings (GooString *fileName) |
void | saveSettings () |
void | loadScribble (GooString *fileName, GBool bEnable=gTrue) |
Private Attributes | |
Controller | controller |
char | path [MAX_PATH] |
Definition at line 32 of file PDFApp.h.
CPDFApp::CPDFApp | ( | int * | argc, | |
char * | argv[] | |||
) |
Definition at line 27 of file PDFApp.cpp.
00028 { 00029 controller.app = this; 00030 setupX(argc, argv); 00031 initialize(); 00032 }
CPDFApp::~CPDFApp | ( | void | ) |
void CPDFApp::initialize | ( | ) | [protected] |
Definition at line 48 of file PDFApp.cpp.
00049 { 00050 globalParams = new GlobalParams(""); 00051 00052 // initialize core 00053 SplashColor white; 00054 white[0] = 255; 00055 white[1] = 255; 00056 white[2] = 255; 00057 controller.core = new CPDFCore(splashModeRGB8, 4, gFalse, white); 00058 controller.core->setController(&controller); 00059 00060 // Initialize controller. notice!!! 00061 // All controller parameters should be initialized here 00062 // there are only 3 pointers in controller 00063 00064 // start render thread 00065 controller.thread.start(&controller.param); 00066 }
void CPDFApp::setupX | ( | int * | argc, | |
char * | argv[] | |||
) | [protected] |
Definition at line 106 of file PDFApp.cpp.
00107 { 00108 // setup X 00109 controller.gtkMgr.setupWindow(); 00110 00111 // Initialize view 00112 controller.view = new CPDFView(controller.gtkMgr.window, &controller); 00113 }
void CPDFApp::clear | ( | ) | [protected] |
Definition at line 39 of file PDFApp.cpp.
00040 { 00041 close(); 00042 delete controller.core; controller.core = NULL; 00043 delete controller.view; controller.view = NULL; 00044 PV_LOGPRINTF("Going to remove globalParams %p", globalParams); 00045 delete globalParams; globalParams = NULL; 00046 }
void CPDFApp::loadSettings | ( | GooString * | fileName | ) | [protected] |
Definition at line 116 of file PDFApp.cpp.
00117 { 00118 // load settings from manifest file 00119 // filename is the container path 00120 strncpy(path, fileName->getCString(), MAX_PATH); 00121 char * p = strrchr(path, '/'); 00122 *p = 0; 00123 controller.settings.load(path); 00124 controller.validateSettings(); 00125 }
void CPDFApp::saveSettings | ( | ) | [protected] |
Definition at line 151 of file PDFApp.cpp.
00152 { 00153 controller.settings.save(path); 00154 }
void CPDFApp::loadScribble | ( | GooString * | fileName, | |
GBool | bEnable = gTrue | |||
) | [protected] |
Definition at line 128 of file PDFApp.cpp.
00129 { 00130 #if (PV_PROFILE_ON) 00131 int t1 = controller.getHighTimeStamp(); 00132 #endif 00133 00134 if (bEnable) 00135 { 00136 controller.scbMgr.open(fileName->getCString()); 00137 controller.channels.initScribbleState(controller.scbMgr.getScbDoc()); 00138 } 00139 else 00140 { 00141 PV_LOGPRINTF("Inhibit scribble by manifest!"); 00142 controller.channels.initScribbleState(0); 00143 } 00144 00145 #if (PV_PROFILE_ON) 00146 int t2 = controller.getHighTimeStamp(); 00147 PV_DUMP("CPDFApp::loadScribble uses %d\n", t2 - t1); 00148 #endif 00149 }
GBool CPDFApp::open | ( | GooString * | fileName, | |
GooString * | ownerPassword = NULL , |
|||
GooString * | userPassword = NULL | |||
) |
Definition at line 156 of file PDFApp.cpp.
00159 { 00160 PV_LOGPRINTF("Open document %s", fileName->getCString()); 00161 if (errNone == controller.core->open(fileName, ownerPassword, userPassword, controller.core)) 00162 { 00163 PV_LOGPRINTF("Open document %s done!", fileName->getCString()); 00164 00165 // initialize page list 00166 PDFDoc * pdfdoc = controller.core->getPDFDoc(); 00167 controller.pageList.reset(pdfdoc->getNumPages()); 00168 00169 // load settings 00170 loadSettings(fileName); 00171 00172 // load scribble 00173 loadScribble(fileName, controller.settings.isScribbleEnabled()); 00174 00175 // initialize the view according to settings 00176 controller.view->initializeViews(); 00177 00178 // render page(s) 00179 controller.view->displayPage(controller.settings.getCurrentPage(), ScrollToPosition); 00180 00181 // init page bar 00182 controller.channels.pagebar_set_count(pdfdoc->getNumPages()); 00183 return gTrue; 00184 } 00185 PV_ERRORPRINTF("Could not open file!"); 00186 return gFalse; 00187 }
void CPDFApp::run | ( | ) |
void CPDFApp::close | ( | ) |
Definition at line 93 of file PDFApp.cpp.
00094 { 00095 controller.thread.stop(); 00096 PV_LOGPRINTF("Stop Render Thread!"); 00097 controller.core->close(); 00098 PV_LOGPRINTF("Clear PDFCore!"); 00099 controller.pageList.clear(); 00100 PV_LOGPRINTF("Clear page list!"); 00101 controller.todoList.clear(); 00102 PV_LOGPRINTF("Clear todo list!"); 00103 controller.view->onClose(); 00104 }
void CPDFApp::quit | ( | GBool | bNormal = gTrue |
) |
Definition at line 75 of file PDFApp.cpp.
00076 { 00077 // clear viewer 00078 clear(); 00079 00080 // save settings 00081 if (bNormal) 00082 { 00083 saveSettings(); 00084 gtk_main_quit (); 00085 } 00086 else 00087 { 00088 delete this; 00089 _exit(0); 00090 } 00091 }
void * CPDFApp::getAuthData | ( | ) |
Definition at line 190 of file PDFApp.cpp.
00191 { 00192 GooString * password = NULL; 00193 if (controller.view) 00194 { 00195 password = controller.view->getPassword(); 00196 return password; 00197 } 00198 return NULL; 00199 }
Controller CPDFApp::controller [private] |
char CPDFApp::path[MAX_PATH] [private] |