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 | 12 |
12 #include "../../core/include/fxcrt/fx_basic.h" | 13 #include "../../core/include/fxcrt/fx_basic.h" |
13 | 14 |
14 class CFFL_IFormFiller; | 15 class CFFL_IFormFiller; |
15 class CFX_RenderDevice; | 16 class CFX_RenderDevice; |
16 class CPDFDoc_Environment; | 17 class CPDFDoc_Environment; |
17 class CPDFSDK_Annot; | 18 class CPDFSDK_Annot; |
18 class CPDFSDK_PageView; | 19 class CPDFSDK_PageView; |
19 class CPDF_Annot; | 20 class CPDF_Annot; |
20 class CPDF_Matrix; | 21 class CPDF_Matrix; |
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
115 | 116 |
116 virtual void OnDeSelected(CPDFSDK_Annot* pAnnot) = 0; | 117 virtual void OnDeSelected(CPDFSDK_Annot* pAnnot) = 0; |
117 virtual void OnSelected(CPDFSDK_Annot* pAnnot) = 0; | 118 virtual void OnSelected(CPDFSDK_Annot* pAnnot) = 0; |
118 | 119 |
119 virtual FX_BOOL OnSetFocus(CPDFSDK_Annot* pAnnot, FX_DWORD nFlag) = 0; | 120 virtual FX_BOOL OnSetFocus(CPDFSDK_Annot* pAnnot, FX_DWORD nFlag) = 0; |
120 virtual FX_BOOL OnKillFocus(CPDFSDK_Annot* pAnnot, FX_DWORD nFlag) = 0; | 121 virtual FX_BOOL OnKillFocus(CPDFSDK_Annot* pAnnot, FX_DWORD nFlag) = 0; |
121 }; | 122 }; |
122 | 123 |
123 class CPDFSDK_BFAnnotHandler : public IPDFSDK_AnnotHandler { | 124 class CPDFSDK_BFAnnotHandler : public IPDFSDK_AnnotHandler { |
124 public: | 125 public: |
125 CPDFSDK_BFAnnotHandler(CPDFDoc_Environment* pApp) | 126 explicit CPDFSDK_BFAnnotHandler(CPDFDoc_Environment* pApp) |
126 : m_pApp(pApp), m_pFormFiller(NULL) {} | 127 : m_pApp(pApp), m_pFormFiller(NULL) {} |
127 ~CPDFSDK_BFAnnotHandler() override {} | 128 ~CPDFSDK_BFAnnotHandler() override {} |
128 | 129 |
129 // IPDFSDK_AnnotHandler | 130 // IPDFSDK_AnnotHandler |
130 CFX_ByteString GetType() override { return CFX_ByteString("Widget"); } | 131 CFX_ByteString GetType() override { return CFX_ByteString("Widget"); } |
131 CFX_ByteString GetName() override { return CFX_ByteString("WidgetHandler"); } | 132 CFX_ByteString GetName() override { return CFX_ByteString("WidgetHandler"); } |
132 FX_BOOL CanAnswer(CPDFSDK_Annot* pAnnot) override; | 133 FX_BOOL CanAnswer(CPDFSDK_Annot* pAnnot) override; |
133 CPDFSDK_Annot* NewAnnot(CPDF_Annot* pAnnot, CPDFSDK_PageView* pPage) override; | 134 CPDFSDK_Annot* NewAnnot(CPDF_Annot* pAnnot, CPDFSDK_PageView* pPage) override; |
134 void ReleaseAnnot(CPDFSDK_Annot* pAnnot) override; | 135 void ReleaseAnnot(CPDFSDK_Annot* pAnnot) override; |
135 void DeleteAnnot(CPDFSDK_Annot* pAnnot) override {} | 136 void DeleteAnnot(CPDFSDK_Annot* pAnnot) override {} |
(...skipping 160 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
296 private: | 297 private: |
297 IPDFSDK_AnnotHandler* GetAnnotHandler(const CFX_ByteString& sType) const; | 298 IPDFSDK_AnnotHandler* GetAnnotHandler(const CFX_ByteString& sType) const; |
298 CPDFSDK_Annot* GetNextAnnot(CPDFSDK_Annot* pSDKAnnot, FX_BOOL bNext); | 299 CPDFSDK_Annot* GetNextAnnot(CPDFSDK_Annot* pSDKAnnot, FX_BOOL bNext); |
299 | 300 |
300 private: | 301 private: |
301 CBA_AnnotHandlerArray m_Handlers; | 302 CBA_AnnotHandlerArray m_Handlers; |
302 std::map<CFX_ByteString, IPDFSDK_AnnotHandler*> m_mapType2Handler; | 303 std::map<CFX_ByteString, IPDFSDK_AnnotHandler*> m_mapType2Handler; |
303 CPDFDoc_Environment* m_pApp; | 304 CPDFDoc_Environment* m_pApp; |
304 }; | 305 }; |
305 | 306 |
306 typedef int (*AI_COMPARE)(CPDFSDK_Annot* p1, CPDFSDK_Annot* p2); | |
307 | |
308 class CPDFSDK_AnnotIterator { | 307 class CPDFSDK_AnnotIterator { |
309 public: | 308 public: |
310 CPDFSDK_AnnotIterator(CPDFSDK_PageView* pPageView, | 309 CPDFSDK_AnnotIterator(CPDFSDK_PageView* pPageView, bool bReverse); |
311 FX_BOOL bReverse, | 310 ~CPDFSDK_AnnotIterator(); |
312 FX_BOOL bIgnoreTopmost = FALSE, | |
313 FX_BOOL bCircle = FALSE, | |
314 CFX_PtrArray* pList = NULL); | |
315 virtual ~CPDFSDK_AnnotIterator() {} | |
316 | 311 |
317 virtual CPDFSDK_Annot* Next(const CPDFSDK_Annot* pCurrent); | 312 CPDFSDK_Annot* Next(); |
318 virtual CPDFSDK_Annot* Prev(const CPDFSDK_Annot* pCurrent); | |
319 virtual CPDFSDK_Annot* Next(int& index); | |
320 virtual CPDFSDK_Annot* Prev(int& index); | |
321 virtual int Count() { return m_pIteratorAnnotList.GetSize(); } | |
322 | 313 |
323 virtual FX_BOOL InitIteratorAnnotList(CPDFSDK_PageView* pPageView, | 314 private: |
324 CFX_PtrArray* pList = NULL); | 315 CPDFSDK_Annot* NextAnnot(); |
| 316 CPDFSDK_Annot* PrevAnnot(); |
325 | 317 |
326 void InsertSort(CFX_PtrArray& arrayList, AI_COMPARE pCompare); | 318 std::vector<CPDFSDK_Annot*> m_iteratorAnnotList; |
327 | 319 const bool m_bReverse; |
328 protected: | 320 size_t m_pos; |
329 CPDFSDK_Annot* NextAnnot(const CPDFSDK_Annot* pCurrent); | |
330 CPDFSDK_Annot* PrevAnnot(const CPDFSDK_Annot* pCurrent); | |
331 CPDFSDK_Annot* NextAnnot(int& index); | |
332 CPDFSDK_Annot* PrevAnnot(int& index); | |
333 | |
334 CFX_PtrArray m_pIteratorAnnotList; | |
335 FX_BOOL m_bReverse; | |
336 FX_BOOL m_bIgnoreTopmost; | |
337 FX_BOOL m_bCircle; | |
338 }; | 321 }; |
339 | 322 |
340 #endif // FPDFSDK_INCLUDE_FSDK_ANNOTHANDLER_H_ | 323 #endif // FPDFSDK_INCLUDE_FSDK_ANNOTHANDLER_H_ |
OLD | NEW |