diff options
Diffstat (limited to 'src/io/file.cpp')
| -rw-r--r-- | src/io/file.cpp | 23 |
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) { |
