diff options
| author | Andrew Higginson <at.higginson@gmail.com> | 2011-12-27 21:04:47 +0000 |
|---|---|---|
| committer | Andrew <at.higginson@gmail.com> | 2011-12-27 21:04:47 +0000 |
| commit | 80960b623a99aae1402ab651b2974ef544ed3b03 (patch) | |
| tree | ba49d42c2789e9e11f805e2d5263e10f9fedeef8 /src/extension/implementation | |
| parent | try to fix bug (diff) | |
| parent | GDL: Cherry-pick upstream patch 73852 (2011-03-23) - Add missing return value. (diff) | |
| download | inkscape-80960b623a99aae1402ab651b2974ef544ed3b03.tar.gz inkscape-80960b623a99aae1402ab651b2974ef544ed3b03.zip | |
merged with trunk so I can build again...
(bzr r10092.1.36)
Diffstat (limited to 'src/extension/implementation')
| -rw-r--r-- | src/extension/implementation/CMakeLists.txt | 5 | ||||
| -rw-r--r-- | src/extension/implementation/implementation.cpp | 174 | ||||
| -rw-r--r-- | src/extension/implementation/implementation.h | 197 | ||||
| -rw-r--r-- | src/extension/implementation/script.cpp | 33 |
4 files changed, 148 insertions, 261 deletions
diff --git a/src/extension/implementation/CMakeLists.txt b/src/extension/implementation/CMakeLists.txt deleted file mode 100644 index 87e1b2541..000000000 --- a/src/extension/implementation/CMakeLists.txt +++ /dev/null @@ -1,5 +0,0 @@ -SET(extension_implementation_SRC -implementation.cpp -xslt.cpp -script.cpp -) diff --git a/src/extension/implementation/implementation.cpp b/src/extension/implementation/implementation.cpp index 63181d0c4..6f6bddb93 100644 --- a/src/extension/implementation/implementation.cpp +++ b/src/extension/implementation/implementation.cpp @@ -29,72 +29,15 @@ namespace Inkscape { namespace Extension { namespace Implementation { -/** - * \return Was the load sucessful? - * \brief This function is the stub load. It just returns success. - * \param module The Extension that should be loaded. - */ -bool -Implementation::load(Inkscape::Extension::Extension */*module*/) { - return TRUE; -} /* Implementation::load */ - -void -Implementation::unload(Inkscape::Extension::Extension */*module*/) { - return; -} /* Implementation::unload */ - -/** \brief Create a new document cache object - \param ext The extension that is referencing us - \param doc The document to create the cache of - \return A new document cache that is valid as long as the document - is not changed. - - This function just returns \c NULL. Subclasses are likely - to reimplement it to do something useful. -*/ -ImplementationDocumentCache * -Implementation::newDocCache( Inkscape::Extension::Extension * /*ext*/, Inkscape::UI::View::View * /*view*/ ) { - return NULL; -} - -bool -Implementation::check(Inkscape::Extension::Extension */*module*/) { - /* If there are no checks, they all pass */ - return TRUE; -} /* Implemenation::check */ - -bool -Implementation::cancelProcessing (void) { - return true; -} - -void -Implementation::commitDocument (void) { - return; -} - Gtk::Widget * Implementation::prefs_input(Inkscape::Extension::Input *module, gchar const */*filename*/) { return module->autogui(NULL, NULL); -} /* Implementation::prefs_input */ - -SPDocument * -Implementation::open(Inkscape::Extension::Input */*module*/, gchar const */*filename*/) { - /* throw open_failed(); */ - return NULL; -} /* Implementation::open */ +} Gtk::Widget * Implementation::prefs_output(Inkscape::Extension::Output *module) { return module->autogui(NULL, NULL); -} /* Implementation::prefs_output */ - -void -Implementation::save(Inkscape::Extension::Output */*module*/, SPDocument */*doc*/, gchar const */*filename*/) { - /* throw save_fail */ - return; -} /* Implementation::save */ +} Gtk::Widget *Implementation::prefs_effect(Inkscape::Extension::Effect *module, Inkscape::UI::View::View * view, sigc::signal<void> * changeSignal, ImplementationDocumentCache * /*docCache*/) { @@ -117,119 +60,6 @@ Gtk::Widget *Implementation::prefs_effect(Inkscape::Extension::Effect *module, I return module->autogui(current_document, const_cast<Inkscape::XML::Node *>(first_select), changeSignal); } // Implementation::prefs_effect -void -Implementation::effect(Inkscape::Extension::Effect */*module*/, Inkscape::UI::View::View */*document*/, ImplementationDocumentCache * /*docCache*/) { - /* throw filter_fail */ - return; -} /* Implementation::filter */ - -unsigned int -Implementation::setup(Inkscape::Extension::Print */*module*/) -{ - return 0; -} - -unsigned int -Implementation::set_preview(Inkscape::Extension::Print */*module*/) -{ - return 0; -} - - -unsigned int -Implementation::begin(Inkscape::Extension::Print */*module*/, SPDocument */*doc*/) -{ - return 0; -} - -unsigned int -Implementation::finish(Inkscape::Extension::Print */*module*/) -{ - return 0; -} - - -/* Rendering methods */ -unsigned int -Implementation::bind(Inkscape::Extension::Print */*module*/, Geom::Affine const */*transform*/, float /*opacity*/) -{ - return 0; -} - -unsigned int -Implementation::release(Inkscape::Extension::Print */*module*/) -{ - return 0; -} - -unsigned int -Implementation::comment(Inkscape::Extension::Print */*module*/, char const */*comment*/) -{ - return 0; -} - -unsigned int -Implementation::fill(Inkscape::Extension::Print */*module*/, Geom::PathVector const &/*pathv*/, Geom::Affine const */*ctm*/, SPStyle const */*style*/, - NRRect const */*pbox*/, NRRect const */*dbox*/, NRRect const */*bbox*/) -{ - return 0; -} - -unsigned int -Implementation::stroke(Inkscape::Extension::Print */*module*/, Geom::PathVector const &/*pathv*/, Geom::Affine const */*transform*/, SPStyle const */*style*/, - NRRect const */*pbox*/, NRRect const */*dbox*/, NRRect const */*bbox*/) -{ - return 0; -} - -unsigned int -Implementation::image(Inkscape::Extension::Print */*module*/, unsigned char */*px*/, unsigned int /*w*/, unsigned int /*h*/, unsigned int /*rs*/, - Geom::Affine const */*transform*/, SPStyle const */*style*/) -{ - return 0; -} - -unsigned int -Implementation::text(Inkscape::Extension::Print */*module*/, char const */*text*/, - Geom::Point /*p*/, SPStyle const */*style*/) -{ - return 0; -} - -void -Implementation::processPath(Inkscape::XML::Node * /*node*/) -{ - return; -} - -/** - \brief Tell the printing engine whether text should be text or path - \retval true Render the text as a path - \retval false Render text using the text function (above) - - Default value is false because most printing engines will support - paths more than they'll support text. (at least they do today) -*/ -bool -Implementation::textToPath(Inkscape::Extension::Print */*ext*/) -{ - return false; -} - -/** - \brief Get "fontEmbedded" param, i.e. tell the printing engine whether fonts should be embedded - \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 - \retval FALSE Not embed fonts - - Only available for Adobe Type 1 fonts in EPS output as of now -*/ - -bool -Implementation::fontEmbedded(Inkscape::Extension::Print * /*ext*/) -{ - return false; -} - } /* namespace Implementation */ } /* namespace Extension */ } /* namespace Inkscape */ diff --git a/src/extension/implementation/implementation.h b/src/extension/implementation/implementation.h index bf584b401..32cc37402 100644 --- a/src/extension/implementation/implementation.h +++ b/src/extension/implementation/implementation.h @@ -9,27 +9,46 @@ important for implementing the extensions themselves. This file contains the base class for all of that. */ -#ifndef __INKSCAPE_EXTENSION_IMPLEMENTATION_H__ -#define __INKSCAPE_EXTENSION_IMPLEMENTATION_H__ +#ifndef SEEN_INKSCAPE_EXTENSION_IMPLEMENTATION_H +#define SEEN_INKSCAPE_EXTENSION_IMPLEMENTATION_H -#include <gtk/gtkdialog.h> +#include <gtk/gtk.h> #include <gdkmm/types.h> #include <gtkmm/widget.h> -#include "forward.h" -#include "extension/extension-forward.h" -#include "libnr/nr-forward.h" -#include "libnr/nr-point.h" #include "xml/node.h" #include <2geom/forward.h> +#include <2geom/point.h> + +class SPDocument; +class SPStyle; namespace Inkscape { + +namespace UI { +namespace View { +class View; +} // namespace View +} // namespace UI + namespace Extension { + +class Effect; +class Extension; +class Input; +class Output; +class Print; + namespace Implementation { -/** \brief A cache for the document and this implementation */ +/** + * A cache for the document and this implementation. + */ class ImplementationDocumentCache { - /** \brief The document that this instance is working on */ + + /** + * The document that this instance is working on. + */ Inkscape::UI::View::View * _view; public: ImplementationDocumentCache (Inkscape::UI::View::View * view) : @@ -48,96 +67,122 @@ public: */ class Implementation { public: - /* ----- Constructor / destructor ----- */ + // ----- Constructor / destructor ----- Implementation() {} virtual ~Implementation() {} - /* ----- Basic functions for all Extension ----- */ - virtual bool load(Inkscape::Extension::Extension *module); + // ----- Basic functions for all Extension ----- + virtual bool load(Inkscape::Extension::Extension * /*module*/) { return true; } - virtual void unload(Inkscape::Extension::Extension *module); - virtual ImplementationDocumentCache * newDocCache (Inkscape::Extension::Extension * ext, Inkscape::UI::View::View * doc); + virtual void unload(Inkscape::Extension::Extension * /*module*/) {} + + /** + * Create a new document cache object. + * This function just returns \c NULL. Subclasses are likely + * to reimplement it to do something useful. + * @param ext The extension that is referencing us + * @param doc The document to create the cache of + * @return A new document cache that is valid as long as the document + * is not changed. + */ + virtual ImplementationDocumentCache * newDocCache (Inkscape::Extension::Extension * /*ext*/, Inkscape::UI::View::View * /*doc*/) { return NULL; } /** Verify any dependencies. */ - virtual bool check(Inkscape::Extension::Extension *module); + virtual bool check(Inkscape::Extension::Extension * /*module*/) { return true; } - virtual bool cancelProcessing (void); - virtual void commitDocument (void); + virtual bool cancelProcessing () { return true; } + virtual void commitDocument () {} - /* ----- Input functions ----- */ + // ----- Input functions ----- /** Find out information about the file. */ virtual Gtk::Widget *prefs_input(Inkscape::Extension::Input *module, gchar const *filename); - virtual SPDocument *open(Inkscape::Extension::Input *module, - gchar const *filename); + virtual SPDocument *open(Inkscape::Extension::Input * /*module*/, + gchar const * /*filename*/) { return NULL; } - /* ----- Output functions ----- */ + // ----- Output functions ----- /** Find out information about the file. */ virtual Gtk::Widget *prefs_output(Inkscape::Extension::Output *module); - virtual void save(Inkscape::Extension::Output *module, SPDocument *doc, gchar const *filename); + virtual void save(Inkscape::Extension::Output * /*module*/, SPDocument * /*doc*/, gchar const * /*filename*/) {} - /* ----- Effect functions ----- */ + // ----- Effect functions ----- /** Find out information about the file. */ virtual Gtk::Widget * prefs_effect(Inkscape::Extension::Effect *module, - Inkscape::UI::View::View * view, - sigc::signal<void> * changeSignal, - ImplementationDocumentCache * docCache); - virtual void effect(Inkscape::Extension::Effect *module, - Inkscape::UI::View::View *document, - ImplementationDocumentCache * docCache); - - /* ----- Print functions ----- */ - virtual unsigned setup(Inkscape::Extension::Print *module); - virtual unsigned set_preview(Inkscape::Extension::Print *module); - - virtual unsigned begin(Inkscape::Extension::Print *module, - SPDocument *doc); - virtual unsigned finish(Inkscape::Extension::Print *module); - virtual bool textToPath(Inkscape::Extension::Print *ext); - virtual bool fontEmbedded(Inkscape::Extension::Print * ext); - - /* ----- Rendering methods ----- */ - virtual unsigned bind(Inkscape::Extension::Print *module, - Geom::Affine const *transform, - float opacity); - virtual unsigned release(Inkscape::Extension::Print *module); - virtual unsigned comment(Inkscape::Extension::Print *module, const char * comment); - virtual unsigned fill(Inkscape::Extension::Print *module, - Geom::PathVector const &pathv, - Geom::Affine const *ctm, - SPStyle const *style, - NRRect const *pbox, - NRRect const *dbox, - NRRect const *bbox); - virtual unsigned stroke(Inkscape::Extension::Print *module, - Geom::PathVector const &pathv, - Geom::Affine const *transform, - SPStyle const *style, - NRRect const *pbox, - NRRect const *dbox, - NRRect const *bbox); - virtual unsigned image(Inkscape::Extension::Print *module, - unsigned char *px, - unsigned int w, - unsigned int h, - unsigned int rs, - Geom::Affine const *transform, - SPStyle const *style); - virtual unsigned text(Inkscape::Extension::Print *module, - char const *text, - Geom::Point p, - SPStyle const *style); - virtual void processPath(Inkscape::XML::Node * node); + Inkscape::UI::View::View *view, + sigc::signal<void> *changeSignal, + ImplementationDocumentCache *docCache); + virtual void effect(Inkscape::Extension::Effect * /*module*/, + Inkscape::UI::View::View * /*document*/, + ImplementationDocumentCache * /*docCache*/) {} + + // ----- Print functions ----- + virtual unsigned setup(Inkscape::Extension::Print * /*module*/) { return 0; } + virtual unsigned set_preview(Inkscape::Extension::Print * /*module*/) { return 0; } + + virtual unsigned begin(Inkscape::Extension::Print * /*module*/, + SPDocument * /*doc*/) { return 0; } + virtual unsigned finish(Inkscape::Extension::Print * /*module*/) { return 0; } + + /** + * Tell the printing engine whether text should be text or path. + * Default value is false because most printing engines will support + * paths more than they'll support text. (at least they do today) + * \retval true Render the text as a path + * \retval false Render text using the text function (above) + */ + virtual bool textToPath(Inkscape::Extension::Print * /*ext*/) { return false; } + + /** + * Get "fontEmbedded" param, i.e. tell the printing engine whether fonts should be embedded. + * Only available for Adobe Type 1 fonts in EPS output as of now + * \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 + * \retval false Do not embed fonts + */ + virtual bool fontEmbedded(Inkscape::Extension::Print * /*ext*/) { return false; } + + // ----- Rendering methods ----- + virtual unsigned bind(Inkscape::Extension::Print * /*module*/, + Geom::Affine const & /*transform*/, + float /*opacity*/) { return 0; } + virtual unsigned release(Inkscape::Extension::Print * /*module*/) { return 0; } + virtual unsigned comment(Inkscape::Extension::Print * /*module*/, char const * /*comment*/) { return 0; } + virtual unsigned fill(Inkscape::Extension::Print * /*module*/, + Geom::PathVector const & /*pathv*/, + Geom::Affine const & /*ctm*/, + SPStyle const * /*style*/, + Geom::OptRect const & /*pbox*/, + Geom::OptRect const & /*dbox*/, + Geom::OptRect const & /*bbox*/) { return 0; } + virtual unsigned stroke(Inkscape::Extension::Print * /*module*/, + Geom::PathVector const & /*pathv*/, + Geom::Affine const & /*transform*/, + SPStyle const * /*style*/, + Geom::OptRect const & /*pbox*/, + Geom::OptRect const & /*dbox*/, + Geom::OptRect const & /*bbox*/) { return 0; } + virtual unsigned image(Inkscape::Extension::Print * /*module*/, + unsigned char * /*px*/, + unsigned int /*w*/, + unsigned int /*h*/, + unsigned int /*rs*/, + Geom::Affine const & /*transform*/, + SPStyle const * /*style*/) { return 0; } + virtual unsigned text(Inkscape::Extension::Print * /*module*/, + char const * /*text*/, + Geom::Point const & /*p*/, + SPStyle const * /*style*/) { return 0; } + virtual void processPath(Inkscape::XML::Node * /*node*/) {} }; -} /* namespace Implementation */ -} /* namespace Extension */ -} /* namespace Inkscape */ +} // namespace Implementation +} // namespace Extension +} // namespace Inkscape -#endif /* __INKSCAPE_EXTENSION_IMPLEMENTATION_H__ */ +#endif // __INKSCAPE_EXTENSION_IMPLEMENTATION_H__ /* Local Variables: diff --git a/src/extension/implementation/script.cpp b/src/extension/implementation/script.cpp index 2f3e2cd65..0a0282284 100644 --- a/src/extension/implementation/script.cpp +++ b/src/extension/implementation/script.cpp @@ -149,7 +149,8 @@ std::string Script::resolveInterpreterExecutable(const Glib::ustring &interpName of memory in the unloaded state. */ Script::Script() : - Implementation() + Implementation(), + _canceled(false) { } @@ -177,8 +178,7 @@ Script::~Script() string. This means that the caller of this function can always free what they are given (and should do it too!). */ -std::string -Script::solve_reldir(Inkscape::XML::Node *reprin) { +std::string Script::solve_reldir(Inkscape::XML::Node *reprin) { gchar const *s = reprin->attribute("reldir"); @@ -361,8 +361,7 @@ void Script::unload(Inkscape::Extension::Extension */*module*/) \param module The Extension in question */ -bool -Script::check(Inkscape::Extension::Extension *module) +bool Script::check(Inkscape::Extension::Extension *module) { int script_count = 0; Inkscape::XML::Node *child_repr = sp_repr_children(module->get_repr()); @@ -729,8 +728,26 @@ void Script::effect(Inkscape::Extension::Effect *module, doc->doc()->emitReconstructionStart(); copy_doc(doc->doc()->rroot, mydoc->rroot); doc->doc()->emitReconstructionFinish(); - mydoc->release(); + SPObject *layer = NULL; + SPObject *obj = mydoc->getObjectById("base"); + + // Getting the named view from the document generated by the extension + SPNamedView *nv = (SPNamedView *) obj; + + //Check if it has a default layer set up + if ( nv != NULL and nv->default_layer_id != 0 ) { + SPDocument *document = desktop->doc(); + //If so, get that layer + layer = document->getObjectById(g_quark_to_string(nv->default_layer_id)); + } + sp_namedview_update_layers_from_document(desktop); + //If that layer exists, + if (layer) { + //set the current layer + desktop->setCurrentLayer(layer); + } + mydoc->release(); } return; @@ -803,7 +820,7 @@ void Script::copy_doc (Inkscape::XML::Node * oldroot, Inkscape::XML::Node * newr } // Delete the attributes of the old root nodes. - for (std::vector<gchar const *>::const_iterator it = attribs.begin(); it != attribs.end(); it++) { + for (std::vector<gchar const *>::const_iterator it = attribs.begin(); it != attribs.end(); ++it) { oldroot->setAttribute(*it, NULL); } @@ -954,7 +971,7 @@ int Script::execute (const std::list<std::string> &in_command, NULL, // STDIN &stdout_pipe, // STDOUT &stderr_pipe); // STDERR - } catch (Glib::Error e) { + } catch (Glib::Error &e) { printf("Can't Spawn!!! spawn returns: %s\n", e.what().data()); return 0; } |
