[gnumeric] Write pagesetup orientation to xlsx. [#701834]



commit fdafe3e22bcc9ca2c8bd5e613fb9881c3369a5ef
Author: Andreas J Guelzow <aguelzow pyrshep ca>
Date:   Mon Jun 10 08:41:19 2013 -0600

    Write pagesetup orientation to xlsx. [#701834]
    
    2013-06-10  Andreas J. Guelzow <aguelzow pyrshep ca>
    
        * xlsx-read.c (xlsx_CT_PageSetup): new
        * xlsx-write.c (xlsx_write_print_info): write orientation

 NEWS                       |    1 +
 plugins/excel/ChangeLog    |    5 +++++
 plugins/excel/xlsx-read.c  |   21 ++++++++++++++++++++-
 plugins/excel/xlsx-write.c |   18 ++++++++++++++++++
 4 files changed, 44 insertions(+), 1 deletions(-)
---
diff --git a/NEWS b/NEWS
index d4e7aef..5936345 100644
--- a/NEWS
+++ b/NEWS
@@ -17,6 +17,7 @@ Andreas:
        * Adjust cell comment display. [#698519]
        * Make reference display in paste/define names dialog consistent with
          sheet preferences. [Debian #699054]
+       * Write pagesetup orientation to xlsx. [#701834]
 
 Darrell Tangman:
        * Update documentation for Edit and Insert menus. [#700596]
diff --git a/plugins/excel/ChangeLog b/plugins/excel/ChangeLog
index cf65475..2ec3917 100644
--- a/plugins/excel/ChangeLog
+++ b/plugins/excel/ChangeLog
@@ -1,3 +1,8 @@
+2013-06-10  Andreas J. Guelzow <aguelzow pyrshep ca>
+
+       * xlsx-read.c (xlsx_CT_PageSetup): new
+       * xlsx-write.c (xlsx_write_print_info): write orientation
+
 2013-06-05  Morten Welinder  <terra gnome org>
 
        * ms-excel-write.c (excel_write_HLINKs): Don't remove hlinks here.
diff --git a/plugins/excel/xlsx-read.c b/plugins/excel/xlsx-read.c
index b64a473..69de994 100644
--- a/plugins/excel/xlsx-read.c
+++ b/plugins/excel/xlsx-read.c
@@ -1584,6 +1584,25 @@ xlsx_CT_SheetFormatPr (GsfXMLIn *xin, xmlChar const **attrs)
 }
 
 static void
+xlsx_CT_PageSetup (GsfXMLIn *xin, xmlChar const **attrs)
+{
+       XLSXReadState *state = (XLSXReadState *)xin->user_state;
+       PrintInformation *pi = state->sheet->print_info;
+       int tmp;
+       static EnumVal const types[] = {
+               { "default",    GTK_PAGE_ORIENTATION_PORTRAIT },
+               { "portrait",   GTK_PAGE_ORIENTATION_PORTRAIT },
+               { "landscape",  GTK_PAGE_ORIENTATION_LANDSCAPE },
+               { NULL, 0 }
+       };
+
+       if (pi->page_setup != NULL)
+               for (; attrs != NULL && attrs[0] && attrs[1] ; attrs += 2)
+                       if (attr_enum (xin, attrs, "orientation", types, &tmp))
+                               gtk_page_setup_set_orientation (pi->page_setup, tmp);
+}
+
+static void
 xlsx_CT_PageMargins (GsfXMLIn *xin, xmlChar const **attrs)
 {
        XLSXReadState *state = (XLSXReadState *)xin->user_state;
@@ -2769,7 +2788,7 @@ GSF_XML_IN_NODE_FULL (START, SHEET, XL_NS_SS, "worksheet", GSF_XML_NO_CONTENT, F
 
   GSF_XML_IN_NODE (SHEET, PRINT_OPTS, XL_NS_SS, "printOptions", GSF_XML_NO_CONTENT, NULL, NULL),
   GSF_XML_IN_NODE (SHEET, PRINT_MARGINS, XL_NS_SS, "pageMargins", GSF_XML_NO_CONTENT, &xlsx_CT_PageMargins, 
NULL),
-  GSF_XML_IN_NODE (SHEET, PRINT_SETUP, XL_NS_SS, "pageSetup", GSF_XML_NO_CONTENT, NULL, NULL),
+  GSF_XML_IN_NODE (SHEET, PRINT_SETUP, XL_NS_SS, "pageSetup", GSF_XML_NO_CONTENT, &xlsx_CT_PageSetup, NULL),
   GSF_XML_IN_NODE (SHEET, PRINT_HEADER_FOOTER, XL_NS_SS, "headerFooter", GSF_XML_NO_CONTENT, NULL, NULL),
     GSF_XML_IN_NODE (PRINT_HEADER_FOOTER, ODD_HEADER, XL_NS_SS, "oddHeader", GSF_XML_NO_CONTENT, NULL, NULL),
     GSF_XML_IN_NODE (PRINT_HEADER_FOOTER, ODD_FOOTER, XL_NS_SS, "oddFooter", GSF_XML_NO_CONTENT, NULL, NULL),
diff --git a/plugins/excel/xlsx-write.c b/plugins/excel/xlsx-write.c
index c7a791b..99e1604 100644
--- a/plugins/excel/xlsx-write.c
+++ b/plugins/excel/xlsx-write.c
@@ -1803,6 +1803,24 @@ xlsx_write_print_info (XLSXWriteState *state, GsfXMLOut *xml)
        gsf_xml_out_end_element (xml); /* </pageMargins> */
 
        gsf_xml_out_start_element (xml, "pageSetup");
+       if (pi->page_setup) {
+               GtkPageOrientation orient;
+               orient = gtk_page_setup_get_orientation (pi->page_setup);
+               switch (orient) {
+               case GTK_PAGE_ORIENTATION_PORTRAIT:
+               case GTK_PAGE_ORIENTATION_REVERSE_PORTRAIT:
+                       gsf_xml_out_add_cstr_unchecked (xml, "orientation", "portrait");
+                       break;
+               case GTK_PAGE_ORIENTATION_LANDSCAPE:
+               case GTK_PAGE_ORIENTATION_REVERSE_LANDSCAPE:
+                       gsf_xml_out_add_cstr_unchecked (xml, "orientation", "landscape");
+                       break;
+               default:
+                       gsf_xml_out_add_cstr_unchecked (xml, "orientation", "default");
+                       break;
+               }
+       } else
+               gsf_xml_out_add_cstr_unchecked (xml, "orientation", "default");
        gsf_xml_out_end_element (xml); /* </pageSetup> */
 
        if (NULL != pi->page_breaks.v)


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