output: Use page_setup for parsing cairo page setup.
[pspp] / src / output / page-setup.h
1 /* PSPP - a program for statistical analysis.
2    Copyright (C) 2009, 2010, 2011, 2018 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_PAGE_SETUP_H
18 #define OUTPUT_PAGE_SETUP_H 1
19
20 /* Page setup.
21
22    Configures the paper size, margins, header and footer, and other attributes
23    used for printing. */
24
25 #include <stdbool.h>
26 #include "table.h"
27
28 struct driver_options;
29
30 enum page_orientation
31   {
32     PAGE_PORTRAIT,
33     PAGE_LANDSCAPE
34   };
35
36 enum page_chart_size
37   {
38     PAGE_CHART_AS_IS,
39     PAGE_CHART_FULL_HEIGHT,
40     PAGE_CHART_HALF_HEIGHT,
41     PAGE_CHART_QUARTER_HEIGHT,
42   };
43
44 struct page_paragraph
45   {
46     char *markup;
47     enum table_halign halign;
48   };
49
50 bool page_paragraph_equals (const struct page_paragraph *,
51                             const struct page_paragraph *);
52
53 struct page_heading
54   {
55     struct page_paragraph *paragraphs;
56     size_t n;
57   };
58
59 void page_heading_copy (struct page_heading *, const struct page_heading *);
60 void page_heading_uninit (struct page_heading *);
61 bool page_heading_equals (const struct page_heading *,
62                           const struct page_heading *);
63
64 struct page_setup
65   {
66     int initial_page_number;
67     double paper[TABLE_N_AXES];         /* Paper size in inches. */
68     double margins[TABLE_N_AXES][2];    /* In inches. */
69     enum page_orientation orientation;
70     double object_spacing;      /* Space between objects, in inches. */
71     enum page_chart_size chart_size;
72     struct page_heading headings[2]; /* Header and footer. */
73     char *file_name;
74   };
75
76 #define PAGE_SETUP_INITIALIZER                                          \
77     {                                                                   \
78         .initial_page_number = 1,                                       \
79         .paper = { [TABLE_HORZ] = 8.5, [TABLE_VERT] = 11.0 },           \
80         .margins = { { 0.5, 0.5 }, { 0.5, 0.5 } },                      \
81         .orientation = PAGE_PORTRAIT,                                   \
82         .object_spacing = 12.0 / 72.0,                                  \
83         .chart_size = PAGE_CHART_AS_IS,                                 \
84     }
85
86 struct page_setup *page_setup_clone (const struct page_setup *);
87 void page_setup_destroy (struct page_setup *);
88
89 struct page_setup *page_setup_parse (struct driver_options *);
90
91 #endif /* output/page-setup.h */