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 // FXFT_Face nFace = pFontMgr->FindSubstFont(sFontFaceName,TRUE,0,0,0,0,NULL); | 144 // FXFT_Face nFace = pFontMgr->FindSubstFont(sFontFaceName,true,0,0,0,0,NULL); |
145 // FXFT_Face nFace = pFontMgr->m_pBuiltinMapper->FindSubstFont(sFontFaceName,T
RUE,0,0,0,0,NULL); | 145 // FXFT_Face nFace = pFontMgr->m_pBuiltinMapper->FindSubstFont(sFontFaceName,t
rue,0,0,0,0,NULL); |
146 | 146 |
147 if(pFontMgr) | 147 if(pFontMgr) |
148 { | 148 { |
149 CFX_FontMapper* pFontMapper = pFontMgr->m_pBuiltinMapper; | 149 CFX_FontMapper* pFontMapper = pFontMgr->m_pBuiltinMapper; |
150 if(pFontMapper) | 150 if(pFontMapper) |
151 { | 151 { |
152 int nSize = pFontMapper->m_InstalledTTFonts.GetSize(); | 152 int nSize = pFontMapper->m_InstalledTTFonts.GetSize(); |
153 if(nSize ==0) | 153 if(nSize ==0) |
154 { | 154 { |
155 pFontMapper->LoadInstalledFonts(); | 155 pFontMapper->LoadInstalledFonts(); |
156 nSize = pFontMapper->m_InstalledTTFonts.GetSize(); | 156 nSize = pFontMapper->m_InstalledTTFonts.GetSize(); |
157 } | 157 } |
158 | 158 |
159 for(int i=0; i<nSize; i++) | 159 for(int i=0; i<nSize; i++) |
160 { | 160 { |
161 if(pFontMapper->m_InstalledTTFonts[i].Compare(sFontFaceName)) | 161 if(pFontMapper->m_InstalledTTFonts[i].Compare(sFontFaceName)) |
162 return TRUE; | 162 return true; |
163 } | 163 } |
164 } | 164 } |
165 | 165 |
166 } | 166 } |
167 | 167 |
168 return FALSE; | 168 return false; |
169 // pFontMgr->m_FaceMap.Lookup(sFontFaceName,pFont); | 169 // pFontMgr->m_FaceMap.Lookup(sFontFaceName,pFont); |
170 // return (pFont!=NULL); | 170 // return (pFont!=NULL); |
171 } | 171 } |
172 | 172 |
173 static int CharSet2CP(int charset) | 173 static int CharSet2CP(int charset) |
174 { | 174 { |
175 if(charset == 128) | 175 if(charset == 128) |
176 return 932; | 176 return 932; |
177 else if(charset == 134) | 177 else if(charset == 134) |
178 return 936; | 178 return 936; |
179 else if(charset == 129) | 179 else if(charset == 129) |
180 return 949; | 180 return 949; |
181 else if(charset == 136) | 181 else if(charset == 136) |
182 return 950; | 182 return 950; |
183 return 0; | 183 return 0; |
184 } | 184 } |
185 CPDF_Font* CFX_SystemHandler::AddNativeTrueTypeFontToPDF(CPDF_Document* pDoc, CF
X_ByteString sFontFaceName, | 185 CPDF_Font* CFX_SystemHandler::AddNativeTrueTypeFontToPDF(CPDF_Document* pDoc, CF
X_ByteString sFontFaceName, |
186 uint8_t nCharset) | 186 uint8_t nCharset) |
187 { | 187 { |
188 if(pDoc) | 188 if(pDoc) |
189 { | 189 { |
190 CFX_Font* pFXFont = new CFX_Font(); | 190 CFX_Font* pFXFont = new CFX_Font(); |
191 pFXFont->LoadSubst(sFontFaceName,TRUE,0,0,0,CharSet2CP(nCharset),FALSE); | 191 pFXFont->LoadSubst(sFontFaceName,true,0,0,0,CharSet2CP(nCharset),false); |
192 CPDF_Font* pFont = pDoc->AddFont(pFXFont,nCharset,FALSE); | 192 CPDF_Font* pFont = pDoc->AddFont(pFXFont,nCharset,false); |
193 delete pFXFont; | 193 delete pFXFont; |
194 return pFont; | 194 return pFont; |
195 } | 195 } |
196 | 196 |
197 return NULL; | 197 return NULL; |
198 } | 198 } |
199 | 199 |
200 | 200 |
201 int32_t CFX_SystemHandler::SetTimer(int32_t uElapse, TimerCallback lpTimerFunc) | 201 int32_t CFX_SystemHandler::SetTimer(int32_t uElapse, TimerCallback lpTimerFunc) |
202 { | 202 { |
(...skipping 204 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
407 m_pIFormFiller = new CFFL_IFormFiller(this); | 407 m_pIFormFiller = new CFFL_IFormFiller(this); |
408 return m_pIFormFiller; | 408 return m_pIFormFiller; |
409 } | 409 } |
410 | 410 |
411 CPDFSDK_Document::CPDFSDK_Document(CPDF_Document* pDoc,CPDFDoc_Environment* pEnv
) : | 411 CPDFSDK_Document::CPDFSDK_Document(CPDF_Document* pDoc,CPDFDoc_Environment* pEnv
) : |
412 m_pDoc(pDoc), | 412 m_pDoc(pDoc), |
413 m_pInterForm(nullptr), | 413 m_pInterForm(nullptr), |
414 m_pFocusAnnot(nullptr), | 414 m_pFocusAnnot(nullptr), |
415 m_pEnv(pEnv), | 415 m_pEnv(pEnv), |
416 m_pOccontent(nullptr), | 416 m_pOccontent(nullptr), |
417 m_bChangeMask(FALSE) | 417 m_bChangeMask(false) |
418 { | 418 { |
419 } | 419 } |
420 | 420 |
421 CPDFSDK_Document::~CPDFSDK_Document() | 421 CPDFSDK_Document::~CPDFSDK_Document() |
422 { | 422 { |
423 for (auto& it : m_pageMap) | 423 for (auto& it : m_pageMap) |
424 delete it.second; | 424 delete it.second; |
425 m_pageMap.clear(); | 425 m_pageMap.clear(); |
426 | 426 |
427 delete m_pInterForm; | 427 delete m_pInterForm; |
428 m_pInterForm = nullptr; | 428 m_pInterForm = nullptr; |
429 | 429 |
430 delete m_pOccontent; | 430 delete m_pOccontent; |
431 m_pOccontent = nullptr; | 431 m_pOccontent = nullptr; |
432 } | 432 } |
433 | 433 |
434 CPDFSDK_PageView* CPDFSDK_Document::GetPageView(CPDF_Page* pPDFPage, FX_BOOL ReN
ew) | 434 CPDFSDK_PageView* CPDFSDK_Document::GetPageView(CPDF_Page* pPDFPage, bool ReNew) |
435 { | 435 { |
436 auto it = m_pageMap.find(pPDFPage); | 436 auto it = m_pageMap.find(pPDFPage); |
437 if (it != m_pageMap.end()) | 437 if (it != m_pageMap.end()) |
438 return it->second; | 438 return it->second; |
439 | 439 |
440 if (!ReNew) | 440 if (!ReNew) |
441 return nullptr; | 441 return nullptr; |
442 | 442 |
443 CPDFSDK_PageView* pPageView = new CPDFSDK_PageView(this, pPDFPage); | 443 CPDFSDK_PageView* pPageView = new CPDFSDK_PageView(this, pPDFPage); |
444 m_pageMap[pPDFPage] = pPageView; | 444 m_pageMap[pPDFPage] = pPageView; |
445 // Delay to load all the annotations, to avoid endless loop. | 445 // Delay to load all the annotations, to avoid endless loop. |
446 pPageView->LoadFXAnnots(); | 446 pPageView->LoadFXAnnots(); |
447 return pPageView; | 447 return pPageView; |
448 } | 448 } |
449 | 449 |
450 CPDFSDK_PageView* CPDFSDK_Document::GetCurrentView() | 450 CPDFSDK_PageView* CPDFSDK_Document::GetCurrentView() |
451 { | 451 { |
452 CPDF_Page* pPage = (CPDF_Page*)m_pEnv->FFI_GetCurrentPage(m_pDoc); | 452 CPDF_Page* pPage = (CPDF_Page*)m_pEnv->FFI_GetCurrentPage(m_pDoc); |
453 return pPage ? GetPageView(pPage, TRUE) : nullptr; | 453 return pPage ? GetPageView(pPage, true) : nullptr; |
454 } | 454 } |
455 | 455 |
456 CPDFSDK_PageView* CPDFSDK_Document::GetPageView(int nIndex) | 456 CPDFSDK_PageView* CPDFSDK_Document::GetPageView(int nIndex) |
457 { | 457 { |
458 CPDF_Page* pTempPage = (CPDF_Page*)m_pEnv->FFI_GetPage(m_pDoc, nIndex); | 458 CPDF_Page* pTempPage = (CPDF_Page*)m_pEnv->FFI_GetPage(m_pDoc, nIndex); |
459 if (!pTempPage) | 459 if (!pTempPage) |
460 return nullptr; | 460 return nullptr; |
461 | 461 |
462 auto it = m_pageMap.find(pTempPage); | 462 auto it = m_pageMap.find(pTempPage); |
463 return it->second; | 463 return it->second; |
464 } | 464 } |
465 | 465 |
466 void CPDFSDK_Document:: ProcJavascriptFun() | 466 void CPDFSDK_Document:: ProcJavascriptFun() |
467 { | 467 { |
468 CPDF_Document* pPDFDoc = GetDocument(); | 468 CPDF_Document* pPDFDoc = GetDocument(); |
469 CPDF_DocJSActions docJS(pPDFDoc); | 469 CPDF_DocJSActions docJS(pPDFDoc); |
470 int iCount = docJS.CountJSActions(); | 470 int iCount = docJS.CountJSActions(); |
471 if (iCount < 1) return; | 471 if (iCount < 1) return; |
472 for (int i = 0; i < iCount; i ++) | 472 for (int i = 0; i < iCount; i ++) |
473 { | 473 { |
474 CFX_ByteString csJSName; | 474 CFX_ByteString csJSName; |
475 CPDF_Action jsAction = docJS.GetJSAction(i, csJSName); | 475 CPDF_Action jsAction = docJS.GetJSAction(i, csJSName); |
476 if(m_pEnv->GetActionHander()) | 476 if(m_pEnv->GetActionHander()) |
477 m_pEnv->GetActionHander()->DoAction_JavaScript(jsAction,CFX_WideStri
ng::FromLocal(csJSName),this); | 477 m_pEnv->GetActionHander()->DoAction_JavaScript(jsAction,CFX_WideStri
ng::FromLocal(csJSName),this); |
478 } | 478 } |
479 | 479 |
480 } | 480 } |
481 | 481 |
482 FX_BOOL CPDFSDK_Document::ProcOpenAction() | 482 bool CPDFSDK_Document::ProcOpenAction() |
483 { | 483 { |
484 if(!m_pDoc) | 484 if(!m_pDoc) |
485 return FALSE; | 485 return false; |
486 | 486 |
487 CPDF_Dictionary* pRoot = m_pDoc->GetRoot(); | 487 CPDF_Dictionary* pRoot = m_pDoc->GetRoot(); |
488 if (!pRoot) | 488 if (!pRoot) |
489 return FALSE; | 489 return false; |
490 | 490 |
491 CPDF_Object* pOpenAction = pRoot->GetDict("OpenAction"); | 491 CPDF_Object* pOpenAction = pRoot->GetDict("OpenAction"); |
492 if(!pOpenAction) | 492 if(!pOpenAction) |
493 pOpenAction = pRoot->GetArray("OpenAction"); | 493 pOpenAction = pRoot->GetArray("OpenAction"); |
494 | 494 |
495 if(!pOpenAction) | 495 if(!pOpenAction) |
496 return FALSE; | 496 return false; |
497 | 497 |
498 if(pOpenAction->GetType()==PDFOBJ_ARRAY) | 498 if(pOpenAction->GetType()==PDFOBJ_ARRAY) |
499 return TRUE; | 499 return true; |
500 | 500 |
501 if(pOpenAction->GetType()==PDFOBJ_DICTIONARY) | 501 if(pOpenAction->GetType()==PDFOBJ_DICTIONARY) |
502 { | 502 { |
503 CPDF_Dictionary * pDict=(CPDF_Dictionary*)pOpenAction; | 503 CPDF_Dictionary * pDict=(CPDF_Dictionary*)pOpenAction; |
504 CPDF_Action action(pDict); | 504 CPDF_Action action(pDict); |
505 if(m_pEnv->GetActionHander()) | 505 if(m_pEnv->GetActionHander()) |
506 m_pEnv->GetActionHander()->DoAction_DocOpen(action, this); | 506 m_pEnv->GetActionHander()->DoAction_DocOpen(action, this); |
507 return TRUE; | 507 return true; |
508 } | 508 } |
509 return FALSE; | 509 return false; |
510 } | 510 } |
511 | 511 |
512 CPDF_OCContext* CPDFSDK_Document::GetOCContext() | 512 CPDF_OCContext* CPDFSDK_Document::GetOCContext() |
513 { | 513 { |
514 if(!m_pOccontent) | 514 if(!m_pOccontent) |
515 m_pOccontent = new CPDF_OCContext(m_pDoc); | 515 m_pOccontent = new CPDF_OCContext(m_pDoc); |
516 return m_pOccontent; | 516 return m_pOccontent; |
517 } | 517 } |
518 | 518 |
519 void CPDFSDK_Document::ReMovePageView(CPDF_Page* pPDFPage) | 519 void CPDFSDK_Document::ReMovePageView(CPDF_Page* pPDFPage) |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
553 pPageView->UpdateView(pAnnot); | 553 pPageView->UpdateView(pAnnot); |
554 } | 554 } |
555 } | 555 } |
556 } | 556 } |
557 | 557 |
558 CPDFSDK_Annot* CPDFSDK_Document::GetFocusAnnot() | 558 CPDFSDK_Annot* CPDFSDK_Document::GetFocusAnnot() |
559 { | 559 { |
560 return m_pFocusAnnot; | 560 return m_pFocusAnnot; |
561 } | 561 } |
562 | 562 |
563 FX_BOOL CPDFSDK_Document::SetFocusAnnot(CPDFSDK_Annot* pAnnot,FX_UINT nFlag) | 563 bool CPDFSDK_Document::SetFocusAnnot(CPDFSDK_Annot* pAnnot,FX_UINT nFlag) |
564 { | 564 { |
565 | 565 |
566 if(m_pFocusAnnot==pAnnot) return TRUE; | 566 if(m_pFocusAnnot==pAnnot) return true; |
567 | 567 |
568 if(m_pFocusAnnot) | 568 if(m_pFocusAnnot) |
569 { | 569 { |
570 if(!KillFocusAnnot(nFlag) ) return FALSE; | 570 if(!KillFocusAnnot(nFlag) ) return false; |
571 } | 571 } |
572 CPDFSDK_PageView* pPageView = pAnnot->GetPageView(); | 572 CPDFSDK_PageView* pPageView = pAnnot->GetPageView(); |
573 if(pAnnot && pPageView->IsValid()) | 573 if(pAnnot && pPageView->IsValid()) |
574 { | 574 { |
575 CPDFSDK_AnnotHandlerMgr *pAnnotHandler=m_pEnv->GetAnnotHandlerMgr(); | 575 CPDFSDK_AnnotHandlerMgr *pAnnotHandler=m_pEnv->GetAnnotHandlerMgr(); |
576 | 576 |
577 if(pAnnotHandler&&!m_pFocusAnnot) | 577 if(pAnnotHandler&&!m_pFocusAnnot) |
578 { | 578 { |
579 if (!pAnnotHandler->Annot_OnSetFocus(pAnnot,nFlag)) | 579 if (!pAnnotHandler->Annot_OnSetFocus(pAnnot,nFlag)) |
580 return FALSE; | 580 return false; |
581 if(!m_pFocusAnnot) | 581 if(!m_pFocusAnnot) |
582 { | 582 { |
583 m_pFocusAnnot=pAnnot; | 583 m_pFocusAnnot=pAnnot; |
584 return TRUE; | 584 return true; |
585 } | 585 } |
586 } | 586 } |
587 } | 587 } |
588 return FALSE; | 588 return false; |
589 } | 589 } |
590 | 590 |
591 FX_BOOL CPDFSDK_Document::KillFocusAnnot(FX_UINT nFlag) | 591 bool CPDFSDK_Document::KillFocusAnnot(FX_UINT nFlag) |
592 { | 592 { |
593 if(m_pFocusAnnot) | 593 if(m_pFocusAnnot) |
594 { | 594 { |
595 CPDFSDK_AnnotHandlerMgr *pAnnotHandler=m_pEnv->GetAnnotHandlerMgr(); | 595 CPDFSDK_AnnotHandlerMgr *pAnnotHandler=m_pEnv->GetAnnotHandlerMgr(); |
596 if(pAnnotHandler) | 596 if(pAnnotHandler) |
597 { | 597 { |
598 CPDFSDK_Annot* pFocusAnnot = m_pFocusAnnot; | 598 CPDFSDK_Annot* pFocusAnnot = m_pFocusAnnot; |
599 m_pFocusAnnot = NULL; | 599 m_pFocusAnnot = NULL; |
600 if(pAnnotHandler->Annot_OnKillFocus(pFocusAnnot, nFlag)) | 600 if(pAnnotHandler->Annot_OnKillFocus(pFocusAnnot, nFlag)) |
601 { | 601 { |
602 | 602 |
603 if(pFocusAnnot->GetType() == FX_BSTRC("Widget")) | 603 if(pFocusAnnot->GetType() == FX_BSTRC("Widget")) |
604 { | 604 { |
605 CPDFSDK_Widget* pWidget = (CPDFSDK_Widget*)pFocusAnnot; | 605 CPDFSDK_Widget* pWidget = (CPDFSDK_Widget*)pFocusAnnot; |
606 int nFieldType = pWidget->GetFieldType(); | 606 int nFieldType = pWidget->GetFieldType(); |
607 if(FIELDTYPE_TEXTFIELD == nFieldType || FIELDTYPE_COMBOBOX =
= nFieldType) | 607 if(FIELDTYPE_TEXTFIELD == nFieldType || FIELDTYPE_COMBOBOX =
= nFieldType) |
608 m_pEnv->FFI_OnSetFieldInputFocus(NULL, NULL, 0, FALSE); | 608 m_pEnv->FFI_OnSetFieldInputFocus(NULL, NULL, 0, false); |
609 } | 609 } |
610 | 610 |
611 if(!m_pFocusAnnot) | 611 if(!m_pFocusAnnot) |
612 return TRUE; | 612 return true; |
613 } | 613 } |
614 else | 614 else |
615 { | 615 { |
616 m_pFocusAnnot = pFocusAnnot; | 616 m_pFocusAnnot = pFocusAnnot; |
617 } | 617 } |
618 } | 618 } |
619 } | 619 } |
620 return FALSE; | 620 return false; |
621 } | 621 } |
622 | 622 |
623 void CPDFSDK_Document::OnCloseDocument() | 623 void CPDFSDK_Document::OnCloseDocument() |
624 { | 624 { |
625 KillFocusAnnot(); | 625 KillFocusAnnot(); |
626 } | 626 } |
627 | 627 |
628 FX_BOOL CPDFSDK_Document::GetPermissions(int nFlag) | 628 bool CPDFSDK_Document::GetPermissions(int nFlag) |
629 { | 629 { |
630 FX_DWORD dwPermissions = m_pDoc->GetUserPermissions(); | 630 FX_DWORD dwPermissions = m_pDoc->GetUserPermissions(); |
631 return dwPermissions&nFlag; | 631 return dwPermissions&nFlag; |
632 } | 632 } |
633 | 633 |
634 IFXJS_Runtime * CPDFSDK_Document::GetJsRuntime() | 634 IFXJS_Runtime * CPDFSDK_Document::GetJsRuntime() |
635 { | 635 { |
636 ASSERT(m_pEnv!=NULL); | 636 ASSERT(m_pEnv!=NULL); |
637 return m_pEnv->GetJSRuntime(); | 637 return m_pEnv->GetJSRuntime(); |
638 } | 638 } |
639 | 639 |
640 CFX_WideString CPDFSDK_Document::GetPath() | 640 CFX_WideString CPDFSDK_Document::GetPath() |
641 { | 641 { |
642 ASSERT(m_pEnv != NULL); | 642 ASSERT(m_pEnv != NULL); |
643 return m_pEnv->JS_docGetFilePath(); | 643 return m_pEnv->JS_docGetFilePath(); |
644 } | 644 } |
645 | 645 |
646 | 646 |
647 CPDFSDK_PageView::CPDFSDK_PageView(CPDFSDK_Document* pSDKDoc,CPDF_Page* page):m_
page(page),m_pSDKDoc(pSDKDoc) | 647 CPDFSDK_PageView::CPDFSDK_PageView(CPDFSDK_Document* pSDKDoc,CPDF_Page* page):m_
page(page),m_pSDKDoc(pSDKDoc) |
648 { | 648 { |
649 CPDFSDK_InterForm* pInterForm = pSDKDoc->GetInterForm(); | 649 CPDFSDK_InterForm* pInterForm = pSDKDoc->GetInterForm(); |
650 if(pInterForm) | 650 if(pInterForm) |
651 { | 651 { |
652 CPDF_InterForm* pPDFInterForm = pInterForm->GetInterForm(); | 652 CPDF_InterForm* pPDFInterForm = pInterForm->GetInterForm(); |
653 pPDFInterForm->FixPageFields(page); | 653 pPDFInterForm->FixPageFields(page); |
654 } | 654 } |
655 m_page->SetPrivateData((void*)m_page, (void*)this, NULL); | 655 m_page->SetPrivateData((void*)m_page, (void*)this, NULL); |
656 m_fxAnnotArray.RemoveAll(); | 656 m_fxAnnotArray.RemoveAll(); |
657 | 657 |
658 m_bEnterWidget = FALSE; | 658 m_bEnterWidget = false; |
659 m_bExitWidget = FALSE; | 659 m_bExitWidget = false; |
660 m_bOnWidget = FALSE; | 660 m_bOnWidget = false; |
661 m_CaptureWidget = NULL; | 661 m_CaptureWidget = NULL; |
662 m_bValid = FALSE; | 662 m_bValid = false; |
663 m_bLocked = FALSE; | 663 m_bLocked = false; |
664 m_bTakeOverPage = FALSE; | 664 m_bTakeOverPage = false; |
665 } | 665 } |
666 | 666 |
667 CPDFSDK_PageView::~CPDFSDK_PageView() | 667 CPDFSDK_PageView::~CPDFSDK_PageView() |
668 { | 668 { |
669 CPDFDoc_Environment* pEnv = m_pSDKDoc->GetEnv(); | 669 CPDFDoc_Environment* pEnv = m_pSDKDoc->GetEnv(); |
670 int nAnnotCount = m_fxAnnotArray.GetSize(); | 670 int nAnnotCount = m_fxAnnotArray.GetSize(); |
671 | 671 |
672 for (int i=0; i<nAnnotCount; i++) | 672 for (int i=0; i<nAnnotCount; i++) |
673 { | 673 { |
674 CPDFSDK_Annot* pAnnot = (CPDFSDK_Annot*)m_fxAnnotArray.GetAt(i); | 674 CPDFSDK_Annot* pAnnot = (CPDFSDK_Annot*)m_fxAnnotArray.GetAt(i); |
(...skipping 13 matching lines...) Expand all Loading... |
688 if(m_bTakeOverPage) { | 688 if(m_bTakeOverPage) { |
689 delete m_page; | 689 delete m_page; |
690 } | 690 } |
691 } | 691 } |
692 | 692 |
693 void CPDFSDK_PageView::PageView_OnDraw(CFX_RenderDevice* pDevice, CPDF_Matrix* p
User2Device,CPDF_RenderOptions* pOptions) | 693 void CPDFSDK_PageView::PageView_OnDraw(CFX_RenderDevice* pDevice, CPDF_Matrix* p
User2Device,CPDF_RenderOptions* pOptions) |
694 { | 694 { |
695 m_curMatrix = *pUser2Device; | 695 m_curMatrix = *pUser2Device; |
696 | 696 |
697 CPDFDoc_Environment* pEnv = m_pSDKDoc->GetEnv(); | 697 CPDFDoc_Environment* pEnv = m_pSDKDoc->GetEnv(); |
698 CPDFSDK_AnnotIterator annotIterator(this, TRUE); | 698 CPDFSDK_AnnotIterator annotIterator(this, true); |
699 CPDFSDK_Annot* pSDKAnnot = nullptr; | 699 CPDFSDK_Annot* pSDKAnnot = nullptr; |
700 int index = -1; | 700 int index = -1; |
701 while ((pSDKAnnot = annotIterator.Next(index))) { | 701 while ((pSDKAnnot = annotIterator.Next(index))) { |
702 CPDFSDK_AnnotHandlerMgr* pAnnotHandlerMgr = pEnv->GetAnnotHandlerMgr(); | 702 CPDFSDK_AnnotHandlerMgr* pAnnotHandlerMgr = pEnv->GetAnnotHandlerMgr(); |
703 ASSERT(pAnnotHandlerMgr); | 703 ASSERT(pAnnotHandlerMgr); |
704 pAnnotHandlerMgr->Annot_OnDraw( | 704 pAnnotHandlerMgr->Annot_OnDraw( |
705 this, pSDKAnnot, pDevice, pUser2Device, 0); | 705 this, pSDKAnnot, pDevice, pUser2Device, 0); |
706 } | 706 } |
707 } | 707 } |
708 | 708 |
(...skipping 26 matching lines...) Expand all Loading... |
735 if(annotRect.Contains(pageX, pageY)) | 735 if(annotRect.Contains(pageX, pageY)) |
736 return pAnnot; | 736 return pAnnot; |
737 } | 737 } |
738 } | 738 } |
739 return NULL; | 739 return NULL; |
740 } | 740 } |
741 | 741 |
742 CPDFSDK_Annot* CPDFSDK_PageView::GetFXAnnotAtPoint(FX_FLOAT pageX, FX_FLOAT page
Y) | 742 CPDFSDK_Annot* CPDFSDK_PageView::GetFXAnnotAtPoint(FX_FLOAT pageX, FX_FLOAT page
Y) |
743 { | 743 { |
744 | 744 |
745 CPDFSDK_AnnotIterator annotIterator(this, FALSE); | 745 CPDFSDK_AnnotIterator annotIterator(this, false); |
746 CPDFDoc_Environment* pEnv = m_pSDKDoc->GetEnv(); | 746 CPDFDoc_Environment* pEnv = m_pSDKDoc->GetEnv(); |
747 CPDFSDK_AnnotHandlerMgr* pAnnotMgr = pEnv->GetAnnotHandlerMgr(); | 747 CPDFSDK_AnnotHandlerMgr* pAnnotMgr = pEnv->GetAnnotHandlerMgr(); |
748 CPDFSDK_Annot* pSDKAnnot = NULL; | 748 CPDFSDK_Annot* pSDKAnnot = NULL; |
749 int index = -1; | 749 int index = -1; |
750 while((pSDKAnnot = annotIterator.Next(index))) | 750 while((pSDKAnnot = annotIterator.Next(index))) |
751 { | 751 { |
752 CPDF_Rect rc = pAnnotMgr->Annot_OnGetViewBBox(this, pSDKAnnot); | 752 CPDF_Rect rc = pAnnotMgr->Annot_OnGetViewBBox(this, pSDKAnnot); |
753 if(rc.Contains(pageX, pageY)) | 753 if(rc.Contains(pageX, pageY)) |
754 return pSDKAnnot; | 754 return pSDKAnnot; |
755 } | 755 } |
756 | 756 |
757 return NULL; | 757 return NULL; |
758 } | 758 } |
759 | 759 |
760 CPDFSDK_Annot* CPDFSDK_PageView::GetFXWidgetAtPoint(FX_FLOAT pageX, FX_FLOAT pag
eY) | 760 CPDFSDK_Annot* CPDFSDK_PageView::GetFXWidgetAtPoint(FX_FLOAT pageX, FX_FLOAT pag
eY) |
761 { | 761 { |
762 | 762 |
763 CPDFSDK_AnnotIterator annotIterator(this, FALSE); | 763 CPDFSDK_AnnotIterator annotIterator(this, false); |
764 CPDFDoc_Environment* pEnv = m_pSDKDoc->GetEnv(); | 764 CPDFDoc_Environment* pEnv = m_pSDKDoc->GetEnv(); |
765 CPDFSDK_AnnotHandlerMgr* pAnnotMgr = pEnv->GetAnnotHandlerMgr(); | 765 CPDFSDK_AnnotHandlerMgr* pAnnotMgr = pEnv->GetAnnotHandlerMgr(); |
766 CPDFSDK_Annot* pSDKAnnot = NULL; | 766 CPDFSDK_Annot* pSDKAnnot = NULL; |
767 int index = -1; | 767 int index = -1; |
768 while((pSDKAnnot = annotIterator.Next(index))) | 768 while((pSDKAnnot = annotIterator.Next(index))) |
769 { | 769 { |
770 if(pSDKAnnot->GetType() == "Widget") | 770 if(pSDKAnnot->GetType() == "Widget") |
771 { | 771 { |
772 pAnnotMgr->Annot_OnGetViewBBox(this, pSDKAnnot); | 772 pAnnotMgr->Annot_OnGetViewBBox(this, pSDKAnnot); |
773 CPDF_Point point(pageX, pageY); | 773 CPDF_Point point(pageX, pageY); |
774 if (pAnnotMgr->Annot_OnHitTest(this, pSDKAnnot, point)) | 774 if (pAnnotMgr->Annot_OnHitTest(this, pSDKAnnot, point)) |
775 return pSDKAnnot; | 775 return pSDKAnnot; |
776 } | 776 } |
777 } | 777 } |
778 | 778 |
779 return NULL; | 779 return NULL; |
780 } | 780 } |
781 | 781 |
782 | 782 |
783 FX_BOOL CPDFSDK_PageView::Annot_HasAppearance(CPDF_Annot* pAnnot) | 783 bool CPDFSDK_PageView::Annot_HasAppearance(CPDF_Annot* pAnnot) |
784 { | 784 { |
785 CPDF_Dictionary* pAnnotDic = pAnnot->GetAnnotDict(); | 785 CPDF_Dictionary* pAnnotDic = pAnnot->GetAnnotDict(); |
786 if(pAnnotDic) | 786 if(pAnnotDic) |
787 return pAnnotDic->KeyExist("AS"); | 787 return pAnnotDic->KeyExist("AS"); |
788 return FALSE; | 788 return false; |
789 } | 789 } |
790 | 790 |
791 CPDFSDK_Annot* CPDFSDK_PageView::AddAnnot(CPDF_Annot * pPDFAnnot) | 791 CPDFSDK_Annot* CPDFSDK_PageView::AddAnnot(CPDF_Annot * pPDFAnnot) |
792 { | 792 { |
793 CPDFDoc_Environment* pEnv = m_pSDKDoc->GetEnv(); | 793 CPDFDoc_Environment* pEnv = m_pSDKDoc->GetEnv(); |
794 ASSERT(pEnv); | 794 ASSERT(pEnv); |
795 CPDFSDK_AnnotHandlerMgr * pAnnotHandler= pEnv->GetAnnotHandlerMgr(); | 795 CPDFSDK_AnnotHandlerMgr * pAnnotHandler= pEnv->GetAnnotHandlerMgr(); |
796 | 796 |
797 CPDFSDK_Annot* pSDKAnnot =NULL; | 797 CPDFSDK_Annot* pSDKAnnot =NULL; |
798 | 798 |
(...skipping 18 matching lines...) Expand all Loading... |
817 CPDFSDK_Annot* CPDFSDK_PageView::AddAnnot(CPDF_Dictionary * pDict) | 817 CPDFSDK_Annot* CPDFSDK_PageView::AddAnnot(CPDF_Dictionary * pDict) |
818 { | 818 { |
819 return pDict ? AddAnnot(pDict->GetString("Subtype"), pDict) : nullptr; | 819 return pDict ? AddAnnot(pDict->GetString("Subtype"), pDict) : nullptr; |
820 } | 820 } |
821 | 821 |
822 CPDFSDK_Annot* CPDFSDK_PageView::AddAnnot(const FX_CHAR* lpSubType,CPDF_Dictiona
ry * pDict) | 822 CPDFSDK_Annot* CPDFSDK_PageView::AddAnnot(const FX_CHAR* lpSubType,CPDF_Dictiona
ry * pDict) |
823 { | 823 { |
824 return NULL; | 824 return NULL; |
825 } | 825 } |
826 | 826 |
827 FX_BOOL CPDFSDK_PageView::DeleteAnnot(CPDFSDK_Annot* pAnnot) | 827 bool CPDFSDK_PageView::DeleteAnnot(CPDFSDK_Annot* pAnnot) |
828 { | 828 { |
829 return FALSE; | 829 return false; |
830 } | 830 } |
831 | 831 |
832 CPDF_Document* CPDFSDK_PageView::GetPDFDocument() | 832 CPDF_Document* CPDFSDK_PageView::GetPDFDocument() |
833 { | 833 { |
834 if(m_page) | 834 if(m_page) |
835 { | 835 { |
836 return m_page->m_pDocument; | 836 return m_page->m_pDocument; |
837 } | 837 } |
838 return NULL; | 838 return NULL; |
839 } | 839 } |
(...skipping 19 matching lines...) Expand all Loading... |
859 int nCount = m_fxAnnotArray.GetSize(); | 859 int nCount = m_fxAnnotArray.GetSize(); |
860 for(int i=0; i<nCount; i++) | 860 for(int i=0; i<nCount; i++) |
861 { | 861 { |
862 CPDFSDK_Annot* pAnnot = (CPDFSDK_Annot*)m_fxAnnotArray.GetAt(i); | 862 CPDFSDK_Annot* pAnnot = (CPDFSDK_Annot*)m_fxAnnotArray.GetAt(i); |
863 if (pDict == pAnnot->GetPDFAnnot()->GetAnnotDict()) | 863 if (pDict == pAnnot->GetPDFAnnot()->GetAnnotDict()) |
864 return pAnnot; | 864 return pAnnot; |
865 } | 865 } |
866 return NULL; | 866 return NULL; |
867 } | 867 } |
868 | 868 |
869 FX_BOOL CPDFSDK_PageView::OnLButtonDown(const CPDF_Point & point, FX_UINT nFlag) | 869 bool CPDFSDK_PageView::OnLButtonDown(const CPDF_Point & point, FX_UINT nFlag) |
870 { | 870 { |
871 CPDFDoc_Environment* pEnv = m_pSDKDoc->GetEnv(); | 871 CPDFDoc_Environment* pEnv = m_pSDKDoc->GetEnv(); |
872 ASSERT(pEnv); | 872 ASSERT(pEnv); |
873 CPDFSDK_Annot* pFXAnnot = GetFXWidgetAtPoint(point.x, point.y); | 873 CPDFSDK_Annot* pFXAnnot = GetFXWidgetAtPoint(point.x, point.y); |
874 if(!pFXAnnot) | 874 if(!pFXAnnot) |
875 { | 875 { |
876 KillFocusAnnot(nFlag); | 876 KillFocusAnnot(nFlag); |
877 } | 877 } |
878 else | 878 else |
879 { | 879 { |
880 CPDFSDK_AnnotHandlerMgr* pAnnotHandlerMgr = pEnv->GetAnnotHandlerMgr(); | 880 CPDFSDK_AnnotHandlerMgr* pAnnotHandlerMgr = pEnv->GetAnnotHandlerMgr(); |
881 ASSERT(pAnnotHandlerMgr); | 881 ASSERT(pAnnotHandlerMgr); |
882 | 882 |
883 FX_BOOL bRet = pAnnotHandlerMgr->Annot_OnLButtonDown(this, pFXAnnot, nFl
ag,point); | 883 bool bRet = pAnnotHandlerMgr->Annot_OnLButtonDown(this, pFXAnnot, nFlag,
point); |
884 if(bRet) | 884 if(bRet) |
885 { | 885 { |
886 SetFocusAnnot(pFXAnnot); | 886 SetFocusAnnot(pFXAnnot); |
887 } | 887 } |
888 return bRet; | 888 return bRet; |
889 } | 889 } |
890 return FALSE; | 890 return false; |
891 } | 891 } |
892 | 892 |
893 | 893 |
894 FX_BOOL CPDFSDK_PageView::OnLButtonUp(const CPDF_Point & point, FX_UINT nFlag) | 894 bool CPDFSDK_PageView::OnLButtonUp(const CPDF_Point & point, FX_UINT nFlag) |
895 { | 895 { |
896 CPDFDoc_Environment* pEnv = m_pSDKDoc->GetEnv(); | 896 CPDFDoc_Environment* pEnv = m_pSDKDoc->GetEnv(); |
897 ASSERT(pEnv); | 897 ASSERT(pEnv); |
898 CPDFSDK_AnnotHandlerMgr* pAnnotHandlerMgr = pEnv->GetAnnotHandlerMgr(); | 898 CPDFSDK_AnnotHandlerMgr* pAnnotHandlerMgr = pEnv->GetAnnotHandlerMgr(); |
899 ASSERT(pAnnotHandlerMgr); | 899 ASSERT(pAnnotHandlerMgr); |
900 CPDFSDK_Annot* pFXAnnot = GetFXWidgetAtPoint(point.x, point.y); | 900 CPDFSDK_Annot* pFXAnnot = GetFXWidgetAtPoint(point.x, point.y); |
901 CPDFSDK_Annot* pFocusAnnot = GetFocusAnnot(); | 901 CPDFSDK_Annot* pFocusAnnot = GetFocusAnnot(); |
902 FX_BOOL bRet = FALSE; | 902 bool bRet = false; |
903 if(pFocusAnnot && pFocusAnnot != pFXAnnot) | 903 if(pFocusAnnot && pFocusAnnot != pFXAnnot) |
904 { | 904 { |
905 //Last focus Annot gets a chance to handle the event. | 905 //Last focus Annot gets a chance to handle the event. |
906 bRet = pAnnotHandlerMgr->Annot_OnLButtonUp(this, pFocusAnnot, nFlag,poin
t); | 906 bRet = pAnnotHandlerMgr->Annot_OnLButtonUp(this, pFocusAnnot, nFlag,poin
t); |
907 } | 907 } |
908 if(pFXAnnot && !bRet) | 908 if(pFXAnnot && !bRet) |
909 { | 909 { |
910 bRet = pAnnotHandlerMgr->Annot_OnLButtonUp(this, pFXAnnot, nFlag,point); | 910 bRet = pAnnotHandlerMgr->Annot_OnLButtonUp(this, pFXAnnot, nFlag,point); |
911 return bRet; | 911 return bRet; |
912 } | 912 } |
913 return bRet; | 913 return bRet; |
914 } | 914 } |
915 | 915 |
916 FX_BOOL CPDFSDK_PageView::OnMouseMove(const CPDF_Point & point, int nFlag) | 916 bool CPDFSDK_PageView::OnMouseMove(const CPDF_Point & point, int nFlag) |
917 { | 917 { |
918 | 918 |
919 CPDFDoc_Environment* pEnv = m_pSDKDoc->GetEnv(); | 919 CPDFDoc_Environment* pEnv = m_pSDKDoc->GetEnv(); |
920 CPDFSDK_AnnotHandlerMgr* pAnnotHandlerMgr = pEnv->GetAnnotHandlerMgr(); | 920 CPDFSDK_AnnotHandlerMgr* pAnnotHandlerMgr = pEnv->GetAnnotHandlerMgr(); |
921 ASSERT(pAnnotHandlerMgr); | 921 ASSERT(pAnnotHandlerMgr); |
922 if(CPDFSDK_Annot* pFXAnnot = GetFXWidgetAtPoint(point.x, point.y)) | 922 if(CPDFSDK_Annot* pFXAnnot = GetFXWidgetAtPoint(point.x, point.y)) |
923 { | 923 { |
924 if(m_CaptureWidget && m_CaptureWidget != pFXAnnot) | 924 if(m_CaptureWidget && m_CaptureWidget != pFXAnnot) |
925 { | 925 { |
926 m_bExitWidget = TRUE; | 926 m_bExitWidget = true; |
927 m_bEnterWidget = FALSE; | 927 m_bEnterWidget = false; |
928 pAnnotHandlerMgr->Annot_OnMouseExit(this, m_CaptureWidget, nFlag); | 928 pAnnotHandlerMgr->Annot_OnMouseExit(this, m_CaptureWidget, nFlag); |
929 } | 929 } |
930 m_CaptureWidget = (CPDFSDK_Widget*)pFXAnnot; | 930 m_CaptureWidget = (CPDFSDK_Widget*)pFXAnnot; |
931 m_bOnWidget = TRUE; | 931 m_bOnWidget = true; |
932 if(!m_bEnterWidget) | 932 if(!m_bEnterWidget) |
933 { | 933 { |
934 m_bEnterWidget = TRUE; | 934 m_bEnterWidget = true; |
935 m_bExitWidget = FALSE; | 935 m_bExitWidget = false; |
936 pAnnotHandlerMgr->Annot_OnMouseEnter(this, pFXAnnot,nFlag); | 936 pAnnotHandlerMgr->Annot_OnMouseEnter(this, pFXAnnot,nFlag); |
937 } | 937 } |
938 pAnnotHandlerMgr->Annot_OnMouseMove(this, pFXAnnot, nFlag, point); | 938 pAnnotHandlerMgr->Annot_OnMouseMove(this, pFXAnnot, nFlag, point); |
939 return TRUE; | 939 return true; |
940 } | 940 } |
941 else | 941 else |
942 { | 942 { |
943 if(m_bOnWidget) | 943 if(m_bOnWidget) |
944 { | 944 { |
945 m_bOnWidget = FALSE; | 945 m_bOnWidget = false; |
946 m_bExitWidget = TRUE; | 946 m_bExitWidget = true; |
947 m_bEnterWidget = FALSE; | 947 m_bEnterWidget = false; |
948 if(m_CaptureWidget) | 948 if(m_CaptureWidget) |
949 { | 949 { |
950 pAnnotHandlerMgr->Annot_OnMouseExit(this, m_CaptureWidget, nFlag
); | 950 pAnnotHandlerMgr->Annot_OnMouseExit(this, m_CaptureWidget, nFlag
); |
951 m_CaptureWidget = NULL; | 951 m_CaptureWidget = NULL; |
952 } | 952 } |
953 } | 953 } |
954 return FALSE; | 954 return false; |
955 } | 955 } |
956 | 956 |
957 return FALSE;; | 957 return false;; |
958 } | 958 } |
959 | 959 |
960 FX_BOOL CPDFSDK_PageView::OnMouseWheel(double deltaX, double deltaY,const CPDF_P
oint& point, int nFlag) | 960 bool CPDFSDK_PageView::OnMouseWheel(double deltaX, double deltaY,const CPDF_Poin
t& point, int nFlag) |
961 { | 961 { |
962 if(CPDFSDK_Annot* pAnnot = GetFXWidgetAtPoint(point.x, point.y)) | 962 if(CPDFSDK_Annot* pAnnot = GetFXWidgetAtPoint(point.x, point.y)) |
963 { | 963 { |
964 CPDFDoc_Environment* pEnv = m_pSDKDoc->GetEnv(); | 964 CPDFDoc_Environment* pEnv = m_pSDKDoc->GetEnv(); |
965 CPDFSDK_AnnotHandlerMgr* pAnnotHandlerMgr = pEnv->GetAnnotHandlerMgr(); | 965 CPDFSDK_AnnotHandlerMgr* pAnnotHandlerMgr = pEnv->GetAnnotHandlerMgr(); |
966 ASSERT(pAnnotHandlerMgr); | 966 ASSERT(pAnnotHandlerMgr); |
967 return pAnnotHandlerMgr->Annot_OnMouseWheel(this, pAnnot, nFlag, (int)de
ltaY, point); | 967 return pAnnotHandlerMgr->Annot_OnMouseWheel(this, pAnnot, nFlag, (int)de
ltaY, point); |
968 } | 968 } |
969 return FALSE; | 969 return false; |
970 | 970 |
971 } | 971 } |
972 | 972 |
973 FX_BOOL CPDFSDK_PageView::OnChar(int nChar, FX_UINT nFlag) | 973 bool CPDFSDK_PageView::OnChar(int nChar, FX_UINT nFlag) |
974 { | 974 { |
975 if(CPDFSDK_Annot* pAnnot = GetFocusAnnot()) | 975 if(CPDFSDK_Annot* pAnnot = GetFocusAnnot()) |
976 { | 976 { |
977 CPDFDoc_Environment* pEnv = m_pSDKDoc->GetEnv(); | 977 CPDFDoc_Environment* pEnv = m_pSDKDoc->GetEnv(); |
978 CPDFSDK_AnnotHandlerMgr* pAnnotHandlerMgr = pEnv->GetAnnotHandlerMgr(); | 978 CPDFSDK_AnnotHandlerMgr* pAnnotHandlerMgr = pEnv->GetAnnotHandlerMgr(); |
979 ASSERT(pAnnotHandlerMgr); | 979 ASSERT(pAnnotHandlerMgr); |
980 return pAnnotHandlerMgr->Annot_OnChar(pAnnot, nChar, nFlag); | 980 return pAnnotHandlerMgr->Annot_OnChar(pAnnot, nChar, nFlag); |
981 } | 981 } |
982 | 982 |
983 return FALSE; | 983 return false; |
984 } | 984 } |
985 | 985 |
986 FX_BOOL CPDFSDK_PageView::OnKeyDown(int nKeyCode, int nFlag) | 986 bool CPDFSDK_PageView::OnKeyDown(int nKeyCode, int nFlag) |
987 { | 987 { |
988 if(CPDFSDK_Annot* pAnnot = GetFocusAnnot()) | 988 if(CPDFSDK_Annot* pAnnot = GetFocusAnnot()) |
989 { | 989 { |
990 CPDFDoc_Environment* pEnv = m_pSDKDoc->GetEnv(); | 990 CPDFDoc_Environment* pEnv = m_pSDKDoc->GetEnv(); |
991 CPDFSDK_AnnotHandlerMgr* pAnnotHandlerMgr = pEnv->GetAnnotHandlerMgr(); | 991 CPDFSDK_AnnotHandlerMgr* pAnnotHandlerMgr = pEnv->GetAnnotHandlerMgr(); |
992 ASSERT(pAnnotHandlerMgr); | 992 ASSERT(pAnnotHandlerMgr); |
993 return pAnnotHandlerMgr->Annot_OnKeyDown(pAnnot, nKeyCode, nFlag); | 993 return pAnnotHandlerMgr->Annot_OnKeyDown(pAnnot, nKeyCode, nFlag); |
994 } | 994 } |
995 return FALSE; | 995 return false; |
996 } | 996 } |
997 | 997 |
998 FX_BOOL CPDFSDK_PageView::OnKeyUp(int nKeyCode, int nFlag) | 998 bool CPDFSDK_PageView::OnKeyUp(int nKeyCode, int nFlag) |
999 { | 999 { |
1000 // if(CPDFSDK_Annot* pAnnot = GetFocusAnnot()) | 1000 // if(CPDFSDK_Annot* pAnnot = GetFocusAnnot()) |
1001 // { | 1001 // { |
1002 // CFFL_IFormFiller* pIFormFiller = g_pFormFillApp->GetIFormFiller(); | 1002 // CFFL_IFormFiller* pIFormFiller = g_pFormFillApp->GetIFormFiller(); |
1003 // return pIFormFiller->OnKeyUp(pAnnot, nKeyCode, nFlag); | 1003 // return pIFormFiller->OnKeyUp(pAnnot, nKeyCode, nFlag); |
1004 // } | 1004 // } |
1005 return FALSE; | 1005 return false; |
1006 } | 1006 } |
1007 | 1007 |
1008 extern void CheckUnSupportAnnot(CPDF_Document * pDoc, CPDF_Annot* pPDFAnnot); | 1008 extern void CheckUnSupportAnnot(CPDF_Document * pDoc, CPDF_Annot* pPDFAnnot); |
1009 | 1009 |
1010 void CPDFSDK_PageView::LoadFXAnnots() | 1010 void CPDFSDK_PageView::LoadFXAnnots() |
1011 { | 1011 { |
1012 CPDFDoc_Environment* pEnv = m_pSDKDoc->GetEnv(); | 1012 CPDFDoc_Environment* pEnv = m_pSDKDoc->GetEnv(); |
1013 | 1013 |
1014 FX_BOOL enableAPUpdate = CPDF_InterForm::UpdatingAPEnabled(); | 1014 bool enableAPUpdate = CPDF_InterForm::UpdatingAPEnabled(); |
1015 //Disable the default AP construction. | 1015 //Disable the default AP construction. |
1016 CPDF_InterForm::EnableUpdateAP(FALSE); | 1016 CPDF_InterForm::EnableUpdateAP(false); |
1017 m_pAnnotList = new CPDF_AnnotList(m_page); | 1017 m_pAnnotList = new CPDF_AnnotList(m_page); |
1018 CPDF_InterForm::EnableUpdateAP(enableAPUpdate); | 1018 CPDF_InterForm::EnableUpdateAP(enableAPUpdate); |
1019 int nCount = m_pAnnotList->Count(); | 1019 int nCount = m_pAnnotList->Count(); |
1020 SetLock(TRUE); | 1020 SetLock(true); |
1021 for(int i=0; i<nCount; i++) | 1021 for(int i=0; i<nCount; i++) |
1022 { | 1022 { |
1023 CPDF_Annot* pPDFAnnot = m_pAnnotList->GetAt(i); | 1023 CPDF_Annot* pPDFAnnot = m_pAnnotList->GetAt(i); |
1024 CPDF_Document * pDoc = GetPDFDocument(); | 1024 CPDF_Document * pDoc = GetPDFDocument(); |
1025 | 1025 |
1026 CheckUnSupportAnnot(pDoc, pPDFAnnot); | 1026 CheckUnSupportAnnot(pDoc, pPDFAnnot); |
1027 | 1027 |
1028 CPDFSDK_AnnotHandlerMgr* pAnnotHandlerMgr = pEnv->GetAnnotHandlerMgr(); | 1028 CPDFSDK_AnnotHandlerMgr* pAnnotHandlerMgr = pEnv->GetAnnotHandlerMgr(); |
1029 ASSERT(pAnnotHandlerMgr != NULL); | 1029 ASSERT(pAnnotHandlerMgr != NULL); |
1030 | 1030 |
1031 if(pAnnotHandlerMgr) | 1031 if(pAnnotHandlerMgr) |
1032 { | 1032 { |
1033 CPDFSDK_Annot* pAnnot = pAnnotHandlerMgr->NewAnnot(pPDFAnnot, this); | 1033 CPDFSDK_Annot* pAnnot = pAnnotHandlerMgr->NewAnnot(pPDFAnnot, this); |
1034 if(!pAnnot) | 1034 if(!pAnnot) |
1035 continue; | 1035 continue; |
1036 m_fxAnnotArray.Add(pAnnot); | 1036 m_fxAnnotArray.Add(pAnnot); |
1037 | 1037 |
1038 pAnnotHandlerMgr->Annot_OnLoad(pAnnot); | 1038 pAnnotHandlerMgr->Annot_OnLoad(pAnnot); |
1039 } | 1039 } |
1040 | 1040 |
1041 } | 1041 } |
1042 SetLock(FALSE); | 1042 SetLock(false); |
1043 } | 1043 } |
1044 | 1044 |
1045 void CPDFSDK_PageView::UpdateRects(CFX_RectArray& rects) | 1045 void CPDFSDK_PageView::UpdateRects(CFX_RectArray& rects) |
1046 { | 1046 { |
1047 for(int i=0; i<rects.GetSize(); i++) | 1047 for(int i=0; i<rects.GetSize(); i++) |
1048 { | 1048 { |
1049 CPDF_Rect rc = rects.GetAt(i); | 1049 CPDF_Rect rc = rects.GetAt(i); |
1050 CPDFDoc_Environment* pEnv = m_pSDKDoc->GetEnv(); | 1050 CPDFDoc_Environment* pEnv = m_pSDKDoc->GetEnv(); |
1051 pEnv->FFI_Invalidate(m_page, rc.left, rc.top, rc.right, rc.bottom); | 1051 pEnv->FFI_Invalidate(m_page, rc.left, rc.top, rc.right, rc.bottom); |
1052 } | 1052 } |
(...skipping 14 matching lines...) Expand all Loading... |
1067 CPDF_Dictionary* pDic = m_page->m_pFormDict; | 1067 CPDF_Dictionary* pDic = m_page->m_pFormDict; |
1068 CPDF_Document* pDoc = m_pSDKDoc->GetDocument(); | 1068 CPDF_Document* pDoc = m_pSDKDoc->GetDocument(); |
1069 if(pDoc && pDic) | 1069 if(pDoc && pDic) |
1070 { | 1070 { |
1071 return pDoc->GetPageIndex(pDic->GetObjNum()); | 1071 return pDoc->GetPageIndex(pDic->GetObjNum()); |
1072 } | 1072 } |
1073 } | 1073 } |
1074 return -1; | 1074 return -1; |
1075 } | 1075 } |
1076 | 1076 |
1077 FX_BOOL CPDFSDK_PageView::IsValidAnnot(void* p) | 1077 bool CPDFSDK_PageView::IsValidAnnot(void* p) |
1078 { | 1078 { |
1079 if (p == NULL) return FALSE; | 1079 if (p == NULL) return false; |
1080 int iCount = m_pAnnotList->Count(); | 1080 int iCount = m_pAnnotList->Count(); |
1081 for (int i = 0; i < iCount; i++) | 1081 for (int i = 0; i < iCount; i++) |
1082 { | 1082 { |
1083 if (m_pAnnotList->GetAt(i) == p) | 1083 if (m_pAnnotList->GetAt(i) == p) |
1084 return TRUE; | 1084 return true; |
1085 } | 1085 } |
1086 return FALSE; | 1086 return false; |
1087 } | 1087 } |
1088 | 1088 |
1089 | 1089 |
1090 CPDFSDK_Annot* CPDFSDK_PageView::GetFocusAnnot() | 1090 CPDFSDK_Annot* CPDFSDK_PageView::GetFocusAnnot() |
1091 { | 1091 { |
1092 CPDFSDK_Annot* pFocusAnnot = m_pSDKDoc->GetFocusAnnot(); | 1092 CPDFSDK_Annot* pFocusAnnot = m_pSDKDoc->GetFocusAnnot(); |
1093 if(!pFocusAnnot) | 1093 if(!pFocusAnnot) |
1094 return NULL; | 1094 return NULL; |
1095 | 1095 |
1096 for(int i=0; i<m_fxAnnotArray.GetSize(); i++) | 1096 for(int i=0; i<m_fxAnnotArray.GetSize(); i++) |
1097 { | 1097 { |
1098 CPDFSDK_Annot* pAnnot = (CPDFSDK_Annot*)m_fxAnnotArray.GetAt(i); | 1098 CPDFSDK_Annot* pAnnot = (CPDFSDK_Annot*)m_fxAnnotArray.GetAt(i); |
1099 if(pAnnot == pFocusAnnot) | 1099 if(pAnnot == pFocusAnnot) |
1100 return pAnnot; | 1100 return pAnnot; |
1101 } | 1101 } |
1102 return NULL; | 1102 return NULL; |
1103 } | 1103 } |
OLD | NEW |