• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 // Copyright 2015 PDFium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4 
5 // This "C" (not "C++") file ensures that the public headers compile
6 // and link for "C" (and not just "C++").
7 
8 #include <stdio.h>
9 
10 #include "fpdfsdk/fpdfview_c_api_test.h"
11 
12 #include "public/fpdf_annot.h"
13 #include "public/fpdf_attachment.h"
14 #include "public/fpdf_catalog.h"
15 #include "public/fpdf_dataavail.h"
16 #include "public/fpdf_doc.h"
17 #include "public/fpdf_edit.h"
18 #include "public/fpdf_ext.h"
19 #include "public/fpdf_flatten.h"
20 #include "public/fpdf_formfill.h"
21 #include "public/fpdf_fwlevent.h"
22 #include "public/fpdf_ppo.h"
23 #include "public/fpdf_progressive.h"
24 #include "public/fpdf_save.h"
25 #include "public/fpdf_searchex.h"
26 #include "public/fpdf_structtree.h"
27 #include "public/fpdf_sysfontinfo.h"
28 #include "public/fpdf_text.h"
29 #include "public/fpdf_transformpage.h"
30 #include "public/fpdfview.h"
31 
32 // Scheme for avoiding LTO out of existence, warnings, etc.
33 typedef void (*fnptr)(void);  // Legal generic function type for casts.
34 fnptr g_c_api_test_fnptr = NULL;  // Extern, so can't know it doesn't change.
35 #define CHK(x) if ((fnptr)(x) == g_c_api_test_fnptr) return 0
36 
37 // Function to call from gtest harness to ensure linker resolution.
CheckPDFiumCApi()38 int CheckPDFiumCApi() {
39     // fpdf_annot.h
40     CHK(FPDFAnnot_IsSupportedSubtype);
41     CHK(FPDFPage_CreateAnnot);
42     CHK(FPDFPage_GetAnnotCount);
43     CHK(FPDFPage_GetAnnot);
44     CHK(FPDFPage_GetAnnotIndex);
45     CHK(FPDFPage_CloseAnnot);
46     CHK(FPDFPage_RemoveAnnot);
47     CHK(FPDFAnnot_GetSubtype);
48     CHK(FPDFAnnot_IsObjectSupportedSubtype);
49     CHK(FPDFAnnot_UpdateObject);
50     CHK(FPDFAnnot_AppendObject);
51     CHK(FPDFAnnot_GetObjectCount);
52     CHK(FPDFAnnot_GetObject);
53     CHK(FPDFAnnot_RemoveObject);
54     CHK(FPDFAnnot_SetColor);
55     CHK(FPDFAnnot_GetColor);
56     CHK(FPDFAnnot_HasAttachmentPoints);
57     CHK(FPDFAnnot_SetAttachmentPoints);
58     CHK(FPDFAnnot_GetAttachmentPoints);
59     CHK(FPDFAnnot_SetRect);
60     CHK(FPDFAnnot_GetRect);
61     CHK(FPDFAnnot_HasKey);
62     CHK(FPDFAnnot_GetValueType);
63     CHK(FPDFAnnot_SetStringValue);
64     CHK(FPDFAnnot_GetStringValue);
65     CHK(FPDFAnnot_SetAP);
66     CHK(FPDFAnnot_GetAP);
67     CHK(FPDFAnnot_GetLinkedAnnot);
68     CHK(FPDFAnnot_GetFlags);
69     CHK(FPDFAnnot_SetFlags);
70     CHK(FPDFAnnot_GetFormFieldFlags);
71     CHK(FPDFAnnot_GetFormFieldAtPoint);
72 
73     // fpdf_attachment.h
74     CHK(FPDFDoc_GetAttachmentCount);
75     CHK(FPDFDoc_AddAttachment);
76     CHK(FPDFDoc_GetAttachment);
77     CHK(FPDFDoc_DeleteAttachment);
78     CHK(FPDFAttachment_GetName);
79     CHK(FPDFAttachment_HasKey);
80     CHK(FPDFAttachment_GetValueType);
81     CHK(FPDFAttachment_SetStringValue);
82     CHK(FPDFAttachment_GetStringValue);
83     CHK(FPDFAttachment_SetFile);
84     CHK(FPDFAttachment_GetFile);
85 
86     // fpdf_catalog.h
87     CHK(FPDFCatalog_IsTagged);
88 
89     // fpdf_dataavail.h
90     CHK(FPDFAvail_Create);
91     CHK(FPDFAvail_Destroy);
92     CHK(FPDFAvail_IsDocAvail);
93     CHK(FPDFAvail_GetDocument);
94     CHK(FPDFAvail_GetFirstPageNum);
95     CHK(FPDFAvail_IsPageAvail);
96     CHK(FPDFAvail_IsFormAvail);
97     CHK(FPDFAvail_IsLinearized);
98 
99     // fpdf_doc.h
100     CHK(FPDFBookmark_GetFirstChild);
101     CHK(FPDFBookmark_GetNextSibling);
102     CHK(FPDFBookmark_GetTitle);
103     CHK(FPDFBookmark_Find);
104     CHK(FPDFBookmark_GetDest);
105     CHK(FPDFBookmark_GetAction);
106     CHK(FPDFAction_GetType);
107     CHK(FPDFAction_GetDest);
108     CHK(FPDFAction_GetFilePath);
109     CHK(FPDFAction_GetURIPath);
110     CHK(FPDFDest_GetPageIndex);
111     CHK(FPDFDest_GetLocationInPage);
112     CHK(FPDFDest_GetView);
113     CHK(FPDFLink_GetLinkAtPoint);
114     CHK(FPDFLink_GetLinkZOrderAtPoint);
115     CHK(FPDFLink_GetDest);
116     CHK(FPDFLink_GetAction);
117     CHK(FPDFLink_Enumerate);
118     CHK(FPDFLink_GetAnnotRect);
119     CHK(FPDFLink_CountQuadPoints);
120     CHK(FPDFLink_GetQuadPoints);
121     CHK(FPDF_GetMetaText);
122     CHK(FPDF_GetPageLabel);
123 
124     // fpdf_edit.h
125     CHK(FPDF_CreateNewDocument);
126     CHK(FPDFPage_New);
127     CHK(FPDFPage_Delete);
128     CHK(FPDFPage_GetRotation);
129     CHK(FPDFPage_SetRotation);
130     CHK(FPDFPage_InsertObject);
131     CHK(FPDFPage_CountObject);
132     CHK(FPDFPage_CountObjects);
133     CHK(FPDFPage_GetObject);
134     CHK(FPDFPage_HasTransparency);
135     CHK(FPDFPage_GenerateContent);
136     CHK(FPDFPageObj_Destroy);
137     CHK(FPDFPageObj_HasTransparency);
138     CHK(FPDFPageObj_GetBounds);
139     CHK(FPDFPageObj_GetType);
140     CHK(FPDFPageObj_SetBlendMode);
141     CHK(FPDFPageObj_Transform);
142     CHK(FPDFPage_TransformAnnots);
143     CHK(FPDFPageObj_NewImageObj);
144     CHK(FPDFImageObj_LoadJpegFile);
145     CHK(FPDFImageObj_LoadJpegFileInline);
146     CHK(FPDFImageObj_SetMatrix);
147     CHK(FPDFImageObj_SetBitmap);
148     CHK(FPDFImageObj_GetBitmap);
149     CHK(FPDFImageObj_GetImageDataDecoded);
150     CHK(FPDFImageObj_GetImageDataRaw);
151     CHK(FPDFImageObj_GetImageFilterCount);
152     CHK(FPDFImageObj_GetImageFilter);
153     CHK(FPDFImageObj_GetImageMetadata);
154     CHK(FPDFPageObj_CreateNewPath);
155     CHK(FPDFPageObj_CreateNewRect);
156     CHK(FPDFPath_SetStrokeColor);
157     CHK(FPDFPath_GetStrokeColor);
158     CHK(FPDFPath_SetStrokeWidth);
159     CHK(FPDFPath_SetFillColor);
160     CHK(FPDFPath_GetFillColor);
161     CHK(FPDFPath_CountSegments);
162     CHK(FPDFPath_GetPathSegment);
163     CHK(FPDFPathSegment_GetPoint);
164     CHK(FPDFPathSegment_GetType);
165     CHK(FPDFPathSegment_GetClose);
166     CHK(FPDFPath_MoveTo);
167     CHK(FPDFPath_LineTo);
168     CHK(FPDFPath_BezierTo);
169     CHK(FPDFPath_Close);
170     CHK(FPDFPath_SetDrawMode);
171     CHK(FPDFPath_SetLineCap);
172     CHK(FPDFPath_SetLineJoin);
173     CHK(FPDFPageObj_NewTextObj);
174     CHK(FPDFText_SetText);
175     CHK(FPDFText_SetFillColor);
176     CHK(FPDFText_LoadFont);
177     CHK(FPDFFont_Close);
178     CHK(FPDFPageObj_CreateTextObj);
179 
180     // fpdf_ext.h
181     CHK(FSDK_SetUnSpObjProcessHandler);
182     CHK(FPDFDoc_GetPageMode);
183 
184     // fpdf_flatten.h
185     CHK(FPDFPage_Flatten);
186 
187     // fpdf_fwlevent.h - no exports.
188 
189     // fpdf_formfill.h
190     CHK(FPDFDOC_InitFormFillEnvironment);
191     CHK(FPDFDOC_ExitFormFillEnvironment);
192     CHK(FORM_OnAfterLoadPage);
193     CHK(FORM_OnBeforeClosePage);
194     CHK(FORM_DoDocumentJSAction);
195     CHK(FORM_DoDocumentOpenAction);
196     CHK(FORM_DoDocumentAAction);
197     CHK(FORM_DoPageAAction);
198     CHK(FORM_OnMouseMove);
199     CHK(FORM_OnFocus);
200     CHK(FORM_OnLButtonDown);
201     CHK(FORM_OnLButtonUp);
202 #ifdef PDF_ENABLE_XFA
203     CHK(FORM_OnRButtonDown);
204     CHK(FORM_OnRButtonUp);
205 #endif
206     CHK(FORM_OnKeyDown);
207     CHK(FORM_OnKeyUp);
208     CHK(FORM_OnChar);
209     CHK(FORM_GetSelectedText);
210     CHK(FORM_ReplaceSelection);
211     CHK(FORM_ForceToKillFocus);
212     CHK(FPDFPage_HasFormFieldAtPoint);
213     CHK(FPDFPage_FormFieldZOrderAtPoint);
214     CHK(FPDF_SetFormFieldHighlightColor);
215     CHK(FPDF_SetFormFieldHighlightAlpha);
216     CHK(FPDF_RemoveFormFieldHighlight);
217     CHK(FPDF_FFLDraw);
218 #ifdef _SKIA_SUPPORT_
219     CHK(FPDF_FFLRecord);
220 #endif
221     CHK(FPDF_GetFormType);
222 #ifdef PDF_ENABLE_XFA
223     CHK(FPDF_LoadXFA);
224     CHK(FPDF_Widget_Undo);
225     CHK(FPDF_Widget_Redo);
226     CHK(FPDF_Widget_SelectAll);
227     CHK(FPDF_Widget_Copy);
228     CHK(FPDF_Widget_Cut);
229     CHK(FPDF_Widget_Paste);
230     CHK(FPDF_Widget_ReplaceSpellCheckWord);
231     CHK(FPDF_Widget_GetSpellCheckWords);
232     CHK(FPDF_StringHandleCounts);
233     CHK(FPDF_StringHandleGetStringByIndex);
234     CHK(FPDF_StringHandleRelease);
235     CHK(FPDF_StringHandleAddString);
236 #endif
237 
238     // fpdf_ppo.h
239     CHK(FPDF_ImportPages);
240     CHK(FPDF_CopyViewerPreferences);
241 
242     // fpdf_progressive.h
243     CHK(FPDF_RenderPageBitmap_Start);
244     CHK(FPDF_RenderPage_Continue);
245     CHK(FPDF_RenderPage_Close);
246 
247     // fpdf_save.h
248     CHK(FPDF_SaveAsCopy);
249     CHK(FPDF_SaveWithVersion);
250 
251     // fpdf_searchex.h
252     CHK(FPDFText_GetCharIndexFromTextIndex);
253     CHK(FPDFText_GetTextIndexFromCharIndex);
254 
255     // fpdf_structtree.h
256     CHK(FPDF_StructTree_GetForPage);
257     CHK(FPDF_StructTree_Close);
258     CHK(FPDF_StructTree_CountChildren);
259     CHK(FPDF_StructTree_GetChildAtIndex);
260     CHK(FPDF_StructElement_GetAltText);
261     CHK(FPDF_StructElement_GetMarkedContentID);
262     CHK(FPDF_StructElement_GetType);
263     CHK(FPDF_StructElement_GetTitle);
264     CHK(FPDF_StructElement_CountChildren);
265     CHK(FPDF_StructElement_GetChildAtIndex);
266 
267     // fpdf_sysfontinfo.h
268     CHK(FPDF_GetDefaultTTFMap);
269     CHK(FPDF_AddInstalledFont);
270     CHK(FPDF_SetSystemFontInfo);
271     CHK(FPDF_GetDefaultSystemFontInfo);
272     CHK(FPDF_FreeDefaultSystemFontInfo);
273 
274     // fpdf_text.h
275     CHK(FPDFText_LoadPage);
276     CHK(FPDFText_ClosePage);
277     CHK(FPDFText_CountChars);
278     CHK(FPDFText_GetUnicode);
279     CHK(FPDFText_GetFontSize);
280     CHK(FPDFText_GetCharBox);
281     CHK(FPDFText_GetCharOrigin);
282     CHK(FPDFText_GetCharIndexAtPos);
283     CHK(FPDFText_GetText);
284     CHK(FPDFText_CountRects);
285     CHK(FPDFText_GetRect);
286     CHK(FPDFText_GetBoundedText);
287     CHK(FPDFText_FindStart);
288     CHK(FPDFText_FindNext);
289     CHK(FPDFText_FindPrev);
290     CHK(FPDFText_GetSchResultIndex);
291     CHK(FPDFText_GetSchCount);
292     CHK(FPDFText_FindClose);
293     CHK(FPDFLink_LoadWebLinks);
294     CHK(FPDFLink_CountWebLinks);
295     CHK(FPDFLink_GetURL);
296     CHK(FPDFLink_CountRects);
297     CHK(FPDFLink_GetRect);
298     CHK(FPDFLink_CloseWebLinks);
299 
300     // fpdf_transformpage.h
301     CHK(FPDFPage_SetMediaBox);
302     CHK(FPDFPage_SetCropBox);
303     CHK(FPDFPage_GetMediaBox);
304     CHK(FPDFPage_GetCropBox);
305     CHK(FPDFPage_TransFormWithClip);
306     CHK(FPDFPageObj_TransformClipPath);
307     CHK(FPDF_CreateClipPath);
308     CHK(FPDF_DestroyClipPath);
309     CHK(FPDFPage_InsertClipPath);
310 
311     // fpdfview.h
312     CHK(FPDF_InitLibrary);
313     CHK(FPDF_InitLibraryWithConfig);
314     CHK(FPDF_DestroyLibrary);
315     CHK(FPDF_SetSandBoxPolicy);
316 #if defined(_WIN32)
317 #if defined(PDFIUM_PRINT_TEXT_WITH_GDI)
318     CHK(FPDF_SetTypefaceAccessibleFunc);
319     CHK(FPDF_SetPrintTextWithGDI);
320 #endif
321     CHK(FPDF_SetPrintPostscriptLevel);
322     CHK(FPDF_SetPrintMode);
323 #endif
324     CHK(FPDF_LoadDocument);
325     CHK(FPDF_LoadMemDocument);
326     CHK(FPDF_LoadCustomDocument);
327     CHK(FPDF_GetFileVersion);
328     CHK(FPDF_GetLastError);
329     CHK(FPDF_GetDocPermissions);
330     CHK(FPDF_GetSecurityHandlerRevision);
331     CHK(FPDF_GetPageCount);
332     CHK(FPDF_LoadPage);
333     CHK(FPDF_GetPageWidth);
334     CHK(FPDF_GetPageHeight);
335     CHK(FPDF_GetPageBoundingBox);
336     CHK(FPDF_GetPageSizeByIndex);
337 #ifdef _WIN32
338     CHK(FPDF_RenderPage);
339 #endif
340     CHK(FPDF_RenderPageBitmap);
341     CHK(FPDF_RenderPageBitmapWithMatrix);
342 #ifdef _SKIA_SUPPORT_
343     CHK(FPDF_RenderPageSkp);
344 #endif
345     CHK(FPDF_ClosePage);
346     CHK(FPDF_CloseDocument);
347     CHK(FPDF_DeviceToPage);
348     CHK(FPDF_PageToDevice);
349     CHK(FPDFBitmap_Create);
350     CHK(FPDFBitmap_CreateEx);
351     CHK(FPDFBitmap_GetFormat);
352     CHK(FPDFBitmap_FillRect);
353     CHK(FPDFBitmap_GetBuffer);
354     CHK(FPDFBitmap_GetWidth);
355     CHK(FPDFBitmap_GetHeight);
356     CHK(FPDFBitmap_GetStride);
357     CHK(FPDFBitmap_Destroy);
358     CHK(FPDF_VIEWERREF_GetPrintScaling);
359     CHK(FPDF_VIEWERREF_GetNumCopies);
360     CHK(FPDF_VIEWERREF_GetPrintPageRange);
361     CHK(FPDF_VIEWERREF_GetDuplex);
362     CHK(FPDF_VIEWERREF_GetName);
363     CHK(FPDF_CountNamedDests);
364     CHK(FPDF_GetNamedDestByName);
365     CHK(FPDF_GetNamedDest);
366 #ifdef PDF_ENABLE_XFA
367     CHK(FPDF_BStr_Init);
368     CHK(FPDF_BStr_Set);
369     CHK(FPDF_BStr_Clear);
370 #endif
371 
372     return 1;
373 }
374 
375 #undef CHK
376