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

Side by Side Diff: fpdfsdk/fpdfformfill.cpp

Issue 2333413003: Rename CPDFDoc_Environment to CPDFSDK_Environment (Closed)
Patch Set: Review feedback Created 4 years, 3 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/formfiller/cffl_textfield.cpp ('k') | fpdfsdk/fpdfxfa/cpdfxfa_docenvironment.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 #include <vector> 10 #include <vector>
11 11
12 #include "core/fpdfapi/fpdf_page/include/cpdf_page.h" 12 #include "core/fpdfapi/fpdf_page/include/cpdf_page.h"
13 #include "core/fpdfapi/fpdf_parser/include/cpdf_document.h" 13 #include "core/fpdfapi/fpdf_parser/include/cpdf_document.h"
14 #include "core/fpdfapi/fpdf_render/include/cpdf_renderoptions.h" 14 #include "core/fpdfapi/fpdf_render/include/cpdf_renderoptions.h"
15 #include "core/fpdfdoc/include/cpdf_formcontrol.h" 15 #include "core/fpdfdoc/include/cpdf_formcontrol.h"
16 #include "core/fpdfdoc/include/cpdf_formfield.h" 16 #include "core/fpdfdoc/include/cpdf_formfield.h"
17 #include "core/fpdfdoc/include/cpdf_interform.h" 17 #include "core/fpdfdoc/include/cpdf_interform.h"
18 #include "core/fpdfdoc/include/cpdf_occontext.h" 18 #include "core/fpdfdoc/include/cpdf_occontext.h"
19 #include "core/fxge/include/cfx_fxgedevice.h" 19 #include "core/fxge/include/cfx_fxgedevice.h"
20 #include "fpdfsdk/include/cpdfdoc_environment.h"
21 #include "fpdfsdk/include/cpdfsdk_document.h" 20 #include "fpdfsdk/include/cpdfsdk_document.h"
21 #include "fpdfsdk/include/cpdfsdk_environment.h"
22 #include "fpdfsdk/include/cpdfsdk_interform.h" 22 #include "fpdfsdk/include/cpdfsdk_interform.h"
23 #include "fpdfsdk/include/cpdfsdk_pageview.h" 23 #include "fpdfsdk/include/cpdfsdk_pageview.h"
24 #include "fpdfsdk/include/fsdk_actionhandler.h" 24 #include "fpdfsdk/include/fsdk_actionhandler.h"
25 #include "fpdfsdk/include/fsdk_define.h" 25 #include "fpdfsdk/include/fsdk_define.h"
26 #include "public/fpdfview.h" 26 #include "public/fpdfview.h"
27 #include "third_party/base/stl_util.h" 27 #include "third_party/base/stl_util.h"
28 28
29 #ifdef PDF_ENABLE_XFA 29 #ifdef PDF_ENABLE_XFA
30 #include "fpdfsdk/fpdfxfa/include/fpdfxfa_app.h" 30 #include "fpdfsdk/fpdfxfa/include/fpdfxfa_app.h"
31 #include "fpdfsdk/fpdfxfa/include/fpdfxfa_doc.h" 31 #include "fpdfsdk/fpdfxfa/include/fpdfxfa_doc.h"
32 #include "fpdfsdk/fpdfxfa/include/fpdfxfa_page.h" 32 #include "fpdfsdk/fpdfxfa/include/fpdfxfa_page.h"
33 #include "xfa/fxfa/include/xfa_ffdocview.h" 33 #include "xfa/fxfa/include/xfa_ffdocview.h"
34 #include "xfa/fxfa/include/xfa_ffpageview.h" 34 #include "xfa/fxfa/include/xfa_ffpageview.h"
35 #include "xfa/fxfa/include/xfa_ffwidget.h" 35 #include "xfa/fxfa/include/xfa_ffwidget.h"
36 #endif // PDF_ENABLE_XFA 36 #endif // PDF_ENABLE_XFA
37 37
38 namespace { 38 namespace {
39 39
40 CPDFSDK_Environment* HandleToCPDFSDKEnvironment(FPDF_FORMHANDLE handle) {
41 return static_cast<CPDFSDK_Environment*>(handle);
42 }
43
40 CPDFSDK_InterForm* FormHandleToInterForm(FPDF_FORMHANDLE hHandle) { 44 CPDFSDK_InterForm* FormHandleToInterForm(FPDF_FORMHANDLE hHandle) {
41 CPDFSDK_Document* pSDKDoc = CPDFSDK_Document::FromFPDFFormHandle(hHandle); 45 CPDFSDK_Document* pSDKDoc = CPDFSDK_Document::FromFPDFFormHandle(hHandle);
42 return pSDKDoc ? pSDKDoc->GetInterForm() : nullptr; 46 return pSDKDoc ? pSDKDoc->GetInterForm() : nullptr;
43 } 47 }
44 48
45 CPDFSDK_PageView* FormHandleToPageView(FPDF_FORMHANDLE hHandle, 49 CPDFSDK_PageView* FormHandleToPageView(FPDF_FORMHANDLE hHandle,
46 FPDF_PAGE page) { 50 FPDF_PAGE page) {
47 UnderlyingPageType* pPage = UnderlyingFromFPDFPage(page); 51 UnderlyingPageType* pPage = UnderlyingFromFPDFPage(page);
48 if (!pPage) 52 if (!pPage)
49 return nullptr; 53 return nullptr;
(...skipping 29 matching lines...) Expand all
79 if (!pPage) 83 if (!pPage)
80 return; 84 return;
81 85
82 #ifdef PDF_ENABLE_XFA 86 #ifdef PDF_ENABLE_XFA
83 CPDFXFA_Document* pDocument = pPage->GetDocument(); 87 CPDFXFA_Document* pDocument = pPage->GetDocument();
84 if (!pDocument) 88 if (!pDocument)
85 return; 89 return;
86 CPDF_Document* pPDFDoc = pDocument->GetPDFDoc(); 90 CPDF_Document* pPDFDoc = pDocument->GetPDFDoc();
87 if (!pPDFDoc) 91 if (!pPDFDoc)
88 return; 92 return;
89 CPDFDoc_Environment* pEnv = (CPDFDoc_Environment*)hHandle; 93 CPDFSDK_Environment* pEnv = HandleToCPDFSDKEnvironment(hHandle);
90 CPDFSDK_Document* pFXDoc = pEnv->GetSDKDocument(); 94 CPDFSDK_Document* pFXDoc = pEnv->GetSDKDocument();
91 if (!pFXDoc) 95 if (!pFXDoc)
92 return; 96 return;
93 #endif // PDF_ENABLE_XFA 97 #endif // PDF_ENABLE_XFA
94 98
95 CFX_Matrix matrix; 99 CFX_Matrix matrix;
96 pPage->GetDisplayMatrix(matrix, start_x, start_y, size_x, size_y, rotate); 100 pPage->GetDisplayMatrix(matrix, start_x, start_y, size_x, size_y, rotate);
97 101
98 FX_RECT clip(start_x, start_y, start_x + size_x, start_y + size_y); 102 FX_RECT clip(start_x, start_y, start_x + size_x, start_y + size_y);
99 103
(...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after
231 #else // PDF_ENABLE_XFA 235 #else // PDF_ENABLE_XFA
232 const int kRequiredVersion = 1; 236 const int kRequiredVersion = 1;
233 #endif // PDF_ENABLE_XFA 237 #endif // PDF_ENABLE_XFA
234 if (!formInfo || formInfo->version != kRequiredVersion) 238 if (!formInfo || formInfo->version != kRequiredVersion)
235 return nullptr; 239 return nullptr;
236 240
237 UnderlyingDocumentType* pDocument = UnderlyingFromFPDFDocument(document); 241 UnderlyingDocumentType* pDocument = UnderlyingFromFPDFDocument(document);
238 if (!pDocument) 242 if (!pDocument)
239 return nullptr; 243 return nullptr;
240 244
241 CPDFDoc_Environment* pEnv = new CPDFDoc_Environment(pDocument, formInfo); 245 CPDFSDK_Environment* pEnv = new CPDFSDK_Environment(pDocument, formInfo);
242 #ifdef PDF_ENABLE_XFA 246 #ifdef PDF_ENABLE_XFA
243 pEnv->SetSDKDocument(pDocument->GetSDKDocument(pEnv)); 247 pEnv->SetSDKDocument(pDocument->GetSDKDocument(pEnv));
244 CPDFXFA_App* pApp = CPDFXFA_App::GetInstance(); 248 CPDFXFA_App* pApp = CPDFXFA_App::GetInstance();
245 pApp->AddFormFillEnv(pEnv); 249 pApp->AddFormFillEnv(pEnv);
246 #else // PDF_ENABLE_XFA 250 #else // PDF_ENABLE_XFA
247 pEnv->SetSDKDocument(new CPDFSDK_Document(pDocument, pEnv)); 251 pEnv->SetSDKDocument(new CPDFSDK_Document(pDocument, pEnv));
248 #endif // PDF_ENABLE_XFA 252 #endif // PDF_ENABLE_XFA
249 return pEnv; 253 return pEnv;
250 } 254 }
251 255
252 DLLEXPORT void STDCALL 256 DLLEXPORT void STDCALL
253 FPDFDOC_ExitFormFillEnvironment(FPDF_FORMHANDLE hHandle) { 257 FPDFDOC_ExitFormFillEnvironment(FPDF_FORMHANDLE hHandle) {
254 if (!hHandle) 258 if (!hHandle)
255 return; 259 return;
256 CPDFDoc_Environment* pEnv = (CPDFDoc_Environment*)hHandle; 260 CPDFSDK_Environment* pEnv = HandleToCPDFSDKEnvironment(hHandle);
257 #ifdef PDF_ENABLE_XFA 261 #ifdef PDF_ENABLE_XFA
258 CPDFXFA_App* pApp = CPDFXFA_App::GetInstance(); 262 CPDFXFA_App* pApp = CPDFXFA_App::GetInstance();
259 pApp->RemoveFormFillEnv(pEnv); 263 pApp->RemoveFormFillEnv(pEnv);
260 #else // PDF_ENABLE_XFA 264 #else // PDF_ENABLE_XFA
261 if (CPDFSDK_Document* pSDKDoc = pEnv->GetSDKDocument()) { 265 if (CPDFSDK_Document* pSDKDoc = pEnv->GetSDKDocument()) {
262 pEnv->SetSDKDocument(nullptr); 266 pEnv->SetSDKDocument(nullptr);
263 delete pSDKDoc; 267 delete pSDKDoc;
264 } 268 }
265 #endif // PDF_ENABLE_XFA 269 #endif // PDF_ENABLE_XFA
266 delete pEnv; 270 delete pEnv;
(...skipping 367 matching lines...) Expand 10 before | Expand all | Expand 10 after
634 FPDF_FORMHANDLE hHandle) { 638 FPDF_FORMHANDLE hHandle) {
635 if (CPDFSDK_PageView* pPageView = FormHandleToPageView(hHandle, page)) 639 if (CPDFSDK_PageView* pPageView = FormHandleToPageView(hHandle, page))
636 pPageView->SetValid(TRUE); 640 pPageView->SetValid(TRUE);
637 } 641 }
638 642
639 DLLEXPORT void STDCALL FORM_OnBeforeClosePage(FPDF_PAGE page, 643 DLLEXPORT void STDCALL FORM_OnBeforeClosePage(FPDF_PAGE page,
640 FPDF_FORMHANDLE hHandle) { 644 FPDF_FORMHANDLE hHandle) {
641 if (!hHandle) 645 if (!hHandle)
642 return; 646 return;
643 647
644 CPDFSDK_Document* pSDKDoc = ((CPDFDoc_Environment*)hHandle)->GetSDKDocument(); 648 CPDFSDK_Document* pSDKDoc =
649 HandleToCPDFSDKEnvironment(hHandle)->GetSDKDocument();
645 if (!pSDKDoc) 650 if (!pSDKDoc)
646 return; 651 return;
647 652
648 UnderlyingPageType* pPage = UnderlyingFromFPDFPage(page); 653 UnderlyingPageType* pPage = UnderlyingFromFPDFPage(page);
649 if (!pPage) 654 if (!pPage)
650 return; 655 return;
651 656
652 CPDFSDK_PageView* pPageView = pSDKDoc->GetPageView(pPage, false); 657 CPDFSDK_PageView* pPageView = pSDKDoc->GetPageView(pPage, false);
653 if (pPageView) { 658 if (pPageView) {
654 pPageView->SetValid(FALSE); 659 pPageView->SetValid(FALSE);
655 // RemovePageView() takes care of the delete for us. 660 // RemovePageView() takes care of the delete for us.
656 pSDKDoc->RemovePageView(pPage); 661 pSDKDoc->RemovePageView(pPage);
657 } 662 }
658 } 663 }
659 664
660 DLLEXPORT void STDCALL FORM_DoDocumentJSAction(FPDF_FORMHANDLE hHandle) { 665 DLLEXPORT void STDCALL FORM_DoDocumentJSAction(FPDF_FORMHANDLE hHandle) {
661 CPDFSDK_Document* pSDKDoc = CPDFSDK_Document::FromFPDFFormHandle(hHandle); 666 CPDFSDK_Document* pSDKDoc = CPDFSDK_Document::FromFPDFFormHandle(hHandle);
662 if (pSDKDoc && ((CPDFDoc_Environment*)hHandle)->IsJSInitiated()) 667 if (pSDKDoc && HandleToCPDFSDKEnvironment(hHandle)->IsJSInitiated())
663 pSDKDoc->ProcJavascriptFun(); 668 pSDKDoc->ProcJavascriptFun();
664 } 669 }
665 670
666 DLLEXPORT void STDCALL FORM_DoDocumentOpenAction(FPDF_FORMHANDLE hHandle) { 671 DLLEXPORT void STDCALL FORM_DoDocumentOpenAction(FPDF_FORMHANDLE hHandle) {
667 CPDFSDK_Document* pSDKDoc = CPDFSDK_Document::FromFPDFFormHandle(hHandle); 672 CPDFSDK_Document* pSDKDoc = CPDFSDK_Document::FromFPDFFormHandle(hHandle);
668 if (pSDKDoc && ((CPDFDoc_Environment*)hHandle)->IsJSInitiated()) 673 if (pSDKDoc && HandleToCPDFSDKEnvironment(hHandle)->IsJSInitiated())
669 pSDKDoc->ProcOpenAction(); 674 pSDKDoc->ProcOpenAction();
670 } 675 }
671 676
672 DLLEXPORT void STDCALL FORM_DoDocumentAAction(FPDF_FORMHANDLE hHandle, 677 DLLEXPORT void STDCALL FORM_DoDocumentAAction(FPDF_FORMHANDLE hHandle,
673 int aaType) { 678 int aaType) {
674 CPDFSDK_Document* pSDKDoc = CPDFSDK_Document::FromFPDFFormHandle(hHandle); 679 CPDFSDK_Document* pSDKDoc = CPDFSDK_Document::FromFPDFFormHandle(hHandle);
675 if (!pSDKDoc) 680 if (!pSDKDoc)
676 return; 681 return;
677 682
678 CPDF_Document* pDoc = pSDKDoc->GetPDFDocument(); 683 CPDF_Document* pDoc = pSDKDoc->GetPDFDocument();
679 CPDF_Dictionary* pDic = pDoc->GetRoot(); 684 CPDF_Dictionary* pDic = pDoc->GetRoot();
680 if (!pDic) 685 if (!pDic)
681 return; 686 return;
682 687
683 CPDF_AAction aa(pDic->GetDictBy("AA")); 688 CPDF_AAction aa(pDic->GetDictBy("AA"));
684 if (aa.ActionExist((CPDF_AAction::AActionType)aaType)) { 689 if (aa.ActionExist((CPDF_AAction::AActionType)aaType)) {
685 CPDF_Action action = aa.GetAction((CPDF_AAction::AActionType)aaType); 690 CPDF_Action action = aa.GetAction((CPDF_AAction::AActionType)aaType);
686 CPDFSDK_ActionHandler* pActionHandler = 691 CPDFSDK_ActionHandler* pActionHandler =
687 ((CPDFDoc_Environment*)hHandle)->GetActionHander(); 692 HandleToCPDFSDKEnvironment(hHandle)->GetActionHander();
688 pActionHandler->DoAction_Document(action, (CPDF_AAction::AActionType)aaType, 693 pActionHandler->DoAction_Document(action, (CPDF_AAction::AActionType)aaType,
689 pSDKDoc); 694 pSDKDoc);
690 } 695 }
691 } 696 }
692 697
693 DLLEXPORT void STDCALL FORM_DoPageAAction(FPDF_PAGE page, 698 DLLEXPORT void STDCALL FORM_DoPageAAction(FPDF_PAGE page,
694 FPDF_FORMHANDLE hHandle, 699 FPDF_FORMHANDLE hHandle,
695 int aaType) { 700 int aaType) {
696 if (!hHandle) 701 if (!hHandle)
697 return; 702 return;
698 703
699 CPDFSDK_Document* pSDKDoc = CPDFSDK_Document::FromFPDFFormHandle(hHandle); 704 CPDFSDK_Document* pSDKDoc = CPDFSDK_Document::FromFPDFFormHandle(hHandle);
700 if (!pSDKDoc) 705 if (!pSDKDoc)
701 return; 706 return;
702 707
703 UnderlyingPageType* pPage = UnderlyingFromFPDFPage(page); 708 UnderlyingPageType* pPage = UnderlyingFromFPDFPage(page);
704 CPDF_Page* pPDFPage = CPDFPageFromFPDFPage(page); 709 CPDF_Page* pPDFPage = CPDFPageFromFPDFPage(page);
705 if (!pPDFPage) 710 if (!pPDFPage)
706 return; 711 return;
707 712
708 if (!pSDKDoc->GetPageView(pPage, false)) 713 if (!pSDKDoc->GetPageView(pPage, false))
709 return; 714 return;
710 715
711 CPDFDoc_Environment* pEnv = pSDKDoc->GetEnv(); 716 CPDFSDK_Environment* pEnv = pSDKDoc->GetEnv();
712 CPDFSDK_ActionHandler* pActionHandler = pEnv->GetActionHander(); 717 CPDFSDK_ActionHandler* pActionHandler = pEnv->GetActionHander();
713 CPDF_Dictionary* pPageDict = pPDFPage->m_pFormDict; 718 CPDF_Dictionary* pPageDict = pPDFPage->m_pFormDict;
714 CPDF_AAction aa(pPageDict->GetDictBy("AA")); 719 CPDF_AAction aa(pPageDict->GetDictBy("AA"));
715 if (FPDFPAGE_AACTION_OPEN == aaType) { 720 if (FPDFPAGE_AACTION_OPEN == aaType) {
716 if (aa.ActionExist(CPDF_AAction::OpenPage)) { 721 if (aa.ActionExist(CPDF_AAction::OpenPage)) {
717 CPDF_Action action = aa.GetAction(CPDF_AAction::OpenPage); 722 CPDF_Action action = aa.GetAction(CPDF_AAction::OpenPage);
718 pActionHandler->DoAction_Page(action, CPDF_AAction::OpenPage, pSDKDoc); 723 pActionHandler->DoAction_Page(action, CPDF_AAction::OpenPage, pSDKDoc);
719 } 724 }
720 } else { 725 } else {
721 if (aa.ActionExist(CPDF_AAction::ClosePage)) { 726 if (aa.ActionExist(CPDF_AAction::ClosePage)) {
722 CPDF_Action action = aa.GetAction(CPDF_AAction::ClosePage); 727 CPDF_Action action = aa.GetAction(CPDF_AAction::ClosePage);
723 pActionHandler->DoAction_Page(action, CPDF_AAction::ClosePage, pSDKDoc); 728 pActionHandler->DoAction_Page(action, CPDF_AAction::ClosePage, pSDKDoc);
724 } 729 }
725 } 730 }
726 } 731 }
OLDNEW
« no previous file with comments | « fpdfsdk/formfiller/cffl_textfield.cpp ('k') | fpdfsdk/fpdfxfa/cpdfxfa_docenvironment.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698