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

Side by Side Diff: public/fpdf_dataavail.h

Issue 1825433002: Cleanup public/fpdf_dataavail.h documentation. (Closed) Base URL: https://pdfium.googlesource.com/pdfium.git@master
Patch Set: Created 4 years, 9 months 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
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 #ifndef PUBLIC_FPDF_DATAAVAIL_H_ 7 #ifndef PUBLIC_FPDF_DATAAVAIL_H_
8 #define PUBLIC_FPDF_DATAAVAIL_H_ 8 #define PUBLIC_FPDF_DATAAVAIL_H_
9 9
10 #include <stddef.h> // For size_t. 10 #include <stddef.h>
11 11
12 #include "fpdfview.h" 12 #include "fpdfview.h"
13 13
14 #define PDF_LINEARIZATION_UNKNOWN -1 14 #define PDF_LINEARIZATION_UNKNOWN -1
15 #define PDF_NOT_LINEARIZED 0 15 #define PDF_NOT_LINEARIZED 0
16 #define PDF_LINEARIZED 1 16 #define PDF_LINEARIZED 1
17 17
18 #define PDF_DATA_ERROR -1 18 #define PDF_DATA_ERROR -1
19 #define PDF_DATA_NOTAVAIL 0 19 #define PDF_DATA_NOTAVAIL 0
20 #define PDF_DATA_AVAIL 1 20 #define PDF_DATA_AVAIL 1
21 21
22 #define PDF_FORM_ERROR -1 22 #define PDF_FORM_ERROR -1
23 #define PDF_FORM_NOTAVAIL 0 23 #define PDF_FORM_NOTAVAIL 0
24 #define PDF_FORM_AVAIL 1 24 #define PDF_FORM_AVAIL 1
25 #define PDF_FORM_NOTEXIST 2 25 #define PDF_FORM_NOTEXIST 2
26 26
27 #ifdef __cplusplus 27 #ifdef __cplusplus
28 extern "C" { 28 extern "C" {
29 #endif 29 #endif // __cplusplus
30 30
31 /** 31 // Interface for checking whether the section of the file is available.
32 * Interface: FX_FILEAVAIL
33 * Interface for checking whether the section of the file is available.
34 */
35 typedef struct _FX_FILEAVAIL { 32 typedef struct _FX_FILEAVAIL {
36 /** 33 // Version number of the interface. Must be 1.
37 * Version number of the interface. Currently must be 1.
38 */
39 int version; 34 int version;
40 35
41 /** 36 // Reports if the specified data section is available. A section is
Tom Sepez 2016/03/23 20:10:58 nit: maybe add "at the present time." since this c
dsinclair 2016/03/23 23:35:59 Changed to 'currently available'
42 * Method: IsDataAvail 37 // available if all bytes in the section are available.
43 * Report whether the specified data section is available. A section is 38 //
44 * available only if all bytes in the section is available. 39 // Interface Version: 1
45 * Interface Version: 40 // Implementation Required: Yes
46 * 1 41 //
47 * Implementation Required: 42 // pThis - pointer to the interface structure.
48 * Yes 43 // offset - the offset of the data section in the file.
49 * Parameters: 44 // size - the size of the data section.
50 * pThis - Pointer to the interface structure itself. 45 //
51 * offset - The offset of the data section in the file. 46 // Returns true if the specified data section at |offset| of |size|
52 * size - The size of the data section 47 // is available.
53 * Return Value:
54 * true means the specified data section is available.
55 * Comments:
56 * Called by Foxit SDK to check whether the data section is ready.
57 */
58 FPDF_BOOL (*IsDataAvail)(struct _FX_FILEAVAIL* pThis, 48 FPDF_BOOL (*IsDataAvail)(struct _FX_FILEAVAIL* pThis,
59 size_t offset, 49 size_t offset,
60 size_t size); 50 size_t size);
61 } FX_FILEAVAIL; 51 } FX_FILEAVAIL;
62
63 typedef void* FPDF_AVAIL; 52 typedef void* FPDF_AVAIL;
64 53
65 /** 54 // Create a document availability provider.
Tom Sepez 2016/03/23 20:10:58 nit: wish we could say what an availabilty provide
dsinclair 2016/03/23 23:35:58 Yea, will have to come back to that one. My unders
66 * Function: FPDFAvail_Create 55 //
67 * Create a document availability provider. 56 // file_avail - pointer to file availability interface.
68 * 57 // file - pointer to a file access interface.
69 * Parameters: 58 //
70 * file_avail - Pointer to file availability interface to check 59 // Returns a handle to the document availability provider. NULL otherwise.
Tom Sepez 2016/03/23 20:10:58 nit: I prefer ", or NULL on error." to otherwise.
dsinclair 2016/03/23 23:35:59 Done.
71 * availability of file data. 60 //
72 * file - Pointer to a file access interface for reading data 61 // |FPDFAvail_Destroy| must be called when done with the availability provider.
73 * from file.
74 * Return value:
75 * A handle to the document availability provider. NULL for error.
76 * Comments:
77 * Application must call FPDFAvail_Destroy when done with the
78 * availability provider.
79 */
80 DLLEXPORT FPDF_AVAIL STDCALL FPDFAvail_Create(FX_FILEAVAIL* file_avail, 62 DLLEXPORT FPDF_AVAIL STDCALL FPDFAvail_Create(FX_FILEAVAIL* file_avail,
81 FPDF_FILEACCESS* file); 63 FPDF_FILEACCESS* file);
82 64
83 /** 65 // Destroy the |avail| document availability provider.
84 * Function: FPDFAvail_Destroy 66 //
85 * Destroy a document availibity provider. 67 // |avail| - handle to document availability provider to be destroyed.
86 *
87 * Parameters:
88 * avail - Handle to document availability provider returned by
89 * FPDFAvail_Create
90 * Return Value:
91 * None.
92 */
93 DLLEXPORT void STDCALL FPDFAvail_Destroy(FPDF_AVAIL avail); 68 DLLEXPORT void STDCALL FPDFAvail_Destroy(FPDF_AVAIL avail);
94 69
95 /** 70 // Download hints interface. Used to receive hints for further downloading.
96 * Interface: FX_DOWNLOADHINTS
97 * Download hints interface. Used to receive hints for further
98 * downloading.
99 */
100 typedef struct _FX_DOWNLOADHINTS { 71 typedef struct _FX_DOWNLOADHINTS {
101 /** 72 // Version number of the interface. Must be 1.
102 * Version number of the interface. Currently must be 1.
103 */
104 int version; 73 int version;
105 74
106 /** 75 // Add a section to be downloaded.
107 * Method: AddSegment 76 //
108 * Add a section to be downloaded. 77 // Interface Version: 1
109 * Interface Version: 78 // Implementation Required: Yes
110 * 1 79 //
111 * Implementation Required: 80 // pThis - pointer to the interface structure.
112 * Yes 81 // offset - the offset of the hint reported to be downloaded.
113 * Parameters: 82 // size - the size of the hint reported to be downloaded.
114 * pThis - Pointer to the interface structure itself. 83 //
115 * offset - The offset of the hint reported to be downloaded. 84 // The |offset| and |size| of the section may not be unique. Part of the
116 * size - The size of the hint reported to be downloaded. 85 // section might be already available. The download manager must deal with
117 * Return Value: 86 // duplicate sections.
Tom Sepez 2016/03/23 20:10:58 nit: overlapping sections.
dsinclair 2016/03/23 23:35:58 Done.
118 * None.
119 * Comments:
120 * Called by Foxit SDK to report some downloading hints for download
121 * manager.
122 * The position and size of section may be not accurate, part of the
123 * section might be already available.
124 * The download manager must deal with that to maximize download
125 * efficiency.
126 */
127 void (*AddSegment)(struct _FX_DOWNLOADHINTS* pThis, 87 void (*AddSegment)(struct _FX_DOWNLOADHINTS* pThis,
128 size_t offset, 88 size_t offset,
129 size_t size); 89 size_t size);
130 } FX_DOWNLOADHINTS; 90 } FX_DOWNLOADHINTS;
131 91
132 /** 92 // Checks if the document is ready for loading, if not, get download hints.
133 * Function: FPDFAvail_IsDocAvail 93 //
134 * Check whether the document is ready for loading, if not, get 94 // avail - handle to document availability provider.
135 * download hints. 95 // hints - pointer to a download hints interface.
136 * 96 //
137 * Parameters: 97 // Returns one of:
138 * avail - Handle to document availability provider returned by 98 // PDF_DATA_ERROR: A common error is returned. Data availability unknown.
139 * FPDFAvail_Create 99 // PDF_DATA_NOTAVAIL: Data not yet available.
140 * hints - Pointer to a download hints interface, receiving 100 // PDF_DATA_AVAIL: Data available.
141 * generated hints 101 //
142 * Return value: 102 // Applications should call this function whenever new data arrives, and process
143 * PDF_DATA_ERROR: A common error is returned. It can't tell 103 // all the generated download hints, if any, until the function returns
144 * whehter data are availabe or not. 104 // |PDF_DATA_ERROR| or |PDF_DATA_AVAIL|.
145 * PDF_DATA_NOTAVAIL: Data are not yet available. 105 //
146 * PDF_DATA_AVAIL: Data are available. 106 // Once all data is available, call |FPDFAvail_GetDocument| to get a document
147 * Comments: 107 // handle.
148 * Applications should call this function whenever new data arrived,
149 * and process all the generated download hints if any, until the
150 * function returns PDF_DATA_ERROR or PDF_DATA_AVAIL. Then
151 * applications can call FPDFAvail_GetDocument() to get a document
152 * handle.
153 */
154 DLLEXPORT int STDCALL 108 DLLEXPORT int STDCALL
155 FPDFAvail_IsDocAvail(FPDF_AVAIL avail, FX_DOWNLOADHINTS* hints); 109 FPDFAvail_IsDocAvail(FPDF_AVAIL avail, FX_DOWNLOADHINTS* hints);
156 110
157 /** 111 // Get document from the availability provider.
158 * Function: FPDFAvail_GetDocument 112 //
159 * Get document from the availability provider. 113 // avail - handle to document availability provider.
160 * 114 // password - password for decrypting the PDF file. Optional.
161 * Parameters: 115 //
162 * avail - Handle to document availability provider returned by 116 // Returns a handle to the document.
163 * FPDFAvail_Create 117 //
164 * password - Optional password for decrypting the PDF file. 118 // When |FPDFAvail_IsDocAvail| returns TRUE, call |FPDFAvail_GetDocument| to
165 * Return value: 119 // retrieve the document handle.
166 * Handle to the document.
167 * Comments:
168 * After FPDFAvail_IsDocAvail() returns TRUE, the application should
169 * call this function to
170 * get the document handle. To close the document, use
171 * FPDF_CloseDocument function.
172 */
173 DLLEXPORT FPDF_DOCUMENT STDCALL FPDFAvail_GetDocument(FPDF_AVAIL avail, 120 DLLEXPORT FPDF_DOCUMENT STDCALL FPDFAvail_GetDocument(FPDF_AVAIL avail,
174 FPDF_BYTESTRING password); 121 FPDF_BYTESTRING password);
175 122
176 /** 123 // Get the page number for the first available page in a linearized PDF.
177 * Function: FPDFAvail_GetFirstPageNum 124 //
178 * Get page number for the first available page in a linearized PDF 125 // doc - document handle.
179 * 126 //
180 * Parameters: 127 // Returns the zero-based index for the first available page.
181 * doc - A document handle returned by FPDFAvail_GetDocument 128 //
182 * Return Value: 129 // For most linearized PDFs, the first available page will be the first page,
183 * Zero-based index for the first available page. 130 // however, some PDFs might make another page the first available page.
184 * Comments: 131 // For non-linearized PDFs, this function will always return zero.
185 * For most linearized PDFs, the first available page would be just the
186 * first page, however,
187 * some PDFs might make other page to be the first available page.
188 * For non-linearized PDF, this function will always return zero.
189 */
190 DLLEXPORT int STDCALL FPDFAvail_GetFirstPageNum(FPDF_DOCUMENT doc); 132 DLLEXPORT int STDCALL FPDFAvail_GetFirstPageNum(FPDF_DOCUMENT doc);
191 133
192 /** 134 // Check if |page_index| is ready for loading, if not, get the
193 * Function: FPDFAvail_IsPageAvail 135 // |FX_DOWNLOADHINTS|.
194 * Check whether a page is ready for loading, if not, get download 136 //
195 * hints. 137 // avail - handle to document availability provider.
196 * 138 // page_index - index number of the page. Zero for the first page.
197 * Parameters: 139 // hints - pointer to a download hints interface. Populated if
198 * avail - Handle to document availability provider returned by 140 // |page_index| is not available.
199 * FPDFAvail_Create 141 //
200 * page_index - Index number of the page. 0 for the first page. 142 // Returns one of:
201 * hints - Pointer to a download hints interface, receiving 143 // PDF_DATA_ERROR: A common error is returned. Data availability unknown.
202 * generated hints 144 // PDF_DATA_NOTAVAIL: Data not yet available.
203 * Return value: 145 // PDF_DATA_AVAIL: Data available.
204 * PDF_DATA_ERROR: A common error is returned. It can't tell 146 //
205 * whehter data are availabe or not. 147 // This function can be called only after |FPDFAvail_GetDocument| is called.
206 * PDF_DATA_NOTAVAIL: Data are not yet available. 148 // Applications should call this function whenever new data arrives and process
207 * PDF_DATA_AVAIL: Data are available. 149 // all the generated download |hints|, if any, until this function returns
208 * Comments: 150 // |PDF_DATA_ERROR| or |PDF_DATA_AVAIL|. Applications can then perform page
209 * This function can be called only after FPDFAvail_GetDocument is 151 // loading.
210 * called. Applications should call this function whenever new data
211 * arrived and process all the generated download hints if any, until
212 * this function returns PDF_DATA_ERROR or PDF_DATA_AVAIL. Then
213 * applications can perform page loading.
214 */
215 DLLEXPORT int STDCALL FPDFAvail_IsPageAvail(FPDF_AVAIL avail, 152 DLLEXPORT int STDCALL FPDFAvail_IsPageAvail(FPDF_AVAIL avail,
216 int page_index, 153 int page_index,
217 FX_DOWNLOADHINTS* hints); 154 FX_DOWNLOADHINTS* hints);
218 155
219 /** 156 // Check if form data is ready for initialization, if not, get the
220 * Function: FPDFAvail_ISFormAvail 157 // |FX_DOWNLOADHINTS|.
221 * Check whether Form data is ready for init, if not, get download 158 //
222 * hints. 159 // avail - handle to document availability provider.
223 * 160 // hints - pointer to a download hints interface. Populated if form is not
224 * Parameters: 161 // ready for initialization.
225 * avail - Handle to document availability provider returned by 162 //
226 * FPDFAvail_Create 163 // Returns one of:
227 * hints - Pointer to a download hints interface, receiving 164 // PDF_FORM_ERROR: A common eror, in general incorrect parameters.
228 * generated hints 165 // PDF_FORM_NOTAVAIL: Data not available.
229 * Return value: 166 // PDF_FORM_AVAIL: Data available.
230 * PDF_FORM_ERROR - A common eror, in general incorrect parameters, 167 // PDF_FORM_NOTEXIST: No form data.
231 * like 'hints' is nullptr. 168 //
232 * PDF_FORM_NOTAVAIL - data not available 169 // This function can be called only after |FPDFAvail_GetDocument| is called.
233 * PDF_FORM_AVAIL - data available 170 // The application should call this function whenever new data arrives and
234 * PDF_FORM_NOTEXIST - no form data 171 // process all the generated download |hints|, if any, until the function
235 * Comments: 172 // |PDF_FORM_ERROR|, |PDF_FORM_AVAIL| or |PDF_FORM_NOTEXIST|.
236 * This function can be called only after FPDFAvail_GetDocument is 173 // Applications can then perform page loading. It is recommend to call
237 * called. 174 // |FPDFDOC_InitFormFillEnvironment| when |PDF_FORM_AVAIL| is returned.
238 * The application should call this function whenever new data arrived,
239 * and process all the
240 * generated download hints if any, until the function returns non-zero
241 * value. Then the
242 * application can perform page loading. Recommend to call
243 * FPDFDOC_InitFormFillEnvironment
244 * after the function returns non-zero value.
245 */
246 DLLEXPORT int STDCALL FPDFAvail_IsFormAvail(FPDF_AVAIL avail, 175 DLLEXPORT int STDCALL FPDFAvail_IsFormAvail(FPDF_AVAIL avail,
247 FX_DOWNLOADHINTS* hints); 176 FX_DOWNLOADHINTS* hints);
248 177
249 /** 178 // Check whether a document is a linearized PDF.
250 * Function: FPDFAvail_IsLinearized 179 //
251 * To check whether a document is Linearized PDF file. 180 // avail - handle to document availability provider.
252 * 181 //
253 * Parameters: 182 // Returns one of:
254 * avail - Handle to document availability provider returned by 183 // PDF_LINEARIZED
255 * FPDFAvail_Create 184 // PDF_NOT_LINEARIZED
256 * Return value: 185 // PDF_LINEARIZATION_UNKNOWN
257 * PDF_LINEARIZED is a linearize file. 186 //
258 * PDF_NOT_LINEARIZED is not a linearize file. 187 // |FPDFAvail_IsLinearized| will return |PDF_LINEARIZED| or |PDF_NOT_LINEARIZED|
259 * PDF_LINEARIZATION_UNKNOWN doesn't know whether the file is a 188 // when we have 1k of data. If the files size less than 1k, it returns
260 *linearize file. 189 // |PDF_LINEARIZATION_UNKNOWN| as there is insufficient information to determine
261 * 190 // if the PDF is linearlized.
262 * Comments:
263 * It return PDF_LINEARIZED or PDF_NOT_LINEARIZED as soon as
264 * we have first 1K data. If the file's size less than 1K, it returns
265 * PDF_LINEARIZATION_UNKNOWN because there is not enough information to
266 * tell whether a PDF file is a linearized file or not.
267 *
268 */
269 DLLEXPORT int STDCALL FPDFAvail_IsLinearized(FPDF_AVAIL avail); 191 DLLEXPORT int STDCALL FPDFAvail_IsLinearized(FPDF_AVAIL avail);
270 192
271 #ifdef __cplusplus 193 #ifdef __cplusplus
272 } 194 } // extern "C"
273 #endif 195 #endif // __cplusplus
274 196
275 #endif // PUBLIC_FPDF_DATAAVAIL_H_ 197 #endif // PUBLIC_FPDF_DATAAVAIL_H_
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698