• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 // Copyright 2014 The PDFium Authors
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4 
5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
6 
7 #ifndef PUBLIC_FPDF_FORMFILL_H_
8 #define PUBLIC_FPDF_FORMFILL_H_
9 
10 // clang-format off
11 // NOLINTNEXTLINE(build/include_directory)
12 #include "fpdfview.h"
13 
14 // These values are return values for a public API, so should not be changed
15 // other than the count when adding new values.
16 #define FORMTYPE_NONE 0            // Document contains no forms
17 #define FORMTYPE_ACRO_FORM 1       // Forms are specified using AcroForm spec
18 #define FORMTYPE_XFA_FULL 2        // Forms are specified using entire XFA spec
19 #define FORMTYPE_XFA_FOREGROUND 3  // Forms are specified using the XFAF subset
20                                    // of XFA spec
21 #define FORMTYPE_COUNT 4           // The number of form types
22 
23 #define JSPLATFORM_ALERT_BUTTON_OK 0           // OK button
24 #define JSPLATFORM_ALERT_BUTTON_OKCANCEL 1     // OK & Cancel buttons
25 #define JSPLATFORM_ALERT_BUTTON_YESNO 2        // Yes & No buttons
26 #define JSPLATFORM_ALERT_BUTTON_YESNOCANCEL 3  // Yes, No & Cancel buttons
27 #define JSPLATFORM_ALERT_BUTTON_DEFAULT JSPLATFORM_ALERT_BUTTON_OK
28 
29 #define JSPLATFORM_ALERT_ICON_ERROR 0     // Error
30 #define JSPLATFORM_ALERT_ICON_WARNING 1   // Warning
31 #define JSPLATFORM_ALERT_ICON_QUESTION 2  // Question
32 #define JSPLATFORM_ALERT_ICON_STATUS 3    // Status
33 #define JSPLATFORM_ALERT_ICON_ASTERISK 4  // Asterisk
34 #define JSPLATFORM_ALERT_ICON_DEFAULT JSPLATFORM_ALERT_ICON_ERROR
35 
36 #define JSPLATFORM_ALERT_RETURN_OK 1      // OK
37 #define JSPLATFORM_ALERT_RETURN_CANCEL 2  // Cancel
38 #define JSPLATFORM_ALERT_RETURN_NO 3      // No
39 #define JSPLATFORM_ALERT_RETURN_YES 4     // Yes
40 
41 #define JSPLATFORM_BEEP_ERROR 0           // Error
42 #define JSPLATFORM_BEEP_WARNING 1         // Warning
43 #define JSPLATFORM_BEEP_QUESTION 2        // Question
44 #define JSPLATFORM_BEEP_STATUS 3          // Status
45 #define JSPLATFORM_BEEP_DEFAULT 4         // Default
46 
47 // Exported Functions
48 #ifdef __cplusplus
49 extern "C" {
50 #endif
51 
52 typedef struct _IPDF_JsPlatform {
53   // Version number of the interface. Currently must be 2.
54   int version;
55 
56   // Version 1.
57 
58   // Method: app_alert
59   //       Pop up a dialog to show warning or hint.
60   // Interface Version:
61   //       1
62   // Implementation Required:
63   //       yes
64   // Parameters:
65   //       pThis       -   Pointer to the interface structure itself.
66   //       Msg         -   A string containing the message to be displayed.
67   //       Title       -   The title of the dialog.
68   //       Type        -   The type of button group, one of the
69   //                       JSPLATFORM_ALERT_BUTTON_* values above.
70   //       nIcon       -   The type of the icon, one of the
71   //                       JSPLATFORM_ALERT_ICON_* above.
72   // Return Value:
73   //       Option selected by user in dialogue, one of the
74   //       JSPLATFORM_ALERT_RETURN_* values above.
75   int (*app_alert)(struct _IPDF_JsPlatform* pThis,
76                    FPDF_WIDESTRING Msg,
77                    FPDF_WIDESTRING Title,
78                    int Type,
79                    int Icon);
80 
81   // Method: app_beep
82   //       Causes the system to play a sound.
83   // Interface Version:
84   //       1
85   // Implementation Required:
86   //       yes
87   // Parameters:
88   //       pThis       -   Pointer to the interface structure itself
89   //       nType       -   The sound type, see JSPLATFORM_BEEP_TYPE_*
90   //                       above.
91   // Return Value:
92   //       None
93   void (*app_beep)(struct _IPDF_JsPlatform* pThis, int nType);
94 
95   // Method: app_response
96   //       Displays a dialog box containing a question and an entry field for
97   //       the user to reply to the question.
98   // Interface Version:
99   //       1
100   // Implementation Required:
101   //       yes
102   // Parameters:
103   //       pThis       -   Pointer to the interface structure itself
104   //       Question    -   The question to be posed to the user.
105   //       Title       -   The title of the dialog box.
106   //       Default     -   A default value for the answer to the question. If
107   //                       not specified, no default value is presented.
108   //       cLabel      -   A short string to appear in front of and on the
109   //                       same line as the edit text field.
110   //       bPassword   -   If true, indicates that the user's response should
111   //                       be shown as asterisks (*) or bullets (?) to mask
112   //                       the response, which might be sensitive information.
113   //       response    -   A string buffer allocated by PDFium, to receive the
114   //                       user's response.
115   //       length      -   The length of the buffer in bytes. Currently, it is
116   //                       always 2048.
117   // Return Value:
118   //       Number of bytes the complete user input would actually require, not
119   //       including trailing zeros, regardless of the value of the length
120   //       parameter or the presence of the response buffer.
121   // Comments:
122   //       No matter on what platform, the response buffer should be always
123   //       written using UTF-16LE encoding. If a response buffer is
124   //       present and the size of the user input exceeds the capacity of the
125   //       buffer as specified by the length parameter, only the
126   //       first "length" bytes of the user input are to be written to the
127   //       buffer.
128   int (*app_response)(struct _IPDF_JsPlatform* pThis,
129                       FPDF_WIDESTRING Question,
130                       FPDF_WIDESTRING Title,
131                       FPDF_WIDESTRING Default,
132                       FPDF_WIDESTRING cLabel,
133                       FPDF_BOOL bPassword,
134                       void* response,
135                       int length);
136 
137   // Method: Doc_getFilePath
138   //       Get the file path of the current document.
139   // Interface Version:
140   //       1
141   // Implementation Required:
142   //       yes
143   // Parameters:
144   //       pThis       -   Pointer to the interface structure itself
145   //       filePath    -   The string buffer to receive the file path. Can
146   //                       be NULL.
147   //       length      -   The length of the buffer, number of bytes. Can
148   //                       be 0.
149   // Return Value:
150   //       Number of bytes the filePath consumes, including trailing zeros.
151   // Comments:
152   //       The filePath should always be provided in the local encoding.
153   //       The return value always indicated number of bytes required for
154   //       the buffer, even when there is no buffer specified, or the buffer
155   //       size is less than required. In this case, the buffer will not
156   //       be modified.
157   int (*Doc_getFilePath)(struct _IPDF_JsPlatform* pThis,
158                          void* filePath,
159                          int length);
160 
161   // Method: Doc_mail
162   //       Mails the data buffer as an attachment to all recipients, with or
163   //       without user interaction.
164   // Interface Version:
165   //       1
166   // Implementation Required:
167   //       yes
168   // Parameters:
169   //       pThis       -   Pointer to the interface structure itself
170   //       mailData    -   Pointer to the data buffer to be sent. Can be NULL.
171   //       length      -   The size,in bytes, of the buffer pointed by
172   //                       mailData parameter. Can be 0.
173   //       bUI         -   If true, the rest of the parameters are used in a
174   //                       compose-new-message window that is displayed to the
175   //                       user. If false, the cTo parameter is required and
176   //                       all others are optional.
177   //       To          -   A semicolon-delimited list of recipients for the
178   //                       message.
179   //       Subject     -   The subject of the message. The length limit is
180   //                       64 KB.
181   //       CC          -   A semicolon-delimited list of CC recipients for
182   //                       the message.
183   //       BCC         -   A semicolon-delimited list of BCC recipients for
184   //                       the message.
185   //       Msg         -   The content of the message. The length limit is
186   //                       64 KB.
187   // Return Value:
188   //       None.
189   // Comments:
190   //       If the parameter mailData is NULL or length is 0, the current
191   //       document will be mailed as an attachment to all recipients.
192   void (*Doc_mail)(struct _IPDF_JsPlatform* pThis,
193                    void* mailData,
194                    int length,
195                    FPDF_BOOL bUI,
196                    FPDF_WIDESTRING To,
197                    FPDF_WIDESTRING Subject,
198                    FPDF_WIDESTRING CC,
199                    FPDF_WIDESTRING BCC,
200                    FPDF_WIDESTRING Msg);
201 
202   // Method: Doc_print
203   //       Prints all or a specific number of pages of the document.
204   // Interface Version:
205   //       1
206   // Implementation Required:
207   //       yes
208   // Parameters:
209   //       pThis         -   Pointer to the interface structure itself.
210   //       bUI           -   If true, will cause a UI to be presented to the
211   //                         user to obtain printing information and confirm
212   //                         the action.
213   //       nStart        -   A 0-based index that defines the start of an
214   //                         inclusive range of pages.
215   //       nEnd          -   A 0-based index that defines the end of an
216   //                         inclusive page range.
217   //       bSilent       -   If true, suppresses the cancel dialog box while
218   //                         the document is printing. The default is false.
219   //       bShrinkToFit  -   If true, the page is shrunk (if necessary) to
220   //                         fit within the imageable area of the printed page.
221   //       bPrintAsImage -   If true, print pages as an image.
222   //       bReverse      -   If true, print from nEnd to nStart.
223   //       bAnnotations  -   If true (the default), annotations are
224   //                         printed.
225   // Return Value:
226   //       None.
227   void (*Doc_print)(struct _IPDF_JsPlatform* pThis,
228                     FPDF_BOOL bUI,
229                     int nStart,
230                     int nEnd,
231                     FPDF_BOOL bSilent,
232                     FPDF_BOOL bShrinkToFit,
233                     FPDF_BOOL bPrintAsImage,
234                     FPDF_BOOL bReverse,
235                     FPDF_BOOL bAnnotations);
236 
237   // Method: Doc_submitForm
238   //       Send the form data to a specified URL.
239   // Interface Version:
240   //       1
241   // Implementation Required:
242   //       yes
243   // Parameters:
244   //       pThis       -   Pointer to the interface structure itself
245   //       formData    -   Pointer to the data buffer to be sent.
246   //       length      -   The size,in bytes, of the buffer pointed by
247   //                       formData parameter.
248   //       URL         -   The URL to send to.
249   // Return Value:
250   //       None.
251   void (*Doc_submitForm)(struct _IPDF_JsPlatform* pThis,
252                          void* formData,
253                          int length,
254                          FPDF_WIDESTRING URL);
255 
256   // Method: Doc_gotoPage
257   //       Jump to a specified page.
258   // Interface Version:
259   //       1
260   // Implementation Required:
261   //       yes
262   // Parameters:
263   //       pThis       -   Pointer to the interface structure itself
264   //       nPageNum    -   The specified page number, zero for the first page.
265   // Return Value:
266   //       None.
267   void (*Doc_gotoPage)(struct _IPDF_JsPlatform* pThis, int nPageNum);
268 
269   // Method: Field_browse
270   //       Show a file selection dialog, and return the selected file path.
271   // Interface Version:
272   //       1
273   // Implementation Required:
274   //       yes
275   // Parameters:
276   //       pThis       -   Pointer to the interface structure itself.
277   //       filePath    -   Pointer to the data buffer to receive the file
278   //                       path. Can be NULL.
279   //       length      -   The length of the buffer, in bytes. Can be 0.
280   // Return Value:
281   //       Number of bytes the filePath consumes, including trailing zeros.
282   // Comments:
283   //       The filePath should always be provided in local encoding.
284   int (*Field_browse)(struct _IPDF_JsPlatform* pThis,
285                       void* filePath,
286                       int length);
287 
288   // Pointer for embedder-specific data. Unused by PDFium, and despite
289   // its name, can be any data the embedder desires, though traditionally
290   // a FPDF_FORMFILLINFO interface.
291   void* m_pFormfillinfo;
292 
293   // Version 2.
294 
295   void* m_isolate;               // Unused in v3, retain for compatibility.
296   unsigned int m_v8EmbedderSlot; // Unused in v3, retain for compatibility.
297 
298   // Version 3.
299   // Version 3 moves m_Isolate and m_v8EmbedderSlot to FPDF_LIBRARY_CONFIG.
300 } IPDF_JSPLATFORM;
301 
302 // Flags for Cursor type
303 #define FXCT_ARROW 0
304 #define FXCT_NESW 1
305 #define FXCT_NWSE 2
306 #define FXCT_VBEAM 3
307 #define FXCT_HBEAM 4
308 #define FXCT_HAND 5
309 
310 // Function signature for the callback function passed to the FFI_SetTimer
311 // method.
312 // Parameters:
313 //          idEvent     -   Identifier of the timer.
314 // Return value:
315 //          None.
316 typedef void (*TimerCallback)(int idEvent);
317 
318 // Declares of a struct type to the local system time.
319 typedef struct _FPDF_SYSTEMTIME {
320   unsigned short wYear;         // years since 1900
321   unsigned short wMonth;        // months since January - [0,11]
322   unsigned short wDayOfWeek;    // days since Sunday - [0,6]
323   unsigned short wDay;          // day of the month - [1,31]
324   unsigned short wHour;         // hours since midnight - [0,23]
325   unsigned short wMinute;       // minutes after the hour - [0,59]
326   unsigned short wSecond;       // seconds after the minute - [0,59]
327   unsigned short wMilliseconds; // milliseconds after the second - [0,999]
328 } FPDF_SYSTEMTIME;
329 
330 #ifdef PDF_ENABLE_XFA
331 
332 // Pageview event flags
333 #define FXFA_PAGEVIEWEVENT_POSTADDED 1    // After a new pageview is added.
334 #define FXFA_PAGEVIEWEVENT_POSTREMOVED 3  // After a pageview is removed.
335 
336 // Definitions for Right Context Menu Features Of XFA Fields
337 #define FXFA_MENU_COPY 1
338 #define FXFA_MENU_CUT 2
339 #define FXFA_MENU_SELECTALL 4
340 #define FXFA_MENU_UNDO 8
341 #define FXFA_MENU_REDO 16
342 #define FXFA_MENU_PASTE 32
343 
344 // Definitions for File Type.
345 #define FXFA_SAVEAS_XML 1
346 #define FXFA_SAVEAS_XDP 2
347 
348 #endif  // PDF_ENABLE_XFA
349 
350 typedef struct _FPDF_FORMFILLINFO {
351   // Version number of the interface.
352   // Version 1 contains stable interfaces. Version 2 has additional
353   // experimental interfaces.
354   // When PDFium is built without the XFA module, version can be 1 or 2.
355   // With version 1, only stable interfaces are called. With version 2,
356   // additional experimental interfaces are also called.
357   // When PDFium is built with the XFA module, version must be 2.
358   // All the XFA related interfaces are experimental. If PDFium is built with
359   // the XFA module and version 1 then none of the XFA related interfaces
360   // would be called. When PDFium is built with XFA module then the version
361   // must be 2.
362   int version;
363 
364   // Version 1.
365 
366   // Method: Release
367   //       Give the implementation a chance to release any resources after the
368   //       interface is no longer used.
369   // Interface Version:
370   //       1
371   // Implementation Required:
372   //       No
373   // Comments:
374   //       Called by PDFium during the final cleanup process.
375   // Parameters:
376   //       pThis       -   Pointer to the interface structure itself
377   // Return Value:
378   //       None
379   void (*Release)(struct _FPDF_FORMFILLINFO* pThis);
380 
381   // Method: FFI_Invalidate
382   //       Invalidate the client area within the specified rectangle.
383   // Interface Version:
384   //       1
385   // Implementation Required:
386   //       yes
387   // Parameters:
388   //       pThis       -   Pointer to the interface structure itself.
389   //       page        -   Handle to the page. Returned by FPDF_LoadPage().
390   //       left        -   Left position of the client area in PDF page
391   //                       coordinates.
392   //       top         -   Top position of the client area in PDF page
393   //                       coordinates.
394   //       right       -   Right position of the client area in PDF page
395   //                       coordinates.
396   //       bottom      -   Bottom position of the client area in PDF page
397   //                       coordinates.
398   // Return Value:
399   //       None.
400   // Comments:
401   //       All positions are measured in PDF "user space".
402   //       Implementation should call FPDF_RenderPageBitmap() for repainting
403   //       the specified page area.
404   void (*FFI_Invalidate)(struct _FPDF_FORMFILLINFO* pThis,
405                          FPDF_PAGE page,
406                          double left,
407                          double top,
408                          double right,
409                          double bottom);
410 
411   // Method: FFI_OutputSelectedRect
412   //       When the user selects text in form fields with the mouse, this
413   //       callback function will be invoked with the selected areas.
414   // Interface Version:
415   //       1
416   // Implementation Required:
417   //       No
418   // Parameters:
419   //       pThis       -   Pointer to the interface structure itself.
420   //       page        -   Handle to the page. Returned by FPDF_LoadPage()/
421   //       left        -   Left position of the client area in PDF page
422   //                       coordinates.
423   //       top         -   Top position of the client area in PDF page
424   //                       coordinates.
425   //       right       -   Right position of the client area in PDF page
426   //                       coordinates.
427   //       bottom      -   Bottom position of the client area in PDF page
428   //                       coordinates.
429   // Return Value:
430   //       None.
431   // Comments:
432   //       This callback function is useful for implementing special text
433   //       selection effects. An implementation should first record the
434   //       returned rectangles, then draw them one by one during the next
435   //       painting period. Lastly, it should remove all the recorded
436   //       rectangles when finished painting.
437   void (*FFI_OutputSelectedRect)(struct _FPDF_FORMFILLINFO* pThis,
438                                  FPDF_PAGE page,
439                                  double left,
440                                  double top,
441                                  double right,
442                                  double bottom);
443 
444   // Method: FFI_SetCursor
445   //       Set the Cursor shape.
446   // Interface Version:
447   //       1
448   // Implementation Required:
449   //       yes
450   // Parameters:
451   //       pThis       -   Pointer to the interface structure itself.
452   //       nCursorType -   Cursor type, see Flags for Cursor type for details.
453   // Return value:
454   //       None.
455   void (*FFI_SetCursor)(struct _FPDF_FORMFILLINFO* pThis, int nCursorType);
456 
457   // Method: FFI_SetTimer
458   //       This method installs a system timer. An interval value is specified,
459   //       and every time that interval elapses, the system must call into the
460   //       callback function with the timer ID as returned by this function.
461   // Interface Version:
462   //       1
463   // Implementation Required:
464   //       yes
465   // Parameters:
466   //       pThis       -   Pointer to the interface structure itself.
467   //       uElapse     -   Specifies the time-out value, in milliseconds.
468   //       lpTimerFunc -   A pointer to the callback function-TimerCallback.
469   // Return value:
470   //       The timer identifier of the new timer if the function is successful.
471   //       An application passes this value to the FFI_KillTimer method to kill
472   //       the timer. Nonzero if it is successful; otherwise, it is zero.
473   int (*FFI_SetTimer)(struct _FPDF_FORMFILLINFO* pThis,
474                       int uElapse,
475                       TimerCallback lpTimerFunc);
476 
477   // Method: FFI_KillTimer
478   //       This method uninstalls a system timer, as set by an earlier call to
479   //       FFI_SetTimer.
480   // Interface Version:
481   //       1
482   // Implementation Required:
483   //       yes
484   // Parameters:
485   //       pThis       -   Pointer to the interface structure itself.
486   //       nTimerID    -   The timer ID returned by FFI_SetTimer function.
487   // Return value:
488   //       None.
489   void (*FFI_KillTimer)(struct _FPDF_FORMFILLINFO* pThis, int nTimerID);
490 
491   // Method: FFI_GetLocalTime
492   //       This method receives the current local time on the system.
493   // Interface Version:
494   //       1
495   // Implementation Required:
496   //       yes
497   // Parameters:
498   //       pThis       -   Pointer to the interface structure itself.
499   // Return value:
500   //       The local time. See FPDF_SYSTEMTIME above for details.
501   // Note: Unused.
502   FPDF_SYSTEMTIME (*FFI_GetLocalTime)(struct _FPDF_FORMFILLINFO* pThis);
503 
504   // Method: FFI_OnChange
505   //       This method will be invoked to notify the implementation when the
506   //       value of any FormField on the document had been changed.
507   // Interface Version:
508   //       1
509   // Implementation Required:
510   //       no
511   // Parameters:
512   //       pThis       -   Pointer to the interface structure itself.
513   // Return value:
514   //       None.
515   void (*FFI_OnChange)(struct _FPDF_FORMFILLINFO* pThis);
516 
517   // Method: FFI_GetPage
518   //       This method receives the page handle associated with a specified
519   //       page index.
520   // Interface Version:
521   //       1
522   // Implementation Required:
523   //       yes
524   // Parameters:
525   //       pThis       -   Pointer to the interface structure itself.
526   //       document    -   Handle to document. Returned by FPDF_LoadDocument().
527   //       nPageIndex  -   Index number of the page. 0 for the first page.
528   // Return value:
529   //       Handle to the page, as previously returned to the implementation by
530   //       FPDF_LoadPage().
531   // Comments:
532   //       The implementation is expected to keep track of the page handles it
533   //       receives from PDFium, and their mappings to page numbers. In some
534   //       cases, the document-level JavaScript action may refer to a page
535   //       which hadn't been loaded yet. To successfully run the Javascript
536   //       action, the implementation needs to load the page.
537   FPDF_PAGE (*FFI_GetPage)(struct _FPDF_FORMFILLINFO* pThis,
538                            FPDF_DOCUMENT document,
539                            int nPageIndex);
540 
541   // Method: FFI_GetCurrentPage
542   //       This method receives the handle to the current page.
543   // Interface Version:
544   //       1
545   // Implementation Required:
546   //       Yes when V8 support is present, otherwise unused.
547   // Parameters:
548   //       pThis       -   Pointer to the interface structure itself.
549   //       document    -   Handle to document. Returned by FPDF_LoadDocument().
550   // Return value:
551   //       Handle to the page. Returned by FPDF_LoadPage().
552   // Comments:
553   //       PDFium doesn't keep keep track of the "current page" (e.g. the one
554   //       that is most visible on screen), so it must ask the embedder for
555   //       this information.
556   FPDF_PAGE (*FFI_GetCurrentPage)(struct _FPDF_FORMFILLINFO* pThis,
557                                   FPDF_DOCUMENT document);
558 
559   // Method: FFI_GetRotation
560   //       This method receives currently rotation of the page view.
561   // Interface Version:
562   //       1
563   // Implementation Required:
564   //       yes
565   // Parameters:
566   //       pThis       -   Pointer to the interface structure itself.
567   //       page        -   Handle to page, as returned by FPDF_LoadPage().
568   // Return value:
569   //       A number to indicate the page rotation in 90 degree increments
570   //       in a clockwise direction:
571   //         0 - 0 degrees
572   //         1 - 90 degrees
573   //         2 - 180 degrees
574   //         3 - 270 degrees
575   // Note: Unused.
576   int (*FFI_GetRotation)(struct _FPDF_FORMFILLINFO* pThis, FPDF_PAGE page);
577 
578   // Method: FFI_ExecuteNamedAction
579   //       This method will execute a named action.
580   // Interface Version:
581   //       1
582   // Implementation Required:
583   //       yes
584   // Parameters:
585   //       pThis           -   Pointer to the interface structure itself.
586   //       namedAction     -   A byte string which indicates the named action,
587   //                           terminated by 0.
588   // Return value:
589   //       None.
590   // Comments:
591   //       See ISO 32000-1:2008, section 12.6.4.11 for descriptions of the
592   //       standard named actions, but note that a document may supply any
593   //       name of its choosing.
594   void (*FFI_ExecuteNamedAction)(struct _FPDF_FORMFILLINFO* pThis,
595                                  FPDF_BYTESTRING namedAction);
596   // Method: FFI_SetTextFieldFocus
597   //       Called when a text field is getting or losing focus.
598   // Interface Version:
599   //       1
600   // Implementation Required:
601   //       no
602   // Parameters:
603   //       pThis           -   Pointer to the interface structure itself.
604   //       value           -   The string value of the form field, in UTF-16LE
605   //                           format.
606   //       valueLen        -   The length of the string value. This is the
607   //                           number of characters, not bytes.
608   //       is_focus        -   True if the form field is getting focus, false
609   //                           if the form field is losing focus.
610   // Return value:
611   //       None.
612   // Comments:
613   //       Only supports text fields and combobox fields.
614   void (*FFI_SetTextFieldFocus)(struct _FPDF_FORMFILLINFO* pThis,
615                                 FPDF_WIDESTRING value,
616                                 FPDF_DWORD valueLen,
617                                 FPDF_BOOL is_focus);
618 
619   // Method: FFI_DoURIAction
620   //       Ask the implementation to navigate to a uniform resource identifier.
621   // Interface Version:
622   //       1
623   // Implementation Required:
624   //       No
625   // Parameters:
626   //       pThis           -   Pointer to the interface structure itself.
627   //       bsURI           -   A byte string which indicates the uniform
628   //                           resource identifier, terminated by 0.
629   // Return value:
630   //       None.
631   // Comments:
632   //       If the embedder is version 2 or higher and have implementation for
633   //       FFI_DoURIActionWithKeyboardModifier, then
634   //       FFI_DoURIActionWithKeyboardModifier takes precedence over
635   //       FFI_DoURIAction.
636   //       See the URI actions description of <<PDF Reference, version 1.7>>
637   //       for more details.
638   void (*FFI_DoURIAction)(struct _FPDF_FORMFILLINFO* pThis,
639                           FPDF_BYTESTRING bsURI);
640 
641   // Method: FFI_DoGoToAction
642   //       This action changes the view to a specified destination.
643   // Interface Version:
644   //       1
645   // Implementation Required:
646   //       No
647   // Parameters:
648   //       pThis           -   Pointer to the interface structure itself.
649   //       nPageIndex      -   The index of the PDF page.
650   //       zoomMode        -   The zoom mode for viewing page. See below.
651   //       fPosArray       -   The float array which carries the position info.
652   //       sizeofArray     -   The size of float array.
653   // PDFZoom values:
654   //         - XYZ = 1
655   //         - FITPAGE = 2
656   //         - FITHORZ = 3
657   //         - FITVERT = 4
658   //         - FITRECT = 5
659   //         - FITBBOX = 6
660   //         - FITBHORZ = 7
661   //         - FITBVERT = 8
662   // Return value:
663   //       None.
664   // Comments:
665   //       See the Destinations description of <<PDF Reference, version 1.7>>
666   //       in 8.2.1 for more details.
667   void (*FFI_DoGoToAction)(struct _FPDF_FORMFILLINFO* pThis,
668                            int nPageIndex,
669                            int zoomMode,
670                            float* fPosArray,
671                            int sizeofArray);
672 
673   // Pointer to IPDF_JSPLATFORM interface.
674   // Unused if PDFium is built without V8 support. Otherwise, if NULL, then
675   // JavaScript will be prevented from executing while rendering the document.
676   IPDF_JSPLATFORM* m_pJsPlatform;
677 
678   // Version 2 - Experimental.
679 
680   // Whether the XFA module is disabled when built with the XFA module.
681   // Interface Version:
682   //       Ignored if |version| < 2.
683   FPDF_BOOL xfa_disabled;
684 
685   // Method: FFI_DisplayCaret
686   //       This method will show the caret at specified position.
687   // Interface Version:
688   //       Ignored if |version| < 2.
689   // Implementation Required:
690   //       Required for XFA, otherwise set to NULL.
691   // Parameters:
692   //       pThis           -   Pointer to the interface structure itself.
693   //       page            -   Handle to page. Returned by FPDF_LoadPage().
694   //       left            -   Left position of the client area in PDF page
695   //                           coordinates.
696   //       top             -   Top position of the client area in PDF page
697   //                           coordinates.
698   //       right           -   Right position of the client area in PDF page
699   //                           coordinates.
700   //       bottom          -   Bottom position of the client area in PDF page
701   //                           coordinates.
702   // Return value:
703   //       None.
704   void (*FFI_DisplayCaret)(struct _FPDF_FORMFILLINFO* pThis,
705                            FPDF_PAGE page,
706                            FPDF_BOOL bVisible,
707                            double left,
708                            double top,
709                            double right,
710                            double bottom);
711 
712   // Method: FFI_GetCurrentPageIndex
713   //       This method will get the current page index.
714   // Interface Version:
715   //       Ignored if |version| < 2.
716   // Implementation Required:
717   //       Required for XFA, otherwise set to NULL.
718   // Parameters:
719   //       pThis           -   Pointer to the interface structure itself.
720   //       document        -   Handle to document from FPDF_LoadDocument().
721   // Return value:
722   //       The index of current page.
723   int (*FFI_GetCurrentPageIndex)(struct _FPDF_FORMFILLINFO* pThis,
724                                  FPDF_DOCUMENT document);
725 
726   // Method: FFI_SetCurrentPage
727   //       This method will set the current page.
728   // Interface Version:
729   //       Ignored if |version| < 2.
730   // Implementation Required:
731   //       Required for XFA, otherwise set to NULL.
732   // Parameters:
733   //       pThis           -   Pointer to the interface structure itself.
734   //       document        -   Handle to document from FPDF_LoadDocument().
735   //       iCurPage        -   The index of the PDF page.
736   // Return value:
737   //       None.
738   void (*FFI_SetCurrentPage)(struct _FPDF_FORMFILLINFO* pThis,
739                              FPDF_DOCUMENT document,
740                              int iCurPage);
741 
742  // Method: FFI_GotoURL
743  //       This method will navigate to the specified URL.
744  // Interface Version:
745  //       Ignored if |version| < 2.
746  // Implementation Required:
747  //       Required for XFA, otherwise set to NULL.
748  // Parameters:
749  //       pThis            -   Pointer to the interface structure itself.
750  //       document         -   Handle to document from FPDF_LoadDocument().
751  //       wsURL            -   The string value of the URL, in UTF-16LE format.
752  // Return value:
753  //       None.
754   void (*FFI_GotoURL)(struct _FPDF_FORMFILLINFO* pThis,
755                       FPDF_DOCUMENT document,
756                       FPDF_WIDESTRING wsURL);
757 
758   // Method: FFI_GetPageViewRect
759   //       This method will get the current page view rectangle.
760   // Interface Version:
761   //       Ignored if |version| < 2.
762   // Implementation Required:
763   //       Required for XFA, otherwise set to NULL.
764   // Parameters:
765   //       pThis           -   Pointer to the interface structure itself.
766   //       page            -   Handle to page. Returned by FPDF_LoadPage().
767   //       left            -   The pointer to receive left position of the page
768   //                           view area in PDF page coordinates.
769   //       top             -   The pointer to receive top position of the page
770   //                           view area in PDF page coordinates.
771   //       right           -   The pointer to receive right position of the
772   //                           page view area in PDF page coordinates.
773   //       bottom          -   The pointer to receive bottom position of the
774   //                           page view area in PDF page coordinates.
775   // Return value:
776   //     None.
777   void (*FFI_GetPageViewRect)(struct _FPDF_FORMFILLINFO* pThis,
778                               FPDF_PAGE page,
779                               double* left,
780                               double* top,
781                               double* right,
782                               double* bottom);
783 
784   // Method: FFI_PageEvent
785   //       This method fires when pages have been added to or deleted from
786   //       the XFA document.
787   // Interface Version:
788   //       Ignored if |version| < 2.
789   // Implementation Required:
790   //       Required for XFA, otherwise set to NULL.
791   // Parameters:
792   //       pThis           -   Pointer to the interface structure itself.
793   //       page_count      -   The number of pages to be added or deleted.
794   //       event_type      -   See FXFA_PAGEVIEWEVENT_* above.
795   // Return value:
796   //       None.
797   // Comments:
798   //       The pages to be added or deleted always start from the last page
799   //       of document. This means that if parameter page_count is 2 and
800   //       event type is FXFA_PAGEVIEWEVENT_POSTADDED, 2 new pages have been
801   //       appended to the tail of document; If page_count is 2 and
802   //       event type is FXFA_PAGEVIEWEVENT_POSTREMOVED, the last 2 pages
803   //       have been deleted.
804   void (*FFI_PageEvent)(struct _FPDF_FORMFILLINFO* pThis,
805                         int page_count,
806                         FPDF_DWORD event_type);
807 
808   // Method: FFI_PopupMenu
809   //       This method will track the right context menu for XFA fields.
810   // Interface Version:
811   //       Ignored if |version| < 2.
812   // Implementation Required:
813   //       Required for XFA, otherwise set to NULL.
814   // Parameters:
815   //       pThis           -   Pointer to the interface structure itself.
816   //       page            -   Handle to page. Returned by FPDF_LoadPage().
817   //       hWidget         -   Always null, exists for compatibility.
818   //       menuFlag        -   The menu flags. Please refer to macro definition
819   //                           of FXFA_MENU_XXX and this can be one or a
820   //                           combination of these macros.
821   //       x               -   X position of the client area in PDF page
822   //                           coordinates.
823   //       y               -   Y position of the client area in PDF page
824   //                           coordinates.
825   // Return value:
826   //       TRUE indicates success; otherwise false.
827   FPDF_BOOL (*FFI_PopupMenu)(struct _FPDF_FORMFILLINFO* pThis,
828                              FPDF_PAGE page,
829                              FPDF_WIDGET hWidget,
830                              int menuFlag,
831                              float x,
832                              float y);
833 
834   // Method: FFI_OpenFile
835   //       This method will open the specified file with the specified mode.
836   // Interface Version:
837   //       Ignored if |version| < 2.
838   // Implementation Required:
839   //       Required for XFA, otherwise set to NULL.
840   // Parameters:
841   //       pThis           -   Pointer to the interface structure itself.
842   //       fileFlag        -   The file flag. Please refer to macro definition
843   //                           of FXFA_SAVEAS_XXX and use one of these macros.
844   //       wsURL           -   The string value of the file URL, in UTF-16LE
845   //                           format.
846   //       mode            -   The mode for open file, e.g. "rb" or "wb".
847   // Return value:
848   //       The handle to FPDF_FILEHANDLER.
849   FPDF_FILEHANDLER* (*FFI_OpenFile)(struct _FPDF_FORMFILLINFO* pThis,
850                                     int fileFlag,
851                                     FPDF_WIDESTRING wsURL,
852                                     const char* mode);
853 
854   // Method: FFI_EmailTo
855   //       This method will email the specified file stream to the specified
856   //       contact.
857   // Interface Version:
858   //       Ignored if |version| < 2.
859   // Implementation Required:
860   //       Required for XFA, otherwise set to NULL.
861   // Parameters:
862   //       pThis           -   Pointer to the interface structure itself.
863   //       pFileHandler    -   Handle to the FPDF_FILEHANDLER.
864   //       pTo             -   A semicolon-delimited list of recipients for the
865   //                           message,in UTF-16LE format.
866   //       pSubject        -   The subject of the message,in UTF-16LE format.
867   //       pCC             -   A semicolon-delimited list of CC recipients for
868   //                           the message,in UTF-16LE format.
869   //       pBcc            -   A semicolon-delimited list of BCC recipients for
870   //                           the message,in UTF-16LE format.
871   //       pMsg            -   Pointer to the data buffer to be sent.Can be
872   //                           NULL,in UTF-16LE format.
873   // Return value:
874   //       None.
875   void (*FFI_EmailTo)(struct _FPDF_FORMFILLINFO* pThis,
876                       FPDF_FILEHANDLER* fileHandler,
877                       FPDF_WIDESTRING pTo,
878                       FPDF_WIDESTRING pSubject,
879                       FPDF_WIDESTRING pCC,
880                       FPDF_WIDESTRING pBcc,
881                       FPDF_WIDESTRING pMsg);
882 
883   // Method: FFI_UploadTo
884   //       This method will upload the specified file stream to the
885   //       specified URL.
886   // Interface Version:
887   //       Ignored if |version| < 2.
888   // Implementation Required:
889   //       Required for XFA, otherwise set to NULL.
890   // Parameters:
891   //       pThis           -   Pointer to the interface structure itself.
892   //       pFileHandler    -   Handle to the FPDF_FILEHANDLER.
893   //       fileFlag        -   The file flag. Please refer to macro definition
894   //                           of FXFA_SAVEAS_XXX and use one of these macros.
895   //       uploadTo        -   Pointer to the URL path, in UTF-16LE format.
896   // Return value:
897   //       None.
898   void (*FFI_UploadTo)(struct _FPDF_FORMFILLINFO* pThis,
899                        FPDF_FILEHANDLER* fileHandler,
900                        int fileFlag,
901                        FPDF_WIDESTRING uploadTo);
902 
903   // Method: FFI_GetPlatform
904   //       This method will get the current platform.
905   // Interface Version:
906   //       Ignored if |version| < 2.
907   // Implementation Required:
908   //       Required for XFA, otherwise set to NULL.
909   // Parameters:
910   //       pThis           -   Pointer to the interface structure itself.
911   //       platform        -   Pointer to the data buffer to receive the
912   //                           platform,in UTF-16LE format. Can be NULL.
913   //       length          -   The length of the buffer in bytes. Can be
914   //                           0 to query the required size.
915   // Return value:
916   //       The length of the buffer, number of bytes.
917   int (*FFI_GetPlatform)(struct _FPDF_FORMFILLINFO* pThis,
918                          void* platform,
919                          int length);
920 
921   // Method: FFI_GetLanguage
922   //       This method will get the current language.
923   // Interface Version:
924   //       Ignored if |version| < 2.
925   // Implementation Required:
926   //       Required for XFA, otherwise set to NULL.
927   // Parameters:
928   //       pThis           -   Pointer to the interface structure itself.
929   //       language        -   Pointer to the data buffer to receive the
930   //                           current language. Can be NULL.
931   //       length          -   The length of the buffer in bytes. Can be
932   //                           0 to query the required size.
933   // Return value:
934   //       The length of the buffer, number of bytes.
935   int (*FFI_GetLanguage)(struct _FPDF_FORMFILLINFO* pThis,
936                          void* language,
937                          int length);
938 
939   // Method: FFI_DownloadFromURL
940   //       This method will download the specified file from the URL.
941   // Interface Version:
942   //       Ignored if |version| < 2.
943   // Implementation Required:
944   //       Required for XFA, otherwise set to NULL.
945   // Parameters:
946   //       pThis           -   Pointer to the interface structure itself.
947   //       URL             -   The string value of the file URL, in UTF-16LE
948   //                           format.
949   // Return value:
950   //       The handle to FPDF_FILEHANDLER.
951   FPDF_FILEHANDLER* (*FFI_DownloadFromURL)(struct _FPDF_FORMFILLINFO* pThis,
952                                            FPDF_WIDESTRING URL);
953   // Method: FFI_PostRequestURL
954   //       This method will post the request to the server URL.
955   // Interface Version:
956   //       Ignored if |version| < 2.
957   // Implementation Required:
958   //       Required for XFA, otherwise set to NULL.
959   // Parameters:
960   //       pThis           -   Pointer to the interface structure itself.
961   //       wsURL           -   The string value of the server URL, in UTF-16LE
962   //                           format.
963   //       wsData          -   The post data,in UTF-16LE format.
964   //       wsContentType   -   The content type of the request data, in
965   //                           UTF-16LE format.
966   //       wsEncode        -   The encode type, in UTF-16LE format.
967   //       wsHeader        -   The request header,in UTF-16LE format.
968   //       response        -   Pointer to the FPDF_BSTR to receive the response
969   //                           data from the server, in UTF-16LE format.
970   // Return value:
971   //       TRUE indicates success, otherwise FALSE.
972   FPDF_BOOL (*FFI_PostRequestURL)(struct _FPDF_FORMFILLINFO* pThis,
973                                   FPDF_WIDESTRING wsURL,
974                                   FPDF_WIDESTRING wsData,
975                                   FPDF_WIDESTRING wsContentType,
976                                   FPDF_WIDESTRING wsEncode,
977                                   FPDF_WIDESTRING wsHeader,
978                                   FPDF_BSTR* response);
979 
980   // Method: FFI_PutRequestURL
981   //       This method will put the request to the server URL.
982   // Interface Version:
983   //       Ignored if |version| < 2.
984   // Implementation Required:
985   //       Required for XFA, otherwise set to NULL.
986   // Parameters:
987   //       pThis           -   Pointer to the interface structure itself.
988   //       wsURL           -   The string value of the server URL, in UTF-16LE
989   //                           format.
990   //       wsData          -   The put data, in UTF-16LE format.
991   //       wsEncode        -   The encode type, in UTR-16LE format.
992   // Return value:
993   //       TRUE indicates success, otherwise FALSE.
994   FPDF_BOOL (*FFI_PutRequestURL)(struct _FPDF_FORMFILLINFO* pThis,
995                                  FPDF_WIDESTRING wsURL,
996                                  FPDF_WIDESTRING wsData,
997                                  FPDF_WIDESTRING wsEncode);
998 
999   // Method: FFI_OnFocusChange
1000   //     Called when the focused annotation is updated.
1001   // Interface Version:
1002   //     Ignored if |version| < 2.
1003   // Implementation Required:
1004   //     No
1005   // Parameters:
1006   //     param           -   Pointer to the interface structure itself.
1007   //     annot           -   The focused annotation.
1008   //     page_index      -   Index number of the page which contains the
1009   //                         focused annotation. 0 for the first page.
1010   // Return value:
1011   //     None.
1012   // Comments:
1013   //     This callback function is useful for implementing any view based
1014   //     action such as scrolling the annotation rect into view. The
1015   //     embedder should not copy and store the annot as its scope is
1016   //     limited to this call only.
1017   void (*FFI_OnFocusChange)(struct _FPDF_FORMFILLINFO* param,
1018                             FPDF_ANNOTATION annot,
1019                             int page_index);
1020 
1021   // Method: FFI_DoURIActionWithKeyboardModifier
1022   //       Ask the implementation to navigate to a uniform resource identifier
1023   //       with the specified modifiers.
1024   // Interface Version:
1025   //       Ignored if |version| < 2.
1026   // Implementation Required:
1027   //       No
1028   // Parameters:
1029   //       param           -   Pointer to the interface structure itself.
1030   //       uri             -   A byte string which indicates the uniform
1031   //                           resource identifier, terminated by 0.
1032   //       modifiers       -   Keyboard modifier that indicates which of
1033   //                           the virtual keys are down, if any.
1034   // Return value:
1035   //       None.
1036   // Comments:
1037   //       If the embedder who is version 2 and does not implement this API,
1038   //       then a call will be redirected to FFI_DoURIAction.
1039   //       See the URI actions description of <<PDF Reference, version 1.7>>
1040   //       for more details.
1041   void(*FFI_DoURIActionWithKeyboardModifier)(struct _FPDF_FORMFILLINFO* param,
1042       FPDF_BYTESTRING uri,
1043       int modifiers);
1044 } FPDF_FORMFILLINFO;
1045 
1046 // Function: FPDFDOC_InitFormFillEnvironment
1047 //       Initialize form fill environment.
1048 // Parameters:
1049 //       document        -   Handle to document from FPDF_LoadDocument().
1050 //       formInfo        -   Pointer to a FPDF_FORMFILLINFO structure.
1051 // Return Value:
1052 //       Handle to the form fill module, or NULL on failure.
1053 // Comments:
1054 //       This function should be called before any form fill operation.
1055 //       The FPDF_FORMFILLINFO passed in via |formInfo| must remain valid until
1056 //       the returned FPDF_FORMHANDLE is closed.
1057 FPDF_EXPORT FPDF_FORMHANDLE FPDF_CALLCONV
1058 FPDFDOC_InitFormFillEnvironment(FPDF_DOCUMENT document,
1059                                 FPDF_FORMFILLINFO* formInfo);
1060 
1061 // Function: FPDFDOC_ExitFormFillEnvironment
1062 //       Take ownership of |hHandle| and exit form fill environment.
1063 // Parameters:
1064 //       hHandle     -   Handle to the form fill module, as returned by
1065 //                       FPDFDOC_InitFormFillEnvironment().
1066 // Return Value:
1067 //       None.
1068 // Comments:
1069 //       This function is a no-op when |hHandle| is null.
1070 FPDF_EXPORT void FPDF_CALLCONV
1071 FPDFDOC_ExitFormFillEnvironment(FPDF_FORMHANDLE hHandle);
1072 
1073 // Function: FORM_OnAfterLoadPage
1074 //       This method is required for implementing all the form related
1075 //       functions. Should be invoked after user successfully loaded a
1076 //       PDF page, and FPDFDOC_InitFormFillEnvironment() has been invoked.
1077 // Parameters:
1078 //       hHandle     -   Handle to the form fill module, as returned by
1079 //                       FPDFDOC_InitFormFillEnvironment().
1080 // Return Value:
1081 //       None.
1082 FPDF_EXPORT void FPDF_CALLCONV FORM_OnAfterLoadPage(FPDF_PAGE page,
1083                                                     FPDF_FORMHANDLE hHandle);
1084 
1085 // Function: FORM_OnBeforeClosePage
1086 //       This method is required for implementing all the form related
1087 //       functions. Should be invoked before user closes the PDF page.
1088 // Parameters:
1089 //        page        -   Handle to the page, as returned by FPDF_LoadPage().
1090 //        hHandle     -   Handle to the form fill module, as returned by
1091 //                        FPDFDOC_InitFormFillEnvironment().
1092 // Return Value:
1093 //        None.
1094 FPDF_EXPORT void FPDF_CALLCONV FORM_OnBeforeClosePage(FPDF_PAGE page,
1095                                                       FPDF_FORMHANDLE hHandle);
1096 
1097 // Function: FORM_DoDocumentJSAction
1098 //       This method is required for performing document-level JavaScript
1099 //       actions. It should be invoked after the PDF document has been loaded.
1100 // Parameters:
1101 //       hHandle     -   Handle to the form fill module, as returned by
1102 //                       FPDFDOC_InitFormFillEnvironment().
1103 // Return Value:
1104 //       None.
1105 // Comments:
1106 //       If there is document-level JavaScript action embedded in the
1107 //       document, this method will execute the JavaScript action. Otherwise,
1108 //       the method will do nothing.
1109 FPDF_EXPORT void FPDF_CALLCONV
1110 FORM_DoDocumentJSAction(FPDF_FORMHANDLE hHandle);
1111 
1112 // Function: FORM_DoDocumentOpenAction
1113 //       This method is required for performing open-action when the document
1114 //       is opened.
1115 // Parameters:
1116 //       hHandle     -   Handle to the form fill module, as returned by
1117 //                       FPDFDOC_InitFormFillEnvironment().
1118 // Return Value:
1119 //       None.
1120 // Comments:
1121 //       This method will do nothing if there are no open-actions embedded
1122 //       in the document.
1123 FPDF_EXPORT void FPDF_CALLCONV
1124 FORM_DoDocumentOpenAction(FPDF_FORMHANDLE hHandle);
1125 
1126 // Additional actions type of document:
1127 //   WC, before closing document, JavaScript action.
1128 //   WS, before saving document, JavaScript action.
1129 //   DS, after saving document, JavaScript action.
1130 //   WP, before printing document, JavaScript action.
1131 //   DP, after printing document, JavaScript action.
1132 #define FPDFDOC_AACTION_WC 0x10
1133 #define FPDFDOC_AACTION_WS 0x11
1134 #define FPDFDOC_AACTION_DS 0x12
1135 #define FPDFDOC_AACTION_WP 0x13
1136 #define FPDFDOC_AACTION_DP 0x14
1137 
1138 // Function: FORM_DoDocumentAAction
1139 //       This method is required for performing the document's
1140 //       additional-action.
1141 // Parameters:
1142 //       hHandle     -   Handle to the form fill module. Returned by
1143 //                       FPDFDOC_InitFormFillEnvironment.
1144 //       aaType      -   The type of the additional-actions which defined
1145 //                       above.
1146 // Return Value:
1147 //       None.
1148 // Comments:
1149 //       This method will do nothing if there is no document
1150 //       additional-action corresponding to the specified |aaType|.
1151 FPDF_EXPORT void FPDF_CALLCONV FORM_DoDocumentAAction(FPDF_FORMHANDLE hHandle,
1152                                                       int aaType);
1153 
1154 // Additional-action types of page object:
1155 //   OPEN (/O) -- An action to be performed when the page is opened
1156 //   CLOSE (/C) -- An action to be performed when the page is closed
1157 #define FPDFPAGE_AACTION_OPEN 0
1158 #define FPDFPAGE_AACTION_CLOSE 1
1159 
1160 // Function: FORM_DoPageAAction
1161 //       This method is required for performing the page object's
1162 //       additional-action when opened or closed.
1163 // Parameters:
1164 //       page        -   Handle to the page, as returned by FPDF_LoadPage().
1165 //       hHandle     -   Handle to the form fill module, as returned by
1166 //                       FPDFDOC_InitFormFillEnvironment().
1167 //       aaType      -   The type of the page object's additional-actions
1168 //                       which defined above.
1169 // Return Value:
1170 //       None.
1171 // Comments:
1172 //       This method will do nothing if no additional-action corresponding
1173 //       to the specified |aaType| exists.
1174 FPDF_EXPORT void FPDF_CALLCONV FORM_DoPageAAction(FPDF_PAGE page,
1175                                                   FPDF_FORMHANDLE hHandle,
1176                                                   int aaType);
1177 
1178 // Function: FORM_OnMouseMove
1179 //       Call this member function when the mouse cursor moves.
1180 // Parameters:
1181 //       hHandle     -   Handle to the form fill module, as returned by
1182 //                       FPDFDOC_InitFormFillEnvironment().
1183 //       page        -   Handle to the page, as returned by FPDF_LoadPage().
1184 //       modifier    -   Indicates whether various virtual keys are down.
1185 //       page_x      -   Specifies the x-coordinate of the cursor in PDF user
1186 //                       space.
1187 //       page_y      -   Specifies the y-coordinate of the cursor in PDF user
1188 //                       space.
1189 // Return Value:
1190 //       True indicates success; otherwise false.
1191 FPDF_EXPORT FPDF_BOOL FPDF_CALLCONV FORM_OnMouseMove(FPDF_FORMHANDLE hHandle,
1192                                                      FPDF_PAGE page,
1193                                                      int modifier,
1194                                                      double page_x,
1195                                                      double page_y);
1196 
1197 // Experimental API
1198 // Function: FORM_OnMouseWheel
1199 //       Call this member function when the user scrolls the mouse wheel.
1200 // Parameters:
1201 //       hHandle     -   Handle to the form fill module, as returned by
1202 //                       FPDFDOC_InitFormFillEnvironment().
1203 //       page        -   Handle to the page, as returned by FPDF_LoadPage().
1204 //       modifier    -   Indicates whether various virtual keys are down.
1205 //       page_coord  -   Specifies the coordinates of the cursor in PDF user
1206 //                       space.
1207 //       delta_x     -   Specifies the amount of wheel movement on the x-axis,
1208 //                       in units of platform-agnostic wheel deltas. Negative
1209 //                       values mean left.
1210 //       delta_y     -   Specifies the amount of wheel movement on the y-axis,
1211 //                       in units of platform-agnostic wheel deltas. Negative
1212 //                       values mean down.
1213 // Return Value:
1214 //       True indicates success; otherwise false.
1215 // Comments:
1216 //       For |delta_x| and |delta_y|, the caller must normalize
1217 //       platform-specific wheel deltas. e.g. On Windows, a delta value of 240
1218 //       for a WM_MOUSEWHEEL event normalizes to 2, since Windows defines
1219 //       WHEEL_DELTA as 120.
1220 FPDF_EXPORT FPDF_BOOL FPDF_CALLCONV FORM_OnMouseWheel(
1221     FPDF_FORMHANDLE hHandle,
1222     FPDF_PAGE page,
1223     int modifier,
1224     const FS_POINTF* page_coord,
1225     int delta_x,
1226     int delta_y);
1227 
1228 // Function: FORM_OnFocus
1229 //       This function focuses the form annotation at a given point. If the
1230 //       annotation at the point already has focus, nothing happens. If there
1231 //       is no annotation at the point, removes form focus.
1232 // Parameters:
1233 //       hHandle     -   Handle to the form fill module, as returned by
1234 //                       FPDFDOC_InitFormFillEnvironment().
1235 //       page        -   Handle to the page, as returned by FPDF_LoadPage().
1236 //       modifier    -   Indicates whether various virtual keys are down.
1237 //       page_x      -   Specifies the x-coordinate of the cursor in PDF user
1238 //                       space.
1239 //       page_y      -   Specifies the y-coordinate of the cursor in PDF user
1240 //                       space.
1241 // Return Value:
1242 //       True if there is an annotation at the given point and it has focus.
1243 FPDF_EXPORT FPDF_BOOL FPDF_CALLCONV FORM_OnFocus(FPDF_FORMHANDLE hHandle,
1244                                                  FPDF_PAGE page,
1245                                                  int modifier,
1246                                                  double page_x,
1247                                                  double page_y);
1248 
1249 // Function: FORM_OnLButtonDown
1250 //       Call this member function when the user presses the left
1251 //       mouse button.
1252 // Parameters:
1253 //       hHandle     -   Handle to the form fill module, as returned by
1254 //                       FPDFDOC_InitFormFillEnvironment().
1255 //       page        -   Handle to the page, as returned by FPDF_LoadPage().
1256 //       modifier    -   Indicates whether various virtual keys are down.
1257 //       page_x      -   Specifies the x-coordinate of the cursor in PDF user
1258 //                       space.
1259 //       page_y      -   Specifies the y-coordinate of the cursor in PDF user
1260 //                       space.
1261 // Return Value:
1262 //       True indicates success; otherwise false.
1263 FPDF_EXPORT FPDF_BOOL FPDF_CALLCONV FORM_OnLButtonDown(FPDF_FORMHANDLE hHandle,
1264                                                        FPDF_PAGE page,
1265                                                        int modifier,
1266                                                        double page_x,
1267                                                        double page_y);
1268 
1269 // Function: FORM_OnRButtonDown
1270 //       Same as above, execpt for the right mouse button.
1271 // Comments:
1272 //       At the present time, has no effect except in XFA builds, but is
1273 //       included for the sake of symmetry.
1274 FPDF_EXPORT FPDF_BOOL FPDF_CALLCONV FORM_OnRButtonDown(FPDF_FORMHANDLE hHandle,
1275                                                        FPDF_PAGE page,
1276                                                        int modifier,
1277                                                        double page_x,
1278                                                        double page_y);
1279 // Function: FORM_OnLButtonUp
1280 //       Call this member function when the user releases the left
1281 //       mouse button.
1282 // Parameters:
1283 //       hHandle     -   Handle to the form fill module, as returned by
1284 //                       FPDFDOC_InitFormFillEnvironment().
1285 //       page        -   Handle to the page, as returned by FPDF_LoadPage().
1286 //       modifier    -   Indicates whether various virtual keys are down.
1287 //       page_x      -   Specifies the x-coordinate of the cursor in device.
1288 //       page_y      -   Specifies the y-coordinate of the cursor in device.
1289 // Return Value:
1290 //       True indicates success; otherwise false.
1291 FPDF_EXPORT FPDF_BOOL FPDF_CALLCONV FORM_OnLButtonUp(FPDF_FORMHANDLE hHandle,
1292                                                      FPDF_PAGE page,
1293                                                      int modifier,
1294                                                      double page_x,
1295                                                      double page_y);
1296 
1297 // Function: FORM_OnRButtonUp
1298 //       Same as above, execpt for the right mouse button.
1299 // Comments:
1300 //       At the present time, has no effect except in XFA builds, but is
1301 //       included for the sake of symmetry.
1302 FPDF_EXPORT FPDF_BOOL FPDF_CALLCONV FORM_OnRButtonUp(FPDF_FORMHANDLE hHandle,
1303                                                      FPDF_PAGE page,
1304                                                      int modifier,
1305                                                      double page_x,
1306                                                      double page_y);
1307 
1308 // Function: FORM_OnLButtonDoubleClick
1309 //       Call this member function when the user double clicks the
1310 //       left mouse button.
1311 // Parameters:
1312 //       hHandle     -   Handle to the form fill module, as returned by
1313 //                       FPDFDOC_InitFormFillEnvironment().
1314 //       page        -   Handle to the page, as returned by FPDF_LoadPage().
1315 //       modifier    -   Indicates whether various virtual keys are down.
1316 //       page_x      -   Specifies the x-coordinate of the cursor in PDF user
1317 //                       space.
1318 //       page_y      -   Specifies the y-coordinate of the cursor in PDF user
1319 //                       space.
1320 // Return Value:
1321 //       True indicates success; otherwise false.
1322 FPDF_EXPORT FPDF_BOOL FPDF_CALLCONV
1323 FORM_OnLButtonDoubleClick(FPDF_FORMHANDLE hHandle,
1324                           FPDF_PAGE page,
1325                           int modifier,
1326                           double page_x,
1327                           double page_y);
1328 
1329 // Function: FORM_OnKeyDown
1330 //       Call this member function when a nonsystem key is pressed.
1331 // Parameters:
1332 //       hHandle     -   Handle to the form fill module, aseturned by
1333 //                       FPDFDOC_InitFormFillEnvironment().
1334 //       page        -   Handle to the page, as returned by FPDF_LoadPage().
1335 //       nKeyCode    -   The virtual-key code of the given key (see
1336 //                       fpdf_fwlevent.h for virtual key codes).
1337 //       modifier    -   Mask of key flags (see fpdf_fwlevent.h for key
1338 //                       flag values).
1339 // Return Value:
1340 //       True indicates success; otherwise false.
1341 FPDF_EXPORT FPDF_BOOL FPDF_CALLCONV FORM_OnKeyDown(FPDF_FORMHANDLE hHandle,
1342                                                    FPDF_PAGE page,
1343                                                    int nKeyCode,
1344                                                    int modifier);
1345 
1346 // Function: FORM_OnKeyUp
1347 //       Call this member function when a nonsystem key is released.
1348 // Parameters:
1349 //       hHandle     -   Handle to the form fill module, as returned by
1350 //                       FPDFDOC_InitFormFillEnvironment().
1351 //       page        -   Handle to the page, as returned by FPDF_LoadPage().
1352 //       nKeyCode    -   The virtual-key code of the given key (see
1353 //                       fpdf_fwlevent.h for virtual key codes).
1354 //       modifier    -   Mask of key flags (see fpdf_fwlevent.h for key
1355 //                       flag values).
1356 // Return Value:
1357 //       True indicates success; otherwise false.
1358 // Comments:
1359 //       Currently unimplemented and always returns false. PDFium reserves this
1360 //       API and may implement it in the future on an as-needed basis.
1361 FPDF_EXPORT FPDF_BOOL FPDF_CALLCONV FORM_OnKeyUp(FPDF_FORMHANDLE hHandle,
1362                                                  FPDF_PAGE page,
1363                                                  int nKeyCode,
1364                                                  int modifier);
1365 
1366 // Function: FORM_OnChar
1367 //       Call this member function when a keystroke translates to a
1368 //       nonsystem character.
1369 // Parameters:
1370 //       hHandle     -   Handle to the form fill module, as returned by
1371 //                       FPDFDOC_InitFormFillEnvironment().
1372 //       page        -   Handle to the page, as returned by FPDF_LoadPage().
1373 //       nChar       -   The character code value itself.
1374 //       modifier    -   Mask of key flags (see fpdf_fwlevent.h for key
1375 //                       flag values).
1376 // Return Value:
1377 //       True indicates success; otherwise false.
1378 FPDF_EXPORT FPDF_BOOL FPDF_CALLCONV FORM_OnChar(FPDF_FORMHANDLE hHandle,
1379                                                 FPDF_PAGE page,
1380                                                 int nChar,
1381                                                 int modifier);
1382 
1383 // Experimental API
1384 // Function: FORM_GetFocusedText
1385 //       Call this function to obtain the text within the current focused
1386 //       field, if any.
1387 // Parameters:
1388 //       hHandle     -   Handle to the form fill module, as returned by
1389 //                       FPDFDOC_InitFormFillEnvironment().
1390 //       page        -   Handle to the page, as returned by FPDF_LoadPage().
1391 //       buffer      -   Buffer for holding the form text, encoded in
1392 //                       UTF-16LE. If NULL, |buffer| is not modified.
1393 //       buflen      -   Length of |buffer| in bytes. If |buflen| is less
1394 //                       than the length of the form text string, |buffer| is
1395 //                       not modified.
1396 // Return Value:
1397 //       Length in bytes for the text in the focused field.
1398 FPDF_EXPORT unsigned long FPDF_CALLCONV
1399 FORM_GetFocusedText(FPDF_FORMHANDLE hHandle,
1400                     FPDF_PAGE page,
1401                     void* buffer,
1402                     unsigned long buflen);
1403 
1404 // Function: FORM_GetSelectedText
1405 //       Call this function to obtain selected text within a form text
1406 //       field or form combobox text field.
1407 // Parameters:
1408 //       hHandle     -   Handle to the form fill module, as returned by
1409 //                       FPDFDOC_InitFormFillEnvironment().
1410 //       page        -   Handle to the page, as returned by FPDF_LoadPage().
1411 //       buffer      -   Buffer for holding the selected text, encoded in
1412 //                       UTF-16LE. If NULL, |buffer| is not modified.
1413 //       buflen      -   Length of |buffer| in bytes. If |buflen| is less
1414 //                       than the length of the selected text string,
1415 //                       |buffer| is not modified.
1416 // Return Value:
1417 //       Length in bytes of selected text in form text field or form combobox
1418 //       text field.
1419 FPDF_EXPORT unsigned long FPDF_CALLCONV
1420 FORM_GetSelectedText(FPDF_FORMHANDLE hHandle,
1421                      FPDF_PAGE page,
1422                      void* buffer,
1423                      unsigned long buflen);
1424 
1425 // Experimental API
1426 // Function: FORM_ReplaceAndKeepSelection
1427 //       Call this function to replace the selected text in a form
1428 //       text field or user-editable form combobox text field with another
1429 //       text string (which can be empty or non-empty). If there is no
1430 //       selected text, this function will append the replacement text after
1431 //       the current caret position. After the insertion, the inserted text
1432 //       will be selected.
1433 // Parameters:
1434 //       hHandle     -   Handle to the form fill module, as returned by
1435 //                       FPDFDOC_InitFormFillEnvironment().
1436 //       page        -   Handle to the page, as Returned by FPDF_LoadPage().
1437 //       wsText      -   The text to be inserted, in UTF-16LE format.
1438 // Return Value:
1439 //       None.
1440 FPDF_EXPORT void FPDF_CALLCONV
1441 FORM_ReplaceAndKeepSelection(FPDF_FORMHANDLE hHandle,
1442                              FPDF_PAGE page,
1443                              FPDF_WIDESTRING wsText);
1444 
1445 // Function: FORM_ReplaceSelection
1446 //       Call this function to replace the selected text in a form
1447 //       text field or user-editable form combobox text field with another
1448 //       text string (which can be empty or non-empty). If there is no
1449 //       selected text, this function will append the replacement text after
1450 //       the current caret position. After the insertion, the selection range
1451 //       will be set to empty.
1452 // Parameters:
1453 //       hHandle     -   Handle to the form fill module, as returned by
1454 //                       FPDFDOC_InitFormFillEnvironment().
1455 //       page        -   Handle to the page, as Returned by FPDF_LoadPage().
1456 //       wsText      -   The text to be inserted, in UTF-16LE format.
1457 // Return Value:
1458 //       None.
1459 FPDF_EXPORT void FPDF_CALLCONV FORM_ReplaceSelection(FPDF_FORMHANDLE hHandle,
1460                                                      FPDF_PAGE page,
1461                                                      FPDF_WIDESTRING wsText);
1462 
1463 // Experimental API
1464 // Function: FORM_SelectAllText
1465 //       Call this function to select all the text within the currently focused
1466 //       form text field or form combobox text field.
1467 // Parameters:
1468 //       hHandle     -   Handle to the form fill module, as returned by
1469 //                       FPDFDOC_InitFormFillEnvironment().
1470 //       page        -   Handle to the page, as returned by FPDF_LoadPage().
1471 // Return Value:
1472 //       Whether the operation succeeded or not.
1473 FPDF_EXPORT FPDF_BOOL FPDF_CALLCONV
1474 FORM_SelectAllText(FPDF_FORMHANDLE hHandle, FPDF_PAGE page);
1475 
1476 // Function: FORM_CanUndo
1477 //       Find out if it is possible for the current focused widget in a given
1478 //       form to perform an undo operation.
1479 // Parameters:
1480 //       hHandle     -   Handle to the form fill module, as returned by
1481 //                       FPDFDOC_InitFormFillEnvironment().
1482 //       page        -   Handle to the page, as returned by FPDF_LoadPage().
1483 // Return Value:
1484 //       True if it is possible to undo.
1485 FPDF_EXPORT FPDF_BOOL FPDF_CALLCONV FORM_CanUndo(FPDF_FORMHANDLE hHandle,
1486                                                  FPDF_PAGE page);
1487 
1488 // Function: FORM_CanRedo
1489 //       Find out if it is possible for the current focused widget in a given
1490 //       form to perform a redo operation.
1491 // Parameters:
1492 //       hHandle     -   Handle to the form fill module, as returned by
1493 //                       FPDFDOC_InitFormFillEnvironment().
1494 //       page        -   Handle to the page, as returned by FPDF_LoadPage().
1495 // Return Value:
1496 //       True if it is possible to redo.
1497 FPDF_EXPORT FPDF_BOOL FPDF_CALLCONV FORM_CanRedo(FPDF_FORMHANDLE hHandle,
1498                                                  FPDF_PAGE page);
1499 
1500 // Function: FORM_Undo
1501 //       Make the current focused widget perform an undo operation.
1502 // Parameters:
1503 //       hHandle     -   Handle to the form fill module, as returned by
1504 //                       FPDFDOC_InitFormFillEnvironment().
1505 //       page        -   Handle to the page, as returned by FPDF_LoadPage().
1506 // Return Value:
1507 //       True if the undo operation succeeded.
1508 FPDF_EXPORT FPDF_BOOL FPDF_CALLCONV FORM_Undo(FPDF_FORMHANDLE hHandle,
1509                                               FPDF_PAGE page);
1510 
1511 // Function: FORM_Redo
1512 //       Make the current focused widget perform a redo operation.
1513 // Parameters:
1514 //       hHandle     -   Handle to the form fill module, as returned by
1515 //                       FPDFDOC_InitFormFillEnvironment().
1516 //       page        -   Handle to the page, as returned by FPDF_LoadPage().
1517 // Return Value:
1518 //       True if the redo operation succeeded.
1519 FPDF_EXPORT FPDF_BOOL FPDF_CALLCONV FORM_Redo(FPDF_FORMHANDLE hHandle,
1520                                               FPDF_PAGE page);
1521 
1522 // Function: FORM_ForceToKillFocus.
1523 //       Call this member function to force to kill the focus of the form
1524 //       field which has focus. If it would kill the focus of a form field,
1525 //       save the value of form field if was changed by theuser.
1526 // Parameters:
1527 //       hHandle     -   Handle to the form fill module, as returned by
1528 //                       FPDFDOC_InitFormFillEnvironment().
1529 // Return Value:
1530 //       True indicates success; otherwise false.
1531 FPDF_EXPORT FPDF_BOOL FPDF_CALLCONV
1532 FORM_ForceToKillFocus(FPDF_FORMHANDLE hHandle);
1533 
1534 // Experimental API.
1535 // Function: FORM_GetFocusedAnnot.
1536 //       Call this member function to get the currently focused annotation.
1537 // Parameters:
1538 //       handle      -   Handle to the form fill module, as returned by
1539 //                       FPDFDOC_InitFormFillEnvironment().
1540 //       page_index  -   Buffer to hold the index number of the page which
1541 //                       contains the focused annotation. 0 for the first page.
1542 //                       Can't be NULL.
1543 //       annot       -   Buffer to hold the focused annotation. Can't be NULL.
1544 // Return Value:
1545 //       On success, return true and write to the out parameters. Otherwise
1546 //       return false and leave the out parameters unmodified.
1547 // Comments:
1548 //       Not currently supported for XFA forms - will report no focused
1549 //       annotation.
1550 //       Must call FPDFPage_CloseAnnot() when the annotation returned in |annot|
1551 //       by this function is no longer needed.
1552 //       This will return true and set |page_index| to -1 and |annot| to NULL,
1553 //       if there is no focused annotation.
1554 FPDF_EXPORT FPDF_BOOL FPDF_CALLCONV
1555 FORM_GetFocusedAnnot(FPDF_FORMHANDLE handle,
1556                      int* page_index,
1557                      FPDF_ANNOTATION* annot);
1558 
1559 // Experimental API.
1560 // Function: FORM_SetFocusedAnnot.
1561 //       Call this member function to set the currently focused annotation.
1562 // Parameters:
1563 //       handle      -   Handle to the form fill module, as returned by
1564 //                       FPDFDOC_InitFormFillEnvironment().
1565 //       annot       -   Handle to an annotation.
1566 // Return Value:
1567 //       True indicates success; otherwise false.
1568 // Comments:
1569 //       |annot| can't be NULL. To kill focus, use FORM_ForceToKillFocus()
1570 //       instead.
1571 FPDF_EXPORT FPDF_BOOL FPDF_CALLCONV
1572 FORM_SetFocusedAnnot(FPDF_FORMHANDLE handle, FPDF_ANNOTATION annot);
1573 
1574 // Form Field Types
1575 // The names of the defines are stable, but the specific values associated with
1576 // them are not, so do not hardcode their values.
1577 #define FPDF_FORMFIELD_UNKNOWN 0      // Unknown.
1578 #define FPDF_FORMFIELD_PUSHBUTTON 1   // push button type.
1579 #define FPDF_FORMFIELD_CHECKBOX 2     // check box type.
1580 #define FPDF_FORMFIELD_RADIOBUTTON 3  // radio button type.
1581 #define FPDF_FORMFIELD_COMBOBOX 4     // combo box type.
1582 #define FPDF_FORMFIELD_LISTBOX 5      // list box type.
1583 #define FPDF_FORMFIELD_TEXTFIELD 6    // text field type.
1584 #define FPDF_FORMFIELD_SIGNATURE 7    // text field type.
1585 #ifdef PDF_ENABLE_XFA
1586 #define FPDF_FORMFIELD_XFA 8              // Generic XFA type.
1587 #define FPDF_FORMFIELD_XFA_CHECKBOX 9     // XFA check box type.
1588 #define FPDF_FORMFIELD_XFA_COMBOBOX 10    // XFA combo box type.
1589 #define FPDF_FORMFIELD_XFA_IMAGEFIELD 11  // XFA image field type.
1590 #define FPDF_FORMFIELD_XFA_LISTBOX 12     // XFA list box type.
1591 #define FPDF_FORMFIELD_XFA_PUSHBUTTON 13  // XFA push button type.
1592 #define FPDF_FORMFIELD_XFA_SIGNATURE 14   // XFA signture field type.
1593 #define FPDF_FORMFIELD_XFA_TEXTFIELD 15   // XFA text field type.
1594 #endif                                    // PDF_ENABLE_XFA
1595 
1596 #ifdef PDF_ENABLE_XFA
1597 #define FPDF_FORMFIELD_COUNT 16
1598 #else  // PDF_ENABLE_XFA
1599 #define FPDF_FORMFIELD_COUNT 8
1600 #endif  // PDF_ENABLE_XFA
1601 
1602 #ifdef PDF_ENABLE_XFA
1603 #define IS_XFA_FORMFIELD(type)                  \
1604   (((type) == FPDF_FORMFIELD_XFA) ||            \
1605    ((type) == FPDF_FORMFIELD_XFA_CHECKBOX) ||   \
1606    ((type) == FPDF_FORMFIELD_XFA_COMBOBOX) ||   \
1607    ((type) == FPDF_FORMFIELD_XFA_IMAGEFIELD) || \
1608    ((type) == FPDF_FORMFIELD_XFA_LISTBOX) ||    \
1609    ((type) == FPDF_FORMFIELD_XFA_PUSHBUTTON) || \
1610    ((type) == FPDF_FORMFIELD_XFA_SIGNATURE) ||  \
1611    ((type) == FPDF_FORMFIELD_XFA_TEXTFIELD))
1612 #endif  // PDF_ENABLE_XFA
1613 
1614 // Function: FPDFPage_HasFormFieldAtPoint
1615 //     Get the form field type by point.
1616 // Parameters:
1617 //     hHandle     -   Handle to the form fill module. Returned by
1618 //                     FPDFDOC_InitFormFillEnvironment().
1619 //     page        -   Handle to the page. Returned by FPDF_LoadPage().
1620 //     page_x      -   X position in PDF "user space".
1621 //     page_y      -   Y position in PDF "user space".
1622 // Return Value:
1623 //     Return the type of the form field; -1 indicates no field.
1624 //     See field types above.
1625 FPDF_EXPORT int FPDF_CALLCONV
1626 FPDFPage_HasFormFieldAtPoint(FPDF_FORMHANDLE hHandle,
1627                              FPDF_PAGE page,
1628                              double page_x,
1629                              double page_y);
1630 
1631 // Function: FPDFPage_FormFieldZOrderAtPoint
1632 //     Get the form field z-order by point.
1633 // Parameters:
1634 //     hHandle     -   Handle to the form fill module. Returned by
1635 //                     FPDFDOC_InitFormFillEnvironment().
1636 //     page        -   Handle to the page. Returned by FPDF_LoadPage().
1637 //     page_x      -   X position in PDF "user space".
1638 //     page_y      -   Y position in PDF "user space".
1639 // Return Value:
1640 //     Return the z-order of the form field; -1 indicates no field.
1641 //     Higher numbers are closer to the front.
1642 FPDF_EXPORT int FPDF_CALLCONV
1643 FPDFPage_FormFieldZOrderAtPoint(FPDF_FORMHANDLE hHandle,
1644                                 FPDF_PAGE page,
1645                                 double page_x,
1646                                 double page_y);
1647 
1648 // Function: FPDF_SetFormFieldHighlightColor
1649 //       Set the highlight color of the specified (or all) form fields
1650 //       in the document.
1651 // Parameters:
1652 //       hHandle     -   Handle to the form fill module, as returned by
1653 //                       FPDFDOC_InitFormFillEnvironment().
1654 //       doc         -   Handle to the document, as returned by
1655 //                       FPDF_LoadDocument().
1656 //       fieldType   -   A 32-bit integer indicating the type of a form
1657 //                       field (defined above).
1658 //       color       -   The highlight color of the form field. Constructed by
1659 //                       0xxxrrggbb.
1660 // Return Value:
1661 //       None.
1662 // Comments:
1663 //       When the parameter fieldType is set to FPDF_FORMFIELD_UNKNOWN, the
1664 //       highlight color will be applied to all the form fields in the
1665 //       document.
1666 //       Please refresh the client window to show the highlight immediately
1667 //       if necessary.
1668 FPDF_EXPORT void FPDF_CALLCONV
1669 FPDF_SetFormFieldHighlightColor(FPDF_FORMHANDLE hHandle,
1670                                 int fieldType,
1671                                 unsigned long color);
1672 
1673 // Function: FPDF_SetFormFieldHighlightAlpha
1674 //       Set the transparency of the form field highlight color in the
1675 //       document.
1676 // Parameters:
1677 //       hHandle     -   Handle to the form fill module, as returned by
1678 //                       FPDFDOC_InitFormFillEnvironment().
1679 //       doc         -   Handle to the document, as returaned by
1680 //                       FPDF_LoadDocument().
1681 //       alpha       -   The transparency of the form field highlight color,
1682 //                       between 0-255.
1683 // Return Value:
1684 //       None.
1685 FPDF_EXPORT void FPDF_CALLCONV
1686 FPDF_SetFormFieldHighlightAlpha(FPDF_FORMHANDLE hHandle, unsigned char alpha);
1687 
1688 // Function: FPDF_RemoveFormFieldHighlight
1689 //       Remove the form field highlight color in the document.
1690 // Parameters:
1691 //       hHandle     -   Handle to the form fill module, as returned by
1692 //                       FPDFDOC_InitFormFillEnvironment().
1693 // Return Value:
1694 //       None.
1695 // Comments:
1696 //       Please refresh the client window to remove the highlight immediately
1697 //       if necessary.
1698 FPDF_EXPORT void FPDF_CALLCONV
1699 FPDF_RemoveFormFieldHighlight(FPDF_FORMHANDLE hHandle);
1700 
1701 // Function: FPDF_FFLDraw
1702 //       Render FormFields and popup window on a page to a device independent
1703 //       bitmap.
1704 // Parameters:
1705 //       hHandle      -   Handle to the form fill module, as returned by
1706 //                        FPDFDOC_InitFormFillEnvironment().
1707 //       bitmap       -   Handle to the device independent bitmap (as the
1708 //                        output buffer). Bitmap handles can be created by
1709 //                        FPDFBitmap_Create().
1710 //       page         -   Handle to the page, as returned by FPDF_LoadPage().
1711 //       start_x      -   Left pixel position of the display area in the
1712 //                        device coordinates.
1713 //       start_y      -   Top pixel position of the display area in the device
1714 //                        coordinates.
1715 //       size_x       -   Horizontal size (in pixels) for displaying the page.
1716 //       size_y       -   Vertical size (in pixels) for displaying the page.
1717 //       rotate       -   Page orientation: 0 (normal), 1 (rotated 90 degrees
1718 //                        clockwise), 2 (rotated 180 degrees), 3 (rotated 90
1719 //                        degrees counter-clockwise).
1720 //       flags        -   0 for normal display, or combination of flags
1721 //                        defined above.
1722 // Return Value:
1723 //       None.
1724 // Comments:
1725 //       This function is designed to render annotations that are
1726 //       user-interactive, which are widget annotations (for FormFields) and
1727 //       popup annotations.
1728 //       With the FPDF_ANNOT flag, this function will render a popup annotation
1729 //       when users mouse-hover on a non-widget annotation. Regardless of
1730 //       FPDF_ANNOT flag, this function will always render widget annotations
1731 //       for FormFields.
1732 //       In order to implement the FormFill functions, implementation should
1733 //       call this function after rendering functions, such as
1734 //       FPDF_RenderPageBitmap() or FPDF_RenderPageBitmap_Start(), have
1735 //       finished rendering the page contents.
1736 FPDF_EXPORT void FPDF_CALLCONV FPDF_FFLDraw(FPDF_FORMHANDLE hHandle,
1737                                             FPDF_BITMAP bitmap,
1738                                             FPDF_PAGE page,
1739                                             int start_x,
1740                                             int start_y,
1741                                             int size_x,
1742                                             int size_y,
1743                                             int rotate,
1744                                             int flags);
1745 
1746 /*
1747 * Function: FPDF_FFLDrawWithMatrix
1748 *       Render FormFields and popup window on a page to a device independent
1749 *       bitmap.
1750 * Parameters:
1751 *       hHandle      -   Handle to the form fill module, as returned by
1752 *                        FPDFDOC_InitFormFillEnvironment().
1753 *       bitmap       -   Handle to the device independent bitmap (as the
1754 *                        output buffer). Bitmap handles can be created by
1755 *                        FPDFBitmap_Create().
1756 *       matrix       -   The transform matrix, which must be invertible.
1757 *                        See PDF Reference 1.7, 4.2.2 Common Transformations.
1758 *       clipping     -   The rect to clip to in device coords.
1759 *       flags        -   0 for normal display, or combination of flags
1760 *                        defined above.
1761 * Return Value:
1762 *       None.
1763 * Comments:
1764 *       This function is designed to render annotations that are
1765 *       user-interactive, which are widget annotations (for FormFields) and
1766 *       popup annotations.
1767 *       With the FPDF_ANNOT flag, this function will render a popup annotation
1768 *       when users mouse-hover on a non-widget annotation. Regardless of
1769 *       FPDF_ANNOT flag, this function will always render widget annotations
1770 *       for FormFields.
1771 *       In order to implement the FormFill functions, implementation should
1772 *       call this function after rendering functions, such as
1773 *       FPDF_RenderPageBitmapWithMatrix(), have finished rendering the page contents.
1774 */
1775 FPDF_EXPORT void FPDF_CALLCONV FPDF_FFLDrawWithMatrix(FPDF_FORMHANDLE hHandle,
1776                                                       FPDF_BITMAP bitmap,
1777                                                       FPDF_PAGE page,
1778                                                       const FS_MATRIX* matrix,
1779                                                       const FS_RECTF* clipping,
1780                                                       int flags);
1781 
1782 #if defined(PDF_USE_SKIA)
1783 FPDF_EXPORT void FPDF_CALLCONV FPDF_FFLDrawSkia(FPDF_FORMHANDLE hHandle,
1784                                                 FPDF_SKIA_CANVAS canvas,
1785                                                 FPDF_PAGE page,
1786                                                 int start_x,
1787                                                 int start_y,
1788                                                 int size_x,
1789                                                 int size_y,
1790                                                 int rotate,
1791                                                 int flags);
1792 #endif
1793 
1794 // Experimental API
1795 // Function: FPDF_GetFormType
1796 //           Returns the type of form contained in the PDF document.
1797 // Parameters:
1798 //           document - Handle to document.
1799 // Return Value:
1800 //           Integer value representing one of the FORMTYPE_ values.
1801 // Comments:
1802 //           If |document| is NULL, then the return value is FORMTYPE_NONE.
1803 FPDF_EXPORT int FPDF_CALLCONV FPDF_GetFormType(FPDF_DOCUMENT document);
1804 
1805 // Experimental API
1806 // Function: FORM_SetIndexSelected
1807 //           Selects/deselects the value at the given |index| of the focused
1808 //           annotation.
1809 // Parameters:
1810 //           hHandle     -   Handle to the form fill module. Returned by
1811 //                           FPDFDOC_InitFormFillEnvironment.
1812 //           page        -   Handle to the page. Returned by FPDF_LoadPage
1813 //           index       -   0-based index of value to be set as
1814 //                           selected/unselected
1815 //           selected    -   true to select, false to deselect
1816 // Return Value:
1817 //           TRUE if the operation succeeded.
1818 //           FALSE if the operation failed or widget is not a supported type.
1819 // Comments:
1820 //           Intended for use with listbox/combobox widget types. Comboboxes
1821 //           have at most a single value selected at a time which cannot be
1822 //           deselected. Deselect on a combobox is a no-op that returns false.
1823 //           Default implementation is a no-op that will return false for
1824 //           other types.
1825 //           Not currently supported for XFA forms - will return false.
1826 FPDF_EXPORT FPDF_BOOL FPDF_CALLCONV
1827 FORM_SetIndexSelected(FPDF_FORMHANDLE hHandle,
1828                       FPDF_PAGE page,
1829                       int index,
1830                       FPDF_BOOL selected);
1831 
1832 // Experimental API
1833 // Function: FORM_IsIndexSelected
1834 //           Returns whether or not the value at |index| of the focused
1835 //           annotation is currently selected.
1836 // Parameters:
1837 //           hHandle     -   Handle to the form fill module. Returned by
1838 //                           FPDFDOC_InitFormFillEnvironment.
1839 //           page        -   Handle to the page. Returned by FPDF_LoadPage
1840 //           index       -   0-based Index of value to check
1841 // Return Value:
1842 //           TRUE if value at |index| is currently selected.
1843 //           FALSE if value at |index| is not selected or widget is not a
1844 //           supported type.
1845 // Comments:
1846 //           Intended for use with listbox/combobox widget types. Default
1847 //           implementation is a no-op that will return false for other types.
1848 //           Not currently supported for XFA forms - will return false.
1849 FPDF_EXPORT FPDF_BOOL FPDF_CALLCONV
1850 FORM_IsIndexSelected(FPDF_FORMHANDLE hHandle, FPDF_PAGE page, int index);
1851 
1852 // Function: FPDF_LoadXFA
1853 //          If the document consists of XFA fields, call this method to
1854 //          attempt to load XFA fields.
1855 // Parameters:
1856 //          document     -   Handle to document from FPDF_LoadDocument().
1857 // Return Value:
1858 //          TRUE upon success, otherwise FALSE. If XFA support is not built
1859 //          into PDFium, performs no action and always returns FALSE.
1860 FPDF_EXPORT FPDF_BOOL FPDF_CALLCONV FPDF_LoadXFA(FPDF_DOCUMENT document);
1861 
1862 #ifdef __cplusplus
1863 }
1864 #endif
1865 
1866 #endif  // PUBLIC_FPDF_FORMFILL_H_
1867