cairo-pager: Add outline to PDF output.
[pspp] / src / output / cairo-pager.h
1 /* PSPP - a program for statistical analysis.
2    Copyright (C) 2009, 2010, 2014, 2020 Free Software Foundation, Inc.
3
4    This program is free software: you can redistribute it and/or modify
5    it under the terms of the GNU General Public License as published by
6    the Free Software Foundation, either version 3 of the License, or
7    (at your option) any later version.
8
9    This program is distributed in the hope that it will be useful,
10    but WITHOUT ANY WARRANTY; without even the implied warranty of
11    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12    GNU General Public License for more details.
13
14    You should have received a copy of the GNU General Public License
15    along with this program.  If not, see <http://www.gnu.org/licenses/>. */
16
17 #ifndef OUTPUT_CAIRO_PAGER_H
18 #define OUTPUT_CAIRO_PAGER_H 1
19
20 #include <stdbool.h>
21
22 #ifdef HAVE_CAIRO
23
24 /* Cairo output driver paginater. */
25
26 #include <cairo/cairo.h>
27 #include <pango/pango-font.h>
28 #include "output/cairo-fsm.h"
29 #include "output/page-setup-item.h"
30 #include "output/table.h"
31
32 struct xr_page_style
33   {
34     int ref_cnt;
35
36     int margins[TABLE_N_AXES][2];    /* Margins. */
37
38     struct page_heading headings[2]; /* Top and bottom headings. */
39
40     int initial_page_number;
41     int object_spacing;
42
43     /* Whether to include an outline in PDF output.  (The only reason I know to
44        omit it is to avoid a Cairo bug that caused crashes in some cases.) */
45     bool include_outline;
46   };
47 struct xr_page_style *xr_page_style_ref (const struct xr_page_style *);
48 struct xr_page_style *xr_page_style_unshare (struct xr_page_style *);
49 void xr_page_style_unref (struct xr_page_style *);
50 bool xr_page_style_equals (const struct xr_page_style *,
51                            const struct xr_page_style *);
52 struct xr_page_style *xr_page_style_default (void);
53
54 static inline int
55 xr_page_style_paper_size (const struct xr_page_style *ps,
56                           const struct xr_fsm_style *fs, enum table_axis a)
57 {
58   return fs->size[a] + ps->margins[a][0] + ps->margins[a][1];
59 }
60
61 struct xr_pager *xr_pager_create (const struct xr_page_style *,
62                                   const struct xr_fsm_style *);
63 void xr_pager_destroy (struct xr_pager *);
64
65 bool xr_pager_has_item (const struct xr_pager *);
66 void xr_pager_add_item (struct xr_pager *, const struct output_item *);
67
68 bool xr_pager_has_page (const struct xr_pager *);
69 void xr_pager_add_page (struct xr_pager *, cairo_t *);
70 void xr_pager_finish_page (struct xr_pager *);
71 bool xr_pager_needs_new_page (struct xr_pager *);
72
73 #endif  /* HAVE_CAIRO */
74
75 #endif /* output/cairo-pager.h */