1 /*
2 * Authors:
3 * Ted Gould <ted@gould.cx>
4 *
5 * Copyright (C) 2006 Authors
6 *
7 * Released under GNU GPL, read the file 'COPYING' for more information
8 */
10 #include "document-private.h"
11 #include "sp-object.h"
13 #include "patheffect.h"
14 #include "db.h"
16 namespace Inkscape {
17 namespace Extension {
19 PathEffect::PathEffect (Inkscape::XML::Node * in_repr, Implementation::Implementation * in_imp)
20 : Extension(in_repr, in_imp)
21 {
23 }
25 PathEffect::~PathEffect (void)
26 {
28 }
30 void
31 PathEffect::processPath (SPDocument * /*doc*/, Inkscape::XML::Node * /*path*/, Inkscape::XML::Node * /*def*/)
32 {
35 }
37 void
38 PathEffect::processPathEffects (SPDocument * doc, Inkscape::XML::Node * path)
39 {
40 gchar const * patheffectlist = path->attribute("inkscape:path-effects");
41 if (patheffectlist == NULL)
42 return;
44 gchar ** patheffects = g_strsplit(patheffectlist, ";", 128);
45 Inkscape::XML::Node * defs = SP_OBJECT_REPR(SP_DOCUMENT_DEFS(doc));
47 for (int i = 0; patheffects[i] != NULL && i < 128; i++) {
48 gchar * patheffect = patheffects[i];
50 // This is weird, they should all be references... but anyway
51 if (patheffect[0] != '#') continue;
53 Inkscape::XML::Node * prefs = sp_repr_lookup_child(defs, "id", &(patheffect[1]));
54 if (prefs == NULL) {
56 continue;
57 }
59 gchar const * ext_id = prefs->attribute("extension");
60 if (ext_id == NULL) {
62 continue;
63 }
65 Inkscape::Extension::PathEffect * peffect;
66 peffect = dynamic_cast<Inkscape::Extension::PathEffect *>(Inkscape::Extension::db.get(ext_id));
67 if (peffect != NULL) {
69 continue;
70 }
72 peffect->processPath(doc, path, prefs);
73 }
75 g_strfreev(patheffects);
76 return;
77 }
80 } } /* namespace Inkscape, Extension */
82 /*
83 Local Variables:
84 mode:c++
85 c-file-style:"stroustrup"
86 c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +))
87 indent-tabs-mode:nil
88 fill-column:99
89 End:
90 */
91 // vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4 :