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 "fpdfview_c_api_test.h"
11 
12 #include "public/fpdf_dataavail.h"
13 #include "public/fpdf_doc.h"
14 #include "public/fpdf_edit.h"
15 #include "public/fpdf_ext.h"
16 #include "public/fpdf_flatten.h"
17 #include "public/fpdf_formfill.h"
18 #include "public/fpdf_fwlevent.h"
19 #include "public/fpdf_ppo.h"
20 #include "public/fpdf_progressive.h"
21 #include "public/fpdf_save.h"
22 #include "public/fpdf_searchex.h"
23 #include "public/fpdf_sysfontinfo.h"
24 #include "public/fpdf_text.h"
25 #include "public/fpdf_transformpage.h"
26 #include "public/fpdfview.h"
27 
28 // Scheme for avoiding LTO out of existence, warnings, etc.
29 typedef void (*fnptr)(void);  // Legal generic function type for casts.
30 fnptr g_c_api_test_fnptr = NULL;  // Extern, so can't know it doesn't change.
31 #define CHK(x) if ((fnptr)(x) == g_c_api_test_fnptr) return 0
32 
33 // Function to call from gtest harness to ensure linker resolution.
CheckPDFiumCApi()34 int CheckPDFiumCApi() {
35     // fpdf_dataavail.h
36     CHK(FPDFAvail_Create);
37     CHK(FPDFAvail_Destroy);
38     CHK(FPDFAvail_IsDocAvail);
39     CHK(FPDFAvail_GetDocument);
40     CHK(FPDFAvail_GetFirstPageNum);
41     CHK(FPDFAvail_IsPageAvail);
42     CHK(FPDFAvail_IsFormAvail);
43     CHK(FPDFAvail_IsLinearized);
44 
45     // fpdf_doc.h
46     CHK(FPDFBookmark_GetFirstChild);
47     CHK(FPDFBookmark_GetNextSibling);
48     CHK(FPDFBookmark_GetTitle);
49     CHK(FPDFBookmark_Find);
50     CHK(FPDFBookmark_GetDest);
51     CHK(FPDFBookmark_GetAction);
52     CHK(FPDFAction_GetType);
53     CHK(FPDFAction_GetDest);
54     CHK(FPDFAction_GetFilePath);
55     CHK(FPDFAction_GetURIPath);
56     CHK(FPDFDest_GetPageIndex);
57     CHK(FPDFLink_GetLinkAtPoint);
58     CHK(FPDFLink_GetLinkZOrderAtPoint);
59     CHK(FPDFLink_GetDest);
60     CHK(FPDFLink_GetAction);
61     CHK(FPDFLink_Enumerate);
62     CHK(FPDFLink_GetAnnotRect);
63     CHK(FPDFLink_CountQuadPoints);
64     CHK(FPDFLink_GetQuadPoints);
65     CHK(FPDF_GetMetaText);
66 
67     // fpdf_edit.h
68     CHK(FPDF_CreateNewDocument);
69     CHK(FPDFPage_New);
70     CHK(FPDFPage_Delete);
71     CHK(FPDFPage_GetRotation);
72     CHK(FPDFPage_SetRotation);
73     CHK(FPDFPage_InsertObject);
74     CHK(FPDFPage_CountObject);
75     CHK(FPDFPage_GetObject);
76     CHK(FPDFPage_HasTransparency);
77     CHK(FPDFPage_GenerateContent);
78     CHK(FPDFPageObj_HasTransparency);
79     CHK(FPDFPageObj_Transform);
80     CHK(FPDFPage_TransformAnnots);
81     CHK(FPDFPageObj_NewImgeObj);
82     CHK(FPDFImageObj_LoadJpegFile);
83     CHK(FPDFImageObj_SetMatrix);
84     CHK(FPDFImageObj_SetBitmap);
85 
86     // fpdf_ext.h
87     CHK(FSDK_SetUnSpObjProcessHandler);
88     CHK(FPDFDoc_GetPageMode);
89 
90     // fpdf_flatten.h
91     CHK(FPDFPage_Flatten);
92 
93     // fpdf_fwlevent.h - no exports.
94 
95     // fpdf_formfill.h
96     CHK(FPDFDOC_InitFormFillEnvironment);
97     CHK(FPDFDOC_ExitFormFillEnvironment);
98     CHK(FORM_OnAfterLoadPage);
99     CHK(FORM_OnBeforeClosePage);
100     CHK(FORM_DoDocumentJSAction);
101     CHK(FORM_DoDocumentOpenAction);
102     CHK(FORM_DoDocumentAAction);
103     CHK(FORM_DoPageAAction);
104     CHK(FORM_OnMouseMove);
105     CHK(FORM_OnLButtonDown);
106     CHK(FORM_OnLButtonUp);
107 #ifdef PDF_ENABLE_XFA
108     CHK(FORM_OnRButtonDown);
109     CHK(FORM_OnRButtonUp);
110 #endif
111     CHK(FORM_OnKeyDown);
112     CHK(FORM_OnKeyUp);
113     CHK(FORM_OnChar);
114     CHK(FORM_ForceToKillFocus);
115     CHK(FPDFPage_HasFormFieldAtPoint);
116     CHK(FPDPage_HasFormFieldAtPoint);  // DEPRECATED. Remove in the future.
117     CHK(FPDFPage_FormFieldZOrderAtPoint);
118     CHK(FPDF_SetFormFieldHighlightColor);
119     CHK(FPDF_SetFormFieldHighlightAlpha);
120     CHK(FPDF_RemoveFormFieldHighlight);
121     CHK(FPDF_FFLDraw);
122 #ifdef PDF_ENABLE_XFA
123     CHK(FPDF_HasXFAField);
124     CHK(FPDF_LoadXFA);
125     CHK(FPDF_Widget_Undo);
126     CHK(FPDF_Widget_Redo);
127     CHK(FPDF_Widget_SelectAll);
128     CHK(FPDF_Widget_Copy);
129     CHK(FPDF_Widget_Cut);
130     CHK(FPDF_Widget_Paste);
131     CHK(FPDF_Widget_ReplaceSpellCheckWord);
132     CHK(FPDF_Widget_GetSpellCheckWords);
133     CHK(FPDF_StringHandleCounts);
134     CHK(FPDF_StringHandleGetStringByIndex);
135     CHK(FPDF_StringHandleRelease);
136     CHK(FPDF_StringHandleAddString);
137 #endif
138 
139     // fpdf_ppo.h
140     CHK(FPDF_ImportPages);
141     CHK(FPDF_CopyViewerPreferences);
142 
143     // fpdf_progressive.h
144     CHK(FPDF_RenderPageBitmap_Start);
145     CHK(FPDF_RenderPage_Continue);
146     CHK(FPDF_RenderPage_Close);
147 
148     // fpdf_save.h
149     CHK(FPDF_SaveAsCopy);
150     CHK(FPDF_SaveWithVersion);
151 
152     // fpdf_searchex.h
153     CHK(FPDFText_GetCharIndexFromTextIndex);
154 
155     // fpdf_sysfontinfo.h
156     CHK(FPDF_GetDefaultTTFMap);
157     CHK(FPDF_AddInstalledFont);
158     CHK(FPDF_SetSystemFontInfo);
159     CHK(FPDF_GetDefaultSystemFontInfo);
160 
161     // fpdf_text.h
162     CHK(FPDFText_LoadPage);
163     CHK(FPDFText_ClosePage);
164     CHK(FPDFText_CountChars);
165     CHK(FPDFText_GetUnicode);
166     CHK(FPDFText_GetFontSize);
167     CHK(FPDFText_GetCharBox);
168     CHK(FPDFText_GetCharIndexAtPos);
169     CHK(FPDFText_GetText);
170     CHK(FPDFText_CountRects);
171     CHK(FPDFText_GetRect);
172     CHK(FPDFText_GetBoundedText);
173     CHK(FPDFText_FindStart);
174     CHK(FPDFText_FindNext);
175     CHK(FPDFText_FindPrev);
176     CHK(FPDFText_GetSchResultIndex);
177     CHK(FPDFText_GetSchCount);
178     CHK(FPDFText_FindClose);
179     CHK(FPDFLink_LoadWebLinks);
180     CHK(FPDFLink_CountWebLinks);
181     CHK(FPDFLink_GetURL);
182     CHK(FPDFLink_CountRects);
183     CHK(FPDFLink_GetRect);
184     CHK(FPDFLink_CloseWebLinks);
185 
186     // fpdf_transformpage.h
187     CHK(FPDFPage_SetMediaBox);
188     CHK(FPDFPage_SetCropBox);
189     CHK(FPDFPage_GetMediaBox);
190     CHK(FPDFPage_GetCropBox);
191     CHK(FPDFPage_TransFormWithClip);
192     CHK(FPDFPageObj_TransformClipPath);
193     CHK(FPDF_CreateClipPath);
194     CHK(FPDF_DestroyClipPath);
195     CHK(FPDFPage_InsertClipPath);
196 
197     // fpdfview.h
198     CHK(FPDF_InitLibrary);
199     CHK(FPDF_InitLibraryWithConfig);
200     CHK(FPDF_DestroyLibrary);
201     CHK(FPDF_SetSandBoxPolicy);
202     CHK(FPDF_LoadDocument);
203     CHK(FPDF_LoadMemDocument);
204     CHK(FPDF_LoadCustomDocument);
205     CHK(FPDF_GetFileVersion);
206     CHK(FPDF_GetLastError);
207     CHK(FPDF_GetDocPermissions);
208     CHK(FPDF_GetSecurityHandlerRevision);
209     CHK(FPDF_GetPageCount);
210     CHK(FPDF_LoadPage);
211     CHK(FPDF_GetPageWidth);
212     CHK(FPDF_GetPageHeight);
213     CHK(FPDF_GetPageSizeByIndex);
214     CHK(FPDF_RenderPageBitmap);
215     CHK(FPDF_ClosePage);
216     CHK(FPDF_CloseDocument);
217     CHK(FPDF_DeviceToPage);
218     CHK(FPDF_PageToDevice);
219     CHK(FPDFBitmap_Create);
220     CHK(FPDFBitmap_CreateEx);
221     CHK(FPDFBitmap_FillRect);
222     CHK(FPDFBitmap_GetBuffer);
223     CHK(FPDFBitmap_GetWidth);
224     CHK(FPDFBitmap_GetHeight);
225     CHK(FPDFBitmap_GetStride);
226     CHK(FPDFBitmap_Destroy);
227     CHK(FPDF_VIEWERREF_GetPrintScaling);
228     CHK(FPDF_VIEWERREF_GetNumCopies);
229     CHK(FPDF_VIEWERREF_GetPrintPageRange);
230     CHK(FPDF_VIEWERREF_GetDuplex);
231     CHK(FPDF_CountNamedDests);
232     CHK(FPDF_GetNamedDestByName);
233     CHK(FPDF_GetNamedDest);
234 #ifdef PDF_ENABLE_XFA
235     CHK(FPDF_BStr_Init);
236     CHK(FPDF_BStr_Set);
237     CHK(FPDF_BStr_Clear);
238 #endif
239 
240     return 1;
241 }
242 
243 #undef CHK
244