1 // Copyright 2014 PDFium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4 
5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
6 
7 #ifndef FPDFSDK_INCLUDE_FSDK_ANNOTHANDLER_H_
8 #define FPDFSDK_INCLUDE_FSDK_ANNOTHANDLER_H_
9 
10 #include <map>
11 #include <vector>
12 
13 #include "core/include/fxcrt/fx_basic.h"
14 
15 #ifdef PDF_ENABLE_XFA
16 #define FSDK_XFAWIDGET_TYPENAME "XFAWidget"
17 #endif  // PDF_ENABLE_XFA
18 
19 class CFFL_IFormFiller;
20 class CFX_RenderDevice;
21 class CPDFDoc_Environment;
22 class CPDFSDK_Annot;
23 class CPDFSDK_PageView;
24 class CPDF_Annot;
25 class CFX_Matrix;
26 class CPDF_Point;
27 
28 class IPDFSDK_AnnotHandler {
29  public:
~IPDFSDK_AnnotHandler()30   virtual ~IPDFSDK_AnnotHandler() {}
31 
32   virtual CFX_ByteString GetType() = 0;
33 
34   virtual CFX_ByteString GetName() = 0;
35 
36   virtual FX_BOOL CanAnswer(CPDFSDK_Annot* pAnnot) = 0;
37 
38   virtual CPDFSDK_Annot* NewAnnot(CPDF_Annot* pAnnot,
39                                   CPDFSDK_PageView* pPage) = 0;
40 
41 #ifdef PDF_ENABLE_XFA
42   virtual CPDFSDK_Annot* NewAnnot(IXFA_Widget* hWidget,
43                                   CPDFSDK_PageView* pPage) = 0;
44 #endif  // PDF_ENABLE_XFA
45 
46   virtual void ReleaseAnnot(CPDFSDK_Annot* pAnnot) = 0;
47 
48   virtual void DeleteAnnot(CPDFSDK_Annot* pAnnot) = 0;
49 
50   virtual CPDF_Rect GetViewBBox(CPDFSDK_PageView* pPageView,
51                                 CPDFSDK_Annot* pAnnot) = 0;
52 
53   virtual FX_BOOL HitTest(CPDFSDK_PageView* pPageView,
54                           CPDFSDK_Annot* pAnnot,
55                           const CPDF_Point& point) = 0;
56 
57   virtual void OnDraw(CPDFSDK_PageView* pPageView,
58                       CPDFSDK_Annot* pAnnot,
59                       CFX_RenderDevice* pDevice,
60                       CFX_Matrix* pUser2Device,
61                       FX_DWORD dwFlags) = 0;
62 
63   virtual void OnDrawSleep(CPDFSDK_PageView* pPageView,
64                            CPDFSDK_Annot* pAnnot,
65                            CFX_RenderDevice* pDevice,
66                            CFX_Matrix* pUser2Device,
67                            const CPDF_Rect& rcWindow,
68                            FX_DWORD dwFlags) = 0;
69 
70   virtual void OnCreate(CPDFSDK_Annot* pAnnot) = 0;
71 
72   virtual void OnLoad(CPDFSDK_Annot* pAnnot) = 0;
73 
74   virtual void OnDelete(CPDFSDK_Annot* pAnnot) = 0;
75 
76   virtual void OnRelease(CPDFSDK_Annot* pAnnot) = 0;
77 
78   virtual void OnMouseEnter(CPDFSDK_PageView* pPageView,
79                             CPDFSDK_Annot* pAnnot,
80                             FX_DWORD nFlag) = 0;
81   virtual void OnMouseExit(CPDFSDK_PageView* pPageView,
82                            CPDFSDK_Annot* pAnnot,
83                            FX_DWORD nFlag) = 0;
84 
85   virtual FX_BOOL OnLButtonDown(CPDFSDK_PageView* pPageView,
86                                 CPDFSDK_Annot* pAnnot,
87                                 FX_DWORD nFlags,
88                                 const CPDF_Point& point) = 0;
89   virtual FX_BOOL OnLButtonUp(CPDFSDK_PageView* pPageView,
90                               CPDFSDK_Annot* pAnnot,
91                               FX_DWORD nFlags,
92                               const CPDF_Point& point) = 0;
93   virtual FX_BOOL OnLButtonDblClk(CPDFSDK_PageView* pPageView,
94                                   CPDFSDK_Annot* pAnnot,
95                                   FX_DWORD nFlags,
96                                   const CPDF_Point& point) = 0;
97   virtual FX_BOOL OnMouseMove(CPDFSDK_PageView* pPageView,
98                               CPDFSDK_Annot* pAnnot,
99                               FX_DWORD nFlags,
100                               const CPDF_Point& point) = 0;
101   virtual FX_BOOL OnMouseWheel(CPDFSDK_PageView* pPageView,
102                                CPDFSDK_Annot* pAnnot,
103                                FX_DWORD nFlags,
104                                short zDelta,
105                                const CPDF_Point& point) = 0;
106   virtual FX_BOOL OnRButtonDown(CPDFSDK_PageView* pPageView,
107                                 CPDFSDK_Annot* pAnnot,
108                                 FX_DWORD nFlags,
109                                 const CPDF_Point& point) = 0;
110   virtual FX_BOOL OnRButtonUp(CPDFSDK_PageView* pPageView,
111                               CPDFSDK_Annot* pAnnot,
112                               FX_DWORD nFlags,
113                               const CPDF_Point& point) = 0;
114   virtual FX_BOOL OnRButtonDblClk(CPDFSDK_PageView* pPageView,
115                                   CPDFSDK_Annot* pAnnot,
116                                   FX_DWORD nFlags,
117                                   const CPDF_Point& point) = 0;
118   // by wjm.
119   virtual FX_BOOL OnChar(CPDFSDK_Annot* pAnnot,
120                          FX_DWORD nChar,
121                          FX_DWORD nFlags) = 0;
122   virtual FX_BOOL OnKeyDown(CPDFSDK_Annot* pAnnot, int nKeyCode, int nFlag) = 0;
123   virtual FX_BOOL OnKeyUp(CPDFSDK_Annot* pAnnot, int nKeyCode, int nFlag) = 0;
124 
125   virtual void OnDeSelected(CPDFSDK_Annot* pAnnot) = 0;
126   virtual void OnSelected(CPDFSDK_Annot* pAnnot) = 0;
127 
128   virtual FX_BOOL OnSetFocus(CPDFSDK_Annot* pAnnot, FX_DWORD nFlag) = 0;
129   virtual FX_BOOL OnKillFocus(CPDFSDK_Annot* pAnnot, FX_DWORD nFlag) = 0;
130 #ifdef PDF_ENABLE_XFA
131   virtual FX_BOOL OnXFAChangedFocus(CPDFSDK_Annot* pOldAnnot,
132                                     CPDFSDK_Annot* pNewAnnot) = 0;
133 #endif  // PDF_ENABLE_XFA
134 };
135 
136 class CPDFSDK_BFAnnotHandler : public IPDFSDK_AnnotHandler {
137  public:
CPDFSDK_BFAnnotHandler(CPDFDoc_Environment * pApp)138   explicit CPDFSDK_BFAnnotHandler(CPDFDoc_Environment* pApp)
139       : m_pApp(pApp), m_pFormFiller(NULL) {}
~CPDFSDK_BFAnnotHandler()140   ~CPDFSDK_BFAnnotHandler() override {}
141 
142   // IPDFSDK_AnnotHandler
GetType()143   CFX_ByteString GetType() override { return CFX_ByteString("Widget"); }
GetName()144   CFX_ByteString GetName() override { return CFX_ByteString("WidgetHandler"); }
145   FX_BOOL CanAnswer(CPDFSDK_Annot* pAnnot) override;
146   CPDFSDK_Annot* NewAnnot(CPDF_Annot* pAnnot, CPDFSDK_PageView* pPage) override;
147 #ifdef PDF_ENABLE_XFA
148   CPDFSDK_Annot* NewAnnot(IXFA_Widget* hWidget,
149                           CPDFSDK_PageView* pPage) override;
150 #endif  // PDF_ENABLE_XFA
151   void ReleaseAnnot(CPDFSDK_Annot* pAnnot) override;
DeleteAnnot(CPDFSDK_Annot * pAnnot)152   void DeleteAnnot(CPDFSDK_Annot* pAnnot) override {}
153   CPDF_Rect GetViewBBox(CPDFSDK_PageView* pPageView,
154                         CPDFSDK_Annot* pAnnot) override;
155   FX_BOOL HitTest(CPDFSDK_PageView* pPageView,
156                   CPDFSDK_Annot* pAnnot,
157                   const CPDF_Point& point) override;
158   void OnDraw(CPDFSDK_PageView* pPageView,
159               CPDFSDK_Annot* pAnnot,
160               CFX_RenderDevice* pDevice,
161               CFX_Matrix* pUser2Device,
162               FX_DWORD dwFlags) override;
OnDrawSleep(CPDFSDK_PageView * pPageView,CPDFSDK_Annot * pAnnot,CFX_RenderDevice * pDevice,CFX_Matrix * pUser2Device,const CPDF_Rect & rcWindow,FX_DWORD dwFlags)163   void OnDrawSleep(CPDFSDK_PageView* pPageView,
164                    CPDFSDK_Annot* pAnnot,
165                    CFX_RenderDevice* pDevice,
166                    CFX_Matrix* pUser2Device,
167                    const CPDF_Rect& rcWindow,
168                    FX_DWORD dwFlags) override {}
169   void OnCreate(CPDFSDK_Annot* pAnnot) override;
170   void OnLoad(CPDFSDK_Annot* pAnnot) override;
OnDelete(CPDFSDK_Annot * pAnnot)171   void OnDelete(CPDFSDK_Annot* pAnnot) override {}
OnRelease(CPDFSDK_Annot * pAnnot)172   void OnRelease(CPDFSDK_Annot* pAnnot) override {}
173   void OnMouseEnter(CPDFSDK_PageView* pPageView,
174                     CPDFSDK_Annot* pAnnot,
175                     FX_DWORD nFlag) override;
176   void OnMouseExit(CPDFSDK_PageView* pPageView,
177                    CPDFSDK_Annot* pAnnot,
178                    FX_DWORD nFlag) override;
179   FX_BOOL OnLButtonDown(CPDFSDK_PageView* pPageView,
180                         CPDFSDK_Annot* pAnnot,
181                         FX_DWORD nFlags,
182                         const CPDF_Point& point) override;
183   FX_BOOL OnLButtonUp(CPDFSDK_PageView* pPageView,
184                       CPDFSDK_Annot* pAnnot,
185                       FX_DWORD nFlags,
186                       const CPDF_Point& point) override;
187   FX_BOOL OnLButtonDblClk(CPDFSDK_PageView* pPageView,
188                           CPDFSDK_Annot* pAnnot,
189                           FX_DWORD nFlags,
190                           const CPDF_Point& point) override;
191   FX_BOOL OnMouseMove(CPDFSDK_PageView* pPageView,
192                       CPDFSDK_Annot* pAnnot,
193                       FX_DWORD nFlags,
194                       const CPDF_Point& point) override;
195   FX_BOOL OnMouseWheel(CPDFSDK_PageView* pPageView,
196                        CPDFSDK_Annot* pAnnot,
197                        FX_DWORD nFlags,
198                        short zDelta,
199                        const CPDF_Point& point) override;
200   FX_BOOL OnRButtonDown(CPDFSDK_PageView* pPageView,
201                         CPDFSDK_Annot* pAnnot,
202                         FX_DWORD nFlags,
203                         const CPDF_Point& point) override;
204   FX_BOOL OnRButtonUp(CPDFSDK_PageView* pPageView,
205                       CPDFSDK_Annot* pAnnot,
206                       FX_DWORD nFlags,
207                       const CPDF_Point& point) override;
OnRButtonDblClk(CPDFSDK_PageView * pPageView,CPDFSDK_Annot * pAnnot,FX_DWORD nFlags,const CPDF_Point & point)208   FX_BOOL OnRButtonDblClk(CPDFSDK_PageView* pPageView,
209                           CPDFSDK_Annot* pAnnot,
210                           FX_DWORD nFlags,
211                           const CPDF_Point& point) override {
212     return FALSE;
213   }
214   FX_BOOL OnChar(CPDFSDK_Annot* pAnnot,
215                  FX_DWORD nChar,
216                  FX_DWORD nFlags) override;
217   FX_BOOL OnKeyDown(CPDFSDK_Annot* pAnnot, int nKeyCode, int nFlag) override;
218   FX_BOOL OnKeyUp(CPDFSDK_Annot* pAnnot, int nKeyCode, int nFlag) override;
OnDeSelected(CPDFSDK_Annot * pAnnot)219   void OnDeSelected(CPDFSDK_Annot* pAnnot) override {}
OnSelected(CPDFSDK_Annot * pAnnot)220   void OnSelected(CPDFSDK_Annot* pAnnot) override {}
221   FX_BOOL OnSetFocus(CPDFSDK_Annot* pAnnot, FX_DWORD nFlag) override;
222   FX_BOOL OnKillFocus(CPDFSDK_Annot* pAnnot, FX_DWORD nFlag) override;
223 #ifdef PDF_ENABLE_XFA
OnXFAChangedFocus(CPDFSDK_Annot * pOldAnnot,CPDFSDK_Annot * pNewAnnot)224   FX_BOOL OnXFAChangedFocus(CPDFSDK_Annot* pOldAnnot,
225                             CPDFSDK_Annot* pNewAnnot) override {
226     return TRUE;
227   }
228 #endif  // PDF_ENABLE_XFA
229 
SetFormFiller(CFFL_IFormFiller * pFiller)230   void SetFormFiller(CFFL_IFormFiller* pFiller) { m_pFormFiller = pFiller; }
GetFormFiller()231   CFFL_IFormFiller* GetFormFiller() { return m_pFormFiller; }
232 
233  private:
234   CPDFDoc_Environment* m_pApp;
235   CFFL_IFormFiller* m_pFormFiller;
236 };
237 
238 #ifdef PDF_ENABLE_XFA
239 class CPDFSDK_XFAAnnotHandler : public IPDFSDK_AnnotHandler {
240  public:
241   explicit CPDFSDK_XFAAnnotHandler(CPDFDoc_Environment* pApp);
~CPDFSDK_XFAAnnotHandler()242   ~CPDFSDK_XFAAnnotHandler() {}
243 
244  public:
GetType()245   virtual CFX_ByteString GetType() { return FSDK_XFAWIDGET_TYPENAME; }
246 
GetName()247   virtual CFX_ByteString GetName() { return "XFAWidgetHandler"; }
248 
249   virtual FX_BOOL CanAnswer(CPDFSDK_Annot* pAnnot);
250 
NewAnnot(CPDF_Annot * pAnnot,CPDFSDK_PageView * pPage)251   virtual CPDFSDK_Annot* NewAnnot(CPDF_Annot* pAnnot, CPDFSDK_PageView* pPage) {
252     return NULL;
253   }
254 
255   virtual CPDFSDK_Annot* NewAnnot(IXFA_Widget* pAnnot, CPDFSDK_PageView* pPage);
256 
257   virtual void ReleaseAnnot(CPDFSDK_Annot* pAnnot);
258 
DeleteAnnot(CPDFSDK_Annot * pAnnot)259   virtual void DeleteAnnot(CPDFSDK_Annot* pAnnot) {}
260 
261   virtual CPDF_Rect GetViewBBox(CPDFSDK_PageView* pPageView,
262                                 CPDFSDK_Annot* pAnnot);
263 
264   virtual FX_BOOL HitTest(CPDFSDK_PageView* pPageView,
265                           CPDFSDK_Annot* pAnnot,
266                           const CPDF_Point& point);
267 
268   virtual void OnDraw(CPDFSDK_PageView* pPageView,
269                       CPDFSDK_Annot* pAnnot,
270                       CFX_RenderDevice* pDevice,
271                       CFX_Matrix* pUser2Device,
272                       FX_DWORD dwFlags);
273 
OnDrawSleep(CPDFSDK_PageView * pPageView,CPDFSDK_Annot * pAnnot,CFX_RenderDevice * pDevice,CFX_Matrix * pUser2Device,const CPDF_Rect & rcWindow,FX_DWORD dwFlags)274   virtual void OnDrawSleep(CPDFSDK_PageView* pPageView,
275                            CPDFSDK_Annot* pAnnot,
276                            CFX_RenderDevice* pDevice,
277                            CFX_Matrix* pUser2Device,
278                            const CPDF_Rect& rcWindow,
279                            FX_DWORD dwFlags) {}
280 
OnCreate(CPDFSDK_Annot * pAnnot)281   virtual void OnCreate(CPDFSDK_Annot* pAnnot) {}
282 
OnLoad(CPDFSDK_Annot * pAnnot)283   virtual void OnLoad(CPDFSDK_Annot* pAnnot) {}
284 
OnDelete(CPDFSDK_Annot * pAnnot)285   virtual void OnDelete(CPDFSDK_Annot* pAnnot) {}
286 
OnRelease(CPDFSDK_Annot * pAnnot)287   virtual void OnRelease(CPDFSDK_Annot* pAnnot) {}
288 
289   virtual void OnMouseEnter(CPDFSDK_PageView* pPageView,
290                             CPDFSDK_Annot* pAnnot,
291                             FX_DWORD nFlag);
292   virtual void OnMouseExit(CPDFSDK_PageView* pPageView,
293                            CPDFSDK_Annot* pAnnot,
294                            FX_DWORD nFlag);
295 
296   virtual FX_BOOL OnLButtonDown(CPDFSDK_PageView* pPageView,
297                                 CPDFSDK_Annot* pAnnot,
298                                 FX_DWORD nFlags,
299                                 const CPDF_Point& point);
300   virtual FX_BOOL OnLButtonUp(CPDFSDK_PageView* pPageView,
301                               CPDFSDK_Annot* pAnnot,
302                               FX_DWORD nFlags,
303                               const CPDF_Point& point);
304   virtual FX_BOOL OnLButtonDblClk(CPDFSDK_PageView* pPageView,
305                                   CPDFSDK_Annot* pAnnot,
306                                   FX_DWORD nFlags,
307                                   const CPDF_Point& point);
308   virtual FX_BOOL OnMouseMove(CPDFSDK_PageView* pPageView,
309                               CPDFSDK_Annot* pAnnot,
310                               FX_DWORD nFlags,
311                               const CPDF_Point& point);
312   virtual FX_BOOL OnMouseWheel(CPDFSDK_PageView* pPageView,
313                                CPDFSDK_Annot* pAnnot,
314                                FX_DWORD nFlags,
315                                short zDelta,
316                                const CPDF_Point& point);
317   virtual FX_BOOL OnRButtonDown(CPDFSDK_PageView* pPageView,
318                                 CPDFSDK_Annot* pAnnot,
319                                 FX_DWORD nFlags,
320                                 const CPDF_Point& point);
321   virtual FX_BOOL OnRButtonUp(CPDFSDK_PageView* pPageView,
322                               CPDFSDK_Annot* pAnnot,
323                               FX_DWORD nFlags,
324                               const CPDF_Point& point);
325   virtual FX_BOOL OnRButtonDblClk(CPDFSDK_PageView* pPageView,
326                                   CPDFSDK_Annot* pAnnot,
327                                   FX_DWORD nFlags,
328                                   const CPDF_Point& point);
329   // by wjm.
330   virtual FX_BOOL OnChar(CPDFSDK_Annot* pAnnot,
331                          FX_DWORD nChar,
332                          FX_DWORD nFlags);
333   virtual FX_BOOL OnKeyDown(CPDFSDK_Annot* pAnnot, int nKeyCode, int nFlag);
334   virtual FX_BOOL OnKeyUp(CPDFSDK_Annot* pAnnot, int nKeyCode, int nFlag);
335 
OnDeSelected(CPDFSDK_Annot * pAnnot)336   virtual void OnDeSelected(CPDFSDK_Annot* pAnnot) {}
OnSelected(CPDFSDK_Annot * pAnnot)337   virtual void OnSelected(CPDFSDK_Annot* pAnnot) {}
338 
339   virtual FX_BOOL OnSetFocus(CPDFSDK_Annot* pAnnot, FX_DWORD nFlag);
340   virtual FX_BOOL OnKillFocus(CPDFSDK_Annot* pAnnot, FX_DWORD nFlag);
341   virtual FX_BOOL OnXFAChangedFocus(CPDFSDK_Annot* pOldAnnot,
342                                     CPDFSDK_Annot* pNewAnnot);
343 
344  private:
345   IXFA_WidgetHandler* GetXFAWidgetHandler(CPDFSDK_Annot* pAnnot);
346   FX_DWORD GetFWLFlags(FX_DWORD dwFlag);
347 
348  private:
349   CPDFDoc_Environment* m_pApp;
350 };
351 #endif  // PDF_ENABLE_XFA
352 
353 #define CBA_AnnotHandlerArray CFX_ArrayTemplate<IPDFSDK_AnnotHandler*>
354 class CPDFSDK_AnnotHandlerMgr {
355  public:
356   // Destroy the handler
357   explicit CPDFSDK_AnnotHandlerMgr(CPDFDoc_Environment* pApp);
358   virtual ~CPDFSDK_AnnotHandlerMgr();
359 
360  public:
361   void RegisterAnnotHandler(IPDFSDK_AnnotHandler* pAnnotHandler);
362   void UnRegisterAnnotHandler(IPDFSDK_AnnotHandler* pAnnotHandler);
363 
364   virtual CPDFSDK_Annot* NewAnnot(CPDF_Annot* pAnnot,
365                                   CPDFSDK_PageView* pPageView);
366 #ifdef PDF_ENABLE_XFA
367   virtual CPDFSDK_Annot* NewAnnot(IXFA_Widget* pAnnot,
368                                   CPDFSDK_PageView* pPageView);
369 #endif  // PDF_ENABLE_XFA
370   virtual void ReleaseAnnot(CPDFSDK_Annot* pAnnot);
371 
372   virtual void Annot_OnCreate(CPDFSDK_Annot* pAnnot);
373   virtual void Annot_OnLoad(CPDFSDK_Annot* pAnnot);
374 
375  public:
376   IPDFSDK_AnnotHandler* GetAnnotHandler(CPDFSDK_Annot* pAnnot) const;
377   virtual void Annot_OnDraw(CPDFSDK_PageView* pPageView,
378                             CPDFSDK_Annot* pAnnot,
379                             CFX_RenderDevice* pDevice,
380                             CFX_Matrix* pUser2Device,
381                             FX_DWORD dwFlags);
382 
383   virtual void Annot_OnMouseEnter(CPDFSDK_PageView* pPageView,
384                                   CPDFSDK_Annot* pAnnot,
385                                   FX_DWORD nFlags);
386   virtual void Annot_OnMouseExit(CPDFSDK_PageView* pPageView,
387                                  CPDFSDK_Annot* pAnnot,
388                                  FX_DWORD nFlags);
389 
390   virtual FX_BOOL Annot_OnLButtonDown(CPDFSDK_PageView* pPageView,
391                                       CPDFSDK_Annot* pAnnot,
392                                       FX_DWORD nFlags,
393                                       const CPDF_Point& point);
394   virtual FX_BOOL Annot_OnLButtonUp(CPDFSDK_PageView* pPageView,
395                                     CPDFSDK_Annot* pAnnot,
396                                     FX_DWORD nFlags,
397                                     const CPDF_Point& point);
398   virtual FX_BOOL Annot_OnLButtonDblClk(CPDFSDK_PageView* pPageView,
399                                         CPDFSDK_Annot* pAnnot,
400                                         FX_DWORD nFlags,
401                                         const CPDF_Point& point);
402 
403   virtual FX_BOOL Annot_OnMouseMove(CPDFSDK_PageView* pPageView,
404                                     CPDFSDK_Annot* pAnnot,
405                                     FX_DWORD nFlags,
406                                     const CPDF_Point& point);
407   virtual FX_BOOL Annot_OnMouseWheel(CPDFSDK_PageView* pPageView,
408                                      CPDFSDK_Annot* pAnnot,
409                                      FX_DWORD nFlags,
410                                      short zDelta,
411                                      const CPDF_Point& point);
412   virtual FX_BOOL Annot_OnRButtonDown(CPDFSDK_PageView* pPageView,
413                                       CPDFSDK_Annot* pAnnot,
414                                       FX_DWORD nFlags,
415                                       const CPDF_Point& point);
416   virtual FX_BOOL Annot_OnRButtonUp(CPDFSDK_PageView* pPageView,
417                                     CPDFSDK_Annot* pAnnot,
418                                     FX_DWORD nFlags,
419                                     const CPDF_Point& point);
420 
421   virtual FX_BOOL Annot_OnChar(CPDFSDK_Annot* pAnnot,
422                                FX_DWORD nChar,
423                                FX_DWORD nFlags);
424   virtual FX_BOOL Annot_OnKeyDown(CPDFSDK_Annot* pAnnot,
425                                   int nKeyCode,
426                                   int nFlag);
427   virtual FX_BOOL Annot_OnKeyUp(CPDFSDK_Annot* pAnnot, int nKeyCode, int nFlag);
428 
429   virtual FX_BOOL Annot_OnSetFocus(CPDFSDK_Annot* pAnnot, FX_DWORD nFlag);
430   virtual FX_BOOL Annot_OnKillFocus(CPDFSDK_Annot* pAnnot, FX_DWORD nFlag);
431 
432 #ifdef PDF_ENABLE_XFA
433   virtual FX_BOOL Annot_OnChangeFocus(CPDFSDK_Annot* pSetAnnot,
434                                       CPDFSDK_Annot* pKillAnnot);
435 #endif  // PDF_ENABLE_XFA
436 
437   virtual CPDF_Rect Annot_OnGetViewBBox(CPDFSDK_PageView* pPageView,
438                                         CPDFSDK_Annot* pAnnot);
439   virtual FX_BOOL Annot_OnHitTest(CPDFSDK_PageView* pPageView,
440                                   CPDFSDK_Annot* pAnnot,
441                                   const CPDF_Point& point);
442 
443  private:
444   IPDFSDK_AnnotHandler* GetAnnotHandler(const CFX_ByteString& sType) const;
445   CPDFSDK_Annot* GetNextAnnot(CPDFSDK_Annot* pSDKAnnot, FX_BOOL bNext);
446 
447  private:
448   CBA_AnnotHandlerArray m_Handlers;
449   std::map<CFX_ByteString, IPDFSDK_AnnotHandler*> m_mapType2Handler;
450   CPDFDoc_Environment* m_pApp;
451 };
452 
453 class CPDFSDK_AnnotIterator {
454  public:
455   CPDFSDK_AnnotIterator(CPDFSDK_PageView* pPageView, bool bReverse);
456   ~CPDFSDK_AnnotIterator();
457 
458   CPDFSDK_Annot* Next();
459 
460  private:
461   CPDFSDK_Annot* NextAnnot();
462   CPDFSDK_Annot* PrevAnnot();
463 
464   std::vector<CPDFSDK_Annot*> m_iteratorAnnotList;
465   const bool m_bReverse;
466   size_t m_pos;
467 };
468 
469 #endif  // FPDFSDK_INCLUDE_FSDK_ANNOTHANDLER_H_
470