16#include <glibmm/fileutils.h>
17#include <glibmm/miscutils.h>
18#include <giomm/file.h>
34std::unique_ptr<SPDocument>
ink_file_new(std::string
const &Template)
39 std::cerr <<
"ink_file_new: Did not create new document!" << std::endl;
45 for (
auto const name: {
"inkscape:templateinfo",
46 "inkscape:_templateinfo"})
58void set_inkscape_and_svg_versions(
SPRoot *
root)
61 if (
root->inkscape.version) {
62 root->inkscape.original = *
root->inkscape.version;
64 if (
root->svg.version) {
65 root->svg.original = *
root->svg.version;
78 std::cerr <<
"ink_file_open: cannot open file in memory (pipe?)" << std::endl;
81 set_inkscape_and_svg_versions(doc->getRoot());
88std::pair<std::unique_ptr<SPDocument>,
bool>
ink_file_open(Glib::RefPtr<Gio::File>
const &file)
90 std::unique_ptr<SPDocument> doc;
91 std::string path = file->get_path();
100 return {
nullptr,
true};
111 return {
nullptr,
true};
116 std::cerr <<
"ink_file_open: '" << path <<
"' cannot be opened!" << std::endl;
117 return {
nullptr,
false};
120 set_inkscape_and_svg_versions(doc->getRoot());
121 return {std::move(doc),
false};
152 auto path = Glib::path_get_dirname(filepath);
153 auto filename = Glib::build_filename(path,
name);
154 if (Glib::file_test(filename, Glib::FileTest::IS_REGULAR)) {
RAII-style mechanism for creating a temporary undo-insensitive context.
TempFilename(const std::string &pattern)
Create a temporary filename, which is closed and deleted when deconstructed.
Interface for refcounted XML nodes.
static std::unique_ptr< SPDocument > createNewDocFromMem(std::span< char const > buffer, bool keepalive, std::string const &filename="")
static std::unique_ptr< SPDocument > createNewDoc(char const *filename, bool keepalive, bool make_new=false, SPDocument *parent=nullptr)
Fetches document from filename, or creates new, if NULL; public document appears in document list.
TODO: insert short description here.
Inkscape::Extension::Extension: Frontend to certain, possibly pluggable, actions.
Inkscape::XML::Node * node
std::unique_ptr< SPDocument > ink_file_open(std::span< char const > buffer)
Open a document from memory.
std::unique_ptr< SPDocument > ink_file_new(std::string const &Template)
Create a blank document, remove any template data.
DB db
This is the actual database object.
std::unique_ptr< SPDocument > open(Extension *key, char const *filename, bool is_importing)
This is a generic function to use the open function of a module (including Autodetect)
std::string find_original_file(Glib::StdStringView const filepath, Glib::StdStringView const name)
Takes an absolute file path and returns a second file at the same directory location,...
Inkscape::XML::Node const * sp_repr_lookup_name(Inkscape::XML::Node const *repr, gchar const *name, gint maxdepth)
C facade to Inkscape::XML::Node.
void sp_repr_unparent(Inkscape::XML::Node *repr)
Remove repr from children of its parent node.
SPRoot: SVG <svg> implementation.