1 // Copyright 2014 PDFium Authors. All rights reserved. 2 // Use of this source code is governed by a BSD-style license that can be 3 // found in the LICENSE file. 4 5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com 6 7 #ifndef _FPDFSDK_MGR_H 8 #define _FPDFSDK_MGR_H 9 10 #include "fsdk_common.h" 11 #include "fsdk_define.h" 12 #include "fx_systemhandler.h" 13 #include "fsdk_baseannot.h" 14 #include "fsdk_baseform.h" 15 #include "fpdfformfill.h" 16 #include "fsdk_annothandler.h" 17 #include "fsdk_actionhandler.h" 18 19 //cross platform keycode and events define. 20 #include "fpdf_fwlevent.h" 21 22 23 class CPDFSDK_Document; 24 class CPDFSDK_PageView; 25 class CPDFSDK_Annot; 26 class CFFL_IFormFiller; 27 class CPDFSDK_Widget; 28 class IFX_SystemHandler; 29 class CPDFSDK_ActionHandler; 30 class CJS_RuntimeFactory; 31 32 #include "javascript/IJavaScript.h" 33 34 class CPDFDoc_Environment 35 { 36 public: 37 CPDFDoc_Environment(CPDF_Document * pDoc); 38 ~CPDFDoc_Environment(); 39 40 int RegAppHandle(FPDF_FORMFILLINFO* pFFinfo);//{ m_pInfo = pFFinfo; return TRUE;} 41 42 virtual void Release() 43 { 44 if (m_pInfo && m_pInfo->Release) 45 m_pInfo->Release(m_pInfo); 46 delete this; 47 } 48 49 virtual void FFI_Invalidate(FPDF_PAGE page, double left, double top, double right, double bottom) 50 { 51 if (m_pInfo && m_pInfo->FFI_Invalidate) 52 { 53 m_pInfo->FFI_Invalidate(m_pInfo, page, left, top, right, bottom); 54 } 55 } 56 virtual void FFI_OutputSelectedRect(FPDF_PAGE page, double left, double top, double right, double bottom) 57 { 58 if (m_pInfo && m_pInfo->FFI_OutputSelectedRect) 59 { 60 m_pInfo->FFI_OutputSelectedRect(m_pInfo, page, left, top, right, bottom); 61 } 62 } 63 64 virtual void FFI_SetCursor(int nCursorType) 65 { 66 if (m_pInfo && m_pInfo->FFI_SetCursor) 67 { 68 m_pInfo->FFI_SetCursor(m_pInfo, nCursorType); 69 } 70 } 71 72 virtual int FFI_SetTimer(int uElapse, TimerCallback lpTimerFunc) 73 { 74 if (m_pInfo && m_pInfo->FFI_SetTimer) 75 { 76 return m_pInfo->FFI_SetTimer(m_pInfo, uElapse, lpTimerFunc); 77 } 78 return -1; 79 } 80 81 virtual void FFI_KillTimer(int nTimerID) 82 { 83 if (m_pInfo && m_pInfo->FFI_KillTimer) 84 { 85 m_pInfo->FFI_KillTimer(m_pInfo, nTimerID); 86 } 87 } 88 FX_SYSTEMTIME FFI_GetLocalTime() 89 { 90 FX_SYSTEMTIME fxtime; 91 if(m_pInfo && m_pInfo->FFI_GetLocalTime) 92 { 93 FPDF_SYSTEMTIME systime = m_pInfo->FFI_GetLocalTime(m_pInfo); 94 fxtime.wDay = systime.wDay; 95 fxtime.wDayOfWeek = systime.wDayOfWeek; 96 fxtime.wHour = systime.wHour; 97 fxtime.wMilliseconds = systime.wMilliseconds; 98 fxtime.wMinute = systime.wMinute; 99 fxtime.wMonth = systime.wMonth; 100 fxtime.wSecond = systime.wSecond; 101 fxtime.wYear = systime.wYear; 102 } 103 return fxtime; 104 } 105 106 virtual void FFI_OnChange() 107 { 108 if(m_pInfo && m_pInfo->FFI_OnChange) 109 { 110 m_pInfo->FFI_OnChange(m_pInfo); 111 } 112 } 113 114 virtual FX_BOOL FFI_IsSHIFTKeyDown(FX_DWORD nFlag) 115 { 116 117 return (nFlag & FWL_EVENTFLAG_ShiftKey) != 0; 118 } 119 virtual FX_BOOL FFI_IsCTRLKeyDown(FX_DWORD nFlag) 120 { 121 122 return (nFlag & FWL_EVENTFLAG_ControlKey) != 0; 123 } 124 virtual FX_BOOL FFI_IsALTKeyDown(FX_DWORD nFlag) 125 { 126 127 return (nFlag & FWL_EVENTFLAG_AltKey) != 0; 128 } 129 virtual FX_BOOL FFI_IsINSERTKeyDown(FX_DWORD nFlag) 130 { 131 return FALSE; 132 } 133 134 virtual int JS_appAlert(FX_LPCWSTR Msg, FX_LPCWSTR Title, FX_UINT Type, FX_UINT Icon) 135 { 136 if(m_pInfo && m_pInfo->m_pJsPlatform && m_pInfo->m_pJsPlatform->app_alert) 137 { 138 CFX_ByteString bsMsg = CFX_WideString(Msg).UTF16LE_Encode(); 139 CFX_ByteString bsTitle = CFX_WideString(Title).UTF16LE_Encode(); 140 FPDF_WIDESTRING pMsg = (FPDF_WIDESTRING)bsMsg.GetBuffer(bsMsg.GetLength()); 141 FPDF_WIDESTRING pTitle = (FPDF_WIDESTRING)bsTitle.GetBuffer(bsTitle.GetLength()); 142 int ret = m_pInfo->m_pJsPlatform->app_alert(m_pInfo->m_pJsPlatform, pMsg, pTitle, Type, Icon); 143 bsMsg.ReleaseBuffer(); 144 bsTitle.ReleaseBuffer(); 145 return ret; 146 } 147 return -1; 148 } 149 150 virtual int JS_appResponse(FX_LPCWSTR Question, FX_LPCWSTR Title, FX_LPCWSTR Default, FX_LPCWSTR cLabel, FPDF_BOOL bPassword, void* response, int length) 151 { 152 if (m_pInfo && m_pInfo->m_pJsPlatform && m_pInfo->m_pJsPlatform->app_response) 153 { 154 CFX_ByteString bsQuestion = CFX_WideString(Question).UTF16LE_Encode(); 155 CFX_ByteString bsTitle = CFX_WideString(Title).UTF16LE_Encode(); 156 CFX_ByteString bsDefault = CFX_WideString(Default).UTF16LE_Encode(); 157 CFX_ByteString bsLabel = CFX_WideString(cLabel).UTF16LE_Encode(); 158 FPDF_WIDESTRING pQuestion = (FPDF_WIDESTRING)bsQuestion.GetBuffer(bsQuestion.GetLength()); 159 FPDF_WIDESTRING pTitle = (FPDF_WIDESTRING)bsTitle.GetBuffer(bsTitle.GetLength()); 160 FPDF_WIDESTRING pDefault = (FPDF_WIDESTRING)bsDefault.GetBuffer(bsDefault.GetLength()); 161 FPDF_WIDESTRING pLabel = (FPDF_WIDESTRING)bsLabel.GetBuffer(bsLabel.GetLength()); 162 int ret = m_pInfo->m_pJsPlatform->app_response(m_pInfo->m_pJsPlatform, pQuestion, pTitle, 163 pDefault, pLabel, bPassword, response, length); 164 bsQuestion.ReleaseBuffer(); 165 bsTitle.ReleaseBuffer(); 166 bsDefault.ReleaseBuffer(); 167 bsLabel.ReleaseBuffer(); 168 return ret; 169 } 170 return -1; 171 } 172 173 virtual void JS_appBeep(int nType) 174 { 175 if(m_pInfo && m_pInfo->m_pJsPlatform && m_pInfo->m_pJsPlatform->app_beep) 176 { 177 m_pInfo->m_pJsPlatform->app_beep(m_pInfo->m_pJsPlatform, nType); 178 } 179 } 180 181 virtual CFX_WideString JS_fieldBrowse() 182 { 183 if(m_pInfo && m_pInfo->m_pJsPlatform && m_pInfo->m_pJsPlatform->Field_browse) 184 { 185 int nLen = m_pInfo->m_pJsPlatform->Field_browse(m_pInfo->m_pJsPlatform, NULL, 0); 186 if(nLen <= 0) 187 return L""; 188 char* pbuff = new char[nLen]; 189 if(pbuff) 190 memset(pbuff, 0, nLen); 191 else 192 return L""; 193 nLen = m_pInfo->m_pJsPlatform->Field_browse(m_pInfo->m_pJsPlatform, pbuff, nLen); 194 CFX_ByteString bsRet = CFX_ByteString(pbuff, nLen); 195 CFX_WideString wsRet = CFX_WideString::FromLocal(bsRet); 196 delete[] pbuff; 197 return wsRet; 198 } 199 return L""; 200 } 201 202 CFX_WideString JS_docGetFilePath() 203 { 204 if(m_pInfo && m_pInfo->m_pJsPlatform && m_pInfo->m_pJsPlatform->Doc_getFilePath) 205 { 206 int nLen = m_pInfo->m_pJsPlatform->Doc_getFilePath(m_pInfo->m_pJsPlatform, NULL, 0); 207 if(nLen <= 0) 208 return L""; 209 char* pbuff = new char[nLen]; 210 if(pbuff) 211 memset(pbuff, 0, nLen); 212 else 213 return L""; 214 nLen = m_pInfo->m_pJsPlatform->Doc_getFilePath(m_pInfo->m_pJsPlatform, pbuff, nLen); 215 CFX_ByteString bsRet = CFX_ByteString(pbuff, nLen); 216 CFX_WideString wsRet = CFX_WideString::FromLocal(bsRet); 217 delete[] pbuff; 218 return wsRet; 219 } 220 return L""; 221 } 222 223 void JS_docSubmitForm(void* formData, int length, FX_LPCWSTR URL) 224 { 225 if(m_pInfo && m_pInfo->m_pJsPlatform && m_pInfo->m_pJsPlatform->Doc_submitForm) 226 { 227 CFX_ByteString bsDestination = CFX_WideString(URL).UTF16LE_Encode(); 228 FPDF_WIDESTRING pDestination = (FPDF_WIDESTRING)bsDestination.GetBuffer(bsDestination.GetLength()); 229 m_pInfo->m_pJsPlatform->Doc_submitForm(m_pInfo->m_pJsPlatform, formData, length, pDestination); 230 bsDestination.ReleaseBuffer(); 231 } 232 } 233 234 void JS_docmailForm(void* mailData, int length, FPDF_BOOL bUI,FX_LPCWSTR To, FX_LPCWSTR Subject, FX_LPCWSTR CC, FX_LPCWSTR BCC, FX_LPCWSTR Msg) 235 { 236 if(m_pInfo && m_pInfo->m_pJsPlatform && m_pInfo->m_pJsPlatform->Doc_mail) 237 { 238 CFX_ByteString bsTo = CFX_WideString(To).UTF16LE_Encode(); 239 CFX_ByteString bsCC = CFX_WideString(Subject).UTF16LE_Encode(); 240 CFX_ByteString bsBcc = CFX_WideString(BCC).UTF16LE_Encode(); 241 CFX_ByteString bsSubject = CFX_WideString(Subject).UTF16LE_Encode(); 242 CFX_ByteString bsMsg = CFX_WideString(Msg).UTF16LE_Encode(); 243 FPDF_WIDESTRING pTo = (FPDF_WIDESTRING)bsTo.GetBuffer(bsTo.GetLength()); 244 FPDF_WIDESTRING pCC = (FPDF_WIDESTRING)bsCC.GetBuffer(bsCC.GetLength()); 245 FPDF_WIDESTRING pBcc = (FPDF_WIDESTRING)bsBcc.GetBuffer(bsBcc.GetLength()); 246 FPDF_WIDESTRING pSubject = (FPDF_WIDESTRING)bsSubject.GetBuffer(bsSubject.GetLength()); 247 FPDF_WIDESTRING pMsg = (FPDF_WIDESTRING)bsMsg.GetBuffer(bsMsg.GetLength()); 248 m_pInfo->m_pJsPlatform->Doc_mail(m_pInfo->m_pJsPlatform, mailData, length, bUI, pTo, pSubject, 249 pCC, pBcc, pMsg); 250 bsTo.ReleaseBuffer(); 251 bsCC.ReleaseBuffer(); 252 bsBcc.ReleaseBuffer(); 253 bsSubject.ReleaseBuffer(); 254 bsMsg.ReleaseBuffer(); 255 } 256 } 257 CFX_WideString JS_appbrowseForDoc(FPDF_BOOL bSave, FX_LPCWSTR cFilenameInit) 258 { 259 //to do.... 260 return L""; 261 // if(m_pInfo && m_pInfo->m_pJsPlatform && m_pInfo->m_pJsPlatform->app_browseForDoc) 262 // { 263 // CFX_ByteString bsFilenameInit = CFX_WideString(cFilenameInit).UTF16LE_Encode(); 264 // FPDF_WIDESTRING pFileNameInit = (FPDF_WIDESTRING)bsFilenameInit.GetBuffer(bsFilenameInit.GetLength()); 265 // 266 // m_pInfo->m_pJsPlatform->app_browseForDoc(m_pInfo->m_pJsPlatform, pFileNameInit); 267 // bsFilenameInit.ReleaseBuffer(); 268 // } 269 } 270 271 void JS_docprint(FPDF_BOOL bUI , int nStart, int nEnd, FPDF_BOOL bSilent ,FPDF_BOOL bShrinkToFit,FPDF_BOOL bPrintAsImage ,FPDF_BOOL bReverse ,FPDF_BOOL bAnnotations) 272 { 273 if(m_pInfo && m_pInfo->m_pJsPlatform && m_pInfo->m_pJsPlatform->Doc_print) 274 { 275 m_pInfo->m_pJsPlatform->Doc_print(m_pInfo->m_pJsPlatform, bUI, nStart, nEnd, bSilent, bShrinkToFit, bPrintAsImage, bReverse, bAnnotations); 276 } 277 } 278 void JS_docgotoPage(int nPageNum) 279 { 280 if(m_pInfo && m_pInfo->m_pJsPlatform && m_pInfo->m_pJsPlatform->Doc_gotoPage) 281 { 282 m_pInfo->m_pJsPlatform->Doc_gotoPage(m_pInfo->m_pJsPlatform, nPageNum); 283 } 284 } 285 286 virtual FPDF_PAGE FFI_GetPage(FPDF_DOCUMENT document,int nPageIndex) 287 { 288 if(m_pInfo && m_pInfo->FFI_GetPage) 289 { 290 return m_pInfo->FFI_GetPage(m_pInfo, document, nPageIndex); 291 } 292 return NULL; 293 } 294 295 virtual FPDF_PAGE FFI_GetCurrentPage(FPDF_DOCUMENT document) 296 { 297 if(m_pInfo && m_pInfo->FFI_GetCurrentPage) 298 { 299 return m_pInfo->FFI_GetCurrentPage(m_pInfo, document); 300 } 301 return NULL; 302 } 303 304 int FFI_GetRotation(FPDF_PAGE page) 305 { 306 if(m_pInfo && m_pInfo->FFI_GetRotation) 307 { 308 return m_pInfo->FFI_GetRotation(m_pInfo, page); 309 } 310 return 0; 311 } 312 void FFI_ExecuteNamedAction(FX_LPCSTR namedAction) 313 { 314 if(m_pInfo && m_pInfo->FFI_ExecuteNamedAction) 315 { 316 m_pInfo->FFI_ExecuteNamedAction(m_pInfo, namedAction); 317 } 318 } 319 void FFI_OnSetFieldInputFocus(void* field,FPDF_WIDESTRING focusText, FPDF_DWORD nTextLen, FX_BOOL bFocus) 320 { 321 if(m_pInfo && m_pInfo->FFI_SetTextFieldFocus) 322 { 323 m_pInfo->FFI_SetTextFieldFocus(m_pInfo, focusText, nTextLen, bFocus); 324 } 325 } 326 327 void FFI_DoURIAction(FX_LPCSTR bsURI) 328 { 329 if(m_pInfo && m_pInfo->FFI_DoURIAction) 330 { 331 m_pInfo->FFI_DoURIAction(m_pInfo, bsURI); 332 } 333 } 334 335 void FFI_DoGoToAction(int nPageIndex, int zoomMode, float* fPosArray, int sizeOfArray) 336 { 337 if(m_pInfo && m_pInfo->FFI_DoGoToAction) 338 { 339 m_pInfo->FFI_DoGoToAction(m_pInfo, nPageIndex, zoomMode, fPosArray, sizeOfArray); 340 } 341 } 342 343 public: 344 FX_BOOL IsJSInitiated(); 345 346 public: 347 void SetCurrentDoc(CPDFSDK_Document* pFXDoc) {m_pSDKDoc = pFXDoc;} 348 CPDFSDK_Document* GetCurrentDoc(); 349 CPDF_Document* GetPDFDocument() {return m_pPDFDoc;} 350 // CPDFSDK_Document* GetDocument(int nIndex); 351 // int CountDocuments() {return m_docMap.GetCount();} 352 353 CPDFSDK_Document* OpenDocument(CFX_WideString &fileName); 354 CPDFSDK_Document* OpenMemPDFDoc(CPDF_Document* pNewDoc, CFX_WideString &fileName); 355 FX_BOOL OpenURL(CFX_WideString &filePath); 356 357 358 CFX_ByteString GetAppName() {return "";} 359 360 CFFL_IFormFiller* GetIFormFiller(); 361 IFX_SystemHandler* GetSysHandler() {return m_pSysHandler;} 362 363 public: 364 CPDFSDK_AnnotHandlerMgr* GetAnnotHandlerMgr(); 365 IFXJS_Runtime* GetJSRuntime(); 366 CPDFSDK_ActionHandler* GetActionHander(); 367 private: 368 CPDFSDK_AnnotHandlerMgr* m_pAnnotHandlerMgr; 369 CPDFSDK_ActionHandler* m_pActionHandler; 370 IFXJS_Runtime* m_pJSRuntime; 371 public: 372 FPDF_FORMFILLINFO* GetFormFillInfo() {return m_pInfo;} 373 private: 374 FPDF_FORMFILLINFO* m_pInfo; 375 // CFX_MapPtrTemplate<CPDF_Document*, CPDFSDK_Document*> m_docMap; 376 CPDFSDK_Document* m_pSDKDoc; 377 CPDF_Document* m_pPDFDoc; 378 379 CFFL_IFormFiller* m_pIFormFiller; 380 IFX_SystemHandler* m_pSysHandler; 381 382 public: 383 CJS_RuntimeFactory* m_pJSRuntimeFactory; 384 }; 385 386 387 388 // class CFX_App 389 // { 390 // public: 391 // CFX_App():m_pCurDoc(NULL) {} 392 // void SetAt(CPDF_Document* pPDFDoc, CPDFSDK_Document* pFXDoc); 393 // CPDFSDK_Document* GetAt(CPDF_Document* pPDFDoc); 394 // public: 395 // void SetCurrentDocument(CPDFSDK_Document* pFXDoc) {m_pCurDoc = pFXDoc;} 396 // CPDFSDK_Document* GetCurrentDocument() {return m_pCurDoc;} 397 // private: 398 // CFX_MapPtrTemplate<CPDF_Document*, CPDFSDK_Document*> m_docArray; 399 // CPDFSDK_Document* m_pCurDoc; 400 // }; 401 class CPDFSDK_InterForm; 402 class CPDFSDK_Document 403 { 404 public: 405 CPDFSDK_Document(CPDF_Document* pDoc, CPDFDoc_Environment* pEnv); 406 ~CPDFSDK_Document(); 407 public: 408 CPDFSDK_InterForm* GetInterForm() ; 409 CPDF_Document* GetDocument() {return m_pDoc;} 410 411 public: 412 void InitPageView(); 413 void AddPageView(CPDF_Page* pPDFPage, CPDFSDK_PageView* pPageView); 414 CPDFSDK_PageView* GetPageView(CPDF_Page* pPDFPage, FX_BOOL ReNew = TRUE); 415 CPDFSDK_PageView* GetPageView(int nIndex); 416 CPDFSDK_PageView* GetCurrentView(); 417 void ReMovePageView(CPDF_Page* pPDFPage); 418 void UpdateAllViews(CPDFSDK_PageView* pSender, CPDFSDK_Annot* pAnnot); 419 420 CPDFSDK_Annot* GetFocusAnnot();//{return NULL;} 421 422 IFXJS_Runtime * GetJsRuntime(); 423 424 FX_BOOL SetFocusAnnot(CPDFSDK_Annot* pAnnot, FX_UINT nFlag = 0);//{return FALSE;} 425 FX_BOOL KillFocusAnnot(FX_UINT nFlag = 0); 426 427 FX_BOOL ExtractPages(const CFX_WordArray &arrExtraPages, CPDF_Document* pDstDoc); 428 FX_BOOL InsertPages(int nInsertAt, const CPDF_Document* pSrcDoc, const CFX_WordArray &arrSrcPages); 429 FX_BOOL DeletePages(int nStart, int nCount); 430 FX_BOOL ReplacePages(int nPage, const CPDF_Document* pSrcDoc, const CFX_WordArray &arrSrcPages); 431 432 void OnCloseDocument(); 433 434 int GetPageCount() {return m_pDoc->GetPageCount();} 435 FX_BOOL GetPermissions(int nFlag); 436 FX_BOOL GetChangeMark() {return m_bChangeMask;} 437 void SetChangeMark() {m_bChangeMask = TRUE;} 438 void ClearChangeMark() {m_bChangeMask= FALSE;} 439 // FX_BOOL GetChangeMark(){return FALSE;}//IsAnnotModified()||IsFormModified() || IsWidgetModified()|| m_nChangeMark>0 ;} 440 // void ClearChangeMark(){} 441 CFX_WideString GetPath() ; 442 CPDF_Page* GetPage(int nIndex); 443 CPDFDoc_Environment * GetEnv() {return m_pEnv; } 444 void ProcJavascriptFun(); 445 FX_BOOL ProcOpenAction(); 446 CPDF_OCContext* GetOCContext(); 447 private: 448 //CFX_ArrayTemplate<CPDFSDK_PageView*> m_pageArray; 449 CFX_MapPtrTemplate<CPDF_Page*, CPDFSDK_PageView*> m_pageMap; 450 CPDF_Document* m_pDoc; 451 452 CPDFSDK_InterForm* m_pInterForm; 453 CPDFSDK_Annot* m_pFocusAnnot; 454 CPDFDoc_Environment * m_pEnv; 455 CPDF_OCContext * m_pOccontent; 456 FX_BOOL m_bChangeMask; 457 }; 458 459 class CPDFSDK_PageView 460 { 461 public: 462 CPDFSDK_PageView(CPDFSDK_Document* pSDKDoc,CPDF_Page* page); 463 ~CPDFSDK_PageView(); 464 public: 465 virtual void PageView_OnDraw(CFX_RenderDevice* pDevice, CPDF_Matrix* pUser2Device,CPDF_RenderOptions* pOptions) ; 466 public: 467 CPDF_Annot* GetPDFAnnotAtPoint(FX_FLOAT pageX, FX_FLOAT pageY); 468 CPDFSDK_Annot* GetFXAnnotAtPoint(FX_FLOAT pageX, FX_FLOAT pageY); 469 CPDF_Annot* GetPDFWidgetAtPoint(FX_FLOAT pageX, FX_FLOAT pageY); 470 CPDFSDK_Annot* GetFXWidgetAtPoint(FX_FLOAT pageX, FX_FLOAT pageY); 471 CPDFSDK_Annot* GetFocusAnnot() ; 472 void SetFocusAnnot(CPDFSDK_Annot* pSDKAnnot,FX_UINT nFlag = 0) {m_pSDKDoc->SetFocusAnnot(pSDKAnnot, nFlag);} 473 FX_BOOL KillFocusAnnot(FX_UINT nFlag = 0) {return m_pSDKDoc->KillFocusAnnot(nFlag);} 474 FX_BOOL Annot_HasAppearance(CPDF_Annot* pAnnot); 475 476 CPDFSDK_Annot* AddAnnot(CPDF_Dictionary * pDict); 477 CPDFSDK_Annot* AddAnnot(FX_LPCSTR lpSubType,CPDF_Dictionary * pDict); 478 CPDFSDK_Annot* AddAnnot(CPDF_Annot * pPDFAnnot); 479 FX_BOOL DeleteAnnot(CPDFSDK_Annot* pAnnot); 480 481 int CountAnnots(); 482 CPDFSDK_Annot* GetAnnot(int nIndex); 483 CPDFSDK_Annot* GetAnnotByDict(CPDF_Dictionary * pDict); 484 CPDF_Page* GetPDFPage(){return m_page;} 485 CPDF_Document* GetPDFDocument(); 486 CPDFSDK_Document* GetSDKDocument() {return m_pSDKDoc;} 487 public: 488 virtual FX_BOOL OnLButtonDown(const CPDF_Point & point, FX_UINT nFlag); 489 virtual FX_BOOL OnLButtonUp(const CPDF_Point & point, FX_UINT nFlag); 490 virtual FX_BOOL OnChar(int nChar, FX_UINT nFlag); 491 virtual FX_BOOL OnKeyDown(int nKeyCode, int nFlag); 492 virtual FX_BOOL OnKeyUp(int nKeyCode, int nFlag); 493 494 virtual FX_BOOL OnMouseMove(const CPDF_Point & point, int nFlag); 495 virtual FX_BOOL OnMouseWheel(double deltaX, double deltaY,const CPDF_Point& point, int nFlag); 496 virtual FX_BOOL IsValidAnnot(FX_LPVOID p); 497 public: 498 virtual void GetCurrentMatrix(CPDF_Matrix& matrix) {matrix = m_curMatrix;} 499 virtual void UpdateRects(CFX_RectArray& rects); 500 void UpdateView(CPDFSDK_Annot* pAnnot); 501 CFX_PtrArray* GetAnnotList(){ return &m_fxAnnotArray; } 502 503 public: 504 virtual int GetPageIndex(); 505 void LoadFXAnnots(); 506 private: 507 CPDF_Matrix m_curMatrix; 508 509 private: 510 void PageView_OnHighlightFormFields(CFX_RenderDevice* pDevice, CPDFSDK_Widget* pWidget); 511 512 private: 513 CPDF_Page* m_page; 514 CPDF_AnnotList* m_pAnnotList; 515 516 //CPDFSDK_Annot* m_pFocusAnnot; 517 CFX_PtrArray m_fxAnnotArray; 518 519 CPDFSDK_Document* m_pSDKDoc; 520 private: 521 CPDFSDK_Widget* m_CaptureWidget; 522 FX_BOOL m_bEnterWidget; 523 FX_BOOL m_bExitWidget; 524 FX_BOOL m_bOnWidget; 525 public: 526 void SetValid(FX_BOOL bValid) {m_bValid = bValid;} 527 FX_BOOL IsValid() {return m_bValid;} 528 private: 529 FX_BOOL m_bValid; 530 }; 531 532 533 template<class TYPE> 534 class CGW_ArrayTemplate : public CFX_ArrayTemplate<TYPE> 535 { 536 public: 537 CGW_ArrayTemplate(){} 538 virtual ~CGW_ArrayTemplate(){} 539 540 typedef int (*LP_COMPARE)(TYPE p1, TYPE p2); 541 542 void Sort(LP_COMPARE pCompare, FX_BOOL bAscent = TRUE) 543 { 544 int nSize = this->GetSize(); 545 QuickSort(0, nSize -1, bAscent, pCompare); 546 } 547 548 private: 549 void QuickSort(FX_UINT nStartPos, FX_UINT nStopPos, FX_BOOL bAscend, LP_COMPARE pCompare) 550 { 551 if (nStartPos >= nStopPos) return; 552 553 if ((nStopPos - nStartPos) == 1) 554 { 555 TYPE Value1 = this->GetAt(nStartPos); 556 TYPE Value2 = this->GetAt(nStopPos); 557 558 int iGreate = (*pCompare)(Value1, Value2); 559 if ((bAscend && iGreate > 0) || (!bAscend && iGreate < 0)) 560 { 561 this->SetAt(nStartPos, Value2); 562 this->SetAt(nStopPos, Value1); 563 } 564 return; 565 } 566 567 FX_UINT m = (nStartPos + nStopPos) / 2; 568 FX_UINT i = nStartPos; 569 570 TYPE Value = this->GetAt(m); 571 572 while (i < m) 573 { 574 TYPE temp = this->GetAt(i); 575 576 int iGreate = (*pCompare)(temp, Value); 577 if ((bAscend && iGreate > 0) || (!bAscend && iGreate < 0)) 578 { 579 this->InsertAt(m+1, temp); 580 this->RemoveAt(i); 581 m--; 582 } 583 else 584 { 585 i++; 586 } 587 } 588 589 FX_UINT j = nStopPos; 590 591 while (j > m) 592 { 593 TYPE temp = this->GetAt(j); 594 595 int iGreate = (*pCompare)(temp, Value); 596 if ((bAscend && iGreate < 0) || (!bAscend && iGreate > 0)) 597 { 598 this->RemoveAt(j); 599 this->InsertAt(m, temp); 600 m++; 601 } 602 else 603 { 604 j--; 605 } 606 } 607 608 if (nStartPos < m) QuickSort(nStartPos, m, bAscend, pCompare); 609 if (nStopPos > m) QuickSort(m, nStopPos, bAscend, pCompare); 610 } 611 }; 612 613 614 #endif //_FPDFSDK_MGR_H 615 616