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

Side by Side Diff: fpdfsdk/fpdfformfill.cpp

Issue 2396213002: Convert CPDFXFA_Document to use CPDFSDK_FormFillEnvironment (Closed)
Patch Set: Review fixes 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/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>
(...skipping 235 matching lines...) Expand 10 before | Expand all | Expand 10 after
246 return nullptr; 246 return nullptr;
247 247
248 UnderlyingDocumentType* pDocument = UnderlyingFromFPDFDocument(document); 248 UnderlyingDocumentType* pDocument = UnderlyingFromFPDFDocument(document);
249 if (!pDocument) 249 if (!pDocument)
250 return nullptr; 250 return nullptr;
251 251
252 #ifdef PDF_ENABLE_XFA 252 #ifdef PDF_ENABLE_XFA
253 // If the CPDFXFA_Document has a SDKDocument already then we've done this 253 // If the CPDFXFA_Document has a SDKDocument already then we've done this
254 // and can just return the old Env. Otherwise, we'll end up setting a new 254 // and can just return the old Env. Otherwise, we'll end up setting a new
255 // SDKDocument into the XFADocument and, that could get weird. 255 // SDKDocument into the XFADocument and, that could get weird.
256 if (pDocument->GetSDKDoc()) 256 if (pDocument->GetFormFillEnv())
257 return pDocument->GetSDKDoc()->GetEnv(); 257 return pDocument->GetFormFillEnv();
258 #endif 258 #endif
259 259
260 CPDFSDK_FormFillEnvironment* pFormFillEnv = 260 CPDFSDK_FormFillEnvironment* pFormFillEnv =
261 new CPDFSDK_FormFillEnvironment(pDocument, formInfo); 261 new CPDFSDK_FormFillEnvironment(pDocument, formInfo);
262 262
263 #ifdef PDF_ENABLE_XFA 263 #ifdef PDF_ENABLE_XFA
264 pDocument->SetSDKDoc(pFormFillEnv->GetSDKDocument()); 264 pDocument->SetFormFillEnv(pFormFillEnv);
265 CPDFXFA_App::GetInstance()->AddFormFillEnv(pFormFillEnv); 265 CPDFXFA_App::GetInstance()->AddFormFillEnv(pFormFillEnv);
266 #endif // PDF_ENABLE_XFA 266 #endif // PDF_ENABLE_XFA
267 267
268 return pFormFillEnv; 268 return pFormFillEnv;
269 } 269 }
270 270
271 DLLEXPORT void STDCALL 271 DLLEXPORT void STDCALL
272 FPDFDOC_ExitFormFillEnvironment(FPDF_FORMHANDLE hHandle) { 272 FPDFDOC_ExitFormFillEnvironment(FPDF_FORMHANDLE hHandle) {
273 if (!hHandle) 273 if (!hHandle)
274 return; 274 return;
275 275
276 CPDFSDK_FormFillEnvironment* pFormFillEnv = 276 CPDFSDK_FormFillEnvironment* pFormFillEnv =
277 HandleToCPDFSDKEnvironment(hHandle); 277 HandleToCPDFSDKEnvironment(hHandle);
278 278
279 #ifdef PDF_ENABLE_XFA 279 #ifdef PDF_ENABLE_XFA
280 CPDFXFA_App::GetInstance()->RemoveFormFillEnv(pFormFillEnv); 280 CPDFXFA_App::GetInstance()->RemoveFormFillEnv(pFormFillEnv);
281 281
282 // Reset the focused annotations and remove the SDK document from the 282 // Reset the focused annotations and remove the SDK document from the
283 // XFA document. 283 // XFA document.
284 pFormFillEnv->GetSDKDocument()->ClearAllFocusedAnnots(); 284 pFormFillEnv->GetSDKDocument()->ClearAllFocusedAnnots();
285 // If the document was closed first, it's possible the XFA document 285 // If the document was closed first, it's possible the XFA document
286 // is now a nullptr. 286 // is now a nullptr.
287 if (pFormFillEnv->GetSDKDocument()->GetXFADocument()) 287 if (pFormFillEnv->GetSDKDocument()->GetXFADocument())
288 pFormFillEnv->GetSDKDocument()->GetXFADocument()->SetSDKDoc(nullptr); 288 pFormFillEnv->GetSDKDocument()->GetXFADocument()->SetFormFillEnv(nullptr);
289 #endif // PDF_ENABLE_XFA 289 #endif // PDF_ENABLE_XFA
290 290
291 delete pFormFillEnv; 291 delete pFormFillEnv;
292 } 292 }
293 293
294 DLLEXPORT FPDF_BOOL STDCALL FORM_OnMouseMove(FPDF_FORMHANDLE hHandle, 294 DLLEXPORT FPDF_BOOL STDCALL FORM_OnMouseMove(FPDF_FORMHANDLE hHandle,
295 FPDF_PAGE page, 295 FPDF_PAGE page,
296 int modifier, 296 int modifier,
297 double page_x, 297 double page_x,
298 double page_y) { 298 double page_y) {
(...skipping 450 matching lines...) Expand 10 before | Expand all | Expand 10 after
749 pFormFillEnv); 749 pFormFillEnv);
750 } 750 }
751 } else { 751 } else {
752 if (aa.ActionExist(CPDF_AAction::ClosePage)) { 752 if (aa.ActionExist(CPDF_AAction::ClosePage)) {
753 CPDF_Action action = aa.GetAction(CPDF_AAction::ClosePage); 753 CPDF_Action action = aa.GetAction(CPDF_AAction::ClosePage);
754 pActionHandler->DoAction_Page(action, CPDF_AAction::ClosePage, 754 pActionHandler->DoAction_Page(action, CPDF_AAction::ClosePage,
755 pFormFillEnv); 755 pFormFillEnv);
756 } 756 }
757 } 757 }
758 } 758 }
OLDNEW
« no previous file with comments | « no previous file | fpdfsdk/fpdfxfa/cpdfxfa_docenvironment.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698