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 #define FSDK_XFAWIDGET_TYPENAME "XFAWidget" | 16 #define FSDK_XFAWIDGET_TYPENAME "XFAWidget" |
16 | 17 |
| 18 #endif |
17 class CFFL_IFormFiller; | 19 class CFFL_IFormFiller; |
18 class CFX_RenderDevice; | 20 class CFX_RenderDevice; |
19 class CPDFDoc_Environment; | 21 class CPDFDoc_Environment; |
20 class CPDFSDK_Annot; | 22 class CPDFSDK_Annot; |
21 class CPDFSDK_PageView; | 23 class CPDFSDK_PageView; |
22 class CPDF_Annot; | 24 class CPDF_Annot; |
23 class CPDF_Matrix; | 25 class CPDF_Matrix; |
24 class CPDF_Point; | 26 class CPDF_Point; |
25 class CPDF_Rect; | 27 class CPDF_Rect; |
26 | 28 |
27 class IPDFSDK_AnnotHandler { | 29 class IPDFSDK_AnnotHandler { |
28 public: | 30 public: |
29 virtual ~IPDFSDK_AnnotHandler() {} | 31 virtual ~IPDFSDK_AnnotHandler() {} |
30 | 32 |
31 virtual CFX_ByteString GetType() = 0; | 33 virtual CFX_ByteString GetType() = 0; |
32 | 34 |
33 virtual CFX_ByteString GetName() = 0; | 35 virtual CFX_ByteString GetName() = 0; |
34 | 36 |
35 virtual FX_BOOL CanAnswer(CPDFSDK_Annot* pAnnot) = 0; | 37 virtual FX_BOOL CanAnswer(CPDFSDK_Annot* pAnnot) = 0; |
36 | 38 |
37 virtual CPDFSDK_Annot* NewAnnot(CPDF_Annot* pAnnot, | 39 virtual CPDFSDK_Annot* NewAnnot(CPDF_Annot* pAnnot, |
38 CPDFSDK_PageView* pPage) = 0; | 40 CPDFSDK_PageView* pPage) = 0; |
39 | 41 |
| 42 #ifdef PDF_ENABLE_XFA |
40 virtual CPDFSDK_Annot* NewAnnot(IXFA_Widget* hWidget, | 43 virtual CPDFSDK_Annot* NewAnnot(IXFA_Widget* hWidget, |
41 CPDFSDK_PageView* pPage) = 0; | 44 CPDFSDK_PageView* pPage) = 0; |
42 | 45 |
| 46 #endif |
43 virtual void ReleaseAnnot(CPDFSDK_Annot* pAnnot) = 0; | 47 virtual void ReleaseAnnot(CPDFSDK_Annot* pAnnot) = 0; |
44 | 48 |
45 virtual void DeleteAnnot(CPDFSDK_Annot* pAnnot) = 0; | 49 virtual void DeleteAnnot(CPDFSDK_Annot* pAnnot) = 0; |
46 | 50 |
47 virtual CPDF_Rect GetViewBBox(CPDFSDK_PageView* pPageView, | 51 virtual CPDF_Rect GetViewBBox(CPDFSDK_PageView* pPageView, |
48 CPDFSDK_Annot* pAnnot) = 0; | 52 CPDFSDK_Annot* pAnnot) = 0; |
49 | 53 |
50 virtual FX_BOOL HitTest(CPDFSDK_PageView* pPageView, | 54 virtual FX_BOOL HitTest(CPDFSDK_PageView* pPageView, |
51 CPDFSDK_Annot* pAnnot, | 55 CPDFSDK_Annot* pAnnot, |
52 const CPDF_Point& point) = 0; | 56 const CPDF_Point& point) = 0; |
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
117 FX_DWORD nChar, | 121 FX_DWORD nChar, |
118 FX_DWORD nFlags) = 0; | 122 FX_DWORD nFlags) = 0; |
119 virtual FX_BOOL OnKeyDown(CPDFSDK_Annot* pAnnot, int nKeyCode, int nFlag) = 0; | 123 virtual FX_BOOL OnKeyDown(CPDFSDK_Annot* pAnnot, int nKeyCode, int nFlag) = 0; |
120 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; |
121 | 125 |
122 virtual void OnDeSelected(CPDFSDK_Annot* pAnnot) = 0; | 126 virtual void OnDeSelected(CPDFSDK_Annot* pAnnot) = 0; |
123 virtual void OnSelected(CPDFSDK_Annot* pAnnot) = 0; | 127 virtual void OnSelected(CPDFSDK_Annot* pAnnot) = 0; |
124 | 128 |
125 virtual FX_BOOL OnSetFocus(CPDFSDK_Annot* pAnnot, FX_DWORD nFlag) = 0; | 129 virtual FX_BOOL OnSetFocus(CPDFSDK_Annot* pAnnot, FX_DWORD nFlag) = 0; |
126 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 |
127 virtual FX_BOOL OnXFAChangedFocus(CPDFSDK_Annot* pOldAnnot, | 132 virtual FX_BOOL OnXFAChangedFocus(CPDFSDK_Annot* pOldAnnot, |
128 CPDFSDK_Annot* pNewAnnot) = 0; | 133 CPDFSDK_Annot* pNewAnnot) = 0; |
| 134 #endif |
129 }; | 135 }; |
130 | 136 |
131 class CPDFSDK_BFAnnotHandler : public IPDFSDK_AnnotHandler { | 137 class CPDFSDK_BFAnnotHandler : public IPDFSDK_AnnotHandler { |
132 public: | 138 public: |
133 explicit CPDFSDK_BFAnnotHandler(CPDFDoc_Environment* pApp) | 139 explicit CPDFSDK_BFAnnotHandler(CPDFDoc_Environment* pApp) |
134 : m_pApp(pApp), m_pFormFiller(NULL) {} | 140 : m_pApp(pApp), m_pFormFiller(NULL) {} |
135 ~CPDFSDK_BFAnnotHandler() override {} | 141 ~CPDFSDK_BFAnnotHandler() override {} |
136 | 142 |
137 // IPDFSDK_AnnotHandler | 143 // IPDFSDK_AnnotHandler |
138 CFX_ByteString GetType() override { return CFX_ByteString("Widget"); } | 144 CFX_ByteString GetType() override { return CFX_ByteString("Widget"); } |
139 CFX_ByteString GetName() override { return CFX_ByteString("WidgetHandler"); } | 145 CFX_ByteString GetName() override { return CFX_ByteString("WidgetHandler"); } |
140 FX_BOOL CanAnswer(CPDFSDK_Annot* pAnnot) override; | 146 FX_BOOL CanAnswer(CPDFSDK_Annot* pAnnot) override; |
141 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 |
142 CPDFSDK_Annot* NewAnnot(IXFA_Widget* hWidget, | 149 CPDFSDK_Annot* NewAnnot(IXFA_Widget* hWidget, |
143 CPDFSDK_PageView* pPage) override; | 150 CPDFSDK_PageView* pPage) override; |
| 151 #endif |
144 void ReleaseAnnot(CPDFSDK_Annot* pAnnot) override; | 152 void ReleaseAnnot(CPDFSDK_Annot* pAnnot) override; |
145 void DeleteAnnot(CPDFSDK_Annot* pAnnot) override {} | 153 void DeleteAnnot(CPDFSDK_Annot* pAnnot) override {} |
146 CPDF_Rect GetViewBBox(CPDFSDK_PageView* pPageView, | 154 CPDF_Rect GetViewBBox(CPDFSDK_PageView* pPageView, |
147 CPDFSDK_Annot* pAnnot) override; | 155 CPDFSDK_Annot* pAnnot) override; |
148 FX_BOOL HitTest(CPDFSDK_PageView* pPageView, | 156 FX_BOOL HitTest(CPDFSDK_PageView* pPageView, |
149 CPDFSDK_Annot* pAnnot, | 157 CPDFSDK_Annot* pAnnot, |
150 const CPDF_Point& point) override; | 158 const CPDF_Point& point) override; |
151 void OnDraw(CPDFSDK_PageView* pPageView, | 159 void OnDraw(CPDFSDK_PageView* pPageView, |
152 CPDFSDK_Annot* pAnnot, | 160 CPDFSDK_Annot* pAnnot, |
153 CFX_RenderDevice* pDevice, | 161 CFX_RenderDevice* pDevice, |
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
206 } | 214 } |
207 FX_BOOL OnChar(CPDFSDK_Annot* pAnnot, | 215 FX_BOOL OnChar(CPDFSDK_Annot* pAnnot, |
208 FX_DWORD nChar, | 216 FX_DWORD nChar, |
209 FX_DWORD nFlags) override; | 217 FX_DWORD nFlags) override; |
210 FX_BOOL OnKeyDown(CPDFSDK_Annot* pAnnot, int nKeyCode, int nFlag) override; | 218 FX_BOOL OnKeyDown(CPDFSDK_Annot* pAnnot, int nKeyCode, int nFlag) override; |
211 FX_BOOL OnKeyUp(CPDFSDK_Annot* pAnnot, int nKeyCode, int nFlag) override; | 219 FX_BOOL OnKeyUp(CPDFSDK_Annot* pAnnot, int nKeyCode, int nFlag) override; |
212 void OnDeSelected(CPDFSDK_Annot* pAnnot) override {} | 220 void OnDeSelected(CPDFSDK_Annot* pAnnot) override {} |
213 void OnSelected(CPDFSDK_Annot* pAnnot) override {} | 221 void OnSelected(CPDFSDK_Annot* pAnnot) override {} |
214 FX_BOOL OnSetFocus(CPDFSDK_Annot* pAnnot, FX_DWORD nFlag) override; | 222 FX_BOOL OnSetFocus(CPDFSDK_Annot* pAnnot, FX_DWORD nFlag) override; |
215 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 |
216 FX_BOOL OnXFAChangedFocus(CPDFSDK_Annot* pOldAnnot, | 225 FX_BOOL OnXFAChangedFocus(CPDFSDK_Annot* pOldAnnot, |
217 CPDFSDK_Annot* pNewAnnot) override { | 226 CPDFSDK_Annot* pNewAnnot) override { |
218 return TRUE; | 227 return TRUE; |
219 } | 228 } |
| 229 #endif |
220 | 230 |
221 void SetFormFiller(CFFL_IFormFiller* pFiller) { m_pFormFiller = pFiller; } | 231 void SetFormFiller(CFFL_IFormFiller* pFiller) { m_pFormFiller = pFiller; } |
222 CFFL_IFormFiller* GetFormFiller() { return m_pFormFiller; } | 232 CFFL_IFormFiller* GetFormFiller() { return m_pFormFiller; } |
223 | 233 |
224 private: | 234 private: |
225 CPDFDoc_Environment* m_pApp; | 235 CPDFDoc_Environment* m_pApp; |
226 CFFL_IFormFiller* m_pFormFiller; | 236 CFFL_IFormFiller* m_pFormFiller; |
227 }; | 237 }; |
228 | 238 |
| 239 #ifdef PDF_ENABLE_XFA |
229 class CPDFSDK_XFAAnnotHandler : public IPDFSDK_AnnotHandler { | 240 class CPDFSDK_XFAAnnotHandler : public IPDFSDK_AnnotHandler { |
230 public: | 241 public: |
231 explicit CPDFSDK_XFAAnnotHandler(CPDFDoc_Environment* pApp); | 242 explicit CPDFSDK_XFAAnnotHandler(CPDFDoc_Environment* pApp); |
232 ~CPDFSDK_XFAAnnotHandler() {} | 243 ~CPDFSDK_XFAAnnotHandler() {} |
233 | 244 |
234 public: | 245 public: |
235 virtual CFX_ByteString GetType() { return FSDK_XFAWIDGET_TYPENAME; } | 246 virtual CFX_ByteString GetType() { return FSDK_XFAWIDGET_TYPENAME; } |
236 | 247 |
237 virtual CFX_ByteString GetName() { return "XFAWidgetHandler"; } | 248 virtual CFX_ByteString GetName() { return "XFAWidgetHandler"; } |
238 | 249 |
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
332 CPDFSDK_Annot* pNewAnnot); | 343 CPDFSDK_Annot* pNewAnnot); |
333 | 344 |
334 private: | 345 private: |
335 IXFA_WidgetHandler* GetXFAWidgetHandler(CPDFSDK_Annot* pAnnot); | 346 IXFA_WidgetHandler* GetXFAWidgetHandler(CPDFSDK_Annot* pAnnot); |
336 FX_DWORD GetFWLFlags(FX_DWORD dwFlag); | 347 FX_DWORD GetFWLFlags(FX_DWORD dwFlag); |
337 | 348 |
338 private: | 349 private: |
339 CPDFDoc_Environment* m_pApp; | 350 CPDFDoc_Environment* m_pApp; |
340 }; | 351 }; |
341 | 352 |
| 353 #endif |
342 #define CBA_AnnotHandlerArray CFX_ArrayTemplate<IPDFSDK_AnnotHandler*> | 354 #define CBA_AnnotHandlerArray CFX_ArrayTemplate<IPDFSDK_AnnotHandler*> |
343 class CPDFSDK_AnnotHandlerMgr { | 355 class CPDFSDK_AnnotHandlerMgr { |
344 public: | 356 public: |
345 // Destroy the handler | 357 // Destroy the handler |
346 explicit CPDFSDK_AnnotHandlerMgr(CPDFDoc_Environment* pApp); | 358 explicit CPDFSDK_AnnotHandlerMgr(CPDFDoc_Environment* pApp); |
347 virtual ~CPDFSDK_AnnotHandlerMgr(); | 359 virtual ~CPDFSDK_AnnotHandlerMgr(); |
348 | 360 |
349 public: | 361 public: |
350 void RegisterAnnotHandler(IPDFSDK_AnnotHandler* pAnnotHandler); | 362 void RegisterAnnotHandler(IPDFSDK_AnnotHandler* pAnnotHandler); |
351 void UnRegisterAnnotHandler(IPDFSDK_AnnotHandler* pAnnotHandler); | 363 void UnRegisterAnnotHandler(IPDFSDK_AnnotHandler* pAnnotHandler); |
352 | 364 |
353 virtual CPDFSDK_Annot* NewAnnot(CPDF_Annot* pAnnot, | 365 virtual CPDFSDK_Annot* NewAnnot(CPDF_Annot* pAnnot, |
354 CPDFSDK_PageView* pPageView); | 366 CPDFSDK_PageView* pPageView); |
| 367 #ifdef PDF_ENABLE_XFA |
355 virtual CPDFSDK_Annot* NewAnnot(IXFA_Widget* pAnnot, | 368 virtual CPDFSDK_Annot* NewAnnot(IXFA_Widget* pAnnot, |
356 CPDFSDK_PageView* pPageView); | 369 CPDFSDK_PageView* pPageView); |
| 370 #endif |
357 virtual void ReleaseAnnot(CPDFSDK_Annot* pAnnot); | 371 virtual void ReleaseAnnot(CPDFSDK_Annot* pAnnot); |
358 | 372 |
359 virtual void Annot_OnCreate(CPDFSDK_Annot* pAnnot); | 373 virtual void Annot_OnCreate(CPDFSDK_Annot* pAnnot); |
360 virtual void Annot_OnLoad(CPDFSDK_Annot* pAnnot); | 374 virtual void Annot_OnLoad(CPDFSDK_Annot* pAnnot); |
361 | 375 |
362 public: | 376 public: |
363 IPDFSDK_AnnotHandler* GetAnnotHandler(CPDFSDK_Annot* pAnnot) const; | 377 IPDFSDK_AnnotHandler* GetAnnotHandler(CPDFSDK_Annot* pAnnot) const; |
364 virtual void Annot_OnDraw(CPDFSDK_PageView* pPageView, | 378 virtual void Annot_OnDraw(CPDFSDK_PageView* pPageView, |
365 CPDFSDK_Annot* pAnnot, | 379 CPDFSDK_Annot* pAnnot, |
366 CFX_RenderDevice* pDevice, | 380 CFX_RenderDevice* pDevice, |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
408 virtual FX_BOOL Annot_OnChar(CPDFSDK_Annot* pAnnot, | 422 virtual FX_BOOL Annot_OnChar(CPDFSDK_Annot* pAnnot, |
409 FX_DWORD nChar, | 423 FX_DWORD nChar, |
410 FX_DWORD nFlags); | 424 FX_DWORD nFlags); |
411 virtual FX_BOOL Annot_OnKeyDown(CPDFSDK_Annot* pAnnot, | 425 virtual FX_BOOL Annot_OnKeyDown(CPDFSDK_Annot* pAnnot, |
412 int nKeyCode, | 426 int nKeyCode, |
413 int nFlag); | 427 int nFlag); |
414 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); |
415 | 429 |
416 virtual FX_BOOL Annot_OnSetFocus(CPDFSDK_Annot* pAnnot, FX_DWORD nFlag); | 430 virtual FX_BOOL Annot_OnSetFocus(CPDFSDK_Annot* pAnnot, FX_DWORD nFlag); |
417 virtual FX_BOOL Annot_OnKillFocus(CPDFSDK_Annot* pAnnot, FX_DWORD nFlag); | 431 virtual FX_BOOL Annot_OnKillFocus(CPDFSDK_Annot* pAnnot, FX_DWORD nFlag); |
| 432 #ifdef PDF_ENABLE_XFA |
418 virtual FX_BOOL Annot_OnChangeFocus(CPDFSDK_Annot* pSetAnnot, | 433 virtual FX_BOOL Annot_OnChangeFocus(CPDFSDK_Annot* pSetAnnot, |
419 CPDFSDK_Annot* pKillAnnot); | 434 CPDFSDK_Annot* pKillAnnot); |
| 435 #endif |
420 | 436 |
421 virtual CPDF_Rect Annot_OnGetViewBBox(CPDFSDK_PageView* pPageView, | 437 virtual CPDF_Rect Annot_OnGetViewBBox(CPDFSDK_PageView* pPageView, |
422 CPDFSDK_Annot* pAnnot); | 438 CPDFSDK_Annot* pAnnot); |
423 virtual FX_BOOL Annot_OnHitTest(CPDFSDK_PageView* pPageView, | 439 virtual FX_BOOL Annot_OnHitTest(CPDFSDK_PageView* pPageView, |
424 CPDFSDK_Annot* pAnnot, | 440 CPDFSDK_Annot* pAnnot, |
425 const CPDF_Point& point); | 441 const CPDF_Point& point); |
426 | 442 |
427 private: | 443 private: |
428 IPDFSDK_AnnotHandler* GetAnnotHandler(const CFX_ByteString& sType) const; | 444 IPDFSDK_AnnotHandler* GetAnnotHandler(const CFX_ByteString& sType) const; |
429 CPDFSDK_Annot* GetNextAnnot(CPDFSDK_Annot* pSDKAnnot, FX_BOOL bNext); | 445 CPDFSDK_Annot* GetNextAnnot(CPDFSDK_Annot* pSDKAnnot, FX_BOOL bNext); |
(...skipping 14 matching lines...) Expand all Loading... |
444 private: | 460 private: |
445 CPDFSDK_Annot* NextAnnot(); | 461 CPDFSDK_Annot* NextAnnot(); |
446 CPDFSDK_Annot* PrevAnnot(); | 462 CPDFSDK_Annot* PrevAnnot(); |
447 | 463 |
448 std::vector<CPDFSDK_Annot*> m_iteratorAnnotList; | 464 std::vector<CPDFSDK_Annot*> m_iteratorAnnotList; |
449 const bool m_bReverse; | 465 const bool m_bReverse; |
450 size_t m_pos; | 466 size_t m_pos; |
451 }; | 467 }; |
452 | 468 |
453 #endif // FPDFSDK_INCLUDE_FSDK_ANNOTHANDLER_H_ | 469 #endif // FPDFSDK_INCLUDE_FSDK_ANNOTHANDLER_H_ |
OLD | NEW |