pdfium_render/pdf/document/page/field/
list.rs1use crate::bindgen::{FPDF_ANNOTATION, FPDF_FORMHANDLE};
5use crate::bindings::PdfiumLibraryBindings;
6use crate::pdf::document::page::field::options::PdfFormFieldOptions;
7use crate::pdf::document::page::field::private::internal::PdfFormFieldPrivate;
8
9pub struct PdfFormListBoxField<'a> {
18 form_handle: FPDF_FORMHANDLE,
19 annotation_handle: FPDF_ANNOTATION,
20 options: PdfFormFieldOptions<'a>,
21 bindings: &'a dyn PdfiumLibraryBindings,
22}
23
24impl<'a> PdfFormListBoxField<'a> {
25 #[inline]
26 pub(crate) fn from_pdfium(
27 form_handle: FPDF_FORMHANDLE,
28 annotation_handle: FPDF_ANNOTATION,
29 bindings: &'a dyn PdfiumLibraryBindings,
30 ) -> Self {
31 PdfFormListBoxField {
32 form_handle,
33 annotation_handle,
34 options: PdfFormFieldOptions::from_pdfium(form_handle, annotation_handle, bindings),
35 bindings,
36 }
37 }
38
39 #[inline]
41 pub fn bindings(&self) -> &'a dyn PdfiumLibraryBindings {
42 self.bindings
43 }
44
45 pub fn options(&self) -> &PdfFormFieldOptions {
47 &self.options
48 }
49
50 #[inline]
52 pub fn value(&self) -> Option<String> {
53 self.options()
54 .iter()
55 .find(|option| option.is_set())
56 .and_then(|option| option.label().cloned())
57 }
58}
59
60impl<'a> PdfFormFieldPrivate<'a> for PdfFormListBoxField<'a> {
61 #[inline]
62 fn form_handle(&self) -> &FPDF_FORMHANDLE {
63 &self.form_handle
64 }
65
66 #[inline]
67 fn annotation_handle(&self) -> &FPDF_ANNOTATION {
68 &self.annotation_handle
69 }
70
71 #[inline]
72 fn bindings(&self) -> &dyn PdfiumLibraryBindings {
73 self.bindings
74 }
75}