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

Side by Side Diff: fpdfsdk/src/formfiller/FFL_FormFiller.cpp

Issue 1252613002: FX_BOOL considered harmful. (Closed) Base URL: https://pdfium.googlesource.com/pdfium.git@master
Patch Set: Manual edits. Created 5 years, 5 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 | « fpdfsdk/src/formfiller/FFL_ComboBox.cpp ('k') | fpdfsdk/src/formfiller/FFL_IFormFiller.cpp » ('j') | no next file with comments »
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 7
8 #include "../../include/formfiller/FFL_FormFiller.h" 8 #include "../../include/formfiller/FFL_FormFiller.h"
9 #include "../../include/formfiller/FFL_Notify.h" 9 #include "../../include/formfiller/FFL_Notify.h"
10 #include "../../include/formfiller/FFL_CBA_Fontmap.h" 10 #include "../../include/formfiller/FFL_CBA_Fontmap.h"
11 11
12 #define GetRed(rgb) ((uint8_t)(rgb)) 12 #define GetRed(rgb) ((uint8_t)(rgb))
13 #define GetGreen(rgb) ((uint8_t)(((FX_WORD)(rgb)) >> 8)) 13 #define GetGreen(rgb) ((uint8_t)(((FX_WORD)(rgb)) >> 8))
14 #define GetBlue(rgb) ((uint8_t)((rgb)>>16)) 14 #define GetBlue(rgb) ((uint8_t)((rgb)>>16))
15 15
16 #define FFL_HINT_ELAPSE 800 16 #define FFL_HINT_ELAPSE 800
17 17
18 /* ------------------------- CFFL_FormFiller ------------------------- */ 18 /* ------------------------- CFFL_FormFiller ------------------------- */
19 19
20 CFFL_FormFiller::CFFL_FormFiller(CPDFDoc_Environment* pApp, CPDFSDK_Annot* pAnno t) 20 CFFL_FormFiller::CFFL_FormFiller(CPDFDoc_Environment* pApp, CPDFSDK_Annot* pAnno t)
21 : m_pApp(pApp), 21 : m_pApp(pApp),
22 m_pAnnot(pAnnot), 22 m_pAnnot(pAnnot),
23 m_bValid(FALSE), 23 m_bValid(false),
24 m_ptOldPos(0,0) 24 m_ptOldPos(0,0)
25 { 25 {
26 m_pWidget = (CPDFSDK_Widget*) pAnnot; 26 m_pWidget = (CPDFSDK_Widget*) pAnnot;
27 } 27 }
28 28
29 CFFL_FormFiller::~CFFL_FormFiller() 29 CFFL_FormFiller::~CFFL_FormFiller()
30 { 30 {
31 for (auto& it : m_Maps) { 31 for (auto& it : m_Maps) {
32 CPWL_Wnd* pWnd = it.second; 32 CPWL_Wnd* pWnd = it.second;
33 CFFL_PrivateData* pData = (CFFL_PrivateData*)pWnd->GetAttachedData(); 33 CFFL_PrivateData* pData = (CFFL_PrivateData*)pWnd->GetAttachedData();
34 pWnd->Destroy(); 34 pWnd->Destroy();
35 delete pWnd; 35 delete pWnd;
36 delete pData; 36 delete pData;
37 } 37 }
38 m_Maps.clear(); 38 m_Maps.clear();
39 } 39 }
40 40
41 void CFFL_FormFiller::SetWindowRect(CPDFSDK_PageView* pPageView, const CPDF_Rect & rcWindow) 41 void CFFL_FormFiller::SetWindowRect(CPDFSDK_PageView* pPageView, const CPDF_Rect & rcWindow)
42 { 42 {
43 if (CPWL_Wnd* pWnd = GetPDFWindow(pPageView, FALSE)) 43 if (CPWL_Wnd* pWnd = GetPDFWindow(pPageView, false))
44 { 44 {
45 pWnd->Move(CPDF_Rect(rcWindow), TRUE, FALSE); 45 pWnd->Move(CPDF_Rect(rcWindow), true, false);
46 } 46 }
47 } 47 }
48 48
49 CPDF_Rect CFFL_FormFiller::GetWindowRect(CPDFSDK_PageView* pPageView) 49 CPDF_Rect CFFL_FormFiller::GetWindowRect(CPDFSDK_PageView* pPageView)
50 { 50 {
51 if (CPWL_Wnd* pWnd = GetPDFWindow(pPageView, FALSE)) 51 if (CPWL_Wnd* pWnd = GetPDFWindow(pPageView, false))
52 { 52 {
53 return pWnd->GetWindowRect(); 53 return pWnd->GetWindowRect();
54 } 54 }
55 55
56 return CPDF_Rect(0,0,0,0); 56 return CPDF_Rect(0,0,0,0);
57 } 57 }
58 58
59 FX_RECT CFFL_FormFiller::GetViewBBox(CPDFSDK_PageView *pPageView, CPDFSDK_Annot* pAnnot) 59 FX_RECT CFFL_FormFiller::GetViewBBox(CPDFSDK_PageView *pPageView, CPDFSDK_Annot* pAnnot)
60 { 60 {
61 ASSERT(pPageView != NULL); 61 ASSERT(pPageView != NULL);
62 ASSERT(pAnnot != NULL); 62 ASSERT(pAnnot != NULL);
63 63
64 CPDF_Rect rcAnnot = m_pWidget->GetRect(); 64 CPDF_Rect rcAnnot = m_pWidget->GetRect();
65 65
66 if (CPWL_Wnd* pWnd = GetPDFWindow(pPageView, FALSE)) 66 if (CPWL_Wnd* pWnd = GetPDFWindow(pPageView, false))
67 { 67 {
68 CPDF_Rect rcWindow = pWnd->GetWindowRect(); 68 CPDF_Rect rcWindow = pWnd->GetWindowRect();
69 rcAnnot = PWLtoFFL(rcWindow); 69 rcAnnot = PWLtoFFL(rcWindow);
70 } 70 }
71 71
72 CPDF_Rect rcWin = rcAnnot; 72 CPDF_Rect rcWin = rcAnnot;
73 73
74 CPDF_Rect rcFocus = GetFocusBox(pPageView); 74 CPDF_Rect rcFocus = GetFocusBox(pPageView);
75 if (!rcFocus.IsEmpty()) 75 if (!rcFocus.IsEmpty())
76 rcWin.Union(rcFocus); 76 rcWin.Union(rcFocus);
77 77
78 CPDF_Rect rect = CPWL_Utils::InflateRect(rcWin,1); 78 CPDF_Rect rect = CPWL_Utils::InflateRect(rcWin,1);
79 79
80 return rect.GetOutterRect(); 80 return rect.GetOutterRect();
81 } 81 }
82 82
83 void CFFL_FormFiller::OnDraw(CPDFSDK_PageView *pPageView, CPDFSDK_Annot* pAnnot, 83 void CFFL_FormFiller::OnDraw(CPDFSDK_PageView *pPageView, CPDFSDK_Annot* pAnnot,
84 CFX_RenderDevice* pDevice, CPDF_Matrix* pUser2Devic e, 84 CFX_RenderDevice* pDevice, CPDF_Matrix* pUser2Devic e,
85 FX_DWORD dwFlags) 85 FX_DWORD dwFlags)
86 { 86 {
87 ASSERT(pAnnot->GetPDFAnnot()->GetSubType() == "Widget"); 87 ASSERT(pAnnot->GetPDFAnnot()->GetSubType() == "Widget");
88 88
89 if (CPWL_Wnd * pWnd = GetPDFWindow(pPageView, FALSE)) 89 if (CPWL_Wnd * pWnd = GetPDFWindow(pPageView, false))
90 { 90 {
91 CPDF_Matrix mt = GetCurMatrix(); 91 CPDF_Matrix mt = GetCurMatrix();
92 mt.Concat(*pUser2Device); 92 mt.Concat(*pUser2Device);
93 pWnd->DrawAppearance(pDevice,&mt); 93 pWnd->DrawAppearance(pDevice,&mt);
94 } 94 }
95 else 95 else
96 { 96 {
97 CPDFSDK_Widget* pWidget = (CPDFSDK_Widget*)pAnnot; 97 CPDFSDK_Widget* pWidget = (CPDFSDK_Widget*)pAnnot;
98 if (CFFL_IFormFiller::IsVisible(pWidget)) 98 if (CFFL_IFormFiller::IsVisible(pWidget))
99 pWidget->DrawAppearance(pDevice, pUser2Device, CPDF_Annot::Normal, N ULL); 99 pWidget->DrawAppearance(pDevice, pUser2Device, CPDF_Annot::Normal, N ULL);
(...skipping 24 matching lines...) Expand all
124 void CFFL_FormFiller::OnMouseEnter(CPDFSDK_PageView *pPageView, CPDFSDK_Annot* p Annot) 124 void CFFL_FormFiller::OnMouseEnter(CPDFSDK_PageView *pPageView, CPDFSDK_Annot* p Annot)
125 { 125 {
126 } 126 }
127 127
128 void CFFL_FormFiller::OnMouseExit(CPDFSDK_PageView *pPageView, CPDFSDK_Annot* pA nnot) 128 void CFFL_FormFiller::OnMouseExit(CPDFSDK_PageView *pPageView, CPDFSDK_Annot* pA nnot)
129 { 129 {
130 EndTimer(); 130 EndTimer();
131 ASSERT(m_pWidget != NULL); 131 ASSERT(m_pWidget != NULL);
132 } 132 }
133 133
134 FX_BOOL CFFL_FormFiller::OnLButtonDown(CPDFSDK_PageView *pPageView, CPDFSDK_Anno t* pAnnot, FX_UINT nFlags, const CPDF_Point& point) 134 bool CFFL_FormFiller::OnLButtonDown(CPDFSDK_PageView *pPageView, CPDFSDK_Annot* pAnnot, FX_UINT nFlags, const CPDF_Point& point)
135 { 135 {
136 if (CPWL_Wnd * pWnd = GetPDFWindow(pPageView, TRUE)) 136 if (CPWL_Wnd * pWnd = GetPDFWindow(pPageView, true))
137 { 137 {
138 m_bValid = TRUE; 138 m_bValid = true;
139 FX_RECT rect = GetViewBBox(pPageView,pAnnot); 139 FX_RECT rect = GetViewBBox(pPageView,pAnnot);
140 InvalidateRect(rect.left, rect.top, rect.right, rect.bottom); 140 InvalidateRect(rect.left, rect.top, rect.right, rect.bottom);
141 141
142 if(!rect.Contains((int)point.x, (int)point.y)) 142 if(!rect.Contains((int)point.x, (int)point.y))
143 return FALSE; 143 return false;
144 144
145 return pWnd->OnLButtonDown(WndtoPWL(pPageView, point),nFlags); 145 return pWnd->OnLButtonDown(WndtoPWL(pPageView, point),nFlags);
146 } 146 }
147 147
148 return FALSE; 148 return false;
149 } 149 }
150 150
151 FX_BOOL CFFL_FormFiller::OnLButtonUp(CPDFSDK_PageView *pPageView, CPDFSDK_Annot* pAnnot, FX_UINT nFlags, const CPDF_Point& point) 151 bool CFFL_FormFiller::OnLButtonUp(CPDFSDK_PageView *pPageView, CPDFSDK_Annot* pA nnot, FX_UINT nFlags, const CPDF_Point& point)
152 { 152 {
153 if (CPWL_Wnd * pWnd = GetPDFWindow(pPageView, FALSE)) 153 if (CPWL_Wnd * pWnd = GetPDFWindow(pPageView, false))
154 { 154 {
155 FX_RECT rcFFL = GetViewBBox(pPageView, pAnnot); 155 FX_RECT rcFFL = GetViewBBox(pPageView, pAnnot);
156 InvalidateRect(rcFFL.left, rcFFL.top, rcFFL.right, rcFFL.bottom); 156 InvalidateRect(rcFFL.left, rcFFL.top, rcFFL.right, rcFFL.bottom);
157 pWnd->OnLButtonUp(WndtoPWL(pPageView, point),nFlags); 157 pWnd->OnLButtonUp(WndtoPWL(pPageView, point),nFlags);
158 return TRUE; 158 return true;
159 } 159 }
160 160
161 return FALSE; 161 return false;
162 } 162 }
163 163
164 FX_BOOL CFFL_FormFiller::OnLButtonDblClk(CPDFSDK_PageView *pPageView, CPDFSDK_An not* pAnnot, FX_UINT nFlags, const CPDF_Point& point) 164 bool CFFL_FormFiller::OnLButtonDblClk(CPDFSDK_PageView *pPageView, CPDFSDK_Annot * pAnnot, FX_UINT nFlags, const CPDF_Point& point)
165 { 165 {
166 if (CPWL_Wnd * pWnd = GetPDFWindow(pPageView, FALSE)) 166 if (CPWL_Wnd * pWnd = GetPDFWindow(pPageView, false))
167 { 167 {
168 pWnd->OnLButtonDblClk(WndtoPWL(pPageView, point),nFlags); 168 pWnd->OnLButtonDblClk(WndtoPWL(pPageView, point),nFlags);
169 return TRUE; 169 return true;
170 } 170 }
171 171
172 return FALSE; 172 return false;
173 } 173 }
174 174
175 FX_BOOL CFFL_FormFiller::OnMouseMove(CPDFSDK_PageView *pPageView, CPDFSDK_Annot* pAnnot, FX_UINT nFlags, const CPDF_Point& point) 175 bool CFFL_FormFiller::OnMouseMove(CPDFSDK_PageView *pPageView, CPDFSDK_Annot* pA nnot, FX_UINT nFlags, const CPDF_Point& point)
176 { 176 {
177 if ((m_ptOldPos.x != point.x) || (m_ptOldPos.y != point.y)) 177 if ((m_ptOldPos.x != point.x) || (m_ptOldPos.y != point.y))
178 { 178 {
179 m_ptOldPos = point; 179 m_ptOldPos = point;
180 } 180 }
181 181
182 if (CPWL_Wnd * pWnd = GetPDFWindow(pPageView, FALSE)) 182 if (CPWL_Wnd * pWnd = GetPDFWindow(pPageView, false))
183 { 183 {
184 pWnd->OnMouseMove(WndtoPWL(pPageView, point),nFlags); 184 pWnd->OnMouseMove(WndtoPWL(pPageView, point),nFlags);
185 return TRUE; 185 return true;
186 } 186 }
187 187
188 return FALSE; 188 return false;
189 } 189 }
190 190
191 FX_BOOL CFFL_FormFiller::OnMouseWheel(CPDFSDK_PageView *pPageView, CPDFSDK_Annot * pAnnot, FX_UINT nFlags, short zDelta, const CPDF_Point& point) 191 bool CFFL_FormFiller::OnMouseWheel(CPDFSDK_PageView *pPageView, CPDFSDK_Annot* p Annot, FX_UINT nFlags, short zDelta, const CPDF_Point& point)
192 { 192 {
193 if (!IsValid()) return FALSE; 193 if (!IsValid()) return false;
194 194
195 if (CPWL_Wnd * pWnd = GetPDFWindow(pPageView, TRUE)) 195 if (CPWL_Wnd * pWnd = GetPDFWindow(pPageView, true))
196 { 196 {
197 return pWnd->OnMouseWheel(zDelta, WndtoPWL(pPageView, point),nFlags); 197 return pWnd->OnMouseWheel(zDelta, WndtoPWL(pPageView, point),nFlags);
198 } 198 }
199 199
200 return FALSE; 200 return false;
201 } 201 }
202 202
203 FX_BOOL CFFL_FormFiller::OnRButtonDown(CPDFSDK_PageView *pPageView, CPDFSDK_Anno t* pAnnot, FX_UINT nFlags, const CPDF_Point& point) 203 bool CFFL_FormFiller::OnRButtonDown(CPDFSDK_PageView *pPageView, CPDFSDK_Annot* pAnnot, FX_UINT nFlags, const CPDF_Point& point)
204 { 204 {
205 if (CPWL_Wnd * pWnd = GetPDFWindow(pPageView, TRUE)) 205 if (CPWL_Wnd * pWnd = GetPDFWindow(pPageView, true))
206 { 206 {
207 pWnd->OnRButtonDown(WndtoPWL(pPageView, point),nFlags); 207 pWnd->OnRButtonDown(WndtoPWL(pPageView, point),nFlags);
208 return TRUE; 208 return true;
209 } 209 }
210 210
211 return FALSE; 211 return false;
212 } 212 }
213 213
214 FX_BOOL CFFL_FormFiller::OnRButtonUp(CPDFSDK_PageView *pPageView, CPDFSDK_Annot* pAnnot, FX_UINT nFlags, const CPDF_Point& point) 214 bool CFFL_FormFiller::OnRButtonUp(CPDFSDK_PageView *pPageView, CPDFSDK_Annot* pA nnot, FX_UINT nFlags, const CPDF_Point& point)
215 { 215 {
216 if (CPWL_Wnd * pWnd = GetPDFWindow(pPageView, FALSE)) 216 if (CPWL_Wnd * pWnd = GetPDFWindow(pPageView, false))
217 { 217 {
218 pWnd->OnRButtonUp(WndtoPWL(pPageView, point),nFlags); 218 pWnd->OnRButtonUp(WndtoPWL(pPageView, point),nFlags);
219 return TRUE; 219 return true;
220 } 220 }
221 221
222 return FALSE; 222 return false;
223 } 223 }
224 224
225 FX_BOOL CFFL_FormFiller::OnKeyDown(CPDFSDK_Annot* pAnnot, FX_UINT nKeyCode, FX_U INT nFlags) 225 bool CFFL_FormFiller::OnKeyDown(CPDFSDK_Annot* pAnnot, FX_UINT nKeyCode, FX_UINT nFlags)
226 { 226 {
227 if (IsValid()) 227 if (IsValid())
228 { 228 {
229 CPDFSDK_PageView* pPageView = GetCurPageView(); 229 CPDFSDK_PageView* pPageView = GetCurPageView();
230 ASSERT(pPageView != NULL); 230 ASSERT(pPageView != NULL);
231 231
232 if (CPWL_Wnd * pWnd = GetPDFWindow(pPageView, FALSE)) 232 if (CPWL_Wnd * pWnd = GetPDFWindow(pPageView, false))
233 { 233 {
234 return pWnd->OnKeyDown(nKeyCode,nFlags); 234 return pWnd->OnKeyDown(nKeyCode,nFlags);
235 } 235 }
236 } 236 }
237 237
238 return FALSE; 238 return false;
239 } 239 }
240 240
241 FX_BOOL CFFL_FormFiller::OnChar(CPDFSDK_Annot* pAnnot, FX_UINT nChar, FX_UINT nF lags) 241 bool CFFL_FormFiller::OnChar(CPDFSDK_Annot* pAnnot, FX_UINT nChar, FX_UINT nFlag s)
242 { 242 {
243 if (IsValid()) 243 if (IsValid())
244 { 244 {
245 CPDFSDK_PageView* pPageView = GetCurPageView(); 245 CPDFSDK_PageView* pPageView = GetCurPageView();
246 ASSERT(pPageView != NULL); 246 ASSERT(pPageView != NULL);
247 247
248 if (CPWL_Wnd * pWnd = GetPDFWindow(pPageView, FALSE)) 248 if (CPWL_Wnd * pWnd = GetPDFWindow(pPageView, false))
249 { 249 {
250 return pWnd->OnChar(nChar,nFlags); 250 return pWnd->OnChar(nChar,nFlags);
251 } 251 }
252 } 252 }
253 253
254 return FALSE; 254 return false;
255 } 255 }
256 256
257 FX_BOOL CFFL_FormFiller::OnSetFocus(CPDFSDK_Annot* pAnnot, FX_UINT nFlag) 257 bool CFFL_FormFiller::OnSetFocus(CPDFSDK_Annot* pAnnot, FX_UINT nFlag)
258 { 258 {
259 CPDFSDK_Widget* pWidget = (CPDFSDK_Widget*)pAnnot; 259 CPDFSDK_Widget* pWidget = (CPDFSDK_Widget*)pAnnot;
260 CPDF_Page* pPage = pWidget->GetPDFPage(); 260 CPDF_Page* pPage = pWidget->GetPDFPage();
261 CPDFSDK_Document* pDoc = m_pApp->GetSDKDocument(); 261 CPDFSDK_Document* pDoc = m_pApp->GetSDKDocument();
262 CPDFSDK_PageView* pPageView = pDoc->GetPageView(pPage); 262 CPDFSDK_PageView* pPageView = pDoc->GetPageView(pPage);
263 if (CPWL_Wnd* pWnd = GetPDFWindow(pPageView, TRUE)) 263 if (CPWL_Wnd* pWnd = GetPDFWindow(pPageView, true))
264 pWnd->SetFocus(); 264 pWnd->SetFocus();
265 265
266 m_bValid = TRUE; 266 m_bValid = true;
267 FX_RECT rcRect = GetViewBBox(pPageView,pAnnot); 267 FX_RECT rcRect = GetViewBBox(pPageView,pAnnot);
268 InvalidateRect(rcRect.left, rcRect.top, rcRect.right, rcRect.bottom); 268 InvalidateRect(rcRect.left, rcRect.top, rcRect.right, rcRect.bottom);
269 return TRUE; 269 return true;
270 } 270 }
271 271
272 FX_BOOL CFFL_FormFiller::OnKillFocus(CPDFSDK_Annot* pAnnot, FX_UINT nFlag) 272 bool CFFL_FormFiller::OnKillFocus(CPDFSDK_Annot* pAnnot, FX_UINT nFlag)
273 { 273 {
274 if (!IsValid()) 274 if (!IsValid())
275 return TRUE; 275 return true;
276 276
277 CPDFSDK_PageView* pPageView = GetCurPageView(); 277 CPDFSDK_PageView* pPageView = GetCurPageView();
278 CommitData(pPageView, nFlag); 278 CommitData(pPageView, nFlag);
279 279
280 if (CPWL_Wnd* pWnd = GetPDFWindow(pPageView, FALSE)) 280 if (CPWL_Wnd* pWnd = GetPDFWindow(pPageView, false))
281 pWnd->KillFocus(); 281 pWnd->KillFocus();
282 282
283 switch (m_pWidget->GetFieldType()) 283 switch (m_pWidget->GetFieldType())
284 { 284 {
285 case FIELDTYPE_PUSHBUTTON: 285 case FIELDTYPE_PUSHBUTTON:
286 case FIELDTYPE_CHECKBOX: 286 case FIELDTYPE_CHECKBOX:
287 case FIELDTYPE_RADIOBUTTON: 287 case FIELDTYPE_RADIOBUTTON:
288 EscapeFiller(pPageView, TRUE); 288 EscapeFiller(pPageView, true);
289 break; 289 break;
290 default: 290 default:
291 EscapeFiller(pPageView, FALSE); 291 EscapeFiller(pPageView, false);
292 break; 292 break;
293 } 293 }
294 return TRUE; 294 return true;
295 } 295 }
296 296
297 FX_BOOL CFFL_FormFiller::IsValid() const 297 bool CFFL_FormFiller::IsValid() const
298 { 298 {
299 return m_bValid; 299 return m_bValid;
300 } 300 }
301 301
302 PWL_CREATEPARAM CFFL_FormFiller::GetCreateParam() 302 PWL_CREATEPARAM CFFL_FormFiller::GetCreateParam()
303 { 303 {
304 ASSERT(m_pApp != NULL); 304 ASSERT(m_pApp != NULL);
305 305
306 PWL_CREATEPARAM cp; 306 PWL_CREATEPARAM cp;
307 cp.pParentWnd = NULL; 307 cp.pParentWnd = NULL;
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
363 if (cp.fFontSize <= 0) 363 if (cp.fFontSize <= 0)
364 { 364 {
365 dwCreateFlags |= PWS_AUTOFONTSIZE; 365 dwCreateFlags |= PWS_AUTOFONTSIZE;
366 } 366 }
367 367
368 cp.dwFlags = dwCreateFlags; 368 cp.dwFlags = dwCreateFlags;
369 cp.pSystemHandler = m_pApp->GetSysHandler(); 369 cp.pSystemHandler = m_pApp->GetSysHandler();
370 return cp; 370 return cp;
371 } 371 }
372 372
373 CPWL_Wnd* CFFL_FormFiller::GetPDFWindow(CPDFSDK_PageView* pPageView, FX_BOOL bNe w) 373 CPWL_Wnd* CFFL_FormFiller::GetPDFWindow(CPDFSDK_PageView* pPageView, bool bNew)
374 { 374 {
375 ASSERT(pPageView); 375 ASSERT(pPageView);
376 376
377 auto it = m_Maps.find(pPageView); 377 auto it = m_Maps.find(pPageView);
378 const bool found = it != m_Maps.end(); 378 const bool found = it != m_Maps.end();
379 CPWL_Wnd* pWnd = found ? it->second : nullptr; 379 CPWL_Wnd* pWnd = found ? it->second : nullptr;
380 if (!bNew) 380 if (!bNew)
381 return pWnd; 381 return pWnd;
382 382
383 if (found) { 383 if (found) {
(...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after
492 492
493 CPDFSDK_PageView* CFFL_FormFiller::GetCurPageView() 493 CPDFSDK_PageView* CFFL_FormFiller::GetCurPageView()
494 { 494 {
495 CPDF_Page* pPage = m_pAnnot->GetPDFPage(); 495 CPDF_Page* pPage = m_pAnnot->GetPDFPage();
496 CPDFSDK_Document* pSDKDoc = m_pApp->GetSDKDocument(); 496 CPDFSDK_Document* pSDKDoc = m_pApp->GetSDKDocument();
497 return pSDKDoc ? pSDKDoc->GetPageView(pPage) : nullptr; 497 return pSDKDoc ? pSDKDoc->GetPageView(pPage) : nullptr;
498 } 498 }
499 499
500 CPDF_Rect CFFL_FormFiller::GetFocusBox(CPDFSDK_PageView* pPageView) 500 CPDF_Rect CFFL_FormFiller::GetFocusBox(CPDFSDK_PageView* pPageView)
501 { 501 {
502 if (CPWL_Wnd* pWnd = GetPDFWindow(pPageView, FALSE)) 502 if (CPWL_Wnd* pWnd = GetPDFWindow(pPageView, false))
503 { 503 {
504 CPDF_Rect rcFocus = FFLtoWnd(pPageView, PWLtoFFL(pWnd->GetFocusRect())); 504 CPDF_Rect rcFocus = FFLtoWnd(pPageView, PWLtoFFL(pWnd->GetFocusRect()));
505 CPDF_Rect rcPage = pPageView->GetPDFPage()->GetPageBBox(); 505 CPDF_Rect rcPage = pPageView->GetPDFPage()->GetPageBBox();
506 if (rcPage.Contains(rcFocus)) 506 if (rcPage.Contains(rcFocus))
507 return rcFocus; 507 return rcFocus;
508 } 508 }
509 return CPDF_Rect(0,0,0,0); 509 return CPDF_Rect(0,0,0,0);
510 } 510 }
511 511
512 CPDF_Rect CFFL_FormFiller::FFLtoPWL(const CPDF_Rect& rect) 512 CPDF_Rect CFFL_FormFiller::FFLtoPWL(const CPDF_Rect& rect)
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
554 CPDF_Point CFFL_FormFiller::WndtoPWL(CPDFSDK_PageView* pPageView, const CPDF_Poi nt& pt) 554 CPDF_Point CFFL_FormFiller::WndtoPWL(CPDFSDK_PageView* pPageView, const CPDF_Poi nt& pt)
555 { 555 {
556 return FFLtoPWL(pt); 556 return FFLtoPWL(pt);
557 } 557 }
558 558
559 CPDF_Rect CFFL_FormFiller::FFLtoWnd(CPDFSDK_PageView* pPageView, const CPDF_Rect & rect) 559 CPDF_Rect CFFL_FormFiller::FFLtoWnd(CPDFSDK_PageView* pPageView, const CPDF_Rect & rect)
560 { 560 {
561 return rect; 561 return rect;
562 } 562 }
563 563
564 FX_BOOL CFFL_FormFiller::CommitData(CPDFSDK_PageView* pPageView, FX_UINT nFlag) 564 bool CFFL_FormFiller::CommitData(CPDFSDK_PageView* pPageView, FX_UINT nFlag)
565 { 565 {
566 if (IsDataChanged(pPageView)) 566 if (IsDataChanged(pPageView))
567 { 567 {
568 FX_BOOL bRC = TRUE; 568 bool bRC = true;
569 FX_BOOL bExit = FALSE; 569 bool bExit = false;
570 CFFL_IFormFiller* pIFormFiller = m_pApp->GetIFormFiller(); 570 CFFL_IFormFiller* pIFormFiller = m_pApp->GetIFormFiller();
571 pIFormFiller->OnKeyStrokeCommit(m_pWidget, pPageView, bRC, bExit, nFlag) ; 571 pIFormFiller->OnKeyStrokeCommit(m_pWidget, pPageView, bRC, bExit, nFlag) ;
572 if (bExit) 572 if (bExit)
573 return TRUE; 573 return true;
574 if (!bRC) 574 if (!bRC)
575 { 575 {
576 ResetPDFWindow(pPageView, FALSE); 576 ResetPDFWindow(pPageView, false);
577 return TRUE; 577 return true;
578 } 578 }
579 579
580 pIFormFiller->OnValidate(m_pWidget, pPageView, bRC, bExit, nFlag); 580 pIFormFiller->OnValidate(m_pWidget, pPageView, bRC, bExit, nFlag);
581 if (bExit) 581 if (bExit)
582 return TRUE; 582 return true;
583 if (!bRC) 583 if (!bRC)
584 { 584 {
585 ResetPDFWindow(pPageView, FALSE); 585 ResetPDFWindow(pPageView, false);
586 return TRUE; 586 return true;
587 } 587 }
588 588
589 SaveData(pPageView); 589 SaveData(pPageView);
590 pIFormFiller->OnCalculate(m_pWidget, pPageView, bExit,nFlag); 590 pIFormFiller->OnCalculate(m_pWidget, pPageView, bExit,nFlag);
591 if (bExit) 591 if (bExit)
592 return TRUE; 592 return true;
593 593
594 pIFormFiller->OnFormat(m_pWidget, pPageView, bExit,nFlag); 594 pIFormFiller->OnFormat(m_pWidget, pPageView, bExit,nFlag);
595 } 595 }
596 return TRUE; 596 return true;
597 } 597 }
598 598
599 FX_BOOL CFFL_FormFiller::IsDataChanged(CPDFSDK_PageView* pPageView) 599 bool CFFL_FormFiller::IsDataChanged(CPDFSDK_PageView* pPageView)
600 { 600 {
601 return FALSE; 601 return false;
602 } 602 }
603 603
604 void CFFL_FormFiller::SaveData(CPDFSDK_PageView* pPageView) 604 void CFFL_FormFiller::SaveData(CPDFSDK_PageView* pPageView)
605 { 605 {
606 } 606 }
607 607
608 void CFFL_FormFiller::GetKeyStrokeData(CPDFSDK_PageView* pPageView, FFL_KeyStrok eData& data) 608 void CFFL_FormFiller::GetKeyStrokeData(CPDFSDK_PageView* pPageView, FFL_KeyStrok eData& data)
609 { 609 {
610 } 610 }
611 611
612 void CFFL_FormFiller::SetChangeMark() 612 void CFFL_FormFiller::SetChangeMark()
613 { 613 {
614 m_pApp->FFI_OnChange(); 614 m_pApp->FFI_OnChange();
615 } 615 }
616 616
617 void CFFL_FormFiller::GetActionData(CPDFSDK_PageView* pPageView, CPDF_AAction::A ActionType type, 617 void CFFL_FormFiller::GetActionData(CPDFSDK_PageView* pPageView, CPDF_AAction::A ActionType type,
618 PDFSDK_FieldAction& fa) 618 PDFSDK_FieldAction& fa)
619 { 619 {
620 fa.sValue = m_pWidget->GetValue(); 620 fa.sValue = m_pWidget->GetValue();
621 } 621 }
622 622
623 void CFFL_FormFiller::SetActionData(CPDFSDK_PageView* pPageView, CPDF_AAction::A ActionType type, 623 void CFFL_FormFiller::SetActionData(CPDFSDK_PageView* pPageView, CPDF_AAction::A ActionType type,
624 const PDFSDK_FieldAction& fa) 624 const PDFSDK_FieldAction& fa)
625 { 625 {
626 } 626 }
627 627
628 FX_BOOL CFFL_FormFiller::IsActionDataChanged(CPDF_AAction::AActionType type, con st PDFSDK_FieldAction& faOld, 628 bool CFFL_FormFiller::IsActionDataChanged(CPDF_AAction::AActionType type, const PDFSDK_FieldAction& faOld,
629 const PDFSDK_FieldAction& faNew) 629 const PDFSDK_FieldAction& faNew)
630 { 630 {
631 return FALSE; 631 return false;
632 } 632 }
633 633
634 void CFFL_FormFiller::SaveState(CPDFSDK_PageView* pPageView) 634 void CFFL_FormFiller::SaveState(CPDFSDK_PageView* pPageView)
635 { 635 {
636 } 636 }
637 637
638 void CFFL_FormFiller::RestoreState(CPDFSDK_PageView* pPageView) 638 void CFFL_FormFiller::RestoreState(CPDFSDK_PageView* pPageView)
639 { 639 {
640 } 640 }
641 641
642 CPWL_Wnd* CFFL_FormFiller::ResetPDFWindow(CPDFSDK_PageView* pPageView, FX_BOOL bRestoreValue) 642 CPWL_Wnd* CFFL_FormFiller::ResetPDFWindow(CPDFSDK_PageView* pPageView, bool bRe storeValue)
643 { 643 {
644 return GetPDFWindow(pPageView, FALSE); 644 return GetPDFWindow(pPageView, false);
645 } 645 }
646 646
647 void CFFL_FormFiller::TimerProc() 647 void CFFL_FormFiller::TimerProc()
648 { 648 {
649 649
650 } 650 }
651 651
652 IFX_SystemHandler* CFFL_FormFiller::GetSystemHandler() const 652 IFX_SystemHandler* CFFL_FormFiller::GetSystemHandler() const
653 { 653 {
654 return m_pApp->GetSysHandler(); 654 return m_pApp->GetSysHandler();
655 } 655 }
656 656
657 void CFFL_FormFiller::OnKeyStroke(FX_BOOL bKeyDown) 657 void CFFL_FormFiller::OnKeyStroke(bool bKeyDown)
658 { 658 {
659 } 659 }
660 660
661 void CFFL_FormFiller::EscapeFiller(CPDFSDK_PageView* pPageView, FX_BOOL bDestroy PDFWindow) 661 void CFFL_FormFiller::EscapeFiller(CPDFSDK_PageView* pPageView, bool bDestroyPDF Window)
662 { 662 {
663 m_bValid = FALSE; 663 m_bValid = false;
664 664
665 FX_RECT rcRect = GetViewBBox(pPageView, m_pWidget); 665 FX_RECT rcRect = GetViewBBox(pPageView, m_pWidget);
666 InvalidateRect(rcRect.left, rcRect.top, rcRect.right, rcRect.bottom); 666 InvalidateRect(rcRect.left, rcRect.top, rcRect.right, rcRect.bottom);
667 667
668 if(bDestroyPDFWindow) 668 if(bDestroyPDFWindow)
669 DestroyPDFWindow(pPageView); 669 DestroyPDFWindow(pPageView);
670 } 670 }
671 671
672 FX_BOOL CFFL_FormFiller::CanCopy(CPDFSDK_Document* pDocument) 672 bool CFFL_FormFiller::CanCopy(CPDFSDK_Document* pDocument)
673 { 673 {
674 return FALSE; 674 return false;
675 } 675 }
676 676
677 FX_BOOL CFFL_FormFiller::CanCut(CPDFSDK_Document* pDocument) 677 bool CFFL_FormFiller::CanCut(CPDFSDK_Document* pDocument)
678 { 678 {
679 return FALSE; 679 return false;
680 } 680 }
681 681
682 FX_BOOL CFFL_FormFiller::CanPaste(CPDFSDK_Document* pDocument) 682 bool CFFL_FormFiller::CanPaste(CPDFSDK_Document* pDocument)
683 { 683 {
684 return FALSE; 684 return false;
685 } 685 }
686 686
687 void CFFL_FormFiller::DoCopy(CPDFSDK_Document* pDocument) 687 void CFFL_FormFiller::DoCopy(CPDFSDK_Document* pDocument)
688 { 688 {
689 } 689 }
690 690
691 void CFFL_FormFiller::DoCut(CPDFSDK_Document* pDocument) 691 void CFFL_FormFiller::DoCut(CPDFSDK_Document* pDocument)
692 { 692 {
693 } 693 }
694 694
695 void CFFL_FormFiller::DoPaste(CPDFSDK_Document* pDocument) 695 void CFFL_FormFiller::DoPaste(CPDFSDK_Document* pDocument)
696 { 696 {
697 } 697 }
698 698
699 void CFFL_FormFiller::InvalidateRect(double left, double top, double right, doub le bottom) 699 void CFFL_FormFiller::InvalidateRect(double left, double top, double right, doub le bottom)
700 { 700 {
701 CPDF_Page * pPage = m_pWidget->GetPDFPage(); 701 CPDF_Page * pPage = m_pWidget->GetPDFPage();
702 m_pApp->FFI_Invalidate(pPage, left, top, right, bottom); 702 m_pApp->FFI_Invalidate(pPage, left, top, right, bottom);
703 } 703 }
704 704
705 /* ------------------------- CFFL_Button ------------------------- */ 705 /* ------------------------- CFFL_Button ------------------------- */
706 706
707 CFFL_Button::CFFL_Button(CPDFDoc_Environment* pApp, CPDFSDK_Annot* pWidget) : 707 CFFL_Button::CFFL_Button(CPDFDoc_Environment* pApp, CPDFSDK_Annot* pWidget) :
708 CFFL_FormFiller(pApp, pWidget), 708 CFFL_FormFiller(pApp, pWidget),
709 m_bMouseIn(FALSE), 709 m_bMouseIn(false),
710 m_bMouseDown(FALSE) 710 m_bMouseDown(false)
711 { 711 {
712 } 712 }
713 713
714 CFFL_Button::~CFFL_Button() 714 CFFL_Button::~CFFL_Button()
715 { 715 {
716 } 716 }
717 717
718 void CFFL_Button::OnMouseEnter(CPDFSDK_PageView *pPageView, CPDFSDK_Annot* pAnno t) 718 void CFFL_Button::OnMouseEnter(CPDFSDK_PageView *pPageView, CPDFSDK_Annot* pAnno t)
719 { 719 {
720 m_bMouseIn = TRUE; 720 m_bMouseIn = true;
721 FX_RECT rect = GetViewBBox(pPageView,pAnnot); 721 FX_RECT rect = GetViewBBox(pPageView,pAnnot);
722 InvalidateRect(rect.left, rect.top, rect.right, rect.bottom); 722 InvalidateRect(rect.left, rect.top, rect.right, rect.bottom);
723 } 723 }
724 724
725 void CFFL_Button::OnMouseExit(CPDFSDK_PageView *pPageView, CPDFSDK_Annot* pAnnot ) 725 void CFFL_Button::OnMouseExit(CPDFSDK_PageView *pPageView, CPDFSDK_Annot* pAnnot )
726 { 726 {
727 m_bMouseIn = FALSE; 727 m_bMouseIn = false;
728 728
729 FX_RECT rect = GetViewBBox(pPageView,pAnnot); 729 FX_RECT rect = GetViewBBox(pPageView,pAnnot);
730 InvalidateRect(rect.left, rect.top, rect.right, rect.bottom); 730 InvalidateRect(rect.left, rect.top, rect.right, rect.bottom);
731 EndTimer(); 731 EndTimer();
732 ASSERT(m_pWidget != NULL); 732 ASSERT(m_pWidget != NULL);
733 } 733 }
734 734
735 FX_BOOL CFFL_Button::OnLButtonDown(CPDFSDK_PageView *pPageView, CPDFSDK_Annot* p Annot, FX_UINT nFlags, const CPDF_Point& point) 735 bool CFFL_Button::OnLButtonDown(CPDFSDK_PageView *pPageView, CPDFSDK_Annot* pAnn ot, FX_UINT nFlags, const CPDF_Point& point)
736 { 736 {
737 CPDF_Rect rcAnnot = pAnnot->GetRect(); 737 CPDF_Rect rcAnnot = pAnnot->GetRect();
738 if(!rcAnnot.Contains(point.x, point.y)) 738 if(!rcAnnot.Contains(point.x, point.y))
739 return FALSE; 739 return false;
740 740
741 m_bMouseDown = TRUE; 741 m_bMouseDown = true;
742 m_bValid = TRUE; 742 m_bValid = true;
743 FX_RECT rect = GetViewBBox(pPageView, pAnnot); 743 FX_RECT rect = GetViewBBox(pPageView, pAnnot);
744 InvalidateRect(rect.left, rect.top, rect.right, rect.bottom); 744 InvalidateRect(rect.left, rect.top, rect.right, rect.bottom);
745 return TRUE; 745 return true;
746 } 746 }
747 747
748 FX_BOOL CFFL_Button::OnLButtonUp(CPDFSDK_PageView *pPageView, CPDFSDK_Annot* pAn not, FX_UINT nFlags, const CPDF_Point& point) 748 bool CFFL_Button::OnLButtonUp(CPDFSDK_PageView *pPageView, CPDFSDK_Annot* pAnnot , FX_UINT nFlags, const CPDF_Point& point)
749 { 749 {
750 CPDF_Rect rcAnnot = pAnnot->GetRect(); 750 CPDF_Rect rcAnnot = pAnnot->GetRect();
751 if(!rcAnnot.Contains(point.x, point.y)) 751 if(!rcAnnot.Contains(point.x, point.y))
752 return FALSE; 752 return false;
753 753
754 m_bMouseDown = FALSE; 754 m_bMouseDown = false;
755 m_pWidget->GetPDFPage(); 755 m_pWidget->GetPDFPage();
756 756
757 757
758 FX_RECT rect = GetViewBBox(pPageView, pAnnot); 758 FX_RECT rect = GetViewBBox(pPageView, pAnnot);
759 InvalidateRect(rect.left, rect.top, rect.right, rect.bottom); 759 InvalidateRect(rect.left, rect.top, rect.right, rect.bottom);
760 return TRUE; 760 return true;
761 } 761 }
762 762
763 FX_BOOL CFFL_Button::OnMouseMove(CPDFSDK_PageView *pPageView, CPDFSDK_Annot* pAn not, FX_UINT nFlags, const CPDF_Point& point) 763 bool CFFL_Button::OnMouseMove(CPDFSDK_PageView *pPageView, CPDFSDK_Annot* pAnnot , FX_UINT nFlags, const CPDF_Point& point)
764 { 764 {
765 ASSERT(m_pApp != NULL); 765 ASSERT(m_pApp != NULL);
766 766
767 return TRUE; 767 return true;
768 } 768 }
769 769
770 void CFFL_Button::OnDraw(CPDFSDK_PageView *pPageView, CPDFSDK_Annot* pAnnot, 770 void CFFL_Button::OnDraw(CPDFSDK_PageView *pPageView, CPDFSDK_Annot* pAnnot,
771 CFX_RenderDevice* pDevice, CPDF_Matrix* pUser2Device, 771 CFX_RenderDevice* pDevice, CPDF_Matrix* pUser2Device,
772 FX_DWORD dwFlags) 772 FX_DWORD dwFlags)
773 { 773 {
774 ASSERT(pPageView != NULL); 774 ASSERT(pPageView != NULL);
775 CPDFSDK_Widget* pWidget = (CPDFSDK_Widget*)pAnnot; 775 CPDFSDK_Widget* pWidget = (CPDFSDK_Widget*)pAnnot;
776 CPDF_FormControl* pCtrl = pWidget->GetFormControl(); 776 CPDF_FormControl* pCtrl = pWidget->GetFormControl();
777 CPDF_FormControl::HighlightingMode eHM = pCtrl->GetHighlightingMode(); 777 CPDF_FormControl::HighlightingMode eHM = pCtrl->GetHighlightingMode();
(...skipping 23 matching lines...) Expand all
801 pWidget->DrawAppearance(pDevice, pUser2Device, CPDF_Annot::Normal, NULL) ; 801 pWidget->DrawAppearance(pDevice, pUser2Device, CPDF_Annot::Normal, NULL) ;
802 } 802 }
803 803
804 804
805 void CFFL_Button::OnDrawDeactive(CPDFSDK_PageView *pPageView, CPDFSDK_Annot* pAn not, 805 void CFFL_Button::OnDrawDeactive(CPDFSDK_PageView *pPageView, CPDFSDK_Annot* pAn not,
806 CFX_RenderDevice* pDevice, CPDF_Matrix* pUser2D evice, 806 CFX_RenderDevice* pDevice, CPDF_Matrix* pUser2D evice,
807 FX_DWORD dwFlags) 807 FX_DWORD dwFlags)
808 { 808 {
809 OnDraw(pPageView, pAnnot, pDevice, pUser2Device, dwFlags); 809 OnDraw(pPageView, pAnnot, pDevice, pUser2Device, dwFlags);
810 } 810 }
OLDNEW
« no previous file with comments | « fpdfsdk/src/formfiller/FFL_ComboBox.cpp ('k') | fpdfsdk/src/formfiller/FFL_IFormFiller.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698