Inkscape
Vector Graphics Editor
Loading...
Searching...
No Matches
implementation.h
Go to the documentation of this file.
1// SPDX-License-Identifier: GPL-2.0-or-later
2/*
3 Author: Ted Gould <ted@gould.cx>
4 Copyright (c) 2003-2005,2007
5
6 Released under GNU GPL v2+, read the file 'COPYING' for more information.
7
8 This file is the backend to the extensions system. These are
9 the parts of the system that most users will never see, but are
10 important for implementing the extensions themselves. This file
11 contains the base class for all of that.
12*/
13#ifndef SEEN_INKSCAPE_EXTENSION_IMPLEMENTATION_H
14#define SEEN_INKSCAPE_EXTENSION_IMPLEMENTATION_H
15
16#include <vector>
17#include <memory>
18#include <sigc++/signal.h>
19#include <glibmm/value.h>
20#include <2geom/forward.h>
21
22namespace Gtk {
23 class Widget;
24}
25
26class SPDesktop;
27class SPDocument;
28class SPPage;
29class SPStyle;
30class SPItem;
31
32namespace Inkscape {
33
34namespace XML {
35 class Node;
36}
37
38namespace Extension {
39
40class Effect;
41class Extension;
42class Template;
43class TemplatePreset;
44class Input;
45class Output;
46class Print;
47class ExecutionEnv;
48
49typedef std::vector<std::shared_ptr<TemplatePreset>> TemplatePresets;
50
51namespace Implementation {
52
68
75public:
76 // ----- Constructor / destructor -----
77 Implementation() = default;
78
79 virtual ~Implementation() = default;
80
81 // ----- Basic functions for all Extension -----
82 virtual bool load(Inkscape::Extension::Extension * /*module*/) { return true; }
83
84 virtual void unload(Inkscape::Extension::Extension * /*module*/) {}
85
95 virtual ImplementationDocumentCache * newDocCache (Inkscape::Extension::Extension * /*ext*/, SPDesktop * /*desktop*/) { return nullptr; }
96
98 virtual bool check(Inkscape::Extension::Extension * /*module*/) { return true; }
99
100 virtual bool cancelProcessing () { return true; }
101 virtual void commitDocument () {}
102
103 // ---- Template and Page functions -----
104 virtual std::unique_ptr<SPDocument> new_from_template(Inkscape::Extension::Template *);
105 virtual void get_template_presets(const Template *tmod, TemplatePresets &presets) const {};
107 virtual bool match_template_size(Inkscape::Extension::Template *tmod, double width, double height){ return false; }
108
109 // ----- Input functions -----
114 virtual std::unique_ptr<SPDocument> open(Inkscape::Extension::Input *module, char const *filename, bool is_importing);
115
116 // ----- Output functions -----
118 virtual void save(Inkscape::Extension::Output * /*module*/, SPDocument * /*doc*/, gchar const * /*filename*/) {}
129 virtual void export_raster(
131 const SPDocument * doc,
132 std::string const &png_file,
133 gchar const * filename) {}
134
135 // ----- Effect functions -----
137 virtual Gtk::Widget * prefs_effect(Inkscape::Extension::Effect *module,
139 sigc::signal<void ()> *changeSignal,
141 virtual void effect(Inkscape::Extension::Effect * /*module*/, ExecutionEnv * /*executionEnv*/,
142 SPDesktop * /*desktop*/, ImplementationDocumentCache * /*docCache*/);
143 virtual void effect(Inkscape::Extension::Effect * /*module*/, ExecutionEnv * /*executionEnv*/, SPDocument *document)
144 {}
145
146 virtual bool apply_filter(Inkscape::Extension::Effect* module, SPItem* item) { return false; }
147
148 // ----- Print functions -----
149 virtual unsigned setup(Inkscape::Extension::Print * /*module*/) { return 0; }
150 virtual unsigned set_preview(Inkscape::Extension::Print * /*module*/) { return 0; }
151
152 virtual unsigned begin(Inkscape::Extension::Print * /*module*/,
153 SPDocument * /*doc*/) { return 0; }
154 virtual unsigned finish(Inkscape::Extension::Print * /*module*/) { return 0; }
155
163 virtual bool textToPath(Inkscape::Extension::Print * /*ext*/) { return false; }
164
172 virtual bool fontEmbedded(Inkscape::Extension::Print * /*ext*/) { return false; }
173
174 // ----- Rendering methods -----
175 virtual unsigned bind(Inkscape::Extension::Print * /*module*/,
176 Geom::Affine const & /*transform*/,
177 float /*opacity*/) { return 0; }
178 virtual unsigned release(Inkscape::Extension::Print * /*module*/) { return 0; }
179 virtual unsigned fill(Inkscape::Extension::Print * /*module*/,
180 Geom::PathVector const & /*pathv*/,
181 Geom::Affine const & /*ctm*/,
182 SPStyle const * /*style*/,
183 Geom::OptRect const & /*pbox*/,
184 Geom::OptRect const & /*dbox*/,
185 Geom::OptRect const & /*bbox*/) { return 0; }
186 virtual unsigned stroke(Inkscape::Extension::Print * /*module*/,
187 Geom::PathVector const & /*pathv*/,
188 Geom::Affine const & /*transform*/,
189 SPStyle const * /*style*/,
190 Geom::OptRect const & /*pbox*/,
191 Geom::OptRect const & /*dbox*/,
192 Geom::OptRect const & /*bbox*/) { return 0; }
193 virtual unsigned image(Inkscape::Extension::Print * /*module*/,
194 unsigned char * /*px*/,
195 unsigned int /*w*/,
196 unsigned int /*h*/,
197 unsigned int /*rs*/,
198 Geom::Affine const & /*transform*/,
199 SPStyle const * /*style*/) { return 0; }
200 virtual unsigned text(Inkscape::Extension::Print * /*module*/,
201 char const * /*text*/,
202 Geom::Point const & /*p*/,
203 SPStyle const * /*style*/) { return 0; }
204 virtual void processPath(Inkscape::XML::Node * /*node*/) {}
205
209 virtual void setDetachBase(bool detach) {}
210};
211
212
213} // namespace Implementation
214} // namespace Extension
215} // namespace Inkscape
216
217#endif // SEEN_INKSCAPE_EXTENSION_IMPLEMENTATION_H
218
219/*
220 Local Variables:
221 mode:c++
222 c-file-style:"stroustrup"
223 c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +))
224 indent-tabs-mode:nil
225 fill-column:99
226 End:
227*/
228// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4 :
uint64_t page
Definition canvas.cpp:171
3x3 matrix representing an affine transformation.
Definition affine.h:70
Axis-aligned rectangle that can be empty.
Definition rect.h:203
Sequence of subpaths.
Definition pathvector.h:122
Two-dimensional point that doubles as a vector.
Definition point.h:66
Effects are extensions that take a document and do something to it in place.
Definition effect.h:39
The object that is the basis for the Extension system.
Definition extension.h:133
A cache for the document and this implementation.
SPDesktop * _desktop
The document that this instance is working on.
Base class for all implementations of modules.
virtual bool match_template_size(Inkscape::Extension::Template *tmod, double width, double height)
virtual unsigned release(Inkscape::Extension::Print *)
virtual void export_raster(Inkscape::Extension::Output *module, const SPDocument *doc, std::string const &png_file, gchar const *filename)
Convert from PNG to raster format.
virtual bool textToPath(Inkscape::Extension::Print *)
Tell the printing engine whether text should be text or path.
virtual unsigned fill(Inkscape::Extension::Print *, Geom::PathVector const &, Geom::Affine const &, SPStyle const *, Geom::OptRect const &, Geom::OptRect const &, Geom::OptRect const &)
virtual void unload(Inkscape::Extension::Extension *)
virtual unsigned image(Inkscape::Extension::Print *, unsigned char *, unsigned int, unsigned int, unsigned int, Geom::Affine const &, SPStyle const *)
virtual unsigned set_preview(Inkscape::Extension::Print *)
virtual unsigned text(Inkscape::Extension::Print *, char const *, Geom::Point const &, SPStyle const *)
virtual unsigned bind(Inkscape::Extension::Print *, Geom::Affine const &, float)
virtual bool fontEmbedded(Inkscape::Extension::Print *)
Get "fontEmbedded" param, i.e.
virtual std::unique_ptr< SPDocument > new_from_template(Inkscape::Extension::Template *)
virtual bool load(Inkscape::Extension::Extension *)
virtual void get_template_presets(const Template *tmod, TemplatePresets &presets) const
virtual void setDetachBase(bool detach)
If detach = true, when saving to a file, don't store URIs relative to the filename.
virtual Gtk::Widget * prefs_effect(Inkscape::Extension::Effect *module, SPDesktop *desktop, sigc::signal< void()> *changeSignal, ImplementationDocumentCache *docCache)
Find out information about the file.
virtual bool check(Inkscape::Extension::Extension *)
Verify any dependencies.
virtual void save(Inkscape::Extension::Output *, SPDocument *, gchar const *)
Find out information about the file.
virtual void processPath(Inkscape::XML::Node *)
virtual unsigned finish(Inkscape::Extension::Print *)
virtual bool apply_filter(Inkscape::Extension::Effect *module, SPItem *item)
virtual unsigned begin(Inkscape::Extension::Print *, SPDocument *)
virtual std::unique_ptr< SPDocument > open(Inkscape::Extension::Input *module, char const *filename, bool is_importing)
Open a file.
virtual void effect(Inkscape::Extension::Effect *, ExecutionEnv *, SPDocument *document)
virtual ImplementationDocumentCache * newDocCache(Inkscape::Extension::Extension *, SPDesktop *)
Create a new document cache object.
virtual unsigned setup(Inkscape::Extension::Print *)
virtual void resize_to_template(Inkscape::Extension::Template *tmod, SPDocument *doc, SPPage *page)
virtual unsigned stroke(Inkscape::Extension::Print *, Geom::PathVector const &, Geom::Affine const &, SPStyle const *, Geom::OptRect const &, Geom::OptRect const &, Geom::OptRect const &)
virtual void effect(Inkscape::Extension::Effect *, ExecutionEnv *, SPDesktop *, ImplementationDocumentCache *)
Interface for refcounted XML nodes.
Definition node.h:80
To do: update description of desktop.
Definition desktop.h:149
Typed SVG document implementation.
Definition document.h:103
Base class for visual SVG elements.
Definition sp-item.h:109
An SVG style object.
Definition style.h:45
Contains forward declarations of 2geom types.
SPItem * item
Definition desktop.h:50
std::vector< std::shared_ptr< TemplatePreset > > TemplatePresets
Helper class to stream background task notifications as a series of messages.
SPDesktop * desktop
double height
double width