1 /*
2 Author: Ted Gould <ted@gould.cx>
3 Copyright (c) 2003-2005,2007
5 This code is licensed under the GNU GPL. See COPYING for details.
7 This file is the backend to the extensions system. These are
8 the parts of the system that most users will never see, but are
9 important for implementing the extensions themselves. This file
10 contains the base class for all of that.
11 */
13 #ifdef HAVE_CONFIG_H
14 # include <config.h>
15 #endif
16 #include "implementation.h"
18 #include <extension/output.h>
19 #include <extension/input.h>
20 #include <extension/effect.h>
22 #include "selection.h"
23 #include "desktop.h"
24 #include "desktop-handles.h"
25 #include "ui/view/view.h"
26 #include "util/glib-list-iterators.h"
28 namespace Inkscape {
29 namespace Extension {
30 namespace Implementation {
32 /**
33 * \return Was the load sucessful?
34 * \brief This function is the stub load. It just returns success.
35 * \param module The Extension that should be loaded.
36 */
37 bool
38 Implementation::load(Inkscape::Extension::Extension */*module*/) {
39 return TRUE;
40 } /* Implementation::load */
42 void
43 Implementation::unload(Inkscape::Extension::Extension */*module*/) {
44 return;
45 } /* Implementation::unload */
47 /** \brief Create a new document cache object
48 \param ext The extension that is referencing us
49 \param doc The document to create the cache of
50 \return A new document cache that is valid as long as the document
51 is not changed.
53 This function just returns \c NULL. Subclasses are likely
54 to reimplement it to do something useful.
55 */
56 ImplementationDocumentCache *
57 Implementation::newDocCache( Inkscape::Extension::Extension * /*ext*/, Inkscape::UI::View::View * /*view*/ ) {
58 return NULL;
59 }
61 bool
62 Implementation::check(Inkscape::Extension::Extension */*module*/) {
63 /* If there are no checks, they all pass */
64 return TRUE;
65 } /* Implemenation::check */
67 bool
68 Implementation::cancelProcessing (void) {
69 return true;
70 }
72 void
73 Implementation::commitDocument (void) {
74 return;
75 }
77 Gtk::Widget *
78 Implementation::prefs_input(Inkscape::Extension::Input *module, gchar const */*filename*/) {
79 return module->autogui(NULL, NULL);
80 } /* Implementation::prefs_input */
82 SPDocument *
83 Implementation::open(Inkscape::Extension::Input */*module*/, gchar const */*filename*/) {
84 /* throw open_failed(); */
85 return NULL;
86 } /* Implementation::open */
88 Gtk::Widget *
89 Implementation::prefs_output(Inkscape::Extension::Output *module) {
90 return module->autogui(NULL, NULL);
91 } /* Implementation::prefs_output */
93 void
94 Implementation::save(Inkscape::Extension::Output */*module*/, SPDocument */*doc*/, gchar const */*filename*/) {
95 /* throw save_fail */
96 return;
97 } /* Implementation::save */
99 Gtk::Widget *
100 Implementation::prefs_effect(Inkscape::Extension::Effect *module, Inkscape::UI::View::View * view, sigc::signal<void> * changeSignal, ImplementationDocumentCache * docCache) {
101 if (module->param_visible_count() == 0) return NULL;
103 SPDocument * current_document = view->doc();
105 using Inkscape::Util::GSListConstIterator;
106 GSListConstIterator<SPItem *> selected =
107 sp_desktop_selection((SPDesktop *)view)->itemList();
108 Inkscape::XML::Node * first_select = NULL;
109 if (selected != NULL) {
110 const SPItem * item = *selected;
111 first_select = SP_OBJECT_REPR(item);
112 }
114 return module->autogui(current_document, first_select, changeSignal);
115 } /* Implementation::prefs_effect */
117 void
118 Implementation::effect(Inkscape::Extension::Effect */*module*/, Inkscape::UI::View::View */*document*/, ImplementationDocumentCache * /*docCache*/) {
119 /* throw filter_fail */
120 return;
121 } /* Implementation::filter */
123 unsigned int
124 Implementation::setup(Inkscape::Extension::Print */*module*/)
125 {
126 return 0;
127 }
129 unsigned int
130 Implementation::set_preview(Inkscape::Extension::Print */*module*/)
131 {
132 return 0;
133 }
136 unsigned int
137 Implementation::begin(Inkscape::Extension::Print */*module*/, SPDocument */*doc*/)
138 {
139 return 0;
140 }
142 unsigned int
143 Implementation::finish(Inkscape::Extension::Print */*module*/)
144 {
145 return 0;
146 }
149 /* Rendering methods */
150 unsigned int
151 Implementation::bind(Inkscape::Extension::Print */*module*/, Geom::Matrix const */*transform*/, float /*opacity*/)
152 {
153 return 0;
154 }
156 unsigned int
157 Implementation::release(Inkscape::Extension::Print */*module*/)
158 {
159 return 0;
160 }
162 unsigned int
163 Implementation::comment(Inkscape::Extension::Print */*module*/, char const */*comment*/)
164 {
165 return 0;
166 }
168 unsigned int
169 Implementation::fill(Inkscape::Extension::Print */*module*/, Geom::PathVector const &/*pathv*/, Geom::Matrix const */*ctm*/, SPStyle const */*style*/,
170 NRRect const */*pbox*/, NRRect const */*dbox*/, NRRect const */*bbox*/)
171 {
172 return 0;
173 }
175 unsigned int
176 Implementation::stroke(Inkscape::Extension::Print */*module*/, Geom::PathVector const &/*pathv*/, Geom::Matrix const */*transform*/, SPStyle const */*style*/,
177 NRRect const */*pbox*/, NRRect const */*dbox*/, NRRect const */*bbox*/)
178 {
179 return 0;
180 }
182 unsigned int
183 Implementation::image(Inkscape::Extension::Print */*module*/, unsigned char */*px*/, unsigned int /*w*/, unsigned int /*h*/, unsigned int /*rs*/,
184 Geom::Matrix const */*transform*/, SPStyle const */*style*/)
185 {
186 return 0;
187 }
189 unsigned int
190 Implementation::text(Inkscape::Extension::Print */*module*/, char const */*text*/,
191 Geom::Point /*p*/, SPStyle const */*style*/)
192 {
193 return 0;
194 }
196 void
197 Implementation::processPath(Inkscape::XML::Node * /*node*/)
198 {
199 return;
200 }
202 /**
203 \brief Tell the printing engine whether text should be text or path
204 \retval true Render the text as a path
205 \retval false Render text using the text function (above)
207 Default value is false because most printing engines will support
208 paths more than they'll support text. (at least they do today)
209 */
210 bool
211 Implementation::textToPath(Inkscape::Extension::Print */*ext*/)
212 {
213 return false;
214 }
216 /**
217 \brief Get "fontEmbedded" param, i.e. tell the printing engine whether fonts should be embedded
218 \retval TRUE Fonts have to be embedded in the output so that the user might not need to install fonts to have the interpreter read the document correctly
219 \retval FALSE Not embed fonts
221 Only available for Adobe Type 1 fonts in EPS output as of now
222 */
224 bool
225 Implementation::fontEmbedded(Inkscape::Extension::Print * /*ext*/)
226 {
227 return false;
228 }
230 } /* namespace Implementation */
231 } /* namespace Extension */
232 } /* namespace Inkscape */
234 /*
235 Local Variables:
236 mode:c++
237 c-file-style:"stroustrup"
238 c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +))
239 indent-tabs-mode:nil
240 fill-column:99
241 End:
242 */
243 // vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=99 :