pdfium_render/pdf/document/page/annotation/
free_text.rs1use crate::bindgen::{FPDF_ANNOTATION, FPDF_DOCUMENT, FPDF_PAGE};
5use crate::pdf::document::page::annotation::attachment_points::PdfPageAnnotationAttachmentPoints;
6use crate::pdf::document::page::annotation::objects::PdfPageAnnotationObjects;
7use crate::pdf::document::page::annotation::private::internal::PdfPageAnnotationPrivate;
8use crate::pdf::document::page::object::ownership::PdfPageObjectOwnership;
9use crate::pdf::document::page::objects::private::internal::PdfPageObjectsPrivate;
10use crate::pdfium::PdfiumLibraryBindingsAccessor;
11use std::marker::PhantomData;
12
13#[cfg(doc)]
14use {
15 crate::pdf::document::page::annotation::PdfPageAnnotation,
16 crate::pdf::document::page::annotation::PdfPageAnnotationType,
17};
18
19pub struct PdfPageFreeTextAnnotation<'a> {
21 handle: FPDF_ANNOTATION,
22 objects: PdfPageAnnotationObjects<'a>,
23 attachment_points: PdfPageAnnotationAttachmentPoints<'a>,
24 lifetime: PhantomData<&'a FPDF_ANNOTATION>,
25}
26
27impl<'a> PdfPageFreeTextAnnotation<'a> {
28 pub(crate) fn from_pdfium(
29 document_handle: FPDF_DOCUMENT,
30 page_handle: FPDF_PAGE,
31 annotation_handle: FPDF_ANNOTATION,
32 ) -> Self {
33 PdfPageFreeTextAnnotation {
34 handle: annotation_handle,
35 objects: PdfPageAnnotationObjects::from_pdfium(
36 document_handle,
37 page_handle,
38 annotation_handle,
39 ),
40 attachment_points: PdfPageAnnotationAttachmentPoints::from_pdfium(annotation_handle),
41 lifetime: PhantomData,
42 }
43 }
44}
45
46impl<'a> PdfPageAnnotationPrivate<'a> for PdfPageFreeTextAnnotation<'a> {
47 #[inline]
48 fn handle(&self) -> FPDF_ANNOTATION {
49 self.handle
50 }
51
52 #[inline]
53 fn ownership(&self) -> &PdfPageObjectOwnership {
54 self.objects_impl().ownership()
55 }
56
57 #[inline]
58 fn objects_impl(&self) -> &PdfPageAnnotationObjects<'_> {
59 &self.objects
60 }
61
62 #[inline]
63 fn attachment_points_impl(&self) -> &PdfPageAnnotationAttachmentPoints<'_> {
64 &self.attachment_points
65 }
66}
67
68impl<'a> PdfiumLibraryBindingsAccessor<'a> for PdfPageFreeTextAnnotation<'a> {}
69
70#[cfg(feature = "thread_safe")]
71unsafe impl<'a> Send for PdfPageFreeTextAnnotation<'a> {}
72
73#[cfg(feature = "thread_safe")]
74unsafe impl<'a> Sync for PdfPageFreeTextAnnotation<'a> {}