diff options
| author | Liam P. White <inkscapebrony@gmail.com> | 2015-02-25 01:48:17 +0000 |
|---|---|---|
| committer | Liam P. White <inkscapebrony@gmail.com> | 2015-02-25 01:48:17 +0000 |
| commit | 9b72cebb7ccb500cf447bf75b66fe77875d9945a (patch) | |
| tree | 5110bf55e68dee4b60030f2008a7127ff347c065 | |
| parent | Translations. Hungarian translation update. (diff) | |
| parent | Restore libinkscape.a (diff) | |
| download | inkscape-9b72cebb7ccb500cf447bf75b66fe77875d9945a.tar.gz inkscape-9b72cebb7ccb500cf447bf75b66fe77875d9945a.zip | |
Restore libinkscape.a .
I have a feeling this will be a controversial commit, and I feel the same way:
I liked the way the SPObject factories were set up. However, they placed undue
stress on the linker to extract every single symbol from every object file,
and this isn't something that it easy for the linker: it continually thrashes
my system with 8 GB of RAM for more and more memory, with my system often times
running out.
This is not the only solution, but for now, it's quite a good one, and the
comment in Makefile.am remains true: libinkscape.a does speed up the build. In
the future, I'd hope to see proper code modules and an incremental link, which
should really help speed up the build.
(bzr r13940)
113 files changed, 477 insertions, 1354 deletions
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 617e9dce1..ddb715f55 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -19,6 +19,7 @@ set(sp_SRC sp-defs.cpp sp-desc.cpp sp-ellipse.cpp + sp-factory.cpp sp-filter-primitive.cpp sp-filter-reference.cpp sp-filter.cpp diff --git a/src/Makefile.am b/src/Makefile.am index 8fb7e23ef..1945c6f12 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -23,6 +23,7 @@ endif noinst_LIBRARIES = \ + libinkscape.a \ libcroco/libcroco.a \ libavoid/libavoid.a \ $(internal_GDL) \ @@ -194,13 +195,13 @@ DISTCLEANFILES = \ # ################################################ # this should speed up the build -#libinkscape_a_SOURCES = $(ink_common_sources) +libinkscape_a_SOURCES = $(ink_common_sources) -inkscape_SOURCES += main.cpp $(ink_common_sources) $(win32_sources) +inkscape_SOURCES += main.cpp $(win32_sources) inkscape_LDADD = $(all_libs) inkscape_LDFLAGS = $(kdeldflags) $(mwindows) -inkview_SOURCES += inkview.cpp $(ink_common_sources) $(win32_sources) +inkview_SOURCES += inkview.cpp $(win32_sources) inkview_LDADD = $(all_libs) inkview_LDFLAGS = $(mwindows) diff --git a/src/Makefile_insert b/src/Makefile_insert index b07541109..ea4755bb5 100644 --- a/src/Makefile_insert +++ b/src/Makefile_insert @@ -124,7 +124,7 @@ ink_common_sources += \ sp-defs.cpp sp-defs.h \ sp-desc.cpp sp-desc.h \ sp-ellipse.cpp sp-ellipse.h \ - sp-factory.h \ + sp-factory.h sp-factory.cpp \ sp-filter.cpp sp-filter.h number-opt-number.h \ sp-filter-primitive.cpp sp-filter-primitive.h \ sp-filter-reference.cpp sp-filter-reference.h \ diff --git a/src/box3d-side.cpp b/src/box3d-side.cpp index 3058eab2d..93d55232e 100644 --- a/src/box3d-side.cpp +++ b/src/box3d-side.cpp @@ -28,16 +28,6 @@ static void box3d_side_compute_corner_ids(Box3DSide *side, unsigned int corners[4]); -#include "sp-factory.h" - -namespace { - SPObject* createBox3DSide() { - return new Box3DSide(); - } - - bool box3DSideRegistered = SPFactory::instance().registerObject("inkscape:box3dside", createBox3DSide); -} - Box3DSide::Box3DSide() : SPPolygon() { this->dir1 = Box3D::NONE; this->dir2 = Box3D::NONE; diff --git a/src/box3d.cpp b/src/box3d.cpp index 86f99049b..dc04a2eb6 100644 --- a/src/box3d.cpp +++ b/src/box3d.cpp @@ -44,16 +44,6 @@ static void box3d_ref_changed(SPObject *old_ref, SPObject *ref, SPBox3D *box); static gint counter = 0; -#include "sp-factory.h" - -namespace { - SPObject* createBox3D() { - return new SPBox3D(); - } - - bool box3DRegistered = SPFactory::instance().registerObject("inkscape:box3d", createBox3D); -} - SPBox3D::SPBox3D() : SPGroup() { this->my_counter = 0; this->swapped = Box3D::NONE; diff --git a/src/color-profile.cpp b/src/color-profile.cpp index 28550b75d..85a6fa876 100644 --- a/src/color-profile.cpp +++ b/src/color-profile.cpp @@ -185,17 +185,6 @@ cmsHPROFILE ColorProfileImpl::getNULLProfile() { #endif // defined(HAVE_LIBLCMS1) || defined(HAVE_LIBLCMS2) - -#include "sp-factory.h" - -namespace { - SPObject* createColorProfile() { - return new Inkscape::ColorProfile(); - } - - bool rectRegistered = SPFactory::instance().registerObject("svg:color-profile", createColorProfile); -} - ColorProfile::ColorProfile() : SPObject() { this->impl = new ColorProfileImpl(); diff --git a/src/desktop.cpp b/src/desktop.cpp index cdf8f276c..1152184c9 100644 --- a/src/desktop.cpp +++ b/src/desktop.cpp @@ -687,7 +687,7 @@ void SPDesktop::set_event_context2(const std::string& toolName) } } - Inkscape::UI::Tools::ToolBase* new_tool = ToolFactory::instance().createObject(toolName); + Inkscape::UI::Tools::ToolBase* new_tool = ToolFactory::createObject(toolName); new_tool->desktop = this; new_tool->message_context = new Inkscape::MessageContext(this->messageStack()); event_context = new_tool; diff --git a/src/document.cpp b/src/document.cpp index 11971e63d..2a50d00bd 100644 --- a/src/document.cpp +++ b/src/document.cpp @@ -368,7 +368,7 @@ SPDocument *SPDocument::createDoc(Inkscape::XML::Document *rdoc, // Create SPRoot element const std::string typeString = NodeTraits::get_type_string(*rroot); - SPObject* rootObj = SPFactory::instance().createObject(typeString); + SPObject* rootObj = SPFactory::createObject(typeString); document->root = dynamic_cast<SPRoot*>(rootObj); if (document->root == 0) { diff --git a/src/factory.h b/src/factory.h deleted file mode 100644 index c1288b460..000000000 --- a/src/factory.h +++ /dev/null @@ -1,123 +0,0 @@ -/** @file - * Generic Factory - *//* - * Authors: - * Markus Engel - * - * Copyright (C) 2013 Authors - * Released under GNU GPL, read the file 'COPYING' for more information - */ - -#ifndef FACTORY_H_SEEN -#define FACTORY_H_SEEN - -#include <exception> -#include <map> -#include <string> -#include "xml/node.h" - -/** - * A simple singleton implementation. - */ -template <class T> -struct Singleton { - static T &instance() { - static T inst; - return inst; - } -}; - -namespace FactoryExceptions { -class TypeNotRegistered : public std::exception { -public: - TypeNotRegistered(std::string const &type) - : std::exception() - , _type_string(type) { - } - - virtual ~TypeNotRegistered() throw() { - } - - char const *what() const throw() { - return _type_string.c_str(); - } - -private: - std::string const _type_string; -}; -} // namespace FactoryExceptions - -/** - * A Factory for creating objects which can be identified by strings. - */ -template <class BaseObject> -class Factory { -public: - typedef BaseObject *CreateFunction(); - - bool registerObject(std::string const &id, CreateFunction *creator) { - return this->_object_map.insert(std::make_pair(id, creator)).second; - } - - BaseObject *createObject(std::string const &id) const { - typename std::map<std::string const, CreateFunction *>::const_iterator it = this->_object_map.find(id); - - if (it == this->_object_map.end()) { - //throw FactoryExceptions::TypeNotRegistered(id); - if (!(id.empty() // comments, usually - || id == "rdf:RDF" // no SP node yet - || id == "inkscape:clipboard" // SP node not necessary - || id == "inkscape:_templateinfo")) { - g_warning("unknown type: %s", id.c_str()); - } - return NULL; - } - - return it->second(); - } - -private: - std::map<std::string const, CreateFunction *> _object_map; -}; - - -struct NodeTraits { - static std::string get_type_string(Inkscape::XML::Node const &node) { - std::string name; - - switch (node.type()) { - case Inkscape::XML::TEXT_NODE: - name = "string"; - break; - - case Inkscape::XML::ELEMENT_NODE: { - char const *const sptype = node.attribute("sodipodi:type"); - - if (sptype) { - name = sptype; - } else { - name = node.name(); - } - break; - } - default: - name = ""; - break; - } - - return name; - } -}; - -#endif - -/* - Local Variables: - mode:c++ - c-file-style:"stroustrup" - c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +)) - indent-tabs-mode:nil - fill-column:99 - End: -*/ -// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:fileencoding=utf-8:textwidth=99 : diff --git a/src/filters/blend.cpp b/src/filters/blend.cpp index ca1d5bf96..6e92ef50f 100644 --- a/src/filters/blend.cpp +++ b/src/filters/blend.cpp @@ -13,10 +13,6 @@ * Released under GNU GPL, read the file 'COPYING' for more information */ -#ifdef HAVE_CONFIG_H -# include "config.h" -#endif - #include <string.h> #include "sp-filter.h" @@ -30,16 +26,6 @@ #include "display/nr-filter-blend.h" #include "display/nr-filter-types.h" -#include "sp-factory.h" - -namespace { - SPObject* createBlend() { - return new SPFeBlend(); - } - - bool blendRegistered = SPFactory::instance().registerObject("svg:feBlend", createBlend); -} - SPFeBlend::SPFeBlend() : SPFilterPrimitive(), blend_mode(Inkscape::Filters::BLEND_NORMAL), in2(Inkscape::Filters::NR_FILTER_SLOT_NOT_SET) diff --git a/src/filters/colormatrix.cpp b/src/filters/colormatrix.cpp index 58f601a65..a7f0296c2 100644 --- a/src/filters/colormatrix.cpp +++ b/src/filters/colormatrix.cpp @@ -14,10 +14,6 @@ * Released under GNU GPL, read the file 'COPYING' for more information */ -#ifdef HAVE_CONFIG_H -# include "config.h" -#endif - #include <string.h> #include "attributes.h" @@ -29,16 +25,6 @@ #include "display/nr-filter.h" #include "display/nr-filter-colormatrix.h" -#include "sp-factory.h" - -namespace { - SPObject* createColorMatrix() { - return new SPFeColorMatrix(); - } - - bool colorMatrixRegistered = SPFactory::instance().registerObject("svg:feColorMatrix", createColorMatrix); -} - SPFeColorMatrix::SPFeColorMatrix() : SPFilterPrimitive(), type(Inkscape::Filters::COLORMATRIX_MATRIX), value(0) { diff --git a/src/filters/componenttransfer-funcnode.cpp b/src/filters/componenttransfer-funcnode.cpp index d8c5b0d49..76e99a648 100644 --- a/src/filters/componenttransfer-funcnode.cpp +++ b/src/filters/componenttransfer-funcnode.cpp @@ -13,10 +13,6 @@ * Released under GNU GPL, read the file 'COPYING' for more information */ -#ifdef HAVE_CONFIG_H -# include "config.h" -#endif - #include <glib.h> #include "attributes.h" @@ -31,32 +27,6 @@ #include "macros.h" -#include "sp-factory.h" - -namespace { - SPObject* createFuncR() { - return new SPFeFuncNode(SPFeFuncNode::R); - } - - SPObject* createFuncG() { - return new SPFeFuncNode(SPFeFuncNode::G); - } - - SPObject* createFuncB() { - return new SPFeFuncNode(SPFeFuncNode::B); - } - - SPObject* createFuncA() { - return new SPFeFuncNode(SPFeFuncNode::A); - } - - bool funcRRegistered = SPFactory::instance().registerObject("svg:feFuncR", createFuncR); - bool funcGRegistered = SPFactory::instance().registerObject("svg:feFuncG", createFuncG); - bool funcBRegistered = SPFactory::instance().registerObject("svg:feFuncB", createFuncB); - bool funcARegistered = SPFactory::instance().registerObject("svg:feFuncA", createFuncA); -} - - /* FeFuncNode class */ SPFeFuncNode::SPFeFuncNode(SPFeFuncNode::Channel channel) : SPObject(), type(Inkscape::Filters::COMPONENTTRANSFER_TYPE_IDENTITY), diff --git a/src/filters/componenttransfer.cpp b/src/filters/componenttransfer.cpp index 610b3dd02..3d0264390 100644 --- a/src/filters/componenttransfer.cpp +++ b/src/filters/componenttransfer.cpp @@ -12,10 +12,6 @@ * Released under GNU GPL, read the file 'COPYING' for more information */ -#ifdef HAVE_CONFIG_H -# include "config.h" -#endif - #include <string.h> #include "document.h" @@ -27,16 +23,6 @@ #include "display/nr-filter.h" #include "display/nr-filter-component-transfer.h" -#include "sp-factory.h" - -namespace { - SPObject* createComponentTransfer() { - return new SPFeComponentTransfer(); - } - - bool componentTransferRegistered = SPFactory::instance().registerObject("svg:feComponentTransfer", createComponentTransfer); -} - SPFeComponentTransfer::SPFeComponentTransfer() : SPFilterPrimitive(), renderer(NULL) { diff --git a/src/filters/composite.cpp b/src/filters/composite.cpp index e600b6d20..3e651a778 100644 --- a/src/filters/composite.cpp +++ b/src/filters/composite.cpp @@ -12,10 +12,6 @@ * Released under GNU GPL, read the file 'COPYING' for more information */ -#ifdef HAVE_CONFIG_H -# include "config.h" -#endif - #include "attributes.h" #include "svg/svg.h" #include "filters/composite.h" @@ -25,16 +21,6 @@ #include "display/nr-filter-composite.h" #include "sp-filter.h" -#include "sp-factory.h" - -namespace { - SPObject* createComposite() { - return new SPFeComposite(); - } - - bool compositeRegistered = SPFactory::instance().registerObject("svg:feComposite", createComposite); -} - SPFeComposite::SPFeComposite() : SPFilterPrimitive(), composite_operator(COMPOSITE_DEFAULT), k1(0), k2(0), k3(0), k4(0), in2(Inkscape::Filters::NR_FILTER_SLOT_NOT_SET) diff --git a/src/filters/convolvematrix.cpp b/src/filters/convolvematrix.cpp index bd710b116..3a443bebc 100644 --- a/src/filters/convolvematrix.cpp +++ b/src/filters/convolvematrix.cpp @@ -13,10 +13,6 @@ * Released under GNU GPL, read the file 'COPYING' for more information */ -#ifdef HAVE_CONFIG_H -# include "config.h" -#endif - #include <string.h> #include <math.h> #include <vector> @@ -28,16 +24,6 @@ #include "display/nr-filter.h" #include "display/nr-filter-convolve-matrix.h" -#include "sp-factory.h" - -namespace { - SPObject* createConvolveMatrix() { - return new SPFeConvolveMatrix(); - } - - bool convolveMatrixRegistered = SPFactory::instance().registerObject("svg:feConvolveMatrix", createConvolveMatrix); -} - SPFeConvolveMatrix::SPFeConvolveMatrix() : SPFilterPrimitive() { this->bias = 0; this->divisorIsSet = 0; diff --git a/src/filters/diffuselighting.cpp b/src/filters/diffuselighting.cpp index 09179a69d..120c058d2 100644 --- a/src/filters/diffuselighting.cpp +++ b/src/filters/diffuselighting.cpp @@ -14,10 +14,6 @@ * Released under GNU GPL, read the file 'COPYING' for more information */ -#ifdef HAVE_CONFIG_H -# include "config.h" -#endif - #include "strneq.h" #include "attributes.h" @@ -36,16 +32,6 @@ /* FeDiffuseLighting base class */ static void sp_feDiffuseLighting_children_modified(SPFeDiffuseLighting *sp_diffuselighting); -#include "sp-factory.h" - -namespace { - SPObject* createDiffuseLighting() { - return new SPFeDiffuseLighting(); - } - - bool diffuseLightingRegistered = SPFactory::instance().registerObject("svg:feDiffuseLighting", createDiffuseLighting); -} - SPFeDiffuseLighting::SPFeDiffuseLighting() : SPFilterPrimitive() { this->surfaceScale = 1; this->diffuseConstant = 1; diff --git a/src/filters/displacementmap.cpp b/src/filters/displacementmap.cpp index 7dedfc031..1dbea67ff 100644 --- a/src/filters/displacementmap.cpp +++ b/src/filters/displacementmap.cpp @@ -12,10 +12,6 @@ * Released under GNU GPL, read the file 'COPYING' for more information */ -#ifdef HAVE_CONFIG_H -# include "config.h" -#endif - #include "attributes.h" #include "svg/svg.h" #include "filters/displacementmap.h" @@ -25,16 +21,6 @@ #include "display/nr-filter.h" #include "display/nr-filter-displacement-map.h" -#include "sp-factory.h" - -namespace { - SPObject* createDisplacementMap() { - return new SPFeDisplacementMap(); - } - - bool displacementMapRegistered = SPFactory::instance().registerObject("svg:feDisplacementMap", createDisplacementMap); -} - SPFeDisplacementMap::SPFeDisplacementMap() : SPFilterPrimitive() { this->scale=0; this->xChannelSelector = DISPLACEMENTMAP_CHANNEL_ALPHA; diff --git a/src/filters/distantlight.cpp b/src/filters/distantlight.cpp index bd8bd2797..fb7380174 100644 --- a/src/filters/distantlight.cpp +++ b/src/filters/distantlight.cpp @@ -13,10 +13,6 @@ * Released under GNU GPL, read the file 'COPYING' for more information */ -#ifdef HAVE_CONFIG_H -# include "config.h" -#endif - #include <glib.h> #include "attributes.h" @@ -30,17 +26,6 @@ #include "macros.h" -#include "sp-factory.h" - -namespace { - SPObject* createDistantLight() { - return new SPFeDistantLight(); - } - - bool distantLightRegistered = SPFactory::instance().registerObject("svg:feDistantLight", createDistantLight); -} - - SPFeDistantLight::SPFeDistantLight() : SPObject(), azimuth(0), azimuth_set(FALSE), elevation(0), elevation_set(FALSE) { } diff --git a/src/filters/flood.cpp b/src/filters/flood.cpp index 134492d34..94ca61b98 100644 --- a/src/filters/flood.cpp +++ b/src/filters/flood.cpp @@ -12,10 +12,6 @@ * Released under GNU GPL, read the file 'COPYING' for more information */ -#ifdef HAVE_CONFIG_H -# include "config.h" -#endif - #include "strneq.h" #include "attributes.h" @@ -27,16 +23,6 @@ #include "display/nr-filter.h" #include "display/nr-filter-flood.h" -#include "sp-factory.h" - -namespace { - SPObject* createFlood() { - return new SPFeFlood(); - } - - bool floodRegistered = SPFactory::instance().registerObject("svg:feFlood", createFlood); -} - SPFeFlood::SPFeFlood() : SPFilterPrimitive() { this->color = 0; diff --git a/src/filters/gaussian-blur.cpp b/src/filters/gaussian-blur.cpp index fc1e65925..43a1f6dfb 100644 --- a/src/filters/gaussian-blur.cpp +++ b/src/filters/gaussian-blur.cpp @@ -27,19 +27,6 @@ #include "display/nr-filter-gaussian.h" #include "display/nr-filter-types.h" -//#define SP_MACROS_SILENT -//#include "macros.h" - -#include "sp-factory.h" - -namespace { - SPObject* createGaussianBlur() { - return new SPGaussianBlur(); - } - - bool gaussianBlurRegistered = SPFactory::instance().registerObject("svg:feGaussianBlur", createGaussianBlur); -} - SPGaussianBlur::SPGaussianBlur() : SPFilterPrimitive() { } diff --git a/src/filters/image.cpp b/src/filters/image.cpp index 116939e0f..62e8b76b9 100644 --- a/src/filters/image.cpp +++ b/src/filters/image.cpp @@ -14,10 +14,6 @@ * Released under GNU GPL, read the file 'COPYING' for more information */ -#ifdef HAVE_CONFIG_H -# include "config.h" -#endif - #include <sigc++/bind.h> #include "display/nr-filter-image.h" #include "uri.h" @@ -31,16 +27,6 @@ #include "display/nr-filter.h" -#include "sp-factory.h" - -namespace { - SPObject* createImage() { - return new SPFeImage(); - } - - bool imageRegistered = SPFactory::instance().registerObject("svg:feImage", createImage); -} - SPFeImage::SPFeImage() : SPFilterPrimitive() { this->href = NULL; this->from_element = 0; diff --git a/src/filters/merge.cpp b/src/filters/merge.cpp index 882ab36dd..68f671b11 100644 --- a/src/filters/merge.cpp +++ b/src/filters/merge.cpp @@ -11,10 +11,6 @@ * Released under GNU GPL, read the file 'COPYING' for more information */ -#ifdef HAVE_CONFIG_H -# include "config.h" -#endif - #include "attributes.h" #include "svg/svg.h" #include "xml/repr.h" @@ -24,16 +20,6 @@ #include "display/nr-filter.h" #include "display/nr-filter-merge.h" -#include "sp-factory.h" - -namespace { - SPObject* createMerge() { - return new SPFeMerge(); - } - - bool mergeRegistered = SPFactory::instance().registerObject("svg:feMerge", createMerge); -} - SPFeMerge::SPFeMerge() : SPFilterPrimitive() { } diff --git a/src/filters/mergenode.cpp b/src/filters/mergenode.cpp index ba237c776..691184eb5 100644 --- a/src/filters/mergenode.cpp +++ b/src/filters/mergenode.cpp @@ -13,26 +13,12 @@ * Released under GNU GPL, read the file 'COPYING' for more information */ -#ifdef HAVE_CONFIG_H -# include "config.h" -#endif - #include "attributes.h" #include "xml/repr.h" #include "filters/mergenode.h" #include "filters/merge.h" #include "display/nr-filter-types.h" -#include "sp-factory.h" - -namespace { - SPObject* createMergeNode() { - return new SPFeMergeNode(); - } - - bool mergeNodeRegistered = SPFactory::instance().registerObject("svg:feMergeNode", createMergeNode); -} - SPFeMergeNode::SPFeMergeNode() : SPObject(), input(Inkscape::Filters::NR_FILTER_SLOT_NOT_SET) { } diff --git a/src/filters/morphology.cpp b/src/filters/morphology.cpp index d3611b081..326c9b7a6 100644 --- a/src/filters/morphology.cpp +++ b/src/filters/morphology.cpp @@ -13,10 +13,6 @@ * Released under GNU GPL, read the file 'COPYING' for more information */ -#ifdef HAVE_CONFIG_H -# include "config.h" -#endif - #include <string.h> #include "attributes.h" @@ -26,16 +22,6 @@ #include "display/nr-filter.h" #include "display/nr-filter-morphology.h" -#include "sp-factory.h" - -namespace { - SPObject* createMorphology() { - return new SPFeMorphology(); - } - - bool morphologyRegistered = SPFactory::instance().registerObject("svg:feMorphology", createMorphology); -} - SPFeMorphology::SPFeMorphology() : SPFilterPrimitive() { this->Operator = Inkscape::Filters::MORPHOLOGY_OPERATOR_ERODE; diff --git a/src/filters/offset.cpp b/src/filters/offset.cpp index 234a1a964..c35649dcc 100644 --- a/src/filters/offset.cpp +++ b/src/filters/offset.cpp @@ -13,10 +13,6 @@ * Released under GNU GPL, read the file 'COPYING' for more information */ -#ifdef HAVE_CONFIG_H -# include "config.h" -#endif - #include "attributes.h" #include "svg/svg.h" #include "filters/offset.h" @@ -25,16 +21,6 @@ #include "display/nr-filter.h" #include "display/nr-filter-offset.h" -#include "sp-factory.h" - -namespace { - SPObject* createOffset() { - return new SPFeOffset(); - } - - bool offsetRegistered = SPFactory::instance().registerObject("svg:feOffset", createOffset); -} - SPFeOffset::SPFeOffset() : SPFilterPrimitive() { this->dx = 0; this->dy = 0; diff --git a/src/filters/pointlight.cpp b/src/filters/pointlight.cpp index 1c7532b4e..dd3a78f4c 100644 --- a/src/filters/pointlight.cpp +++ b/src/filters/pointlight.cpp @@ -13,10 +13,6 @@ * Released under GNU GPL, read the file 'COPYING' for more information */ -#ifdef HAVE_CONFIG_H -# include "config.h" -#endif - #include <glib.h> #include "attributes.h" @@ -29,16 +25,6 @@ #define SP_MACROS_SILENT #include "macros.h" -#include "sp-factory.h" - -namespace { - SPObject* createPointLight() { - return new SPFePointLight(); - } - - bool pointLightRegistered = SPFactory::instance().registerObject("svg:fePointLight", createPointLight); -} - SPFePointLight::SPFePointLight() : SPObject(), x(0), x_set(FALSE), y(0), y_set(FALSE), z(0), z_set(FALSE) { } diff --git a/src/filters/specularlighting.cpp b/src/filters/specularlighting.cpp index 6cdd5d9ba..bda1a0f30 100644 --- a/src/filters/specularlighting.cpp +++ b/src/filters/specularlighting.cpp @@ -14,10 +14,6 @@ * Released under GNU GPL, read the file 'COPYING' for more information */ -#ifdef HAVE_CONFIG_H -# include "config.h" -#endif - #include "strneq.h" #include "attributes.h" @@ -36,16 +32,6 @@ /* FeSpecularLighting base class */ static void sp_feSpecularLighting_children_modified(SPFeSpecularLighting *sp_specularlighting); -#include "sp-factory.h" - -namespace { - SPObject* createSpecularLighting() { - return new SPFeSpecularLighting(); - } - - bool specularLightingRegistered = SPFactory::instance().registerObject("svg:feSpecularLighting", createSpecularLighting); -} - SPFeSpecularLighting::SPFeSpecularLighting() : SPFilterPrimitive() { this->surfaceScale = 1; this->specularConstant = 1; diff --git a/src/filters/spotlight.cpp b/src/filters/spotlight.cpp index c0344067c..2e55d39d0 100644 --- a/src/filters/spotlight.cpp +++ b/src/filters/spotlight.cpp @@ -13,10 +13,6 @@ * Released under GNU GPL, read the file 'COPYING' for more information */ -#ifdef HAVE_CONFIG_H -# include "config.h" -#endif - #include <glib.h> #include "attributes.h" @@ -29,16 +25,6 @@ #define SP_MACROS_SILENT #include "macros.h" -#include "sp-factory.h" - -namespace { - SPObject* createSpotLight() { - return new SPFeSpotLight(); - } - - bool spotLightRegistered = SPFactory::instance().registerObject("svg:feSpotLight", createSpotLight); -} - SPFeSpotLight::SPFeSpotLight() : SPObject(), x(0), x_set(FALSE), y(0), y_set(FALSE), z(0), z_set(FALSE), pointsAtX(0), pointsAtX_set(FALSE), pointsAtY(0), pointsAtY_set(FALSE), pointsAtZ(0), pointsAtZ_set(FALSE), diff --git a/src/filters/tile.cpp b/src/filters/tile.cpp index 19e96f47d..623f3ab37 100644 --- a/src/filters/tile.cpp +++ b/src/filters/tile.cpp @@ -11,10 +11,6 @@ * Released under GNU GPL, read the file 'COPYING' for more information */ -#ifdef HAVE_CONFIG_H -# include "config.h" -#endif - #include "attributes.h" #include "svg/svg.h" #include "filters/tile.h" @@ -22,16 +18,6 @@ #include "display/nr-filter.h" #include "display/nr-filter-tile.h" -#include "sp-factory.h" - -namespace { - SPObject* createTile() { - return new SPFeTile(); - } - - bool tileRegistered = SPFactory::instance().registerObject("svg:feTile", createTile); -} - SPFeTile::SPFeTile() : SPFilterPrimitive() { } diff --git a/src/filters/turbulence.cpp b/src/filters/turbulence.cpp index d33667a8c..7541175ed 100644 --- a/src/filters/turbulence.cpp +++ b/src/filters/turbulence.cpp @@ -14,10 +14,6 @@ * Released under GNU GPL, read the file 'COPYING' for more information */ -#ifdef HAVE_CONFIG_H -# include "config.h" -#endif - #include "attributes.h" #include "svg/svg.h" #include "turbulence.h" @@ -28,16 +24,6 @@ #include "display/nr-filter.h" #include "display/nr-filter-turbulence.h" -#include "sp-factory.h" - -namespace { - SPObject* createTurbulence() { - return new SPFeTurbulence(); - } - - bool turbulenceRegistered = SPFactory::instance().registerObject("svg:feTurbulence", createTurbulence); -} - SPFeTurbulence::SPFeTurbulence() : SPFilterPrimitive() { this->stitchTiles = 0; this->seed = 0; diff --git a/src/live_effects/lpeobject.cpp b/src/live_effects/lpeobject.cpp index d92c94d01..8e5ae568f 100644 --- a/src/live_effects/lpeobject.cpp +++ b/src/live_effects/lpeobject.cpp @@ -20,16 +20,6 @@ //#define LIVEPATHEFFECT_VERBOSE -#include "sp-factory.h" - -namespace { - SPObject* createLivepatheffect() { - return new LivePathEffectObject(); - } - - bool livepatheffectRegistered = SPFactory::instance().registerObject("inkscape:path-effect", createLivepatheffect); -} - static void livepatheffect_on_repr_attr_changed (Inkscape::XML::Node * repr, const gchar *key, const gchar *oldval, const gchar *newval, bool is_interactive, void * data); static Inkscape::XML::NodeEventVector const livepatheffect_repr_events = { diff --git a/src/persp3d.cpp b/src/persp3d.cpp index c761947ad..dc0975d12 100644 --- a/src/persp3d.cpp +++ b/src/persp3d.cpp @@ -34,16 +34,6 @@ static void persp3d_on_repr_attr_changed (Inkscape::XML::Node * repr, const gcha static int global_counter = 0; -#include "sp-factory.h" - -namespace { - SPObject* createPersp3D() { - return new Persp3D(); - } - - bool persp3DRegistered = SPFactory::instance().registerObject("inkscape:persp3d", createPersp3D); -} - /* Constructor/destructor for the internal class */ Persp3DImpl::Persp3DImpl() { diff --git a/src/sp-anchor.cpp b/src/sp-anchor.cpp index 7b558bf08..78ba10c13 100644 --- a/src/sp-anchor.cpp +++ b/src/sp-anchor.cpp @@ -13,10 +13,6 @@ #define noSP_ANCHOR_VERBOSE -#ifdef HAVE_CONFIG_H -# include "config.h" -#endif - #include <glibmm/i18n.h> #include "xml/quote.h" #include "xml/repr.h" @@ -25,16 +21,6 @@ #include "ui/view/view.h" #include "document.h" -#include "sp-factory.h" - -namespace { - SPObject* createAnchor() { - return new SPAnchor(); - } - - bool anchorRegistered = SPFactory::instance().registerObject("svg:a", createAnchor); -} - SPAnchor::SPAnchor() : SPGroup() { this->href = NULL; } diff --git a/src/sp-clippath.cpp b/src/sp-clippath.cpp index 5065f25c3..3c6167438 100644 --- a/src/sp-clippath.cpp +++ b/src/sp-clippath.cpp @@ -40,16 +40,6 @@ struct SPClipPathView { static SPClipPathView* sp_clippath_view_new_prepend(SPClipPathView *list, unsigned int key, Inkscape::DrawingItem *arenaitem); static SPClipPathView* sp_clippath_view_list_remove(SPClipPathView *list, SPClipPathView *view); -#include "sp-factory.h" - -namespace { - SPObject* createClipPath() { - return new SPClipPath(); - } - - bool clipPathRegistered = SPFactory::instance().registerObject("svg:clipPath", createClipPath); -} - SPClipPath::SPClipPath() : SPObjectGroup() { this->clipPathUnits_set = FALSE; this->clipPathUnits = SP_CONTENT_UNITS_USERSPACEONUSE; diff --git a/src/sp-defs.cpp b/src/sp-defs.cpp index 334570076..8dd695867 100644 --- a/src/sp-defs.cpp +++ b/src/sp-defs.cpp @@ -20,16 +20,6 @@ #include "xml/repr.h" #include "document.h" -#include "sp-factory.h" - -namespace { - SPObject* createDefs() { - return new SPDefs(); - } - - bool defsRegistered = SPFactory::instance().registerObject("svg:defs", createDefs); -} - SPDefs::SPDefs() : SPObject() { } diff --git a/src/sp-desc.cpp b/src/sp-desc.cpp index 199ae0176..3c75d087a 100644 --- a/src/sp-desc.cpp +++ b/src/sp-desc.cpp @@ -9,23 +9,9 @@ * Released under GNU GPL, read the file 'COPYING' for more information */ -#ifdef HAVE_CONFIG_H -# include "config.h" -#endif - #include "sp-desc.h" #include "xml/repr.h" -#include "sp-factory.h" - -namespace { - SPObject* createDesc() { - return new SPDesc(); - } - - bool descRegistered = SPFactory::instance().registerObject("svg:desc", createDesc); -} - SPDesc::SPDesc() : SPObject() { } diff --git a/src/sp-ellipse.cpp b/src/sp-ellipse.cpp index a74d4687d..885fedafa 100644 --- a/src/sp-ellipse.cpp +++ b/src/sp-ellipse.cpp @@ -34,35 +34,6 @@ #include "svg/path-string.h" #include "xml/repr.h" -#include "sp-factory.h" - -namespace { -SPObject *create_ellipse() -{ - SPGenericEllipse *ellipse = new SPGenericEllipse(); - ellipse->type = SP_GENERIC_ELLIPSE_ELLIPSE; - return ellipse; -} - -SPObject *create_circle() -{ - SPGenericEllipse *circle = new SPGenericEllipse(); - circle->type = SP_GENERIC_ELLIPSE_CIRCLE; - return circle; -} - -SPObject *create_arc() -{ - SPGenericEllipse *arc = new SPGenericEllipse(); - arc->type = SP_GENERIC_ELLIPSE_ARC; - return arc; -} - -bool ellipse_registered = SPFactory::instance().registerObject("svg:ellipse", create_ellipse); -bool circle_registered = SPFactory::instance().registerObject("svg:circle", create_circle); -bool arc_registered = SPFactory::instance().registerObject("arc", create_arc); -} - #ifndef M_PI #define M_PI 3.14159265358979323846 diff --git a/src/sp-factory.cpp b/src/sp-factory.cpp new file mode 100644 index 000000000..9911222e5 --- /dev/null +++ b/src/sp-factory.cpp @@ -0,0 +1,337 @@ +/* + * Factory for SPObject tree + * + * Authors: + * Markus Engel + * + * Copyright (C) 2013 Authors + * Released under GNU GPL, read the file 'COPYING' for more information + */ + +#include "sp-factory.h" + +// primary +#include "box3d.h" +#include "box3d-side.h" +#include "color-profile.h" +#include "persp3d.h" +#include "sp-anchor.h" +#include "sp-clippath.h" +#include "sp-defs.h" +#include "sp-desc.h" +#include "sp-ellipse.h" +#include "sp-filter.h" +#include "sp-flowdiv.h" +#include "sp-flowregion.h" +#include "sp-flowtext.h" +#include "sp-font.h" +#include "sp-font-face.h" +#include "sp-glyph.h" +#include "sp-guide.h" +#include "sp-hatch.h" +#include "sp-hatch-path.h" +#include "sp-image.h" +#include "sp-item-group.h" +#include "sp-line.h" +#include "sp-linear-gradient.h" +#include "sp-marker.h" +#include "sp-mask.h" +#include "sp-mesh-gradient.h" +#include "sp-mesh-patch.h" +#include "sp-mesh-row.h" +#include "sp-metadata.h" +#include "sp-missing-glyph.h" +#include "sp-namedview.h" +#include "sp-object.h" +#include "sp-offset.h" +#include "sp-path.h" +#include "sp-pattern.h" +#include "sp-polygon.h" +#include "sp-polyline.h" +#include "sp-radial-gradient.h" +#include "sp-rect.h" +#include "sp-root.h" +#include "sp-script.h" +#include "sp-solid-color.h" +#include "sp-spiral.h" +#include "sp-star.h" +#include "sp-stop.h" +#include "sp-string.h" +#include "sp-style-elem.h" +#include "sp-switch.h" +#include "sp-symbol.h" +#include "sp-tag.h" +#include "sp-tag-use.h" +#include "sp-text.h" +#include "sp-textpath.h" +#include "sp-title.h" +#include "sp-tref.h" +#include "sp-tspan.h" +#include "sp-use.h" +#include "live_effects/lpeobject.h" + +// filters +#include "filters/blend.h" +#include "filters/colormatrix.h" +#include "filters/componenttransfer.h" +#include "filters/componenttransfer-funcnode.h" +#include "filters/composite.h" +#include "filters/convolvematrix.h" +#include "filters/diffuselighting.h" +#include "filters/displacementmap.h" +#include "filters/distantlight.h" +#include "filters/flood.h" +#include "filters/gaussian-blur.h" +#include "filters/image.h" +#include "filters/merge.h" +#include "filters/mergenode.h" +#include "filters/morphology.h" +#include "filters/offset.h" +#include "filters/pointlight.h" +#include "filters/specularlighting.h" +#include "filters/spotlight.h" +#include "filters/tile.h" +#include "filters/turbulence.h" + +SPObject *SPFactory::createObject(std::string const& id) +{ + SPObject *ret = NULL; + + if (id == "inkscape:box3d") + ret = new SPBox3D; + else if (id == "inkscape:box3dside") + ret = new Box3DSide; + else if (id == "svg:color-profile") + ret = new Inkscape::ColorProfile; + else if (id == "inkscape:persp3d") + ret = new Persp3D; + else if (id == "svg:a") + ret = new SPAnchor; + else if (id == "svg:clipPath") + ret = new SPClipPath; + else if (id == "svg:defs") + ret = new SPDefs; + else if (id == "svg:desc") + ret = new SPDesc; + else if (id == "svg:ellipse") { + SPGenericEllipse *e = new SPGenericEllipse; + e->type = SP_GENERIC_ELLIPSE_ELLIPSE; + ret = e; + } else if (id == "svg:circle") { + SPGenericEllipse *c = new SPGenericEllipse; + c->type = SP_GENERIC_ELLIPSE_CIRCLE; + ret = c; + } else if (id == "arc") { + SPGenericEllipse *a = new SPGenericEllipse; + a->type = SP_GENERIC_ELLIPSE_ARC; + ret = a; + } + else if (id == "svg:filter") + ret = new SPFilter; + else if (id == "svg:flowDiv") + ret = new SPFlowdiv; + else if (id == "svg:flowSpan") + ret = new SPFlowtspan; + else if (id == "svg:flowPara") + ret = new SPFlowpara; + else if (id == "svg:flowLine") + ret = new SPFlowline; + else if (id == "svg:flowRegionBreak") + ret = new SPFlowregionbreak; + else if (id == "svg:flowRegion") + ret = new SPFlowregion; + else if (id == "svg:flowRegionExclude") + ret = new SPFlowregionExclude; + else if (id == "svg:flowRoot") + ret = new SPFlowtext; + else if (id == "svg:font") + ret = new SPFont; + else if (id == "svg:font-face") + ret = new SPFontFace; + else if (id == "svg:glyph") + ret = new SPGlyph; + else if (id == "sodipodi:guide") + ret = new SPGuide; + else if (id == "svg:hatch") + ret = new SPHatch; + else if (id == "svg:hatchPath") + ret = new SPHatchPath; + else if (id == "svg:image") + ret = new SPImage; + else if (id == "svg:g") + ret = new SPGroup; + else if (id == "svg:line") + ret = new SPLine; + else if (id == "svg:linearGradient") + ret = new SPLinearGradient; + else if (id == "svg:marker") + ret = new SPMarker; + else if (id == "svg:mask") + ret = new SPMask; + else if (id == "svg:meshGradient") + ret = new SPMeshGradient; + else if (id == "svg:meshPatch") + ret = new SPMeshPatch; + else if (id == "svg:meshRow") + ret = new SPMeshRow; + else if (id == "svg:metadata") + ret = new SPMetadata; + else if (id == "svg:missing-glyph") + ret = new SPMissingGlyph; + else if (id == "sodipodi:namedview") + ret = new SPNamedView; + else if (id == "inkscape:offset") + ret = new SPOffset; + else if (id == "svg:path") + ret = new SPPath; + else if (id == "svg:pattern") + ret = new SPPattern; + else if (id == "svg:polygon") + ret = new SPPolygon; + else if (id == "svg:polyline") + ret = new SPPolyLine; + else if (id == "svg:radialGradient") + ret = new SPRadialGradient; + else if (id == "svg:rect") + ret = new SPRect; + else if (id == "svg:svg") + ret = new SPRoot; + else if (id == "svg:script") + ret = new SPScript; + else if (id == "svg:solidColor") + ret = new SPSolidColor; + else if (id == "spiral") + ret = new SPSpiral; + else if (id == "star") + ret = new SPStar; + else if (id == "svg:stop") + ret = new SPStop; + else if (id == "string") + ret = new SPString; + else if (id == "svg:style") + ret = new SPStyleElem; + else if (id == "svg:switch") + ret = new SPSwitch; + else if (id == "svg:symbol") + ret = new SPSymbol; + else if (id == "inkscape:tag") + ret = new SPTag; + else if (id == "inkscape:tagref") + ret = new SPTagUse; + else if (id == "svg:text") + ret = new SPText; + else if (id == "svg:title") + ret = new SPTitle; + else if (id == "svg:tref") + ret = new SPTRef; + else if (id == "svg:tspan") + ret = new SPTSpan; + else if (id == "svg:textPath") + ret = new SPTextPath; + else if (id == "svg:use") + ret = new SPUse; + else if (id == "inkscape:path-effect") + ret = new LivePathEffectObject; + + + // filters + else if (id == "svg:feBlend") + ret = new SPFeBlend; + else if (id == "svg:feColorMatrix") + ret = new SPFeColorMatrix; + else if (id == "svg:feComponentTransfer") + ret = new SPFeComponentTransfer; + else if (id == "svg:feFuncR") + ret = new SPFeFuncNode(SPFeFuncNode::R); + else if (id == "svg:feFuncG") + ret = new SPFeFuncNode(SPFeFuncNode::G); + else if (id == "svg:feFuncB") + ret = new SPFeFuncNode(SPFeFuncNode::B); + else if (id == "svg:feFuncA") + ret = new SPFeFuncNode(SPFeFuncNode::A); + else if (id == "svg:feComposite") + ret = new SPFeComposite; + else if (id == "svg:feConvolveMatrix") + ret = new SPFeConvolveMatrix; + else if (id == "svg:feDiffuseLighting") + ret = new SPFeDiffuseLighting; + else if (id == "svg:feDisplacementMap") + ret = new SPFeDisplacementMap; + else if (id == "svg:feDistantLight") + ret = new SPFeDistantLight; + else if (id == "svg:feFlood") + ret = new SPFeFlood; + else if (id == "svg:feGaussianBlur") + ret = new SPGaussianBlur; + else if (id == "svg:feImage") + ret = new SPFeImage; + else if (id == "svg:feMerge") + ret = new SPFeMerge; + else if (id == "svg:feMergeNode") + ret = new SPFeMergeNode; + else if (id == "svg:feMorphology") + ret = new SPFeMorphology; + else if (id == "svg:feOffset") + ret = new SPFeOffset; + else if (id == "svg:fePointLight") + ret = new SPFePointLight; + else if (id == "svg:feSpecularLighting") + ret = new SPFeSpecularLighting; + else if (id == "svg:feSpotLight") + ret = new SPFeSpotLight; + else if (id == "svg:feTile") + ret = new SPFeTile; + else if (id == "svg:feTurbulence") + ret = new SPFeTurbulence; + else if (id == "inkscape:grid") + ret = new SPObject; // TODO wtf + else if (id == "rdf:RDF") // no SP node yet + {} + else if (id == "inkscape:clipboard") // SP node not necessary + {} + else if (id.empty()) // comments + {} + else { + fprintf(stderr, "WARNING: unknown type: %s", id.c_str()); + } + + return ret; +} + +std::string NodeTraits::get_type_string(Inkscape::XML::Node const &node) +{ + std::string name; + + switch (node.type()) { + case Inkscape::XML::TEXT_NODE: + name = "string"; + break; + + case Inkscape::XML::ELEMENT_NODE: { + char const *const sptype = node.attribute("sodipodi:type"); + + if (sptype) { + name = sptype; + } else { + name = node.name(); + } + break; + } + default: + name = ""; + break; + } + + return name; +} + +/* + Local Variables: + mode:c++ + c-file-style:"stroustrup" + c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +)) + indent-tabs-mode:nil + fill-column:99 + End: +*/ +// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:fileencoding=utf-8:textwidth=99 : diff --git a/src/sp-factory.h b/src/sp-factory.h index 0621f77ba..040fd14ae 100644 --- a/src/sp-factory.h +++ b/src/sp-factory.h @@ -1,6 +1,6 @@ -/** @file +/* * Factory for SPObject tree - *//* + * * Authors: * Markus Engel * @@ -11,11 +11,23 @@ #ifndef SP_FACTORY_SEEN #define SP_FACTORY_SEEN -#include "factory.h" +#include <string> class SPObject; -typedef Singleton< Factory<SPObject> > SPFactory; +namespace Inkscape { +namespace XML { +class Node; +} +} + +struct SPFactory { + static SPObject *createObject(std::string const& id); +}; + +struct NodeTraits { + static std::string get_type_string(Inkscape::XML::Node const &node); +}; #endif diff --git a/src/sp-filter.cpp b/src/sp-filter.cpp index 9cb33a6f3..a70fbd5bb 100644 --- a/src/sp-filter.cpp +++ b/src/sp-filter.cpp @@ -41,15 +41,6 @@ using std::pair; static void filter_ref_changed(SPObject *old_ref, SPObject *ref, SPFilter *filter); static void filter_ref_modified(SPObject *href, guint flags, SPFilter *filter); -#include "sp-factory.h" - -namespace { - SPObject* createFilter() { - return new SPFilter(); - } - - bool filterRegistered = SPFactory::instance().registerObject("svg:filter", createFilter); -} SPFilter::SPFilter() : SPObject(), filterUnits(SP_FILTER_UNITS_OBJECTBOUNDINGBOX), filterUnits_set(FALSE), diff --git a/src/sp-flowdiv.cpp b/src/sp-flowdiv.cpp index 00ba48b06..8d9c51ab8 100644 --- a/src/sp-flowdiv.cpp +++ b/src/sp-flowdiv.cpp @@ -1,45 +1,11 @@ /* */ -#ifdef HAVE_CONFIG_H -# include "config.h" -#endif - #include "xml/repr.h" #include "sp-flowdiv.h" #include "sp-string.h" #include "document.h" -#include "sp-factory.h" - -namespace { - SPObject* createFlowdiv() { - return new SPFlowdiv(); - } - - SPObject* createFlowtspan() { - return new SPFlowtspan(); - } - - SPObject* createFlowpara() { - return new SPFlowpara(); - } - - SPObject* createFlowline() { - return new SPFlowline(); - } - - SPObject* createFlowregionbreak() { - return new SPFlowregionbreak(); - } - - bool flowdivRegistered = SPFactory::instance().registerObject("svg:flowDiv", createFlowdiv); - bool flowtspanRegistered = SPFactory::instance().registerObject("svg:flowSpan", createFlowtspan); - bool flowparaRegistered = SPFactory::instance().registerObject("svg:flowPara", createFlowpara); - bool flowlineRegistered = SPFactory::instance().registerObject("svg:flowLine", createFlowline); - bool flowregionbreakRegistered = SPFactory::instance().registerObject("svg:flowRegionBreak", createFlowregionbreak); -} - SPFlowdiv::SPFlowdiv() : SPItem() { } diff --git a/src/sp-flowregion.cpp b/src/sp-flowregion.cpp index 580945d74..5715e5eb1 100644 --- a/src/sp-flowregion.cpp +++ b/src/sp-flowregion.cpp @@ -23,20 +23,6 @@ #include "livarot/Path.h" #include "livarot/Shape.h" -#include "sp-factory.h" - -namespace { - SPObject* createFlowregion() { - return new SPFlowregion(); - } - - SPObject* createFlowregionExclude() { - return new SPFlowregionExclude(); - } - - bool flowregionRegistered = SPFactory::instance().registerObject("svg:flowRegion", createFlowregion); - bool flowregionExcludeRegistered = SPFactory::instance().registerObject("svg:flowRegionExclude", createFlowregionExclude); -} static void GetDest(SPObject* child,Shape **computed); diff --git a/src/sp-flowtext.cpp b/src/sp-flowtext.cpp index 6d2385aff..cac3cc61d 100644 --- a/src/sp-flowtext.cpp +++ b/src/sp-flowtext.cpp @@ -34,16 +34,6 @@ #include "display/drawing-text.h" -#include "sp-factory.h" - -namespace { - SPObject* createFlowtext() { - return new SPFlowtext(); - } - - bool flowtextRegistered = SPFactory::instance().registerObject("svg:flowRoot", createFlowtext); -} - SPFlowtext::SPFlowtext() : SPItem() { this->par_indent = 0; } diff --git a/src/sp-font-face.cpp b/src/sp-font-face.cpp index 9782f0c83..afd2a9dee 100644 --- a/src/sp-font-face.cpp +++ b/src/sp-font-face.cpp @@ -259,16 +259,6 @@ static std::vector<FontFaceStretchType> sp_read_fontFaceStretchType(gchar const return v; } -#include "sp-factory.h" - -namespace { - SPObject* createFontFace() { - return new SPFontFace(); - } - - bool fontFaceRegistered = SPFactory::instance().registerObject("svg:font-face", createFontFace); -} - SPFontFace::SPFontFace() : SPObject() { std::vector<FontFaceStyleType> style; style.push_back(SP_FONTFACE_STYLE_ALL); diff --git a/src/sp-font.cpp b/src/sp-font.cpp index 62cf521d3..341a6159f 100644 --- a/src/sp-font.cpp +++ b/src/sp-font.cpp @@ -23,15 +23,6 @@ #include "display/nr-svgfonts.h" -#include "sp-factory.h" - -namespace { - SPObject* createFont() { - return new SPFont(); - } - - bool fontRegistered = SPFactory::instance().registerObject("svg:font", createFont); -} //I think we should have extra stuff here and in the set method in order to set default value as specified at http://www.w3.org/TR/SVG/fonts.html diff --git a/src/sp-glyph.cpp b/src/sp-glyph.cpp index eaa69d486..4829aae51 100644 --- a/src/sp-glyph.cpp +++ b/src/sp-glyph.cpp @@ -20,15 +20,6 @@ #include "document.h" #include <cstring> -#include "sp-factory.h" - -namespace { - SPObject* createGlyph() { - return new SPGlyph(); - } - bool glyphRegistered = SPFactory::instance().registerObject("svg:glyph", createGlyph); -} - SPGlyph::SPGlyph() : SPObject() //TODO: correct these values: diff --git a/src/sp-guide.cpp b/src/sp-guide.cpp index 08b055508..4e1c5913d 100644 --- a/src/sp-guide.cpp +++ b/src/sp-guide.cpp @@ -47,16 +47,6 @@ using Inkscape::DocumentUndo; using std::vector; -#include "sp-factory.h" - -namespace { - SPObject* createGuide() { - return new SPGuide(); - } - - bool guideRegistered = SPFactory::instance().registerObject("sodipodi:guide", createGuide); -} - SPGuide::SPGuide() : SPObject() , label(NULL) diff --git a/src/sp-hatch-path.cpp b/src/sp-hatch-path.cpp index bc95c246e..32a514dcb 100644 --- a/src/sp-hatch-path.cpp +++ b/src/sp-hatch-path.cpp @@ -12,10 +12,6 @@ * Released under GNU GPL, read the file 'COPYING' for more information */ -#ifdef HAVE_CONFIG_H -# include "config.h" -#endif - #include <cstring> #include <string> #include <2geom/path.h> @@ -37,19 +33,6 @@ #include "svg/css-ostringstream.h" #include "xml/repr.h" -#include "sp-factory.h" - -namespace { - -SPObject* createHatchPath() -{ - return new SPHatchPath(); -} - -bool hatchRegistered = SPFactory::instance().registerObject("svg:hatchPath", createHatchPath); - -} // namespace - SPHatchPath::SPHatchPath() : offset(), _display(), diff --git a/src/sp-hatch.cpp b/src/sp-hatch.cpp index dfecb2250..ea4c5865a 100644 --- a/src/sp-hatch.cpp +++ b/src/sp-hatch.cpp @@ -12,10 +12,6 @@ * Released under GNU GPL, read the file 'COPYING' for more information */ -#ifdef HAVE_CONFIG_H -# include "config.h" -#endif - #include <cstring> #include <string> #include <2geom/transforms.h> @@ -35,18 +31,6 @@ #include "sp-hatch-path.h" #include "xml/repr.h" -#include "sp-factory.h" - -namespace { - -SPObject* createHatch() { - return new SPHatch(); -} - -bool hatchRegistered = SPFactory::instance().registerObject("svg:hatch", createHatch); - -} // namespace - SPHatch::SPHatch() : SPPaintServer(), href(), diff --git a/src/sp-image.cpp b/src/sp-image.cpp index b6177fae6..bf5b9ebcd 100644 --- a/src/sp-image.cpp +++ b/src/sp-image.cpp @@ -42,7 +42,6 @@ #include "snap-candidate.h" #include "preferences.h" #include "io/sys.h" -#include "sp-factory.h" #if defined(HAVE_LIBLCMS1) || defined(HAVE_LIBLCMS2) #include "cms-system.h" @@ -112,14 +111,6 @@ extern guint update_in_progress; #define DEBUG_MESSAGE_SCISLAC(key, ...) #endif // DEBUG_LCMS -namespace { -SPObject* createImage() { - return new SPImage(); -} - -bool imageRegistered = SPFactory::instance().registerObject("svg:image", createImage); -} - SPImage::SPImage() : SPItem(), SPViewBox() { this->x.unset(); diff --git a/src/sp-item-group.cpp b/src/sp-item-group.cpp index 0f76051bc..0c65bbaed 100644 --- a/src/sp-item-group.cpp +++ b/src/sp-item-group.cpp @@ -58,16 +58,6 @@ using Inkscape::DocumentUndo; static void sp_group_perform_patheffect(SPGroup *group, SPGroup *topgroup, bool write); -#include "sp-factory.h" - -namespace { - SPObject* createGroup() { - return new SPGroup(); - } - - bool groupRegistered = SPFactory::instance().registerObject("svg:g", createGroup); -} - SPGroup::SPGroup() : SPLPEItem() { this->_layer_mode = SPGroup::GROUP; } diff --git a/src/sp-line.cpp b/src/sp-line.cpp index 8af95b4ce..cf21be912 100644 --- a/src/sp-line.cpp +++ b/src/sp-line.cpp @@ -11,9 +11,6 @@ * Released under GNU GPL, read the file 'COPYING' for more information */ -#ifdef HAVE_CONFIG_H -# include "config.h" -#endif #include "attributes.h" #include "style.h" #include "sp-line.h" @@ -24,16 +21,6 @@ #include "document.h" #include "inkscape.h" -#include "sp-factory.h" - -namespace { - SPObject* createLine() { - return new SPLine(); - } - - bool lineRegistered = SPFactory::instance().registerObject("svg:line", createLine); -} - SPLine::SPLine() : SPShape() { this->x1.unset(); this->y1.unset(); diff --git a/src/sp-linear-gradient.cpp b/src/sp-linear-gradient.cpp index 6e9f5e6dd..29579b617 100644 --- a/src/sp-linear-gradient.cpp +++ b/src/sp-linear-gradient.cpp @@ -5,17 +5,6 @@ #include "attributes.h" #include "xml/repr.h" -#include "sp-factory.h" - -namespace { - SPObject* createLinearGradient() { - return new SPLinearGradient(); - } - - bool linearGradientRegistered = SPFactory::instance().registerObject("svg:linearGradient", createLinearGradient); -} - - /* * Linear Gradient */ diff --git a/src/sp-marker.cpp b/src/sp-marker.cpp index 371a6c35c..d3cf50fa7 100644 --- a/src/sp-marker.cpp +++ b/src/sp-marker.cpp @@ -43,16 +43,6 @@ public: std::vector<Inkscape::DrawingItem *> items; }; -#include "sp-factory.h" - -namespace { - SPObject* createMarker() { - return new SPMarker(); - } - - bool markerRegistered = SPFactory::instance().registerObject("svg:marker", createMarker); -} - SPMarker::SPMarker() : SPGroup(), SPViewBox() { this->markerUnits = 0; diff --git a/src/sp-mask.cpp b/src/sp-mask.cpp index 9707c9d8e..d60473e1d 100644 --- a/src/sp-mask.cpp +++ b/src/sp-mask.cpp @@ -37,16 +37,6 @@ struct SPMaskView { SPMaskView *sp_mask_view_new_prepend (SPMaskView *list, unsigned int key, Inkscape::DrawingItem *arenaitem); SPMaskView *sp_mask_view_list_remove (SPMaskView *list, SPMaskView *view); -#include "sp-factory.h" - -namespace { - SPObject* createMask() { - return new SPMask(); - } - - bool maskRegistered = SPFactory::instance().registerObject("svg:mask", createMask); -} - SPMask::SPMask() : SPObjectGroup() { this->maskUnits_set = FALSE; this->maskUnits = SP_CONTENT_UNITS_OBJECTBOUNDINGBOX; diff --git a/src/sp-mesh-gradient.cpp b/src/sp-mesh-gradient.cpp index 5c6a2f9da..3301d257c 100644 --- a/src/sp-mesh-gradient.cpp +++ b/src/sp-mesh-gradient.cpp @@ -6,17 +6,6 @@ #include "sp-mesh-gradient.h" -#include "sp-factory.h" - -namespace { - SPObject* createMeshGradient() { - return new SPMeshGradient(); - } - - bool meshGradientRegistered = SPFactory::instance().registerObject("svg:meshGradient", createMeshGradient); -} - - /* * Mesh Gradient */ diff --git a/src/sp-mesh-patch.cpp b/src/sp-mesh-patch.cpp index 216de8270..e7c7c837d 100644 --- a/src/sp-mesh-patch.cpp +++ b/src/sp-mesh-patch.cpp @@ -20,16 +20,6 @@ #include "attributes.h" #include "xml/repr.h" -#include "sp-factory.h" - -namespace { - SPObject* createMeshPatch() { - return new SPMeshPatch(); - } - - bool meshPatchRegistered = SPFactory::instance().registerObject("svg:meshPatch", createMeshPatch); -} - SPMeshPatch* SPMeshPatch::getNextMeshPatch() { SPMeshPatch *result = 0; diff --git a/src/sp-mesh-row.cpp b/src/sp-mesh-row.cpp index 07747f7f5..f95909b63 100644 --- a/src/sp-mesh-row.cpp +++ b/src/sp-mesh-row.cpp @@ -19,16 +19,6 @@ #include "xml/repr.h" -#include "sp-factory.h" - -namespace { - SPObject* createMeshRow() { - return new SPMeshRow(); - } - - bool meshRowRegistered = SPFactory::instance().registerObject("svg:meshRow", createMeshRow); -} - SPMeshRow* SPMeshRow::getNextMeshRow() { SPMeshRow *result = 0; diff --git a/src/sp-metadata.cpp b/src/sp-metadata.cpp index bf4ce27a1..6bdc2f0b9 100644 --- a/src/sp-metadata.cpp +++ b/src/sp-metadata.cpp @@ -33,16 +33,6 @@ /* Metadata base class */ -#include "sp-factory.h" - -namespace { - SPObject* createMetadata() { - return new SPMetadata(); - } - - bool metadataRegistered = SPFactory::instance().registerObject("svg:metadata", createMetadata); -} - SPMetadata::SPMetadata() : SPObject() { } diff --git a/src/sp-missing-glyph.cpp b/src/sp-missing-glyph.cpp index 06b741165..75de55693 100644 --- a/src/sp-missing-glyph.cpp +++ b/src/sp-missing-glyph.cpp @@ -19,16 +19,6 @@ #include "sp-missing-glyph.h" #include "document.h" -#include "sp-factory.h" - -namespace { - SPObject* createMissingGlyph() { - return new SPMissingGlyph(); - } - - bool missingGlyphRegistered = SPFactory::instance().registerObject("svg:missing-glyph", createMissingGlyph); -} - SPMissingGlyph::SPMissingGlyph() : SPObject() { //TODO: correct these values: this->d = NULL; diff --git a/src/sp-namedview.cpp b/src/sp-namedview.cpp index dc36e68b9..c26eff39f 100644 --- a/src/sp-namedview.cpp +++ b/src/sp-namedview.cpp @@ -56,16 +56,6 @@ static void sp_namedview_show_single_guide(SPGuide* guide, bool show); static gboolean sp_str_to_bool(const gchar *str); static gboolean sp_nv_read_opacity(const gchar *str, guint32 *color); -#include "sp-factory.h" - -namespace { - SPObject* createNamedView() { - return new SPNamedView(); - } - - bool namedViewRegistered = SPFactory::instance().registerObject("sodipodi:namedview", createNamedView); -} - SPNamedView::SPNamedView() : SPObjectGroup(), snap_manager(this) { this->zoom = 0; this->guidecolor = 0; diff --git a/src/sp-object.cpp b/src/sp-object.cpp index 1094b88a7..343db435e 100644 --- a/src/sp-object.cpp +++ b/src/sp-object.cpp @@ -61,14 +61,6 @@ using std::strstr; # define debug(f, a...) /* */ #endif -namespace { - SPObject* createObject() { - return new SPObject(); - } - - bool gridRegistered = SPFactory::instance().registerObject("inkscape:grid", createObject); -} - guint update_in_progress = 0; // guard against update-during-update Inkscape::XML::NodeEventVector object_event_vector = { @@ -629,7 +621,7 @@ void SPObject::child_added(Inkscape::XML::Node *child, Inkscape::XML::Node *ref) const std::string type_string = NodeTraits::get_type_string(*child); - SPObject* ochild = SPFactory::instance().createObject(type_string); + SPObject* ochild = SPFactory::createObject(type_string); if (ochild == NULL) { // Currenty, there are many node types that do not have // corresponding classes in the SPObject tree. @@ -688,7 +680,7 @@ void SPObject::build(SPDocument *document, Inkscape::XML::Node *repr) { for (Inkscape::XML::Node *rchild = repr->firstChild() ; rchild != NULL; rchild = rchild->next()) { const std::string typeString = NodeTraits::get_type_string(*rchild); - SPObject* child = SPFactory::instance().createObject(typeString); + SPObject* child = SPFactory::createObject(typeString); if (child == NULL) { // Currenty, there are many node types that do not have // corresponding classes in the SPObject tree. diff --git a/src/sp-offset.cpp b/src/sp-offset.cpp index 3aa1e4eb6..15d3821c7 100644 --- a/src/sp-offset.cpp +++ b/src/sp-offset.cpp @@ -43,16 +43,6 @@ class SPDocument; -#include "sp-factory.h" - -namespace { - SPObject* createOffset() { - return new SPOffset(); - } - - bool offsetRegistered = SPFactory::instance().registerObject("inkscape:offset", createOffset); -} - #define noOFFSET_VERBOSE /** \note diff --git a/src/sp-path.cpp b/src/sp-path.cpp index 0fef57698..51cc8d6dc 100644 --- a/src/sp-path.cpp +++ b/src/sp-path.cpp @@ -51,16 +51,6 @@ #define noPATH_VERBOSE -#include "sp-factory.h" - -namespace { - SPObject* createPath() { - return new SPPath(); - } - - bool pathRegistered = SPFactory::instance().registerObject("svg:path", createPath); -} - gint SPPath::nodesInPath() const { return _curve ? _curve->nodes_in_path() : 0; diff --git a/src/sp-pattern.cpp b/src/sp-pattern.cpp index 961ab0f84..987a86fe4 100644 --- a/src/sp-pattern.cpp +++ b/src/sp-pattern.cpp @@ -45,16 +45,6 @@ static void pattern_ref_changed(SPObject *old_ref, SPObject *ref, SPPattern *pat); static void pattern_ref_modified (SPObject *ref, guint flags, SPPattern *pattern); -#include "sp-factory.h" - -namespace { - SPObject* createPattern() { - return new SPPattern(); - } - - bool patternRegistered = SPFactory::instance().registerObject("svg:pattern", createPattern); -} - SPPattern::SPPattern() : SPPaintServer(), SPViewBox() { this->href = NULL; diff --git a/src/sp-polygon.cpp b/src/sp-polygon.cpp index 302905a62..af71280d5 100644 --- a/src/sp-polygon.cpp +++ b/src/sp-polygon.cpp @@ -11,8 +11,6 @@ * Released under GNU GPL, read the file 'COPYING' for more information */ -#include "config.h" - #include "attributes.h" #include "sp-polygon.h" #include "display/curve.h" @@ -25,16 +23,6 @@ #include "xml/repr.h" #include "document.h" -#include "sp-factory.h" - -namespace { - SPObject* createPolygon() { - return new SPPolygon(); - } - - bool polygonRegistered = SPFactory::instance().registerObject("svg:polygon", createPolygon); -} - SPPolygon::SPPolygon() : SPShape() { } diff --git a/src/sp-polyline.cpp b/src/sp-polyline.cpp index c80190097..a12f927b5 100644 --- a/src/sp-polyline.cpp +++ b/src/sp-polyline.cpp @@ -20,16 +20,6 @@ #include "xml/repr.h" #include "document.h" -#include "sp-factory.h" - -namespace { - SPObject* createPolyLine() { - return new SPPolyLine(); - } - - bool polyLineRegistered = SPFactory::instance().registerObject("svg:polyline", createPolyLine); -} - SPPolyLine::SPPolyLine() : SPShape() { } diff --git a/src/sp-radial-gradient.cpp b/src/sp-radial-gradient.cpp index 2c2b17b7d..8fb230ba7 100644 --- a/src/sp-radial-gradient.cpp +++ b/src/sp-radial-gradient.cpp @@ -5,17 +5,7 @@ #include "attributes.h" #include "xml/repr.h" -#include "2geom/transforms.h" - -#include "sp-factory.h" - -namespace { - SPObject* createRadialGradient() { - return new SPRadialGradient(); - } - - bool radialGradientRegistered = SPFactory::instance().registerObject("svg:radialGradient", createRadialGradient); -} +#include <2geom/transforms.h> /* * Radial Gradient diff --git a/src/sp-rect.cpp b/src/sp-rect.cpp index af3e2bfb4..361d3c8c0 100644 --- a/src/sp-rect.cpp +++ b/src/sp-rect.cpp @@ -31,16 +31,6 @@ #define noRECT_VERBOSE -#include "sp-factory.h" - -namespace { - SPObject* createRect() { - return new SPRect(); - } - - bool rectRegistered = SPFactory::instance().registerObject("svg:rect", createRect); -} - SPRect::SPRect() : SPShape() { } diff --git a/src/sp-root.cpp b/src/sp-root.cpp index 3a39a51c1..8bedec0a5 100644 --- a/src/sp-root.cpp +++ b/src/sp-root.cpp @@ -13,10 +13,6 @@ * Released under GNU GPL, read the file 'COPYING' for more information */ -#ifdef HAVE_CONFIG_H -# include "config.h" -#endif - #include <string> #include <2geom/transforms.h> @@ -32,17 +28,6 @@ #include "xml/repr.h" #include "util/units.h" -#include "sp-factory.h" - -namespace { -SPObject *createRoot() -{ - return new SPRoot(); -} - -bool rootRegistered = SPFactory::instance().registerObject("svg:svg", createRoot); -} - SPRoot::SPRoot() : SPGroup(), SPViewBox() { this->onload = NULL; diff --git a/src/sp-script.cpp b/src/sp-script.cpp index 260b3dcfd..f1ea9c9bd 100644 --- a/src/sp-script.cpp +++ b/src/sp-script.cpp @@ -16,16 +16,6 @@ #include <cstring> #include "document.h" -#include "sp-factory.h" - -namespace { - SPObject* createScript() { - return new SPScript(); - } - - bool scriptRegistered = SPFactory::instance().registerObject("svg:script", createScript); -} - SPScript::SPScript() : SPObject() { this->xlinkhref = NULL; } diff --git a/src/sp-solid-color.cpp b/src/sp-solid-color.cpp index 72569d8c0..f319410b0 100644 --- a/src/sp-solid-color.cpp +++ b/src/sp-solid-color.cpp @@ -16,18 +16,9 @@ #include "style.h" #include "xml/repr.h" -#include "sp-factory.h" #include "sp-item.h" #include "style-internal.h" -namespace { - SPObject* createSolidColor() { - return new SPSolidColor(); - } - - bool solidColorRegistered = SPFactory::instance().registerObject("svg:solidColor", createSolidColor); -} - /* * Solid Color diff --git a/src/sp-spiral.cpp b/src/sp-spiral.cpp index 9ef73d56d..5dbd7dfa0 100644 --- a/src/sp-spiral.cpp +++ b/src/sp-spiral.cpp @@ -28,16 +28,6 @@ #include "sp-spiral.h" -#include "sp-factory.h" - -namespace { - SPObject* createSpiral() { - return new SPSpiral(); - } - - bool spiralRegistered = SPFactory::instance().registerObject("spiral", createSpiral); -} - SPSpiral::SPSpiral() : SPShape() , cx(0) diff --git a/src/sp-star.cpp b/src/sp-star.cpp index 97a690520..51d5e6254 100644 --- a/src/sp-star.cpp +++ b/src/sp-star.cpp @@ -32,16 +32,6 @@ #include "sp-star.h" -#include "sp-factory.h" - -namespace { - SPObject* createStar() { - return new SPStar(); - } - - bool starRegistered = SPFactory::instance().registerObject("star", createStar); -} - SPStar::SPStar() : SPPolygon() { this->sides = 5; this->center = Geom::Point(0, 0); diff --git a/src/sp-stop.cpp b/src/sp-stop.cpp index 3ee467322..5e8fed86c 100644 --- a/src/sp-stop.cpp +++ b/src/sp-stop.cpp @@ -24,16 +24,6 @@ #include "svg/css-ostringstream.h" #include "xml/repr.h" -#include "sp-factory.h" - -namespace { - SPObject* createStop() { - return new SPStop(); - } - - bool stopRegistered = SPFactory::instance().registerObject("svg:stop", createStop); -} - SPStop::SPStop() : SPObject() { this->path_string = NULL; diff --git a/src/sp-string.cpp b/src/sp-string.cpp index b561187d0..26bb44006 100644 --- a/src/sp-string.cpp +++ b/src/sp-string.cpp @@ -22,30 +22,13 @@ * */ - - -#ifdef HAVE_CONFIG_H -# include "config.h" -#endif - - #include "sp-string.h" #include "style.h" #include "xml/repr.h" -#include "sp-factory.h" - #include <iostream> -namespace { - SPObject* createString() { - return new SPString(); - } - - bool stringRegistered = SPFactory::instance().registerObject("string", createString); -} - /*##################################################### # SPSTRING #####################################################*/ diff --git a/src/sp-style-elem.cpp b/src/sp-style-elem.cpp index 668780272..80e45677c 100644 --- a/src/sp-style-elem.cpp +++ b/src/sp-style-elem.cpp @@ -7,16 +7,6 @@ #include "style.h" using Inkscape::XML::TEXT_NODE; -#include "sp-factory.h" - -namespace { - SPObject* createStyle() { - return new SPStyleElem(); - } - - bool styleRegistered = SPFactory::instance().registerObject("svg:style", createStyle); -} - SPStyleElem::SPStyleElem() : SPObject() { media_set_all(this->media); this->is_css = false; diff --git a/src/sp-switch.cpp b/src/sp-switch.cpp index db6db9909..66cec3637 100644 --- a/src/sp-switch.cpp +++ b/src/sp-switch.cpp @@ -12,10 +12,6 @@ * Released under GNU GPL, read the file 'COPYING' for more information */ -#ifdef HAVE_CONFIG_H -# include "config.h" -#endif - #include <glibmm/i18n.h> #include "sp-switch.h" @@ -25,16 +21,6 @@ #include <sigc++/functors/ptr_fun.h> #include <sigc++/adaptors/bind.h> -#include "sp-factory.h" - -namespace { - SPObject* createSwitch() { - return new SPSwitch(); - } - - bool switchRegistered = SPFactory::instance().registerObject("svg:switch", createSwitch); -} - SPSwitch::SPSwitch() : SPGroup() { this->_cached_item = 0; } diff --git a/src/sp-symbol.cpp b/src/sp-symbol.cpp index 3156680b3..62fb232a3 100644 --- a/src/sp-symbol.cpp +++ b/src/sp-symbol.cpp @@ -26,16 +26,6 @@ #include "sp-symbol.h" #include "document.h" -#include "sp-factory.h" - -namespace { - SPObject* createSymbol() { - return new SPSymbol(); - } - - bool symbolRegistered = SPFactory::instance().registerObject("svg:symbol", createSymbol); -} - SPSymbol::SPSymbol() : SPGroup(), SPViewBox() { } diff --git a/src/sp-tag-use-reference.cpp b/src/sp-tag-use-reference.cpp index 50c011812..220cd16d1 100644 --- a/src/sp-tag-use-reference.cpp +++ b/src/sp-tag-use-reference.cpp @@ -20,16 +20,6 @@ #include "sp-text.h" #include "uri.h" -#if 0 -namespace { - SPObject* createTagUseReference() { - return new SPTag(); - } - bool tagUseReferencesRegistered = SPFactory::instance().registerObject("inkscape:tag", createTag); -} -// this SPObject doesn't need to be registered -#endif - bool SPTagUseReference::_acceptObject(SPObject * const obj) const { diff --git a/src/sp-tag-use.cpp b/src/sp-tag-use.cpp index 5851598f2..935f7429e 100644 --- a/src/sp-tag-use.cpp +++ b/src/sp-tag-use.cpp @@ -10,10 +10,6 @@ * Released under GNU GPL, read the file 'COPYING' for more information */ -#ifdef HAVE_CONFIG_H -# include <config.h> -#endif - #include <cstring> #include <string> @@ -30,13 +26,6 @@ #include "sp-tag-use.h" #include "sp-tag-use-reference.h" -namespace { - SPObject* createTagUse() { - return new SPTagUse(); - } - bool tagUseRegistered = SPFactory::instance().registerObject("inkscape:tagref", createTagUse); -} - SPTagUse::SPTagUse() { href = NULL; @@ -173,7 +162,7 @@ SPTagUse::href_changed(SPObject */*old_ref*/, SPObject */*ref*/) Inkscape::XML::Node *childrepr = refobj->getRepr(); const std::string typeString = NodeTraits::get_type_string(*childrepr); - SPObject* child_ = SPFactory::instance().createObject(typeString); + SPObject* child_ = SPFactory::createObject(typeString); if (child_) { child = child_; attach(child_, lastChild()); diff --git a/src/sp-tag.cpp b/src/sp-tag.cpp index c4b40417f..d331e6b18 100644 --- a/src/sp-tag.cpp +++ b/src/sp-tag.cpp @@ -10,23 +10,11 @@ * Released under GNU GPL, read the file 'COPYING' for more information */ -#ifdef HAVE_CONFIG_H -# include "config.h" -#endif - #include "attributes.h" -#include "sp-factory.h" #include "sp-tag.h" #include "xml/repr.h" #include <cstring> -namespace { - SPObject* createTag() { - return new SPTag(); - } - bool tagsRegistered = SPFactory::instance().registerObject("inkscape:tag", createTag); -} - /* * Move this SPItem into or after another SPItem in the doc * \param target - the SPItem to move into or after diff --git a/src/sp-text.cpp b/src/sp-text.cpp index e40661824..0dca42bb4 100644 --- a/src/sp-text.cpp +++ b/src/sp-text.cpp @@ -23,10 +23,6 @@ * */ -#ifdef HAVE_CONFIG_H -# include "config.h" -#endif - #include <2geom/affine.h> #include <libnrtype/FontFactory.h> #include <libnrtype/font-instance.h> @@ -55,22 +51,12 @@ #include "text-editing.h" -#include "sp-factory.h" - // For SVG 2 text flow #include "livarot/Path.h" #include "livarot/Shape.h" #include "sp-shape.h" #include "display/curve.h" -namespace { - SPObject* createText() { - return new SPText(); - } - - bool textRegistered = SPFactory::instance().registerObject("svg:text", createText); -} - /*##################################################### # SPTEXT #####################################################*/ diff --git a/src/sp-title.cpp b/src/sp-title.cpp index 4ecfcfa8e..ba5ae754a 100644 --- a/src/sp-title.cpp +++ b/src/sp-title.cpp @@ -9,23 +9,9 @@ * Released under GNU GPL, read the file 'COPYING' for more information */ -#ifdef HAVE_CONFIG_H -# include "config.h" -#endif - #include "sp-title.h" #include "xml/repr.h" -#include "sp-factory.h" - -namespace { - SPObject* createTitle() { - return new SPTitle(); - } - - bool titleRegistered = SPFactory::instance().registerObject("svg:title", createTitle); -} - SPTitle::SPTitle() : SPObject() { } diff --git a/src/sp-tref.cpp b/src/sp-tref.cpp index 6a229e170..aef18462a 100644 --- a/src/sp-tref.cpp +++ b/src/sp-tref.cpp @@ -16,10 +16,6 @@ * Released under GNU GPL, read the file 'COPYING' for more information */ -#ifdef HAVE_CONFIG_H -# include "config.h" -#endif - #include <glibmm/i18n.h> #include "attributes.h" @@ -35,14 +31,6 @@ #include "xml/node.h" #include "xml/repr.h" -namespace { - SPObject* createTRef() { - return new SPTRef(); - } - - bool trefRegistered = SPFactory::instance().registerObject("svg:tref", createTRef); -} - //#define DEBUG_TREF #ifdef DEBUG_TREF # define debug(f, a...) { g_message("%s(%d) %s:", \ @@ -413,7 +401,7 @@ void sp_tref_update_text(SPTRef *tref) Inkscape::XML::Document *xml_doc = tref->document->getReprDoc(); Inkscape::XML::Node *newStringRepr = xml_doc->createTextNode(charData.c_str()); - tref->stringChild = SPFactory::instance().createObject(NodeTraits::get_type_string(*newStringRepr)); + tref->stringChild = SPFactory::createObject(NodeTraits::get_type_string(*newStringRepr)); // Add this SPString as a child of the tref tref->attach(tref->stringChild, tref->lastChild()); diff --git a/src/sp-tspan.cpp b/src/sp-tspan.cpp index 147efff33..7582cb9e6 100644 --- a/src/sp-tspan.cpp +++ b/src/sp-tspan.cpp @@ -44,21 +44,6 @@ #include "document.h" #include "2geom/transforms.h" -#include "sp-factory.h" - -namespace { - SPObject* createTSpan() { - return new SPTSpan(); - } - - SPObject* createTextPath() { - return new SPTextPath(); - } - - bool tspanRegistered = SPFactory::instance().registerObject("svg:tspan", createTSpan); - bool textPathRegistered = SPFactory::instance().registerObject("svg:textPath", createTextPath); -} - /*##################################################### # SPTSPAN #####################################################*/ diff --git a/src/sp-use.cpp b/src/sp-use.cpp index 7e02de3c1..239f487a4 100644 --- a/src/sp-use.cpp +++ b/src/sp-use.cpp @@ -13,10 +13,6 @@ * Released under GNU GPL, read the file 'COPYING' for more information */ -#ifdef HAVE_CONFIG_H -# include <config.h> -#endif - #include <cstring> #include <string> @@ -42,14 +38,6 @@ #include "sp-text.h" #include "sp-flowtext.h" -namespace { - SPObject* createUse() { - return new SPUse(); - } - - bool useRegistered = SPFactory::instance().registerObject("svg:use", createUse); -} - SPUse::SPUse() : SPItem(), child(NULL), @@ -482,7 +470,7 @@ void SPUse::href_changed() { if (refobj) { Inkscape::XML::Node *childrepr = refobj->getRepr(); - SPObject* obj = SPFactory::instance().createObject(NodeTraits::get_type_string(*childrepr)); + SPObject* obj = SPFactory::createObject(NodeTraits::get_type_string(*childrepr)); SPItem *item = dynamic_cast<SPItem *>(obj); if (item) { diff --git a/src/ui/CMakeLists.txt b/src/ui/CMakeLists.txt index 98a5a224c..674254686 100644 --- a/src/ui/CMakeLists.txt +++ b/src/ui/CMakeLists.txt @@ -8,6 +8,7 @@ set(ui_SRC object-edit.cpp previewholder.cpp shape-editor.cpp + tool-factory.cpp tools-switch.cpp uxmanager.cpp diff --git a/src/ui/Makefile_insert b/src/ui/Makefile_insert index 7aeb4a83d..f94cba4e9 100644 --- a/src/ui/Makefile_insert +++ b/src/ui/Makefile_insert @@ -21,6 +21,7 @@ ink_common_sources += \ ui/previewholder.h \ ui/shape-editor.cpp \ ui/shape-editor.h \ + ui/tool-factory.cpp \ ui/tool-factory.h \ ui/tools-switch.cpp \ ui/tools-switch.h \ diff --git a/src/ui/tool-factory.cpp b/src/ui/tool-factory.cpp new file mode 100644 index 000000000..700bd40ce --- /dev/null +++ b/src/ui/tool-factory.cpp @@ -0,0 +1,102 @@ +/* + * Factory for ToolBase tree + * + * Authors: + * Markus Engel + * + * Copyright (C) 2013 Authors + * Released under GNU GPL, read the file 'COPYING' for more information + */ + +#include "tool-factory.h" + +#include "ui/tools/arc-tool.h" +#include "ui/tools/box3d-tool.h" +#include "ui/tools/calligraphic-tool.h" +#include "ui/tools/connector-tool.h" +#include "ui/tools/dropper-tool.h" +#include "ui/tools/eraser-tool.h" +#include "ui/tools/flood-tool.h" +#include "ui/tools/gradient-tool.h" +#include "ui/tools/lpe-tool.h" +#include "ui/tools/measure-tool.h" +#include "ui/tools/mesh-tool.h" +#include "ui/tools/node-tool.h" +#include "ui/tools/pencil-tool.h" +#include "ui/tools/pen-tool.h" +#include "ui/tools/rect-tool.h" +#include "ui/tools/select-tool.h" +#include "ui/tools/spiral-tool.h" +#include "ui/tools/spray-tool.h" +#include "ui/tools/star-tool.h" +#include "ui/tools/text-tool.h" +#include "ui/tools/tool-base.h" +#include "ui/tools/tweak-tool.h" +#include "ui/tools/zoom-tool.h" + +using namespace Inkscape::UI::Tools; + +ToolBase *ToolFactory::createObject(std::string const& id) +{ + ToolBase *tool = NULL; + + if (id == "/tools/shapes/arc") + tool = new ArcTool; + else if (id == "/tools/shapes/3dbox") + tool = new Box3dTool; + else if (id == "/tools/calligraphic") + tool = new CalligraphicTool; + else if (id == "/tools/connector") + tool = new ConnectorTool; + else if (id == "/tools/dropper") + tool = new DropperTool; + else if (id == "/tools/eraser") + tool = new EraserTool; + else if (id == "/tools/paintbucket") + tool = new FloodTool; + else if (id == "/tools/gradient") + tool = new GradientTool; + else if (id == "/tools/lpetool") + tool = new LpeTool; + else if (id == "/tools/measure") + tool = new MeasureTool; + else if (id == "/tools/mesh") + tool = new MeshTool; + else if (id == "/tools/nodes") + tool = new NodeTool; + else if (id == "/tools/freehand/pencil") + tool = new PencilTool; + else if (id == "/tools/freehand/pen") + tool = new PenTool; + else if (id == "/tools/shapes/rect") + tool = new RectTool; + else if (id == "/tools/select") + tool = new SelectTool; + else if (id == "/tools/shapes/spiral") + tool = new SpiralTool; + else if (id == "/tools/spray") + tool = new SprayTool; + else if (id == "/tools/shapes/star") + tool = new StarTool; + else if (id == "/tools/text") + tool = new TextTool; + else if (id == "/tools/tweak") + tool = new TweakTool; + else if (id == "/tools/zoom") + tool = new ZoomTool; + else + fprintf(stderr, "WARNING: unknown tool: %s", id.c_str()); + + return tool; +} + +/* + Local Variables: + mode:c++ + c-file-style:"stroustrup" + c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +)) + indent-tabs-mode:nil + fill-column:99 + End: +*/ +// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:fileencoding=utf-8:textwidth=99 : diff --git a/src/ui/tool-factory.h b/src/ui/tool-factory.h index 726706732..3b041fec5 100644 --- a/src/ui/tool-factory.h +++ b/src/ui/tool-factory.h @@ -1,6 +1,6 @@ -/** @file +/* * Factory for ToolBase tree - *//* + * * Authors: * Markus Engel * @@ -11,7 +11,7 @@ #ifndef TOOL_FACTORY_SEEN #define TOOL_FACTORY_SEEN -#include "factory.h" +#include <string> namespace Inkscape { namespace UI { @@ -23,7 +23,9 @@ class ToolBase; } } -typedef Singleton< Factory<Inkscape::UI::Tools::ToolBase> > ToolFactory; +struct ToolFactory { + static Inkscape::UI::Tools::ToolBase *createObject(std::string const& id); +}; #endif diff --git a/src/ui/tools/arc-tool.cpp b/src/ui/tools/arc-tool.cpp index b9206407a..c6a9bb23a 100644 --- a/src/ui/tools/arc-tool.cpp +++ b/src/ui/tools/arc-tool.cpp @@ -48,20 +48,10 @@ using Inkscape::DocumentUndo; -#include "ui/tool-factory.h" - namespace Inkscape { namespace UI { namespace Tools { -namespace { - ToolBase* createArcContext() { - return new ArcTool(); - } - - bool arcContextRegistered = ToolFactory::instance().registerObject("/tools/shapes/arc", createArcContext); -} - const std::string& ArcTool::getPrefsPath() { return ArcTool::prefsPath; } diff --git a/src/ui/tools/box3d-tool.cpp b/src/ui/tools/box3d-tool.cpp index f8ae685c4..538e0c7e2 100644 --- a/src/ui/tools/box3d-tool.cpp +++ b/src/ui/tools/box3d-tool.cpp @@ -52,20 +52,10 @@ using Inkscape::DocumentUndo; -#include "ui/tool-factory.h" - namespace Inkscape { namespace UI { namespace Tools { -namespace { - ToolBase* createBox3dTool() { - return new Box3dTool(); - } - - bool Box3dToolRegistered = ToolFactory::instance().registerObject("/tools/shapes/3dbox", createBox3dTool); -} - const std::string& Box3dTool::getPrefsPath() { return Box3dTool::prefsPath; } diff --git a/src/ui/tools/calligraphic-tool.cpp b/src/ui/tools/calligraphic-tool.cpp index 151ab5f89..15e6527a3 100644 --- a/src/ui/tools/calligraphic-tool.cpp +++ b/src/ui/tools/calligraphic-tool.cpp @@ -82,22 +82,12 @@ using Inkscape::DocumentUndo; #define DYNA_MIN_WIDTH 1.0e-6 -#include "ui/tool-factory.h" - namespace Inkscape { namespace UI { namespace Tools { static void add_cap(SPCurve *curve, Geom::Point const &from, Geom::Point const &to, double rounding); -namespace { - ToolBase* createCalligraphicContext() { - return new CalligraphicTool(); - } - - bool calligraphicContextRegistered = ToolFactory::instance().registerObject("/tools/calligraphic", createCalligraphicContext); -} - const std::string& CalligraphicTool::getPrefsPath() { return CalligraphicTool::prefsPath; } diff --git a/src/ui/tools/connector-tool.cpp b/src/ui/tools/connector-tool.cpp index 26a4eadd5..d76b0d142 100644 --- a/src/ui/tools/connector-tool.cpp +++ b/src/ui/tools/connector-tool.cpp @@ -109,8 +109,6 @@ using Inkscape::DocumentUndo; -#include "ui/tool-factory.h" - namespace Inkscape { namespace UI { namespace Tools { @@ -147,14 +145,6 @@ static Inkscape::XML::NodeEventVector layer_repr_events = { NULL /* order_changed */ }; -namespace { - ToolBase* createConnectorContext() { - return new ConnectorTool(); - } - - bool connectorContextRegistered = ToolFactory::instance().registerObject("/tools/connector", createConnectorContext); -} - const std::string& ConnectorTool::getPrefsPath() { return ConnectorTool::prefsPath; } diff --git a/src/ui/tools/dropper-tool.cpp b/src/ui/tools/dropper-tool.cpp index 9038628ee..bda9d8e8a 100644 --- a/src/ui/tools/dropper-tool.cpp +++ b/src/ui/tools/dropper-tool.cpp @@ -52,20 +52,10 @@ using Inkscape::DocumentUndo; static GdkCursor *cursor_dropper_fill = NULL; static GdkCursor *cursor_dropper_stroke = NULL; -#include "ui/tool-factory.h" - namespace Inkscape { namespace UI { namespace Tools { -namespace { - ToolBase* createDropperContext() { - return new DropperTool(); - } - - bool dropperContextRegistered = ToolFactory::instance().registerObject("/tools/dropper", createDropperContext); -} - const std::string& DropperTool::getPrefsPath() { return DropperTool::prefsPath; } diff --git a/src/ui/tools/eraser-tool.cpp b/src/ui/tools/eraser-tool.cpp index 1b4dcfe25..af0cbcb78 100644 --- a/src/ui/tools/eraser-tool.cpp +++ b/src/ui/tools/eraser-tool.cpp @@ -84,20 +84,10 @@ using Inkscape::DocumentUndo; #define DRAG_DEFAULT 1.0 #define DRAG_MAX 1.0 -#include "ui/tool-factory.h" - namespace Inkscape { namespace UI { namespace Tools { -namespace { - ToolBase* createEraserContext() { - return new EraserTool(); - } - - bool eraserContextRegistered = ToolFactory::instance().registerObject("/tools/eraser", createEraserContext); -} - const std::string& EraserTool::getPrefsPath() { return EraserTool::prefsPath; } diff --git a/src/ui/tools/flood-tool.cpp b/src/ui/tools/flood-tool.cpp index f9b64e4fd..bb8782dfa 100644 --- a/src/ui/tools/flood-tool.cpp +++ b/src/ui/tools/flood-tool.cpp @@ -74,20 +74,10 @@ using Inkscape::Display::ExtractARGB32; using Inkscape::Display::ExtractRGB32; using Inkscape::Display::AssembleARGB32; -#include "ui/tool-factory.h" - namespace Inkscape { namespace UI { namespace Tools { -namespace { - ToolBase* createPaintbucketContext() { - return new FloodTool(); - } - - bool paintbucketContextRegistered = ToolFactory::instance().registerObject("/tools/paintbucket", createPaintbucketContext); -} - const std::string& FloodTool::getPrefsPath() { return FloodTool::prefsPath; } diff --git a/src/ui/tools/gradient-tool.cpp b/src/ui/tools/gradient-tool.cpp index 5da30da7b..5be84eb76 100644 --- a/src/ui/tools/gradient-tool.cpp +++ b/src/ui/tools/gradient-tool.cpp @@ -51,22 +51,12 @@ using Inkscape::DocumentUndo; -#include "ui/tool-factory.h" - namespace Inkscape { namespace UI { namespace Tools { static void sp_gradient_drag(GradientTool &rc, Geom::Point const pt, guint state, guint32 etime); -namespace { - ToolBase* createGradientContext() { - return new GradientTool(); - } - - bool gradientContextRegistered = ToolFactory::instance().registerObject("/tools/gradient", createGradientContext); -} - const std::string& GradientTool::getPrefsPath() { return GradientTool::prefsPath; } diff --git a/src/ui/tools/lpe-tool.cpp b/src/ui/tools/lpe-tool.cpp index c9b656397..c0517578d 100644 --- a/src/ui/tools/lpe-tool.cpp +++ b/src/ui/tools/lpe-tool.cpp @@ -58,23 +58,12 @@ SubtoolEntry lpesubtools[] = { {Inkscape::LivePathEffect::MIRROR_SYMMETRY, "draw-geometry-mirror"} }; - -#include "ui/tool-factory.h" - namespace Inkscape { namespace UI { namespace Tools { void sp_lpetool_context_selection_changed(Inkscape::Selection *selection, gpointer data); -namespace { - ToolBase* createLPEToolContext() { - return new LpeTool(); - } - - bool lpetoolContextRegistered = ToolFactory::instance().registerObject("/tools/lpetool", createLPEToolContext); -} - const std::string& LpeTool::getPrefsPath() { return LpeTool::prefsPath; } diff --git a/src/ui/tools/measure-tool.cpp b/src/ui/tools/measure-tool.cpp index b7e54b9c8..0875c29e0 100644 --- a/src/ui/tools/measure-tool.cpp +++ b/src/ui/tools/measure-tool.cpp @@ -49,22 +49,12 @@ using Inkscape::ControlManager; using Inkscape::CTLINE_SECONDARY; using Inkscape::Util::unit_table; -#include "ui/tool-factory.h" - namespace Inkscape { namespace UI { namespace Tools { std::vector<Inkscape::Display::TemporaryItem*> measure_tmp_items; -namespace { - ToolBase* createMeasureContext() { - return new MeasureTool(); - } - - bool measureContextRegistered = ToolFactory::instance().registerObject("/tools/measure", createMeasureContext); -} - const std::string& MeasureTool::getPrefsPath() { return MeasureTool::prefsPath; } diff --git a/src/ui/tools/mesh-tool.cpp b/src/ui/tools/mesh-tool.cpp index d333b932e..9527b7de8 100644 --- a/src/ui/tools/mesh-tool.cpp +++ b/src/ui/tools/mesh-tool.cpp @@ -53,22 +53,12 @@ using Inkscape::DocumentUndo; -#include "ui/tool-factory.h" - namespace Inkscape { namespace UI { namespace Tools { static void sp_mesh_drag(MeshTool &rc, Geom::Point const pt, guint state, guint32 etime); -namespace { - ToolBase* createMeshContext() { - return new MeshTool(); - } - - bool meshContextRegistered = ToolFactory::instance().registerObject("/tools/mesh", createMeshContext); -} - const std::string& MeshTool::getPrefsPath() { return MeshTool::prefsPath; } diff --git a/src/ui/tools/node-tool.cpp b/src/ui/tools/node-tool.cpp index caec901a6..f8045a029 100644 --- a/src/ui/tools/node-tool.cpp +++ b/src/ui/tools/node-tool.cpp @@ -107,20 +107,10 @@ using Inkscape::ControlManager; -#include "ui/tool-factory.h" - namespace Inkscape { namespace UI { namespace Tools { -namespace { - ToolBase* createNodesContext() { - return new NodeTool(); - } - - bool nodesContextRegistered = ToolFactory::instance().registerObject("/tools/nodes", createNodesContext); -} - const std::string& NodeTool::getPrefsPath() { return NodeTool::prefsPath; } diff --git a/src/ui/tools/pen-tool.cpp b/src/ui/tools/pen-tool.cpp index 5174775c9..d28b7c27a 100644 --- a/src/ui/tools/pen-tool.cpp +++ b/src/ui/tools/pen-tool.cpp @@ -73,8 +73,6 @@ #include "live_effects/lpe-bspline.h" #include <2geom/nearest-point.h> -#include "ui/tool-factory.h" - #include "live_effects/effect.h" @@ -88,13 +86,6 @@ static Geom::Point pen_drag_origin_w(0, 0); static bool pen_within_tolerance = false; static int pen_last_paraxial_dir = 0; // last used direction in horizontal/vertical mode; 0 = horizontal, 1 = vertical const double handleCubicGap = 0.01; -namespace { - ToolBase* createPenContext() { - return new PenTool(); - } - - bool penContextRegistered = ToolFactory::instance().registerObject("/tools/freehand/pen", createPenContext); -} const std::string& PenTool::getPrefsPath() { return PenTool::prefsPath; diff --git a/src/ui/tools/pencil-tool.cpp b/src/ui/tools/pencil-tool.cpp index 28fed3a8f..db24c7432 100644 --- a/src/ui/tools/pencil-tool.cpp +++ b/src/ui/tools/pencil-tool.cpp @@ -43,7 +43,6 @@ #include "display/sp-canvas.h" #include "display/curve.h" #include "livarot/Path.h" -#include "ui/tool-factory.h" #include "ui/tool/event-utils.h" namespace Inkscape { @@ -55,14 +54,6 @@ static bool pencil_within_tolerance = false; static bool in_svg_plane(Geom::Point const &p) { return Geom::LInfty(p) < 1e18; } -namespace { - ToolBase* createPencilContext() { - return new PencilTool(); - } - - bool pencilContextRegistered = ToolFactory::instance().registerObject("/tools/freehand/pencil", createPencilContext); -} - const std::string& PencilTool::getPrefsPath() { return PencilTool::prefsPath; } diff --git a/src/ui/tools/rect-tool.cpp b/src/ui/tools/rect-tool.cpp index 9476ff624..62a9006ea 100644 --- a/src/ui/tools/rect-tool.cpp +++ b/src/ui/tools/rect-tool.cpp @@ -46,20 +46,10 @@ using Inkscape::DocumentUndo; -#include "ui/tool-factory.h" - namespace Inkscape { namespace UI { namespace Tools { -namespace { - ToolBase* createRectContext() { - return new RectTool(); - } - - bool rectContextRegistered = ToolFactory::instance().registerObject("/tools/shapes/rect", createRectContext); -} - const std::string& RectTool::getPrefsPath() { return RectTool::prefsPath; } diff --git a/src/ui/tools/select-tool.cpp b/src/ui/tools/select-tool.cpp index 939b1a0b3..40b994968 100644 --- a/src/ui/tools/select-tool.cpp +++ b/src/ui/tools/select-tool.cpp @@ -49,7 +49,6 @@ #include "display/sp-canvas.h" #include "display/sp-canvas-item.h" #include "display/drawing-item.h" -#include "ui/tool-factory.h" using Inkscape::DocumentUndo; @@ -65,14 +64,6 @@ static GdkCursor *CursorSelectDragging = NULL; static gint rb_escaped = 0; // if non-zero, rubberband was canceled by esc, so the next button release should not deselect static gint drag_escaped = 0; // if non-zero, drag was canceled by esc -namespace { - ToolBase* createSelectContext() { - return new SelectTool(); - } - - bool selectContextRegistered = ToolFactory::instance().registerObject("/tools/select", createSelectContext); -} - const std::string& SelectTool::getPrefsPath() { return SelectTool::prefsPath; } diff --git a/src/ui/tools/spiral-tool.cpp b/src/ui/tools/spiral-tool.cpp index f208e1c43..833fef18d 100644 --- a/src/ui/tools/spiral-tool.cpp +++ b/src/ui/tools/spiral-tool.cpp @@ -45,20 +45,10 @@ using Inkscape::DocumentUndo; -#include "ui/tool-factory.h" - namespace Inkscape { namespace UI { namespace Tools { -namespace { - ToolBase* createSpiralContext() { - return new SpiralTool(); - } - - bool spiralContextRegistered = ToolFactory::instance().registerObject("/tools/shapes/spiral", createSpiralContext); -} - const std::string& SpiralTool::getPrefsPath() { return SpiralTool::prefsPath; } diff --git a/src/ui/tools/spray-tool.cpp b/src/ui/tools/spray-tool.cpp index a01c5c55b..790270d91 100644 --- a/src/ui/tools/spray-tool.cpp +++ b/src/ui/tools/spray-tool.cpp @@ -84,20 +84,10 @@ using namespace std; // Please enable again when working on 1.0 #define ENABLE_SPRAY_MODE_SINGLE_PATH -#include "ui/tool-factory.h" - namespace Inkscape { namespace UI { namespace Tools { -namespace { - ToolBase* createSprayContext() { - return new SprayTool(); - } - - bool sprayContextRegistered = ToolFactory::instance().registerObject("/tools/spray", createSprayContext); -} - const std::string& SprayTool::getPrefsPath() { return SprayTool::prefsPath; } diff --git a/src/ui/tools/star-tool.cpp b/src/ui/tools/star-tool.cpp index df311f2d8..9190ae57b 100644 --- a/src/ui/tools/star-tool.cpp +++ b/src/ui/tools/star-tool.cpp @@ -49,20 +49,10 @@ using Inkscape::DocumentUndo; -#include "ui/tool-factory.h" - namespace Inkscape { namespace UI { namespace Tools { -namespace { - ToolBase* createStarContext() { - return new StarTool(); - } - - bool starContextRegistered = ToolFactory::instance().registerObject("/tools/shapes/star", createStarContext); -} - const std::string& StarTool::getPrefsPath() { return StarTool::prefsPath; } diff --git a/src/ui/tools/text-tool.cpp b/src/ui/tools/text-tool.cpp index df0583d67..a2c0c81ae 100644 --- a/src/ui/tools/text-tool.cpp +++ b/src/ui/tools/text-tool.cpp @@ -52,7 +52,6 @@ #include "xml/node-event-vector.h" #include "xml/repr.h" #include <gtk/gtk.h> -#include "ui/tool-factory.h" using Inkscape::ControlManager; using Inkscape::DocumentUndo; @@ -71,14 +70,6 @@ static gint sptc_focus_in(GtkWidget *widget, GdkEventFocus *event, TextTool *tc) static gint sptc_focus_out(GtkWidget *widget, GdkEventFocus *event, TextTool *tc); static void sptc_commit(GtkIMContext *imc, gchar *string, TextTool *tc); -namespace { - ToolBase* createTextContext() { - return new TextTool(); - } - - bool textContextRegistered = ToolFactory::instance().registerObject("/tools/text", createTextContext); -} - const std::string& TextTool::getPrefsPath() { return TextTool::prefsPath; } diff --git a/src/ui/tools/tweak-tool.cpp b/src/ui/tools/tweak-tool.cpp index 5e53fdb93..80b52fba6 100644 --- a/src/ui/tools/tweak-tool.cpp +++ b/src/ui/tools/tweak-tool.cpp @@ -91,20 +91,10 @@ using Inkscape::DocumentUndo; #define DYNA_MIN_WIDTH 1.0e-6 -#include "ui/tool-factory.h" - namespace Inkscape { namespace UI { namespace Tools { -namespace { - ToolBase* createTweakContext() { - return new TweakTool(); - } - - bool tweakContextRegistered = ToolFactory::instance().registerObject("/tools/tweak", createTweakContext); -} - const std::string& TweakTool::getPrefsPath() { return TweakTool::prefsPath; } diff --git a/src/ui/tools/zoom-tool.cpp b/src/ui/tools/zoom-tool.cpp index b3fb78c8f..6a4d4dbbd 100644 --- a/src/ui/tools/zoom-tool.cpp +++ b/src/ui/tools/zoom-tool.cpp @@ -25,20 +25,11 @@ #include "selection-chemistry.h" #include "ui/tools/zoom-tool.h" -#include "ui/tool-factory.h" namespace Inkscape { namespace UI { namespace Tools { -namespace { - ToolBase* createZoomContext() { - return new ZoomTool(); - } - - bool zoomContextRegistered = ToolFactory::instance().registerObject("/tools/zoom", createZoomContext); -} - const std::string& ZoomTool::getPrefsPath() { return ZoomTool::prefsPath; } |
