Skip to main content

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

1//! Defines the [PdfPageUnsupportedObject] struct, exposing functionality related to a single
2//! page object of type [PdfPageObjectType::Unsupported].
3
4use crate::bindgen::FPDF_PAGEOBJECT;
5use crate::error::PdfiumError;
6use crate::pdf::document::page::object::private::internal::PdfPageObjectPrivate;
7use crate::pdf::document::page::object::PdfPageObjectOwnership;
8use crate::pdf::matrix::{PdfMatrix, PdfMatrixValue};
9use crate::pdf::points::PdfPoints;
10use crate::pdfium::PdfiumLibraryBindingsAccessor;
11use crate::{create_transform_getters, create_transform_setters};
12use std::marker::PhantomData;
13
14#[cfg(doc)]
15use {
16    crate::pdf::document::page::object::PdfPageObject,
17    crate::pdf::document::page::object::PdfPageObjectType, crate::pdf::document::page::PdfPage,
18};
19
20/// A single [PdfPageObject] of any object type not supported by Pdfium.
21pub struct PdfPageUnsupportedObject<'a> {
22    object_handle: FPDF_PAGEOBJECT,
23    ownership: PdfPageObjectOwnership,
24    lifetime: PhantomData<&'a FPDF_PAGEOBJECT>,
25}
26
27impl<'a> PdfPageUnsupportedObject<'a> {
28    pub(crate) fn from_pdfium(
29        object_handle: FPDF_PAGEOBJECT,
30        ownership: PdfPageObjectOwnership,
31    ) -> Self {
32        PdfPageUnsupportedObject {
33            object_handle,
34            ownership,
35            lifetime: PhantomData,
36        }
37    }
38
39    create_transform_setters!(
40        &mut Self,
41        Result<(), PdfiumError>,
42        "this [PdfPageUnsupportedObject]",
43        "this [PdfPageUnsupportedObject].",
44        "this [PdfPageUnsupportedObject],"
45    );
46
47    // The transform_impl() function required by the create_transform_setters!() macro
48    // is provided by the PdfPageObjectPrivate trait.
49
50    create_transform_getters!(
51        "this [PdfPageUnsupportedObject]",
52        "this [PdfPageUnsupportedObject].",
53        "this [PdfPageUnsupportedObject],"
54    );
55
56    // The get_matrix_impl() function required by the create_transform_getters!() macro
57    // is provided by the PdfPageObjectPrivate trait.
58}
59
60impl<'a> PdfPageObjectPrivate<'a> for PdfPageUnsupportedObject<'a> {
61    #[inline]
62    fn object_handle(&self) -> FPDF_PAGEOBJECT {
63        self.object_handle
64    }
65
66    #[inline]
67    fn ownership(&self) -> &PdfPageObjectOwnership {
68        &self.ownership
69    }
70
71    #[inline]
72    fn set_ownership(&mut self, ownership: PdfPageObjectOwnership) {
73        self.ownership = ownership;
74    }
75}
76
77impl<'a> Drop for PdfPageUnsupportedObject<'a> {
78    /// Closes this [PdfPageUnsupportedObject], releasing held memory.
79    fn drop(&mut self) {
80        self.drop_impl();
81    }
82}
83
84impl<'a> PdfiumLibraryBindingsAccessor<'a> for PdfPageUnsupportedObject<'a> {}
85
86#[cfg(feature = "thread_safe")]
87unsafe impl<'a> Send for PdfPageUnsupportedObject<'a> {}
88
89#[cfg(feature = "thread_safe")]
90unsafe impl<'a> Sync for PdfPageUnsupportedObject<'a> {}