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 #include <vector> | 10 #include <vector> |
(...skipping 240 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
251 // environment into the XFADocument and, that could get weird. | 251 // environment into the XFADocument and, that could get weird. |
252 if (pDocument->GetFormFillEnv()) | 252 if (pDocument->GetFormFillEnv()) |
253 return pDocument->GetFormFillEnv(); | 253 return pDocument->GetFormFillEnv(); |
254 #endif | 254 #endif |
255 | 255 |
256 CPDFSDK_FormFillEnvironment* pFormFillEnv = | 256 CPDFSDK_FormFillEnvironment* pFormFillEnv = |
257 new CPDFSDK_FormFillEnvironment(pDocument, formInfo); | 257 new CPDFSDK_FormFillEnvironment(pDocument, formInfo); |
258 | 258 |
259 #ifdef PDF_ENABLE_XFA | 259 #ifdef PDF_ENABLE_XFA |
260 pDocument->SetFormFillEnv(pFormFillEnv); | 260 pDocument->SetFormFillEnv(pFormFillEnv); |
261 CPDFXFA_App::GetInstance()->AddFormFillEnv(pFormFillEnv); | |
262 #endif // PDF_ENABLE_XFA | 261 #endif // PDF_ENABLE_XFA |
263 | 262 |
264 return pFormFillEnv; | 263 return pFormFillEnv; |
265 } | 264 } |
266 | 265 |
267 DLLEXPORT void STDCALL | 266 DLLEXPORT void STDCALL |
268 FPDFDOC_ExitFormFillEnvironment(FPDF_FORMHANDLE hHandle) { | 267 FPDFDOC_ExitFormFillEnvironment(FPDF_FORMHANDLE hHandle) { |
269 if (!hHandle) | 268 if (!hHandle) |
270 return; | 269 return; |
271 | 270 |
272 CPDFSDK_FormFillEnvironment* pFormFillEnv = | 271 CPDFSDK_FormFillEnvironment* pFormFillEnv = |
273 HandleToCPDFSDKEnvironment(hHandle); | 272 HandleToCPDFSDKEnvironment(hHandle); |
274 | 273 |
275 #ifdef PDF_ENABLE_XFA | 274 #ifdef PDF_ENABLE_XFA |
276 CPDFXFA_App::GetInstance()->RemoveFormFillEnv(pFormFillEnv); | |
277 | |
278 // Reset the focused annotations and remove the SDK document from the | 275 // Reset the focused annotations and remove the SDK document from the |
279 // XFA document. | 276 // XFA document. |
280 pFormFillEnv->ClearAllFocusedAnnots(); | 277 pFormFillEnv->ClearAllFocusedAnnots(); |
281 // If the document was closed first, it's possible the XFA document | 278 // If the document was closed first, it's possible the XFA document |
282 // is now a nullptr. | 279 // is now a nullptr. |
283 if (pFormFillEnv->GetXFADocument()) | 280 if (pFormFillEnv->GetXFADocument()) |
284 pFormFillEnv->GetXFADocument()->SetFormFillEnv(nullptr); | 281 pFormFillEnv->GetXFADocument()->SetFormFillEnv(nullptr); |
285 #endif // PDF_ENABLE_XFA | 282 #endif // PDF_ENABLE_XFA |
286 | 283 |
287 delete pFormFillEnv; | 284 delete pFormFillEnv; |
(...skipping 456 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
744 pFormFillEnv); | 741 pFormFillEnv); |
745 } | 742 } |
746 } else { | 743 } else { |
747 if (aa.ActionExist(CPDF_AAction::ClosePage)) { | 744 if (aa.ActionExist(CPDF_AAction::ClosePage)) { |
748 CPDF_Action action = aa.GetAction(CPDF_AAction::ClosePage); | 745 CPDF_Action action = aa.GetAction(CPDF_AAction::ClosePage); |
749 pActionHandler->DoAction_Page(action, CPDF_AAction::ClosePage, | 746 pActionHandler->DoAction_Page(action, CPDF_AAction::ClosePage, |
750 pFormFillEnv); | 747 pFormFillEnv); |
751 } | 748 } |
752 } | 749 } |
753 } | 750 } |
OLD | NEW |