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

Side by Side Diff: fpdfsdk/src/fsdk_annothandler.cpp

Issue 453133004: clang-format all code (Closed) Base URL: https://pdfium.googlesource.com/pdfium.git@master
Patch Set: Created 6 years, 4 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
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 #include "../include/fsdk_define.h" 7 #include "../include/fsdk_define.h"
8 #include "../include/fsdk_mgr.h" 8 #include "../include/fsdk_mgr.h"
9 #include "../include/formfiller/FFL_FormFiller.h" 9 #include "../include/formfiller/FFL_FormFiller.h"
10 #include "../include/fsdk_annothandler.h" 10 #include "../include/fsdk_annothandler.h"
11 11
12 12 CPDFSDK_AnnotHandlerMgr::CPDFSDK_AnnotHandlerMgr(CPDFDoc_Environment* pApp) {
13 CPDFSDK_AnnotHandlerMgr::CPDFSDK_AnnotHandlerMgr(CPDFDoc_Environment* pApp) 13 m_pApp = pApp;
14 { 14
15 m_pApp = pApp; 15 CPDFSDK_BFAnnotHandler* pHandler = new CPDFSDK_BFAnnotHandler(m_pApp);
16 16 pHandler->SetFormFiller(m_pApp->GetIFormFiller());
17 CPDFSDK_BFAnnotHandler* pHandler = new CPDFSDK_BFAnnotHandler(m_pApp); 17 RegisterAnnotHandler(pHandler);
18 pHandler->SetFormFiller(m_pApp->GetIFormFiller()); 18 }
19 RegisterAnnotHandler(pHandler); 19
20 } 20 CPDFSDK_AnnotHandlerMgr::~CPDFSDK_AnnotHandlerMgr() {
21 21 for (int i = 0; i < m_Handlers.GetSize(); i++) {
22 CPDFSDK_AnnotHandlerMgr::~CPDFSDK_AnnotHandlerMgr() 22 IPDFSDK_AnnotHandler* pHandler = m_Handlers.GetAt(i);
23 { 23 delete pHandler;
24 for(int i=0; i<m_Handlers.GetSize(); i++) 24 }
25 { 25 m_Handlers.RemoveAll();
26 IPDFSDK_AnnotHandler* pHandler = m_Handlers.GetAt(i); 26 m_mapType2Handler.RemoveAll();
27 delete pHandler; 27 }
28 } 28
29 m_Handlers.RemoveAll(); 29 void CPDFSDK_AnnotHandlerMgr::RegisterAnnotHandler(
30 m_mapType2Handler.RemoveAll(); 30 IPDFSDK_AnnotHandler* pAnnotHandler) {
31 } 31 ASSERT(pAnnotHandler != NULL);
32 32
33 void CPDFSDK_AnnotHandlerMgr::RegisterAnnotHandler(IPDFSDK_AnnotHandler* pAnn otHandler) 33 ASSERT(GetAnnotHandler(pAnnotHandler->GetType()) == NULL);
34 { 34
35 ASSERT(pAnnotHandler != NULL); 35 m_Handlers.Add(pAnnotHandler);
36 36 m_mapType2Handler.SetAt(pAnnotHandler->GetType(), (void*)pAnnotHandler);
37 ASSERT(GetAnnotHandler(pAnnotHandler->GetType()) == NULL); 37 }
38 38
39 m_Handlers.Add(pAnnotHandler); 39 void CPDFSDK_AnnotHandlerMgr::UnRegisterAnnotHandler(
40 m_mapType2Handler.SetAt(pAnnotHandler->GetType(), (void*)pAnnotHandler); 40 IPDFSDK_AnnotHandler* pAnnotHandler) {
41 } 41 ASSERT(pAnnotHandler != NULL);
42 42
43 void CPDFSDK_AnnotHandlerMgr::UnRegisterAnnotHandler(IPDFSDK_AnnotHandler* pAnno tHandler) 43 m_mapType2Handler.RemoveKey(pAnnotHandler->GetType());
44 { 44
45 ASSERT(pAnnotHandler != NULL); 45 for (int i = 0, sz = m_Handlers.GetSize(); i < sz; i++) {
46 46 if (m_Handlers.GetAt(i) == pAnnotHandler) {
47 m_mapType2Handler.RemoveKey(pAnnotHandler->GetType()); 47 m_Handlers.RemoveAt(i);
48 48 break;
49 for (int i=0, sz=m_Handlers.GetSize(); i<sz; i++) 49 }
50 { 50 }
51 if (m_Handlers.GetAt(i) == pAnnotHandler) 51 }
52 { 52
53 m_Handlers.RemoveAt(i); 53 CPDFSDK_Annot* CPDFSDK_AnnotHandlerMgr::NewAnnot(CPDF_Annot* pAnnot,
54 break; 54 CPDFSDK_PageView* pPageView) {
55 } 55 ASSERT(pAnnot != NULL);
56 } 56 ASSERT(pPageView != NULL);
57 } 57
58 58 if (IPDFSDK_AnnotHandler* pAnnotHandler =
59 CPDFSDK_Annot* CPDFSDK_AnnotHandlerMgr::NewAnnot(CPDF_Annot * pAnnot, CPDFSDK_Pa geView *pPageView) 59 GetAnnotHandler(pAnnot->GetSubType())) {
60 { 60 return pAnnotHandler->NewAnnot(pAnnot, pPageView);
61 ASSERT(pAnnot != NULL); 61 }
62 ASSERT(pPageView != NULL); 62
63 63 return new CPDFSDK_Annot(pAnnot, pPageView);
64 if (IPDFSDK_AnnotHandler* pAnnotHandler = GetAnnotHandler(pAnnot->GetSub Type())) 64 }
65 { 65
66 return pAnnotHandler->NewAnnot(pAnnot, pPageView); 66 void CPDFSDK_AnnotHandlerMgr::ReleaseAnnot(CPDFSDK_Annot* pAnnot) {
67 } 67 ASSERT(pAnnot != NULL);
68 68
69 return new CPDFSDK_Annot(pAnnot, pPageView); 69 pAnnot->GetPDFPage();
70 } 70
71 71 if (IPDFSDK_AnnotHandler* pAnnotHandler = GetAnnotHandler(pAnnot)) {
72 void CPDFSDK_AnnotHandlerMgr::ReleaseAnnot(CPDFSDK_Annot* pAnnot) 72 pAnnotHandler->OnRelease(pAnnot);
73 { 73 pAnnotHandler->ReleaseAnnot(pAnnot);
74 ASSERT(pAnnot != NULL); 74 } else {
75 75 delete (CPDFSDK_Annot*)pAnnot;
76 pAnnot->GetPDFPage(); 76 }
77 77 }
78 if (IPDFSDK_AnnotHandler* pAnnotHandler = GetAnnotHandler(pAnnot)) 78
79 { 79 void CPDFSDK_AnnotHandlerMgr::Annot_OnCreate(CPDFSDK_Annot* pAnnot) {
80 pAnnotHandler->OnRelease(pAnnot); 80 ASSERT(pAnnot != NULL);
81 pAnnotHandler->ReleaseAnnot(pAnnot); 81
82 } 82 CPDF_Annot* pPDFAnnot = pAnnot->GetPDFAnnot();
83 else 83 ASSERT(pPDFAnnot != NULL);
84 { 84 ASSERT(pPDFAnnot->m_pAnnotDict != NULL);
85 delete (CPDFSDK_Annot*)pAnnot; 85
86 } 86 CPDFSDK_DateTime curTime;
87 } 87 pPDFAnnot->m_pAnnotDict->SetAtString("M", curTime.ToPDFDateTimeString());
88 88 pPDFAnnot->m_pAnnotDict->SetAtNumber("F", (int)0);
89 void CPDFSDK_AnnotHandlerMgr::Annot_OnCreate(CPDFSDK_Annot* pAnnot) 89
90 { 90 if (IPDFSDK_AnnotHandler* pAnnotHandler = GetAnnotHandler(pAnnot)) {
91 ASSERT(pAnnot != NULL); 91 pAnnotHandler->OnCreate(pAnnot);
92 92 }
93 CPDF_Annot* pPDFAnnot = pAnnot->GetPDFAnnot(); 93 }
94 ASSERT(pPDFAnnot != NULL); 94
95 ASSERT(pPDFAnnot->m_pAnnotDict != NULL); 95 void CPDFSDK_AnnotHandlerMgr::Annot_OnLoad(CPDFSDK_Annot* pAnnot) {
96 96 ASSERT(pAnnot != NULL);
97 CPDFSDK_DateTime curTime; 97
98 pPDFAnnot->m_pAnnotDict->SetAtString("M", curTime.ToPDFDateTimeString()) ; 98 if (IPDFSDK_AnnotHandler* pAnnotHandler = GetAnnotHandler(pAnnot)) {
99 pPDFAnnot->m_pAnnotDict->SetAtNumber("F", (int)0); 99 pAnnotHandler->OnLoad(pAnnot);
100 100 }
101 if (IPDFSDK_AnnotHandler* pAnnotHandler = GetAnnotHandler(pAnnot)) 101 }
102 { 102
103 pAnnotHandler->OnCreate(pAnnot); 103 IPDFSDK_AnnotHandler* CPDFSDK_AnnotHandlerMgr::GetAnnotHandler(
104 } 104 CPDFSDK_Annot* pAnnot) const {
105 } 105 ASSERT(pAnnot != NULL);
106 106
107 void CPDFSDK_AnnotHandlerMgr::Annot_OnLoad(CPDFSDK_Annot* pAnnot) 107 CPDF_Annot* pPDFAnnot = pAnnot->GetPDFAnnot();
108 { 108 ASSERT(pPDFAnnot != NULL);
109 ASSERT(pAnnot != NULL); 109
110 110 return GetAnnotHandler(pPDFAnnot->GetSubType());
111 if (IPDFSDK_AnnotHandler* pAnnotHandler = GetAnnotHandler(pAnnot)) 111 }
112 { 112
113 pAnnotHandler->OnLoad(pAnnot); 113 IPDFSDK_AnnotHandler* CPDFSDK_AnnotHandlerMgr::GetAnnotHandler(
114 } 114 const CFX_ByteString& sType) const {
115 } 115 void* pRet = NULL;
116 116 m_mapType2Handler.Lookup(sType, pRet);
117 IPDFSDK_AnnotHandler* CPDFSDK_AnnotHandlerMgr::GetAnnotHandler(CPDFSDK_Annot* pA nnot) const 117 return (IPDFSDK_AnnotHandler*)pRet;
118 { 118 }
119 ASSERT(pAnnot != NULL); 119
120 120 void CPDFSDK_AnnotHandlerMgr::Annot_OnDraw(CPDFSDK_PageView* pPageView,
121 CPDF_Annot* pPDFAnnot = pAnnot->GetPDFAnnot(); 121 CPDFSDK_Annot* pAnnot,
122 ASSERT(pPDFAnnot != NULL); 122 CFX_RenderDevice* pDevice,
123 123 CPDF_Matrix* pUser2Device,
124 return GetAnnotHandler(pPDFAnnot->GetSubType()); 124 FX_DWORD dwFlags) {
125 } 125 ASSERT(pAnnot != NULL);
126 126
127 IPDFSDK_AnnotHandler* CPDFSDK_AnnotHandlerMgr::GetAnnotHandler(const CFX_ByteStr ing& sType) const 127 if (IPDFSDK_AnnotHandler* pAnnotHandler = GetAnnotHandler(pAnnot)) {
128 { 128 pAnnotHandler->OnDraw(pPageView, pAnnot, pDevice, pUser2Device, dwFlags);
129 void* pRet = NULL; 129 } else {
130 m_mapType2Handler.Lookup(sType, pRet); 130 pAnnot->DrawAppearance(pDevice, pUser2Device, CPDF_Annot::Normal, NULL);
131 return (IPDFSDK_AnnotHandler*)pRet; 131 }
132 } 132 }
133 133
134 void CPDFSDK_AnnotHandlerMgr::Annot_OnDraw(CPDFSDK_PageView* pPageView, CPDFSDK_ Annot* pAnnot, CFX_RenderDevice* pDevice, CPDF_Matrix* pUser2Device,FX_DWORD dwF lags) 134 FX_BOOL CPDFSDK_AnnotHandlerMgr::Annot_OnLButtonDown(
135 { 135 CPDFSDK_PageView* pPageView,
136 ASSERT(pAnnot != NULL); 136 CPDFSDK_Annot* pAnnot,
137 137 FX_DWORD nFlags,
138 if (IPDFSDK_AnnotHandler* pAnnotHandler = GetAnnotHandler(pAnnot)) 138 const CPDF_Point& point) {
139 { 139 ASSERT(pAnnot != NULL);
140 pAnnotHandler->OnDraw(pPageView, pAnnot, pDevice, pUser2Device, dwFlags); 140
141 } 141 if (IPDFSDK_AnnotHandler* pAnnotHandler = GetAnnotHandler(pAnnot)) {
142 else 142 return pAnnotHandler->OnLButtonDown(pPageView, pAnnot, nFlags, point);
143 { 143 }
144 pAnnot->DrawAppearance(pDevice, pUser2Device, CPDF_Annot::Normal , NULL); 144 return FALSE;
145 } 145 }
146 } 146 FX_BOOL CPDFSDK_AnnotHandlerMgr::Annot_OnLButtonUp(CPDFSDK_PageView* pPageView,
147 147 CPDFSDK_Annot* pAnnot,
148 148 FX_DWORD nFlags,
149 FX_BOOL CPDFSDK_AnnotHandlerMgr::Annot_OnLButtonDown(CPDFSDK_PageView * pPageVie w, CPDFSDK_Annot* pAnnot, FX_DWORD nFlags, const CPDF_Point& point) 149 const CPDF_Point& point) {
150 { 150 ASSERT(pAnnot != NULL);
151 ASSERT(pAnnot != NULL); 151
152 152 if (IPDFSDK_AnnotHandler* pAnnotHandler = GetAnnotHandler(pAnnot)) {
153 if (IPDFSDK_AnnotHandler* pAnnotHandler = GetAnnotHandler(pAnnot)) 153 return pAnnotHandler->OnLButtonUp(pPageView, pAnnot, nFlags, point);
154 { 154 }
155 return pAnnotHandler->OnLButtonDown(pPageView, pAnnot, nFlags, p oint); 155 return FALSE;
156 } 156 }
157 return FALSE; 157 FX_BOOL CPDFSDK_AnnotHandlerMgr::Annot_OnLButtonDblClk(
158 } 158 CPDFSDK_PageView* pPageView,
159 FX_BOOL CPDFSDK_AnnotHandlerMgr::Annot_OnLButtonUp(CPDFSDK_PageView * pPageView, CPDFSDK_Annot* pAnnot, FX_DWORD nFlags, const CPDF_Point& point) 159 CPDFSDK_Annot* pAnnot,
160 { 160 FX_DWORD nFlags,
161 ASSERT(pAnnot != NULL); 161 const CPDF_Point& point) {
162 162 ASSERT(pAnnot != NULL);
163 if (IPDFSDK_AnnotHandler* pAnnotHandler = GetAnnotHandler(pAnnot)) 163
164 { 164 if (IPDFSDK_AnnotHandler* pAnnotHandler = GetAnnotHandler(pAnnot)) {
165 return pAnnotHandler->OnLButtonUp(pPageView, pAnnot, nFlags, poi nt); 165 return pAnnotHandler->OnLButtonDblClk(pPageView, pAnnot, nFlags, point);
166 } 166 }
167 return FALSE; 167 return FALSE;
168 } 168 }
169 FX_BOOL CPDFSDK_AnnotHandlerMgr::Annot_OnLButtonDblClk(CPDFSDK_PageView * pPageV iew, CPDFSDK_Annot* pAnnot, FX_DWORD nFlags, const CPDF_Point& point) 169 FX_BOOL CPDFSDK_AnnotHandlerMgr::Annot_OnMouseMove(CPDFSDK_PageView* pPageView,
170 { 170 CPDFSDK_Annot* pAnnot,
171 ASSERT(pAnnot != NULL); 171 FX_DWORD nFlags,
172 172 const CPDF_Point& point) {
173 if (IPDFSDK_AnnotHandler* pAnnotHandler = GetAnnotHandler(pAnnot)) 173 ASSERT(pAnnot != NULL);
174 { 174
175 return pAnnotHandler->OnLButtonDblClk(pPageView, pAnnot, nFlags, point); 175 if (IPDFSDK_AnnotHandler* pAnnotHandler = GetAnnotHandler(pAnnot)) {
176 } 176 return pAnnotHandler->OnMouseMove(pPageView, pAnnot, nFlags, point);
177 return FALSE; 177 }
178 } 178 return FALSE;
179 FX_BOOL CPDFSDK_AnnotHandlerMgr::Annot_OnMouseMove(CPDFSDK_PageView * pPageView, CPDFSDK_Annot* pAnnot, FX_DWORD nFlags, const CPDF_Point& point) 179 }
180 { 180 FX_BOOL CPDFSDK_AnnotHandlerMgr::Annot_OnMouseWheel(CPDFSDK_PageView* pPageView,
181 ASSERT(pAnnot != NULL); 181 CPDFSDK_Annot* pAnnot,
182 182 FX_DWORD nFlags,
183 if (IPDFSDK_AnnotHandler* pAnnotHandler = GetAnnotHandler(pAnnot)) 183 short zDelta,
184 { 184 const CPDF_Point& point) {
185 return pAnnotHandler->OnMouseMove(pPageView, pAnnot, nFlags, poi nt); 185 ASSERT(pAnnot != NULL);
186 } 186
187 return FALSE; 187 if (IPDFSDK_AnnotHandler* pAnnotHandler = GetAnnotHandler(pAnnot)) {
188 } 188 return pAnnotHandler->OnMouseWheel(
189 FX_BOOL CPDFSDK_AnnotHandlerMgr::Annot_OnMouseWheel(CPDFSDK_PageView * pPageView , CPDFSDK_Annot* pAnnot, FX_DWORD nFlags, short zDelta, const CPDF_Point& point) 189 pPageView, pAnnot, nFlags, zDelta, point);
190 { 190 }
191 ASSERT(pAnnot != NULL); 191 return FALSE;
192 192 }
193 if (IPDFSDK_AnnotHandler* pAnnotHandler = GetAnnotHandler(pAnnot)) 193 FX_BOOL CPDFSDK_AnnotHandlerMgr::Annot_OnRButtonDown(
194 { 194 CPDFSDK_PageView* pPageView,
195 return pAnnotHandler->OnMouseWheel(pPageView, pAnnot,nFlags,zDel ta, point); 195 CPDFSDK_Annot* pAnnot,
196 } 196 FX_DWORD nFlags,
197 return FALSE; 197 const CPDF_Point& point) {
198 } 198 ASSERT(pAnnot != NULL);
199 FX_BOOL CPDFSDK_AnnotHandlerMgr::Annot_OnRButtonDown(CPDFSDK_PageView * pPageVie w, CPDFSDK_Annot* pAnnot, FX_DWORD nFlags, const CPDF_Point& point) 199
200 { 200 if (IPDFSDK_AnnotHandler* pAnnotHandler = GetAnnotHandler(pAnnot)) {
201 ASSERT(pAnnot != NULL); 201 return pAnnotHandler->OnRButtonDown(pPageView, pAnnot, nFlags, point);
202 202 }
203 if (IPDFSDK_AnnotHandler* pAnnotHandler = GetAnnotHandler(pAnnot)) 203 return FALSE;
204 { 204 }
205 return pAnnotHandler->OnRButtonDown(pPageView, pAnnot, nFlags, p oint); 205 FX_BOOL CPDFSDK_AnnotHandlerMgr::Annot_OnRButtonUp(CPDFSDK_PageView* pPageView,
206 } 206 CPDFSDK_Annot* pAnnot,
207 return FALSE; 207 FX_DWORD nFlags,
208 } 208 const CPDF_Point& point) {
209 FX_BOOL CPDFSDK_AnnotHandlerMgr::Annot_OnRButtonUp(CPDFSDK_PageView * pPageView, CPDFSDK_Annot* pAnnot, FX_DWORD nFlags, const CPDF_Point& point) 209 ASSERT(pAnnot != NULL);
210 { 210
211 ASSERT(pAnnot != NULL); 211 if (IPDFSDK_AnnotHandler* pAnnotHandler = GetAnnotHandler(pAnnot)) {
212 212 return pAnnotHandler->OnRButtonUp(pPageView, pAnnot, nFlags, point);
213 if (IPDFSDK_AnnotHandler* pAnnotHandler = GetAnnotHandler(pAnnot)) 213 }
214 { 214 return FALSE;
215 return pAnnotHandler->OnRButtonUp(pPageView, pAnnot, nFlags, poi nt); 215 }
216 } 216
217 return FALSE; 217 void CPDFSDK_AnnotHandlerMgr::Annot_OnMouseEnter(CPDFSDK_PageView* pPageView,
218 } 218 CPDFSDK_Annot* pAnnot,
219 219 FX_DWORD nFlag) {
220 void CPDFSDK_AnnotHandlerMgr::Annot_OnMouseEnter(CPDFSDK_PageView * pPageView, C PDFSDK_Annot* pAnnot, FX_DWORD nFlag) 220 ASSERT(pAnnot != NULL);
221 { 221
222 ASSERT(pAnnot != NULL); 222 if (IPDFSDK_AnnotHandler* pAnnotHandler = GetAnnotHandler(pAnnot)) {
223 223 pAnnotHandler->OnMouseEnter(pPageView, pAnnot, nFlag);
224 if (IPDFSDK_AnnotHandler* pAnnotHandler = GetAnnotHandler(pAnnot)) 224 }
225 { 225 return;
226 pAnnotHandler->OnMouseEnter(pPageView, pAnnot, nFlag); 226 }
227 } 227
228 return ; 228 void CPDFSDK_AnnotHandlerMgr::Annot_OnMouseExit(CPDFSDK_PageView* pPageView,
229 } 229 CPDFSDK_Annot* pAnnot,
230 230 FX_DWORD nFlag) {
231 void CPDFSDK_AnnotHandlerMgr::Annot_OnMouseExit(CPDFSDK_PageView * pPageView, CP DFSDK_Annot* pAnnot, FX_DWORD nFlag) 231 ASSERT(pAnnot != NULL);
232 { 232
233 ASSERT(pAnnot != NULL); 233 if (IPDFSDK_AnnotHandler* pAnnotHandler = GetAnnotHandler(pAnnot)) {
234 234 pAnnotHandler->OnMouseExit(pPageView, pAnnot, nFlag);
235 if (IPDFSDK_AnnotHandler* pAnnotHandler = GetAnnotHandler(pAnnot)) 235 }
236 { 236 return;
237 pAnnotHandler->OnMouseExit(pPageView, pAnnot, nFlag); 237 }
238 } 238
239 return; 239 FX_BOOL CPDFSDK_AnnotHandlerMgr::Annot_OnChar(CPDFSDK_Annot* pAnnot,
240 } 240 FX_DWORD nChar,
241 241 FX_DWORD nFlags) {
242 FX_BOOL CPDFSDK_AnnotHandlerMgr::Annot_OnChar(CPDFSDK_Annot* pAnnot, FX_DWORD nC har, FX_DWORD nFlags) 242 if (IPDFSDK_AnnotHandler* pAnnotHandler = GetAnnotHandler(pAnnot)) {
243 { 243 return pAnnotHandler->OnChar(pAnnot, nChar, nFlags);
244 244 }
245 if (IPDFSDK_AnnotHandler* pAnnotHandler = GetAnnotHandler(pAnnot)) 245 return FALSE;
246 { 246 }
247 return pAnnotHandler->OnChar(pAnnot,nChar, nFlags); 247
248 } 248 FX_BOOL CPDFSDK_AnnotHandlerMgr::Annot_OnKeyDown(CPDFSDK_Annot* pAnnot,
249 return FALSE; 249 int nKeyCode,
250 250 int nFlag) {
251 } 251 if (!m_pApp->FFI_IsCTRLKeyDown(nFlag) && !m_pApp->FFI_IsALTKeyDown(nFlag)) {
252 252 CPDFSDK_PageView* pPage = pAnnot->GetPageView();
253 FX_BOOL CPDFSDK_AnnotHandlerMgr::Annot_OnKeyDown(CPDFSDK_Annot* pAnnot, int nKeyCode, int nFlag) 253 CPDFSDK_Annot* pFocusAnnot = pPage->GetFocusAnnot();
254 { 254 if (pFocusAnnot && (nKeyCode == FWL_VKEY_Tab)) {
255 255 CPDFSDK_Annot* pNext =
256 if (!m_pApp->FFI_IsCTRLKeyDown(nFlag) && !m_pApp->FFI_IsALTKeyDown(nFlag )) 256 GetNextAnnot(pFocusAnnot, !m_pApp->FFI_IsSHIFTKeyDown(nFlag));
257 { 257
258 CPDFSDK_PageView* pPage = pAnnot->GetPageView(); 258 if (pNext && pNext != pFocusAnnot) {
259 CPDFSDK_Annot* pFocusAnnot = pPage->GetFocusAnnot(); 259 CPDFSDK_Document* pDocument = pPage->GetSDKDocument();
260 if (pFocusAnnot && (nKeyCode == FWL_VKEY_Tab)) 260 pDocument->SetFocusAnnot(pNext);
261 { 261 return TRUE;
262 CPDFSDK_Annot* pNext = GetNextAnnot(pFocusAnnot, !m_pApp ->FFI_IsSHIFTKeyDown(nFlag)); 262 }
263 263 }
264 if(pNext && pNext != pFocusAnnot) 264 }
265 { 265
266 CPDFSDK_Document* pDocument = pPage->GetSDKDocum ent(); 266 if (IPDFSDK_AnnotHandler* pAnnotHandler = GetAnnotHandler(pAnnot)) {
267 pDocument->SetFocusAnnot(pNext); 267 return pAnnotHandler->OnKeyDown(pAnnot, nKeyCode, nFlag);
268 return TRUE; 268 }
269 } 269 return FALSE;
270 } 270 }
271 } 271 FX_BOOL CPDFSDK_AnnotHandlerMgr::Annot_OnKeyUp(CPDFSDK_Annot* pAnnot,
272 272 int nKeyCode,
273 if (IPDFSDK_AnnotHandler* pAnnotHandler = GetAnnotHandler(pAnnot)) 273 int nFlag) {
274 { 274 return FALSE;
275 return pAnnotHandler->OnKeyDown(pAnnot,nKeyCode, nFlag); 275 }
276 } 276
277 return FALSE; 277 FX_BOOL CPDFSDK_AnnotHandlerMgr::Annot_OnSetFocus(CPDFSDK_Annot* pAnnot,
278 } 278 FX_DWORD nFlag) {
279 FX_BOOL CPDFSDK_AnnotHandlerMgr::Annot_OnKeyUp(CPDFSDK_Annot* pA nnot, int nKeyCode, int nFlag) 279 ASSERT(pAnnot != NULL);
280 { 280
281 return FALSE; 281 if (IPDFSDK_AnnotHandler* pAnnotHandler = GetAnnotHandler(pAnnot)) {
282 } 282 if (pAnnotHandler->OnSetFocus(pAnnot, nFlag)) {
283 283 CPDFSDK_PageView* pPage = pAnnot->GetPageView();
284 FX_BOOL CPDFSDK_AnnotHandlerMgr::Annot_OnSetFocus(CPDFSDK_Annot* pAnnot, FX_DWORD nFlag) 284 ASSERT(pPage != NULL);
285 { 285
286 ASSERT(pAnnot != NULL); 286 pPage->GetSDKDocument();
287 287 // pDocument->SetTopmostAnnot(pAnnot);
288 if (IPDFSDK_AnnotHandler* pAnnotHandler = GetAnnotHandler(pAnnot)) 288
289 { 289 return TRUE;
290 if (pAnnotHandler->OnSetFocus(pAnnot, nFlag)) 290 } else {
291 { 291 return FALSE;
292 CPDFSDK_PageView* pPage = pAnnot->GetPageView(); 292 }
293 ASSERT(pPage != NULL); 293 }
294 294
295 pPage->GetSDKDocument(); 295 return FALSE;
296 // pDocument->SetTopmostAnnot(pAnnot); 296 }
297 297
298 return TRUE; 298 FX_BOOL CPDFSDK_AnnotHandlerMgr::Annot_OnKillFocus(CPDFSDK_Annot* pAnnot,
299 } 299 FX_DWORD nFlag) {
300 else 300 ASSERT(pAnnot != NULL);
301 { 301
302 return FALSE; 302 if (IPDFSDK_AnnotHandler* pAnnotHandler = GetAnnotHandler(pAnnot)) {
303 } 303 if (pAnnotHandler->OnKillFocus(pAnnot, nFlag)) {
304 } 304 return TRUE;
305 305 } else
306 return FALSE; 306 return FALSE;
307 } 307 }
308 308
309 FX_BOOL CPDFSDK_AnnotHandlerMgr::Annot_OnKillFocus(CPDFSDK_Annot * pAnnot, FX_DWORD nFlag) 309 return FALSE;
310 { 310 }
311 ASSERT(pAnnot != NULL); 311
312 312 CPDF_Rect CPDFSDK_AnnotHandlerMgr::Annot_OnGetViewBBox(
313 if (IPDFSDK_AnnotHandler* pAnnotHandler = GetAnnotHandler(pAnnot)) 313 CPDFSDK_PageView* pPageView,
314 { 314 CPDFSDK_Annot* pAnnot) {
315 if (pAnnotHandler->OnKillFocus(pAnnot, nFlag)) 315 ASSERT(pAnnot);
316 { 316 if (IPDFSDK_AnnotHandler* pAnnotHandler = GetAnnotHandler(pAnnot)) {
317 return TRUE; 317 return pAnnotHandler->GetViewBBox(pPageView, pAnnot);
318 } 318 }
319 else 319 return pAnnot->GetRect();
320 return FALSE; 320 }
321 } 321
322 322 FX_BOOL CPDFSDK_AnnotHandlerMgr::Annot_OnHitTest(CPDFSDK_PageView* pPageView,
323 return FALSE; 323 CPDFSDK_Annot* pAnnot,
324 } 324 const CPDF_Point& point) {
325 325 ASSERT(pAnnot);
326 CPDF_Rect CPDFSDK_AnnotHandlerMgr::Annot_OnGetViewBBox(CPDFSDK_PageView *p PageView, CPDFSDK_Annot* pAnnot) 326 if (IPDFSDK_AnnotHandler* pAnnotHandler = GetAnnotHandler(pAnnot)) {
327 { 327 if (pAnnotHandler->CanAnswer(pAnnot))
328 ASSERT(pAnnot); 328 return pAnnotHandler->HitTest(pPageView, pAnnot, point);
329 if (IPDFSDK_AnnotHandler* pAnnotHandler = GetAnnotHandler(pAnnot)) 329 }
330 { 330 return FALSE;
331 return pAnnotHandler->GetViewBBox(pPageView, pAnnot); 331 }
332 } 332
333 return pAnnot->GetRect(); 333 CPDFSDK_Annot* CPDFSDK_AnnotHandlerMgr::GetNextAnnot(CPDFSDK_Annot* pSDKAnnot,
334 } 334 FX_BOOL bNext) {
335 335 CBA_AnnotIterator ai(pSDKAnnot->GetPageView(), "Widget", "");
336 FX_BOOL CPDFSDK_AnnotHandlerMgr::Annot_OnHitTest(CPDFSDK_PageView *pPageView, CP DFSDK_Annot* pAnnot, const CPDF_Point& point) 336
337 { 337 CPDFSDK_Annot* pNext =
338 ASSERT(pAnnot); 338 bNext ? ai.GetNextAnnot(pSDKAnnot) : ai.GetPrevAnnot(pSDKAnnot);
339 if (IPDFSDK_AnnotHandler* pAnnotHandler = GetAnnotHandler(pAnnot)) 339
340 { 340 return pNext;
341 if(pAnnotHandler->CanAnswer(pAnnot)) 341 }
342 return pAnnotHandler->HitTest(pPageView, pAnnot, point); 342
343 } 343 FX_BOOL CPDFSDK_BFAnnotHandler::CanAnswer(CPDFSDK_Annot* pAnnot) {
344 return FALSE; 344 ASSERT(pAnnot);
345 } 345 ASSERT(pAnnot->GetType() == "Widget");
346 346 CFX_ByteString sSubType = pAnnot->GetSubType();
347 CPDFSDK_Annot* CPDFSDK_AnnotHandlerMgr::GetNextAnnot(CPDFSDK_Annot* pSDKAnnot,F X_BOOL bNext) 347
348 { 348 if (sSubType == BFFT_SIGNATURE) {
349 CBA_AnnotIterator ai(pSDKAnnot->GetPageView(), "Widget", ""); 349 } else {
350 350 CPDFSDK_Widget* pWidget = (CPDFSDK_Widget*)pAnnot;
351 CPDFSDK_Annot* pNext = bNext ? 351 if (!pWidget->IsVisible())
352 ai.GetNextAnnot(pSDKAnnot) : 352 return FALSE;
353 ai.GetPrevAnnot(pSDKAnnot); 353
354 354 int nFieldFlags = pWidget->GetFieldFlags();
355 return pNext; 355 if ((nFieldFlags & FIELDFLAG_READONLY) == FIELDFLAG_READONLY)
356 } 356 return FALSE;
357 357 if (pWidget->GetFieldType() == FIELDTYPE_PUSHBUTTON)
358 FX_BOOL CPDFSDK_BFAnnotHandler::CanAnswer(CPDFSDK_Annot* pAnnot) 358 return TRUE;
359 { 359 else {
360 ASSERT(pAnnot); 360 CPDF_Page* pPage = pWidget->GetPDFPage();
361 ASSERT(pAnnot->GetType() == "Widget"); 361 ASSERT(pPage != NULL);
362 CFX_ByteString sSubType = pAnnot->GetSubType(); 362
363 363 CPDF_Document* pDocument = pPage->m_pDocument;
364 if (sSubType == BFFT_SIGNATURE) 364 ASSERT(pDocument != NULL);
365 { 365
366 } 366 FX_DWORD dwPermissions = pDocument->GetUserPermissions();
367 else 367 return (dwPermissions & FPDFPERM_FILL_FORM) ||
368 { 368 (dwPermissions & FPDFPERM_ANNOT_FORM) ||
369 CPDFSDK_Widget* pWidget = (CPDFSDK_Widget*)pAnnot; 369 (dwPermissions & FPDFPERM_ANNOT_FORM);
370 if (!pWidget->IsVisible()) return FALSE; 370 }
371 371 }
372 int nFieldFlags = pWidget->GetFieldFlags(); 372
373 if ((nFieldFlags & FIELDFLAG_READONLY) == FIELDFLAG_READONLY) re turn FALSE; 373 return FALSE;
374 if (pWidget->GetFieldType() == FIELDTYPE_PUSHBUTTON) 374 }
375 return TRUE; 375
376 else 376 CPDFSDK_Annot* CPDFSDK_BFAnnotHandler::NewAnnot(CPDF_Annot* pAnnot,
377 { 377 CPDFSDK_PageView* pPage) {
378 CPDF_Page* pPage = pWidget->GetPDFPage(); 378 ASSERT(pPage != NULL);
379 ASSERT(pPage != NULL); 379 pPage->GetPDFDocument();
380 380
381 CPDF_Document* pDocument = pPage->m_pDocument; 381 CPDFSDK_Document* pSDKDoc = m_pApp->GetCurrentDoc();
382 ASSERT(pDocument != NULL); 382 ASSERT(pSDKDoc);
383 383 CPDFSDK_InterForm* pInterForm = (CPDFSDK_InterForm*)pSDKDoc->GetInterForm();
384 FX_DWORD dwPermissions = pDocument->GetUserPermissions() ; 384 ASSERT(pInterForm != NULL);
385 return (dwPermissions&FPDFPERM_FILL_FORM) || 385
386 (dwPermissions&FPDFPERM_ANNOT_FORM) || 386 CPDFSDK_Widget* pWidget = NULL;
387 (dwPermissions&FPDFPERM_ANNOT_FORM); 387 if (CPDF_FormControl* pCtrl = CPDFSDK_Widget::GetFormControl(
388 } 388 pInterForm->GetInterForm(), pAnnot->m_pAnnotDict)) {
389 } 389 pWidget = new CPDFSDK_Widget(pAnnot, pPage, pInterForm);
390 390 pInterForm->AddMap(pCtrl, pWidget);
391 return FALSE; 391 CPDF_InterForm* pPDFInterForm = pInterForm->GetInterForm();
392 } 392 if (pPDFInterForm && pPDFInterForm->NeedConstructAP())
393 393 pWidget->ResetAppearance(NULL, FALSE);
394 CPDFSDK_Annot* CPDFSDK_BFAnnotHandler::NewAnnot(CPDF_Annot* pAnnot, CPD FSDK_PageView* pPage) 394 }
395 { 395
396 ASSERT(pPage != NULL); 396 return pWidget;
397 pPage->GetPDFDocument(); 397 }
398 398
399 CPDFSDK_Document* pSDKDoc = m_pApp->GetCurrentDoc(); 399 void CPDFSDK_BFAnnotHandler::ReleaseAnnot(CPDFSDK_Annot* pAnnot) {
400 ASSERT(pSDKDoc); 400 ASSERT(pAnnot != NULL);
401 CPDFSDK_InterForm* pInterForm = (CPDFSDK_InterForm*)pSDKDoc->GetInterFor m(); 401
402 ASSERT(pInterForm != NULL); 402 if (m_pFormFiller)
403 403 m_pFormFiller->OnDelete(pAnnot);
404 CPDFSDK_Widget* pWidget = NULL; 404
405 if (CPDF_FormControl* pCtrl = CPDFSDK_Widget::GetFormControl(pInterForm- >GetInterForm(), pAnnot->m_pAnnotDict)) 405 CPDFSDK_Widget* pWidget = (CPDFSDK_Widget*)pAnnot;
406 { 406 CPDFSDK_InterForm* pInterForm = pWidget->GetInterForm();
407 pWidget = new CPDFSDK_Widget(pAnnot, pPage, pInterForm); 407 ASSERT(pInterForm != NULL);
408 pInterForm->AddMap(pCtrl, pWidget); 408
409 CPDF_InterForm* pPDFInterForm = pInterForm->GetInterForm(); 409 CPDF_FormControl* pCtrol = pWidget->GetFormControl();
410 if(pPDFInterForm && pPDFInterForm->NeedConstructAP()) 410 pInterForm->RemoveMap(pCtrol);
411 pWidget->ResetAppearance(NULL,FALSE); 411
412 } 412 delete pWidget;
413 413 }
414 return pWidget; 414
415 } 415 void CPDFSDK_BFAnnotHandler::OnDraw(CPDFSDK_PageView* pPageView,
416 416 CPDFSDK_Annot* pAnnot,
417 void CPDFSDK_BFAnnotHandler::ReleaseAnnot(CPDFSDK_Annot* pAnnot) 417 CFX_RenderDevice* pDevice,
418 { 418 CPDF_Matrix* pUser2Device,
419 ASSERT(pAnnot != NULL); 419 FX_DWORD dwFlags) {
420 420 ASSERT(pAnnot != NULL);
421 if (m_pFormFiller) 421 CFX_ByteString sSubType = pAnnot->GetSubType();
422 m_pFormFiller->OnDelete(pAnnot); 422
423 423 if (sSubType == BFFT_SIGNATURE) {
424 CPDFSDK_Widget* pWidget = (CPDFSDK_Widget*)pAnnot; 424 pAnnot->DrawAppearance(pDevice, pUser2Device, CPDF_Annot::Normal, NULL);
425 CPDFSDK_InterForm* pInterForm = pWidget->GetInterForm(); 425 } else {
426 ASSERT(pInterForm != NULL); 426 if (m_pFormFiller) {
427 427 m_pFormFiller->OnDraw(pPageView, pAnnot, pDevice, pUser2Device, dwFlags);
428 CPDF_FormControl* pCtrol = pWidget->GetFormControl(); 428 }
429 pInterForm->RemoveMap(pCtrol); 429 }
430 430 }
431 431
432 delete pWidget; 432 void CPDFSDK_BFAnnotHandler::OnMouseEnter(CPDFSDK_PageView* pPageView,
433 } 433 CPDFSDK_Annot* pAnnot,
434 434 FX_DWORD nFlag) {
435 435 ASSERT(pAnnot != NULL);
436 void CPDFSDK_BFAnnotHandler::OnDraw(CPDFSDK_PageView *pPageView, CPDFSDK_Annot* pAnnot, CFX_RenderDevice* pDevice, CPDF_Matrix* pUser2Device, FX_DWORD dwFlags) 436 CFX_ByteString sSubType = pAnnot->GetSubType();
437 { 437
438 ASSERT(pAnnot != NULL); 438 if (sSubType == BFFT_SIGNATURE) {
439 CFX_ByteString sSubType = pAnnot->GetSubType(); 439 } else {
440 440 if (m_pFormFiller)
441 if (sSubType == BFFT_SIGNATURE) 441 m_pFormFiller->OnMouseEnter(pPageView, pAnnot, nFlag);
442 { 442 }
443 pAnnot->DrawAppearance(pDevice, pUser2Device, CPDF_Annot::Normal , NULL); 443 }
444 } 444 void CPDFSDK_BFAnnotHandler::OnMouseExit(CPDFSDK_PageView* pPageView,
445 else 445 CPDFSDK_Annot* pAnnot,
446 { 446 FX_DWORD nFlag) {
447 if (m_pFormFiller) 447 ASSERT(pAnnot != NULL);
448 { 448 CFX_ByteString sSubType = pAnnot->GetSubType();
449 m_pFormFiller->OnDraw(pPageView, pAnnot, pDevice, pUser2 Device, dwFlags); 449
450 } 450 if (sSubType == BFFT_SIGNATURE) {
451 } 451 } else {
452 } 452 if (m_pFormFiller)
453 453 m_pFormFiller->OnMouseExit(pPageView, pAnnot, nFlag);
454 void CPDFSDK_BFAnnotHandler::OnMouseEnter(CPDFSDK_PageView *pPageView, CPDFSDK_A nnot* pAnnot, FX_DWORD nFlag) 454 }
455 { 455 }
456 ASSERT(pAnnot != NULL); 456 FX_BOOL CPDFSDK_BFAnnotHandler::OnLButtonDown(CPDFSDK_PageView* pPageView,
457 CFX_ByteString sSubType = pAnnot->GetSubType(); 457 CPDFSDK_Annot* pAnnot,
458 458 FX_DWORD nFlags,
459 if (sSubType == BFFT_SIGNATURE) 459 const CPDF_Point& point) {
460 { 460 ASSERT(pAnnot != NULL);
461 } 461 CFX_ByteString sSubType = pAnnot->GetSubType();
462 else 462
463 { 463 if (sSubType == BFFT_SIGNATURE) {
464 if (m_pFormFiller) 464 } else {
465 m_pFormFiller->OnMouseEnter(pPageView, pAnnot, nFlag); 465 if (m_pFormFiller)
466 } 466 return m_pFormFiller->OnLButtonDown(pPageView, pAnnot, nFlags, point);
467 467 }
468 468
469 } 469 return FALSE;
470 void CPDFSDK_BFAnnotHandler::OnMouseExit(CPDFSDK_PageView *pPageView, CPDFSDK_An not* pAnnot, FX_DWORD nFlag) 470 }
471 { 471
472 ASSERT(pAnnot != NULL); 472 FX_BOOL CPDFSDK_BFAnnotHandler::OnLButtonUp(CPDFSDK_PageView* pPageView,
473 CFX_ByteString sSubType = pAnnot->GetSubType(); 473 CPDFSDK_Annot* pAnnot,
474 474 FX_DWORD nFlags,
475 if (sSubType == BFFT_SIGNATURE) 475 const CPDF_Point& point) {
476 { 476 ASSERT(pAnnot != NULL);
477 } 477 CFX_ByteString sSubType = pAnnot->GetSubType();
478 else 478
479 { 479 if (sSubType == BFFT_SIGNATURE) {
480 if (m_pFormFiller) 480 } else {
481 m_pFormFiller->OnMouseExit(pPageView, pAnnot, nFlag); 481 if (m_pFormFiller)
482 } 482 return m_pFormFiller->OnLButtonUp(pPageView, pAnnot, nFlags, point);
483 483 }
484 } 484
485 FX_BOOL CPDFSDK_BFAnnotHandler::OnLButtonDown(CPDFSDK_PageView *pPageView, CPDFS DK_Annot* pAnnot, FX_DWORD nFlags, const CPDF_Point& point) 485 return FALSE;
486 { 486 }
487 ASSERT(pAnnot != NULL); 487
488 CFX_ByteString sSubType = pAnnot->GetSubType(); 488 FX_BOOL CPDFSDK_BFAnnotHandler::OnLButtonDblClk(CPDFSDK_PageView* pPageView,
489 489 CPDFSDK_Annot* pAnnot,
490 if (sSubType == BFFT_SIGNATURE) 490 FX_DWORD nFlags,
491 { 491 const CPDF_Point& point) {
492 } 492 ASSERT(pAnnot != NULL);
493 else 493 CFX_ByteString sSubType = pAnnot->GetSubType();
494 { 494
495 if (m_pFormFiller) 495 if (sSubType == BFFT_SIGNATURE) {
496 return m_pFormFiller->OnLButtonDown(pPageView, pAnnot, n Flags, point); 496 } else {
497 } 497 if (m_pFormFiller)
498 498 return m_pFormFiller->OnLButtonDblClk(pPageView, pAnnot, nFlags, point);
499 return FALSE; 499 }
500 } 500
501 501 return FALSE;
502 FX_BOOL CPDFSDK_BFAnnotHandler::OnLButtonUp(CPDFSDK_PageView *pPageView, CPDFSDK _Annot* pAnnot, FX_DWORD nFlags, const CPDF_Point& point) 502 }
503 { 503
504 ASSERT(pAnnot != NULL); 504 FX_BOOL CPDFSDK_BFAnnotHandler::OnMouseMove(CPDFSDK_PageView* pPageView,
505 CFX_ByteString sSubType = pAnnot->GetSubType(); 505 CPDFSDK_Annot* pAnnot,
506 506 FX_DWORD nFlags,
507 if (sSubType == BFFT_SIGNATURE) 507 const CPDF_Point& point) {
508 { 508 ASSERT(pAnnot != NULL);
509 } 509 CFX_ByteString sSubType = pAnnot->GetSubType();
510 else 510
511 { 511 if (sSubType == BFFT_SIGNATURE) {
512 if (m_pFormFiller) 512 } else {
513 return m_pFormFiller->OnLButtonUp(pPageView, pAnnot, nFl ags, point); 513 if (m_pFormFiller)
514 } 514 return m_pFormFiller->OnMouseMove(pPageView, pAnnot, nFlags, point);
515 515 }
516 return FALSE; 516
517 } 517 return FALSE;
518 518 }
519 FX_BOOL CPDFSDK_BFAnnotHandler::OnLButtonDblClk(CPDFSDK_PageView *pPageView, CPD FSDK_Annot* pAnnot, FX_DWORD nFlags, const CPDF_Point& point) 519
520 { 520 FX_BOOL CPDFSDK_BFAnnotHandler::OnMouseWheel(CPDFSDK_PageView* pPageView,
521 ASSERT(pAnnot != NULL); 521 CPDFSDK_Annot* pAnnot,
522 CFX_ByteString sSubType = pAnnot->GetSubType(); 522 FX_DWORD nFlags,
523 523 short zDelta,
524 if (sSubType == BFFT_SIGNATURE) 524 const CPDF_Point& point) {
525 { 525 ASSERT(pAnnot != NULL);
526 } 526 CFX_ByteString sSubType = pAnnot->GetSubType();
527 else 527
528 { 528 if (sSubType == BFFT_SIGNATURE) {
529 if (m_pFormFiller) 529 } else {
530 return m_pFormFiller->OnLButtonDblClk(pPageView, pAnnot, nFlags, point); 530 if (m_pFormFiller)
531 } 531 return m_pFormFiller->OnMouseWheel(
532 532 pPageView, pAnnot, nFlags, zDelta, point);
533 return FALSE; 533 }
534 } 534
535 535 return FALSE;
536 FX_BOOL CPDFSDK_BFAnnotHandler::OnMouseMove(CPDFSDK_PageView *pPageView, CPDFSDK _Annot* pAnnot, FX_DWORD nFlags, const CPDF_Point& point) 536 }
537 { 537
538 ASSERT(pAnnot != NULL); 538 FX_BOOL CPDFSDK_BFAnnotHandler::OnRButtonDown(CPDFSDK_PageView* pPageView,
539 CFX_ByteString sSubType = pAnnot->GetSubType(); 539 CPDFSDK_Annot* pAnnot,
540 540 FX_DWORD nFlags,
541 if (sSubType == BFFT_SIGNATURE) 541 const CPDF_Point& point) {
542 { 542 ASSERT(pAnnot != NULL);
543 } 543 CFX_ByteString sSubType = pAnnot->GetSubType();
544 else 544
545 { 545 if (sSubType == BFFT_SIGNATURE) {
546 if (m_pFormFiller) 546 } else {
547 return m_pFormFiller->OnMouseMove(pPageView, pAnnot, nFl ags, point); 547 if (m_pFormFiller)
548 } 548 return m_pFormFiller->OnRButtonDown(pPageView, pAnnot, nFlags, point);
549 549 }
550 return FALSE; 550
551 551 return FALSE;
552 } 552 }
553 553 FX_BOOL CPDFSDK_BFAnnotHandler::OnRButtonUp(CPDFSDK_PageView* pPageView,
554 554 CPDFSDK_Annot* pAnnot,
555 FX_BOOL CPDFSDK_BFAnnotHandler::OnMouseWheel(CPDFSDK_PageView *pPageView, CPDFSD K_Annot* pAnnot, FX_DWORD nFlags, short zDelta, const CPDF_Point& point) 555 FX_DWORD nFlags,
556 { 556 const CPDF_Point& point) {
557 ASSERT(pAnnot != NULL); 557 ASSERT(pAnnot != NULL);
558 CFX_ByteString sSubType = pAnnot->GetSubType(); 558 CFX_ByteString sSubType = pAnnot->GetSubType();
559 559
560 if (sSubType == BFFT_SIGNATURE) 560 if (sSubType == BFFT_SIGNATURE) {
561 { 561 } else {
562 } 562 if (m_pFormFiller)
563 else 563 return m_pFormFiller->OnRButtonUp(pPageView, pAnnot, nFlags, point);
564 { 564 }
565 if (m_pFormFiller) 565
566 return m_pFormFiller->OnMouseWheel(pPageView, pAnnot, nF lags, zDelta,point); 566 return FALSE;
567 } 567 }
568 568
569 return FALSE; 569 FX_BOOL CPDFSDK_BFAnnotHandler::OnChar(CPDFSDK_Annot* pAnnot,
570 } 570 FX_DWORD nChar,
571 571 FX_DWORD nFlags) {
572 FX_BOOL CPDFSDK_BFAnnotHandler::OnRButtonDown(CPDFSDK_PageView *pPageView, CPDFS DK_Annot* pAnnot, FX_DWORD nFlags, const CPDF_Point& point) 572 ASSERT(pAnnot != NULL);
573 { 573 CFX_ByteString sSubType = pAnnot->GetSubType();
574 ASSERT(pAnnot != NULL); 574
575 CFX_ByteString sSubType = pAnnot->GetSubType(); 575 if (sSubType == BFFT_SIGNATURE) {
576 576 } else {
577 if (sSubType == BFFT_SIGNATURE) 577 if (m_pFormFiller)
578 { 578 return m_pFormFiller->OnChar(pAnnot, nChar, nFlags);
579 } 579 }
580 else 580
581 { 581 return FALSE;
582 if (m_pFormFiller) 582 }
583 return m_pFormFiller->OnRButtonDown(pPageView, pAnnot, n Flags, point); 583
584 } 584 FX_BOOL CPDFSDK_BFAnnotHandler::OnKeyDown(CPDFSDK_Annot* pAnnot,
585 585 int nKeyCode,
586 return FALSE; 586 int nFlag) {
587 } 587 ASSERT(pAnnot != NULL);
588 FX_BOOL CPDFSDK_BFAnnotHandler::OnRButtonUp(CPDFSDK_PageView *pPageView, CPDFSDK _Annot* pAnnot, FX_DWORD nFlags, const CPDF_Point& point) 588 CFX_ByteString sSubType = pAnnot->GetSubType();
589 { 589
590 ASSERT(pAnnot != NULL); 590 if (sSubType == BFFT_SIGNATURE) {
591 CFX_ByteString sSubType = pAnnot->GetSubType(); 591 } else {
592 592 if (m_pFormFiller)
593 if (sSubType == BFFT_SIGNATURE) 593 return m_pFormFiller->OnKeyDown(pAnnot, nKeyCode, nFlag);
594 { 594 }
595 } 595
596 else 596 return FALSE;
597 { 597 }
598 if (m_pFormFiller) 598
599 return m_pFormFiller->OnRButtonUp(pPageView, pAnnot, nFl ags, point); 599 FX_BOOL CPDFSDK_BFAnnotHandler::OnKeyUp(CPDFSDK_Annot* pAnnot,
600 } 600 int nKeyCode,
601 601 int nFlag) {
602 return FALSE; 602 return FALSE;
603 } 603 }
604 604 void CPDFSDK_BFAnnotHandler::OnCreate(CPDFSDK_Annot* pAnnot) {
605 FX_BOOL CPDFSDK_BFAnnotHandler::OnChar(CPDFSDK_Annot* pAnnot, FX_DWORD nChar, FX _DWORD nFlags) 605 ASSERT(pAnnot != NULL);
606 { 606 CFX_ByteString sSubType = pAnnot->GetSubType();
607 ASSERT(pAnnot != NULL); 607
608 CFX_ByteString sSubType = pAnnot->GetSubType(); 608 if (sSubType == BFFT_SIGNATURE) {
609 609 } else {
610 if (sSubType == BFFT_SIGNATURE) 610 if (m_pFormFiller)
611 { 611 m_pFormFiller->OnCreate(pAnnot);
612 } 612 }
613 else 613 }
614 { 614
615 if (m_pFormFiller) 615 void CPDFSDK_BFAnnotHandler::OnLoad(CPDFSDK_Annot* pAnnot) {
616 return m_pFormFiller->OnChar(pAnnot,nChar, nFlags); 616 ASSERT(pAnnot != NULL);
617 } 617
618 618 CFX_ByteString sSubType = pAnnot->GetSubType();
619 return FALSE; 619
620 } 620 if (sSubType == BFFT_SIGNATURE) {
621 621 } else {
622 FX_BOOL CPDFSDK_BFAnnotHandler::OnKeyDown(CPDFSDK_Annot* pAnnot, int nKeyCode, i nt nFlag) 622 CPDFSDK_Widget* pWidget = (CPDFSDK_Widget*)pAnnot;
623 { 623
624 ASSERT(pAnnot != NULL); 624 if (!pWidget->IsAppearanceValid())
625 CFX_ByteString sSubType = pAnnot->GetSubType(); 625 pWidget->ResetAppearance(NULL, FALSE);
626 626
627 if (sSubType == BFFT_SIGNATURE) 627 int nFieldType = pWidget->GetFieldType();
628 { 628
629 } 629 if (nFieldType == FIELDTYPE_TEXTFIELD || nFieldType == FIELDTYPE_COMBOBOX) {
630 else 630 FX_BOOL bFormated = FALSE;
631 { 631 CFX_WideString sValue = pWidget->OnFormat(0, bFormated);
632 if (m_pFormFiller) 632
633 return m_pFormFiller->OnKeyDown(pAnnot,nKeyCode, nFlag); 633 if (bFormated && nFieldType == FIELDTYPE_COMBOBOX) {
634 } 634 pWidget->ResetAppearance(sValue, FALSE);
635 635 }
636 return FALSE; 636 }
637 } 637
638 638 if (m_pFormFiller)
639 FX_BOOL CPDFSDK_BFAnnotHandler::OnKeyUp(CPDFSDK_Annot* pAnnot, int nKeyCode, int nFlag) 639 m_pFormFiller->OnLoad(pAnnot);
640 { 640 }
641 641 }
642 return FALSE; 642
643 } 643 FX_BOOL CPDFSDK_BFAnnotHandler::OnSetFocus(CPDFSDK_Annot* pAnnot,
644 void CPDFSDK_BFAnnotHandler::OnCreate(CPDFSDK_Annot* pAnnot) 644 FX_DWORD nFlag) {
645 { 645 ASSERT(pAnnot != NULL);
646 ASSERT(pAnnot != NULL); 646 CFX_ByteString sSubType = pAnnot->GetSubType();
647 CFX_ByteString sSubType = pAnnot->GetSubType(); 647
648 648 if (sSubType == BFFT_SIGNATURE) {
649 if (sSubType == BFFT_SIGNATURE) 649 } else {
650 { 650 if (m_pFormFiller)
651 } 651 return m_pFormFiller->OnSetFocus(pAnnot, nFlag);
652 else 652 }
653 { 653
654 if (m_pFormFiller) 654 return TRUE;
655 m_pFormFiller->OnCreate(pAnnot); 655 }
656 } 656 FX_BOOL CPDFSDK_BFAnnotHandler::OnKillFocus(CPDFSDK_Annot* pAnnot,
657 } 657 FX_DWORD nFlag) {
658 658 ASSERT(pAnnot != NULL);
659 void CPDFSDK_BFAnnotHandler::OnLoad(CPDFSDK_Annot* pAnnot) 659 CFX_ByteString sSubType = pAnnot->GetSubType();
660 { 660
661 ASSERT(pAnnot != NULL); 661 if (sSubType == BFFT_SIGNATURE) {
662 662 } else {
663 CFX_ByteString sSubType = pAnnot->GetSubType(); 663 if (m_pFormFiller)
664 664 return m_pFormFiller->OnKillFocus(pAnnot, nFlag);
665 if (sSubType == BFFT_SIGNATURE) 665 }
666 { 666
667 } 667 return TRUE;
668 else 668 }
669 { 669
670 CPDFSDK_Widget* pWidget = (CPDFSDK_Widget*)pAnnot; 670 CPDF_Rect CPDFSDK_BFAnnotHandler::GetViewBBox(CPDFSDK_PageView* pPageView,
671 671 CPDFSDK_Annot* pAnnot) {
672 if (!pWidget->IsAppearanceValid()) 672 ASSERT(pAnnot != NULL);
673 pWidget->ResetAppearance(NULL, FALSE); 673 CFX_ByteString sSubType = pAnnot->GetSubType();
674 674
675 int nFieldType = pWidget->GetFieldType(); 675 if (sSubType == BFFT_SIGNATURE) {
676 676 } else {
677 if (nFieldType == FIELDTYPE_TEXTFIELD || nFieldType == FIELDTYPE _COMBOBOX) 677 if (m_pFormFiller)
678 { 678 return m_pFormFiller->GetViewBBox(pPageView, pAnnot);
679 FX_BOOL bFormated = FALSE; 679 }
680 CFX_WideString sValue = pWidget->OnFormat(0, bFormated); 680
681 681 return CPDF_Rect(0, 0, 0, 0);
682 if (bFormated && nFieldType == FIELDTYPE_COMBOBOX) 682 }
683 { 683
684 pWidget->ResetAppearance(sValue, FALSE); 684 FX_BOOL CPDFSDK_BFAnnotHandler::HitTest(CPDFSDK_PageView* pPageView,
685 } 685 CPDFSDK_Annot* pAnnot,
686 } 686 const CPDF_Point& point) {
687 687 ASSERT(pPageView);
688 688 ASSERT(pAnnot);
689 if (m_pFormFiller) 689
690 m_pFormFiller->OnLoad(pAnnot); 690 CPDF_Rect rect = GetViewBBox(pPageView, pAnnot);
691 691 return rect.Contains(point.x, point.y);
692 } 692 }
693 } 693
694 694 // CReader_AnnotIteratorEx
695 FX_BOOL CPDFSDK_BFAnnotHandler::OnSetFocus(CPDFSDK_Annot* pAnnot, FX_DWORD nFlag ) 695
696 { 696 CPDFSDK_AnnotIterator::CPDFSDK_AnnotIterator(CPDFSDK_PageView* pPageView,
697 ASSERT(pAnnot != NULL); 697 FX_BOOL bReverse,
698 CFX_ByteString sSubType = pAnnot->GetSubType(); 698 FX_BOOL bIgnoreTopmost /*=FALSE*/,
699 699 FX_BOOL bCircle /*=FALSE*/,
700 if (sSubType == BFFT_SIGNATURE) 700 CFX_PtrArray* pList /*=NULL*/) {
701 { 701 ASSERT(pPageView);
702 } 702 m_bReverse = bReverse;
703 else 703 m_bIgnoreTopmost = bIgnoreTopmost;
704 { 704 m_bCircle = bCircle;
705 if (m_pFormFiller) 705 m_pIteratorAnnotList.RemoveAll();
706 return m_pFormFiller->OnSetFocus(pAnnot,nFlag); 706 InitIteratorAnnotList(pPageView, pList);
707 } 707 }
708 708
709 return TRUE; 709 CPDFSDK_Annot* CPDFSDK_AnnotIterator::NextAnnot(const CPDFSDK_Annot* pCurrent) {
710 } 710 int index = -1;
711 FX_BOOL CPDFSDK_BFAnnotHandler::OnKillFocus(CPDFSDK_Annot* pAnnot, FX_DWORD nFla g) 711 int nCount = this->m_pIteratorAnnotList.GetSize();
712 { 712 if (pCurrent) {
713 ASSERT(pAnnot != NULL); 713 for (int i = 0; i < nCount; i++) {
714 CFX_ByteString sSubType = pAnnot->GetSubType(); 714 CPDFSDK_Annot* pReaderAnnot =
715 715 (CPDFSDK_Annot*)m_pIteratorAnnotList.GetAt(i);
716 if (sSubType == BFFT_SIGNATURE) 716 if (pReaderAnnot == pCurrent) {
717 { 717 index = i;
718 } 718 break;
719 else 719 }
720 { 720 }
721 if (m_pFormFiller) 721 }
722 return m_pFormFiller->OnKillFocus(pAnnot,nFlag); 722 return NextAnnot(index);
723 } 723 }
724 724 CPDFSDK_Annot* CPDFSDK_AnnotIterator::PrevAnnot(const CPDFSDK_Annot* pCurrent) {
725 return TRUE; 725 int index = -1;
726 } 726 int nCount = this->m_pIteratorAnnotList.GetSize();
727 727 if (pCurrent) {
728 CPDF_Rect CPDFSDK_BFAnnotHandler::GetViewBBox(CPDFSDK_PageView *pPageView, CPDFS DK_Annot* pAnnot) 728 for (int i = 0; i < nCount; i++) {
729 { 729 CPDFSDK_Annot* pReaderAnnot =
730 ASSERT(pAnnot != NULL); 730 (CPDFSDK_Annot*)m_pIteratorAnnotList.GetAt(i);
731 CFX_ByteString sSubType = pAnnot->GetSubType(); 731 if (pReaderAnnot == pCurrent) {
732 732 index = i;
733 if (sSubType == BFFT_SIGNATURE) 733 break;
734 { 734 }
735 } 735 }
736 else 736 }
737 { 737 return PrevAnnot(index);
738 if (m_pFormFiller) 738 }
739 return m_pFormFiller->GetViewBBox(pPageView, pAnnot); 739 CPDFSDK_Annot* CPDFSDK_AnnotIterator::NextAnnot(int& index) {
740 740 int nCount = m_pIteratorAnnotList.GetSize();
741 } 741 if (nCount <= 0)
742 742 index = -1;
743 return CPDF_Rect(0,0,0,0); 743 else {
744 } 744 if (index < 0) {
745 745 index = 0;
746 FX_BOOL CPDFSDK_BFAnnotHandler::HitTest(CPDFSDK_PageView *pPageView, CPDFSDK_Ann ot* pAnnot, const CPDF_Point& point) 746 } else {
747 { 747 if (m_bCircle) {
748 ASSERT(pPageView); 748 index = (index < nCount - 1) ? (index + 1) : 0;
749 ASSERT(pAnnot); 749 } else {
750 750 index = (index < nCount - 1) ? (index + 1) : -1;
751 CPDF_Rect rect = GetViewBBox(pPageView, pAnnot); 751 }
752 return rect.Contains(point.x, point.y); 752 }
753 } 753 }
754 754 return (index < 0) ? NULL : (CPDFSDK_Annot*)m_pIteratorAnnotList.GetAt(index);
755 //CReader_AnnotIteratorEx 755 }
756 756
757 CPDFSDK_AnnotIterator::CPDFSDK_AnnotIterator(CPDFSDK_PageView * pPageView,FX_BOO L bReverse, 757 CPDFSDK_Annot* CPDFSDK_AnnotIterator::PrevAnnot(int& index) {
758 FX_BOOL bIgnoreTopmost/*=FALSE*/, 758 int nCount = m_pIteratorAnnotList.GetSize();
759 FX_BOOL bCircle/*=FALSE*/, 759 if (nCount <= 0)
760 CFX_PtrArray *pList/*=NULL*/) 760 index = -1;
761 { 761 else {
762 ASSERT(pPageView); 762 if (index < 0) {
763 m_bReverse=bReverse; 763 index = nCount - 1;
764 m_bIgnoreTopmost= bIgnoreTopmost; 764 } else {
765 m_bCircle=bCircle; 765 if (m_bCircle) {
766 m_pIteratorAnnotList.RemoveAll(); 766 index = (index > 0) ? (index - 1) : nCount - 1;
767 InitIteratorAnnotList(pPageView,pList); 767 } else {
768 } 768 index = (index > 0) ? (index - 1) : -1;
769 769 }
770 CPDFSDK_Annot* CPDFSDK_AnnotIterator::NextAnnot (const CPDFSDK_Annot* pCurrent) 770 }
771 { 771 }
772 772 return (index < 0) ? NULL : (CPDFSDK_Annot*)m_pIteratorAnnotList.GetAt(index);
773 int index=-1; 773 }
774 int nCount=this->m_pIteratorAnnotList.GetSize(); 774
775 if(pCurrent){ 775 CPDFSDK_Annot* CPDFSDK_AnnotIterator::Next(const CPDFSDK_Annot* pCurrent) {
776 for(int i=0;i<nCount;i++){ 776 return (m_bReverse) ? PrevAnnot(pCurrent) : NextAnnot(pCurrent);
777 CPDFSDK_Annot * pReaderAnnot= (CPDFSDK_Annot *)m_pIterat orAnnotList.GetAt(i); 777 }
778 if(pReaderAnnot ==pCurrent){ 778
779 index=i; 779 CPDFSDK_Annot* CPDFSDK_AnnotIterator::Prev(const CPDFSDK_Annot* pCurrent) {
780 break; 780 return (m_bReverse) ? NextAnnot(pCurrent) : PrevAnnot(pCurrent);
781 } 781 }
782 } 782
783 } 783 CPDFSDK_Annot* CPDFSDK_AnnotIterator::Next(int& index) {
784 return NextAnnot(index); 784 return (m_bReverse) ? PrevAnnot(index) : NextAnnot(index);
785 } 785 }
786 CPDFSDK_Annot* CPDFSDK_AnnotIterator::PrevAnnot (const CPDFSDK_Annot*pCurrent) 786
787 { 787 CPDFSDK_Annot* CPDFSDK_AnnotIterator::Prev(int& index) {
788 788 return (m_bReverse) ? NextAnnot(index) : PrevAnnot(index);
789 int index=-1; 789 }
790 int nCount=this->m_pIteratorAnnotList.GetSize(); 790
791 if(pCurrent){ 791 void CPDFSDK_AnnotIterator::InsertSort(CFX_PtrArray& arrayList,
792 for(int i=0;i<nCount;i++){ 792 AI_COMPARE pCompare) {
793 CPDFSDK_Annot * pReaderAnnot= (CPDFSDK_Annot*)m_pIterato rAnnotList.GetAt(i); 793 for (int i = 1; i < arrayList.GetSize(); i++) {
794 if(pReaderAnnot ==pCurrent){ 794 if (pCompare((CPDFSDK_Annot*)(arrayList[i]),
795 index=i; 795 (CPDFSDK_Annot*)(arrayList[i - 1])) < 0) {
796 break; 796 int j = i - 1;
797 } 797 CPDFSDK_Annot* pTemp = (CPDFSDK_Annot*)arrayList[i];
798 } 798
799 } 799 do {
800 return PrevAnnot(index); 800 arrayList[j + 1] = arrayList[j];
801 } 801 } while (--j >= 0 && pCompare(pTemp, (CPDFSDK_Annot*)arrayList[j]) < 0);
802 CPDFSDK_Annot* CPDFSDK_AnnotIterator::NextAnnot (int& index) 802
803 { 803 arrayList[j + 1] = pTemp;
804 804 }
805 int nCount=m_pIteratorAnnotList.GetSize(); 805 }
806 if(nCount<=0) index=-1; 806 }
807 else{ 807
808 if(index<0){ 808 int LyOrderCompare(CPDFSDK_Annot* p1, CPDFSDK_Annot* p2) {
809 index=0; 809 if (p1->GetLayoutOrder() < p2->GetLayoutOrder())
810 } 810 return -1;
811 else{ 811 else if (p1->GetLayoutOrder() == p2->GetLayoutOrder())
812 if(m_bCircle){ 812 return 0;
813 index=( index <nCount-1) ? (index+1) :0; 813 else
814 } 814 return 1;
815 else{ 815 }
816 index=( index <nCount-1) ? (index+1) :-1; 816
817 } 817 FX_BOOL CPDFSDK_AnnotIterator::InitIteratorAnnotList(
818 818 CPDFSDK_PageView* pPageView,
819 } 819 CFX_PtrArray* pAnnotList) {
820 } 820 ASSERT(pPageView);
821 return (index <0) ? NULL : (CPDFSDK_Annot*)m_pIteratorAnnotList.GetAt(in dex); 821
822 } 822 if (pAnnotList == NULL) {
823 823 pAnnotList = pPageView->GetAnnotList();
824 824 }
825 CPDFSDK_Annot* CPDFSDK_AnnotIterator::PrevAnnot (int& index) 825
826 { 826 this->m_pIteratorAnnotList.RemoveAll();
827 827 if (!pAnnotList)
828 int nCount=m_pIteratorAnnotList.GetSize(); 828 return FALSE;
829 if(nCount<=0) index=-1; 829
830 else{ 830 CPDFSDK_Annot* pTopMostAnnot =
831 if(index<0){ 831 (m_bIgnoreTopmost) ? NULL : pPageView->GetFocusAnnot();
832 index=nCount-1; 832
833 } 833 int nCount = pAnnotList->GetSize();
834 else{ 834
835 if(m_bCircle){ 835 for (int i = nCount - 1; i >= 0; i--) {
836 index = ( index >0) ? (index-1) :nCount-1; 836 CPDFSDK_Annot* pReaderAnnot = (CPDFSDK_Annot*)pAnnotList->GetAt(i);
837 } 837 m_pIteratorAnnotList.Add(pReaderAnnot);
838 else{ 838 }
839 index = ( index >0) ? (index-1) :-1; 839
840 } 840 InsertSort(m_pIteratorAnnotList, &LyOrderCompare);
841 } 841
842 } 842 if (pTopMostAnnot) {
843 return (index <0) ? NULL : (CPDFSDK_Annot*)m_pIteratorAnnotList.GetAt(in dex); 843 for (int i = 0; i < nCount; i++) {
844 } 844 CPDFSDK_Annot* pReaderAnnot =
845 845 (CPDFSDK_Annot*)m_pIteratorAnnotList.GetAt(i);
846 846 if (pReaderAnnot == pTopMostAnnot) {
847 CPDFSDK_Annot*CPDFSDK_AnnotIterator::Next(const CPDFSDK_Annot* pCurrent) 847 m_pIteratorAnnotList.RemoveAt(i);
848 { 848 m_pIteratorAnnotList.InsertAt(0, pReaderAnnot);
849 849 break;
850 return (m_bReverse) ? PrevAnnot(pCurrent):NextAnnot(pCurrent); 850 }
851 851 }
852 } 852 }
853 853
854 CPDFSDK_Annot* CPDFSDK_AnnotIterator::Prev(const CPDFSDK_Annot* pCurrent) 854 return TRUE;
855 { 855 }
856
857 return (m_bReverse) ? NextAnnot(pCurrent):PrevAnnot(pCurrent);
858 }
859
860 CPDFSDK_Annot*CPDFSDK_AnnotIterator::Next(int& index )
861 {
862
863 return (m_bReverse) ? PrevAnnot(index):NextAnnot(index);
864
865 }
866
867 CPDFSDK_Annot* CPDFSDK_AnnotIterator::Prev(int& index )
868 {
869
870 return (m_bReverse) ? NextAnnot(index):PrevAnnot(index);
871 }
872
873
874 void CPDFSDK_AnnotIterator::InsertSort(CFX_PtrArray &arrayList, AI_COMPARE pComp are)
875 {
876 for (int i = 1; i < arrayList.GetSize(); i++)
877 {
878 if (pCompare((CPDFSDK_Annot*)(arrayList[i]) , (CPDFSDK_Annot*)(a rrayList[i-1])) < 0)
879 {
880 int j = i-1;
881 CPDFSDK_Annot* pTemp = (CPDFSDK_Annot*)arrayList[i];
882
883 do
884 {
885 arrayList[j + 1] = arrayList[j];
886 } while (--j >= 0 && pCompare(pTemp, (CPDFSDK_Annot*)arr ayList[j]) < 0);
887
888 arrayList[j+1] = pTemp;
889 }
890 }
891 }
892
893 int LyOrderCompare(CPDFSDK_Annot* p1, CPDFSDK_Annot* p2)
894 {
895 if(p1->GetLayoutOrder() < p2->GetLayoutOrder())
896 return -1;
897 else if (p1->GetLayoutOrder() == p2->GetLayoutOrder())
898 return 0;
899 else
900 return 1;
901 }
902
903 FX_BOOL CPDFSDK_AnnotIterator::InitIteratorAnnotList(CPDFSDK_PageView* pPageView ,CFX_PtrArray * pAnnotList)
904 {
905 ASSERT(pPageView);
906
907
908
909 if(pAnnotList==NULL){
910 pAnnotList=pPageView->GetAnnotList();
911 }
912
913 this->m_pIteratorAnnotList.RemoveAll();
914 if(!pAnnotList) return FALSE;
915
916 CPDFSDK_Annot * pTopMostAnnot= (m_bIgnoreTopmost) ? NULL : pPageView->Ge tFocusAnnot();
917
918
919 int nCount =pAnnotList->GetSize();
920
921 for(int i = nCount- 1 ;i >= 0;i--)
922 {
923 CPDFSDK_Annot * pReaderAnnot= (CPDFSDK_Annot*)pAnnotList->GetAt( i);
924 m_pIteratorAnnotList.Add(pReaderAnnot);
925 }
926
927 InsertSort(m_pIteratorAnnotList,&LyOrderCompare);
928
929 if(pTopMostAnnot)
930 {
931 for(int i=0 ;i<nCount;i++)
932 {
933 CPDFSDK_Annot * pReaderAnnot = (CPDFSDK_Annot*)m_pIterat orAnnotList.GetAt(i);
934 if(pReaderAnnot == pTopMostAnnot)
935 {
936 m_pIteratorAnnotList.RemoveAt(i);
937 m_pIteratorAnnotList.InsertAt(0, pReaderAnnot);
938 break;
939 }
940 }
941 }
942
943 return TRUE;
944 }
945
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698