summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 8f478a2)
raw | patch | inline | side by side (parent: 8f478a2)
author | pjrm <pjrm@users.sourceforge.net> | |
Mon, 6 Apr 2009 21:53:09 +0000 (21:53 +0000) | ||
committer | pjrm <pjrm@users.sourceforge.net> | |
Mon, 6 Apr 2009 21:53:09 +0000 (21:53 +0000) |
Add a couple of fixme comments to do with use of this argument.
18 files changed:
index 744d59f755f8cb249516473d1da3e01600e94400..c81fdd0298df8286fa35fdc7ff56aa14811e404e 100644 (file)
\param uri Filename to save to (probably will end in .png)
*/
void
-CairoRendererOutput::save (Inkscape::Extension::Output *mod, SPDocument *doc, const gchar *uri)
+CairoRendererOutput::save(Inkscape::Extension::Output *mod, SPDocument *doc, gchar const *filename)
{
- if (!png_render_document_to_file(doc, uri))
+ if (!png_render_document_to_file(doc, filename))
throw Inkscape::Extension::Output::save_failed();
return;
index 625c53ffcf36dc91f9578cef489e0e26ed56f43b..9b9bd6ffe9d5d3f84b9205a62df855bf0c77a707 100644 (file)
bool check(Inkscape::Extension::Extension *module);
void save(Inkscape::Extension::Output *mod,
SPDocument *doc,
- gchar const *uri);
+ gchar const *filename);
static void init();
};
index f8918c060019926dbea9fdcc60c1eb713b1c59bb..0ea0a051d832588cee39bdb0d00472343d230838 100644 (file)
@@ -121,10 +121,10 @@ ps_print_document_to_file(SPDocument *doc, gchar const *filename, unsigned int l
\brief This function calls the output module with the filename
\param mod unused
\param doc Document to be saved
- \param uri Filename to save to (probably will end in .ps)
+ \param filename Filename to save to (probably will end in .ps)
*/
void
-CairoPsOutput::save (Inkscape::Extension::Output *mod, SPDocument *doc, const gchar *uri)
+CairoPsOutput::save(Inkscape::Extension::Output *mod, SPDocument *doc, gchar const *filename)
{
Inkscape::Extension::Extension * ext;
unsigned int ret;
@@ -172,7 +172,7 @@ CairoPsOutput::save (Inkscape::Extension::Output *mod, SPDocument *doc, const gc
} catch(...) {}
gchar * final_name;
- final_name = g_strdup_printf("> %s", uri);
+ final_name = g_strdup_printf("> %s", filename);
ret = ps_print_document_to_file(doc, final_name, level, new_textToPath, new_blurToBitmap, new_bitmapResolution, new_exportId, new_areaDrawing, new_areaCanvas);
g_free(final_name);
@@ -185,10 +185,10 @@ CairoPsOutput::save (Inkscape::Extension::Output *mod, SPDocument *doc, const gc
\brief This function calls the output module with the filename
\param mod unused
\param doc Document to be saved
- \param uri Filename to save to (probably will end in .ps)
+ \param filename Filename to save to (probably will end in .ps)
*/
void
-CairoEpsOutput::save (Inkscape::Extension::Output *mod, SPDocument *doc, const gchar *uri)
+CairoEpsOutput::save(Inkscape::Extension::Output *mod, SPDocument *doc, gchar const *filename)
{
Inkscape::Extension::Extension * ext;
unsigned int ret;
@@ -236,7 +236,7 @@ CairoEpsOutput::save (Inkscape::Extension::Output *mod, SPDocument *doc, const g
} catch(...) {}
gchar * final_name;
- final_name = g_strdup_printf("> %s", uri);
+ final_name = g_strdup_printf("> %s", filename);
ret = ps_print_document_to_file(doc, final_name, level, new_textToPath, new_blurToBitmap, new_bitmapResolution, new_exportId, new_areaDrawing, new_areaCanvas, true);
g_free(final_name);
index d6730c9cea8484a5142ad80700b9323e7486391c..019b6b8101ed9341f3d4d3cb4aa55862aa42b7b5 100644 (file)
bool check(Inkscape::Extension::Extension *module);
void save(Inkscape::Extension::Output *mod,
SPDocument *doc,
- gchar const *uri);
+ gchar const *filename);
static void init();
bool textToPath(Inkscape::Extension::Print *ext);
diff --git a/src/extension/internal/cairo-renderer-pdf-out.cpp b/src/extension/internal/cairo-renderer-pdf-out.cpp
index 4b37cae5ca193afae0c4a5f1176533a7f6feceb9..3a4dde639844e9d2664403659a72186043659f04 100644 (file)
@@ -110,14 +110,14 @@ pdf_render_document_to_file(SPDocument *doc, gchar const *filename, unsigned int
\brief This function calls the output module with the filename
\param mod unused
\param doc Document to be saved
- \param uri Filename to save to (probably will end in .pdf)
+ \param filename Filename to save to (probably will end in .pdf)
The most interesting thing that this function does is just attach
an '>' on the front of the filename. This is the syntax used to
tell the printing system to save to file.
*/
void
-CairoRendererPdfOutput::save (Inkscape::Extension::Output *mod, SPDocument *doc, const gchar *uri)
+CairoRendererPdfOutput::save(Inkscape::Extension::Output *mod, SPDocument *doc, gchar const *filename)
{
Inkscape::Extension::Extension * ext;
unsigned int ret;
@@ -186,7 +186,7 @@ CairoRendererPdfOutput::save (Inkscape::Extension::Output *mod, SPDocument *doc,
}
gchar * final_name;
- final_name = g_strdup_printf("> %s", uri);
+ final_name = g_strdup_printf("> %s", filename);
ret = pdf_render_document_to_file(doc, final_name, level,
new_textToPath, new_blurToBitmap, new_bitmapResolution,
new_exportId, new_exportDrawing, new_exportCanvas);
diff --git a/src/extension/internal/cairo-renderer-pdf-out.h b/src/extension/internal/cairo-renderer-pdf-out.h
index 1c18519a0a63ec135330e924b96c167872749874..d76ffb4d44bfb76996963014749c659e184dbeb9 100644 (file)
bool check(Inkscape::Extension::Extension *module);
void save(Inkscape::Extension::Output *mod,
SPDocument *doc,
- gchar const *uri);
+ gchar const *filename);
static void init();
};
index 49c1826e45f9af92f27f53bee9fc558389c96257..c62d7a4e9025071fcab7637f9e12acd8d2984358 100644 (file)
void save(Inkscape::Extension::Output *mod, // Save the given document to the given filename
SPDocument *doc,
- gchar const *uri);
+ gchar const *filename);
virtual SPDocument *open( Inkscape::Extension::Input *mod,
const gchar *uri );
index 1c3ae9c2a1c3eb69349a56880ca38eccefa17b2d..fd28011c353c553e93f89abc3dc830b10046b51a 100644 (file)
/**\r
* Saves the <paths> of an Inkscape SVG file as JavaFX spline definitions\r
*/\r
-bool JavaFXOutput::saveDocument(SPDocument *doc, gchar const *uri)\r
+bool JavaFXOutput::saveDocument(SPDocument *doc, gchar const *filename_utf8)\r
{\r
reset();\r
\r
\r
- name = Glib::path_get_basename(uri);\r
+ name = Glib::path_get_basename(filename_utf8);\r
int pos = name.find('.');\r
if (pos > 0)\r
name = name.substr(0, pos);\r
\r
\r
//###### WRITE TO FILE\r
- FILE *f = Inkscape::IO::fopen_utf8name(uri, "w");\r
+ FILE *f = Inkscape::IO::fopen_utf8name(filename_utf8, "w");\r
if (!f)\r
{\r
- err("Could open JavaFX file '%s' for writing", uri);\r
+ err("Could open JavaFX file '%s' for writing", filename_utf8);\r
return false;\r
}\r
\r
*/\r
void\r
JavaFXOutput::save(Inkscape::Extension::Output */*mod*/,\r
- SPDocument *doc, gchar const *uri)\r
+ SPDocument *doc, gchar const *filename_utf8)\r
{\r
- if (!saveDocument(doc, uri))\r
+ /* N.B. The name `filename_utf8' represents the fact that we want it to be in utf8; whereas in\r
+ * fact we know that some callers of Extension::save pass something in the filesystem's\r
+ * encoding, while others do g_filename_to_utf8 before calling.\r
+ *\r
+ * In terms of safety, it's best to make all callers pass actual filenames, since in general\r
+ * one can't round-trip from filename to utf8 back to the same filename. Whereas the argument\r
+ * for passing utf8 filenames is one of convenience: we often want to pass to g_warning or\r
+ * store as a string (rather than a byte stream) in XML, or the like. */\r
+ if (!saveDocument(doc, filename_utf8))\r
{\r
- g_warning("Could not save JavaFX file '%s'", uri);\r
+ g_warning("Could not save JavaFX file '%s'", filename_utf8);\r
}\r
}\r
\r
index b3552097f5b5408d5455bb31ee99d9571b91e62e..691812ee250a372f258ccc4282d482f3975ab012 100644 (file)
/**\r
* API call to perform the output to a file\r
*/\r
- virtual void save (Inkscape::Extension::Output *mod,\r
- SPDocument *doc, const gchar *uri);\r
+ virtual void save(Inkscape::Extension::Output *mod,\r
+ SPDocument *doc, gchar const *filename);\r
\r
/**\r
* Inkscape runtime startup call.\r
/**\r
* Actual method to save document\r
*/\r
- bool saveDocument(SPDocument *doc, const gchar *uri);\r
+ bool saveDocument(SPDocument *doc, gchar const *filename);\r
\r
//For statistics\r
int nrNodes;\r
diff --git a/src/extension/internal/latex-pstricks-out.cpp b/src/extension/internal/latex-pstricks-out.cpp
index 8d89951ce347972250bfbb9afe3b0d4267e6043e..4a469a7500a0da118ed649fa5ff19fad21ebe443 100644 (file)
void
-LatexOutput::save (Inkscape::Extension::Output *mod2, SPDocument *doc, const gchar *uri)
+LatexOutput::save(Inkscape::Extension::Output *mod2, SPDocument *doc, gchar const *filename)
{
Inkscape::Extension::Print *mod;
SPPrintContext context;
mod = Inkscape::Extension::get_print(SP_MODULE_KEY_PRINT_LATEX);
oldconst = mod->get_param_string("destination");
oldoutput = g_strdup(oldconst);
- mod->set_param_string("destination", (gchar *)uri);
+ mod->set_param_string("destination", filename);
/* Start */
context.module = mod;
diff --git a/src/extension/internal/latex-pstricks-out.h b/src/extension/internal/latex-pstricks-out.h
index 8e544d5b4ce64797b764667907748e77e0892125..a12cdc3c1395db9c187361dcb428ade17e32218b 100644 (file)
void save(Inkscape::Extension::Output *mod, // Save the given document to the given filename
SPDocument *doc,
- gchar const *uri);
+ gchar const *filename);
static void init(void);//Initialize the class
};
index c15b839d795621897f42dc8f0457cba3b39ee990..cc8489302d2c73da43173e14eba0be3fc2a49f19 100644 (file)
* Descends into the SVG tree, mapping things to ODF when appropriate
*/
void
-OdfOutput::save(Inkscape::Extension::Output */*mod*/, SPDocument *doc, gchar const *uri)
+OdfOutput::save(Inkscape::Extension::Output */*mod*/, SPDocument *doc, gchar const *filename)
{
reset();
- //g_message("native file:%s\n", uri);
- documentUri = URI(uri);
+ //g_message("native file:%s\n", filename);
+ documentUri = URI(filename);
+ /* fixme: It looks like we really are using documentUri as a URI, so we ought to call
+ * g_filename_to_uri for the URI constructor. */
ZipFile zf;
preprocess(zf, doc->rroot);
@@ -2395,7 +2397,7 @@ OdfOutput::save(Inkscape::Extension::Output */*mod*/, SPDocument *doc, gchar con
return;
}
- if (!zf.writeFile(uri))
+ if (!zf.writeFile(filename))
{
return;
}
index 8d38e530f97f87de8da485d0bfbec943cbcf2b38..3854ddfe126a785d763254b6659a9f4ce2b0d4e2 100644 (file)
void save (Inkscape::Extension::Output *mod,
SPDocument *doc,
- const gchar *uri);
+ gchar const *filename);
static void init (void);
index 89f58befcf4697f69bed7fd616c947aa26dabf3b..f30cbc317a4413cd6b07270bd2542a15c3bfc86e 100644 (file)
/**
* Saves the Shapes of an Inkscape SVG file as PovRay spline definitions
*/
-void PovOutput::saveDocument(SPDocument *doc, gchar const *uri)
+void PovOutput::saveDocument(SPDocument *doc, gchar const *filename_utf8)
{
reset();
//# Lets do the curves first, to get the stats
if (!doTree(doc))
{
- err("Could not output curves for %s", uri);
+ err("Could not output curves for %s", filename_utf8);
return;
}
if (!doHeader())
{
- err("Could not write header for %s", uri);
+ err("Could not write header for %s", filename_utf8);
return;
}
if (!doTail())
{
- err("Could not write footer for %s", uri);
+ err("Could not write footer for %s", filename_utf8);
return;
}
//###### WRITE TO FILE
- Inkscape::IO::dump_fopen_call(uri, "L");
- FILE *f = Inkscape::IO::fopen_utf8name(uri, "w");
+ Inkscape::IO::dump_fopen_call(filename_utf8, "L");
+ FILE *f = Inkscape::IO::fopen_utf8name(filename_utf8, "w");
if (!f)
return;
*/
void
PovOutput::save(Inkscape::Extension::Output */*mod*/,
- SPDocument *doc, gchar const *uri)
+ SPDocument *doc, gchar const *filename_utf8)
{
- saveDocument(doc, uri);
+ /* See comments in JavaFSOutput::save re the name `filename_utf8'. */
+ saveDocument(doc, filename_utf8);
}
index a9f94b61ae46db3d7b723410dc17d9875e474eea..0c3b73a7f0f3b531f87260f6cfa19b84ab8b42f6 100644 (file)
/**
* API call to perform the output to a file
*/
- void save (Inkscape::Extension::Output *mod,
- SPDocument *doc, const gchar *uri);
+ void save(Inkscape::Extension::Output *mod,
+ SPDocument *doc, gchar const *filename);
/**
* Inkscape runtime startup call.
/**
* Actual method to save document
*/
- void saveDocument(SPDocument *doc, const gchar *uri);
+ void saveDocument(SPDocument *doc, gchar const *filename);
/**
index 31178f8d5b403419ac61aa74f931a3a4bdb12f2e..4a323d7d76ddb814cbdec3312c5def5c89699672 100644 (file)
all of this code. I just stole it.
*/
void
-Svg::save (Inkscape::Extension::Output *mod, SPDocument *doc, const gchar *uri)
+Svg::save(Inkscape::Extension::Output *mod, SPDocument *doc, gchar const *filename)
{
g_return_if_fail(doc != NULL);
- g_return_if_fail(uri != NULL);
+ g_return_if_fail(filename != NULL);
- gchar *save_path = g_path_get_dirname (uri);
+ gchar *save_path = g_path_get_dirname(filename);
gboolean const spns = (!mod->get_id()
|| !strcmp (mod->get_id(), SP_MODULE_KEY_OUTPUT_SVG_INKSCAPE)
Inkscape::IO::fixupHrefs( doc, save_path, spns );
- gboolean const s = sp_repr_save_file (repr->document(), uri, SP_SVG_NS_URI);
+ gboolean const s = sp_repr_save_file(repr->document(), filename, SP_SVG_NS_URI);
if (s == FALSE) {
throw Inkscape::Extension::Output::save_failed();
}
index de75f00210c7e639679058bdb1626e46d2e309d5..b97735dd805c72d5aa6a072fdba28a8b2654a214 100644 (file)
public:
virtual void save( Inkscape::Extension::Output *mod,
SPDocument *doc,
- const gchar *uri );
+ gchar const *filename );
virtual SPDocument *open( Inkscape::Extension::Input *mod,
const gchar *uri );
static void init( void );
index e0070339d7c47dc20c3c60df0196417789577844..e1481d0002e7cdce122b6ed81f4d5a69a58139b0 100644 (file)
--- a/src/extension/output.cpp
+++ b/src/extension/output.cpp
\return None
\brief Save a document as a file
\param doc Document to save
- \param uri File to save the document as
+ \param filename File to save the document as
This function does a little of the dirty work involved in saving
a document so that the implementation only has to worry about geting
could be changed, and old files will still work properly.
*/
void
-Output::save (SPDocument * doc, const gchar * uri)
+Output::save(SPDocument *doc, gchar const *filename)
{
try {
- imp->save(this, doc, uri);
+ imp->save(this, doc, filename);
}
catch (...) {
g_warning("There was an error saving the file.");