[gnumeric] ODF export: write header and footer geometry



commit 28dce7596c7b0ad3ed852914f4e9b5d64f20d9d3
Author: Andreas J Guelzow <aguelzow pyrshep ca>
Date:   Wed Jun 22 01:07:15 2011 -0600

    ODF export: write header and footer geometry
    
    2011-06-22  Andreas J. Guelzow <aguelzow pyrshep ca>
    
    	* openoffice-write.c (df_write_hf) change arguments and change all
    	callers, allow for hidden headers/footers
    	(odf_write_hf_style): new
    	(odf_write_page_layout): call odf_write_hf_style

 plugins/openoffice/ChangeLog          |    7 ++++
 plugins/openoffice/openoffice-write.c |   61 ++++++++++++++++++++++++++++++--
 2 files changed, 64 insertions(+), 4 deletions(-)
---
diff --git a/plugins/openoffice/ChangeLog b/plugins/openoffice/ChangeLog
index f0e37d1..0ffa5b8 100644
--- a/plugins/openoffice/ChangeLog
+++ b/plugins/openoffice/ChangeLog
@@ -1,3 +1,10 @@
+2011-06-22  Andreas J. Guelzow <aguelzow pyrshep ca>
+
+	* openoffice-write.c (df_write_hf) change arguments and change all
+	callers, allow for hidden headers/footers
+	(odf_write_hf_style): new
+	(odf_write_page_layout): call odf_write_hf_style
+
 2011-06-21  Andreas J. Guelzow <aguelzow pyrshep ca>
 
 	* openoffice-read.c (odf_page_layout_properties): read style:print and
diff --git a/plugins/openoffice/openoffice-write.c b/plugins/openoffice/openoffice-write.c
index dca3b44..2561abf 100644
--- a/plugins/openoffice/openoffice-write.c
+++ b/plugins/openoffice/openoffice-write.c
@@ -4695,13 +4695,27 @@ odf_write_hf_region (GnmOOExport *state, char const *format, char const *id)
 }
 
 static void
-odf_write_hf (GnmOOExport *state, PrintHF *hf, char const *id)
+odf_write_hf (GnmOOExport *state, PrintInformation *pi, char const *id, gboolean header)
 {
+	PrintHF *hf = header ? pi->header : pi->footer;
+	double page_margin;
+	double hf_height;
+	GtkPageSetup *gps = print_info_get_page_setup (pi);
+
 	if (hf == NULL)
 		return;
 
+	if (header) {
+		page_margin = gtk_page_setup_get_top_margin (gps, GTK_UNIT_POINTS);
+		hf_height = pi->edge_to_below_header - page_margin;
+	} else {
+		page_margin = gtk_page_setup_get_bottom_margin (gps, GTK_UNIT_POINTS);
+		hf_height = pi->edge_to_above_footer - page_margin;
+	}
+
 	gsf_xml_out_start_element (state->xml, id);
-	odf_add_bool (state->xml, STYLE "display", TRUE);
+	odf_add_bool (state->xml, STYLE "display", hf_height > 0.);
+
 	odf_write_hf_region (state, hf->left_format, STYLE "region-left");
 	odf_write_hf_region (state, hf->middle_format, STYLE "region-center");
 	odf_write_hf_region (state, hf->right_format, STYLE "region-right");
@@ -4755,6 +4769,41 @@ odf_write_office_styles (GnmOOExport *state)
 }
 
 static void
+odf_write_hf_style (GnmOOExport *state, PrintInformation *pi, char const *id, gboolean header)
+{
+	PrintHF *hf = header ? pi->header : pi->footer;
+	double page_margin;
+	double hf_height;
+	GtkPageSetup *gps = print_info_get_page_setup (pi);
+
+	if (hf == NULL)
+		return;
+
+	if (header) {
+		page_margin = gtk_page_setup_get_top_margin (gps, GTK_UNIT_POINTS);
+		hf_height = pi->edge_to_below_header - page_margin;
+	} else {
+		page_margin = gtk_page_setup_get_bottom_margin (gps, GTK_UNIT_POINTS);
+		hf_height = pi->edge_to_above_footer - page_margin;
+	}
+
+	gsf_xml_out_start_element (state->xml, id);
+	gsf_xml_out_start_element (state->xml, STYLE "header-footer-properties");
+
+	gsf_xml_out_add_cstr_unchecked (state->xml, FOSTYLE "border", "none");
+	gsf_xml_out_add_cstr_unchecked (state->xml, STYLE "shadow", "none");
+	odf_add_pt (state->xml, FOSTYLE "padding", 0.0);
+	odf_add_pt (state->xml, FOSTYLE "margin", 0.0);
+	odf_add_pt (state->xml, FOSTYLE "min-height", hf_height);
+	odf_add_pt (state->xml, SVG "height", hf_height);
+	odf_add_bool (state->xml, STYLE "dynamic-spacing", TRUE);
+
+	gsf_xml_out_end_element (state->xml); /* header-footer-properties */
+	gsf_xml_out_end_element (state->xml); /* id */
+}
+
+
+static void
 odf_write_page_layout (GnmOOExport *state, PrintInformation *pi,
 		       Sheet const *sheet)
 {
@@ -4847,6 +4896,10 @@ odf_write_page_layout (GnmOOExport *state, PrintInformation *pi,
 	
 	gsf_xml_out_end_element (state->xml); /* </style:page-layout-properties> */
 
+	odf_write_hf_style (state, pi, STYLE "header-style", FALSE);
+	odf_write_hf_style (state, pi, STYLE "footer-style", FALSE);
+
+
 	gsf_xml_out_end_element (state->xml); /* </style:page-layout> */
 }
 
@@ -4883,8 +4936,8 @@ odf_write_master_styles (GnmOOExport *state)
 		gsf_xml_out_add_cstr_unchecked (state->xml, STYLE "page-layout-name", 
 						name);
 
-		odf_write_hf (state, sheet->print_info->header, STYLE "header");
-		odf_write_hf (state, sheet->print_info->footer, STYLE "footer");
+		odf_write_hf (state, sheet->print_info, STYLE "header", TRUE);
+		odf_write_hf (state, sheet->print_info, STYLE "footer", FALSE);
 		
 		gsf_xml_out_end_element (state->xml); /* </master-page> */
 		g_free (mp_name);



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]