[gnumeric] Import/Export some more print formatting settings from/to ODF
- From: Andreas J. Guelzow <guelzow src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnumeric] Import/Export some more print formatting settings from/to ODF
- Date: Wed, 22 Jun 2011 02:23:41 +0000 (UTC)
commit 270ef013189642f543315267fee605852de13b0b
Author: Andreas J Guelzow <aguelzow pyrshep ca>
Date: Tue Jun 21 20:22:23 2011 -0600
Import/Export some more print formatting settings from/to ODF
2011-06-21 Andreas J. Guelzow <aguelzow pyrshep ca>
* openoffice-read.c (odf_get_paper_size): consider orientation
(odf_page_layout_properties): read style:print-page-order and
style:print-orientation
* openoffice-write.c (odf_write_page_layout) write
style:print-page-order, style:writing-mode and style:print-orientation
NEWS | 4 +-
plugins/openoffice/ChangeLog | 8 +++++++
plugins/openoffice/openoffice-read.c | 37 +++++++++++++++++++++++++++++---
plugins/openoffice/openoffice-write.c | 21 ++++++++++++++++--
4 files changed, 61 insertions(+), 9 deletions(-)
---
diff --git a/NEWS b/NEWS
index 1a7f96b..62c0c2a 100644
--- a/NEWS
+++ b/NEWS
@@ -3,8 +3,8 @@ Gnumeric 1.10.17
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.
+ * 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 b4caa72..214ef36 100644
--- a/plugins/openoffice/ChangeLog
+++ b/plugins/openoffice/ChangeLog
@@ -1,5 +1,13 @@
2011-06-21 Andreas J. Guelzow <aguelzow pyrshep ca>
+ * openoffice-read.c (odf_get_paper_size): consider orientation
+ (odf_page_layout_properties): read style:print-page-order and
+ style:print-orientation
+ * openoffice-write.c (odf_write_page_layout) write
+ style:print-page-order, style:writing-mode and style:print-orientation
+
+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
diff --git a/plugins/openoffice/openoffice-read.c b/plugins/openoffice/openoffice-read.c
index 7363582..bb94045 100644
--- a/plugins/openoffice/openoffice-read.c
+++ b/plugins/openoffice/openoffice-read.c
@@ -4271,7 +4271,7 @@ odf_number_style_end (GsfXMLIn *xin, G_GNUC_UNUSED GsfXMLBlob *blob)
/*****************************************************************************************************/
static GtkPaperSize *
-odf_get_paper_size (gnm_float width, gnm_float height)
+odf_get_paper_size (gnm_float width, gnm_float height, gint orient)
{
GtkPaperSize *size = NULL;
char *name, *display_name;
@@ -4282,8 +4282,17 @@ odf_get_paper_size (gnm_float width, gnm_float height)
GtkPaperSize *n_size = l->data;
double n_width = gtk_paper_size_get_width (n_size, GTK_UNIT_POINTS);
double n_height = gtk_paper_size_get_height (n_size, GTK_UNIT_POINTS);
- double w_diff = n_width - width;
- double h_diff = n_height - height;
+ double w_diff;
+ double h_diff;
+
+ if (orient == GTK_PAGE_ORIENTATION_PORTRAIT ||
+ orient == GTK_PAGE_ORIENTATION_REVERSE_PORTRAIT) {
+ w_diff = n_width - width;
+ h_diff = n_height - height;
+ } else {
+ w_diff = n_height - width;
+ h_diff = n_width - height;
+ }
if (w_diff > -2. && w_diff < 2. && h_diff > -2 && h_diff < 2) {
size = gtk_paper_size_copy (n_size);
@@ -4313,16 +4322,28 @@ odf_page_layout_properties (GsfXMLIn *xin, xmlChar const **attrs)
{"both" , 1|2},
{NULL , 0},
};
+ static OOEnum const print_order_type [] = {
+ {"ltr" , 0},
+ {"ttb" , 1},
+ {NULL , 0},
+ };
+ static OOEnum const print_orientation_type [] = {
+ {"portrait" , GTK_PAGE_ORIENTATION_PORTRAIT},
+ {"landscape" , GTK_PAGE_ORIENTATION_LANDSCAPE},
+ {NULL , 0},
+ };
OOParseState *state = (OOParseState *)xin->user_state;
gnm_float pts, height, width;
gboolean h_set = FALSE, w_set = FALSE;
GtkPageSetup *gps;
gint tmp;
+ gint orient = GTK_PAGE_ORIENTATION_PORTRAIT;
if (state->cur_pi == NULL)
return;
gps = print_info_get_page_setup (state->cur_pi);
+ gtk_page_setup_set_orientation (gps, GTK_PAGE_ORIENTATION_PORTRAIT);
for (; attrs != NULL && attrs[0] && attrs[1] ; attrs += 2)
if (oo_attr_distance (xin, attrs, OO_NS_FO, "margin-left", &pts))
@@ -4341,13 +4362,21 @@ odf_page_layout_properties (GsfXMLIn *xin, xmlChar const **attrs)
centre_type, &tmp)) {
state->cur_pi->center_horizontally = ((1 & tmp) != 0);
state->cur_pi->center_vertically = ((2 & tmp) != 0);
+ } else if (oo_attr_enum (xin, attrs, OO_NS_STYLE, "print-page-order",
+ print_order_type, &tmp)) {
+ state->cur_pi->print_across_then_down = (tmp == 0);
+ } else if (oo_attr_enum (xin, attrs, OO_NS_STYLE, "print-orientation",
+ print_orientation_type, &orient)) {
+ gtk_page_setup_set_orientation (gps, orient);
}
+ /* STYLE "writing-mode" is being ignored since we can't store it anywhere atm */
if (h_set && w_set) {
GtkPaperSize *size;
- size = odf_get_paper_size (width, height);
+ size = odf_get_paper_size (width, height, orient);
gtk_page_setup_set_paper_size (gps, size);
gtk_paper_size_free (size);
+
}
}
diff --git a/plugins/openoffice/openoffice-write.c b/plugins/openoffice/openoffice-write.c
index 2fe8e99..f0fd154 100644
--- a/plugins/openoffice/openoffice-write.c
+++ b/plugins/openoffice/openoffice-write.c
@@ -4755,7 +4755,8 @@ odf_write_office_styles (GnmOOExport *state)
}
static void
-odf_write_page_layout (GnmOOExport *state, PrintInformation *pi)
+odf_write_page_layout (GnmOOExport *state, PrintInformation *pi,
+ Sheet const *sheet)
{
static char const *centre_type [] = {
"none" ,
@@ -4767,6 +4768,9 @@ odf_write_page_layout (GnmOOExport *state, PrintInformation *pi)
char *name = page_layout_name (pi);
GtkPageSetup *gps = print_info_get_page_setup (pi);
int i;
+ GtkPageOrientation orient = gtk_page_setup_get_orientation (gps);
+ gboolean landscape = !(orient == GTK_PAGE_ORIENTATION_PORTRAIT ||
+ orient == GTK_PAGE_ORIENTATION_REVERSE_PORTRAIT);
gsf_xml_out_start_element (state->xml, STYLE "page-layout");
gsf_xml_out_add_cstr_unchecked (state->xml, STYLE "name", name);
@@ -4787,7 +4791,18 @@ odf_write_page_layout (GnmOOExport *state, PrintInformation *pi)
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_add_cstr_unchecked (state->xml, STYLE "table-centering",
+ centre_type [i]);
+ gsf_xml_out_add_cstr_unchecked
+ (state->xml, STYLE "print-page-order",
+ pi->print_across_then_down ? "ltr" : "ttb");
+ gsf_xml_out_add_cstr_unchecked
+ (state->xml, STYLE "writing-mode",
+ sheet->text_is_rtl ? "rl-tb" : "lr-tb");
+ gsf_xml_out_add_cstr_unchecked
+ (state->xml, STYLE "print-orientation",
+ landscape ? "landscape" : "portrait");
+
gsf_xml_out_end_element (state->xml); /* </style:page-layout-properties> */
gsf_xml_out_end_element (state->xml); /* </style:page-layout> */
@@ -4802,7 +4817,7 @@ odf_write_automatic_styles (GnmOOExport *state)
for (i = 0; i < workbook_sheet_count (state->wb); i++) {
Sheet const *sheet = workbook_sheet_by_index (state->wb, i);
- odf_write_page_layout (state, sheet->print_info);
+ odf_write_page_layout (state, sheet->print_info, sheet);
}
gsf_xml_out_end_element (state->xml); /* </office:automatic-styles> */
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]