[gnumeric] Save and restore print file name. [#649713]



commit fa9910134a9e010ff8ae760931956eac2dc0fdc7
Author: Andreas J Guelzow <aguelzow pyrshep ca>
Date:   Mon May 9 00:55:18 2011 -0600

    Save and restore print file name. [#649713]
    
    2011-05-09  Andreas J. Guelzow <aguelzow pyrshep ca>
    
    	* gnumeric.xsd: add xs:element name="print-to-uri"
    	* src/print-info.h (print_info_set_printtofile_uri): new
    	* src/print-info.c (print_info_set_printtofile_uri): new
    	(print_info_set_printtofile_from_settings): use above
    	* src/xml-sax-read.c (xml_sax_print_to_uri): new
    	* src/xml-sax-write.c (xml_write_print_info): write print-to-uri

 ChangeLog           |    9 +++++++++
 NEWS                |    2 +-
 gnumeric.xsd        |    2 +-
 src/print-info.c    |   12 +++++++++---
 src/print-info.h    |    2 ++
 src/xml-sax-read.c  |   12 ++++++++++++
 src/xml-sax-write.c |   11 +++++++++--
 7 files changed, 43 insertions(+), 7 deletions(-)
---
diff --git a/ChangeLog b/ChangeLog
index f9ec9aa..ee5f674 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,14 @@
 2011-05-09  Andreas J. Guelzow <aguelzow pyrshep ca>
 
+	* gnumeric.xsd: add xs:element name="print-to-uri"
+	* src/print-info.h (print_info_set_printtofile_uri): new
+	* src/print-info.c (print_info_set_printtofile_uri): new
+	(print_info_set_printtofile_from_settings): use above
+	* src/xml-sax-read.c (xml_sax_print_to_uri): new
+	* src/xml-sax-write.c (xml_write_print_info): write print-to-uri
+
+2011-05-09  Andreas J. Guelzow <aguelzow pyrshep ca>
+
 	* src/print-info.h (_PrintInformation): new field printtofile_uri
 	(print_info_set_printtofile_from_settings): new
 	(print_info_get_printtofile_uri): new
diff --git a/NEWS b/NEWS
index 22409d2..a902a48 100644
--- a/NEWS
+++ b/NEWS
@@ -12,7 +12,7 @@ Andreas:
 	* Fix pdf docs. [#649591]
 	* Handle MS Works formula import. [#649406]
 	* Restore Gnumeric print range. [#649714]
-	* Set print file name. [#649711]
+	* Set default, save and restore print file name. [#649711][#649713]
 
 Morten:
 	* Fix problems with localized function docs.
diff --git a/gnumeric.xsd b/gnumeric.xsd
index c33b89c..be30e56 100644
--- a/gnumeric.xsd
+++ b/gnumeric.xsd
@@ -329,7 +329,7 @@
 	            <xs:attribute name="value" type="xs:boolean" use="required"/>
 	        </xs:complexType>
 	    </xs:element>
-
+            <xs:element name="print-to-uri" type="xs:string" minOccurs="0" maxOccurs="1"/>
             <xs:element name="vPageBreaks" type="gnm:PageBreaks" minOccurs="0" maxOccurs="1"/><!-- between rows -->
             <xs:element name="hPageBreaks" type="gnm:PageBreaks" minOccurs="0" maxOccurs="1"/><!-- between cols -->
         </xs:choice>
diff --git a/src/print-info.c b/src/print-info.c
index 2d61c87..7ebcbdc 100644
--- a/src/print-info.c
+++ b/src/print-info.c
@@ -1506,6 +1506,13 @@ gnm_page_breaks_clean (GnmPageBreaks *breaks)
 	}
 }
 
+void
+print_info_set_printtofile_uri (PrintInformation *pi, 
+				gchar const *uri)
+{
+	g_free (pi->printtofile_uri);
+	pi->printtofile_uri = g_strdup (uri);
+}
 
 void
 print_info_set_printtofile_from_settings (PrintInformation *pi, 
@@ -1515,11 +1522,10 @@ print_info_set_printtofile_from_settings (PrintInformation *pi,
 	char const *uri = gtk_print_settings_get 
 		(settings, 
 		 GTK_PRINT_SETTINGS_OUTPUT_URI);
-	g_free (pi->printtofile_uri);
 	if (strcmp (uri, default_uri) == 0)
-		pi->printtofile_uri = NULL;
+		print_info_set_printtofile_uri (pi, NULL);
 	else
-		pi->printtofile_uri = g_strdup (uri);
+		print_info_set_printtofile_uri (pi, uri);
 }
 
 char const *
diff --git a/src/print-info.h b/src/print-info.h
index 7fc0b81..c4c6c56 100644
--- a/src/print-info.h
+++ b/src/print-info.h
@@ -172,6 +172,8 @@ void        print_info_set_edge_to_above_footer (PrintInformation *pi,
 						 double e_f);
 void        print_info_set_edge_to_below_header (PrintInformation *pi,
 						 double e_h);
+void        print_info_set_printtofile_uri (PrintInformation *pi, 
+					gchar const *uri);
 void        print_info_set_printtofile_from_settings 
                                (PrintInformation *pi, 
 				GtkPrintSettings *settings,
diff --git a/src/xml-sax-read.c b/src/xml-sax-read.c
index 55de28d..765fcea 100644
--- a/src/xml-sax-read.c
+++ b/src/xml-sax-read.c
@@ -2723,6 +2723,17 @@ xml_sax_paper (GsfXMLIn *xin, G_GNUC_UNUSED GsfXMLBlob *blob)
 }
 
 static void
+xml_sax_print_to_uri (GsfXMLIn *xin, G_GNUC_UNUSED GsfXMLBlob *blob)
+{
+	XMLSaxParseState *state = (XMLSaxParseState *)xin->user_state;
+
+	xml_sax_must_have_sheet (state);
+
+	print_info_set_printtofile_uri (state->sheet->print_info, 
+					xin->content->str);
+}
+
+static void
 handle_delayed_names (XMLSaxParseState *state)
 {
 	GList *l;
@@ -2875,6 +2886,7 @@ GSF_XML_IN_NODE_FULL (START, WB, GNM, "Workbook", GSF_XML_NO_CONTENT, TRUE, TRUE
 	GSF_XML_IN_NODE_FULL (SHEET_PRINTINFO, PRINT_HEADER,	    GNM, "Header",	GSF_XML_NO_CONTENT, FALSE, FALSE, &xml_sax_print_hf, NULL, 1),
 	GSF_XML_IN_NODE (SHEET_PRINTINFO, PRINT_ORDER,	    GNM, "order",	GSF_XML_CONTENT,  NULL, &xml_sax_print_order),
 	GSF_XML_IN_NODE (SHEET_PRINTINFO, PRINT_PAPER,	    GNM, "paper",	GSF_XML_CONTENT,  NULL, &xml_sax_paper),
+	GSF_XML_IN_NODE (SHEET_PRINTINFO, PRINT_TO_URI,	    GNM, "print-to-uri",GSF_XML_CONTENT,  NULL, &xml_sax_print_to_uri),
 	GSF_XML_IN_NODE (SHEET_PRINTINFO, PRINT_ORIENT,	    GNM, "orientation",	GSF_XML_CONTENT,  NULL, &xml_sax_orientation),
 	GSF_XML_IN_NODE (SHEET_PRINTINFO, PRINT_ONLY_STYLE, GNM, "even_if_only_styles", GSF_XML_CONTENT, &xml_sax_even_if_only_styles, NULL),
 
diff --git a/src/xml-sax-write.c b/src/xml-sax-write.c
index bb47c1e..7f58497 100644
--- a/src/xml-sax-write.c
+++ b/src/xml-sax-write.c
@@ -1,4 +1,4 @@
-/* vim: set sw=8: */
+/* vim: set sw=8: -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
 
 /*
  * xml-sax-write.c : export .gnumeric and the clipboard subset using a the sax
@@ -305,6 +305,7 @@ static void
 xml_write_print_info (GnmOutputXML *state, PrintInformation *pi)
 {
 	char  *paper_name;
+	char const *uri;
 	double header;
 	double footer;
 	double left;
@@ -398,8 +399,14 @@ xml_write_print_info (GnmOutputXML *state, PrintInformation *pi)
 
 	paper_name = print_info_get_paper (pi);
 	if (paper_name)
-		gsf_xml_out_simple_element (state->output, GNM "paper", paper_name);
+		gsf_xml_out_simple_element (state->output, GNM "paper", 
+					    paper_name);
 	g_free (paper_name);
+	
+	uri = print_info_get_printtofile_uri (pi);
+	if (uri)
+		gsf_xml_out_simple_element (state->output, GNM "print-to-uri", 
+					    uri);
 
 	if (NULL != pi->page_breaks.v)
 		xml_write_breaks (state, pi->page_breaks.v);



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