aboutsummaryrefslogtreecommitdiffstats
path: root/save-xml.c
diff options
context:
space:
mode:
authorGravatar Miika Turkia <miika.turkia@gmail.com>2014-04-26 10:55:41 +0300
committerGravatar Dirk Hohndel <dirk@hohndel.org>2014-04-26 17:20:32 -0700
commitf6be4ccf226da8a8f5326ac742d2cebd83d599e9 (patch)
treea6a89c6cc77ab6735704cbe32432922f3830372a /save-xml.c
parent2b559225d6ea480e1a5023900b8498b37fadf861 (diff)
downloadsubsurface-f6be4ccf226da8a8f5326ac742d2cebd83d599e9.tar.gz
Add GUI support for exporting in CSV format
This patch adds an item to File menu to export all dives in CSV format. Naturally this includes also the code to perform the export. Fixes #434 Signed-off-by: Miika Turkia <miika.turkia@gmail.com> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Diffstat (limited to 'save-xml.c')
-rw-r--r--save-xml.c15
1 files changed, 8 insertions, 7 deletions
diff --git a/save-xml.c b/save-xml.c
index 1db2513d0..b61f79440 100644
--- a/save-xml.c
+++ b/save-xml.c
@@ -618,7 +618,7 @@ int save_dives_logic(const char *filename, const bool select_only)
return error;
}
-int export_dives_uddf(const char *filename, const bool selected)
+int export_dives_xslt(const char *filename, const bool selected, const char *export_xslt)
{
FILE *f;
struct membuffer buf = { 0 };
@@ -626,15 +626,16 @@ int export_dives_uddf(const char *filename, const bool selected)
xsltStylesheetPtr xslt = NULL;
xmlDoc *transformed;
+
if (!filename)
- return report_error("No filename for UDDF export");
+ return report_error("No filename for export");
/* Save XML to file and convert it into a memory buffer */
save_dives_buffer(&buf, selected);
/*
* Parse the memory buffer into XML document and
- * transform it to UDDF format, finally dumping
+ * transform it to selected export format, finally dumping
* the XML into a character buffer.
*/
doc = xmlReadMemory(buf.buffer, buf.len, "divelog", NULL, 0);
@@ -642,16 +643,16 @@ int export_dives_uddf(const char *filename, const bool selected)
if (!doc)
return report_error("Failed to read XML memory");
- /* Convert to UDDF format */
- xslt = get_stylesheet("uddf-export.xslt");
+ /* Convert to export format */
+ xslt = get_stylesheet(export_xslt);
if (!xslt)
- return report_error("Failed to open UDDF conversion stylesheet");
+ return report_error("Failed to open export conversion stylesheet");
transformed = xsltApplyStylesheet(xslt, doc, NULL);
xsltFreeStylesheet(xslt);
xmlFreeDoc(doc);
- /* Write the transformed XML to file */
+ /* Write the transformed export to file */
f = subsurface_fopen(filename, "w");
if (!f)
return report_error("Failed to open %s for writing (%s)", filename, strerror(errno));