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 #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> // For size_t. |
11 | 11 |
12 #include "fpdfview.h" | 12 #include "fpdfview.h" |
13 | 13 |
14 /** The result of the process which check linearized PDF. */ | 14 /** The result of the process which check linearized PDF. */ |
15 #define FSDK_IS_LINEARIZED 1 | 15 #define FSDK_IS_LINEARIZED 1 |
16 #define FSDK_NOT_LINEARIZED 0 | 16 #define FSDK_NOT_LINEARIZED 0 |
17 #define FSDK_UNKNOW_LINEARIZED -1 | 17 #define FSDK_UNKNOW_LINEARIZED -1 |
18 | |
19 | 18 |
20 #ifdef __cplusplus | 19 #ifdef __cplusplus |
21 extern "C" { | 20 extern "C" { |
22 #endif | 21 #endif |
23 | 22 |
24 /** | 23 /** |
25 * Interface: FX_FILEAVAIL | 24 * Interface: FX_FILEAVAIL |
26 * Interface for checking whether the section of the file is available. | 25 * Interface for checking whether the section of the file is available. |
27 */ | 26 */ |
28 typedef struct _FX_FILEAVAIL { | 27 typedef struct _FX_FILEAVAIL { |
29 /** | 28 /** |
30 * Version number of the interface. Currently must be 1. | 29 * Version number of the interface. Currently must be 1. |
31 */ | 30 */ |
32 int version; | 31 int version; |
33 | 32 |
34 /** | 33 /** |
35 * Method: IsDataAvail | 34 * Method: IsDataAvail |
36 * Report whether the specified data section is available. A section is
available only if all bytes in the section is available. | 35 * Report whether the specified data section is available. A section is |
37 * Interface Version: | 36 * available only if all bytes in the section is available. |
38 * 1 | 37 * Interface Version: |
39 * Implementation Required: | 38 * 1 |
40 * Yes | 39 * Implementation Required: |
41 * Parameters: | 40 * Yes |
42 * pThis - Pointer to the interface structure itself. | 41 * Parameters: |
43 * offset - The offset of the data section in the file. | 42 * pThis - Pointer to the interface structure itself. |
44 * size - The size of the data section | 43 * offset - The offset of the data section in the file. |
45 * Return Value: | 44 * size - The size of the data section |
46 * true means the specified data section is available. | 45 * Return Value: |
47 * Comments: | 46 * true means the specified data section is available. |
48 * Called by Foxit SDK to check whether the data section is ready. | 47 * Comments: |
49 */ | 48 * Called by Foxit SDK to check whether the data section is ready. |
50 FPDF_BOOL (*IsDataAvail)(struct _FX_FILEAVAIL* pThis, size_t offset, size_t
size); | 49 */ |
| 50 FPDF_BOOL (*IsDataAvail)(struct _FX_FILEAVAIL* pThis, size_t offset, size_t si
ze); |
51 } FX_FILEAVAIL; | 51 } FX_FILEAVAIL; |
52 | 52 |
53 typedef void* FPDF_AVAIL; | 53 typedef void* FPDF_AVAIL; |
54 | 54 |
55 /** | 55 /** |
56 * Function: FPDFAvail_Create | 56 * Function: FPDFAvail_Create |
57 * Create a document availability provider. | 57 * Create a document availability provider. |
58 * | 58 * |
59 * Parameters: | 59 * Parameters: |
60 * file_avail - Pointer to file availability interface to check avai
lability of file data. | 60 * file_avail - Pointer to file availability interface to check |
61 * file - Pointer to a file access interface for reading data
from file. | 61 * availability of file data. |
| 62 * file - Pointer to a file access interface for reading data |
| 63 * from file. |
62 * Return value: | 64 * Return value: |
63 * A handle to the document availability provider. NULL for error. | 65 * A handle to the document availability provider. NULL for error. |
64 * Comments: | 66 * Comments: |
65 * Application must call FPDFAvail_Destroy when done with the availabil
ity provider. | 67 * Application must call FPDFAvail_Destroy when done with the |
| 68 * availability provider. |
66 */ | 69 */ |
67 DLLEXPORT FPDF_AVAIL STDCALL FPDFAvail_Create(FX_FILEAVAIL* file_avail, FPDF_FIL
EACCESS* file); | 70 DLLEXPORT FPDF_AVAIL STDCALL FPDFAvail_Create(FX_FILEAVAIL* file_avail, |
| 71 FPDF_FILEACCESS* file); |
68 | 72 |
69 /** | 73 /** |
70 * Function: FPDFAvail_Destroy | 74 * Function: FPDFAvail_Destroy |
71 * Destroy a document availibity provider. | 75 * Destroy a document availibity provider. |
72 * | 76 * |
73 * Parameters: | 77 * Parameters: |
74 * avail - Handle to document availability provider returned by
FPDFAvail_Create | 78 * avail - Handle to document availability provider returned by |
| 79 * FPDFAvail_Create |
75 * Return Value: | 80 * Return Value: |
76 * None. | 81 * None. |
77 */ | 82 */ |
78 DLLEXPORT void STDCALL FPDFAvail_Destroy(FPDF_AVAIL avail); | 83 DLLEXPORT void STDCALL FPDFAvail_Destroy(FPDF_AVAIL avail); |
79 | 84 |
80 /** | 85 /** |
81 * Interface: FX_DOWNLOADHINTS | 86 * Interface: FX_DOWNLOADHINTS |
82 * Download hints interface. Used to receive hints for further download
ing. | 87 * Download hints interface. Used to receive hints for further |
| 88 * downloading. |
83 */ | 89 */ |
84 typedef struct _FX_DOWNLOADHINTS { | 90 typedef struct _FX_DOWNLOADHINTS { |
85 /** | 91 /** |
86 * Version number of the interface. Currently must be 1. | 92 * Version number of the interface. Currently must be 1. |
87 */ | 93 */ |
88 int version; | 94 int version; |
89 | 95 |
90 /** | 96 /** |
91 * Method: AddSegment | 97 * Method: AddSegment |
92 * Add a section to be downloaded. | 98 * Add a section to be downloaded. |
93 * Interface Version: | 99 * Interface Version: |
94 * 1 | 100 * 1 |
95 * Implementation Required: | 101 * Implementation Required: |
96 * Yes | 102 * Yes |
97 * Parameters: | 103 * Parameters: |
98 * pThis - Pointer to the interface structure itself. | 104 * pThis - Pointer to the interface structure itself. |
99 * offset - The offset of the hint reported to be downloaded. | 105 * offset - The offset of the hint reported to be downloaded. |
100 * size - The size of the hint reported to be downloaded. | 106 * size - The size of the hint reported to be downloaded. |
101 * Return Value: | 107 * Return Value: |
102 * None. | 108 * None. |
103 * Comments: | 109 * Comments: |
104 * Called by Foxit SDK to report some downloading hints for download ma
nager. | 110 * Called by Foxit SDK to report some downloading hints for download |
105 * The position and size of section may be not accurate, part of the se
ction might be already available. | 111 * manager. |
106 * The download manager must deal with that to maximize download effici
ency. | 112 * The position and size of section may be not accurate, part of the |
107 */ | 113 * section might be already available. |
108 void (*AddSegment)(struct _FX_DOWNLOADHINTS* pThis, size_t offset, size_t si
ze); | 114 * The download manager must deal with that to maximize download |
| 115 * efficiency. |
| 116 */ |
| 117 void (*AddSegment)(struct _FX_DOWNLOADHINTS* pThis, |
| 118 size_t offset, |
| 119 size_t size); |
109 } FX_DOWNLOADHINTS; | 120 } FX_DOWNLOADHINTS; |
110 | 121 |
111 /** | 122 /** |
112 * Function: FPDFAvail_IsDocAvail | 123 * Function: FPDFAvail_IsDocAvail |
113 * Check whether the document is ready for loading, if not, get downloa
d hints. | 124 * Check whether the document is ready for loading, if not, get |
| 125 * download hints. |
114 * | 126 * |
115 * Parameters: | 127 * Parameters: |
116 * avail - Handle to document availability provider returned by
FPDFAvail_Create | 128 * avail - Handle to document availability provider returned by |
117 * hints - Pointer to a download hints interface, receiving gen
erated hints | 129 * FPDFAvail_Create |
| 130 * hints - Pointer to a download hints interface, receiving |
| 131 * generated hints |
118 * Return value: | 132 * Return value: |
119 * Non-zero for page is fully available, 0 for page not yet available. | 133 * Non-zero for page is fully available, 0 for page not yet available. |
120 * Comments: | 134 * Comments: |
121 * The application should call this function whenever new data arrived,
and process all the | 135 * The application should call this function whenever new data arrived, |
122 * generated download hints if any, until the function returns non-zero
value. Then the | 136 * and process all the |
123 * application can call FPDFAvail_GetDocument() to get a document handl
e. | 137 * generated download hints if any, until the function returns non-zero |
| 138 * value. Then the |
| 139 * application can call FPDFAvail_GetDocument() to get a document |
| 140 * handle. |
124 */ | 141 */ |
125 DLLEXPORT int STDCALL FPDFAvail_IsDocAvail(FPDF_AVAIL avail, FX_DOWNLOADHINTS* h
ints); | 142 DLLEXPORT int STDCALL FPDFAvail_IsDocAvail(FPDF_AVAIL avail, |
| 143 FX_DOWNLOADHINTS* hints); |
126 | 144 |
127 /** | 145 /** |
128 * Function: FPDFAvail_GetDocument | 146 * Function: FPDFAvail_GetDocument |
129 * Get document from the availability provider. | 147 * Get document from the availability provider. |
130 * | 148 * |
131 * Parameters: | 149 * Parameters: |
132 * avail - Handle to document availability provider returned by
FPDFAvail_Create | 150 * avail - Handle to document availability provider returned by |
| 151 * FPDFAvail_Create |
133 * password - Optional password for decrypting the PDF file. | 152 * password - Optional password for decrypting the PDF file. |
134 * Return value: | 153 * Return value: |
135 * Handle to the document. | 154 * Handle to the document. |
136 * Comments: | 155 * Comments: |
137 * After FPDFAvail_IsDocAvail() returns TRUE, the application should ca
ll this function to | 156 * After FPDFAvail_IsDocAvail() returns TRUE, the application should |
138 * get the document handle. To close the document, use FPDF_CloseDocume
nt function. | 157 * call this function to |
| 158 * get the document handle. To close the document, use |
| 159 * FPDF_CloseDocument function. |
139 */ | 160 */ |
140 DLLEXPORT FPDF_DOCUMENT STDCALL FPDFAvail_GetDocument(FPDF_AVAIL avail, | 161 DLLEXPORT FPDF_DOCUMENT STDCALL FPDFAvail_GetDocument(FPDF_AVAIL avail, |
141 FPDF_BYTESTRING password); | 162 FPDF_BYTESTRING password); |
142 | 163 |
143 /** | 164 /** |
144 * Function: FPDFAvail_GetFirstPageNum | 165 * Function: FPDFAvail_GetFirstPageNum |
145 * Get page number for the first available page in a linearized PDF | 166 * Get page number for the first available page in a linearized PDF |
146 * | 167 * |
147 * Parameters: | 168 * Parameters: |
148 * doc - A document handle returned by FPDFAvail_GetDocument | 169 * doc - A document handle returned by FPDFAvail_GetDocument |
149 * Return Value: | 170 * Return Value: |
150 * Zero-based index for the first available page. | 171 * Zero-based index for the first available page. |
151 * Comments: | 172 * Comments: |
152 * For most linearized PDFs, the first available page would be just the
first page, however, | 173 * For most linearized PDFs, the first available page would be just the |
| 174 * first page, however, |
153 * some PDFs might make other page to be the first available page. | 175 * some PDFs might make other page to be the first available page. |
154 * For non-linearized PDF, this function will always return zero. | 176 * For non-linearized PDF, this function will always return zero. |
155 */ | 177 */ |
156 DLLEXPORT int STDCALL FPDFAvail_GetFirstPageNum(FPDF_DOCUMENT doc); | 178 DLLEXPORT int STDCALL FPDFAvail_GetFirstPageNum(FPDF_DOCUMENT doc); |
157 | 179 |
158 /** | 180 /** |
159 * Function: FPDFAvail_IsPageAvail | 181 * Function: FPDFAvail_IsPageAvail |
160 * Check whether a page is ready for loading, if not, get download hint
s. | 182 * Check whether a page is ready for loading, if not, get download |
| 183 * hints. |
161 * | 184 * |
162 * Parameters: | 185 * Parameters: |
163 * avail - Handle to document availability provider returned by
FPDFAvail_Create | 186 * avail - Handle to document availability provider returned by |
| 187 * FPDFAvail_Create |
164 * page_index - Index number of the page. 0 for the first page. | 188 * page_index - Index number of the page. 0 for the first page. |
165 * hints - Pointer to a download hints interface, receiving gen
erated hints | 189 * hints - Pointer to a download hints interface, receiving |
| 190 * generated hints |
166 * Return value: | 191 * Return value: |
167 * Non-zero for page is fully available, 0 for page not yet available. | 192 * Non-zero for page is fully available, 0 for page not yet available. |
168 * Comments: | 193 * Comments: |
169 * This function call be called only after FPDFAvail_GetDocument if cal
led. | 194 * This function call be called only after FPDFAvail_GetDocument if |
170 * The application should call this function whenever new data arrived,
and process all the | 195 * called. |
171 * generated download hints if any, until the function returns non-zero
value. Then the | 196 * The application should call this function whenever new data arrived, |
| 197 * and process all the |
| 198 * generated download hints if any, until the function returns non-zero |
| 199 * value. Then the |
172 * application can perform page loading. | 200 * application can perform page loading. |
173 */ | 201 */ |
174 DLLEXPORT int STDCALL FPDFAvail_IsPageAvail(FPDF_AVAIL avail, int page_index, FX
_DOWNLOADHINTS* hints); | 202 DLLEXPORT int STDCALL FPDFAvail_IsPageAvail(FPDF_AVAIL avail, |
| 203 int page_index, |
| 204 FX_DOWNLOADHINTS* hints); |
175 | 205 |
176 /** | 206 /** |
177 * Function: FPDFAvail_ISFormAvail | 207 * Function: FPDFAvail_ISFormAvail |
178 * Check whether Form data is ready for init, if not, get download hint
s. | 208 * Check whether Form data is ready for init, if not, get download |
| 209 * hints. |
179 * | 210 * |
180 * Parameters: | 211 * Parameters: |
181 * avail - Handle to document availability provider returned by
FPDFAvail_Create | 212 * avail - Handle to document availability provider returned by |
182 * hints - Pointer to a download hints interface, receiving gen
erated hints | 213 * FPDFAvail_Create |
| 214 * hints - Pointer to a download hints interface, receiving |
| 215 * generated hints |
183 * Return value: | 216 * Return value: |
184 * Non-zero for Form data is fully available, 0 for Form data not yet a
vailable. | 217 * Non-zero for Form data is fully available, 0 for Form data not yet |
185 * Details: -1 - error, the input parameter not correct, such as hints
is null. | 218 * available. |
| 219 * Details: -1 - error, the input parameter not correct, such as hints |
| 220 * is null. |
186 * 0 - data not available | 221 * 0 - data not available |
187 * 1 - data available | 222 * 1 - data available |
188 * 2 - no form data. | 223 * 2 - no form data. |
189 * Comments: | 224 * Comments: |
190 * This function call be called only after FPDFAvail_GetDocument if cal
led. | 225 * This function call be called only after FPDFAvail_GetDocument if |
191 * The application should call this function whenever new data arrived,
and process all the | 226 * called. |
192 * generated download hints if any, until the function returns non-zero
value. Then the | 227 * The application should call this function whenever new data arrived, |
193 * application can perform page loading. Recommend to call FPDFDOC_Init
FormFillEnvironment | 228 * and process all the |
| 229 * generated download hints if any, until the function returns non-zero |
| 230 * value. Then the |
| 231 * application can perform page loading. Recommend to call |
| 232 * FPDFDOC_InitFormFillEnvironment |
194 * after the function returns non-zero value. | 233 * after the function returns non-zero value. |
195 */ | 234 */ |
196 DLLEXPORT int STDCALL FPDFAvail_IsFormAvail(FPDF_AVAIL avail, FX_DOWNLOADHINTS*
hints); | 235 DLLEXPORT int STDCALL FPDFAvail_IsFormAvail(FPDF_AVAIL avail, |
| 236 FX_DOWNLOADHINTS* hints); |
197 | 237 |
198 /** | 238 /** |
199 * Function: FPDFAvail_IsLinearized | 239 * Function: FPDFAvail_IsLinearized |
200 * To check whether a document is Linearized PDF file. | 240 * To check whether a document is Linearized PDF file. |
201 * | 241 * |
202 * Parameters: | 242 * Parameters: |
203 * avail - Handle to document availability provider returned by
FPDFAvail_Create | 243 * avail - Handle to document availability provider returned by |
| 244 * FPDFAvail_Create |
204 * Return value: | 245 * Return value: |
205 * return TRUE means the document is linearized PDF else not. | 246 * return TRUE means the document is linearized PDF else not. |
206 * FSDK_IS_LINEARIZED is a linearize file. | 247 * FSDK_IS_LINEARIZED is a linearize file. |
207 * FSDK_NOT_LINEARIZED is not a linearize file. | 248 * FSDK_NOT_LINEARIZED is not a linearize file. |
208 * FSDK_UNKNOW_LINEARIZED don't know whether the file is a linearize fi
le. | 249 * FSDK_UNKNOW_LINEARIZED don't know whether the file is a linearize |
| 250 * file. |
209 * Comments: | 251 * Comments: |
210 * It return TRUE/FALSE as soon as we have first 1K data. If the file'
s size less than | 252 * It return TRUE/FALSE as soon as we have first 1K data. If the |
| 253 * file's size less than |
211 * 1K,we don't known whether the PDF is a linearized file. | 254 * 1K,we don't known whether the PDF is a linearized file. |
212 * | 255 * |
213 */ | 256 */ |
214 DLLEXPORT FPDF_BOOL STDCALL FPDFAvail_IsLinearized(FPDF_AVAIL avail); | 257 DLLEXPORT FPDF_BOOL STDCALL FPDFAvail_IsLinearized(FPDF_AVAIL avail); |
215 | 258 |
216 #ifdef __cplusplus | 259 #ifdef __cplusplus |
217 } | 260 } |
218 #endif | 261 #endif |
219 | 262 |
220 #endif // PUBLIC_FPDF_DATAAVAIL_H_ | 263 #endif // PUBLIC_FPDF_DATAAVAIL_H_ |
OLD | NEW |