1 // SPDX-License-Identifier: GPL-2.0-or-later
2 /** \file
3  * feMergeNode implementation. A feMergeNode contains the name of one
4  * input image for feMerge.
5  */
6 /*
7  * Authors:
8  *   Kees Cook <kees@outflux.net>
9  *   Niko Kiirala <niko@kiirala.com>
10  *   Abhishek Sharma
11  *
12  * Copyright (C) 2004,2007 authors
13  *
14  * Released under GNU GPL v2+, read the file 'COPYING' for more information.
15  */
16 
17 #include "mergenode.h"
18 #include "merge.h"
19 
20 #include "attributes.h"
21 
22 #include "display/nr-filter-types.h"
23 
24 #include "xml/repr.h"
25 
SPFeMergeNode()26 SPFeMergeNode::SPFeMergeNode()
27     : SPObject(), input(Inkscape::Filters::NR_FILTER_SLOT_NOT_SET) {
28 }
29 
30 SPFeMergeNode::~SPFeMergeNode() = default;
31 
32 /**
33  * Reads the Inkscape::XML::Node, and initializes SPFeMergeNode variables.  For this to get called,
34  * our name must be associated with a repr via "sp_object_type_register".  Best done through
35  * sp-object-repr.cpp's repr_name_entries array.
36  */
build(SPDocument *,Inkscape::XML::Node *)37 void SPFeMergeNode::build(SPDocument */*document*/, Inkscape::XML::Node */*repr*/) {
38 	this->readAttr(SPAttr::IN_);
39 }
40 
41 /**
42  * Drops any allocated memory.
43  */
release()44 void SPFeMergeNode::release() {
45 	SPObject::release();
46 }
47 
48 /**
49  * Sets a specific value in the SPFeMergeNode.
50  */
set(SPAttr key,gchar const * value)51 void SPFeMergeNode::set(SPAttr key, gchar const *value) {
52     SPFeMerge *parent = SP_FEMERGE(this->parent);
53 
54     if (key == SPAttr::IN_) {
55         int input = parent->read_in(value);
56         if (input != this->input) {
57             this->input = input;
58             this->requestModified(SP_OBJECT_MODIFIED_FLAG);
59         }
60     }
61 
62     /* See if any parents need this value. */
63     SPObject::set(key, value);
64 }
65 
66 /**
67  * Receives update notifications.
68  */
update(SPCtx * ctx,guint flags)69 void SPFeMergeNode::update(SPCtx *ctx, guint flags) {
70     if (flags & SP_OBJECT_MODIFIED_FLAG) {
71         this->parent->requestModified(SP_OBJECT_MODIFIED_FLAG);
72     }
73 
74     SPObject::update(ctx, flags);
75 }
76 
77 /**
78  * Writes its settings to an incoming repr object, if any.
79  */
write(Inkscape::XML::Document * doc,Inkscape::XML::Node * repr,guint flags)80 Inkscape::XML::Node* SPFeMergeNode::write(Inkscape::XML::Document *doc, Inkscape::XML::Node *repr, guint flags) {
81     // Inkscape-only this, not copied during an "plain SVG" dump:
82     if (flags & SP_OBJECT_WRITE_EXT) {
83         if (repr) {
84             // is this sane?
85             //repr->mergeFrom(object->getRepr(), "id");
86         } else {
87             repr = this->getRepr()->duplicate(doc);
88         }
89     }
90 
91     SPObject::write(doc, repr, flags);
92 
93     return repr;
94 }
95 
96 
97 /*
98   Local Variables:
99   mode:c++
100   c-file-style:"stroustrup"
101   c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +))
102   indent-tabs-mode:nil
103   fill-column:99
104   End:
105 */
106 // vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:fileencoding=utf-8:textwidth=99 :
107