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

1//! Defines the [PdfPageUnsupportedAnnotation] struct, exposing functionality related to any
2//! single annotation object of a type not supported by Pdfium.
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::annotation::PdfPageAnnotationType;
10
11/// A single `PdfPageAnnotation` of any annotation type not supported by Pdfium.
12pub struct PdfPageUnsupportedAnnotation<'a> {
13    annotation_type: PdfPageAnnotationType,
14    handle: FPDF_ANNOTATION,
15    objects: PdfPageAnnotationObjects<'a>,
16    attachment_points: PdfPageAnnotationAttachmentPoints<'a>,
17    bindings: &'a dyn PdfiumLibraryBindings,
18}
19
20impl<'a> PdfPageUnsupportedAnnotation<'a> {
21    pub(crate) fn from_pdfium(
22        document_handle: FPDF_DOCUMENT,
23        page_handle: FPDF_PAGE,
24        annotation_handle: FPDF_ANNOTATION,
25        annotation_type: PdfPageAnnotationType,
26        bindings: &'a dyn PdfiumLibraryBindings,
27    ) -> Self {
28        PdfPageUnsupportedAnnotation {
29            annotation_type,
30            handle: annotation_handle,
31            objects: PdfPageAnnotationObjects::from_pdfium(
32                document_handle,
33                page_handle,
34                annotation_handle,
35                bindings,
36            ),
37            attachment_points: PdfPageAnnotationAttachmentPoints::from_pdfium(
38                annotation_handle,
39                bindings,
40            ),
41            bindings,
42        }
43    }
44
45    /// Returns the annotation type of this annotation recognized by Pdfium, but unsupported
46    /// for creation, editing, or rendering.
47    #[inline]
48    pub fn get_type(&self) -> PdfPageAnnotationType {
49        self.annotation_type
50    }
51}
52
53impl<'a> PdfPageAnnotationPrivate<'a> for PdfPageUnsupportedAnnotation<'a> {
54    #[inline]
55    fn handle(&self) -> FPDF_ANNOTATION {
56        self.handle
57    }
58
59    #[inline]
60    fn bindings(&self) -> &dyn PdfiumLibraryBindings {
61        self.bindings
62    }
63
64    #[inline]
65    fn objects_impl(&self) -> &PdfPageAnnotationObjects {
66        &self.objects
67    }
68
69    #[inline]
70    fn objects_mut_impl(&mut self) -> &mut PdfPageAnnotationObjects<'a> {
71        &mut self.objects
72    }
73
74    #[inline]
75    fn attachment_points_impl(&self) -> &PdfPageAnnotationAttachmentPoints {
76        &self.attachment_points
77    }
78
79    #[inline]
80    fn attachment_points_mut_impl(&mut self) -> &mut PdfPageAnnotationAttachmentPoints<'a> {
81        &mut self.attachment_points
82    }
83}