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/json/json_writer.h" | 9 #include "base/json/json_writer.h" |
10 #include "base/logging.h" | 10 #include "base/logging.h" |
(...skipping 580 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
591 IPDF_JSPLATFORM::Doc_submitForm = Form_SubmitForm; | 591 IPDF_JSPLATFORM::Doc_submitForm = Form_SubmitForm; |
592 IPDF_JSPLATFORM::Doc_gotoPage = Form_GotoPage; | 592 IPDF_JSPLATFORM::Doc_gotoPage = Form_GotoPage; |
593 IPDF_JSPLATFORM::Field_browse = Form_Browse; | 593 IPDF_JSPLATFORM::Field_browse = Form_Browse; |
594 | 594 |
595 IFSDK_PAUSE::version = 1; | 595 IFSDK_PAUSE::version = 1; |
596 IFSDK_PAUSE::user = NULL; | 596 IFSDK_PAUSE::user = NULL; |
597 IFSDK_PAUSE::NeedToPauseNow = Pause_NeedToPauseNow; | 597 IFSDK_PAUSE::NeedToPauseNow = Pause_NeedToPauseNow; |
598 } | 598 } |
599 | 599 |
600 PDFiumEngine::~PDFiumEngine() { | 600 PDFiumEngine::~PDFiumEngine() { |
601 STLDeleteElements(&pages_); | 601 for (size_t i = 0; i < pages_.size(); ++i) |
| 602 pages_[i]->Unload(); |
| 603 |
602 if (doc_) { | 604 if (doc_) { |
603 if (form_) { | 605 if (form_) { |
604 FORM_DoDocumentAAction(form_, FPDFDOC_AACTION_WC); | 606 FORM_DoDocumentAAction(form_, FPDFDOC_AACTION_WC); |
605 FPDFDOC_ExitFormFillEnviroument(form_); | 607 FPDFDOC_ExitFormFillEnviroument(form_); |
606 } | 608 } |
607 FPDF_CloseDocument(doc_); | 609 FPDF_CloseDocument(doc_); |
608 } | 610 } |
609 | 611 |
610 if (fpdf_availability_) | 612 if (fpdf_availability_) |
611 FPDFAvail_Destroy(fpdf_availability_); | 613 FPDFAvail_Destroy(fpdf_availability_); |
| 614 |
| 615 STLDeleteElements(&pages_); |
612 } | 616 } |
613 | 617 |
614 int PDFiumEngine::GetBlock(void* param, unsigned long position, | 618 int PDFiumEngine::GetBlock(void* param, unsigned long position, |
615 unsigned char* buffer, unsigned long size) { | 619 unsigned char* buffer, unsigned long size) { |
616 DocumentLoader* loader = static_cast<DocumentLoader*>(param); | 620 DocumentLoader* loader = static_cast<DocumentLoader*>(param); |
617 return loader->GetBlock(position, size, buffer); | 621 return loader->GetBlock(position, size, buffer); |
618 } | 622 } |
619 | 623 |
620 bool PDFiumEngine::IsDataAvail(FX_FILEAVAIL* param, | 624 bool PDFiumEngine::IsDataAvail(FX_FILEAVAIL* param, |
621 size_t offset, size_t size) { | 625 size_t offset, size_t size) { |
(...skipping 2800 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3422 double* height) { | 3426 double* height) { |
3423 FPDF_DOCUMENT doc = FPDF_LoadMemDocument(pdf_buffer, pdf_buffer_size, NULL); | 3427 FPDF_DOCUMENT doc = FPDF_LoadMemDocument(pdf_buffer, pdf_buffer_size, NULL); |
3424 if (!doc) | 3428 if (!doc) |
3425 return false; | 3429 return false; |
3426 bool success = FPDF_GetPageSizeByIndex(doc, page_number, width, height) != 0; | 3430 bool success = FPDF_GetPageSizeByIndex(doc, page_number, width, height) != 0; |
3427 FPDF_CloseDocument(doc); | 3431 FPDF_CloseDocument(doc); |
3428 return success; | 3432 return success; |
3429 } | 3433 } |
3430 | 3434 |
3431 } // namespace chrome_pdf | 3435 } // namespace chrome_pdf |
OLD | NEW |