From 2892b301b3c9aab0e251759ee2b8a3edba18dc99 Mon Sep 17 00:00:00 2001 From: Tavmjong Bah Date: Wed, 19 Jun 2019 10:49:04 +0200 Subject: Restore ability to pipe a file into Inkscape. --- src/io/file.cpp | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) (limited to 'src/io/file.cpp') diff --git a/src/io/file.cpp b/src/io/file.cpp index 294707464..a87453d47 100644 --- a/src/io/file.cpp +++ b/src/io/file.cpp @@ -49,7 +49,30 @@ ink_file_new(const std::string &Template) return doc; } +/** + * Open a document from memory. + */ +SPDocument* +ink_file_open(const Glib::ustring& data) +{ + SPDocument *doc = SPDocument::createNewDocFromMem (data.c_str(), data.length(), true); + + if (doc == nullptr) { + std::cerr << "ink_file_open: cannot open file in memory (pipe?)" << std::endl; + } else { + + // This is the only place original values should be set. + SPRoot *root = doc->getRoot(); + root->original.inkscape = root->version.inkscape; + root->original.svg = root->version.svg; + } + return doc; +} + +/** + * Open a document. + */ SPDocument* ink_file_open(const Glib::RefPtr& file, bool &cancelled) { -- cgit v1.2.3