summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 24a2410)
raw | patch | inline | side by side (parent: 24a2410)
author | ishmal <ishmal@users.sourceforge.net> | |
Wed, 2 Apr 2008 20:38:51 +0000 (20:38 +0000) | ||
committer | ishmal <ishmal@users.sourceforge.net> | |
Wed, 2 Apr 2008 20:38:51 +0000 (20:38 +0000) |
src/xml/repr-io.cpp | patch | blob | history | |
src/xml/repr.h | patch | blob | history |
diff --git a/src/xml/repr-io.cpp b/src/xml/repr-io.cpp
index 19753e9e3c4c02df190870f32511a26221efcc73..2a5125375a462dc0180dfda2ac3392c407648220 100644 (file)
--- a/src/xml/repr-io.cpp
+++ b/src/xml/repr-io.cpp
@@ -506,29 +506,22 @@ sp_repr_svg_read_node (Document *xml_doc, xmlNodePtr node, const gchar *default_
return repr;
}
+
void
-sp_repr_save_stream (Document *doc, FILE *fp, gchar const *default_ns, bool compress)
+sp_repr_save_writer(Document *doc, Inkscape::IO::Writer *out,
+ gchar const *default_ns)
{
- Node *repr;
- const gchar *str;
-
- Inkscape::URI dummy("x");
- Inkscape::IO::UriOutputStream bout(fp, dummy);
- Inkscape::IO::GzipOutputStream *gout = compress ? new Inkscape::IO::GzipOutputStream(bout) : NULL;
- Inkscape::IO::OutputStreamWriter *out = compress ? new Inkscape::IO::OutputStreamWriter( *gout ) : new Inkscape::IO::OutputStreamWriter( bout );
-
int inlineattrs = prefs_get_int_attribute("options.svgoutput", "inlineattrs", 0);
int indent = prefs_get_int_attribute("options.svgoutput", "indent", 2);
/* fixme: do this The Right Way */
out->writeString( "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"no\"?>\n" );
- str = ((Node *)doc)->attribute("doctype");
- if (str) {
+ const gchar *str = ((Node *)doc)->attribute("doctype");
+ if (str)
out->writeString( str );
- }
- repr = sp_repr_document_first_child(doc);
+ Node *repr = sp_repr_document_first_child(doc);
for ( repr = sp_repr_document_first_child(doc) ;
repr ; repr = sp_repr_next(repr) )
{
@@ -541,16 +534,45 @@ sp_repr_save_stream (Document *doc, FILE *fp, gchar const *default_ns, bool comp
sp_repr_write_stream(repr, *out, 0, TRUE, GQuark(0), inlineattrs, indent);
}
}
- if ( out ) {
- delete out;
- out = NULL;
- }
- if ( gout ) {
- delete gout;
- gout = NULL;
- }
}
+
+
+
+Glib::ustring
+sp_repr_save_buf(Document *doc)
+{
+ Inkscape::IO::StringOutputStream souts;
+ Inkscape::IO::OutputStreamWriter outs(souts);
+
+ sp_repr_save_writer(doc, &outs, SP_INKSCAPE_NS_URI);
+
+ outs.close();
+ Glib::ustring buf = souts.getString();
+
+ return buf;
+}
+
+
+
+
+
+void
+sp_repr_save_stream (Document *doc, FILE *fp, gchar const *default_ns, bool compress)
+{
+ Inkscape::URI dummy("x");
+ Inkscape::IO::UriOutputStream bout(fp, dummy);
+ Inkscape::IO::GzipOutputStream *gout = compress ? new Inkscape::IO::GzipOutputStream(bout) : NULL;
+ Inkscape::IO::OutputStreamWriter *out = compress ? new Inkscape::IO::OutputStreamWriter( *gout ) : new Inkscape::IO::OutputStreamWriter( bout );
+
+ sp_repr_save_writer(doc, out, default_ns);
+
+ delete out;
+ delete gout;
+}
+
+
+
/* Returns TRUE if file successfully saved; FALSE if not
*/
bool
}
-Glib::ustring
-sp_repr_write_buf(Node *repr, gint indent_level,
- bool add_whitespace, Glib::QueryQuark elide_prefix,
- int inlineattrs, int indent)
-{
- Glib::ustring buf;
- Inkscape::IO::StringOutputStream souts;
- Inkscape::IO::OutputStreamWriter outs(souts);
- sp_repr_write_stream(repr, outs, indent_level, add_whitespace,
- elide_prefix, inlineattrs, indent);
- outs.close();
- buf = souts.getString();
- return buf;
-}
-
-
void
sp_repr_write_stream_element (Node * repr, Writer & out, gint indent_level,
bool add_whitespace,
diff --git a/src/xml/repr.h b/src/xml/repr.h
index 69fe2adcefbd9294ff7ac69d090f5a02739b0c6d..67616df294308cdd9f09af27708d76878dd4d5d4 100644 (file)
--- a/src/xml/repr.h
+++ b/src/xml/repr.h
@@ -182,9 +182,7 @@ void sp_repr_write_stream (Inkscape::XML::Node *repr, Inkscape::IO::Writer &out,
gint indent_level, bool add_whitespace, Glib::QueryQuark elide_prefix,
int inlineattrs, int indent);
Inkscape::XML::Document *sp_repr_read_buf (const Glib::ustring &buf, const gchar *default_ns);
-Glib::ustring sp_repr_write_buf(Inkscape::XML::Node *repr, gint indent_level,
- bool add_whitespace, Glib::QueryQuark elide_prefix,
- int inlineattrs, int indent);
+Glib::ustring sp_repr_save_buf(Inkscape::XML::Document *doc);
void sp_repr_save_stream(Inkscape::XML::Document *doc, FILE *to_file, gchar const *default_ns=NULL, bool compress = false);
bool sp_repr_save_file(Inkscape::XML::Document *doc, gchar const *filename, gchar const *default_ns=NULL);