[gnumeric] ODF import of header/footer height



commit 7563f238f81b956966a152f204e8623e47ac7bfc
Author: Andreas J Guelzow <aguelzow pyrshep ca>
Date:   Wed Jun 22 03:12:02 2011 -0600

    ODF import of header/footer height
    
    2011-06-22  Andreas J. Guelzow <aguelzow pyrshep ca>
    
    	* openoffice-read.c (odf_header_properties): new
    	(odf_footer_properties): new
    	(odf_header_footer): don't overwrite already set footer/header height
    	(styles_dtd): connect the above
    	* openoffice-write.c (odf_write_style_cell_properties): use style:repeat-content
    	(odf_write_style_paragraph_properties): HALIGN_FILL is recorded as
    	style:repeat-content

 plugins/openoffice/ChangeLog          |   10 +++++
 plugins/openoffice/openoffice-read.c  |   68 ++++++++++++++++++++++++++++++--
 plugins/openoffice/openoffice-write.c |   18 +++++----
 3 files changed, 83 insertions(+), 13 deletions(-)
---
diff --git a/plugins/openoffice/ChangeLog b/plugins/openoffice/ChangeLog
index 0ffa5b8..5038e0a 100644
--- a/plugins/openoffice/ChangeLog
+++ b/plugins/openoffice/ChangeLog
@@ -1,5 +1,15 @@
 2011-06-22  Andreas J. Guelzow <aguelzow pyrshep ca>
 
+	* openoffice-read.c (odf_header_properties): new
+	(odf_footer_properties): new
+	(odf_header_footer): don't overwrite already set footer/header height
+	(styles_dtd): connect the above
+	* openoffice-write.c (odf_write_style_cell_properties): use style:repeat-content
+	(odf_write_style_paragraph_properties): HALIGN_FILL is recorded as
+	style:repeat-content
+
+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
diff --git a/plugins/openoffice/openoffice-read.c b/plugins/openoffice/openoffice-read.c
index 27bd4bc..ee3dea7 100644
--- a/plugins/openoffice/openoffice-read.c
+++ b/plugins/openoffice/openoffice-read.c
@@ -4313,6 +4313,55 @@ odf_get_paper_size (gnm_float width, gnm_float height, gint orient)
 }
 
 static void
+odf_header_properties (GsfXMLIn *xin, xmlChar const **attrs)
+{
+	OOParseState *state = (OOParseState *)xin->user_state;
+	gboolean height_set = FALSE;
+	gnm_float pts;
+	double page_margin;
+	GtkPageSetup *gps;
+
+	if (state->cur_pi == NULL)
+		return;
+	gps = print_info_get_page_setup (state->cur_pi);
+	page_margin = gtk_page_setup_get_top_margin (gps, GTK_UNIT_POINTS);
+
+	for (; attrs != NULL && attrs[0] && attrs[1] ; attrs += 2)
+		if (oo_attr_distance (xin, attrs, OO_NS_SVG, "height", &pts)) {
+			print_info_set_edge_to_below_header (state->cur_pi, pts + page_margin);
+			height_set = TRUE;
+		} else if (oo_attr_distance (xin, attrs, OO_NS_FO, "min-height", &pts))
+			if (!height_set)
+				print_info_set_edge_to_below_header 
+					(state->cur_pi, pts + page_margin);
+}
+
+static void
+odf_footer_properties (GsfXMLIn *xin, xmlChar const **attrs)
+{
+	OOParseState *state = (OOParseState *)xin->user_state;
+	gboolean height_set = FALSE;
+	gnm_float pts;
+	double page_margin;
+	GtkPageSetup *gps;
+
+	if (state->cur_pi == NULL)
+		return;
+	gps = print_info_get_page_setup (state->cur_pi);
+	page_margin = gtk_page_setup_get_bottom_margin (gps, GTK_UNIT_POINTS);
+
+	for (; attrs != NULL && attrs[0] && attrs[1] ; attrs += 2)
+		if (oo_attr_distance (xin, attrs, OO_NS_SVG, "height", &pts)) {
+			print_info_set_edge_to_above_footer (state->cur_pi, pts + page_margin);
+			height_set = TRUE;
+		} else if (oo_attr_distance (xin, attrs, OO_NS_FO, "min-height", &pts))
+			if (!height_set)
+				print_info_set_edge_to_above_footer 
+					(state->cur_pi, pts + page_margin);
+
+}
+
+static void
 odf_page_layout_properties (GsfXMLIn *xin, xmlChar const **attrs)
 {
 	static OOEnum const centre_type [] = {
@@ -4503,11 +4552,19 @@ odf_header_footer (GsfXMLIn *xin, xmlChar const **attrs)
 	if (xin->node->user_data.v_int == 0) {
 		state->cur_hf = state->cur_pi->header;
 		margin = gtk_page_setup_get_top_margin (gps, GTK_UNIT_POINTS);
-		print_info_set_edge_to_below_header (state->cur_pi, margin + (display ? 36 : 0));
+		if (display) {
+			if (margin >= state->cur_pi->edge_to_below_header)
+				print_info_set_edge_to_below_header (state->cur_pi, margin + 1);
+		} else
+			print_info_set_edge_to_below_header (state->cur_pi, margin);
 	} else {
 		state->cur_hf = state->cur_pi->footer;
 		margin = gtk_page_setup_get_bottom_margin (gps, GTK_UNIT_POINTS);
-		print_info_set_edge_to_above_footer (state->cur_pi, margin + (display ? 36 : 0));
+		if (display) {
+			if (margin >= state->cur_pi->edge_to_above_footer)
+				print_info_set_edge_to_above_footer (state->cur_pi, margin + 1);
+		} else
+			print_info_set_edge_to_above_footer (state->cur_pi, margin);	
 	}
 	state->cur_hf_format = &state->cur_hf->middle_format;
 }
@@ -8542,10 +8599,11 @@ GSF_XML_IN_NODE (OFFICE_DOC_STYLES, AUTOMATIC_STYLES, OO_NS_OFFICE, "automatic-s
   GSF_XML_IN_NODE (AUTOMATIC_STYLES, PAGE_LAYOUT, OO_NS_STYLE, "page-layout", GSF_XML_NO_CONTENT,  &odf_page_layout, &odf_page_layout_end),
 GSF_XML_IN_NODE (PAGE_LAYOUT, PAGE_LAYOUT_PROPS, OO_NS_STYLE, "page-layout-properties", GSF_XML_NO_CONTENT, &odf_page_layout_properties, NULL),
 GSF_XML_IN_NODE (PAGE_LAYOUT, HEADER_STYLE, OO_NS_STYLE, "header-style", GSF_XML_NO_CONTENT, NULL, NULL),
-GSF_XML_IN_NODE (HEADER_STYLE, HEADER_FOOTER_PROPERTIES, OO_NS_STYLE, "header-footer-properties", GSF_XML_NO_CONTENT, NULL, NULL),
-GSF_XML_IN_NODE (HEADER_FOOTER_PROPERTIES, HF_BACK_IMAGE, OO_NS_STYLE, "background-image", GSF_XML_NO_CONTENT, NULL, NULL),
+GSF_XML_IN_NODE (HEADER_STYLE, HEADER_PROPERTIES, OO_NS_STYLE, "header-footer-properties", GSF_XML_NO_CONTENT, odf_header_properties, NULL),
+GSF_XML_IN_NODE (HEADER_PROPERTIES, HF_BACK_IMAGE, OO_NS_STYLE, "background-image", GSF_XML_NO_CONTENT, NULL, NULL),
 GSF_XML_IN_NODE (PAGE_LAYOUT, FOOTER_STYLE, OO_NS_STYLE, "footer-style", GSF_XML_NO_CONTENT, NULL, NULL),
-GSF_XML_IN_NODE (FOOTER_STYLE, HEADER_FOOTER_PROPERTIES, OO_NS_STYLE, "header-footer-properties", GSF_XML_NO_CONTENT, NULL, NULL), /* 2nd */
+GSF_XML_IN_NODE (FOOTER_STYLE, FOOTER_PROPERTIES, OO_NS_STYLE, "header-footer-properties", GSF_XML_NO_CONTENT, odf_footer_properties, NULL),
+GSF_XML_IN_NODE (FOOTER_PROPERTIES, HF_BACK_IMAGE, OO_NS_STYLE, "background-image", GSF_XML_NO_CONTENT, NULL, NULL), /* 2nd */
   GSF_XML_IN_NODE (AUTOMATIC_STYLES, NUMBER_STYLE, OO_NS_NUMBER, "number-style", GSF_XML_NO_CONTENT, NULL, NULL), /* 2nd */
   GSF_XML_IN_NODE (AUTOMATIC_STYLES, DATE_STYLE, OO_NS_NUMBER, "date-style", GSF_XML_NO_CONTENT, NULL, NULL), /* 2nd */
   GSF_XML_IN_NODE (AUTOMATIC_STYLES, TIME_STYLE, OO_NS_NUMBER, "time-style", GSF_XML_NO_CONTENT, NULL, NULL), /* 2nd */
diff --git a/plugins/openoffice/openoffice-write.c b/plugins/openoffice/openoffice-write.c
index 2561abf..828281e 100644
--- a/plugins/openoffice/openoffice-write.c
+++ b/plugins/openoffice/openoffice-write.c
@@ -1036,7 +1036,7 @@ odf_get_gnm_border_format (GnmBorder   *border)
 static void
 odf_write_style_cell_properties (GnmOOExport *state, GnmStyle const *style)
 {
-	gboolean test1, test2;
+	gboolean test1, test2, rep_content = FALSE;
 
 	gsf_xml_out_start_element (state->xml, STYLE "table-cell-properties");
 /* Background Color */
@@ -1146,9 +1146,6 @@ odf_write_style_cell_properties (GnmOOExport *state, GnmStyle const *style)
 /* Print Content */
 	odf_add_bool (state->xml,  STYLE "print-content", TRUE);
 
-/* Repeat Content */
-	odf_add_bool (state->xml,  STYLE "repeat-content", FALSE);
-
 /* Decimal Places (this is the maximum number of decimal places shown if not otherwise specified.)  */
 	/* Only interpreted in a default style. */
 	gsf_xml_out_add_int (state->xml, STYLE "decimal-places", 13);
@@ -1175,8 +1172,9 @@ odf_write_style_cell_properties (GnmOOExport *state, GnmStyle const *style)
 		case HALIGN_JUSTIFY:
 		        source = "fix";
 			break;
-		case HALIGN_GENERAL:
 		case HALIGN_FILL:
+			rep_content = TRUE;
+		case HALIGN_GENERAL:
 		case HALIGN_CENTER_ACROSS_SELECTION:
 		case HALIGN_DISTRIBUTED:
 		default:
@@ -1190,6 +1188,9 @@ odf_write_style_cell_properties (GnmOOExport *state, GnmStyle const *style)
 
 	gsf_xml_out_end_element (state->xml); /* </style:table-cell-properties */
 
+/* Repeat Content */
+	odf_add_bool (state->xml,  STYLE "repeat-content", rep_content);
+
 }
 
 static void
@@ -1221,8 +1222,9 @@ odf_write_style_paragraph_properties (GnmOOExport *state, GnmStyle const *style)
 		case HALIGN_JUSTIFY:
 			alignment = "justify";
 			break;
-		case HALIGN_GENERAL:
 		case HALIGN_FILL:
+			break;
+		case HALIGN_GENERAL:
 		case HALIGN_CENTER_ACROSS_SELECTION:
 		case HALIGN_DISTRIBUTED:
 		default:
@@ -1232,7 +1234,7 @@ odf_write_style_paragraph_properties (GnmOOExport *state, GnmStyle const *style)
 			gnum_specs = TRUE;
 			break;
 		}
-		if (align != HALIGN_GENERAL)
+		if (align != HALIGN_GENERAL && align != HALIGN_FILL)
 			gsf_xml_out_add_cstr (state->xml, FOSTYLE "text-align", alignment);
 		if (gnum_specs && state->with_extension)
 			gsf_xml_out_add_int (state->xml, GNMSTYLE "GnmHAlign", align);
@@ -4896,7 +4898,7 @@ 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 "header-style", TRUE);
 	odf_write_hf_style (state, pi, STYLE "footer-style", FALSE);
 
 



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