OLD | NEW |
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 #ifdef PDF_ENABLE_XFA | 15 #ifdef PDF_ENABLE_XFA |
16 #include "fpdfsdk/include/fpdfxfa/fpdfxfa_app.h" | 16 #include "fpdfsdk/include/fpdfxfa/fpdfxfa_app.h" |
17 #include "fpdfsdk/include/fpdfxfa/fpdfxfa_doc.h" | 17 #include "fpdfsdk/include/fpdfxfa/fpdfxfa_doc.h" |
18 #include "fpdfsdk/include/fpdfxfa/fpdfxfa_page.h" | 18 #include "fpdfsdk/include/fpdfxfa/fpdfxfa_page.h" |
19 #endif // PDF_ENABLE_XFA | 19 #endif // PDF_ENABLE_XFA |
20 | 20 |
21 namespace { | 21 namespace { |
22 | 22 |
23 CPDFSDK_Document* FormHandleToSDKDoc(FPDF_FORMHANDLE hHandle) { | |
24 CPDFDoc_Environment* pEnv = (CPDFDoc_Environment*)hHandle; | |
25 return pEnv ? pEnv->GetSDKDocument() : nullptr; | |
26 } | |
27 | |
28 CPDFSDK_InterForm* FormHandleToInterForm(FPDF_FORMHANDLE hHandle) { | 23 CPDFSDK_InterForm* FormHandleToInterForm(FPDF_FORMHANDLE hHandle) { |
29 CPDFSDK_Document* pSDKDoc = FormHandleToSDKDoc(hHandle); | 24 CPDFSDK_Document* pSDKDoc = CPDFSDK_Document::FromFPDFFormHandle(hHandle); |
30 return pSDKDoc ? pSDKDoc->GetInterForm() : nullptr; | 25 return pSDKDoc ? pSDKDoc->GetInterForm() : nullptr; |
31 } | 26 } |
32 | 27 |
33 CPDFSDK_PageView* FormHandleToPageView(FPDF_FORMHANDLE hHandle, | 28 CPDFSDK_PageView* FormHandleToPageView(FPDF_FORMHANDLE hHandle, |
34 FPDF_PAGE page) { | 29 FPDF_PAGE page) { |
35 UnderlyingPageType* pPage = UnderlyingFromFPDFPage(page); | 30 UnderlyingPageType* pPage = UnderlyingFromFPDFPage(page); |
36 if (!pPage) | 31 if (!pPage) |
37 return nullptr; | 32 return nullptr; |
38 | 33 |
39 CPDFSDK_Document* pSDKDoc = FormHandleToSDKDoc(hHandle); | 34 CPDFSDK_Document* pSDKDoc = CPDFSDK_Document::FromFPDFFormHandle(hHandle); |
40 return pSDKDoc ? pSDKDoc->GetPageView(pPage, TRUE) : nullptr; | 35 return pSDKDoc ? pSDKDoc->GetPageView(pPage, TRUE) : nullptr; |
41 } | 36 } |
42 | 37 |
43 } // namespace | 38 } // namespace |
44 | 39 |
45 DLLEXPORT int STDCALL FPDFPage_HasFormFieldAtPoint(FPDF_FORMHANDLE hHandle, | 40 DLLEXPORT int STDCALL FPDFPage_HasFormFieldAtPoint(FPDF_FORMHANDLE hHandle, |
46 FPDF_PAGE page, | 41 FPDF_PAGE page, |
47 double page_x, | 42 double page_x, |
48 double page_y) { | 43 double page_y) { |
49 if (!hHandle) | 44 if (!hHandle) |
(...skipping 228 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
278 int nChar, | 273 int nChar, |
279 int modifier) { | 274 int modifier) { |
280 CPDFSDK_PageView* pPageView = FormHandleToPageView(hHandle, page); | 275 CPDFSDK_PageView* pPageView = FormHandleToPageView(hHandle, page); |
281 if (!pPageView) | 276 if (!pPageView) |
282 return FALSE; | 277 return FALSE; |
283 | 278 |
284 return pPageView->OnChar(nChar, modifier); | 279 return pPageView->OnChar(nChar, modifier); |
285 } | 280 } |
286 | 281 |
287 DLLEXPORT FPDF_BOOL STDCALL FORM_ForceToKillFocus(FPDF_FORMHANDLE hHandle) { | 282 DLLEXPORT FPDF_BOOL STDCALL FORM_ForceToKillFocus(FPDF_FORMHANDLE hHandle) { |
288 CPDFSDK_Document* pSDKDoc = FormHandleToSDKDoc(hHandle); | 283 CPDFSDK_Document* pSDKDoc = CPDFSDK_Document::FromFPDFFormHandle(hHandle); |
289 if (!pSDKDoc) | 284 if (!pSDKDoc) |
290 return FALSE; | 285 return FALSE; |
291 | 286 |
292 return pSDKDoc->KillFocusAnnot(0); | 287 return pSDKDoc->KillFocusAnnot(0); |
293 } | 288 } |
294 | 289 |
295 DLLEXPORT void STDCALL FPDF_FFLDraw(FPDF_FORMHANDLE hHandle, | 290 DLLEXPORT void STDCALL FPDF_FFLDraw(FPDF_FORMHANDLE hHandle, |
296 FPDF_BITMAP bitmap, | 291 FPDF_BITMAP bitmap, |
297 FPDF_PAGE page, | 292 FPDF_PAGE page, |
298 int start_x, | 293 int start_x, |
(...skipping 375 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
674 | 669 |
675 CPDFSDK_PageView* pPageView = pSDKDoc->GetPageView(pPage, FALSE); | 670 CPDFSDK_PageView* pPageView = pSDKDoc->GetPageView(pPage, FALSE); |
676 if (pPageView) { | 671 if (pPageView) { |
677 pPageView->SetValid(FALSE); | 672 pPageView->SetValid(FALSE); |
678 // RemovePageView() takes care of the delete for us. | 673 // RemovePageView() takes care of the delete for us. |
679 pSDKDoc->RemovePageView(pPage); | 674 pSDKDoc->RemovePageView(pPage); |
680 } | 675 } |
681 } | 676 } |
682 | 677 |
683 DLLEXPORT void STDCALL FORM_DoDocumentJSAction(FPDF_FORMHANDLE hHandle) { | 678 DLLEXPORT void STDCALL FORM_DoDocumentJSAction(FPDF_FORMHANDLE hHandle) { |
684 CPDFSDK_Document* pSDKDoc = FormHandleToSDKDoc(hHandle); | 679 CPDFSDK_Document* pSDKDoc = CPDFSDK_Document::FromFPDFFormHandle(hHandle); |
685 if (pSDKDoc && ((CPDFDoc_Environment*)hHandle)->IsJSInitiated()) | 680 if (pSDKDoc && ((CPDFDoc_Environment*)hHandle)->IsJSInitiated()) |
686 pSDKDoc->ProcJavascriptFun(); | 681 pSDKDoc->ProcJavascriptFun(); |
687 } | 682 } |
688 | 683 |
689 DLLEXPORT void STDCALL FORM_DoDocumentOpenAction(FPDF_FORMHANDLE hHandle) { | 684 DLLEXPORT void STDCALL FORM_DoDocumentOpenAction(FPDF_FORMHANDLE hHandle) { |
690 CPDFSDK_Document* pSDKDoc = FormHandleToSDKDoc(hHandle); | 685 CPDFSDK_Document* pSDKDoc = CPDFSDK_Document::FromFPDFFormHandle(hHandle); |
691 if (pSDKDoc && ((CPDFDoc_Environment*)hHandle)->IsJSInitiated()) | 686 if (pSDKDoc && ((CPDFDoc_Environment*)hHandle)->IsJSInitiated()) |
692 pSDKDoc->ProcOpenAction(); | 687 pSDKDoc->ProcOpenAction(); |
693 } | 688 } |
694 | 689 |
695 DLLEXPORT void STDCALL FORM_DoDocumentAAction(FPDF_FORMHANDLE hHandle, | 690 DLLEXPORT void STDCALL FORM_DoDocumentAAction(FPDF_FORMHANDLE hHandle, |
696 int aaType) { | 691 int aaType) { |
697 CPDFSDK_Document* pSDKDoc = FormHandleToSDKDoc(hHandle); | 692 CPDFSDK_Document* pSDKDoc = CPDFSDK_Document::FromFPDFFormHandle(hHandle); |
698 if (!pSDKDoc) | 693 if (!pSDKDoc) |
699 return; | 694 return; |
700 | 695 |
701 CPDF_Document* pDoc = pSDKDoc->GetPDFDocument(); | 696 CPDF_Document* pDoc = pSDKDoc->GetPDFDocument(); |
702 CPDF_Dictionary* pDic = pDoc->GetRoot(); | 697 CPDF_Dictionary* pDic = pDoc->GetRoot(); |
703 if (!pDic) | 698 if (!pDic) |
704 return; | 699 return; |
705 | 700 |
706 CPDF_AAction aa = pDic->GetDictBy("AA"); | 701 CPDF_AAction aa = pDic->GetDictBy("AA"); |
707 if (aa.ActionExist((CPDF_AAction::AActionType)aaType)) { | 702 if (aa.ActionExist((CPDF_AAction::AActionType)aaType)) { |
(...skipping 26 matching lines...) Expand all Loading... |
734 pActionHandler->DoAction_Page(action, CPDF_AAction::OpenPage, pSDKDoc); | 729 pActionHandler->DoAction_Page(action, CPDF_AAction::OpenPage, pSDKDoc); |
735 } | 730 } |
736 } else { | 731 } else { |
737 if (aa.ActionExist(CPDF_AAction::ClosePage)) { | 732 if (aa.ActionExist(CPDF_AAction::ClosePage)) { |
738 CPDF_Action action = aa.GetAction(CPDF_AAction::ClosePage); | 733 CPDF_Action action = aa.GetAction(CPDF_AAction::ClosePage); |
739 pActionHandler->DoAction_Page(action, CPDF_AAction::ClosePage, pSDKDoc); | 734 pActionHandler->DoAction_Page(action, CPDF_AAction::ClosePage, pSDKDoc); |
740 } | 735 } |
741 } | 736 } |
742 } | 737 } |
743 } | 738 } |
OLD | NEW |