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

1//! Defines the [PdfPageSquigglyAnnotation] struct, exposing functionality related to a single
2//! user annotation of type [PdfPageAnnotationType::Squiggly].
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::Squiggly].
16pub struct PdfPageSquigglyAnnotation<'a> {
17    handle: FPDF_ANNOTATION,
18    objects: PdfPageAnnotationObjects<'a>,
19    attachment_points: PdfPageAnnotationAttachmentPoints<'a>,
20    bindings: &'a dyn PdfiumLibraryBindings,
21}
22
23impl<'a> PdfPageSquigglyAnnotation<'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        PdfPageSquigglyAnnotation {
31            handle: annotation_handle,
32            objects: PdfPageAnnotationObjects::from_pdfium(
33                document_handle,
34                page_handle,
35                annotation_handle,
36                bindings,
37            ),
38            attachment_points: PdfPageAnnotationAttachmentPoints::from_pdfium(
39                annotation_handle,
40                bindings,
41            ),
42            bindings,
43        }
44    }
45
46    /// Returns a mutable collection of all the attachment points in this [PdfPageSquigglyAnnotation].
47    #[inline]
48    pub fn attachment_points_mut(&mut self) -> &mut PdfPageAnnotationAttachmentPoints<'a> {
49        &mut self.attachment_points
50    }
51}
52
53impl<'a> PdfPageAnnotationPrivate<'a> for PdfPageSquigglyAnnotation<'a> {
54    #[inline]
55    fn handle(&self) -> FPDF_ANNOTATION {
56        self.handle
57    }
58
59    #[inline]
60    fn ownership(&self) -> &PdfPageObjectOwnership {
61        self.objects_impl().ownership()
62    }
63
64    #[inline]
65    fn bindings(&self) -> &dyn PdfiumLibraryBindings {
66        self.bindings
67    }
68
69    #[inline]
70    fn objects_impl(&self) -> &PdfPageAnnotationObjects {
71        &self.objects
72    }
73
74    #[inline]
75    fn attachment_points_impl(&self) -> &PdfPageAnnotationAttachmentPoints {
76        &self.attachment_points
77    }
78}