diff options
| author | Marc Jeanmougin <marc@jeanmougin.fr> | 2017-10-20 18:45:52 +0000 |
|---|---|---|
| committer | Marc Jeanmougin <marc@jeanmougin.fr> | 2017-10-20 18:45:52 +0000 |
| commit | 10af9131e03df0227458285b59ed1425d15b52b5 (patch) | |
| tree | 835b89f653c157ba1f176e7b02aabeb0498d49f2 /src/xml/repr-io.cpp | |
| parent | Removed author on request (diff) | |
| parent | Drop obsolete wrapper around Glib::file_open_tmp (diff) | |
| download | inkscape-10af9131e03df0227458285b59ed1425d15b52b5.tar.gz inkscape-10af9131e03df0227458285b59ed1425d15b52b5.zip | |
Merge branch 'cleanups' of gitlab.com:stfacc/inkscape
Diffstat (limited to 'src/xml/repr-io.cpp')
| -rw-r--r-- | src/xml/repr-io.cpp | 59 |
1 files changed, 20 insertions, 39 deletions
diff --git a/src/xml/repr-io.cpp b/src/xml/repr-io.cpp index d8e0f5418..f4b86a140 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; |
