[gnumeric] read more pagesetup settings from xlsx
- From: Andreas J. Guelzow <guelzow src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnumeric] read more pagesetup settings from xlsx
- Date: Thu, 13 Jun 2013 04:16:57 +0000 (UTC)
commit ab800ac612be9ef9cc6f179385740b8081410a26
Author: Andreas J Guelzow <aguelzow pyrshep ca>
Date: Wed Jun 12 22:15:53 2013 -0600
read more pagesetup settings from xlsx
2013-06-12 Andreas J. Guelzow <aguelzow pyrshep ca>
* xlsx-write.c (xlsx_write_print_info): fix typo
* xlsx-read.c (xlsx_sheet_page_setup): read more attributes
(xlsx_CT_PageSetup): read more attributes
plugins/excel/ChangeLog | 6 ++++
plugins/excel/xlsx-read.c | 68 +++++++++++++++++++++++++++++++++++++++----
plugins/excel/xlsx-write.c | 2 +-
3 files changed, 68 insertions(+), 8 deletions(-)
---
diff --git a/plugins/excel/ChangeLog b/plugins/excel/ChangeLog
index 540b65e..55acc9e 100644
--- a/plugins/excel/ChangeLog
+++ b/plugins/excel/ChangeLog
@@ -1,5 +1,11 @@
2013-06-12 Andreas J. Guelzow <aguelzow pyrshep ca>
+ * xlsx-write.c (xlsx_write_print_info): fix typo
+ * xlsx-read.c (xlsx_sheet_page_setup): read more attributes
+ (xlsx_CT_PageSetup): read more attributes
+
+2013-06-12 Andreas J. Guelzow <aguelzow pyrshep ca>
+
* xlsx-write.c (xlsx_write_print_info): always write fitTo*
(xlsx_write_sheet): write pageSetUpPr
diff --git a/plugins/excel/xlsx-read.c b/plugins/excel/xlsx-read.c
index 7a4b3a0..af557fd 100644
--- a/plugins/excel/xlsx-read.c
+++ b/plugins/excel/xlsx-read.c
@@ -1636,7 +1636,16 @@ xlsx_sheet_tabcolor (GsfXMLIn *xin, xmlChar const **attrs)
static void
xlsx_sheet_page_setup (G_GNUC_UNUSED GsfXMLIn *xin, G_GNUC_UNUSED xmlChar const **attrs)
{
- /* XLSXReadState *state = (XLSXReadState *)xin->user_state; */
+ XLSXReadState *state = (XLSXReadState *)xin->user_state;
+ PrintInformation *pi = state->sheet->print_info;
+ gboolean tmp;
+
+ if (pi->page_setup == NULL)
+ print_info_load_defaults (pi);
+
+ for (; attrs != NULL && attrs[0] && attrs[1] ; attrs += 2)
+ if (attr_bool (xin, attrs, "fitToPage", &tmp))
+ pi->scaling.type = tmp ? PRINT_SCALE_FIT_PAGES : PRINT_SCALE_PERCENTAGE;
}
static void
@@ -1830,31 +1839,76 @@ xlsx_CT_PageSetup (GsfXMLIn *xin, xmlChar const **attrs)
{
XLSXReadState *state = (XLSXReadState *)xin->user_state;
PrintInformation *pi = state->sheet->print_info;
- int orient, paper_code = 0;
- gboolean orient_set = FALSE;
+ int orient, paper_code = 0, scale, tmp_int;
+ gboolean orient_set = FALSE, first_page_number = TRUE, tmp_bool;
gnm_float width = 0., height = 0.;
- static EnumVal const types[] = {
+ static EnumVal const orientation_types[] = {
{ "default", GTK_PAGE_ORIENTATION_PORTRAIT },
{ "portrait", GTK_PAGE_ORIENTATION_PORTRAIT },
{ "landscape", GTK_PAGE_ORIENTATION_LANDSCAPE },
{ NULL, 0 }
};
+ static EnumVal const comment_types[] = {
+ { "asDisplayed", GNM_PRINT_COMMENTS_IN_PLACE },
+ { "atEnd", GNM_PRINT_COMMENTS_AT_END },
+ { "none", GNM_PRINT_COMMENTS_NONE },
+ { NULL, 0 }
+ };
+ static EnumVal const error_types[] = {
+ { "blank", GNM_PRINT_ERRORS_AS_BLANK },
+ { "dash", GNM_PRINT_ERRORS_AS_DASHES },
+ { "NA", GNM_PRINT_ERRORS_AS_NA },
+ { "displayed", GNM_PRINT_ERRORS_AS_DISPLAYED },
+ { NULL, 0 }
+ };
+ static EnumVal const page_order_types[] = {
+ { "overThenDown", 1 },
+ { "downThenOver", 0 },
+ { NULL, 0 }
+ };
if (pi->page_setup == NULL)
print_info_load_defaults (pi);
for (; attrs != NULL && attrs[0] && attrs[1] ; attrs += 2)
- if (attr_enum (xin, attrs, "orientation", types, &orient))
+ if (attr_enum (xin, attrs, "orientation", orientation_types, &orient))
orient_set = TRUE;
+ else if (attr_enum (xin, attrs, "cellComments", comment_types, &tmp_int))
+ pi->comment_placement = tmp_int;
+ else if (attr_enum (xin, attrs, "errors", error_types, &tmp_int))
+ pi->error_display = tmp_int;
+ else if (attr_enum (xin, attrs, "pageOrder", page_order_types, &tmp_int))
+ pi->print_across_then_down = (tmp_int != 0);
else if (attr_int (xin, attrs, "paperSize", &paper_code))
;
else if (attr_distance (xin, attrs, "paperWidth", &width))
;
else if (attr_distance (xin, attrs, "paperHeight", &height))
;
- if (!xlsx_set_paper_from_code (pi, paper_code) && width > 0.0 && height > 0.0)
- gtk_page_setup_set_paper_size (pi->page_setup, xlsx_paper_size (width, height,
GTK_UNIT_POINTS, 0));
+ else if (attr_bool (xin, attrs, "blackAndWhite", &tmp_bool))
+ pi->print_black_and_white = tmp_bool;
+ else if (attr_int (xin, attrs, "copies", &(pi->n_copies)))
+ ;
+ else if (attr_bool (xin, attrs, "draft", &tmp_bool))
+ pi->print_as_draft = tmp_bool;
+ else if (attr_int (xin, attrs, "firstPageNumber", &(pi->start_page)))
+ ;
+ else if (attr_int (xin, attrs, "fitToHeight", &(pi->scaling.dim.rows)))
+ ;
+ else if (attr_int (xin, attrs, "fitToWidth", &(pi->scaling.dim.cols)))
+ ;
+ else if (attr_int (xin, attrs, "scale", &scale)) {
+ pi->scaling.percentage.x = scale;
+ pi->scaling.percentage.y = scale;
+ } else if (attr_bool (xin, attrs, "useFirstPageNumber", &first_page_number))
+ ;
+ if (!first_page_number)
+ pi->start_page = -1;
+
+ if (!xlsx_set_paper_from_code (pi, paper_code) && width > 0.0 && height > 0.0)
+ gtk_page_setup_set_paper_size (pi->page_setup,
+ xlsx_paper_size (width, height, GTK_UNIT_POINTS, 0));
if (orient_set)
print_info_set_paper_orientation (pi, orient);
}
diff --git a/plugins/excel/xlsx-write.c b/plugins/excel/xlsx-write.c
index 61d266c..2d8a7b8 100644
--- a/plugins/excel/xlsx-write.c
+++ b/plugins/excel/xlsx-write.c
@@ -1981,7 +1981,7 @@ xlsx_write_print_info (XLSXWriteState *state, GsfXMLOut *xml)
xlsx_add_bool (xml, "blackAndWhite", pi->print_black_and_white);
switch (pi->comment_placement) {
case GNM_PRINT_COMMENTS_IN_PLACE:
- gsf_xml_out_add_cstr_unchecked (xml, "cellComments", "asDisplayed ");
+ gsf_xml_out_add_cstr_unchecked (xml, "cellComments", "asDisplayed");
break;
case GNM_PRINT_COMMENTS_AT_END:
gsf_xml_out_add_cstr_unchecked (xml, "cellComments", "atEnd");
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]