[gnumeric] Import/ Export some print formatting settings from/to ODF.



commit 44f0c23e268989c8b357cd76c13420170d9aed2d
Author: Andreas J Guelzow <aguelzow pyrshep ca>
Date:   Tue Jun 21 16:39:11 2011 -0600

    Import/ Export some print formatting settings from/to ODF.
    
    2011-06-21  Andreas J. Guelzow <aguelzow pyrshep ca>
    
    	* openoffice-read.c (odf_page_layout_properties): handle
    	style:table-centering
    	* openoffice-write.c (odf_write_page_layout) write
    	style:table-centering

 NEWS                                  |    1 +
 plugins/openoffice/ChangeLog          |    7 +++++++
 plugins/openoffice/openoffice-read.c  |   14 ++++++++++++++
 plugins/openoffice/openoffice-write.c |   10 ++++++++++
 4 files changed, 32 insertions(+), 0 deletions(-)
---
diff --git a/NEWS b/NEWS
index f3dcabe..1a7f96b 100644
--- a/NEWS
+++ b/NEWS
@@ -4,6 +4,7 @@ Andreas:
 	* Fix some style import from ODF. [#652492]
 	* Import/Export header and footer from/to ODF.
 	* Import/ Export margins from/to ODF.
+	* Import/ Export some print formatting settings from/to ODF.
 
 Morten:
 	* Fix --with-gnome compilation:  [#652802]
diff --git a/plugins/openoffice/ChangeLog b/plugins/openoffice/ChangeLog
index bd8ff79..b4caa72 100644
--- a/plugins/openoffice/ChangeLog
+++ b/plugins/openoffice/ChangeLog
@@ -1,5 +1,12 @@
 2011-06-21  Andreas J. Guelzow <aguelzow pyrshep ca>
 
+	* openoffice-read.c (odf_page_layout_properties): handle
+	style:table-centering
+	* openoffice-write.c (odf_write_page_layout) write
+	style:table-centering
+
+2011-06-21  Andreas J. Guelzow <aguelzow pyrshep ca>
+
 	* openoffice-read.c (odf_get_paper_size): new
 	(odf_page_layout_properties): new
 	(odf_page_layout): new
diff --git a/plugins/openoffice/openoffice-read.c b/plugins/openoffice/openoffice-read.c
index cdb98f5..7363582 100644
--- a/plugins/openoffice/openoffice-read.c
+++ b/plugins/openoffice/openoffice-read.c
@@ -4306,10 +4306,19 @@ odf_get_paper_size (gnm_float width, gnm_float height)
 static void
 odf_page_layout_properties (GsfXMLIn *xin, xmlChar const **attrs)
 {
+	static OOEnum const centre_type [] = {
+		{"none"        , 0},
+		{"horizontal"  , 1},
+		{"vertical"    , 2},
+		{"both"        , 1|2},
+		{NULL          , 0},
+	};
+
 	OOParseState *state = (OOParseState *)xin->user_state;
 	gnm_float pts, height, width;
 	gboolean h_set = FALSE, w_set = FALSE;
 	GtkPageSetup *gps;
+	gint tmp;
 
 	if (state->cur_pi == NULL)
 		return;
@@ -4328,6 +4337,11 @@ odf_page_layout_properties (GsfXMLIn *xin, xmlChar const **attrs)
 			h_set = TRUE;
 		else if (oo_attr_distance (xin, attrs, OO_NS_FO, "page-width", &width))
 			w_set = TRUE;
+		else if (oo_attr_enum (xin, attrs, OO_NS_STYLE, "table-centering",
+				       centre_type, &tmp)) {
+			state->cur_pi->center_horizontally = ((1 & tmp) != 0);
+			state->cur_pi->center_vertically = ((2 & tmp) != 0);
+		}
 	
 	if (h_set && w_set) {
 		GtkPaperSize *size;
diff --git a/plugins/openoffice/openoffice-write.c b/plugins/openoffice/openoffice-write.c
index c21429b..2fe8e99 100644
--- a/plugins/openoffice/openoffice-write.c
+++ b/plugins/openoffice/openoffice-write.c
@@ -4757,8 +4757,16 @@ odf_write_office_styles (GnmOOExport *state)
 static void
 odf_write_page_layout (GnmOOExport *state, PrintInformation *pi)
 {
+	static char const *centre_type [] = {
+		"none"        ,
+		"horizontal"  ,
+		"vertical"    ,
+		"both"        ,
+		NULL          };
+
 	char *name =  page_layout_name (pi);
 	GtkPageSetup *gps = print_info_get_page_setup (pi);
+	int i;
 
 	gsf_xml_out_start_element (state->xml, STYLE "page-layout");
 	gsf_xml_out_add_cstr_unchecked (state->xml, STYLE "name", name);
@@ -4778,6 +4786,8 @@ odf_write_page_layout (GnmOOExport *state, PrintInformation *pi)
 		    gtk_page_setup_get_paper_width (gps, GTK_UNIT_POINTS));
 	odf_add_pt (state->xml, FOSTYLE "page-height",
 		    gtk_page_setup_get_paper_height (gps, GTK_UNIT_POINTS));
+	i = (pi->center_horizontally ? 1 : 0) | (pi->center_vertically ? 2 : 0);
+	gsf_xml_out_add_cstr_unchecked (state->xml, STYLE "table-centering", centre_type [i]);
 	gsf_xml_out_end_element (state->xml); /* </style:page-layout-properties> */
 
 	gsf_xml_out_end_element (state->xml); /* </style:page-layout> */



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