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
// 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 glib::translate::*;

glib::wrapper! {
    /// A [`Rectangle`][crate::Rectangle] is used to describe
    /// locations on a page and bounding boxes
    pub struct Rectangle(BoxedInline<ffi::PopplerRectangle>);

    match fn {
        copy => |ptr| ffi::poppler_rectangle_copy(mut_override(ptr)),
        free => |ptr| ffi::poppler_rectangle_free(ptr),
        type_ => || ffi::poppler_rectangle_get_type(),
    }
}

impl Rectangle {
    /// Creates a new [`Rectangle`][crate::Rectangle]
    ///
    /// # Returns
    ///
    /// a new [`Rectangle`][crate::Rectangle], use `poppler_rectangle_free()` to free it
    #[doc(alias = "poppler_rectangle_new")]
    pub fn new() -> Rectangle {
        unsafe { from_glib_full(ffi::poppler_rectangle_new()) }
    }

    /// When using [`Page::find_text_with_options()`][crate::Page::find_text_with_options()] with the
    /// [`FindFlags::MULTILINE`][crate::FindFlags::MULTILINE] flag, a match may span more than one line,
    /// and may have been formed by ignoring a hyphen at the end of the line.
    /// When this happens at the end of the line corresponding to `self`,
    /// this function returns [`true`] (and then [`find_get_match_continued()`][Self::find_get_match_continued()]
    /// will also return [`true`]); otherwise it returns [`false`].
    ///
    /// Note that you must only call this function on a [`Rectangle`][crate::Rectangle]
    /// returned in the list from [`Page::find_text()`][crate::Page::find_text()] or
    /// [`Page::find_text_with_options()`][crate::Page::find_text_with_options()].
    ///
    /// # Returns
    ///
    /// whether a hyphen was ignored at the end of the line corresponding to `self`.
    #[cfg(feature = "v21_5")]
    #[cfg_attr(docsrs, doc(cfg(feature = "v21_5")))]
    #[doc(alias = "poppler_rectangle_find_get_ignored_hyphen")]
    pub fn find_get_ignored_hyphen(&self) -> bool {
        unsafe {
            from_glib(ffi::poppler_rectangle_find_get_ignored_hyphen(
                self.to_glib_none().0,
            ))
        }
    }

    /// When using [`Page::find_text_with_options()`][crate::Page::find_text_with_options()] with the
    /// [`FindFlags::MULTILINE`][crate::FindFlags::MULTILINE] flag, a match may span more than one line
    /// and thus consist of more than one rectangle. Every rectangle belonging
    /// to the same match will return [`true`] from this function, except for
    /// the last rectangle, where this function will return [`false`].
    ///
    /// Note that you must only call this function on a [`Rectangle`][crate::Rectangle]
    /// returned in the list from [`Page::find_text()`][crate::Page::find_text()] or
    /// [`Page::find_text_with_options()`][crate::Page::find_text_with_options()].
    ///
    /// # Returns
    ///
    /// whether there are more rectangles belonging to the same match
    #[cfg(feature = "v21_5")]
    #[cfg_attr(docsrs, doc(cfg(feature = "v21_5")))]
    #[doc(alias = "poppler_rectangle_find_get_match_continued")]
    pub fn find_get_match_continued(&self) -> bool {
        unsafe {
            from_glib(ffi::poppler_rectangle_find_get_match_continued(
                self.to_glib_none().0,
            ))
        }
    }
}

impl Default for Rectangle {
    fn default() -> Self {
        Self::new()
    }
}