OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium 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 #include "pdf/pdfium/pdfium_engine.h" | 5 #include "pdf/pdfium/pdfium_engine.h" |
6 | 6 |
7 #include <math.h> | 7 #include <math.h> |
8 | 8 |
9 #include "base/i18n/icu_encoding_detection.h" | 9 #include "base/i18n/icu_encoding_detection.h" |
10 #include "base/i18n/icu_string_conversions.h" | 10 #include "base/i18n/icu_string_conversions.h" |
(...skipping 659 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
670 IFSDK_PAUSE::user = NULL; | 670 IFSDK_PAUSE::user = NULL; |
671 IFSDK_PAUSE::NeedToPauseNow = Pause_NeedToPauseNow; | 671 IFSDK_PAUSE::NeedToPauseNow = Pause_NeedToPauseNow; |
672 } | 672 } |
673 | 673 |
674 PDFiumEngine::~PDFiumEngine() { | 674 PDFiumEngine::~PDFiumEngine() { |
675 for (size_t i = 0; i < pages_.size(); ++i) | 675 for (size_t i = 0; i < pages_.size(); ++i) |
676 pages_[i]->Unload(); | 676 pages_[i]->Unload(); |
677 | 677 |
678 if (doc_) { | 678 if (doc_) { |
679 FORM_DoDocumentAAction(form_, FPDFDOC_AACTION_WC); | 679 FORM_DoDocumentAAction(form_, FPDFDOC_AACTION_WC); |
| 680 |
| 681 #ifdef PDF_USE_XFA |
| 682 // XFA may require |form_| to outlive |doc_|, so shut down in that order. |
680 FPDF_CloseDocument(doc_); | 683 FPDF_CloseDocument(doc_); |
681 FPDFDOC_ExitFormFillEnvironment(form_); | 684 FPDFDOC_ExitFormFillEnvironment(form_); |
| 685 #else |
| 686 // Normally |doc_| should outlive |form_|. |
| 687 FPDFDOC_ExitFormFillEnvironment(form_); |
| 688 FPDF_CloseDocument(doc_); |
| 689 #endif |
682 } | 690 } |
683 FPDFAvail_Destroy(fpdf_availability_); | 691 FPDFAvail_Destroy(fpdf_availability_); |
684 | 692 |
685 STLDeleteElements(&pages_); | 693 STLDeleteElements(&pages_); |
686 } | 694 } |
687 | 695 |
688 #ifdef PDF_USE_XFA | 696 #ifdef PDF_USE_XFA |
689 | 697 |
690 // This is just for testing, needs to be removed later | 698 // This is just for testing, needs to be removed later |
691 #if defined(WIN32) | 699 #if defined(WIN32) |
(...skipping 3339 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4031 double* height) { | 4039 double* height) { |
4032 FPDF_DOCUMENT doc = FPDF_LoadMemDocument(pdf_buffer, pdf_buffer_size, NULL); | 4040 FPDF_DOCUMENT doc = FPDF_LoadMemDocument(pdf_buffer, pdf_buffer_size, NULL); |
4033 if (!doc) | 4041 if (!doc) |
4034 return false; | 4042 return false; |
4035 bool success = FPDF_GetPageSizeByIndex(doc, page_number, width, height) != 0; | 4043 bool success = FPDF_GetPageSizeByIndex(doc, page_number, width, height) != 0; |
4036 FPDF_CloseDocument(doc); | 4044 FPDF_CloseDocument(doc); |
4037 return success; | 4045 return success; |
4038 } | 4046 } |
4039 | 4047 |
4040 } // namespace chrome_pdf | 4048 } // namespace chrome_pdf |
OLD | NEW |