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

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

Issue 1411623002: Merge to XFA: Introduce CPDFPageFromFPFDPage() (Closed) Base URL: https://pdfium.googlesource.com/pdfium.git@xfa
Patch Set: Created 5 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
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 24 matching lines...) Expand all
35 CPDFSDK_Document* pSDKDoc = FormHandleToSDKDoc(hHandle); 35 CPDFSDK_Document* pSDKDoc = FormHandleToSDKDoc(hHandle);
36 return pSDKDoc ? pSDKDoc->GetPageView((CPDFXFA_Page*)page, TRUE) : nullptr; 36 return pSDKDoc ? pSDKDoc->GetPageView((CPDFXFA_Page*)page, TRUE) : nullptr;
37 } 37 }
38 38
39 } // namespace 39 } // namespace
40 40
41 DLLEXPORT int STDCALL FPDFPage_HasFormFieldAtPoint(FPDF_FORMHANDLE hHandle, 41 DLLEXPORT int STDCALL FPDFPage_HasFormFieldAtPoint(FPDF_FORMHANDLE hHandle,
42 FPDF_PAGE page, 42 FPDF_PAGE page,
43 double page_x, 43 double page_x,
44 double page_y) { 44 double page_y) {
45 if (!page || !hHandle) 45 if (!hHandle)
46 return -1; 46 return -1;
47 47 CPDF_Page* pPage = CPDFPageFromFPDFPage(page);
48 CPDF_Page* pPage = ((CPDFXFA_Page*)page)->GetPDFPage();
49 if (pPage) { 48 if (pPage) {
50 CPDF_InterForm interform(pPage->m_pDocument, FALSE); 49 CPDF_InterForm interform(pPage->m_pDocument, FALSE);
51 CPDF_FormControl* pFormCtrl = interform.GetControlAtPoint( 50 CPDF_FormControl* pFormCtrl = interform.GetControlAtPoint(
52 pPage, (FX_FLOAT)page_x, (FX_FLOAT)page_y, nullptr); 51 pPage, (FX_FLOAT)page_x, (FX_FLOAT)page_y, nullptr);
53 if (!pFormCtrl) 52 if (!pFormCtrl)
54 return -1; 53 return -1;
55 54
56 CPDF_FormField* pFormField = pFormCtrl->GetField(); 55 CPDF_FormField* pFormField = pFormCtrl->GetField();
57 if (!pFormField) 56 if (!pFormField)
58 return -1; 57 return -1;
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
108 FPDF_PAGE page, 107 FPDF_PAGE page,
109 double page_x, 108 double page_x,
110 double page_y) { 109 double page_y) {
111 return FPDFPage_HasFormFieldAtPoint(hHandle, page, page_x, page_y); 110 return FPDFPage_HasFormFieldAtPoint(hHandle, page, page_x, page_y);
112 } 111 }
113 112
114 DLLEXPORT int STDCALL FPDFPage_FormFieldZOrderAtPoint(FPDF_FORMHANDLE hHandle, 113 DLLEXPORT int STDCALL FPDFPage_FormFieldZOrderAtPoint(FPDF_FORMHANDLE hHandle,
115 FPDF_PAGE page, 114 FPDF_PAGE page,
116 double page_x, 115 double page_x,
117 double page_y) { 116 double page_y) {
118 if (!page || !hHandle) 117 if (!hHandle)
119 return -1; 118 return -1;
120 119 CPDF_Page* pPage = CPDFPageFromFPDFPage(page);
121 CPDF_Page* pPage = (CPDF_Page*)page; 120 if (!pPage)
Tom Sepez 2015/10/16 00:18:55 And this would be a bug in xfa.
Lei Zhang 2015/10/16 01:23:55 I wonder why wrote that code... Hmmmm!
121 return -1;
122 CPDF_InterForm interform(pPage->m_pDocument, FALSE); 122 CPDF_InterForm interform(pPage->m_pDocument, FALSE);
123 int z_order = -1; 123 int z_order = -1;
124 (void)interform.GetControlAtPoint(pPage, (FX_FLOAT)page_x, (FX_FLOAT)page_y, 124 (void)interform.GetControlAtPoint(pPage, (FX_FLOAT)page_x, (FX_FLOAT)page_y,
125 &z_order); 125 &z_order);
126 return z_order; 126 return z_order;
127 } 127 }
128 128
129 DLLEXPORT FPDF_FORMHANDLE STDCALL 129 DLLEXPORT FPDF_FORMHANDLE STDCALL
130 FPDFDOC_InitFormFillEnvironment(FPDF_DOCUMENT document, 130 FPDFDOC_InitFormFillEnvironment(FPDF_DOCUMENT document,
131 FPDF_FORMFILLINFO* formInfo) { 131 FPDF_FORMFILLINFO* formInfo) {
(...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after
259 259
260 DLLEXPORT void STDCALL FPDF_FFLDraw(FPDF_FORMHANDLE hHandle, 260 DLLEXPORT void STDCALL FPDF_FFLDraw(FPDF_FORMHANDLE hHandle,
261 FPDF_BITMAP bitmap, 261 FPDF_BITMAP bitmap,
262 FPDF_PAGE page, 262 FPDF_PAGE page,
263 int start_x, 263 int start_x,
264 int start_y, 264 int start_y,
265 int size_x, 265 int size_x,
266 int size_y, 266 int size_y,
267 int rotate, 267 int rotate,
268 int flags) { 268 int flags) {
269 if (!hHandle || !page) 269 if (!hHandle)
270 return; 270 return;
271 271
272 CPDFXFA_Page* pPage = (CPDFXFA_Page*)page; 272 CPDF_Page* pPage = CPDFPageFromFPDFPage(page);
Tom Sepez 2015/10/16 00:18:55 wrong, fix it.
273 CPDFXFA_Document* pDocument = pPage->GetDocument(); 273 if (!pPage)
274 return;
275
276 CPDFXFA_Document* pDocument = ((CPDFXFA_Page*)pPage)->GetDocument();
Lei Zhang 2015/10/16 01:23:55 No more C-style casts.
274 if (!pDocument) 277 if (!pDocument)
275 return; 278 return;
276 CPDF_Document* pPDFDoc = pDocument->GetPDFDoc();
277 if (!pPDFDoc)
278 return;
279 279
280 CPDFDoc_Environment* pEnv = (CPDFDoc_Environment*)hHandle; 280 CPDFDoc_Environment* pEnv = (CPDFDoc_Environment*)hHandle;
281 CPDFSDK_Document* pFXDoc = pEnv->GetSDKDocument(); 281 CPDFSDK_Document* pFXDoc = pEnv->GetSDKDocument();
282 if (!pFXDoc) 282 if (!pFXDoc)
283 return; 283 return;
284 284
285 CFX_AffineMatrix matrix; 285 CFX_AffineMatrix matrix;
286 pPage->GetDisplayMatrix(matrix, start_x, start_y, size_x, size_y, rotate); 286 pPage->GetDisplayMatrix(matrix, start_x, start_y, size_x, size_y, rotate);
287 287
288 FX_RECT clip; 288 FX_RECT clip;
(...skipping 305 matching lines...) Expand 10 before | Expand all | Expand 10 after
594 } 594 }
595 595
596 DLLEXPORT void STDCALL FORM_OnAfterLoadPage(FPDF_PAGE page, 596 DLLEXPORT void STDCALL FORM_OnAfterLoadPage(FPDF_PAGE page,
597 FPDF_FORMHANDLE hHandle) { 597 FPDF_FORMHANDLE hHandle) {
598 if (CPDFSDK_PageView* pPageView = FormHandleToPageView(hHandle, page)) 598 if (CPDFSDK_PageView* pPageView = FormHandleToPageView(hHandle, page))
599 pPageView->SetValid(TRUE); 599 pPageView->SetValid(TRUE);
600 } 600 }
601 601
602 DLLEXPORT void STDCALL FORM_OnBeforeClosePage(FPDF_PAGE page, 602 DLLEXPORT void STDCALL FORM_OnBeforeClosePage(FPDF_PAGE page,
603 FPDF_FORMHANDLE hHandle) { 603 FPDF_FORMHANDLE hHandle) {
604 if (!hHandle || !page) 604 if (!hHandle)
Tom Sepez 2015/10/16 00:18:55 wrong, fix.
Lei Zhang 2015/10/16 01:23:55 We are ok with a NULL |page| ?
Tom Sepez 2015/10/16 16:58:54 No, fixed.
605 return; 605 return;
606 606
607 CPDFSDK_Document* pSDKDoc = ((CPDFDoc_Environment*)hHandle)->GetSDKDocument(); 607 CPDFSDK_Document* pSDKDoc = ((CPDFDoc_Environment*)hHandle)->GetSDKDocument();
608 if (!pSDKDoc) 608 if (!pSDKDoc)
609 return; 609 return;
610 610
611 CPDFXFA_Page* pPage = (CPDFXFA_Page*)page; 611 CPDFXFA_Page* pPage = (CPDFXFA_Page*)page;
612 CPDFSDK_PageView* pPageView = pSDKDoc->GetPageView(pPage, FALSE); 612 CPDFSDK_PageView* pPageView = pSDKDoc->GetPageView(pPage, FALSE);
613 if (pPageView) { 613 if (pPageView) {
614 pPageView->SetValid(FALSE); 614 pPageView->SetValid(FALSE);
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
647 ((CPDFDoc_Environment*)hHandle)->GetActionHander(); 647 ((CPDFDoc_Environment*)hHandle)->GetActionHander();
648 ASSERT(pActionHandler != NULL); 648 ASSERT(pActionHandler != NULL);
649 pActionHandler->DoAction_Document(action, (CPDF_AAction::AActionType)aaType, 649 pActionHandler->DoAction_Document(action, (CPDF_AAction::AActionType)aaType,
650 pSDKDoc); 650 pSDKDoc);
651 } 651 }
652 } 652 }
653 653
654 DLLEXPORT void STDCALL FORM_DoPageAAction(FPDF_PAGE page, 654 DLLEXPORT void STDCALL FORM_DoPageAAction(FPDF_PAGE page,
655 FPDF_FORMHANDLE hHandle, 655 FPDF_FORMHANDLE hHandle,
656 int aaType) { 656 int aaType) {
657 if (!hHandle || !page) 657 if (!hHandle)
658 return; 658 return;
659 CPDFSDK_Document* pSDKDoc = ((CPDFDoc_Environment*)hHandle)->GetSDKDocument(); 659 CPDFSDK_Document* pSDKDoc = ((CPDFDoc_Environment*)hHandle)->GetSDKDocument();
660 CPDFXFA_Page* pPage = (CPDFXFA_Page*)page; 660 CPDFXFA_Page* pPage = (CPDFXFA_Page*)page;
661 if (!pPage)
662 return;
661 CPDFSDK_PageView* pPageView = pSDKDoc->GetPageView(pPage, FALSE); 663 CPDFSDK_PageView* pPageView = pSDKDoc->GetPageView(pPage, FALSE);
662 if (pPageView) { 664 if (pPageView) {
663 CPDFDoc_Environment* pEnv = pSDKDoc->GetEnv(); 665 CPDFDoc_Environment* pEnv = pSDKDoc->GetEnv();
664 CPDFSDK_ActionHandler* pActionHandler = pEnv->GetActionHander(); 666 CPDFSDK_ActionHandler* pActionHandler = pEnv->GetActionHander();
665 CPDF_Dictionary* pPageDict = pPage->GetPDFPage()->m_pFormDict; 667 CPDF_Dictionary* pPageDict = pPage->GetPDFPage()->m_pFormDict;
666 CPDF_AAction aa = pPageDict->GetDict(FX_BSTRC("AA")); 668 CPDF_AAction aa = pPageDict->GetDict(FX_BSTRC("AA"));
667 669
668 FX_BOOL bExistOAAction = FALSE; 670 FX_BOOL bExistOAAction = FALSE;
669 FX_BOOL bExistCAAction = FALSE; 671 FX_BOOL bExistCAAction = FALSE;
670 if (FPDFPAGE_AACTION_OPEN == aaType) { 672 if (FPDFPAGE_AACTION_OPEN == aaType) {
671 bExistOAAction = aa.ActionExist(CPDF_AAction::OpenPage); 673 bExistOAAction = aa.ActionExist(CPDF_AAction::OpenPage);
672 if (bExistOAAction) { 674 if (bExistOAAction) {
673 CPDF_Action action = aa.GetAction(CPDF_AAction::OpenPage); 675 CPDF_Action action = aa.GetAction(CPDF_AAction::OpenPage);
674 pActionHandler->DoAction_Page(action, CPDF_AAction::OpenPage, pSDKDoc); 676 pActionHandler->DoAction_Page(action, CPDF_AAction::OpenPage, pSDKDoc);
675 } 677 }
676 } else { 678 } else {
677 bExistCAAction = aa.ActionExist(CPDF_AAction::ClosePage); 679 bExistCAAction = aa.ActionExist(CPDF_AAction::ClosePage);
678 if (bExistCAAction) { 680 if (bExistCAAction) {
679 CPDF_Action action = aa.GetAction(CPDF_AAction::ClosePage); 681 CPDF_Action action = aa.GetAction(CPDF_AAction::ClosePage);
680 pActionHandler->DoAction_Page(action, CPDF_AAction::ClosePage, pSDKDoc); 682 pActionHandler->DoAction_Page(action, CPDF_AAction::ClosePage, pSDKDoc);
681 } 683 }
682 } 684 }
683 } 685 }
684 } 686 }
OLDNEW
« no previous file with comments | « fpdfsdk/src/fpdfeditpage.cpp ('k') | fpdfsdk/src/fpdftext.cpp » ('j') | fpdfsdk/src/fpdftext.cpp » ('J')

Powered by Google App Engine
This is Rietveld 408576698