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 236 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
247 // If the CPDFXFA_Document has a SDKDocument already then we've done this | 247 // If the CPDFXFA_Document has a SDKDocument already then we've done this |
248 // and can just return the old Env. Otherwise, we'll end up setting a new | 248 // and can just return the old Env. Otherwise, we'll end up setting a new |
249 // SDKDocument into the XFADocument and, that could get weird. | 249 // SDKDocument into the XFADocument and, that could get weird. |
250 if (pDocument->GetSDKDoc()) | 250 if (pDocument->GetSDKDoc()) |
251 return pDocument->GetSDKDoc()->GetEnv(); | 251 return pDocument->GetSDKDoc()->GetEnv(); |
252 #endif | 252 #endif |
253 | 253 |
254 CPDFSDK_Environment* pEnv = new CPDFSDK_Environment(pDocument, formInfo); | 254 CPDFSDK_Environment* pEnv = new CPDFSDK_Environment(pDocument, formInfo); |
255 | 255 |
256 #ifdef PDF_ENABLE_XFA | 256 #ifdef PDF_ENABLE_XFA |
257 // Ownership of the SDKDocument is passed to the CPDFXFA_Document. | 257 pDocument->SetSDKDoc(pEnv->GetSDKDocument()); |
258 pDocument->SetSDKDoc(pdfium::WrapUnique(pEnv->GetSDKDocument())); | |
259 CPDFXFA_App::GetInstance()->AddFormFillEnv(pEnv); | 258 CPDFXFA_App::GetInstance()->AddFormFillEnv(pEnv); |
260 #endif // PDF_ENABLE_XFA | 259 #endif // PDF_ENABLE_XFA |
261 | 260 |
262 return pEnv; | 261 return pEnv; |
263 } | 262 } |
264 | 263 |
265 DLLEXPORT void STDCALL | 264 DLLEXPORT void STDCALL |
266 FPDFDOC_ExitFormFillEnvironment(FPDF_FORMHANDLE hHandle) { | 265 FPDFDOC_ExitFormFillEnvironment(FPDF_FORMHANDLE hHandle) { |
267 if (!hHandle) | 266 if (!hHandle) |
268 return; | 267 return; |
269 | 268 |
270 CPDFSDK_Environment* pEnv = HandleToCPDFSDKEnvironment(hHandle); | 269 CPDFSDK_Environment* pEnv = HandleToCPDFSDKEnvironment(hHandle); |
271 | 270 |
272 #ifdef PDF_ENABLE_XFA | 271 #ifdef PDF_ENABLE_XFA |
273 CPDFXFA_App::GetInstance()->RemoveFormFillEnv(pEnv); | 272 CPDFXFA_App::GetInstance()->RemoveFormFillEnv(pEnv); |
274 #else // PDF_ENABLE_XFA | 273 |
| 274 // Reset the focused annotations and remove the SDK document from the |
| 275 // XFA document. |
275 if (CPDFSDK_Document* pSDKDoc = pEnv->GetSDKDocument()) { | 276 if (CPDFSDK_Document* pSDKDoc = pEnv->GetSDKDocument()) { |
276 pEnv->SetSDKDocument(nullptr); | 277 pSDKDoc->ClearAllFocusedAnnots(); |
277 delete pSDKDoc; | 278 pSDKDoc->GetXFADocument()->SetSDKDoc(nullptr); |
278 } | 279 } |
279 #endif // PDF_ENABLE_XFA | 280 #endif // PDF_ENABLE_XFA |
280 | 281 |
281 delete pEnv; | 282 delete pEnv; |
282 } | 283 } |
283 | 284 |
284 DLLEXPORT FPDF_BOOL STDCALL FORM_OnMouseMove(FPDF_FORMHANDLE hHandle, | 285 DLLEXPORT FPDF_BOOL STDCALL FORM_OnMouseMove(FPDF_FORMHANDLE hHandle, |
285 FPDF_PAGE page, | 286 FPDF_PAGE page, |
286 int modifier, | 287 int modifier, |
287 double page_x, | 288 double page_x, |
(...skipping 445 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
733 CPDF_Action action = aa.GetAction(CPDF_AAction::OpenPage); | 734 CPDF_Action action = aa.GetAction(CPDF_AAction::OpenPage); |
734 pActionHandler->DoAction_Page(action, CPDF_AAction::OpenPage, pSDKDoc); | 735 pActionHandler->DoAction_Page(action, CPDF_AAction::OpenPage, pSDKDoc); |
735 } | 736 } |
736 } else { | 737 } else { |
737 if (aa.ActionExist(CPDF_AAction::ClosePage)) { | 738 if (aa.ActionExist(CPDF_AAction::ClosePage)) { |
738 CPDF_Action action = aa.GetAction(CPDF_AAction::ClosePage); | 739 CPDF_Action action = aa.GetAction(CPDF_AAction::ClosePage); |
739 pActionHandler->DoAction_Page(action, CPDF_AAction::ClosePage, pSDKDoc); | 740 pActionHandler->DoAction_Page(action, CPDF_AAction::ClosePage, pSDKDoc); |
740 } | 741 } |
741 } | 742 } |
742 } | 743 } |
OLD | NEW |