Skip to main content

pdfium_render/pdf/document/page/annotation/
underline.rs

1//! Defines the [PdfPageUnderlineAnnotation] struct, exposing functionality related to a single
2//! user annotation of type [PdfPageAnnotationType::Underline].
3
4use crate::bindgen::{FPDF_ANNOTATION, FPDF_DOCUMENT, FPDF_PAGE};
5use crate::bindings::PdfiumLibraryBindings;
6use crate::pdf::document::page::annotation::attachment_points::PdfPageAnnotationAttachmentPoints;
7use crate::pdf::document::page::annotation::objects::PdfPageAnnotationObjects;
8use crate::pdf::document::page::annotation::private::internal::PdfPageAnnotationPrivate;
9use crate::pdf::document::page::object::ownership::PdfPageObjectOwnership;
10use crate::pdf::document::page::objects::private::internal::PdfPageObjectsPrivate;
11
12#[cfg(doc)]
13use crate::pdf::document::page::annotation::{PdfPageAnnotation, PdfPageAnnotationType};
14
15/// A single [PdfPageAnnotation] of type [PdfPageAnnotationType::Underline].
16pub struct PdfPageUnderlineAnnotation<'a> {
17    handle: FPDF_ANNOTATION,
18    objects: PdfPageAnnotationObjects<'a>,
19    attachment_points: PdfPageAnnotationAttachmentPoints<'a>,
20    bindings: &'a dyn PdfiumLibraryBindings,
21}
22
23impl<'a> PdfPageUnderlineAnnotation<'a> {
24    pub(crate) fn from_pdfium(
25        document_handle: FPDF_DOCUMENT,
26        page_handle: FPDF_PAGE,
27        annotation_handle: FPDF_ANNOTATION,
28        bindings: &'a dyn PdfiumLibraryBindings,
29    ) -> Self {
30        PdfPageUnderlineAnnotation {
31            handle: annotation_handle,
32            objects: PdfPageAnnotationObjects::from_pdfium(document_handle, page_handle, annotation_handle, bindings),
33            attachment_points: PdfPageAnnotationAttachmentPoints::from_pdfium(annotation_handle, bindings),
34            bindings,
35        }
36    }
37
38    /// Returns a mutable collection of all the attachment points in this [PdfPageUnderlineAnnotation].
39    #[inline]
40    pub fn attachment_points_mut(&mut self) -> &mut PdfPageAnnotationAttachmentPoints<'a> {
41        &mut self.attachment_points
42    }
43}
44
45impl<'a> PdfPageAnnotationPrivate<'a> for PdfPageUnderlineAnnotation<'a> {
46    #[inline]
47    fn handle(&self) -> FPDF_ANNOTATION {
48        self.handle
49    }
50
51    #[inline]
52    fn ownership(&self) -> &PdfPageObjectOwnership {
53        self.objects_impl().ownership()
54    }
55
56    #[inline]
57    fn bindings(&self) -> &dyn PdfiumLibraryBindings {
58        self.bindings
59    }
60
61    #[inline]
62    fn objects_impl(&self) -> &PdfPageAnnotationObjects<'_> {
63        &self.objects
64    }
65
66    #[inline]
67    fn attachment_points_impl(&self) -> &PdfPageAnnotationAttachmentPoints<'_> {
68        &self.attachment_points
69    }
70}