summaryrefslogtreecommitdiffstats
path: root/src/io/file.cpp
diff options
context:
space:
mode:
authorTavmjong Bah <tavmjong@free.fr>2019-06-19 08:49:04 +0000
committerTavmjong Bah <tavmjong@free.fr>2019-06-19 08:49:04 +0000
commit2892b301b3c9aab0e251759ee2b8a3edba18dc99 (patch)
treec9204a8db5ef4f7fde26a3e353ebb533e94ead41 /src/io/file.cpp
parentfix horizontal palette scrolling for macOS (diff)
downloadinkscape-2892b301b3c9aab0e251759ee2b8a3edba18dc99.tar.gz
inkscape-2892b301b3c9aab0e251759ee2b8a3edba18dc99.zip
Restore ability to pipe a file into Inkscape.
Diffstat (limited to 'src/io/file.cpp')
-rw-r--r--src/io/file.cpp23
1 files changed, 23 insertions, 0 deletions
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<Gio::File>& file, bool &cancelled)
{