1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114
// This file was generated by gir (https://github.com/gtk-rs/gir)
// from
// from gir-files (https://github.com/gtk-rs/gir-files)
// DO NOT EDIT
use crate::{ffi, Document, StructureElement};
use glib::translate::*;
glib::wrapper! {
#[derive(Debug, PartialEq, Eq, PartialOrd, Ord, Hash)]
pub struct StructureElementIter(Boxed<ffi::PopplerStructureElementIter>);
match fn {
copy => |ptr| ffi::poppler_structure_element_iter_copy(mut_override(ptr)),
free => |ptr| ffi::poppler_structure_element_iter_free(ptr),
type_ => || ffi::poppler_structure_element_iter_get_type(),
}
}
impl StructureElementIter {
/// Returns the root [`StructureElementIter`][crate::StructureElementIter] for `document`, or [`None`]. The
/// returned value must be freed with `poppler_structure_element_iter_free()`.
///
/// Documents may have an associated structure tree —mostly, Tagged-PDF
/// compliant documents— which can be used to obtain information about
/// the document structure and its contents. Each node in the tree contains
/// a [`StructureElement`][crate::StructureElement].
///
/// Here is a simple example that walks the whole tree:
///
/// `<informalexample>``<programlisting>`
/// static void
/// walk_structure (PopplerStructureElementIter *iter)
/// {
/// do {
/// /<!-- -->* Get the element and do something with it *<!-- -->/
/// PopplerStructureElementIter *child = poppler_structure_element_iter_get_child (iter);
/// if (child)
/// walk_structure (child);
/// poppler_structure_element_iter_free (child);
/// } while (poppler_structure_element_iter_next (iter));
/// }
/// ...
/// {
/// iter = poppler_structure_element_iter_new (document);
/// walk_structure (iter);
/// poppler_structure_element_iter_free (iter);
/// }
/// `</programlisting>``</informalexample>`
/// ## `poppler_document`
/// a [`Document`][crate::Document].
///
/// # Returns
///
/// a new [`StructureElementIter`][crate::StructureElementIter], or [`None`] if document
/// doesn't have structure tree.
#[doc(alias = "poppler_structure_element_iter_new")]
pub fn new(poppler_document: &Document) -> StructureElementIter {
unsafe {
from_glib_full(ffi::poppler_structure_element_iter_new(
poppler_document.to_glib_none().0,
))
}
}
/// Returns a new iterator to the children elements of the
/// [`StructureElement`][crate::StructureElement] associated with `iter`. The returned value must
/// be freed with `poppler_structure_element_iter_free()`.
///
/// # Returns
///
/// a new [`StructureElementIter`][crate::StructureElementIter]
#[doc(alias = "poppler_structure_element_iter_get_child")]
#[doc(alias = "get_child")]
#[must_use]
pub fn child(&mut self) -> Option<StructureElementIter> {
unsafe {
from_glib_full(ffi::poppler_structure_element_iter_get_child(
self.to_glib_none_mut().0,
))
}
}
/// Returns the [`StructureElementIter`][crate::StructureElementIter] associated with `self`.
///
/// # Returns
///
/// a new [`StructureElementIter`][crate::StructureElementIter]
#[doc(alias = "poppler_structure_element_iter_get_element")]
#[doc(alias = "get_element")]
pub fn element(&mut self) -> Option<StructureElement> {
unsafe {
from_glib_full(ffi::poppler_structure_element_iter_get_element(
self.to_glib_none_mut().0,
))
}
}
/// Sets `self` to point to the next structure element at the current level
/// of the tree, if valid. See [`new()`][Self::new()] for more
/// information.
///
/// # Returns
///
/// [`true`], if `self` was set to the next structure element
#[doc(alias = "poppler_structure_element_iter_next")]
pub fn next(&mut self) -> bool {
unsafe {
from_glib(ffi::poppler_structure_element_iter_next(
self.to_glib_none_mut().0,
))
}
}
}