[gnumeric] xlsx: make window size roundtrip.



commit 2569ccd8088af806914acde677d2af2dc497b812
Author: Morten Welinder <terra gnome org>
Date:   Mon Feb 24 13:33:20 2014 -0500

    xlsx: make window size roundtrip.

 NEWS                       |    1 +
 plugins/excel/xlsx-read.c  |   25 ++++++++++++++++++++++++-
 plugins/excel/xlsx-write.c |    5 +++++
 test/t6500-strings.pl      |    3 +--
 test/t6503-page-setup.pl   |    3 +--
 test/t6504-formula.pl      |    3 +--
 6 files changed, 33 insertions(+), 7 deletions(-)
---
diff --git a/NEWS b/NEWS
index 6fc328d..f155ac4 100644
--- a/NEWS
+++ b/NEWS
@@ -34,6 +34,7 @@ Morten:
        * Fix xls import of headers and footers.  [Part of #724516]
        * Fix xlsx export of row heights.
        * Fix xlsx export of rotated styles.
+       * Make window geometry round-trip through xlsx.
 
 --------------------------------------------------------------------------
 Gnumeric 1.12.11
diff --git a/plugins/excel/xlsx-read.c b/plugins/excel/xlsx-read.c
index 25f2aa8..83189b6 100644
--- a/plugins/excel/xlsx-read.c
+++ b/plugins/excel/xlsx-read.c
@@ -3237,6 +3237,29 @@ xlsx_CT_CalcPr (GsfXMLIn *xin, xmlChar const **attrs)
 }
 
 static void
+xlsx_CT_workbookView (GsfXMLIn *xin, xmlChar const **attrs)
+{
+       XLSXReadState *state = (XLSXReadState *)xin->user_state;
+       int active_tab = -1;
+       int width = -1, height = -1;
+       const int scale = 10;  /* Guess */
+
+       for (; attrs != NULL && attrs[0] && attrs[1] ; attrs += 2) {
+               if (attr_int (xin, attrs, "activeTab", &active_tab))
+                       ;
+               else if (attr_int (xin, attrs, "windowHeight", &height))
+                       ;
+               else if (attr_int (xin, attrs, "windowWidth", &width))
+                       ;
+       }
+
+       if (width > scale / 2 && height > scale / 2)
+               wb_view_preferred_size (state->wb_view,
+                                       (width + scale / 2) / scale,
+                                       (height + scale / 2) / scale);
+}
+
+static void
 xlsx_sheet_begin (GsfXMLIn *xin, xmlChar const **attrs)
 {
        static EnumVal const visibilities[] = {
@@ -3801,7 +3824,7 @@ GSF_XML_IN_NODE_FULL (START, WORKBOOK, XL_NS_SS, "workbook", GSF_XML_NO_CONTENT,
   GSF_XML_IN_NODE (WORKBOOK, CALC_PROPS, XL_NS_SS, "calcPr", GSF_XML_NO_CONTENT, &xlsx_CT_CalcPr, NULL),
 
   GSF_XML_IN_NODE (WORKBOOK, VIEWS,     XL_NS_SS, "bookViews", GSF_XML_NO_CONTENT, NULL, NULL),
-    GSF_XML_IN_NODE (VIEWS,  VIEW,      XL_NS_SS, "workbookView",  GSF_XML_NO_CONTENT, NULL, NULL),
+    GSF_XML_IN_NODE (VIEWS,  VIEW,      XL_NS_SS, "workbookView",  GSF_XML_NO_CONTENT, 
&xlsx_CT_workbookView, NULL),
   GSF_XML_IN_NODE (WORKBOOK, CUSTOMWVIEWS, XL_NS_SS, "customWorkbookViews", GSF_XML_NO_CONTENT, NULL, NULL),
     GSF_XML_IN_NODE (CUSTOMWVIEWS, CUSTOMWVIEW , XL_NS_SS, "customWorkbookView", GSF_XML_NO_CONTENT, NULL, 
NULL),
 GSF_XML_IN_NODE (CUSTOMWVIEW, EXTLST, XL_NS_SS, "extLst", GSF_XML_NO_CONTENT, NULL, NULL), /* 2nd  */
diff --git a/plugins/excel/xlsx-write.c b/plugins/excel/xlsx-write.c
index 5449c8e..8cf3744 100644
--- a/plugins/excel/xlsx-write.c
+++ b/plugins/excel/xlsx-write.c
@@ -2545,9 +2545,14 @@ xlsx_write_workbook (XLSXWriteState *state, GsfOutfile *root_part)
 
        gsf_xml_out_start_element (xml, "bookViews");
        WORKBOOK_FOREACH_VIEW (state->base.wb, view, {
+               int scale = 10;  /* Guess */
                gsf_xml_out_start_element (xml, "workbookView");
                gsf_xml_out_add_int (xml, "activeTab",
                        view->current_sheet->index_in_wb);
+               if (view->preferred_width > 0)
+                       gsf_xml_out_add_int (xml, "windowWidth", view->preferred_width * scale);
+               if (view->preferred_height > 0)
+                       gsf_xml_out_add_int (xml, "windowHeight", view->preferred_height * scale);
                gsf_xml_out_end_element (xml);
        });
        gsf_xml_out_end_element (xml);
diff --git a/test/t6500-strings.pl b/test/t6500-strings.pl
index 196dcb3..236beb9 100755
--- a/test/t6500-strings.pl
+++ b/test/t6500-strings.pl
@@ -39,5 +39,4 @@ my $xls_greek_filter = "$PERL -p -C7 -e '1 while (s{\\b(ValueType=\"60\">Greek[
 &test_roundtrip ($file,
                 'format' => 'Gnumeric_Excel:xlsx',
                 'ext' => "xlsx",
-                'resize' => '1048576x16384',
-                'ignore_failure' => 1);
+                'resize' => '1048576x16384');
diff --git a/test/t6503-page-setup.pl b/test/t6503-page-setup.pl
index 3fa9039..a82a4ed 100755
--- a/test/t6503-page-setup.pl
+++ b/test/t6503-page-setup.pl
@@ -37,5 +37,4 @@ my $xls_codepage_filter = "$PERL -p -e '\$_ = \"\" if m{<meta:user-defined meta:
 &test_roundtrip ($file,
                 'format' => 'Gnumeric_Excel:xlsx',
                 'ext' => "xlsx",
-                'resize' => '1048576x16384',
-                'ignore_failure' => 1);
+                'resize' => '1048576x16384');
diff --git a/test/t6504-formula.pl b/test/t6504-formula.pl
index 3edb922..2ce68c2 100755
--- a/test/t6504-formula.pl
+++ b/test/t6504-formula.pl
@@ -37,5 +37,4 @@ my $xls_codepage_filter = "$PERL -p -e '\$_ = \"\" if m{<meta:user-defined meta:
 &test_roundtrip ($file,
                 'format' => 'Gnumeric_Excel:xlsx',
                 'ext' => "xlsx",
-                'resize' => '1048576x16384',
-                'ignore_failure' => 1);
+                'resize' => '1048576x16384');


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