Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(54)

Side by Side Diff: fpdfsdk/include/fsdk_annothandler.h

Issue 1411203007: Cleanup parts of CPDFSDK_AnnotIterator and CPDFSDK_PageView. (Closed) Base URL: https://pdfium.googlesource.com/pdfium@master
Patch Set: fix bounds check Created 5 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | fpdfsdk/include/fsdk_mgr.h » ('j') | fpdfsdk/src/fsdk_annothandler.cpp » ('J')
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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
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 {
Tom Sepez 2015/10/21 19:32:58 Can we just kill this class entirely, and have a m
Lei Zhang 2015/10/22 06:56:22 The sorting is not trivial. I changed it to just N
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(size_t* index);
Tom Sepez 2015/10/21 19:32:58 Shouldn't an iterator maintain position on its own
Lei Zhang 2015/10/22 06:56:21 Mmmhmm.
318 virtual CPDFSDK_Annot* Prev(const CPDFSDK_Annot* pCurrent); 313 CPDFSDK_Annot* Prev(size_t* index);
319 virtual CPDFSDK_Annot* Next(int& index); 314 size_t Count() const { return m_iteratorAnnotList.size(); }
320 virtual CPDFSDK_Annot* Prev(int& index);
321 virtual int Count() { return m_pIteratorAnnotList.GetSize(); }
322
323 virtual FX_BOOL InitIteratorAnnotList(CPDFSDK_PageView* pPageView,
324 CFX_PtrArray* pList = NULL);
325
326 void InsertSort(CFX_PtrArray& arrayList, AI_COMPARE pCompare);
327 315
328 protected: 316 protected:
329 CPDFSDK_Annot* NextAnnot(const CPDFSDK_Annot* pCurrent); 317 CPDFSDK_Annot* NextAnnot(size_t* index);
330 CPDFSDK_Annot* PrevAnnot(const CPDFSDK_Annot* pCurrent); 318 CPDFSDK_Annot* PrevAnnot(size_t* index);
331 CPDFSDK_Annot* NextAnnot(int& index); 319 void InsertSort();
332 CPDFSDK_Annot* PrevAnnot(int& index);
333 320
334 CFX_PtrArray m_pIteratorAnnotList; 321 std::vector<CPDFSDK_Annot*> m_iteratorAnnotList;
335 FX_BOOL m_bReverse; 322 const bool m_bReverse;
336 FX_BOOL m_bIgnoreTopmost;
337 FX_BOOL m_bCircle;
338 }; 323 };
339 324
340 #endif // FPDFSDK_INCLUDE_FSDK_ANNOTHANDLER_H_ 325 #endif // FPDFSDK_INCLUDE_FSDK_ANNOTHANDLER_H_
OLDNEW
« no previous file with comments | « no previous file | fpdfsdk/include/fsdk_mgr.h » ('j') | fpdfsdk/src/fsdk_annothandler.cpp » ('J')

Powered by Google App Engine
This is Rietveld 408576698