1 #ifndef _GNM_PRINT_INFO_H_
2 # define _GNM_PRINT_INFO_H_
3 
4 #include <gnumeric.h>
5 #include <print.h>
6 
7 G_BEGIN_DECLS
8 
9 GType gnm_print_comment_placement_get_type (void);
10 #define GNM_PRINT_COMMENT_PLACEMENT_TYPE (gnm_print_comment_placement_get_type ())
11 
12 GType gnm_print_errors_get_type (void);
13 #define GNM_PRINT_ERRORS_TYPE (gnm_print_errors_get_type ())
14 
15 
16 typedef struct {
17 	GtkUnit   top, bottom, left, right, header, footer;
18 } GnmPrintDesiredDisplay;
19 
20 /* Header/Footer definition */
21 typedef struct {
22 	char *left_format;
23 	char *middle_format;
24 	char *right_format;
25 } GnmPrintHF;
26 
27 typedef enum {
28 	GNM_PRINT_COMMENTS_NONE,
29 	GNM_PRINT_COMMENTS_IN_PLACE,
30 	GNM_PRINT_COMMENTS_AT_END
31 } GnmPrintCommentPlacementType;
32 
33 typedef enum {
34 	GNM_PRINT_ERRORS_AS_DISPLAYED,
35 	GNM_PRINT_ERRORS_AS_BLANK,
36 	GNM_PRINT_ERRORS_AS_DASHES,
37 	GNM_PRINT_ERRORS_AS_NA
38 } GnmPrintErrorsType;
39 
40 typedef enum {
41 	GNM_PAGE_BREAK_NONE,    /* Not actually a page break  */
42 	GNM_PAGE_BREAK_MANUAL,  /* hard page break            */
43 	GNM_PAGE_BREAK_AUTO,    /* soft (automatic) pagebreak */
44 	GNM_PAGE_BREAK_DATA_SLICE  /* place holder ?          */
45 } GnmPageBreakType;
46 GnmPageBreakType gnm_page_break_type_from_str (char const *str);
47 
48 typedef struct {
49 	int		 pos;  /* break before this 0 based position */
50 	GnmPageBreakType type;
51 } GnmPageBreak;
52 
53 typedef struct {
54 	gboolean is_vert;
55 	GArray	*details; /* ordered array of GnmPageBreak  */
56 } GnmPageBreaks;
57 
58 struct GnmPrintInformation_ {
59 	struct GnmPrintInfoScaling_ {
60 		enum GnmPrintScaleType_ {
61 			PRINT_SCALE_PERCENTAGE,
62 			PRINT_SCALE_FIT_PAGES
63 		} type;
64 
65 		/* We store separate x and y scales internally, for the
66 		* 'fit-to' printing feature. (They are calculated at print-time)
67 		* When the user is doing the simple scaling, both these values
68 		* will be equal.
69 		*/
70 		struct _PrintScalePercent {
71 			double x;
72 			double y;
73 		} percentage;
74 
75 		struct _PrintScaleDim { /* zero == use as many as required */
76 			int cols;
77 			int rows;
78 		} dim;
79 	} scaling;
80 	double           edge_to_below_header;
81 	double           edge_to_above_footer;
82         GnmPrintDesiredDisplay   desired_display;
83 	char            *repeat_top, *repeat_left;
84 	unsigned int	 print_across_then_down;
85 	unsigned int     center_vertically:1;
86 	unsigned int     center_horizontally:1;
87 	unsigned int     print_grid_lines:1;
88 	unsigned int     print_titles:1;	/* col/row headers */
89 	unsigned int     print_black_and_white:1;
90 	unsigned int     print_as_draft:1;
91 
92 	/* Gnumeric specific */
93 	unsigned int     print_even_if_only_styles:1;
94 	unsigned int     do_not_print:1;
95 
96 	GnmPrintCommentPlacementType comment_placement;
97 	GnmPrintErrorsType error_display;
98 
99 	struct _PrintInfoPageBreaks {
100 		GnmPageBreaks *h,  /* between rows */
101 			      *v;  /* between columns */
102 	} page_breaks;
103 	GnmPrintHF		*header, *footer;
104 
105 	int		  start_page; /* < 0 implies auto */
106         int              n_copies;
107 
108 	gchar           *printtofile_uri;
109 	PrintRange       print_range;
110 
111   /* page_setup doubles as a flag whether the defaults are loaded */
112         GtkPageSetup     *page_setup;
113 };
114 
115 typedef enum {
116 	HF_RENDER_PRINT
117 } GnmPrintHFRenderType;
118 
119 typedef struct {
120 	Sheet const *sheet;
121 	int       page;
122 	int       pages;
123 	GnmValue *date_time;
124 	GODateConventions const *date_conv;
125 	GnmRange  page_area;
126 	GnmCellPos top_repeating;
127 } GnmPrintHFRenderInfo;
128 
129 GType             gnm_print_information_get_type (void);
130 GnmPrintInformation *gnm_print_information_new         (gboolean load_defaults);
131 void              gnm_print_info_load_defaults (GnmPrintInformation *pi);
132 GnmPrintInformation *gnm_print_info_dup	 (GnmPrintInformation const *pi);
133 void              gnm_print_info_free        (GnmPrintInformation *pi);
134 void              gnm_print_info_save        (GnmPrintInformation *pi);
135 
136 GtkPageSetup     *gnm_print_info_get_page_setup (GnmPrintInformation *pi); /* Does not return a ref! */
137 void              gnm_print_info_set_page_setup (GnmPrintInformation *pi, GtkPageSetup *page_setup);
138 
139 GType             gnm_print_hf_get_type      (void);
140 GnmPrintHF          *gnm_print_hf_new           (char const *left,
141 					  char const *middle,
142 				          char const *right);
143 void              gnm_print_hf_free          (GnmPrintHF *print_hf);
144 GnmPrintHF          *gnm_print_hf_copy          (GnmPrintHF const *source);
145 GnmPrintHF          *gnm_print_hf_register      (GnmPrintHF *hf);
146 gboolean          gnm_print_hf_same          (GnmPrintHF const *a, GnmPrintHF const *b);
147 
148 char             *gnm_print_hf_format_render       (char const *format,
149 					  GnmPrintHFRenderInfo *info,
150 					  GnmPrintHFRenderType render_type);
151 
152 GType             gnm_print_hf_render_info_get_type      (void);
153 GnmPrintHFRenderInfo     *gnm_print_hf_render_info_new     (void);
154 void              gnm_print_hf_render_info_destroy (GnmPrintHFRenderInfo *hfi);
155 
156 
157 GtkUnit     unit_name_to_unit    (char const *name);
158 char const *unit_to_unit_name (GtkUnit unit);
159 
160 void        print_init               (void);
161 void        print_shutdown           (void);
162 
163 gboolean    page_setup_set_paper (GtkPageSetup *page_setup, char const *paper);
164 char	   *page_setup_get_paper (GtkPageSetup *page_setup); /* caller frees result */
165 gboolean    print_info_set_paper (GnmPrintInformation *pi, char const *paper);
166 char       *print_info_get_paper (GnmPrintInformation *pi); /* caller frees result */
167 GtkPaperSize *print_info_get_paper_size (GnmPrintInformation *pi);
168 
169 void	    print_info_set_paper_orientation   (GnmPrintInformation *pi,
170 						GtkPageOrientation orientation);
171 char const *print_info_get_paper_display_name (GnmPrintInformation *pi);
172 
173 double      print_info_get_paper_width     (GnmPrintInformation *pi, GtkUnit unit);
174 double      print_info_get_paper_height    (GnmPrintInformation *pi, GtkUnit unit);
175 GtkPageOrientation print_info_get_paper_orientation   (GnmPrintInformation *pi);
176 void        print_info_get_margins   (GnmPrintInformation *pi,
177 				      double *top, double *bottom,
178 				      double *left, double *right,
179 				      double *edge_to_below_header,
180 				      double *edge_to_above_footer);
181 void        print_info_set_margins   (GnmPrintInformation *pi,
182 				      double header, double footer, double left, double right);
183 void        print_info_set_margin_header (GnmPrintInformation *pi, double header);
184 void        print_info_set_margin_footer (GnmPrintInformation *pi, double footer);
185 void        print_info_set_margin_left   (GnmPrintInformation *pi, double left);
186 void        print_info_set_margin_right  (GnmPrintInformation *pi, double right);
187 void        print_info_set_edge_to_above_footer (GnmPrintInformation *pi,
188 						 double e_f);
189 void        print_info_set_edge_to_below_header (GnmPrintInformation *pi,
190 						 double e_h);
191 void        print_info_set_printtofile_uri (GnmPrintInformation *pi,
192 					gchar const *uri);
193 void        print_info_set_printtofile_from_settings
194                                (GnmPrintInformation *pi,
195 				GtkPrintSettings *settings,
196 				gchar const *default_uri);
197 void        print_info_set_from_settings
198                                (GnmPrintInformation *pi,
199 				GtkPrintSettings *settings);
200 char const *print_info_get_printtofile_uri (GnmPrintInformation *pi);
201 PrintRange  print_info_get_printrange (GnmPrintInformation *pi);
202 void        print_info_set_printrange (GnmPrintInformation *pi, PrintRange pr);
203 
204 void        print_info_set_breaks (GnmPrintInformation *pi, GnmPageBreaks *breaks);
205 
206 gboolean        print_info_has_manual_breaks (GnmPrintInformation *pi);
207 
208 GType            gnm_page_breaks_get_type       (void);
209 GnmPageBreaks	*gnm_page_breaks_new		(gboolean is_vert);
210 GnmPageBreaks	*gnm_page_breaks_dup		(GnmPageBreaks const *src);
211 void		 gnm_page_breaks_free		(GnmPageBreaks *breaks);
212 void		 gnm_page_breaks_clean		(GnmPageBreaks *breaks);
213 gboolean	 gnm_page_breaks_append_break	(GnmPageBreaks *breaks,
214 						 int pos,
215 						 GnmPageBreakType type);
216 gboolean	 gnm_page_breaks_set_break	(GnmPageBreaks *breaks,
217 						 int pos,
218 						 GnmPageBreakType type);
219 GnmPageBreakType gnm_page_breaks_get_break      (GnmPageBreaks *breaks, int pos);
220 int              gnm_page_breaks_get_next_manual_break  (GnmPageBreaks *breaks, int pos);
221 int              gnm_page_breaks_get_next_break  (GnmPageBreaks *breaks, int pos);
222 GnmPageBreaks *  gnm_page_breaks_dup_non_auto_breaks (GnmPageBreaks const *src);
223 
224 gboolean         print_load_repeat_range (char const *str, GnmRange *r, Sheet const *sheet);
225 
226 
227 
228 /* Formats known */
229 extern GList *gnm_print_hf_formats;
230 
231 G_END_DECLS
232 
233 #endif /* _GNM_PRINT_INFO_H_ */
234