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_DOCUMENT, FPDF_PAGEOBJECT};
5use crate::bindings::PdfiumLibraryBindings;
6use crate::error::PdfiumError;
7use crate::pdf::document::page::object::private::internal::PdfPageObjectPrivate;
8use crate::pdf::document::page::object::PdfPageObject;
9use crate::pdf::document::page::object::PdfPageObjectOwnership;
10use crate::pdf::matrix::{PdfMatrix, PdfMatrixValue};
11use crate::pdf::points::PdfPoints;
12use crate::{create_transform_getters, create_transform_setters};
13
14#[cfg(doc)]
15use {crate::pdf::document::page::object::PdfPageObjectType, crate::pdf::document::page::PdfPage};
16
17/// A single [PdfPageObject] of any object type not supported by Pdfium.
18pub struct PdfPageUnsupportedObject<'a> {
19    object_handle: FPDF_PAGEOBJECT,
20    ownership: PdfPageObjectOwnership,
21    bindings: &'a dyn PdfiumLibraryBindings,
22}
23
24impl<'a> PdfPageUnsupportedObject<'a> {
25    pub(crate) fn from_pdfium(
26        object_handle: FPDF_PAGEOBJECT,
27        ownership: PdfPageObjectOwnership,
28        bindings: &'a dyn PdfiumLibraryBindings,
29    ) -> Self {
30        PdfPageUnsupportedObject {
31            object_handle,
32            ownership,
33            bindings,
34        }
35    }
36
37    create_transform_setters!(
38        &mut Self,
39        Result<(), PdfiumError>,
40        "this [PdfPageUnsupportedObject]",
41        "this [PdfPageUnsupportedObject].",
42        "this [PdfPageUnsupportedObject],"
43    );
44
45    // The transform_impl() function required by the create_transform_setters!() macro
46    // is provided by the PdfPageObjectPrivate trait.
47
48    create_transform_getters!(
49        "this [PdfPageUnsupportedObject]",
50        "this [PdfPageUnsupportedObject].",
51        "this [PdfPageUnsupportedObject],"
52    );
53
54    // The get_matrix_impl() function required by the create_transform_getters!() macro
55    // is provided by the PdfPageObjectPrivate trait.
56}
57
58impl<'a> PdfPageObjectPrivate<'a> for PdfPageUnsupportedObject<'a> {
59    #[inline]
60    fn object_handle(&self) -> FPDF_PAGEOBJECT {
61        self.object_handle
62    }
63
64    #[inline]
65    fn ownership(&self) -> &PdfPageObjectOwnership {
66        &self.ownership
67    }
68
69    #[inline]
70    fn set_ownership(&mut self, ownership: PdfPageObjectOwnership) {
71        self.ownership = ownership;
72    }
73
74    #[inline]
75    fn bindings(&self) -> &dyn PdfiumLibraryBindings {
76        self.bindings
77    }
78
79    #[inline]
80    fn is_copyable_impl(&self) -> bool {
81        false
82    }
83
84    #[inline]
85    fn try_copy_impl<'b>(
86        &self,
87        _: FPDF_DOCUMENT,
88        _: &'b dyn PdfiumLibraryBindings,
89    ) -> Result<PdfPageObject<'b>, PdfiumError> {
90        Err(PdfiumError::UnsupportedPdfPageObjectType)
91    }
92}
93
94impl<'a> Drop for PdfPageUnsupportedObject<'a> {
95    /// Closes this [PdfPageUnsupportedObject], releasing held memory.
96    fn drop(&mut self) {
97        self.drop_impl();
98    }
99}