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

Side by Side Diff: fpdfsdk/fpdfformfill.cpp

Issue 2353303004: Make creation of CPDFSDK_Document clearer (Closed)
Patch Set: Created 4 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
« no previous file with comments | « no previous file | fpdfsdk/fpdfxfa/fpdfxfa_doc.cpp » ('j') | fpdfsdk/fpdfxfa/fpdfxfa_doc.cpp » ('J')
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>
(...skipping 225 matching lines...) Expand 10 before | Expand all | Expand 10 after
236 const int kRequiredVersion = 1; 236 const int kRequiredVersion = 1;
237 #endif // PDF_ENABLE_XFA 237 #endif // PDF_ENABLE_XFA
238 if (!formInfo || formInfo->version != kRequiredVersion) 238 if (!formInfo || formInfo->version != kRequiredVersion)
239 return nullptr; 239 return nullptr;
240 240
241 UnderlyingDocumentType* pDocument = UnderlyingFromFPDFDocument(document); 241 UnderlyingDocumentType* pDocument = UnderlyingFromFPDFDocument(document);
242 if (!pDocument) 242 if (!pDocument)
243 return nullptr; 243 return nullptr;
244 244
245 CPDFSDK_Environment* pEnv = new CPDFSDK_Environment(pDocument, formInfo); 245 CPDFSDK_Environment* pEnv = new CPDFSDK_Environment(pDocument, formInfo);
246 CPDFSDK_Document* pSDKDoc = new CPDFSDK_Document(pDocument, pEnv);
Tom Sepez 2016/09/22 17:02:22 I like how this adds credibility to the theory tha
dsinclair 2016/09/22 17:32:12 Done.
247 pEnv->SetSDKDocument(pSDKDoc);
248
246 #ifdef PDF_ENABLE_XFA 249 #ifdef PDF_ENABLE_XFA
247 pEnv->SetSDKDocument(pDocument->GetSDKDocument(pEnv)); 250 pDocument->SetSDKDoc(WrapUnique(pSDKDoc));
248 CPDFXFA_App* pApp = CPDFXFA_App::GetInstance(); 251 CPDFXFA_App::GetInstance()->AddFormFillEnv(pEnv);
249 pApp->AddFormFillEnv(pEnv);
250 #else // PDF_ENABLE_XFA
251 pEnv->SetSDKDocument(new CPDFSDK_Document(pDocument, pEnv));
252 #endif // PDF_ENABLE_XFA 252 #endif // PDF_ENABLE_XFA
253
253 return pEnv; 254 return pEnv;
254 } 255 }
255 256
256 DLLEXPORT void STDCALL 257 DLLEXPORT void STDCALL
257 FPDFDOC_ExitFormFillEnvironment(FPDF_FORMHANDLE hHandle) { 258 FPDFDOC_ExitFormFillEnvironment(FPDF_FORMHANDLE hHandle) {
258 if (!hHandle) 259 if (!hHandle)
259 return; 260 return;
261
260 CPDFSDK_Environment* pEnv = HandleToCPDFSDKEnvironment(hHandle); 262 CPDFSDK_Environment* pEnv = HandleToCPDFSDKEnvironment(hHandle);
263
261 #ifdef PDF_ENABLE_XFA 264 #ifdef PDF_ENABLE_XFA
262 CPDFXFA_App* pApp = CPDFXFA_App::GetInstance(); 265 CPDFXFA_App::GetInstance()->RemoveFormFillEnv(pEnv);
263 pApp->RemoveFormFillEnv(pEnv);
264 #else // PDF_ENABLE_XFA 266 #else // PDF_ENABLE_XFA
265 if (CPDFSDK_Document* pSDKDoc = pEnv->GetSDKDocument()) { 267 if (CPDFSDK_Document* pSDKDoc = pEnv->GetSDKDocument()) {
266 pEnv->SetSDKDocument(nullptr); 268 pEnv->SetSDKDocument(nullptr);
Tom Sepez 2016/09/22 17:02:22 Similarly, this is the only place where this gets
dsinclair 2016/09/22 17:32:12 That we can't do. The environment only owns the SD
267 delete pSDKDoc; 269 delete pSDKDoc;
268 } 270 }
269 #endif // PDF_ENABLE_XFA 271 #endif // PDF_ENABLE_XFA
272
270 delete pEnv; 273 delete pEnv;
271 } 274 }
272 275
273 DLLEXPORT FPDF_BOOL STDCALL FORM_OnMouseMove(FPDF_FORMHANDLE hHandle, 276 DLLEXPORT FPDF_BOOL STDCALL FORM_OnMouseMove(FPDF_FORMHANDLE hHandle,
274 FPDF_PAGE page, 277 FPDF_PAGE page,
275 int modifier, 278 int modifier,
276 double page_x, 279 double page_x,
277 double page_y) { 280 double page_y) {
278 CPDFSDK_PageView* pPageView = FormHandleToPageView(hHandle, page); 281 CPDFSDK_PageView* pPageView = FormHandleToPageView(hHandle, page);
279 if (!pPageView) 282 if (!pPageView)
(...skipping 442 matching lines...) Expand 10 before | Expand all | Expand 10 after
722 CPDF_Action action = aa.GetAction(CPDF_AAction::OpenPage); 725 CPDF_Action action = aa.GetAction(CPDF_AAction::OpenPage);
723 pActionHandler->DoAction_Page(action, CPDF_AAction::OpenPage, pSDKDoc); 726 pActionHandler->DoAction_Page(action, CPDF_AAction::OpenPage, pSDKDoc);
724 } 727 }
725 } else { 728 } else {
726 if (aa.ActionExist(CPDF_AAction::ClosePage)) { 729 if (aa.ActionExist(CPDF_AAction::ClosePage)) {
727 CPDF_Action action = aa.GetAction(CPDF_AAction::ClosePage); 730 CPDF_Action action = aa.GetAction(CPDF_AAction::ClosePage);
728 pActionHandler->DoAction_Page(action, CPDF_AAction::ClosePage, pSDKDoc); 731 pActionHandler->DoAction_Page(action, CPDF_AAction::ClosePage, pSDKDoc);
729 } 732 }
730 } 733 }
731 } 734 }
OLDNEW
« no previous file with comments | « no previous file | fpdfsdk/fpdfxfa/fpdfxfa_doc.cpp » ('j') | fpdfsdk/fpdfxfa/fpdfxfa_doc.cpp » ('J')

Powered by Google App Engine
This is Rietveld 408576698