diff options
| author | Tavmjong Bah <tavmjong@free.fr> | 2019-06-19 08:49:04 +0000 |
|---|---|---|
| committer | Tavmjong Bah <tavmjong@free.fr> | 2019-06-19 08:49:04 +0000 |
| commit | 2892b301b3c9aab0e251759ee2b8a3edba18dc99 (patch) | |
| tree | c9204a8db5ef4f7fde26a3e353ebb533e94ead41 /src/io | |
| parent | fix horizontal palette scrolling for macOS (diff) | |
| download | inkscape-2892b301b3c9aab0e251759ee2b8a3edba18dc99.tar.gz inkscape-2892b301b3c9aab0e251759ee2b8a3edba18dc99.zip | |
Restore ability to pipe a file into Inkscape.
Diffstat (limited to 'src/io')
| -rw-r--r-- | src/io/file.cpp | 23 | ||||
| -rw-r--r-- | src/io/file.h | 1 |
2 files changed, 24 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) { diff --git a/src/io/file.h b/src/io/file.h index 3e1c8ca65..3b53bce4f 100644 --- a/src/io/file.h +++ b/src/io/file.h @@ -14,6 +14,7 @@ class SPDocument; SPDocument* ink_file_new(const std::string &Template = nullptr); +SPDocument* ink_file_open(const Glib::ustring &data); SPDocument* ink_file_open(const Glib::RefPtr<Gio::File>& file, bool &cancelled); // To do: |
