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

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

Issue 1652533002: Add tests for CBA_AnnotIterator. (Closed) Base URL: https://pdfium.googlesource.com/pdfium.git@master
Patch Set: static_cast. Created 4 years, 10 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/include/fsdk_mgr.h ('k') | fpdfsdk/src/fsdk_baseform_embeddertest.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 8
9 #include <memory> 9 #include <memory>
10 10
11 #include "fpdfsdk/include/fsdk_define.h" 11 #include "fpdfsdk/include/fsdk_define.h"
12 #include "fpdfsdk/include/fsdk_mgr.h" 12 #include "fpdfsdk/include/fsdk_mgr.h"
13 #include "public/fpdfview.h" 13 #include "public/fpdfview.h"
14 14
15 namespace { 15 namespace {
16 16
17 CPDFSDK_Document* FormHandleToSDKDoc(FPDF_FORMHANDLE hHandle) {
18 CPDFDoc_Environment* pEnv = (CPDFDoc_Environment*)hHandle;
19 return pEnv ? pEnv->GetSDKDocument() : nullptr;
20 }
21
22 CPDFSDK_InterForm* FormHandleToInterForm(FPDF_FORMHANDLE hHandle) { 17 CPDFSDK_InterForm* FormHandleToInterForm(FPDF_FORMHANDLE hHandle) {
23 CPDFSDK_Document* pSDKDoc = FormHandleToSDKDoc(hHandle); 18 CPDFSDK_Document* pSDKDoc = CPDFSDK_Document::FromFPDFFormHandle(hHandle);
24 return pSDKDoc ? pSDKDoc->GetInterForm() : nullptr; 19 return pSDKDoc ? pSDKDoc->GetInterForm() : nullptr;
25 } 20 }
26 21
27 CPDFSDK_PageView* FormHandleToPageView(FPDF_FORMHANDLE hHandle, 22 CPDFSDK_PageView* FormHandleToPageView(FPDF_FORMHANDLE hHandle,
28 FPDF_PAGE page) { 23 FPDF_PAGE page) {
29 UnderlyingPageType* pPage = UnderlyingFromFPDFPage(page); 24 UnderlyingPageType* pPage = UnderlyingFromFPDFPage(page);
30 if (!pPage) 25 if (!pPage)
31 return nullptr; 26 return nullptr;
32 27
33 CPDFSDK_Document* pSDKDoc = FormHandleToSDKDoc(hHandle); 28 CPDFSDK_Document* pSDKDoc = CPDFSDK_Document::FromFPDFFormHandle(hHandle);
34 return pSDKDoc ? pSDKDoc->GetPageView(pPage, TRUE) : nullptr; 29 return pSDKDoc ? pSDKDoc->GetPageView(pPage, TRUE) : nullptr;
35 } 30 }
36 31
37 } // namespace 32 } // namespace
38 33
39 DLLEXPORT int STDCALL FPDFPage_HasFormFieldAtPoint(FPDF_FORMHANDLE hHandle, 34 DLLEXPORT int STDCALL FPDFPage_HasFormFieldAtPoint(FPDF_FORMHANDLE hHandle,
40 FPDF_PAGE page, 35 FPDF_PAGE page,
41 double page_x, 36 double page_x,
42 double page_y) { 37 double page_y) {
43 if (!hHandle) 38 if (!hHandle)
(...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after
173 int nChar, 168 int nChar,
174 int modifier) { 169 int modifier) {
175 CPDFSDK_PageView* pPageView = FormHandleToPageView(hHandle, page); 170 CPDFSDK_PageView* pPageView = FormHandleToPageView(hHandle, page);
176 if (!pPageView) 171 if (!pPageView)
177 return FALSE; 172 return FALSE;
178 173
179 return pPageView->OnChar(nChar, modifier); 174 return pPageView->OnChar(nChar, modifier);
180 } 175 }
181 176
182 DLLEXPORT FPDF_BOOL STDCALL FORM_ForceToKillFocus(FPDF_FORMHANDLE hHandle) { 177 DLLEXPORT FPDF_BOOL STDCALL FORM_ForceToKillFocus(FPDF_FORMHANDLE hHandle) {
183 CPDFSDK_Document* pSDKDoc = FormHandleToSDKDoc(hHandle); 178 CPDFSDK_Document* pSDKDoc = CPDFSDK_Document::FromFPDFFormHandle(hHandle);
184 if (!pSDKDoc) 179 if (!pSDKDoc)
185 return FALSE; 180 return FALSE;
186 181
187 return pSDKDoc->KillFocusAnnot(0); 182 return pSDKDoc->KillFocusAnnot(0);
188 } 183 }
189 184
190 DLLEXPORT void STDCALL FPDF_FFLDraw(FPDF_FORMHANDLE hHandle, 185 DLLEXPORT void STDCALL FPDF_FFLDraw(FPDF_FORMHANDLE hHandle,
191 FPDF_BITMAP bitmap, 186 FPDF_BITMAP bitmap,
192 FPDF_PAGE page, 187 FPDF_PAGE page,
193 int start_x, 188 int start_x,
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after
283 278
284 CPDFSDK_PageView* pPageView = pSDKDoc->GetPageView(pPage, FALSE); 279 CPDFSDK_PageView* pPageView = pSDKDoc->GetPageView(pPage, FALSE);
285 if (pPageView) { 280 if (pPageView) {
286 pPageView->SetValid(FALSE); 281 pPageView->SetValid(FALSE);
287 // RemovePageView() takes care of the delete for us. 282 // RemovePageView() takes care of the delete for us.
288 pSDKDoc->RemovePageView(pPage); 283 pSDKDoc->RemovePageView(pPage);
289 } 284 }
290 } 285 }
291 286
292 DLLEXPORT void STDCALL FORM_DoDocumentJSAction(FPDF_FORMHANDLE hHandle) { 287 DLLEXPORT void STDCALL FORM_DoDocumentJSAction(FPDF_FORMHANDLE hHandle) {
293 CPDFSDK_Document* pSDKDoc = FormHandleToSDKDoc(hHandle); 288 CPDFSDK_Document* pSDKDoc = CPDFSDK_Document::FromFPDFFormHandle(hHandle);
294 if (pSDKDoc && ((CPDFDoc_Environment*)hHandle)->IsJSInitiated()) 289 if (pSDKDoc && ((CPDFDoc_Environment*)hHandle)->IsJSInitiated())
295 pSDKDoc->ProcJavascriptFun(); 290 pSDKDoc->ProcJavascriptFun();
296 } 291 }
297 292
298 DLLEXPORT void STDCALL FORM_DoDocumentOpenAction(FPDF_FORMHANDLE hHandle) { 293 DLLEXPORT void STDCALL FORM_DoDocumentOpenAction(FPDF_FORMHANDLE hHandle) {
299 CPDFSDK_Document* pSDKDoc = FormHandleToSDKDoc(hHandle); 294 CPDFSDK_Document* pSDKDoc = CPDFSDK_Document::FromFPDFFormHandle(hHandle);
300 if (pSDKDoc && ((CPDFDoc_Environment*)hHandle)->IsJSInitiated()) 295 if (pSDKDoc && ((CPDFDoc_Environment*)hHandle)->IsJSInitiated())
301 pSDKDoc->ProcOpenAction(); 296 pSDKDoc->ProcOpenAction();
302 } 297 }
303 298
304 DLLEXPORT void STDCALL FORM_DoDocumentAAction(FPDF_FORMHANDLE hHandle, 299 DLLEXPORT void STDCALL FORM_DoDocumentAAction(FPDF_FORMHANDLE hHandle,
305 int aaType) { 300 int aaType) {
306 CPDFSDK_Document* pSDKDoc = FormHandleToSDKDoc(hHandle); 301 CPDFSDK_Document* pSDKDoc = CPDFSDK_Document::FromFPDFFormHandle(hHandle);
307 if (!pSDKDoc) 302 if (!pSDKDoc)
308 return; 303 return;
309 304
310 CPDF_Document* pDoc = pSDKDoc->GetPDFDocument(); 305 CPDF_Document* pDoc = pSDKDoc->GetPDFDocument();
311 CPDF_Dictionary* pDic = pDoc->GetRoot(); 306 CPDF_Dictionary* pDic = pDoc->GetRoot();
312 if (!pDic) 307 if (!pDic)
313 return; 308 return;
314 309
315 CPDF_AAction aa = pDic->GetDictBy("AA"); 310 CPDF_AAction aa = pDic->GetDictBy("AA");
316 if (aa.ActionExist((CPDF_AAction::AActionType)aaType)) { 311 if (aa.ActionExist((CPDF_AAction::AActionType)aaType)) {
(...skipping 26 matching lines...) Expand all
343 pActionHandler->DoAction_Page(action, CPDF_AAction::OpenPage, pSDKDoc); 338 pActionHandler->DoAction_Page(action, CPDF_AAction::OpenPage, pSDKDoc);
344 } 339 }
345 } else { 340 } else {
346 if (aa.ActionExist(CPDF_AAction::ClosePage)) { 341 if (aa.ActionExist(CPDF_AAction::ClosePage)) {
347 CPDF_Action action = aa.GetAction(CPDF_AAction::ClosePage); 342 CPDF_Action action = aa.GetAction(CPDF_AAction::ClosePage);
348 pActionHandler->DoAction_Page(action, CPDF_AAction::ClosePage, pSDKDoc); 343 pActionHandler->DoAction_Page(action, CPDF_AAction::ClosePage, pSDKDoc);
349 } 344 }
350 } 345 }
351 } 346 }
352 } 347 }
OLDNEW
« no previous file with comments | « fpdfsdk/include/fsdk_mgr.h ('k') | fpdfsdk/src/fsdk_baseform_embeddertest.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698