summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: f85ce7f)
raw | patch | inline | side by side (parent: f85ce7f)
author | buliabyak <buliabyak@users.sourceforge.net> | |
Wed, 1 Nov 2006 03:55:05 +0000 (03:55 +0000) | ||
committer | buliabyak <buliabyak@users.sourceforge.net> | |
Wed, 1 Nov 2006 03:55:05 +0000 (03:55 +0000) |
src/preferences-skeleton.h | patch | blob | history | |
src/xml/repr-io.cpp | patch | blob | history |
index a76e6c19a2e6cec5c8d5db37bb67b0c7b6e90a70..ec8ca44289d7e8d81844e303f698612431489c95 100644 (file)
" ondark=\"4294967295\"" //ffffffff
" clips=\"16711935\"" // 00ff00ff
" masks=\"65535\"/>\n" // 0x0000ffff
-" <group id=\"svgoutput\" usenamedcolors=\"0\" numericprecision=\"8\" minimumexponent=\"-8\"/>\n"
+" <group id=\"svgoutput\" usenamedcolors=\"0\" numericprecision=\"8\" minimumexponent=\"-8\" inlineattrs=\"0\" indent=\"2\"/>\n"
" </group>\n"
"\n"
" <group id=\"extensions\">"
diff --git a/src/xml/repr-io.cpp b/src/xml/repr-io.cpp
index d4eea0835013cb4a58402f7e0a8068938e48bf4d..a7425ccb3eaa9aeb274f67fee981413e720a71b6 100644 (file)
--- a/src/xml/repr-io.cpp
+++ b/src/xml/repr-io.cpp
#include "io/uristream.h"
#include "io/gzipstream.h"
+#include "prefs-utils.h"
using Inkscape::IO::Writer;
using Inkscape::Util::List;
static Document *sp_repr_do_read (xmlDocPtr doc, const gchar *default_ns);
static Node *sp_repr_svg_read_node (xmlNodePtr node, const gchar *default_ns, GHashTable *prefix_map);
static gint sp_repr_qualified_name (gchar *p, gint len, xmlNsPtr ns, const xmlChar *name, const gchar *default_ns, GHashTable *prefix_map);
-static void sp_repr_write_stream_root_element (Node *repr, Writer &out, bool add_whitespace, gchar const *default_ns);
-static void sp_repr_write_stream (Node *repr, Writer &out, gint indent_level, bool add_whitespace, Glib::QueryQuark elide_prefix);
-static void sp_repr_write_stream_element (Node *repr, Writer &out, gint indent_level, bool add_whitespace, Glib::QueryQuark elide_prefix, List<AttributeRecord const> attributes);
+static void sp_repr_write_stream_root_element (Node *repr, Writer &out, bool add_whitespace, gchar const *default_ns, int inlineattrs, int indent);
+static void sp_repr_write_stream (Node *repr, Writer &out, gint indent_level, bool add_whitespace, Glib::QueryQuark elide_prefix, int inlineattrs, int indent);
+static void sp_repr_write_stream_element (Node *repr, Writer &out, gint indent_level, bool add_whitespace, Glib::QueryQuark elide_prefix, List<AttributeRecord const> attributes, int inlineattrs, int indent);
#ifdef HAVE_LIBWMF
static xmlDocPtr sp_wmf_convert (const char * file_name);
@@ -505,8 +506,10 @@ sp_repr_save_stream (Document *doc, FILE *fp, gchar const *default_ns, bool comp
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 );
- /* fixme: do this The Right Way */
+ 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");
@@ -519,12 +522,12 @@ sp_repr_save_stream (Document *doc, FILE *fp, gchar const *default_ns, bool comp
repr ; repr = sp_repr_next(repr) )
{
if ( repr->type() == Inkscape::XML::ELEMENT_NODE ) {
- sp_repr_write_stream_root_element(repr, *out, TRUE, default_ns);
+ sp_repr_write_stream_root_element(repr, *out, TRUE, default_ns, inlineattrs, indent);
} else if ( repr->type() == Inkscape::XML::COMMENT_NODE ) {
- sp_repr_write_stream(repr, *out, 0, TRUE, GQuark(0));
+ sp_repr_write_stream(repr, *out, 0, TRUE, GQuark(0), inlineattrs, indent);
out->writeChar( '\n' );
} else {
- sp_repr_write_stream(repr, *out, 0, TRUE, GQuark(0));
+ sp_repr_write_stream(repr, *out, 0, TRUE, GQuark(0), inlineattrs, indent);
}
}
if ( out ) {
Inkscape::IO::StdOutputStream bout;
Inkscape::IO::OutputStreamWriter out(bout);
- sp_repr_write_stream (repr, out, 0, TRUE, GQuark(0));
+ sp_repr_write_stream (repr, out, 0, TRUE, GQuark(0), 0, 2);
return;
}
}
void
-sp_repr_write_stream_root_element (Node *repr, Writer &out, bool add_whitespace, gchar const *default_ns)
+sp_repr_write_stream_root_element (Node *repr, Writer &out, bool add_whitespace, gchar const *default_ns,
+ int inlineattrs, int indent)
{
using Inkscape::Util::ptr_shared;
g_assert(repr != NULL);
@@ -705,19 +709,19 @@ sp_repr_write_stream_root_element (Node *repr, Writer &out, bool add_whitespace,
}
}
- return sp_repr_write_stream_element(repr, out, 0, add_whitespace, elide_prefix, attributes);
+ return sp_repr_write_stream_element(repr, out, 0, add_whitespace, elide_prefix, attributes, inlineattrs, indent);
}
void
sp_repr_write_stream (Node *repr, Writer &out, gint indent_level,
- bool add_whitespace, Glib::QueryQuark elide_prefix)
+ bool add_whitespace, Glib::QueryQuark elide_prefix, int inlineattrs, int indent)
{
if (repr->type() == Inkscape::XML::TEXT_NODE) {
repr_quote_write (out, repr->content());
} else if (repr->type() == Inkscape::XML::COMMENT_NODE) {
out.printf( "<!--%s-->", repr->content() );
} else if (repr->type() == Inkscape::XML::ELEMENT_NODE) {
- sp_repr_write_stream_element(repr, out, indent_level, add_whitespace, elide_prefix, repr->attributeList());
+ sp_repr_write_stream_element(repr, out, indent_level, add_whitespace, elide_prefix, repr->attributeList(), inlineattrs, indent);
} else {
g_assert_not_reached();
}
sp_repr_write_stream_element (Node * repr, Writer & out, gint indent_level,
bool add_whitespace,
Glib::QueryQuark elide_prefix,
- List<AttributeRecord const> attributes)
+ List<AttributeRecord const> attributes,
+ int inlineattrs, int indent)
{
Node *child;
bool loose;
- gint i;
g_return_if_fail (repr != NULL);
if ( indent_level > 16 )
indent_level = 16;
- if (add_whitespace) {
- for ( i = 0 ; i < indent_level ; i++ ) {
- out.writeString( " " );
+ if (add_whitespace && indent) {
+ for (gint i = 0; i < indent_level; i++) {
+ for (gint j = 0; j < indent; j++) {
+ out.writeString(" ");
+ }
}
}
for ( List<AttributeRecord const> iter = attributes ;
iter ; ++iter )
{
- out.writeString("\n");
- for ( i = 0 ; i < indent_level + 1 ; i++ ) {
- out.writeString(" ");
+ if (!inlineattrs) {
+ out.writeString("\n");
+ if (indent) {
+ for ( gint i = 0 ; i < indent_level + 1 ; i++ ) {
+ for ( gint j = 0 ; j < indent ; j++ ) {
+ out.writeString(" ");
+ }
+ }
+ }
}
out.printf(" %s=\"", g_quark_to_string(iter->key));
repr_quote_write(out, iter->value);
out.writeString( "\n" );
}
for (child = repr->firstChild(); child != NULL; child = child->next()) {
- sp_repr_write_stream (child, out, (loose) ? (indent_level + 1) : 0, add_whitespace, elide_prefix);
+ sp_repr_write_stream (child, out, (loose) ? (indent_level + 1) : 0, add_whitespace, elide_prefix, inlineattrs, indent);
}
- if (loose && add_whitespace) {
- for (i = 0; i < indent_level; i++) {
- out.writeString( " " );
+ if (loose && add_whitespace && indent) {
+ for (gint i = 0; i < indent_level; i++) {
+ for ( gint j = 0 ; j < indent ; j++ ) {
+ out.writeString(" ");
+ }
}
}
out.printf( "</%s>", element_name );