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

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

Issue 1254703002: FX_BOOL considered harmful, part 2. (Closed) Base URL: https://pdfium.googlesource.com/pdfium.git@master
Patch Set: 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/fpdfeditpage.cpp ('k') | fpdfsdk/src/fpdfppo.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 #include "../../public/fpdf_formfill.h" 7 #include "../../public/fpdf_formfill.h"
8 #include "../../public/fpdfview.h" 8 #include "../../public/fpdfview.h"
9 #include "../../third_party/base/nonstd_unique_ptr.h" 9 #include "../../third_party/base/nonstd_unique_ptr.h"
10 #include "../include/fsdk_define.h" 10 #include "../include/fsdk_define.h"
(...skipping 10 matching lines...) Expand all
21 21
22 CPDFSDK_InterForm* FormHandleToInterForm(FPDF_FORMHANDLE hHandle) 22 CPDFSDK_InterForm* FormHandleToInterForm(FPDF_FORMHANDLE hHandle)
23 { 23 {
24 CPDFSDK_Document* pSDKDoc = FormHandleToSDKDoc(hHandle); 24 CPDFSDK_Document* pSDKDoc = FormHandleToSDKDoc(hHandle);
25 return pSDKDoc ? pSDKDoc->GetInterForm() : nullptr; 25 return pSDKDoc ? pSDKDoc->GetInterForm() : nullptr;
26 } 26 }
27 27
28 CPDFSDK_PageView* FormHandleToPageView(FPDF_FORMHANDLE hHandle, FPDF_PAGE page) 28 CPDFSDK_PageView* FormHandleToPageView(FPDF_FORMHANDLE hHandle, FPDF_PAGE page)
29 { 29 {
30 CPDFSDK_Document* pSDKDoc = FormHandleToSDKDoc(hHandle); 30 CPDFSDK_Document* pSDKDoc = FormHandleToSDKDoc(hHandle);
31 return pSDKDoc ? pSDKDoc->GetPageView((CPDF_Page*)page, TRUE) : nullptr; 31 return pSDKDoc ? pSDKDoc->GetPageView((CPDF_Page*)page, true) : nullptr;
32 } 32 }
33 33
34 } // namespace 34 } // namespace
35 35
36 DLLEXPORT int STDCALL FPDPage_HasFormFieldAtPoint( 36 DLLEXPORT int STDCALL FPDPage_HasFormFieldAtPoint(
37 FPDF_FORMHANDLE hHandle, FPDF_PAGE page, double page_x, double page_y) 37 FPDF_FORMHANDLE hHandle, FPDF_PAGE page, double page_x, double page_y)
38 { 38 {
39 if (!page || !hHandle) 39 if (!page || !hHandle)
40 return -1; 40 return -1;
41 CPDF_Page* pPage = (CPDF_Page*) page; 41 CPDF_Page* pPage = (CPDF_Page*) page;
42 42
43 nonstd::unique_ptr<CPDF_InterForm> pInterForm( 43 nonstd::unique_ptr<CPDF_InterForm> pInterForm(
44 new CPDF_InterForm(pPage->m_pDocument, FALSE)); 44 new CPDF_InterForm(pPage->m_pDocument, false));
45 CPDF_FormControl* pFormCtrl = pInterForm->GetControlAtPoint( 45 CPDF_FormControl* pFormCtrl = pInterForm->GetControlAtPoint(
46 pPage, (FX_FLOAT)page_x, (FX_FLOAT)page_y); 46 pPage, (FX_FLOAT)page_x, (FX_FLOAT)page_y);
47 if (!pFormCtrl) 47 if (!pFormCtrl)
48 return -1; 48 return -1;
49 49
50 CPDF_FormField* pFormField = pFormCtrl->GetField(); 50 CPDF_FormField* pFormField = pFormCtrl->GetField();
51 if(!pFormField) 51 if(!pFormField)
52 return -1; 52 return -1;
53 53
54 return pFormField->GetFieldType(); 54 return pFormField->GetFieldType();
(...skipping 22 matching lines...) Expand all
77 pEnv->SetSDKDocument(NULL); 77 pEnv->SetSDKDocument(NULL);
78 delete pSDKDoc; 78 delete pSDKDoc;
79 } 79 }
80 delete pEnv; 80 delete pEnv;
81 } 81 }
82 82
83 DLLEXPORT FPDF_BOOL STDCALL FORM_OnMouseMove(FPDF_FORMHANDLE hHandle, FPDF_PAGE page, int modifier, double page_x, double page_y) 83 DLLEXPORT FPDF_BOOL STDCALL FORM_OnMouseMove(FPDF_FORMHANDLE hHandle, FPDF_PAGE page, int modifier, double page_x, double page_y)
84 { 84 {
85 CPDFSDK_PageView* pPageView = FormHandleToPageView(hHandle, page); 85 CPDFSDK_PageView* pPageView = FormHandleToPageView(hHandle, page);
86 if (!pPageView) 86 if (!pPageView)
87 return FALSE; 87 return false;
88 88
89 CPDF_Point pt((FX_FLOAT)page_x, (FX_FLOAT)page_y); 89 CPDF_Point pt((FX_FLOAT)page_x, (FX_FLOAT)page_y);
90 return pPageView->OnMouseMove(pt, modifier); 90 return pPageView->OnMouseMove(pt, modifier);
91 } 91 }
92 92
93 DLLEXPORT FPDF_BOOL STDCALL FORM_OnLButtonDown(FPDF_FORMHANDLE hHandle, FPDF_PAG E page, int modifier, double page_x, double page_y) 93 DLLEXPORT FPDF_BOOL STDCALL FORM_OnLButtonDown(FPDF_FORMHANDLE hHandle, FPDF_PAG E page, int modifier, double page_x, double page_y)
94 { 94 {
95 CPDFSDK_PageView* pPageView = FormHandleToPageView(hHandle, page); 95 CPDFSDK_PageView* pPageView = FormHandleToPageView(hHandle, page);
96 if (!pPageView) 96 if (!pPageView)
97 return FALSE; 97 return false;
98 98
99 CPDF_Point pt((FX_FLOAT)page_x, (FX_FLOAT)page_y); 99 CPDF_Point pt((FX_FLOAT)page_x, (FX_FLOAT)page_y);
100 return pPageView->OnLButtonDown(pt, modifier); 100 return pPageView->OnLButtonDown(pt, modifier);
101 } 101 }
102 102
103 DLLEXPORT FPDF_BOOL STDCALL FORM_OnLButtonUp(FPDF_FORMHANDLE hHandle, FPDF_PAGE page, int modifier, double page_x, double page_y) 103 DLLEXPORT FPDF_BOOL STDCALL FORM_OnLButtonUp(FPDF_FORMHANDLE hHandle, FPDF_PAGE page, int modifier, double page_x, double page_y)
104 { 104 {
105 CPDFSDK_PageView* pPageView = FormHandleToPageView(hHandle, page); 105 CPDFSDK_PageView* pPageView = FormHandleToPageView(hHandle, page);
106 if (!pPageView) 106 if (!pPageView)
107 return FALSE; 107 return false;
108 108
109 CPDF_Point pt((FX_FLOAT)page_x, (FX_FLOAT)page_y); 109 CPDF_Point pt((FX_FLOAT)page_x, (FX_FLOAT)page_y);
110 return pPageView->OnLButtonUp(pt, modifier); 110 return pPageView->OnLButtonUp(pt, modifier);
111 } 111 }
112 112
113 DLLEXPORT FPDF_BOOL STDCALL FORM_OnKeyDown(FPDF_FORMHANDLE hHandle, FPDF_PAGE pa ge, int nKeyCode, int modifier) 113 DLLEXPORT FPDF_BOOL STDCALL FORM_OnKeyDown(FPDF_FORMHANDLE hHandle, FPDF_PAGE pa ge, int nKeyCode, int modifier)
114 { 114 {
115 CPDFSDK_PageView* pPageView = FormHandleToPageView(hHandle, page); 115 CPDFSDK_PageView* pPageView = FormHandleToPageView(hHandle, page);
116 if (!pPageView) 116 if (!pPageView)
117 return FALSE; 117 return false;
118 118
119 return pPageView->OnKeyDown(nKeyCode, modifier); 119 return pPageView->OnKeyDown(nKeyCode, modifier);
120 } 120 }
121 121
122 DLLEXPORT FPDF_BOOL STDCALL FORM_OnKeyUp(FPDF_FORMHANDLE hHandle, FPDF_PAGE page , int nKeyCode, int modifier) 122 DLLEXPORT FPDF_BOOL STDCALL FORM_OnKeyUp(FPDF_FORMHANDLE hHandle, FPDF_PAGE page , int nKeyCode, int modifier)
123 { 123 {
124 CPDFSDK_PageView* pPageView = FormHandleToPageView(hHandle, page); 124 CPDFSDK_PageView* pPageView = FormHandleToPageView(hHandle, page);
125 if (!pPageView) 125 if (!pPageView)
126 return FALSE; 126 return false;
127 127
128 return pPageView->OnKeyUp(nKeyCode, modifier); 128 return pPageView->OnKeyUp(nKeyCode, modifier);
129 } 129 }
130 130
131 DLLEXPORT FPDF_BOOL STDCALL FORM_OnChar(FPDF_FORMHANDLE hHandle, FPDF_PAGE page, int nChar, int modifier) 131 DLLEXPORT FPDF_BOOL STDCALL FORM_OnChar(FPDF_FORMHANDLE hHandle, FPDF_PAGE page, int nChar, int modifier)
132 { 132 {
133 CPDFSDK_PageView* pPageView = FormHandleToPageView(hHandle, page); 133 CPDFSDK_PageView* pPageView = FormHandleToPageView(hHandle, page);
134 if (!pPageView) 134 if (!pPageView)
135 return FALSE; 135 return false;
136 136
137 return pPageView->OnChar(nChar, modifier); 137 return pPageView->OnChar(nChar, modifier);
138 } 138 }
139 139
140 DLLEXPORT FPDF_BOOL STDCALL FORM_ForceToKillFocus(FPDF_FORMHANDLE hHandle) 140 DLLEXPORT FPDF_BOOL STDCALL FORM_ForceToKillFocus(FPDF_FORMHANDLE hHandle)
141 { 141 {
142 CPDFSDK_Document* pSDKDoc = FormHandleToSDKDoc(hHandle); 142 CPDFSDK_Document* pSDKDoc = FormHandleToSDKDoc(hHandle);
143 if (!pSDKDoc) 143 if (!pSDKDoc)
144 return FALSE; 144 return false;
145 145
146 return pSDKDoc->KillFocusAnnot(0); 146 return pSDKDoc->KillFocusAnnot(0);
147 } 147 }
148 148
149 DLLEXPORT void STDCALL FPDF_FFLDraw(FPDF_FORMHANDLE hHandle, FPDF_BITMAP bitmap, FPDF_PAGE page, 149 DLLEXPORT void STDCALL FPDF_FFLDraw(FPDF_FORMHANDLE hHandle, FPDF_BITMAP bitmap, FPDF_PAGE page,
150 int start_x, int start_y, int size_x, int si ze_y, int rotate, int flags) 150 int start_x, int start_y, int size_x, int si ze_y, int rotate, int flags)
151 { 151 {
152 if (!hHandle || !page) 152 if (!hHandle || !page)
153 return; 153 return;
154 154
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
209 209
210 DLLEXPORT void STDCALL FPDF_RemoveFormFieldHighlight(FPDF_FORMHANDLE hHandle) 210 DLLEXPORT void STDCALL FPDF_RemoveFormFieldHighlight(FPDF_FORMHANDLE hHandle)
211 { 211 {
212 if (CPDFSDK_InterForm* pInterForm = FormHandleToInterForm(hHandle)) 212 if (CPDFSDK_InterForm* pInterForm = FormHandleToInterForm(hHandle))
213 pInterForm->RemoveAllHighLight(); 213 pInterForm->RemoveAllHighLight();
214 } 214 }
215 215
216 DLLEXPORT void STDCALL FORM_OnAfterLoadPage(FPDF_PAGE page, FPDF_FORMHANDLE hHan dle) 216 DLLEXPORT void STDCALL FORM_OnAfterLoadPage(FPDF_PAGE page, FPDF_FORMHANDLE hHan dle)
217 { 217 {
218 if (CPDFSDK_PageView* pPageView = FormHandleToPageView(hHandle, page)) 218 if (CPDFSDK_PageView* pPageView = FormHandleToPageView(hHandle, page))
219 pPageView->SetValid(TRUE); 219 pPageView->SetValid(true);
220 } 220 }
221 221
222 DLLEXPORT void STDCALL FORM_OnBeforeClosePage(FPDF_PAGE page, FPDF_FORMHANDLE hH andle) 222 DLLEXPORT void STDCALL FORM_OnBeforeClosePage(FPDF_PAGE page, FPDF_FORMHANDLE hH andle)
223 { 223 {
224 if (!hHandle || !page) 224 if (!hHandle || !page)
225 return; 225 return;
226 226
227 CPDFSDK_Document* pSDKDoc = ((CPDFDoc_Environment*)hHandle)->GetSDKDocument( ); 227 CPDFSDK_Document* pSDKDoc = ((CPDFDoc_Environment*)hHandle)->GetSDKDocument( );
228 if (!pSDKDoc) 228 if (!pSDKDoc)
229 return; 229 return;
230 230
231 CPDF_Page* pPage = (CPDF_Page*)page; 231 CPDF_Page* pPage = (CPDF_Page*)page;
232 CPDFSDK_PageView* pPageView = pSDKDoc->GetPageView(pPage, FALSE); 232 CPDFSDK_PageView* pPageView = pSDKDoc->GetPageView(pPage, false);
233 if (pPageView) 233 if (pPageView)
234 { 234 {
235 pPageView->SetValid(FALSE); 235 pPageView->SetValid(false);
236 // ReMovePageView() takes care of the delete for us. 236 // ReMovePageView() takes care of the delete for us.
237 pSDKDoc->ReMovePageView(pPage); 237 pSDKDoc->ReMovePageView(pPage);
238 } 238 }
239 } 239 }
240 240
241 DLLEXPORT void STDCALL FORM_DoDocumentJSAction(FPDF_FORMHANDLE hHandle) 241 DLLEXPORT void STDCALL FORM_DoDocumentJSAction(FPDF_FORMHANDLE hHandle)
242 { 242 {
243 CPDFSDK_Document* pSDKDoc = FormHandleToSDKDoc(hHandle); 243 CPDFSDK_Document* pSDKDoc = FormHandleToSDKDoc(hHandle);
244 if (pSDKDoc && ((CPDFDoc_Environment*)hHandle)->IsJSInitiated()) 244 if (pSDKDoc && ((CPDFDoc_Environment*)hHandle)->IsJSInitiated())
245 pSDKDoc->ProcJavascriptFun(); 245 pSDKDoc->ProcJavascriptFun();
(...skipping 26 matching lines...) Expand all
272 pActionHandler->DoAction_Document(action, (CPDF_AAction::AActionType)aaT ype, pSDKDoc); 272 pActionHandler->DoAction_Document(action, (CPDF_AAction::AActionType)aaT ype, pSDKDoc);
273 } 273 }
274 } 274 }
275 275
276 DLLEXPORT void STDCALL FORM_DoPageAAction(FPDF_PAGE page, FPDF_FORMHANDLE hHandl e, int aaType) 276 DLLEXPORT void STDCALL FORM_DoPageAAction(FPDF_PAGE page, FPDF_FORMHANDLE hHandl e, int aaType)
277 { 277 {
278 if(!hHandle || !page) 278 if(!hHandle || !page)
279 return; 279 return;
280 CPDFSDK_Document* pSDKDoc = ((CPDFDoc_Environment*)hHandle)->GetSDKDocument( ); 280 CPDFSDK_Document* pSDKDoc = ((CPDFDoc_Environment*)hHandle)->GetSDKDocument( );
281 CPDF_Page* pPage = (CPDF_Page*)page; 281 CPDF_Page* pPage = (CPDF_Page*)page;
282 CPDFSDK_PageView* pPageView = pSDKDoc->GetPageView(pPage, FALSE); 282 CPDFSDK_PageView* pPageView = pSDKDoc->GetPageView(pPage, false);
283 if(pPageView) 283 if(pPageView)
284 { 284 {
285 CPDFDoc_Environment *pEnv = pSDKDoc->GetEnv(); 285 CPDFDoc_Environment *pEnv = pSDKDoc->GetEnv();
286 ASSERT(pEnv != NULL); 286 ASSERT(pEnv != NULL);
287 287
288 CPDFSDK_ActionHandler *pActionHandler = pEnv->GetActionHander(); 288 CPDFSDK_ActionHandler *pActionHandler = pEnv->GetActionHander();
289 ASSERT(pActionHandler != NULL); 289 ASSERT(pActionHandler != NULL);
290 290
291 CPDF_Dictionary *pPageDict = pPage->m_pFormDict; 291 CPDF_Dictionary *pPageDict = pPage->m_pFormDict;
292 ASSERT(pPageDict != NULL); 292 ASSERT(pPageDict != NULL);
293 293
294 CPDF_AAction aa = pPageDict->GetDict(FX_BSTRC("AA")); 294 CPDF_AAction aa = pPageDict->GetDict(FX_BSTRC("AA"));
295 295
296 FX_BOOL bExistOAAction = FALSE; 296 bool bExistOAAction = false;
297 FX_BOOL bExistCAAction = FALSE; 297 bool bExistCAAction = false;
298 if (FPDFPAGE_AACTION_OPEN == aaType) 298 if (FPDFPAGE_AACTION_OPEN == aaType)
299 { 299 {
300 bExistOAAction = aa.ActionExist(CPDF_AAction::OpenPage); 300 bExistOAAction = aa.ActionExist(CPDF_AAction::OpenPage);
301 if (bExistOAAction) 301 if (bExistOAAction)
302 { 302 {
303 CPDF_Action action = aa.GetAction(CPDF_AAction::OpenPage); 303 CPDF_Action action = aa.GetAction(CPDF_AAction::OpenPage);
304 pActionHandler->DoAction_Page(action, CPDF_AAction::OpenPage, pS DKDoc); 304 pActionHandler->DoAction_Page(action, CPDF_AAction::OpenPage, pS DKDoc);
305 } 305 }
306 } 306 }
307 else 307 else
308 { 308 {
309 bExistCAAction = aa.ActionExist(CPDF_AAction::ClosePage); 309 bExistCAAction = aa.ActionExist(CPDF_AAction::ClosePage);
310 if (bExistCAAction) 310 if (bExistCAAction)
311 { 311 {
312 CPDF_Action action = aa.GetAction(CPDF_AAction::ClosePage); 312 CPDF_Action action = aa.GetAction(CPDF_AAction::ClosePage);
313 pActionHandler->DoAction_Page(action, CPDF_AAction::ClosePage, p SDKDoc); 313 pActionHandler->DoAction_Page(action, CPDF_AAction::ClosePage, p SDKDoc);
314 } 314 }
315 } 315 }
316 } 316 }
317 } 317 }
OLDNEW
« no previous file with comments | « fpdfsdk/src/fpdfeditpage.cpp ('k') | fpdfsdk/src/fpdfppo.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698