bool ImageIcon::showSvgFromMemory(const char *xmlBuffer) { if (!xmlBuffer) return false; gint len = (gint)strlen(xmlBuffer); SPDocument *doc = sp_document_new_from_mem(xmlBuffer, len, 0); if (!doc) { g_warning("SVGView: error loading buffer '%s'\n",xmlBuffer); return false; } showSvgDocument(doc); sp_document_unref(doc); return true; }
/** \return A new document just for you! \brief This function takes in a filename of a SVG document and turns it into a SPDocument. \param mod Module to use \param uri The path to the file (UTF-8) This function is really simple, it just calls sp_document_new... */ SPDocument * Svg::open (Inkscape::Extension::Input */*mod*/, const gchar *uri) { #ifdef WITH_GNOME_VFS if (!gnome_vfs_initialized() || gnome_vfs_uri_is_local(gnome_vfs_uri_new(uri))) { // Use built-in loader instead of VFS for this return sp_document_new(uri, TRUE); } gchar * buffer = _load_uri(uri); if (buffer == NULL) { g_warning("Error: Could not open file '%s' with VFS\n", uri); return NULL; } SPDocument * doc = sp_document_new_from_mem(buffer, strlen(buffer), 1); g_free(buffer); return doc; #else return sp_document_new (uri, TRUE); #endif }