Add Opt array functions to to fpdf_annot.h.
Add 2 functions to provide access to Opt array size and option
labels by index. Part of feature work to make Pdfium more usable
by mobile platforms that wish to render comboboxes and listboxes
using custom displays when a widget is selected instead of
Pdfium's support for drawing the dropdown/selected items.
R=thestig@chromium.org
Bug: b/124252477
Change-Id: I4b91a43febbc7dd4f7ce46f744424ddbf8af50f8
Reviewed-on: https://pdfium-review.googlesource.com/c/50474
Reviewed-by: Lei Zhang <thestig@chromium.org>
Commit-Queue: Lei Zhang <thestig@chromium.org>
Auto-Submit: Ryan Smith <rycsmith@google.com>
diff --git a/public/fpdf_annot.h b/public/fpdf_annot.h
index 22d46fa..ae1a14e 100644
--- a/public/fpdf_annot.h
+++ b/public/fpdf_annot.h
@@ -537,6 +537,43 @@
double page_x,
double page_y);
+// Experimental API.
+// Get the number of options in the |annot|'s "Opt" dictionary. Intended for
+// use with listbox and combobox widget annotations.
+//
+// hHandle - handle to the form fill module, returned by
+// FPDFDOC_InitFormFillEnvironment.
+// annot - handle to an annotation.
+//
+// Returns the number of options in "Opt" dictionary on success. Return value
+// will be -1 if annotation does not have an "Opt" dictionary or other error.
+FPDF_EXPORT int FPDF_CALLCONV FPDFAnnot_GetOptionCount(FPDF_FORMHANDLE hHandle,
+ FPDF_ANNOTATION annot);
+
+// Experimental API.
+// Get the string value for the label of the option at |index| in |annot|'s
+// "Opt" dictionary. Intended for use with listbox and combobox widget
+// annotations. |buffer| is only modified if |buflen| is longer than the length
+// of contents. If index is out of range or in case of other error, nothing
+// will be added to |buffer| and the return value will be 0. Note that
+// return value of empty string is 2 for "\0\0".
+//
+// hHandle - handle to the form fill module, returned by
+// FPDFDOC_InitFormFillEnvironment.
+// annot - handle to an annotation.
+// index - numeric index of the option in the "Opt" array
+// buffer - buffer for holding the value string, encoded in UTF16-LE.
+// buflen - length of the buffer.
+//
+// Returns the length of the string value or 0 if annot does not have "Opt"
+// array, index is out of range or other error.
+FPDF_EXPORT unsigned long FPDF_CALLCONV
+FPDFAnnot_GetOptionLabel(FPDF_FORMHANDLE hHandle,
+ FPDF_ANNOTATION annot,
+ int index,
+ void* buffer,
+ unsigned long buflen);
+
#ifdef __cplusplus
} // extern "C"
#endif // __cplusplus