OLD | NEW |
1 // Copyright 2014 PDFium Authors. All rights reserved. | 1 // Copyright 2014 PDFium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com | 5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com |
6 | 6 |
7 #include "../../public/fpdf_ext.h" | 7 #include "../../public/fpdf_ext.h" |
8 #include "../../third_party/base/nonstd_unique_ptr.h" | 8 #include "../../third_party/base/nonstd_unique_ptr.h" |
9 #include "../include/fsdk_define.h" | 9 #include "../include/fsdk_define.h" |
10 #include "../include/fsdk_mgr.h" | 10 #include "../include/fsdk_mgr.h" |
11 #include "../include/formfiller/FFL_FormFiller.h" | 11 #include "../include/formfiller/FFL_FormFiller.h" |
12 #include "../include/javascript/IJavaScript.h" | 12 #include "../include/javascript/IJavaScript.h" |
13 | 13 |
14 #if _FX_OS_ == _FX_ANDROID_ | 14 #if _FX_OS_ == _FX_ANDROID_ |
15 #include "time.h" | 15 #include "time.h" |
16 #else | 16 #else |
17 #include <ctime> | 17 #include <ctime> |
18 #endif | 18 #endif |
19 | 19 |
20 //extern CPDFDoc_Environment* g_pFormFillApp; | 20 //extern CPDFDoc_Environment* g_pFormFillApp; |
21 class CFX_SystemHandler:public IFX_SystemHandler | 21 class CFX_SystemHandler:public IFX_SystemHandler |
22 { | 22 { |
23 public: | 23 public: |
24 CFX_SystemHandler(CPDFDoc_Environment* pEnv):m_pEnv(pEnv),m_nCharSet(-1) {} | 24 CFX_SystemHandler(CPDFDoc_Environment* pEnv):m_pEnv(pEnv),m_nCharSet(-1) {} |
25 public: | 25 public: |
26 virtual void InvalidateRect(FX_HWND hWnd, FX_RECT rect) ; | 26 virtual void InvalidateRect(FX_HWND hWnd, FX_RECT rect) ; |
27 virtual void OutputSelectedRect(void* pFormFiller, CPDF_Rect&
rect); | 27 virtual void OutputSelectedRect(void* pFormFiller, CPDF_Rect&
rect); |
28 | 28 |
29 virtual FX_BOOL IsSelectionImplemented(); | 29 virtual bool IsSelectionImplemented(); |
30 | 30 |
31 virtual CFX_WideString GetClipboardText(FX_HWND hWnd){return L"";} | 31 virtual CFX_WideString GetClipboardText(FX_HWND hWnd){return L"";} |
32 virtual FX_BOOL SetClipboardText(FX_HWND hWnd, CFX_WideString st
ring) {return FALSE;} | 32 virtual bool SetClipboardText(FX_HWND hWnd, CFX_WideString strin
g) {return false;} |
33 | 33 |
34 virtual void ClientToScreen(FX_HWND hWnd, int32_t& x, int32_t
& y) {} | 34 virtual void ClientToScreen(FX_HWND hWnd, int32_t& x, int32_t
& y) {} |
35 virtual void ScreenToClient(FX_HWND hWnd, int32_t& x, int32_t
& y) {} | 35 virtual void ScreenToClient(FX_HWND hWnd, int32_t& x, int32_t
& y) {} |
36 | 36 |
37 /*cursor style | 37 /*cursor style |
38 FXCT_ARROW | 38 FXCT_ARROW |
39 FXCT_NESW | 39 FXCT_NESW |
40 FXCT_NWSE | 40 FXCT_NWSE |
41 FXCT_VBEAM | 41 FXCT_VBEAM |
42 FXCT_HBEAM | 42 FXCT_HBEAM |
43 FXCT_HAND | 43 FXCT_HAND |
44 */ | 44 */ |
45 virtual void SetCursor(int32_t nCursorType); | 45 virtual void SetCursor(int32_t nCursorType); |
46 | 46 |
47 virtual FX_HMENU CreatePopupMenu() {return NULL;} | 47 virtual FX_HMENU CreatePopupMenu() {return NULL;} |
48 virtual FX_BOOL AppendMenuItem(FX_HMENU hMenu, int32_t nIDNewIte
m, CFX_WideString string) {return FALSE;} | 48 virtual bool AppendMenuItem(FX_HMENU hMenu, int32_t nIDNewItem,
CFX_WideString string) {return false;} |
49 virtual FX_BOOL EnableMenuItem(FX_HMENU hMenu, int32_t nIDItem,
FX_BOOL bEnabled) {return FALSE;} | 49 virtual bool EnableMenuItem(FX_HMENU hMenu, int32_t nIDItem, boo
l bEnabled) {return false;} |
50 virtual int32_t TrackPopupMenu(FX_HMENU hMenu, int32_t x, int32_t y,
FX_HWND hParent) {return -1;} | 50 virtual int32_t TrackPopupMenu(FX_HMENU hMenu, int32_t x, int32_t y,
FX_HWND hParent) {return -1;} |
51 virtual void DestroyMenu(FX_HMENU hMenu) {} | 51 virtual void DestroyMenu(FX_HMENU hMenu) {} |
52 | 52 |
53 virtual CFX_ByteString GetNativeTrueTypeFont(int32_t nCharset); | 53 virtual CFX_ByteString GetNativeTrueTypeFont(int32_t nCharset); |
54 virtual FX_BOOL FindNativeTrueTypeFont(int32_t nCharset, CFX_Byt
eString sFontFaceName); | 54 virtual bool FindNativeTrueTypeFont(int32_t nCharset, CFX_ByteSt
ring sFontFaceName); |
55 virtual CPDF_Font* AddNativeTrueTypeFontToPDF(CPDF_Document* pDoc,
CFX_ByteString sFontFaceName, uint8_t nCharset); | 55 virtual CPDF_Font* AddNativeTrueTypeFontToPDF(CPDF_Document* pDoc,
CFX_ByteString sFontFaceName, uint8_t nCharset); |
56 | 56 |
57 virtual int32_t SetTimer(int32_t uElapse, TimerCallback lpTimerFunc)
; | 57 virtual int32_t SetTimer(int32_t uElapse, TimerCallback lpTimerFunc)
; |
58 virtual void KillTimer(int32_t nID) ; | 58 virtual void KillTimer(int32_t nID) ; |
59 | 59 |
60 | 60 |
61 virtual FX_BOOL IsSHIFTKeyDown(FX_DWORD nFlag) {return m_pEnv->F
FI_IsSHIFTKeyDown(nFlag);} | 61 virtual bool IsSHIFTKeyDown(FX_DWORD nFlag) {return m_pEnv->FFI_
IsSHIFTKeyDown(nFlag);} |
62 virtual FX_BOOL IsCTRLKeyDown(FX_DWORD nFlag) {return m_pEnv->FF
I_IsCTRLKeyDown(nFlag);} | 62 virtual bool IsCTRLKeyDown(FX_DWORD nFlag) {return m_pEnv->FFI_I
sCTRLKeyDown(nFlag);} |
63 virtual FX_BOOL IsALTKeyDown(FX_DWORD nFlag) {return m_pEnv->FFI
_IsALTKeyDown(nFlag);} | 63 virtual bool IsALTKeyDown(FX_DWORD nFlag) {return m_pEnv->FFI_Is
ALTKeyDown(nFlag);} |
64 virtual FX_BOOL IsINSERTKeyDown(FX_DWORD nFlag) {return m_pEnv->
FFI_IsINSERTKeyDown(nFlag);} | 64 virtual bool IsINSERTKeyDown(FX_DWORD nFlag) {return m_pEnv->FFI
_IsINSERTKeyDown(nFlag);} |
65 | 65 |
66 virtual FX_SYSTEMTIME GetLocalTime(); | 66 virtual FX_SYSTEMTIME GetLocalTime(); |
67 | 67 |
68 virtual int32_t GetCharSet() {return m_nCharSet;} | 68 virtual int32_t GetCharSet() {return m_nCharSet;} |
69 virtual void SetCharSet(int32_t nCharSet) {m_nCharSet = nChar
Set;} | 69 virtual void SetCharSet(int32_t nCharSet) {m_nCharSet = nChar
Set;} |
70 private: | 70 private: |
71 CPDFDoc_Environment* m_pEnv; | 71 CPDFDoc_Environment* m_pEnv; |
72 int m_nCharSet; | 72 int m_nCharSet; |
73 }; | 73 }; |
74 | 74 |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
115 | 115 |
116 CPDFSDK_Annot* pAnnot = pFFL->GetSDKAnnot(); | 116 CPDFSDK_Annot* pAnnot = pFFL->GetSDKAnnot(); |
117 ASSERT(pAnnot); | 117 ASSERT(pAnnot); |
118 CPDF_Page* pPage = pAnnot->GetPDFPage(); | 118 CPDF_Page* pPage = pAnnot->GetPDFPage(); |
119 ASSERT(pPage); | 119 ASSERT(pPage); |
120 m_pEnv->FFI_OutputSelectedRect(pPage, ptA.x, ptB.y, ptB.x, ptA.y); | 120 m_pEnv->FFI_OutputSelectedRect(pPage, ptA.x, ptB.y, ptB.x, ptA.y); |
121 } | 121 } |
122 | 122 |
123 } | 123 } |
124 | 124 |
125 FX_BOOL CFX_SystemHandler::IsSelectionImplemented() | 125 bool CFX_SystemHandler::IsSelectionImplemented() |
126 { | 126 { |
127 if(m_pEnv) | 127 if(m_pEnv) |
128 { | 128 { |
129 FPDF_FORMFILLINFO* pInfo = m_pEnv->GetFormFillInfo(); | 129 FPDF_FORMFILLINFO* pInfo = m_pEnv->GetFormFillInfo(); |
130 if(pInfo && pInfo->FFI_OutputSelectedRect) | 130 if(pInfo && pInfo->FFI_OutputSelectedRect) |
131 return TRUE; | 131 return true; |
132 } | 132 } |
133 return FALSE; | 133 return false; |
134 } | 134 } |
135 | 135 |
136 CFX_ByteString CFX_SystemHandler::GetNativeTrueTypeFont(int32_t nCharset) | 136 CFX_ByteString CFX_SystemHandler::GetNativeTrueTypeFont(int32_t nCharset) |
137 { | 137 { |
138 return ""; | 138 return ""; |
139 } | 139 } |
140 | 140 |
141 FX_BOOL CFX_SystemHandler::FindNativeTrueTypeFont(int32_t nCharset, CFX_ByteStri
ng sFontFaceName) | 141 bool CFX_SystemHandler::FindNativeTrueTypeFont(int32_t nCharset, CFX_ByteString
sFontFaceName) |
142 { | 142 { |
143 CFX_FontMgr* pFontMgr = CFX_GEModule::Get()->GetFontMgr(); | 143 CFX_FontMgr* pFontMgr = CFX_GEModule::Get()->GetFontMgr(); |
144 if(pFontMgr) | 144 if(pFontMgr) |
145 { | 145 { |
146 CFX_FontMapper* pFontMapper = pFontMgr->m_pBuiltinMapper; | 146 CFX_FontMapper* pFontMapper = pFontMgr->m_pBuiltinMapper; |
147 if(pFontMapper) | 147 if(pFontMapper) |
148 { | 148 { |
149 int nSize = pFontMapper->m_InstalledTTFonts.GetSize(); | 149 int nSize = pFontMapper->m_InstalledTTFonts.GetSize(); |
150 if(nSize ==0) | 150 if(nSize ==0) |
151 { | 151 { |
152 pFontMapper->LoadInstalledFonts(); | 152 pFontMapper->LoadInstalledFonts(); |
153 nSize = pFontMapper->m_InstalledTTFonts.GetSize(); | 153 nSize = pFontMapper->m_InstalledTTFonts.GetSize(); |
154 } | 154 } |
155 | 155 |
156 for(int i=0; i<nSize; i++) | 156 for(int i=0; i<nSize; i++) |
157 { | 157 { |
158 if(pFontMapper->m_InstalledTTFonts[i].Compare(sFontFaceName)) | 158 if(pFontMapper->m_InstalledTTFonts[i].Compare(sFontFaceName)) |
159 return TRUE; | 159 return true; |
160 } | 160 } |
161 } | 161 } |
162 | 162 |
163 } | 163 } |
164 | 164 |
165 return FALSE; | 165 return false; |
166 } | 166 } |
167 | 167 |
168 static int CharSet2CP(int charset) | 168 static int CharSet2CP(int charset) |
169 { | 169 { |
170 if (charset == 128) | 170 if (charset == 128) |
171 return 932; | 171 return 932; |
172 if (charset == 134) | 172 if (charset == 134) |
173 return 936; | 173 return 936; |
174 if (charset == 129) | 174 if (charset == 129) |
175 return 949; | 175 return 949; |
176 if (charset == 136) | 176 if (charset == 136) |
177 return 950; | 177 return 950; |
178 return 0; | 178 return 0; |
179 } | 179 } |
180 CPDF_Font* CFX_SystemHandler::AddNativeTrueTypeFontToPDF(CPDF_Document* pDoc, CF
X_ByteString sFontFaceName, | 180 CPDF_Font* CFX_SystemHandler::AddNativeTrueTypeFontToPDF(CPDF_Document* pDoc, CF
X_ByteString sFontFaceName, |
181 uint8_t nCharset) | 181 uint8_t nCharset) |
182 { | 182 { |
183 if(pDoc) | 183 if(pDoc) |
184 { | 184 { |
185 CFX_Font* pFXFont = new CFX_Font(); | 185 CFX_Font* pFXFont = new CFX_Font(); |
186 pFXFont->LoadSubst(sFontFaceName,TRUE,0,0,0,CharSet2CP(nCharset),FALSE); | 186 pFXFont->LoadSubst(sFontFaceName,true,0,0,0,CharSet2CP(nCharset),false); |
187 CPDF_Font* pFont = pDoc->AddFont(pFXFont,nCharset,FALSE); | 187 CPDF_Font* pFont = pDoc->AddFont(pFXFont,nCharset,false); |
188 delete pFXFont; | 188 delete pFXFont; |
189 return pFont; | 189 return pFont; |
190 } | 190 } |
191 | 191 |
192 return NULL; | 192 return NULL; |
193 } | 193 } |
194 | 194 |
195 | 195 |
196 int32_t CFX_SystemHandler::SetTimer(int32_t uElapse, TimerCallback lpTimerFunc) | 196 int32_t CFX_SystemHandler::SetTimer(int32_t uElapse, TimerCallback lpTimerFunc) |
197 { | 197 { |
(...skipping 204 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
402 m_pIFormFiller = new CFFL_IFormFiller(this); | 402 m_pIFormFiller = new CFFL_IFormFiller(this); |
403 return m_pIFormFiller; | 403 return m_pIFormFiller; |
404 } | 404 } |
405 | 405 |
406 CPDFSDK_Document::CPDFSDK_Document(CPDF_Document* pDoc,CPDFDoc_Environment* pEnv
) : | 406 CPDFSDK_Document::CPDFSDK_Document(CPDF_Document* pDoc,CPDFDoc_Environment* pEnv
) : |
407 m_pDoc(pDoc), | 407 m_pDoc(pDoc), |
408 m_pInterForm(nullptr), | 408 m_pInterForm(nullptr), |
409 m_pFocusAnnot(nullptr), | 409 m_pFocusAnnot(nullptr), |
410 m_pEnv(pEnv), | 410 m_pEnv(pEnv), |
411 m_pOccontent(nullptr), | 411 m_pOccontent(nullptr), |
412 m_bChangeMask(FALSE) | 412 m_bChangeMask(false) |
413 { | 413 { |
414 } | 414 } |
415 | 415 |
416 CPDFSDK_Document::~CPDFSDK_Document() | 416 CPDFSDK_Document::~CPDFSDK_Document() |
417 { | 417 { |
418 for (auto& it : m_pageMap) | 418 for (auto& it : m_pageMap) |
419 delete it.second; | 419 delete it.second; |
420 m_pageMap.clear(); | 420 m_pageMap.clear(); |
421 | 421 |
422 delete m_pInterForm; | 422 delete m_pInterForm; |
423 m_pInterForm = nullptr; | 423 m_pInterForm = nullptr; |
424 | 424 |
425 delete m_pOccontent; | 425 delete m_pOccontent; |
426 m_pOccontent = nullptr; | 426 m_pOccontent = nullptr; |
427 } | 427 } |
428 | 428 |
429 CPDFSDK_PageView* CPDFSDK_Document::GetPageView(CPDF_Page* pPDFPage, FX_BOOL ReN
ew) | 429 CPDFSDK_PageView* CPDFSDK_Document::GetPageView(CPDF_Page* pPDFPage, bool ReNew) |
430 { | 430 { |
431 auto it = m_pageMap.find(pPDFPage); | 431 auto it = m_pageMap.find(pPDFPage); |
432 if (it != m_pageMap.end()) | 432 if (it != m_pageMap.end()) |
433 return it->second; | 433 return it->second; |
434 | 434 |
435 if (!ReNew) | 435 if (!ReNew) |
436 return nullptr; | 436 return nullptr; |
437 | 437 |
438 CPDFSDK_PageView* pPageView = new CPDFSDK_PageView(this, pPDFPage); | 438 CPDFSDK_PageView* pPageView = new CPDFSDK_PageView(this, pPDFPage); |
439 m_pageMap[pPDFPage] = pPageView; | 439 m_pageMap[pPDFPage] = pPageView; |
440 // Delay to load all the annotations, to avoid endless loop. | 440 // Delay to load all the annotations, to avoid endless loop. |
441 pPageView->LoadFXAnnots(); | 441 pPageView->LoadFXAnnots(); |
442 return pPageView; | 442 return pPageView; |
443 } | 443 } |
444 | 444 |
445 CPDFSDK_PageView* CPDFSDK_Document::GetCurrentView() | 445 CPDFSDK_PageView* CPDFSDK_Document::GetCurrentView() |
446 { | 446 { |
447 CPDF_Page* pPage = (CPDF_Page*)m_pEnv->FFI_GetCurrentPage(m_pDoc); | 447 CPDF_Page* pPage = (CPDF_Page*)m_pEnv->FFI_GetCurrentPage(m_pDoc); |
448 return pPage ? GetPageView(pPage, TRUE) : nullptr; | 448 return pPage ? GetPageView(pPage, true) : nullptr; |
449 } | 449 } |
450 | 450 |
451 CPDFSDK_PageView* CPDFSDK_Document::GetPageView(int nIndex) | 451 CPDFSDK_PageView* CPDFSDK_Document::GetPageView(int nIndex) |
452 { | 452 { |
453 CPDF_Page* pTempPage = (CPDF_Page*)m_pEnv->FFI_GetPage(m_pDoc, nIndex); | 453 CPDF_Page* pTempPage = (CPDF_Page*)m_pEnv->FFI_GetPage(m_pDoc, nIndex); |
454 if (!pTempPage) | 454 if (!pTempPage) |
455 return nullptr; | 455 return nullptr; |
456 | 456 |
457 auto it = m_pageMap.find(pTempPage); | 457 auto it = m_pageMap.find(pTempPage); |
458 return it->second; | 458 return it->second; |
459 } | 459 } |
460 | 460 |
461 void CPDFSDK_Document:: ProcJavascriptFun() | 461 void CPDFSDK_Document:: ProcJavascriptFun() |
462 { | 462 { |
463 CPDF_Document* pPDFDoc = GetDocument(); | 463 CPDF_Document* pPDFDoc = GetDocument(); |
464 CPDF_DocJSActions docJS(pPDFDoc); | 464 CPDF_DocJSActions docJS(pPDFDoc); |
465 int iCount = docJS.CountJSActions(); | 465 int iCount = docJS.CountJSActions(); |
466 if (iCount < 1) return; | 466 if (iCount < 1) return; |
467 for (int i = 0; i < iCount; i ++) | 467 for (int i = 0; i < iCount; i ++) |
468 { | 468 { |
469 CFX_ByteString csJSName; | 469 CFX_ByteString csJSName; |
470 CPDF_Action jsAction = docJS.GetJSAction(i, csJSName); | 470 CPDF_Action jsAction = docJS.GetJSAction(i, csJSName); |
471 if(m_pEnv->GetActionHander()) | 471 if(m_pEnv->GetActionHander()) |
472 m_pEnv->GetActionHander()->DoAction_JavaScript(jsAction,CFX_WideStri
ng::FromLocal(csJSName),this); | 472 m_pEnv->GetActionHander()->DoAction_JavaScript(jsAction,CFX_WideStri
ng::FromLocal(csJSName),this); |
473 } | 473 } |
474 | 474 |
475 } | 475 } |
476 | 476 |
477 FX_BOOL CPDFSDK_Document::ProcOpenAction() | 477 bool CPDFSDK_Document::ProcOpenAction() |
478 { | 478 { |
479 if(!m_pDoc) | 479 if(!m_pDoc) |
480 return FALSE; | 480 return false; |
481 | 481 |
482 CPDF_Dictionary* pRoot = m_pDoc->GetRoot(); | 482 CPDF_Dictionary* pRoot = m_pDoc->GetRoot(); |
483 if (!pRoot) | 483 if (!pRoot) |
484 return FALSE; | 484 return false; |
485 | 485 |
486 CPDF_Object* pOpenAction = pRoot->GetDict("OpenAction"); | 486 CPDF_Object* pOpenAction = pRoot->GetDict("OpenAction"); |
487 if(!pOpenAction) | 487 if(!pOpenAction) |
488 pOpenAction = pRoot->GetArray("OpenAction"); | 488 pOpenAction = pRoot->GetArray("OpenAction"); |
489 | 489 |
490 if(!pOpenAction) | 490 if(!pOpenAction) |
491 return FALSE; | 491 return false; |
492 | 492 |
493 if(pOpenAction->GetType()==PDFOBJ_ARRAY) | 493 if(pOpenAction->GetType()==PDFOBJ_ARRAY) |
494 return TRUE; | 494 return true; |
495 | 495 |
496 if(pOpenAction->GetType()==PDFOBJ_DICTIONARY) | 496 if(pOpenAction->GetType()==PDFOBJ_DICTIONARY) |
497 { | 497 { |
498 CPDF_Dictionary * pDict=(CPDF_Dictionary*)pOpenAction; | 498 CPDF_Dictionary * pDict=(CPDF_Dictionary*)pOpenAction; |
499 CPDF_Action action(pDict); | 499 CPDF_Action action(pDict); |
500 if(m_pEnv->GetActionHander()) | 500 if(m_pEnv->GetActionHander()) |
501 m_pEnv->GetActionHander()->DoAction_DocOpen(action, this); | 501 m_pEnv->GetActionHander()->DoAction_DocOpen(action, this); |
502 return TRUE; | 502 return true; |
503 } | 503 } |
504 return FALSE; | 504 return false; |
505 } | 505 } |
506 | 506 |
507 CPDF_OCContext* CPDFSDK_Document::GetOCContext() | 507 CPDF_OCContext* CPDFSDK_Document::GetOCContext() |
508 { | 508 { |
509 if(!m_pOccontent) | 509 if(!m_pOccontent) |
510 m_pOccontent = new CPDF_OCContext(m_pDoc); | 510 m_pOccontent = new CPDF_OCContext(m_pDoc); |
511 return m_pOccontent; | 511 return m_pOccontent; |
512 } | 512 } |
513 | 513 |
514 void CPDFSDK_Document::ReMovePageView(CPDF_Page* pPDFPage) | 514 void CPDFSDK_Document::ReMovePageView(CPDF_Page* pPDFPage) |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
548 pPageView->UpdateView(pAnnot); | 548 pPageView->UpdateView(pAnnot); |
549 } | 549 } |
550 } | 550 } |
551 } | 551 } |
552 | 552 |
553 CPDFSDK_Annot* CPDFSDK_Document::GetFocusAnnot() | 553 CPDFSDK_Annot* CPDFSDK_Document::GetFocusAnnot() |
554 { | 554 { |
555 return m_pFocusAnnot; | 555 return m_pFocusAnnot; |
556 } | 556 } |
557 | 557 |
558 FX_BOOL CPDFSDK_Document::SetFocusAnnot(CPDFSDK_Annot* pAnnot,FX_UINT nFlag) | 558 bool CPDFSDK_Document::SetFocusAnnot(CPDFSDK_Annot* pAnnot,FX_UINT nFlag) |
559 { | 559 { |
560 | 560 |
561 if(m_pFocusAnnot==pAnnot) return TRUE; | 561 if(m_pFocusAnnot==pAnnot) return true; |
562 | 562 |
563 if(m_pFocusAnnot) | 563 if(m_pFocusAnnot) |
564 { | 564 { |
565 if(!KillFocusAnnot(nFlag) ) return FALSE; | 565 if(!KillFocusAnnot(nFlag) ) return false; |
566 } | 566 } |
567 CPDFSDK_PageView* pPageView = pAnnot->GetPageView(); | 567 CPDFSDK_PageView* pPageView = pAnnot->GetPageView(); |
568 if(pAnnot && pPageView->IsValid()) | 568 if(pAnnot && pPageView->IsValid()) |
569 { | 569 { |
570 CPDFSDK_AnnotHandlerMgr *pAnnotHandler=m_pEnv->GetAnnotHandlerMgr(); | 570 CPDFSDK_AnnotHandlerMgr *pAnnotHandler=m_pEnv->GetAnnotHandlerMgr(); |
571 | 571 |
572 if(pAnnotHandler&&!m_pFocusAnnot) | 572 if(pAnnotHandler&&!m_pFocusAnnot) |
573 { | 573 { |
574 if (!pAnnotHandler->Annot_OnSetFocus(pAnnot,nFlag)) | 574 if (!pAnnotHandler->Annot_OnSetFocus(pAnnot,nFlag)) |
575 return FALSE; | 575 return false; |
576 if(!m_pFocusAnnot) | 576 if(!m_pFocusAnnot) |
577 { | 577 { |
578 m_pFocusAnnot=pAnnot; | 578 m_pFocusAnnot=pAnnot; |
579 return TRUE; | 579 return true; |
580 } | 580 } |
581 } | 581 } |
582 } | 582 } |
583 return FALSE; | 583 return false; |
584 } | 584 } |
585 | 585 |
586 FX_BOOL CPDFSDK_Document::KillFocusAnnot(FX_UINT nFlag) | 586 bool CPDFSDK_Document::KillFocusAnnot(FX_UINT nFlag) |
587 { | 587 { |
588 if(m_pFocusAnnot) | 588 if(m_pFocusAnnot) |
589 { | 589 { |
590 CPDFSDK_AnnotHandlerMgr *pAnnotHandler=m_pEnv->GetAnnotHandlerMgr(); | 590 CPDFSDK_AnnotHandlerMgr *pAnnotHandler=m_pEnv->GetAnnotHandlerMgr(); |
591 if(pAnnotHandler) | 591 if(pAnnotHandler) |
592 { | 592 { |
593 CPDFSDK_Annot* pFocusAnnot = m_pFocusAnnot; | 593 CPDFSDK_Annot* pFocusAnnot = m_pFocusAnnot; |
594 m_pFocusAnnot = NULL; | 594 m_pFocusAnnot = NULL; |
595 if(pAnnotHandler->Annot_OnKillFocus(pFocusAnnot, nFlag)) | 595 if(pAnnotHandler->Annot_OnKillFocus(pFocusAnnot, nFlag)) |
596 { | 596 { |
597 | 597 |
598 if(pFocusAnnot->GetType() == FX_BSTRC("Widget")) | 598 if(pFocusAnnot->GetType() == FX_BSTRC("Widget")) |
599 { | 599 { |
600 CPDFSDK_Widget* pWidget = (CPDFSDK_Widget*)pFocusAnnot; | 600 CPDFSDK_Widget* pWidget = (CPDFSDK_Widget*)pFocusAnnot; |
601 int nFieldType = pWidget->GetFieldType(); | 601 int nFieldType = pWidget->GetFieldType(); |
602 if(FIELDTYPE_TEXTFIELD == nFieldType || FIELDTYPE_COMBOBOX =
= nFieldType) | 602 if(FIELDTYPE_TEXTFIELD == nFieldType || FIELDTYPE_COMBOBOX =
= nFieldType) |
603 m_pEnv->FFI_OnSetFieldInputFocus(NULL, NULL, 0, FALSE); | 603 m_pEnv->FFI_OnSetFieldInputFocus(NULL, NULL, 0, false); |
604 } | 604 } |
605 | 605 |
606 if(!m_pFocusAnnot) | 606 if(!m_pFocusAnnot) |
607 return TRUE; | 607 return true; |
608 } | 608 } |
609 else | 609 else |
610 { | 610 { |
611 m_pFocusAnnot = pFocusAnnot; | 611 m_pFocusAnnot = pFocusAnnot; |
612 } | 612 } |
613 } | 613 } |
614 } | 614 } |
615 return FALSE; | 615 return false; |
616 } | 616 } |
617 | 617 |
618 void CPDFSDK_Document::OnCloseDocument() | 618 void CPDFSDK_Document::OnCloseDocument() |
619 { | 619 { |
620 KillFocusAnnot(); | 620 KillFocusAnnot(); |
621 } | 621 } |
622 | 622 |
623 FX_BOOL CPDFSDK_Document::GetPermissions(int nFlag) | 623 bool CPDFSDK_Document::GetPermissions(int nFlag) |
624 { | 624 { |
625 FX_DWORD dwPermissions = m_pDoc->GetUserPermissions(); | 625 FX_DWORD dwPermissions = m_pDoc->GetUserPermissions(); |
626 return dwPermissions&nFlag; | 626 return dwPermissions&nFlag; |
627 } | 627 } |
628 | 628 |
629 IFXJS_Runtime * CPDFSDK_Document::GetJsRuntime() | 629 IFXJS_Runtime * CPDFSDK_Document::GetJsRuntime() |
630 { | 630 { |
631 ASSERT(m_pEnv!=NULL); | 631 ASSERT(m_pEnv!=NULL); |
632 return m_pEnv->GetJSRuntime(); | 632 return m_pEnv->GetJSRuntime(); |
633 } | 633 } |
634 | 634 |
635 CFX_WideString CPDFSDK_Document::GetPath() | 635 CFX_WideString CPDFSDK_Document::GetPath() |
636 { | 636 { |
637 ASSERT(m_pEnv != NULL); | 637 ASSERT(m_pEnv != NULL); |
638 return m_pEnv->JS_docGetFilePath(); | 638 return m_pEnv->JS_docGetFilePath(); |
639 } | 639 } |
640 | 640 |
641 | 641 |
642 CPDFSDK_PageView::CPDFSDK_PageView(CPDFSDK_Document* pSDKDoc,CPDF_Page* page):m_
page(page),m_pSDKDoc(pSDKDoc) | 642 CPDFSDK_PageView::CPDFSDK_PageView(CPDFSDK_Document* pSDKDoc,CPDF_Page* page):m_
page(page),m_pSDKDoc(pSDKDoc) |
643 { | 643 { |
644 CPDFSDK_InterForm* pInterForm = pSDKDoc->GetInterForm(); | 644 CPDFSDK_InterForm* pInterForm = pSDKDoc->GetInterForm(); |
645 if(pInterForm) | 645 if(pInterForm) |
646 { | 646 { |
647 CPDF_InterForm* pPDFInterForm = pInterForm->GetInterForm(); | 647 CPDF_InterForm* pPDFInterForm = pInterForm->GetInterForm(); |
648 pPDFInterForm->FixPageFields(page); | 648 pPDFInterForm->FixPageFields(page); |
649 } | 649 } |
650 m_page->SetPrivateData((void*)m_page, (void*)this, NULL); | 650 m_page->SetPrivateData((void*)m_page, (void*)this, NULL); |
651 m_fxAnnotArray.RemoveAll(); | 651 m_fxAnnotArray.RemoveAll(); |
652 | 652 |
653 m_bEnterWidget = FALSE; | 653 m_bEnterWidget = false; |
654 m_bExitWidget = FALSE; | 654 m_bExitWidget = false; |
655 m_bOnWidget = FALSE; | 655 m_bOnWidget = false; |
656 m_CaptureWidget = NULL; | 656 m_CaptureWidget = NULL; |
657 m_bValid = FALSE; | 657 m_bValid = false; |
658 m_bLocked = FALSE; | 658 m_bLocked = false; |
659 m_bTakeOverPage = FALSE; | 659 m_bTakeOverPage = false; |
660 } | 660 } |
661 | 661 |
662 CPDFSDK_PageView::~CPDFSDK_PageView() | 662 CPDFSDK_PageView::~CPDFSDK_PageView() |
663 { | 663 { |
664 CPDFDoc_Environment* pEnv = m_pSDKDoc->GetEnv(); | 664 CPDFDoc_Environment* pEnv = m_pSDKDoc->GetEnv(); |
665 int nAnnotCount = m_fxAnnotArray.GetSize(); | 665 int nAnnotCount = m_fxAnnotArray.GetSize(); |
666 | 666 |
667 for (int i=0; i<nAnnotCount; i++) | 667 for (int i=0; i<nAnnotCount; i++) |
668 { | 668 { |
669 CPDFSDK_Annot* pAnnot = (CPDFSDK_Annot*)m_fxAnnotArray.GetAt(i); | 669 CPDFSDK_Annot* pAnnot = (CPDFSDK_Annot*)m_fxAnnotArray.GetAt(i); |
(...skipping 13 matching lines...) Expand all Loading... |
683 if(m_bTakeOverPage) { | 683 if(m_bTakeOverPage) { |
684 delete m_page; | 684 delete m_page; |
685 } | 685 } |
686 } | 686 } |
687 | 687 |
688 void CPDFSDK_PageView::PageView_OnDraw(CFX_RenderDevice* pDevice, CPDF_Matrix* p
User2Device,CPDF_RenderOptions* pOptions) | 688 void CPDFSDK_PageView::PageView_OnDraw(CFX_RenderDevice* pDevice, CPDF_Matrix* p
User2Device,CPDF_RenderOptions* pOptions) |
689 { | 689 { |
690 m_curMatrix = *pUser2Device; | 690 m_curMatrix = *pUser2Device; |
691 | 691 |
692 CPDFDoc_Environment* pEnv = m_pSDKDoc->GetEnv(); | 692 CPDFDoc_Environment* pEnv = m_pSDKDoc->GetEnv(); |
693 CPDFSDK_AnnotIterator annotIterator(this, TRUE); | 693 CPDFSDK_AnnotIterator annotIterator(this, true); |
694 CPDFSDK_Annot* pSDKAnnot = nullptr; | 694 CPDFSDK_Annot* pSDKAnnot = nullptr; |
695 int index = -1; | 695 int index = -1; |
696 while ((pSDKAnnot = annotIterator.Next(index))) { | 696 while ((pSDKAnnot = annotIterator.Next(index))) { |
697 CPDFSDK_AnnotHandlerMgr* pAnnotHandlerMgr = pEnv->GetAnnotHandlerMgr(); | 697 CPDFSDK_AnnotHandlerMgr* pAnnotHandlerMgr = pEnv->GetAnnotHandlerMgr(); |
698 ASSERT(pAnnotHandlerMgr); | 698 ASSERT(pAnnotHandlerMgr); |
699 pAnnotHandlerMgr->Annot_OnDraw( | 699 pAnnotHandlerMgr->Annot_OnDraw( |
700 this, pSDKAnnot, pDevice, pUser2Device, 0); | 700 this, pSDKAnnot, pDevice, pUser2Device, 0); |
701 } | 701 } |
702 } | 702 } |
703 | 703 |
(...skipping 26 matching lines...) Expand all Loading... |
730 if(annotRect.Contains(pageX, pageY)) | 730 if(annotRect.Contains(pageX, pageY)) |
731 return pAnnot; | 731 return pAnnot; |
732 } | 732 } |
733 } | 733 } |
734 return NULL; | 734 return NULL; |
735 } | 735 } |
736 | 736 |
737 CPDFSDK_Annot* CPDFSDK_PageView::GetFXAnnotAtPoint(FX_FLOAT pageX, FX_FLOAT page
Y) | 737 CPDFSDK_Annot* CPDFSDK_PageView::GetFXAnnotAtPoint(FX_FLOAT pageX, FX_FLOAT page
Y) |
738 { | 738 { |
739 | 739 |
740 CPDFSDK_AnnotIterator annotIterator(this, FALSE); | 740 CPDFSDK_AnnotIterator annotIterator(this, false); |
741 CPDFDoc_Environment* pEnv = m_pSDKDoc->GetEnv(); | 741 CPDFDoc_Environment* pEnv = m_pSDKDoc->GetEnv(); |
742 CPDFSDK_AnnotHandlerMgr* pAnnotMgr = pEnv->GetAnnotHandlerMgr(); | 742 CPDFSDK_AnnotHandlerMgr* pAnnotMgr = pEnv->GetAnnotHandlerMgr(); |
743 CPDFSDK_Annot* pSDKAnnot = NULL; | 743 CPDFSDK_Annot* pSDKAnnot = NULL; |
744 int index = -1; | 744 int index = -1; |
745 while((pSDKAnnot = annotIterator.Next(index))) | 745 while((pSDKAnnot = annotIterator.Next(index))) |
746 { | 746 { |
747 CPDF_Rect rc = pAnnotMgr->Annot_OnGetViewBBox(this, pSDKAnnot); | 747 CPDF_Rect rc = pAnnotMgr->Annot_OnGetViewBBox(this, pSDKAnnot); |
748 if(rc.Contains(pageX, pageY)) | 748 if(rc.Contains(pageX, pageY)) |
749 return pSDKAnnot; | 749 return pSDKAnnot; |
750 } | 750 } |
751 | 751 |
752 return NULL; | 752 return NULL; |
753 } | 753 } |
754 | 754 |
755 CPDFSDK_Annot* CPDFSDK_PageView::GetFXWidgetAtPoint(FX_FLOAT pageX, FX_FLOAT pag
eY) | 755 CPDFSDK_Annot* CPDFSDK_PageView::GetFXWidgetAtPoint(FX_FLOAT pageX, FX_FLOAT pag
eY) |
756 { | 756 { |
757 | 757 |
758 CPDFSDK_AnnotIterator annotIterator(this, FALSE); | 758 CPDFSDK_AnnotIterator annotIterator(this, false); |
759 CPDFDoc_Environment* pEnv = m_pSDKDoc->GetEnv(); | 759 CPDFDoc_Environment* pEnv = m_pSDKDoc->GetEnv(); |
760 CPDFSDK_AnnotHandlerMgr* pAnnotMgr = pEnv->GetAnnotHandlerMgr(); | 760 CPDFSDK_AnnotHandlerMgr* pAnnotMgr = pEnv->GetAnnotHandlerMgr(); |
761 CPDFSDK_Annot* pSDKAnnot = NULL; | 761 CPDFSDK_Annot* pSDKAnnot = NULL; |
762 int index = -1; | 762 int index = -1; |
763 while((pSDKAnnot = annotIterator.Next(index))) | 763 while((pSDKAnnot = annotIterator.Next(index))) |
764 { | 764 { |
765 if(pSDKAnnot->GetType() == "Widget") | 765 if(pSDKAnnot->GetType() == "Widget") |
766 { | 766 { |
767 pAnnotMgr->Annot_OnGetViewBBox(this, pSDKAnnot); | 767 pAnnotMgr->Annot_OnGetViewBBox(this, pSDKAnnot); |
768 CPDF_Point point(pageX, pageY); | 768 CPDF_Point point(pageX, pageY); |
769 if (pAnnotMgr->Annot_OnHitTest(this, pSDKAnnot, point)) | 769 if (pAnnotMgr->Annot_OnHitTest(this, pSDKAnnot, point)) |
770 return pSDKAnnot; | 770 return pSDKAnnot; |
771 } | 771 } |
772 } | 772 } |
773 | 773 |
774 return NULL; | 774 return NULL; |
775 } | 775 } |
776 | 776 |
777 | 777 |
778 FX_BOOL CPDFSDK_PageView::Annot_HasAppearance(CPDF_Annot* pAnnot) | 778 bool CPDFSDK_PageView::Annot_HasAppearance(CPDF_Annot* pAnnot) |
779 { | 779 { |
780 CPDF_Dictionary* pAnnotDic = pAnnot->GetAnnotDict(); | 780 CPDF_Dictionary* pAnnotDic = pAnnot->GetAnnotDict(); |
781 if(pAnnotDic) | 781 if(pAnnotDic) |
782 return pAnnotDic->KeyExist("AS"); | 782 return pAnnotDic->KeyExist("AS"); |
783 return FALSE; | 783 return false; |
784 } | 784 } |
785 | 785 |
786 CPDFSDK_Annot* CPDFSDK_PageView::AddAnnot(CPDF_Annot * pPDFAnnot) | 786 CPDFSDK_Annot* CPDFSDK_PageView::AddAnnot(CPDF_Annot * pPDFAnnot) |
787 { | 787 { |
788 CPDFDoc_Environment* pEnv = m_pSDKDoc->GetEnv(); | 788 CPDFDoc_Environment* pEnv = m_pSDKDoc->GetEnv(); |
789 ASSERT(pEnv); | 789 ASSERT(pEnv); |
790 CPDFSDK_AnnotHandlerMgr * pAnnotHandler= pEnv->GetAnnotHandlerMgr(); | 790 CPDFSDK_AnnotHandlerMgr * pAnnotHandler= pEnv->GetAnnotHandlerMgr(); |
791 | 791 |
792 CPDFSDK_Annot* pSDKAnnot =NULL; | 792 CPDFSDK_Annot* pSDKAnnot =NULL; |
793 | 793 |
(...skipping 18 matching lines...) Expand all Loading... |
812 CPDFSDK_Annot* CPDFSDK_PageView::AddAnnot(CPDF_Dictionary * pDict) | 812 CPDFSDK_Annot* CPDFSDK_PageView::AddAnnot(CPDF_Dictionary * pDict) |
813 { | 813 { |
814 return pDict ? AddAnnot(pDict->GetString("Subtype"), pDict) : nullptr; | 814 return pDict ? AddAnnot(pDict->GetString("Subtype"), pDict) : nullptr; |
815 } | 815 } |
816 | 816 |
817 CPDFSDK_Annot* CPDFSDK_PageView::AddAnnot(const FX_CHAR* lpSubType,CPDF_Dictiona
ry * pDict) | 817 CPDFSDK_Annot* CPDFSDK_PageView::AddAnnot(const FX_CHAR* lpSubType,CPDF_Dictiona
ry * pDict) |
818 { | 818 { |
819 return NULL; | 819 return NULL; |
820 } | 820 } |
821 | 821 |
822 FX_BOOL CPDFSDK_PageView::DeleteAnnot(CPDFSDK_Annot* pAnnot) | 822 bool CPDFSDK_PageView::DeleteAnnot(CPDFSDK_Annot* pAnnot) |
823 { | 823 { |
824 return FALSE; | 824 return false; |
825 } | 825 } |
826 | 826 |
827 CPDF_Document* CPDFSDK_PageView::GetPDFDocument() | 827 CPDF_Document* CPDFSDK_PageView::GetPDFDocument() |
828 { | 828 { |
829 if(m_page) | 829 if(m_page) |
830 { | 830 { |
831 return m_page->m_pDocument; | 831 return m_page->m_pDocument; |
832 } | 832 } |
833 return NULL; | 833 return NULL; |
834 } | 834 } |
(...skipping 19 matching lines...) Expand all Loading... |
854 int nCount = m_fxAnnotArray.GetSize(); | 854 int nCount = m_fxAnnotArray.GetSize(); |
855 for(int i=0; i<nCount; i++) | 855 for(int i=0; i<nCount; i++) |
856 { | 856 { |
857 CPDFSDK_Annot* pAnnot = (CPDFSDK_Annot*)m_fxAnnotArray.GetAt(i); | 857 CPDFSDK_Annot* pAnnot = (CPDFSDK_Annot*)m_fxAnnotArray.GetAt(i); |
858 if (pDict == pAnnot->GetPDFAnnot()->GetAnnotDict()) | 858 if (pDict == pAnnot->GetPDFAnnot()->GetAnnotDict()) |
859 return pAnnot; | 859 return pAnnot; |
860 } | 860 } |
861 return NULL; | 861 return NULL; |
862 } | 862 } |
863 | 863 |
864 FX_BOOL CPDFSDK_PageView::OnLButtonDown(const CPDF_Point & point, FX_UINT nFlag) | 864 bool CPDFSDK_PageView::OnLButtonDown(const CPDF_Point & point, FX_UINT nFlag) |
865 { | 865 { |
866 CPDFDoc_Environment* pEnv = m_pSDKDoc->GetEnv(); | 866 CPDFDoc_Environment* pEnv = m_pSDKDoc->GetEnv(); |
867 ASSERT(pEnv); | 867 ASSERT(pEnv); |
868 CPDFSDK_Annot* pFXAnnot = GetFXWidgetAtPoint(point.x, point.y); | 868 CPDFSDK_Annot* pFXAnnot = GetFXWidgetAtPoint(point.x, point.y); |
869 if(!pFXAnnot) | 869 if(!pFXAnnot) |
870 { | 870 { |
871 KillFocusAnnot(nFlag); | 871 KillFocusAnnot(nFlag); |
872 } | 872 } |
873 else | 873 else |
874 { | 874 { |
875 CPDFSDK_AnnotHandlerMgr* pAnnotHandlerMgr = pEnv->GetAnnotHandlerMgr(); | 875 CPDFSDK_AnnotHandlerMgr* pAnnotHandlerMgr = pEnv->GetAnnotHandlerMgr(); |
876 ASSERT(pAnnotHandlerMgr); | 876 ASSERT(pAnnotHandlerMgr); |
877 | 877 |
878 FX_BOOL bRet = pAnnotHandlerMgr->Annot_OnLButtonDown(this, pFXAnnot, nFl
ag,point); | 878 bool bRet = pAnnotHandlerMgr->Annot_OnLButtonDown(this, pFXAnnot, nFlag,
point); |
879 if(bRet) | 879 if(bRet) |
880 { | 880 { |
881 SetFocusAnnot(pFXAnnot); | 881 SetFocusAnnot(pFXAnnot); |
882 } | 882 } |
883 return bRet; | 883 return bRet; |
884 } | 884 } |
885 return FALSE; | 885 return false; |
886 } | 886 } |
887 | 887 |
888 | 888 |
889 FX_BOOL CPDFSDK_PageView::OnLButtonUp(const CPDF_Point & point, FX_UINT nFlag) | 889 bool CPDFSDK_PageView::OnLButtonUp(const CPDF_Point & point, FX_UINT nFlag) |
890 { | 890 { |
891 CPDFDoc_Environment* pEnv = m_pSDKDoc->GetEnv(); | 891 CPDFDoc_Environment* pEnv = m_pSDKDoc->GetEnv(); |
892 ASSERT(pEnv); | 892 ASSERT(pEnv); |
893 CPDFSDK_AnnotHandlerMgr* pAnnotHandlerMgr = pEnv->GetAnnotHandlerMgr(); | 893 CPDFSDK_AnnotHandlerMgr* pAnnotHandlerMgr = pEnv->GetAnnotHandlerMgr(); |
894 ASSERT(pAnnotHandlerMgr); | 894 ASSERT(pAnnotHandlerMgr); |
895 CPDFSDK_Annot* pFXAnnot = GetFXWidgetAtPoint(point.x, point.y); | 895 CPDFSDK_Annot* pFXAnnot = GetFXWidgetAtPoint(point.x, point.y); |
896 CPDFSDK_Annot* pFocusAnnot = GetFocusAnnot(); | 896 CPDFSDK_Annot* pFocusAnnot = GetFocusAnnot(); |
897 FX_BOOL bRet = FALSE; | 897 bool bRet = false; |
898 if(pFocusAnnot && pFocusAnnot != pFXAnnot) | 898 if(pFocusAnnot && pFocusAnnot != pFXAnnot) |
899 { | 899 { |
900 //Last focus Annot gets a chance to handle the event. | 900 //Last focus Annot gets a chance to handle the event. |
901 bRet = pAnnotHandlerMgr->Annot_OnLButtonUp(this, pFocusAnnot, nFlag,poin
t); | 901 bRet = pAnnotHandlerMgr->Annot_OnLButtonUp(this, pFocusAnnot, nFlag,poin
t); |
902 } | 902 } |
903 if(pFXAnnot && !bRet) | 903 if(pFXAnnot && !bRet) |
904 { | 904 { |
905 bRet = pAnnotHandlerMgr->Annot_OnLButtonUp(this, pFXAnnot, nFlag,point); | 905 bRet = pAnnotHandlerMgr->Annot_OnLButtonUp(this, pFXAnnot, nFlag,point); |
906 return bRet; | 906 return bRet; |
907 } | 907 } |
908 return bRet; | 908 return bRet; |
909 } | 909 } |
910 | 910 |
911 FX_BOOL CPDFSDK_PageView::OnMouseMove(const CPDF_Point & point, int nFlag) | 911 bool CPDFSDK_PageView::OnMouseMove(const CPDF_Point & point, int nFlag) |
912 { | 912 { |
913 | 913 |
914 CPDFDoc_Environment* pEnv = m_pSDKDoc->GetEnv(); | 914 CPDFDoc_Environment* pEnv = m_pSDKDoc->GetEnv(); |
915 CPDFSDK_AnnotHandlerMgr* pAnnotHandlerMgr = pEnv->GetAnnotHandlerMgr(); | 915 CPDFSDK_AnnotHandlerMgr* pAnnotHandlerMgr = pEnv->GetAnnotHandlerMgr(); |
916 ASSERT(pAnnotHandlerMgr); | 916 ASSERT(pAnnotHandlerMgr); |
917 if(CPDFSDK_Annot* pFXAnnot = GetFXWidgetAtPoint(point.x, point.y)) | 917 if(CPDFSDK_Annot* pFXAnnot = GetFXWidgetAtPoint(point.x, point.y)) |
918 { | 918 { |
919 if(m_CaptureWidget && m_CaptureWidget != pFXAnnot) | 919 if(m_CaptureWidget && m_CaptureWidget != pFXAnnot) |
920 { | 920 { |
921 m_bExitWidget = TRUE; | 921 m_bExitWidget = true; |
922 m_bEnterWidget = FALSE; | 922 m_bEnterWidget = false; |
923 pAnnotHandlerMgr->Annot_OnMouseExit(this, m_CaptureWidget, nFlag); | 923 pAnnotHandlerMgr->Annot_OnMouseExit(this, m_CaptureWidget, nFlag); |
924 } | 924 } |
925 m_CaptureWidget = (CPDFSDK_Widget*)pFXAnnot; | 925 m_CaptureWidget = (CPDFSDK_Widget*)pFXAnnot; |
926 m_bOnWidget = TRUE; | 926 m_bOnWidget = true; |
927 if(!m_bEnterWidget) | 927 if(!m_bEnterWidget) |
928 { | 928 { |
929 m_bEnterWidget = TRUE; | 929 m_bEnterWidget = true; |
930 m_bExitWidget = FALSE; | 930 m_bExitWidget = false; |
931 pAnnotHandlerMgr->Annot_OnMouseEnter(this, pFXAnnot,nFlag); | 931 pAnnotHandlerMgr->Annot_OnMouseEnter(this, pFXAnnot,nFlag); |
932 } | 932 } |
933 pAnnotHandlerMgr->Annot_OnMouseMove(this, pFXAnnot, nFlag, point); | 933 pAnnotHandlerMgr->Annot_OnMouseMove(this, pFXAnnot, nFlag, point); |
934 return TRUE; | 934 return true; |
935 } | 935 } |
936 if(m_bOnWidget) | 936 if(m_bOnWidget) |
937 { | 937 { |
938 m_bOnWidget = FALSE; | 938 m_bOnWidget = false; |
939 m_bExitWidget = TRUE; | 939 m_bExitWidget = true; |
940 m_bEnterWidget = FALSE; | 940 m_bEnterWidget = false; |
941 if(m_CaptureWidget) | 941 if(m_CaptureWidget) |
942 { | 942 { |
943 pAnnotHandlerMgr->Annot_OnMouseExit(this, m_CaptureWidget, nFlag); | 943 pAnnotHandlerMgr->Annot_OnMouseExit(this, m_CaptureWidget, nFlag); |
944 m_CaptureWidget = NULL; | 944 m_CaptureWidget = NULL; |
945 } | 945 } |
946 } | 946 } |
947 return FALSE; | 947 return false; |
948 } | 948 } |
949 | 949 |
950 FX_BOOL CPDFSDK_PageView::OnMouseWheel(double deltaX, double deltaY,const CPDF_P
oint& point, int nFlag) | 950 bool CPDFSDK_PageView::OnMouseWheel(double deltaX, double deltaY,const CPDF_Poin
t& point, int nFlag) |
951 { | 951 { |
952 if(CPDFSDK_Annot* pAnnot = GetFXWidgetAtPoint(point.x, point.y)) | 952 if(CPDFSDK_Annot* pAnnot = GetFXWidgetAtPoint(point.x, point.y)) |
953 { | 953 { |
954 CPDFDoc_Environment* pEnv = m_pSDKDoc->GetEnv(); | 954 CPDFDoc_Environment* pEnv = m_pSDKDoc->GetEnv(); |
955 CPDFSDK_AnnotHandlerMgr* pAnnotHandlerMgr = pEnv->GetAnnotHandlerMgr(); | 955 CPDFSDK_AnnotHandlerMgr* pAnnotHandlerMgr = pEnv->GetAnnotHandlerMgr(); |
956 ASSERT(pAnnotHandlerMgr); | 956 ASSERT(pAnnotHandlerMgr); |
957 return pAnnotHandlerMgr->Annot_OnMouseWheel(this, pAnnot, nFlag, (int)de
ltaY, point); | 957 return pAnnotHandlerMgr->Annot_OnMouseWheel(this, pAnnot, nFlag, (int)de
ltaY, point); |
958 } | 958 } |
959 return FALSE; | 959 return false; |
960 | 960 |
961 } | 961 } |
962 | 962 |
963 FX_BOOL CPDFSDK_PageView::OnChar(int nChar, FX_UINT nFlag) | 963 bool CPDFSDK_PageView::OnChar(int nChar, FX_UINT nFlag) |
964 { | 964 { |
965 if(CPDFSDK_Annot* pAnnot = GetFocusAnnot()) | 965 if(CPDFSDK_Annot* pAnnot = GetFocusAnnot()) |
966 { | 966 { |
967 CPDFDoc_Environment* pEnv = m_pSDKDoc->GetEnv(); | 967 CPDFDoc_Environment* pEnv = m_pSDKDoc->GetEnv(); |
968 CPDFSDK_AnnotHandlerMgr* pAnnotHandlerMgr = pEnv->GetAnnotHandlerMgr(); | 968 CPDFSDK_AnnotHandlerMgr* pAnnotHandlerMgr = pEnv->GetAnnotHandlerMgr(); |
969 ASSERT(pAnnotHandlerMgr); | 969 ASSERT(pAnnotHandlerMgr); |
970 return pAnnotHandlerMgr->Annot_OnChar(pAnnot, nChar, nFlag); | 970 return pAnnotHandlerMgr->Annot_OnChar(pAnnot, nChar, nFlag); |
971 } | 971 } |
972 | 972 |
973 return FALSE; | 973 return false; |
974 } | 974 } |
975 | 975 |
976 FX_BOOL CPDFSDK_PageView::OnKeyDown(int nKeyCode, int nFlag) | 976 bool CPDFSDK_PageView::OnKeyDown(int nKeyCode, int nFlag) |
977 { | 977 { |
978 if(CPDFSDK_Annot* pAnnot = GetFocusAnnot()) | 978 if(CPDFSDK_Annot* pAnnot = GetFocusAnnot()) |
979 { | 979 { |
980 CPDFDoc_Environment* pEnv = m_pSDKDoc->GetEnv(); | 980 CPDFDoc_Environment* pEnv = m_pSDKDoc->GetEnv(); |
981 CPDFSDK_AnnotHandlerMgr* pAnnotHandlerMgr = pEnv->GetAnnotHandlerMgr(); | 981 CPDFSDK_AnnotHandlerMgr* pAnnotHandlerMgr = pEnv->GetAnnotHandlerMgr(); |
982 ASSERT(pAnnotHandlerMgr); | 982 ASSERT(pAnnotHandlerMgr); |
983 return pAnnotHandlerMgr->Annot_OnKeyDown(pAnnot, nKeyCode, nFlag); | 983 return pAnnotHandlerMgr->Annot_OnKeyDown(pAnnot, nKeyCode, nFlag); |
984 } | 984 } |
985 return FALSE; | 985 return false; |
986 } | 986 } |
987 | 987 |
988 FX_BOOL CPDFSDK_PageView::OnKeyUp(int nKeyCode, int nFlag) | 988 bool CPDFSDK_PageView::OnKeyUp(int nKeyCode, int nFlag) |
989 { | 989 { |
990 // if(CPDFSDK_Annot* pAnnot = GetFocusAnnot()) | 990 // if(CPDFSDK_Annot* pAnnot = GetFocusAnnot()) |
991 // { | 991 // { |
992 // CFFL_IFormFiller* pIFormFiller = g_pFormFillApp->GetIFormFiller(); | 992 // CFFL_IFormFiller* pIFormFiller = g_pFormFillApp->GetIFormFiller(); |
993 // return pIFormFiller->OnKeyUp(pAnnot, nKeyCode, nFlag); | 993 // return pIFormFiller->OnKeyUp(pAnnot, nKeyCode, nFlag); |
994 // } | 994 // } |
995 return FALSE; | 995 return false; |
996 } | 996 } |
997 | 997 |
998 extern void CheckUnSupportAnnot(CPDF_Document * pDoc, CPDF_Annot* pPDFAnnot); | 998 extern void CheckUnSupportAnnot(CPDF_Document * pDoc, CPDF_Annot* pPDFAnnot); |
999 | 999 |
1000 void CPDFSDK_PageView::LoadFXAnnots() | 1000 void CPDFSDK_PageView::LoadFXAnnots() |
1001 { | 1001 { |
1002 CPDFDoc_Environment* pEnv = m_pSDKDoc->GetEnv(); | 1002 CPDFDoc_Environment* pEnv = m_pSDKDoc->GetEnv(); |
1003 | 1003 |
1004 FX_BOOL enableAPUpdate = CPDF_InterForm::UpdatingAPEnabled(); | 1004 bool enableAPUpdate = CPDF_InterForm::UpdatingAPEnabled(); |
1005 //Disable the default AP construction. | 1005 //Disable the default AP construction. |
1006 CPDF_InterForm::EnableUpdateAP(FALSE); | 1006 CPDF_InterForm::EnableUpdateAP(false); |
1007 m_pAnnotList = new CPDF_AnnotList(m_page); | 1007 m_pAnnotList = new CPDF_AnnotList(m_page); |
1008 CPDF_InterForm::EnableUpdateAP(enableAPUpdate); | 1008 CPDF_InterForm::EnableUpdateAP(enableAPUpdate); |
1009 int nCount = m_pAnnotList->Count(); | 1009 int nCount = m_pAnnotList->Count(); |
1010 SetLock(TRUE); | 1010 SetLock(true); |
1011 for(int i=0; i<nCount; i++) | 1011 for(int i=0; i<nCount; i++) |
1012 { | 1012 { |
1013 CPDF_Annot* pPDFAnnot = m_pAnnotList->GetAt(i); | 1013 CPDF_Annot* pPDFAnnot = m_pAnnotList->GetAt(i); |
1014 CPDF_Document * pDoc = GetPDFDocument(); | 1014 CPDF_Document * pDoc = GetPDFDocument(); |
1015 | 1015 |
1016 CheckUnSupportAnnot(pDoc, pPDFAnnot); | 1016 CheckUnSupportAnnot(pDoc, pPDFAnnot); |
1017 | 1017 |
1018 CPDFSDK_AnnotHandlerMgr* pAnnotHandlerMgr = pEnv->GetAnnotHandlerMgr(); | 1018 CPDFSDK_AnnotHandlerMgr* pAnnotHandlerMgr = pEnv->GetAnnotHandlerMgr(); |
1019 ASSERT(pAnnotHandlerMgr != NULL); | 1019 ASSERT(pAnnotHandlerMgr != NULL); |
1020 | 1020 |
1021 if(pAnnotHandlerMgr) | 1021 if(pAnnotHandlerMgr) |
1022 { | 1022 { |
1023 CPDFSDK_Annot* pAnnot = pAnnotHandlerMgr->NewAnnot(pPDFAnnot, this); | 1023 CPDFSDK_Annot* pAnnot = pAnnotHandlerMgr->NewAnnot(pPDFAnnot, this); |
1024 if(!pAnnot) | 1024 if(!pAnnot) |
1025 continue; | 1025 continue; |
1026 m_fxAnnotArray.Add(pAnnot); | 1026 m_fxAnnotArray.Add(pAnnot); |
1027 | 1027 |
1028 pAnnotHandlerMgr->Annot_OnLoad(pAnnot); | 1028 pAnnotHandlerMgr->Annot_OnLoad(pAnnot); |
1029 } | 1029 } |
1030 | 1030 |
1031 } | 1031 } |
1032 SetLock(FALSE); | 1032 SetLock(false); |
1033 } | 1033 } |
1034 | 1034 |
1035 void CPDFSDK_PageView::UpdateRects(CFX_RectArray& rects) | 1035 void CPDFSDK_PageView::UpdateRects(CFX_RectArray& rects) |
1036 { | 1036 { |
1037 for(int i=0; i<rects.GetSize(); i++) | 1037 for(int i=0; i<rects.GetSize(); i++) |
1038 { | 1038 { |
1039 CPDF_Rect rc = rects.GetAt(i); | 1039 CPDF_Rect rc = rects.GetAt(i); |
1040 CPDFDoc_Environment* pEnv = m_pSDKDoc->GetEnv(); | 1040 CPDFDoc_Environment* pEnv = m_pSDKDoc->GetEnv(); |
1041 pEnv->FFI_Invalidate(m_page, rc.left, rc.top, rc.right, rc.bottom); | 1041 pEnv->FFI_Invalidate(m_page, rc.left, rc.top, rc.right, rc.bottom); |
1042 } | 1042 } |
(...skipping 14 matching lines...) Expand all Loading... |
1057 CPDF_Dictionary* pDic = m_page->m_pFormDict; | 1057 CPDF_Dictionary* pDic = m_page->m_pFormDict; |
1058 CPDF_Document* pDoc = m_pSDKDoc->GetDocument(); | 1058 CPDF_Document* pDoc = m_pSDKDoc->GetDocument(); |
1059 if(pDoc && pDic) | 1059 if(pDoc && pDic) |
1060 { | 1060 { |
1061 return pDoc->GetPageIndex(pDic->GetObjNum()); | 1061 return pDoc->GetPageIndex(pDic->GetObjNum()); |
1062 } | 1062 } |
1063 } | 1063 } |
1064 return -1; | 1064 return -1; |
1065 } | 1065 } |
1066 | 1066 |
1067 FX_BOOL CPDFSDK_PageView::IsValidAnnot(void* p) | 1067 bool CPDFSDK_PageView::IsValidAnnot(void* p) |
1068 { | 1068 { |
1069 if (p == NULL) return FALSE; | 1069 if (p == NULL) return false; |
1070 int iCount = m_pAnnotList->Count(); | 1070 int iCount = m_pAnnotList->Count(); |
1071 for (int i = 0; i < iCount; i++) | 1071 for (int i = 0; i < iCount; i++) |
1072 { | 1072 { |
1073 if (m_pAnnotList->GetAt(i) == p) | 1073 if (m_pAnnotList->GetAt(i) == p) |
1074 return TRUE; | 1074 return true; |
1075 } | 1075 } |
1076 return FALSE; | 1076 return false; |
1077 } | 1077 } |
1078 | 1078 |
1079 | 1079 |
1080 CPDFSDK_Annot* CPDFSDK_PageView::GetFocusAnnot() | 1080 CPDFSDK_Annot* CPDFSDK_PageView::GetFocusAnnot() |
1081 { | 1081 { |
1082 CPDFSDK_Annot* pFocusAnnot = m_pSDKDoc->GetFocusAnnot(); | 1082 CPDFSDK_Annot* pFocusAnnot = m_pSDKDoc->GetFocusAnnot(); |
1083 if(!pFocusAnnot) | 1083 if(!pFocusAnnot) |
1084 return NULL; | 1084 return NULL; |
1085 | 1085 |
1086 for(int i=0; i<m_fxAnnotArray.GetSize(); i++) | 1086 for(int i=0; i<m_fxAnnotArray.GetSize(); i++) |
1087 { | 1087 { |
1088 CPDFSDK_Annot* pAnnot = (CPDFSDK_Annot*)m_fxAnnotArray.GetAt(i); | 1088 CPDFSDK_Annot* pAnnot = (CPDFSDK_Annot*)m_fxAnnotArray.GetAt(i); |
1089 if(pAnnot == pFocusAnnot) | 1089 if(pAnnot == pFocusAnnot) |
1090 return pAnnot; | 1090 return pAnnot; |
1091 } | 1091 } |
1092 return NULL; | 1092 return NULL; |
1093 } | 1093 } |
OLD | NEW |