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

Side by Side Diff: fpdfsdk/src/fpdf_dataavail.cpp

Issue 1353093003: Support linearized loading (Closed) Base URL: https://pdfium.googlesource.com/pdfium.git@master
Patch Set: Created 5 years, 1 month 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
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_dataavail.h" 7 #include "../../public/fpdf_dataavail.h"
8 #include "../../public/fpdf_formfill.h" 8 #include "../../public/fpdf_formfill.h"
9 #include "../include/fsdk_define.h" 9 #include "../include/fsdk_define.h"
10 10
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after
80 pAvail->m_FileRead.Set(file); 80 pAvail->m_FileRead.Set(file);
81 pAvail->m_pDataAvail = 81 pAvail->m_pDataAvail =
82 IPDF_DataAvail::Create(&pAvail->m_FileAvail, &pAvail->m_FileRead); 82 IPDF_DataAvail::Create(&pAvail->m_FileAvail, &pAvail->m_FileRead);
83 return pAvail; 83 return pAvail;
84 } 84 }
85 85
86 DLLEXPORT void STDCALL FPDFAvail_Destroy(FPDF_AVAIL avail) { 86 DLLEXPORT void STDCALL FPDFAvail_Destroy(FPDF_AVAIL avail) {
87 delete (CFPDF_DataAvail*)avail; 87 delete (CFPDF_DataAvail*)avail;
88 } 88 }
89 89
90 DLLEXPORT int STDCALL FPDFAvail_IsDocAvail(FPDF_AVAIL avail, 90 DLLEXPORT int STDCALL
91 FX_DOWNLOADHINTS* hints) { 91 FPDFAvail_IsDocAvail(FPDF_AVAIL avail, FX_DOWNLOADHINTS* hints) {
92 if (avail == NULL || hints == NULL) 92 if (!avail || !hints)
93 return 0; 93 return PDF_DATA_ERROR;
94 CFPDF_DownloadHintsWrap hints_wrap(hints); 94 CFPDF_DownloadHintsWrap hints_wrap(hints);
95 return ((CFPDF_DataAvail*)avail)->m_pDataAvail->IsDocAvail(&hints_wrap); 95 return ((CFPDF_DataAvail*)avail)->m_pDataAvail->IsDocAvail(&hints_wrap);
96 } 96 }
97 97
98 DLLEXPORT FPDF_DOCUMENT STDCALL 98 DLLEXPORT FPDF_DOCUMENT STDCALL
99 FPDFAvail_GetDocument(FPDF_AVAIL avail, FPDF_BYTESTRING password) { 99 FPDFAvail_GetDocument(FPDF_AVAIL avail, FPDF_BYTESTRING password) {
100 if (avail == NULL) 100 if (avail == NULL)
101 return NULL; 101 return NULL;
102 CPDF_Parser* pParser = new CPDF_Parser; 102 CPDF_Parser* pParser = new CPDF_Parser;
103 pParser->SetPassword(password); 103 pParser->SetPassword(password);
(...skipping 13 matching lines...) Expand all
117 DLLEXPORT int STDCALL FPDFAvail_GetFirstPageNum(FPDF_DOCUMENT doc) { 117 DLLEXPORT int STDCALL FPDFAvail_GetFirstPageNum(FPDF_DOCUMENT doc) {
118 CPDF_Document* pDoc = CPDFDocumentFromFPDFDocument(doc); 118 CPDF_Document* pDoc = CPDFDocumentFromFPDFDocument(doc);
119 if (!doc) 119 if (!doc)
120 return 0; 120 return 0;
121 return ((CPDF_Parser*)pDoc->GetParser())->GetFirstPageNo(); 121 return ((CPDF_Parser*)pDoc->GetParser())->GetFirstPageNo();
122 } 122 }
123 123
124 DLLEXPORT int STDCALL FPDFAvail_IsPageAvail(FPDF_AVAIL avail, 124 DLLEXPORT int STDCALL FPDFAvail_IsPageAvail(FPDF_AVAIL avail,
125 int page_index, 125 int page_index,
126 FX_DOWNLOADHINTS* hints) { 126 FX_DOWNLOADHINTS* hints) {
127 if (avail == NULL || hints == NULL) 127 if (!avail || !hints)
128 return 0; 128 return PDF_DATA_ERROR;
129 CFPDF_DownloadHintsWrap hints_wrap(hints); 129 CFPDF_DownloadHintsWrap hints_wrap(hints);
130 return ((CFPDF_DataAvail*)avail) 130 return ((CFPDF_DataAvail*)avail)
131 ->m_pDataAvail->IsPageAvail(page_index, &hints_wrap); 131 ->m_pDataAvail->IsPageAvail(page_index, &hints_wrap);
132 } 132 }
133 133
134 DLLEXPORT int STDCALL FPDFAvail_IsFormAvail(FPDF_AVAIL avail, 134 DLLEXPORT int STDCALL FPDFAvail_IsFormAvail(FPDF_AVAIL avail,
135 FX_DOWNLOADHINTS* hints) { 135 FX_DOWNLOADHINTS* hints) {
136 if (avail == NULL || hints == NULL) 136 if (!avail || !hints)
137 return -1; 137 return PDF_FORM_AVAIL;
jun_fang 2015/10/29 15:31:45 should return PDF_DATA_ERROR;
138 CFPDF_DownloadHintsWrap hints_wrap(hints); 138 CFPDF_DownloadHintsWrap hints_wrap(hints);
139 return ((CFPDF_DataAvail*)avail)->m_pDataAvail->IsFormAvail(&hints_wrap); 139 return ((CFPDF_DataAvail*)avail)->m_pDataAvail->IsFormAvail(&hints_wrap);
140 } 140 }
141 141
142 DLLEXPORT FPDF_BOOL STDCALL FPDFAvail_IsLinearized(FPDF_AVAIL avail) { 142 DLLEXPORT int STDCALL FPDFAvail_IsLinearized(FPDF_AVAIL avail) {
143 if (avail == NULL) 143 if (!avail)
144 return -1; 144 return PDF_LINEARIZATION_UNKNOWN;
145 return ((CFPDF_DataAvail*)avail)->m_pDataAvail->IsLinearizedPDF(); 145 return ((CFPDF_DataAvail*)avail)->m_pDataAvail->IsLinearizedPDF();
146 } 146 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698