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 #ifndef FPDFSDK_INCLUDE_FSDK_ANNOTHANDLER_H_ | 7 #ifndef FPDFSDK_INCLUDE_FSDK_ANNOTHANDLER_H_ |
8 #define FPDFSDK_INCLUDE_FSDK_ANNOTHANDLER_H_ | 8 #define FPDFSDK_INCLUDE_FSDK_ANNOTHANDLER_H_ |
9 | 9 |
10 #include <map> | 10 #include <map> |
11 #include <vector> | 11 #include <vector> |
12 | 12 |
13 #include "core/include/fxcrt/fx_basic.h" | 13 #include "core/include/fxcrt/fx_basic.h" |
14 | 14 |
15 #ifdef PDF_ENABLE_XFA | 15 #ifdef PDF_ENABLE_XFA |
16 #define FSDK_XFAWIDGET_TYPENAME "XFAWidget" | 16 #define FSDK_XFAWIDGET_TYPENAME "XFAWidget" |
| 17 #endif // PDF_ENABLE_XFA |
17 | 18 |
18 #endif | |
19 class CFFL_IFormFiller; | 19 class CFFL_IFormFiller; |
20 class CFX_RenderDevice; | 20 class CFX_RenderDevice; |
21 class CPDFDoc_Environment; | 21 class CPDFDoc_Environment; |
22 class CPDFSDK_Annot; | 22 class CPDFSDK_Annot; |
23 class CPDFSDK_PageView; | 23 class CPDFSDK_PageView; |
24 class CPDF_Annot; | 24 class CPDF_Annot; |
25 class CPDF_Matrix; | 25 class CPDF_Matrix; |
26 class CPDF_Point; | 26 class CPDF_Point; |
27 class CPDF_Rect; | 27 class CPDF_Rect; |
28 | 28 |
29 class IPDFSDK_AnnotHandler { | 29 class IPDFSDK_AnnotHandler { |
30 public: | 30 public: |
31 virtual ~IPDFSDK_AnnotHandler() {} | 31 virtual ~IPDFSDK_AnnotHandler() {} |
32 | 32 |
33 virtual CFX_ByteString GetType() = 0; | 33 virtual CFX_ByteString GetType() = 0; |
34 | 34 |
35 virtual CFX_ByteString GetName() = 0; | 35 virtual CFX_ByteString GetName() = 0; |
36 | 36 |
37 virtual FX_BOOL CanAnswer(CPDFSDK_Annot* pAnnot) = 0; | 37 virtual FX_BOOL CanAnswer(CPDFSDK_Annot* pAnnot) = 0; |
38 | 38 |
39 virtual CPDFSDK_Annot* NewAnnot(CPDF_Annot* pAnnot, | 39 virtual CPDFSDK_Annot* NewAnnot(CPDF_Annot* pAnnot, |
40 CPDFSDK_PageView* pPage) = 0; | 40 CPDFSDK_PageView* pPage) = 0; |
41 | 41 |
42 #ifdef PDF_ENABLE_XFA | 42 #ifdef PDF_ENABLE_XFA |
43 virtual CPDFSDK_Annot* NewAnnot(IXFA_Widget* hWidget, | 43 virtual CPDFSDK_Annot* NewAnnot(IXFA_Widget* hWidget, |
44 CPDFSDK_PageView* pPage) = 0; | 44 CPDFSDK_PageView* pPage) = 0; |
| 45 #endif // PDF_ENABLE_XFA |
45 | 46 |
46 #endif | |
47 virtual void ReleaseAnnot(CPDFSDK_Annot* pAnnot) = 0; | 47 virtual void ReleaseAnnot(CPDFSDK_Annot* pAnnot) = 0; |
48 | 48 |
49 virtual void DeleteAnnot(CPDFSDK_Annot* pAnnot) = 0; | 49 virtual void DeleteAnnot(CPDFSDK_Annot* pAnnot) = 0; |
50 | 50 |
51 virtual CPDF_Rect GetViewBBox(CPDFSDK_PageView* pPageView, | 51 virtual CPDF_Rect GetViewBBox(CPDFSDK_PageView* pPageView, |
52 CPDFSDK_Annot* pAnnot) = 0; | 52 CPDFSDK_Annot* pAnnot) = 0; |
53 | 53 |
54 virtual FX_BOOL HitTest(CPDFSDK_PageView* pPageView, | 54 virtual FX_BOOL HitTest(CPDFSDK_PageView* pPageView, |
55 CPDFSDK_Annot* pAnnot, | 55 CPDFSDK_Annot* pAnnot, |
56 const CPDF_Point& point) = 0; | 56 const CPDF_Point& point) = 0; |
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
124 virtual FX_BOOL OnKeyUp(CPDFSDK_Annot* pAnnot, int nKeyCode, int nFlag) = 0; | 124 virtual FX_BOOL OnKeyUp(CPDFSDK_Annot* pAnnot, int nKeyCode, int nFlag) = 0; |
125 | 125 |
126 virtual void OnDeSelected(CPDFSDK_Annot* pAnnot) = 0; | 126 virtual void OnDeSelected(CPDFSDK_Annot* pAnnot) = 0; |
127 virtual void OnSelected(CPDFSDK_Annot* pAnnot) = 0; | 127 virtual void OnSelected(CPDFSDK_Annot* pAnnot) = 0; |
128 | 128 |
129 virtual FX_BOOL OnSetFocus(CPDFSDK_Annot* pAnnot, FX_DWORD nFlag) = 0; | 129 virtual FX_BOOL OnSetFocus(CPDFSDK_Annot* pAnnot, FX_DWORD nFlag) = 0; |
130 virtual FX_BOOL OnKillFocus(CPDFSDK_Annot* pAnnot, FX_DWORD nFlag) = 0; | 130 virtual FX_BOOL OnKillFocus(CPDFSDK_Annot* pAnnot, FX_DWORD nFlag) = 0; |
131 #ifdef PDF_ENABLE_XFA | 131 #ifdef PDF_ENABLE_XFA |
132 virtual FX_BOOL OnXFAChangedFocus(CPDFSDK_Annot* pOldAnnot, | 132 virtual FX_BOOL OnXFAChangedFocus(CPDFSDK_Annot* pOldAnnot, |
133 CPDFSDK_Annot* pNewAnnot) = 0; | 133 CPDFSDK_Annot* pNewAnnot) = 0; |
134 #endif | 134 #endif // PDF_ENABLE_XFA |
135 }; | 135 }; |
136 | 136 |
137 class CPDFSDK_BFAnnotHandler : public IPDFSDK_AnnotHandler { | 137 class CPDFSDK_BFAnnotHandler : public IPDFSDK_AnnotHandler { |
138 public: | 138 public: |
139 explicit CPDFSDK_BFAnnotHandler(CPDFDoc_Environment* pApp) | 139 explicit CPDFSDK_BFAnnotHandler(CPDFDoc_Environment* pApp) |
140 : m_pApp(pApp), m_pFormFiller(NULL) {} | 140 : m_pApp(pApp), m_pFormFiller(NULL) {} |
141 ~CPDFSDK_BFAnnotHandler() override {} | 141 ~CPDFSDK_BFAnnotHandler() override {} |
142 | 142 |
143 // IPDFSDK_AnnotHandler | 143 // IPDFSDK_AnnotHandler |
144 CFX_ByteString GetType() override { return CFX_ByteString("Widget"); } | 144 CFX_ByteString GetType() override { return CFX_ByteString("Widget"); } |
145 CFX_ByteString GetName() override { return CFX_ByteString("WidgetHandler"); } | 145 CFX_ByteString GetName() override { return CFX_ByteString("WidgetHandler"); } |
146 FX_BOOL CanAnswer(CPDFSDK_Annot* pAnnot) override; | 146 FX_BOOL CanAnswer(CPDFSDK_Annot* pAnnot) override; |
147 CPDFSDK_Annot* NewAnnot(CPDF_Annot* pAnnot, CPDFSDK_PageView* pPage) override; | 147 CPDFSDK_Annot* NewAnnot(CPDF_Annot* pAnnot, CPDFSDK_PageView* pPage) override; |
148 #ifdef PDF_ENABLE_XFA | 148 #ifdef PDF_ENABLE_XFA |
149 CPDFSDK_Annot* NewAnnot(IXFA_Widget* hWidget, | 149 CPDFSDK_Annot* NewAnnot(IXFA_Widget* hWidget, |
150 CPDFSDK_PageView* pPage) override; | 150 CPDFSDK_PageView* pPage) override; |
151 #endif | 151 #endif // PDF_ENABLE_XFA |
152 void ReleaseAnnot(CPDFSDK_Annot* pAnnot) override; | 152 void ReleaseAnnot(CPDFSDK_Annot* pAnnot) override; |
153 void DeleteAnnot(CPDFSDK_Annot* pAnnot) override {} | 153 void DeleteAnnot(CPDFSDK_Annot* pAnnot) override {} |
154 CPDF_Rect GetViewBBox(CPDFSDK_PageView* pPageView, | 154 CPDF_Rect GetViewBBox(CPDFSDK_PageView* pPageView, |
155 CPDFSDK_Annot* pAnnot) override; | 155 CPDFSDK_Annot* pAnnot) override; |
156 FX_BOOL HitTest(CPDFSDK_PageView* pPageView, | 156 FX_BOOL HitTest(CPDFSDK_PageView* pPageView, |
157 CPDFSDK_Annot* pAnnot, | 157 CPDFSDK_Annot* pAnnot, |
158 const CPDF_Point& point) override; | 158 const CPDF_Point& point) override; |
159 void OnDraw(CPDFSDK_PageView* pPageView, | 159 void OnDraw(CPDFSDK_PageView* pPageView, |
160 CPDFSDK_Annot* pAnnot, | 160 CPDFSDK_Annot* pAnnot, |
161 CFX_RenderDevice* pDevice, | 161 CFX_RenderDevice* pDevice, |
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
219 FX_BOOL OnKeyUp(CPDFSDK_Annot* pAnnot, int nKeyCode, int nFlag) override; | 219 FX_BOOL OnKeyUp(CPDFSDK_Annot* pAnnot, int nKeyCode, int nFlag) override; |
220 void OnDeSelected(CPDFSDK_Annot* pAnnot) override {} | 220 void OnDeSelected(CPDFSDK_Annot* pAnnot) override {} |
221 void OnSelected(CPDFSDK_Annot* pAnnot) override {} | 221 void OnSelected(CPDFSDK_Annot* pAnnot) override {} |
222 FX_BOOL OnSetFocus(CPDFSDK_Annot* pAnnot, FX_DWORD nFlag) override; | 222 FX_BOOL OnSetFocus(CPDFSDK_Annot* pAnnot, FX_DWORD nFlag) override; |
223 FX_BOOL OnKillFocus(CPDFSDK_Annot* pAnnot, FX_DWORD nFlag) override; | 223 FX_BOOL OnKillFocus(CPDFSDK_Annot* pAnnot, FX_DWORD nFlag) override; |
224 #ifdef PDF_ENABLE_XFA | 224 #ifdef PDF_ENABLE_XFA |
225 FX_BOOL OnXFAChangedFocus(CPDFSDK_Annot* pOldAnnot, | 225 FX_BOOL OnXFAChangedFocus(CPDFSDK_Annot* pOldAnnot, |
226 CPDFSDK_Annot* pNewAnnot) override { | 226 CPDFSDK_Annot* pNewAnnot) override { |
227 return TRUE; | 227 return TRUE; |
228 } | 228 } |
229 #endif | 229 #endif // PDF_ENABLE_XFA |
230 | 230 |
231 void SetFormFiller(CFFL_IFormFiller* pFiller) { m_pFormFiller = pFiller; } | 231 void SetFormFiller(CFFL_IFormFiller* pFiller) { m_pFormFiller = pFiller; } |
232 CFFL_IFormFiller* GetFormFiller() { return m_pFormFiller; } | 232 CFFL_IFormFiller* GetFormFiller() { return m_pFormFiller; } |
233 | 233 |
234 private: | 234 private: |
235 CPDFDoc_Environment* m_pApp; | 235 CPDFDoc_Environment* m_pApp; |
236 CFFL_IFormFiller* m_pFormFiller; | 236 CFFL_IFormFiller* m_pFormFiller; |
237 }; | 237 }; |
238 | 238 |
239 #ifdef PDF_ENABLE_XFA | 239 #ifdef PDF_ENABLE_XFA |
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
342 virtual FX_BOOL OnXFAChangedFocus(CPDFSDK_Annot* pOldAnnot, | 342 virtual FX_BOOL OnXFAChangedFocus(CPDFSDK_Annot* pOldAnnot, |
343 CPDFSDK_Annot* pNewAnnot); | 343 CPDFSDK_Annot* pNewAnnot); |
344 | 344 |
345 private: | 345 private: |
346 IXFA_WidgetHandler* GetXFAWidgetHandler(CPDFSDK_Annot* pAnnot); | 346 IXFA_WidgetHandler* GetXFAWidgetHandler(CPDFSDK_Annot* pAnnot); |
347 FX_DWORD GetFWLFlags(FX_DWORD dwFlag); | 347 FX_DWORD GetFWLFlags(FX_DWORD dwFlag); |
348 | 348 |
349 private: | 349 private: |
350 CPDFDoc_Environment* m_pApp; | 350 CPDFDoc_Environment* m_pApp; |
351 }; | 351 }; |
| 352 #endif // PDF_ENABLE_XFA |
352 | 353 |
353 #endif | |
354 #define CBA_AnnotHandlerArray CFX_ArrayTemplate<IPDFSDK_AnnotHandler*> | 354 #define CBA_AnnotHandlerArray CFX_ArrayTemplate<IPDFSDK_AnnotHandler*> |
355 class CPDFSDK_AnnotHandlerMgr { | 355 class CPDFSDK_AnnotHandlerMgr { |
356 public: | 356 public: |
357 // Destroy the handler | 357 // Destroy the handler |
358 explicit CPDFSDK_AnnotHandlerMgr(CPDFDoc_Environment* pApp); | 358 explicit CPDFSDK_AnnotHandlerMgr(CPDFDoc_Environment* pApp); |
359 virtual ~CPDFSDK_AnnotHandlerMgr(); | 359 virtual ~CPDFSDK_AnnotHandlerMgr(); |
360 | 360 |
361 public: | 361 public: |
362 void RegisterAnnotHandler(IPDFSDK_AnnotHandler* pAnnotHandler); | 362 void RegisterAnnotHandler(IPDFSDK_AnnotHandler* pAnnotHandler); |
363 void UnRegisterAnnotHandler(IPDFSDK_AnnotHandler* pAnnotHandler); | 363 void UnRegisterAnnotHandler(IPDFSDK_AnnotHandler* pAnnotHandler); |
364 | 364 |
365 virtual CPDFSDK_Annot* NewAnnot(CPDF_Annot* pAnnot, | 365 virtual CPDFSDK_Annot* NewAnnot(CPDF_Annot* pAnnot, |
366 CPDFSDK_PageView* pPageView); | 366 CPDFSDK_PageView* pPageView); |
367 #ifdef PDF_ENABLE_XFA | 367 #ifdef PDF_ENABLE_XFA |
368 virtual CPDFSDK_Annot* NewAnnot(IXFA_Widget* pAnnot, | 368 virtual CPDFSDK_Annot* NewAnnot(IXFA_Widget* pAnnot, |
369 CPDFSDK_PageView* pPageView); | 369 CPDFSDK_PageView* pPageView); |
370 #endif | 370 #endif // PDF_ENABLE_XFA |
371 virtual void ReleaseAnnot(CPDFSDK_Annot* pAnnot); | 371 virtual void ReleaseAnnot(CPDFSDK_Annot* pAnnot); |
372 | 372 |
373 virtual void Annot_OnCreate(CPDFSDK_Annot* pAnnot); | 373 virtual void Annot_OnCreate(CPDFSDK_Annot* pAnnot); |
374 virtual void Annot_OnLoad(CPDFSDK_Annot* pAnnot); | 374 virtual void Annot_OnLoad(CPDFSDK_Annot* pAnnot); |
375 | 375 |
376 public: | 376 public: |
377 IPDFSDK_AnnotHandler* GetAnnotHandler(CPDFSDK_Annot* pAnnot) const; | 377 IPDFSDK_AnnotHandler* GetAnnotHandler(CPDFSDK_Annot* pAnnot) const; |
378 virtual void Annot_OnDraw(CPDFSDK_PageView* pPageView, | 378 virtual void Annot_OnDraw(CPDFSDK_PageView* pPageView, |
379 CPDFSDK_Annot* pAnnot, | 379 CPDFSDK_Annot* pAnnot, |
380 CFX_RenderDevice* pDevice, | 380 CFX_RenderDevice* pDevice, |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
422 virtual FX_BOOL Annot_OnChar(CPDFSDK_Annot* pAnnot, | 422 virtual FX_BOOL Annot_OnChar(CPDFSDK_Annot* pAnnot, |
423 FX_DWORD nChar, | 423 FX_DWORD nChar, |
424 FX_DWORD nFlags); | 424 FX_DWORD nFlags); |
425 virtual FX_BOOL Annot_OnKeyDown(CPDFSDK_Annot* pAnnot, | 425 virtual FX_BOOL Annot_OnKeyDown(CPDFSDK_Annot* pAnnot, |
426 int nKeyCode, | 426 int nKeyCode, |
427 int nFlag); | 427 int nFlag); |
428 virtual FX_BOOL Annot_OnKeyUp(CPDFSDK_Annot* pAnnot, int nKeyCode, int nFlag); | 428 virtual FX_BOOL Annot_OnKeyUp(CPDFSDK_Annot* pAnnot, int nKeyCode, int nFlag); |
429 | 429 |
430 virtual FX_BOOL Annot_OnSetFocus(CPDFSDK_Annot* pAnnot, FX_DWORD nFlag); | 430 virtual FX_BOOL Annot_OnSetFocus(CPDFSDK_Annot* pAnnot, FX_DWORD nFlag); |
431 virtual FX_BOOL Annot_OnKillFocus(CPDFSDK_Annot* pAnnot, FX_DWORD nFlag); | 431 virtual FX_BOOL Annot_OnKillFocus(CPDFSDK_Annot* pAnnot, FX_DWORD nFlag); |
| 432 |
432 #ifdef PDF_ENABLE_XFA | 433 #ifdef PDF_ENABLE_XFA |
433 virtual FX_BOOL Annot_OnChangeFocus(CPDFSDK_Annot* pSetAnnot, | 434 virtual FX_BOOL Annot_OnChangeFocus(CPDFSDK_Annot* pSetAnnot, |
434 CPDFSDK_Annot* pKillAnnot); | 435 CPDFSDK_Annot* pKillAnnot); |
435 #endif | 436 #endif // PDF_ENABLE_XFA |
436 | 437 |
437 virtual CPDF_Rect Annot_OnGetViewBBox(CPDFSDK_PageView* pPageView, | 438 virtual CPDF_Rect Annot_OnGetViewBBox(CPDFSDK_PageView* pPageView, |
438 CPDFSDK_Annot* pAnnot); | 439 CPDFSDK_Annot* pAnnot); |
439 virtual FX_BOOL Annot_OnHitTest(CPDFSDK_PageView* pPageView, | 440 virtual FX_BOOL Annot_OnHitTest(CPDFSDK_PageView* pPageView, |
440 CPDFSDK_Annot* pAnnot, | 441 CPDFSDK_Annot* pAnnot, |
441 const CPDF_Point& point); | 442 const CPDF_Point& point); |
442 | 443 |
443 private: | 444 private: |
444 IPDFSDK_AnnotHandler* GetAnnotHandler(const CFX_ByteString& sType) const; | 445 IPDFSDK_AnnotHandler* GetAnnotHandler(const CFX_ByteString& sType) const; |
445 CPDFSDK_Annot* GetNextAnnot(CPDFSDK_Annot* pSDKAnnot, FX_BOOL bNext); | 446 CPDFSDK_Annot* GetNextAnnot(CPDFSDK_Annot* pSDKAnnot, FX_BOOL bNext); |
(...skipping 14 matching lines...) Expand all Loading... |
460 private: | 461 private: |
461 CPDFSDK_Annot* NextAnnot(); | 462 CPDFSDK_Annot* NextAnnot(); |
462 CPDFSDK_Annot* PrevAnnot(); | 463 CPDFSDK_Annot* PrevAnnot(); |
463 | 464 |
464 std::vector<CPDFSDK_Annot*> m_iteratorAnnotList; | 465 std::vector<CPDFSDK_Annot*> m_iteratorAnnotList; |
465 const bool m_bReverse; | 466 const bool m_bReverse; |
466 size_t m_pos; | 467 size_t m_pos; |
467 }; | 468 }; |
468 | 469 |
469 #endif // FPDFSDK_INCLUDE_FSDK_ANNOTHANDLER_H_ | 470 #endif // FPDFSDK_INCLUDE_FSDK_ANNOTHANDLER_H_ |
OLD | NEW |