Skip to main content

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