summaryrefslogtreecommitdiffstats
path: root/src/xml/repr-io.cpp
diff options
context:
space:
mode:
authorJabier Arraiza <jabier.arraiza@marker.es>2017-11-03 00:10:02 +0000
committerJabier Arraiza <jabier.arraiza@marker.es>2017-11-03 00:10:02 +0000
commitd2df0412f728dd5bb54537dfdfe7c35b34d40e0e (patch)
treee2703384779e83312c456399999997fcc289c5cf /src/xml/repr-io.cpp
parentMerge branch 'master' into powerpencil (diff)
parentchange assignment to equality (diff)
downloadinkscape-d2df0412f728dd5bb54537dfdfe7c35b34d40e0e.tar.gz
inkscape-d2df0412f728dd5bb54537dfdfe7c35b34d40e0e.zip
Merge branch 'master' into powerpencil
Diffstat (limited to 'src/xml/repr-io.cpp')
-rw-r--r--src/xml/repr-io.cpp70
1 files changed, 27 insertions, 43 deletions
diff --git a/src/xml/repr-io.cpp b/src/xml/repr-io.cpp
index d8e0f5418..2ff9d4776 100644
--- a/src/xml/repr-io.cpp
+++ b/src/xml/repr-io.cpp
@@ -67,11 +67,6 @@ static void sp_repr_write_stream_element(Node *repr, Writer &out,
gchar const *old_href_abs_base,
gchar const *new_href_abs_base);
-#ifdef HAVE_LIBWMF
-static xmlDocPtr sp_wmf_convert (const char * file_name);
-static char * sp_wmf_image_name (void * context);
-#endif /* HAVE_LIBWMF */
-
class XmlSource
{
@@ -323,19 +318,18 @@ int XmlSource::close()
}
/**
- * Reads XML from a file, including WMF files, and returns the Document.
+ * Reads XML from a file, and returns the Document.
* The default namespace can also be specified, if desired.
*/
Document *sp_repr_read_file (const gchar * filename, const gchar *default_ns)
{
- // g_warning( "Reading file: %s", filename );
xmlDocPtr doc = 0;
Document * rdoc = 0;
xmlSubstituteEntitiesDefault(1);
- g_return_val_if_fail (filename != NULL, NULL);
- if (!Inkscape::IO::file_test( filename, G_FILE_TEST_EXISTS )) {
+ g_return_val_if_fail(filename != NULL, NULL);
+ if (!Inkscape::IO::file_test(filename, G_FILE_TEST_EXISTS)) {
g_warning("Can't open file: %s (doesn't exist)", filename);
return NULL;
}
@@ -348,45 +342,32 @@ Document *sp_repr_read_file (const gchar * filename, const gchar *default_ns)
gsize bytesWritten = 0;
GError* error = NULL;
// TODO: need to replace with our own fopen and reading
- gchar* localFilename = g_filename_from_utf8 ( filename,
- -1, &bytesRead, &bytesWritten, &error);
- g_return_val_if_fail( localFilename != NULL, NULL );
-
- Inkscape::IO::dump_fopen_call( filename, "N" );
+ gchar* localFilename = g_filename_from_utf8(filename, -1, &bytesRead, &bytesWritten, &error);
+ g_return_val_if_fail(localFilename != NULL, NULL);
-#ifdef HAVE_LIBWMF
- if (strlen (localFilename) > 4) {
- if ( (strcmp (localFilename + strlen (localFilename) - 4,".wmf") == 0)
- || (strcmp (localFilename + strlen (localFilename) - 4,".WMF") == 0)) {
- doc = sp_wmf_convert (localFilename);
- }
- }
-#endif // !HAVE_LIBWMF
+ Inkscape::IO::dump_fopen_call(filename, "N");
- if ( !doc ) {
- XmlSource src;
+ XmlSource src;
- if ( (src.setFile(filename) == 0) ) {
+ if (src.setFile(filename) == 0) {
+ doc = src.readXml();
+ rdoc = sp_repr_do_read(doc, default_ns);
+ // For some reason, failed ns loading results in this
+ // We try a system check version of load with NOENT for adobe
+ if (rdoc && strcmp(rdoc->root()->name(), "ns:svg") == 0) {
+ xmlFreeDoc(doc);
+ src.setFile(filename, true);
doc = src.readXml();
- rdoc = sp_repr_do_read( doc, default_ns );
- // For some reason, failed ns loading results in this
- // We try a system check version of load with NOENT for adobe
- if(rdoc && strcmp(rdoc->root()->name(), "ns:svg") == 0) {
- xmlFreeDoc( doc );
- src.setFile(filename, true);
- doc = src.readXml();
- rdoc = sp_repr_do_read( doc, default_ns );
- }
+ rdoc = sp_repr_do_read(doc, default_ns);
}
}
-
- if ( doc ) {
- xmlFreeDoc( doc );
+ if (doc) {
+ xmlFreeDoc(doc);
}
- if ( localFilename ) {
- g_free( localFilename );
+ if (localFilename) {
+ g_free(localFilename);
}
return rdoc;
@@ -580,7 +561,10 @@ static Node *sp_repr_svg_read_node (Document *xml_doc, xmlNodePtr node, const gc
return NULL; // empty text node
}
- bool preserve = (xmlNodeGetSpacePreserve (node) == 1);
+ // Since libxml2 2.9.0, only element nodes are checked, thus check parent.
+ // Note: this only handles XML's rules for white space. SVG's specific rules
+ // are handled in sp-string.cpp.
+ bool preserve = (xmlNodeGetSpacePreserve (node->parent) == 1);
xmlChar *p;
for (p = node->content; *p && g_ascii_isspace (*p) && !preserve; p++)
@@ -812,7 +796,7 @@ static void repr_write_comment( Writer &out, const gchar * val, bool addWhitespa
namespace {
typedef std::map<Glib::QueryQuark, gchar const *, Inkscape::compare_quark_ids> LocalNameMap;
-typedef std::map<Glib::QueryQuark, Inkscape::Util::ptr_shared<char>, Inkscape::compare_quark_ids> NSMap;
+typedef std::map<Glib::QueryQuark, Inkscape::Util::ptr_shared, Inkscape::compare_quark_ids> NSMap;
gchar const *qname_local_name(Glib::QueryQuark qname) {
static LocalNameMap local_name_map;
@@ -846,7 +830,7 @@ void add_ns_map_entry(NSMap &ns_map, Glib::QueryQuark prefix) {
g_warning("No namespace known for normalized prefix %s", g_quark_to_string(prefix));
}
} else {
- ns_map.insert(NSMap::value_type(prefix, ptr_shared<char>()));
+ ns_map.insert(NSMap::value_type(prefix, ptr_shared()));
}
}
}
@@ -905,7 +889,7 @@ static void sp_repr_write_stream_root_element(Node *repr, Writer &out,
for ( NSMap::iterator iter=ns_map.begin() ; iter != ns_map.end() ; ++iter )
{
Glib::QueryQuark prefix=(*iter).first;
- ptr_shared<char> ns_uri=(*iter).second;
+ ptr_shared ns_uri=(*iter).second;
if (prefix.id()) {
if ( prefix != xml_prefix ) {