summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorMarkus Engel <markus.engel@tum.de>2013-07-31 23:06:31 +0000
committerMarkus Engel <markus.engel@tum.de>2013-07-31 23:06:31 +0000
commit49c324545e713c1ca375b7e559418e02ebe52945 (patch)
treeb1fa48caaa5446f49c09a1d73d48730893fbf8b0 /src
parentRemoved placement news / explicit destructor calls. (diff)
downloadinkscape-49c324545e713c1ca375b7e559418e02ebe52945.tar.gz
inkscape-49c324545e713c1ca375b7e559418e02ebe52945.zip
Replacement of unnecessary variables.
(bzr r11608.1.114)
Diffstat (limited to 'src')
-rw-r--r--src/filters/blend.cpp107
-rw-r--r--src/filters/blend.h1
-rw-r--r--src/filters/colormatrix.cpp57
-rw-r--r--src/filters/colormatrix.h1
-rw-r--r--src/filters/componenttransfer.cpp44
-rw-r--r--src/filters/componenttransfer.h1
-rw-r--r--src/filters/composite.cpp179
-rw-r--r--src/filters/composite.h1
-rw-r--r--src/filters/convolvematrix.cpp214
-rw-r--r--src/filters/convolvematrix.h1
-rw-r--r--src/filters/diffuselighting.cpp188
-rw-r--r--src/filters/diffuselighting.h1
-rw-r--r--src/filters/displacementmap.cpp107
-rw-r--r--src/filters/displacementmap.h1
-rw-r--r--src/filters/flood.cpp71
-rw-r--r--src/filters/flood.h1
-rw-r--r--src/filters/gaussian-blur.cpp38
-rw-r--r--src/filters/gaussian-blur.h1
-rw-r--r--src/filters/image.cpp99
-rw-r--r--src/filters/image.h1
-rw-r--r--src/filters/merge.cpp26
-rw-r--r--src/filters/merge.h1
-rw-r--r--src/filters/morphology.cpp64
-rw-r--r--src/filters/morphology.h1
-rw-r--r--src/filters/offset.cpp47
-rw-r--r--src/filters/offset.h1
-rw-r--r--src/filters/specularlighting.cpp203
-rw-r--r--src/filters/specularlighting.h1
-rw-r--r--src/filters/tile.cpp20
-rw-r--r--src/filters/tile.h1
-rw-r--r--src/filters/turbulence.cpp128
-rw-r--r--src/filters/turbulence.h1
-rw-r--r--src/sp-flowdiv.cpp125
-rw-r--r--src/sp-flowdiv.h5
-rw-r--r--src/sp-font-face.cpp499
-rw-r--r--src/sp-font-face.h1
-rw-r--r--src/sp-font.cpp128
-rw-r--r--src/sp-font.h1
-rw-r--r--src/sp-glyph-kerning.cpp129
-rw-r--r--src/sp-glyph-kerning.h1
-rw-r--r--src/sp-glyph.cpp204
-rw-r--r--src/sp-glyph.h1
-rw-r--r--src/sp-guide.cpp56
-rw-r--r--src/sp-guide.h1
44 files changed, 1356 insertions, 1403 deletions
diff --git a/src/filters/blend.cpp b/src/filters/blend.cpp
index d2f281805..219a099d1 100644
--- a/src/filters/blend.cpp
+++ b/src/filters/blend.cpp
@@ -40,10 +40,10 @@ namespace {
bool blendRegistered = SPFactory::instance().registerObject("svg:feBlend", createBlend);
}
-SPFeBlend::SPFeBlend() : SPFilterPrimitive() {
- this->blend_mode = Inkscape::Filters::BLEND_NORMAL;
-
- this->in2 = Inkscape::Filters::NR_FILTER_SLOT_NOT_SET;
+SPFeBlend::SPFeBlend()
+ : SPFilterPrimitive(), blend_mode(Inkscape::Filters::BLEND_NORMAL),
+ in2(Inkscape::Filters::NR_FILTER_SLOT_NOT_SET)
+{
}
SPFeBlend::~SPFeBlend() {
@@ -55,24 +55,20 @@ SPFeBlend::~SPFeBlend() {
* sp-object-repr.cpp's repr_name_entries array.
*/
void SPFeBlend::build(SPDocument *document, Inkscape::XML::Node *repr) {
- SPFeBlend* object = this;
-
- SPFeBlend *blend = SP_FEBLEND(object);
-
SPFilterPrimitive::build(document, repr);
/*LOAD ATTRIBUTES FROM REPR HERE*/
- object->readAttr( "mode" );
- object->readAttr( "in2" );
+ this->readAttr( "mode" );
+ this->readAttr( "in2" );
/* Unlike normal in, in2 is required attribute. Make sure, we can call
* it by some name. */
- if (blend->in2 == Inkscape::Filters::NR_FILTER_SLOT_NOT_SET ||
- blend->in2 == Inkscape::Filters::NR_FILTER_UNNAMED_SLOT)
+ if (this->in2 == Inkscape::Filters::NR_FILTER_SLOT_NOT_SET ||
+ this->in2 == Inkscape::Filters::NR_FILTER_UNNAMED_SLOT)
{
- SPFilter *parent = SP_FILTER(object->parent);
- blend->in2 = sp_filter_primitive_name_previous_out(blend);
- repr->setAttribute("in2", sp_filter_name_for_image(parent, blend->in2));
+ SPFilter *parent = SP_FILTER(this->parent);
+ this->in2 = sp_filter_primitive_name_previous_out(this);
+ repr->setAttribute("in2", sp_filter_name_for_image(parent, this->in2));
}
}
@@ -83,9 +79,11 @@ void SPFeBlend::release() {
SPFilterPrimitive::release();
}
-static Inkscape::Filters::FilterBlendMode sp_feBlend_readmode(gchar const *value)
-{
- if (!value) return Inkscape::Filters::BLEND_NORMAL;
+static Inkscape::Filters::FilterBlendMode sp_feBlend_readmode(gchar const *value) {
+ if (!value) {
+ return Inkscape::Filters::BLEND_NORMAL;
+ }
+
switch (value[0]) {
case 'n':
if (strncmp(value, "normal", 6) == 0)
@@ -111,6 +109,7 @@ static Inkscape::Filters::FilterBlendMode sp_feBlend_readmode(gchar const *value
// do nothing by default
break;
}
+
return Inkscape::Filters::BLEND_NORMAL;
}
@@ -118,27 +117,25 @@ static Inkscape::Filters::FilterBlendMode sp_feBlend_readmode(gchar const *value
* Sets a specific value in the SPFeBlend.
*/
void SPFeBlend::set(unsigned int key, gchar const *value) {
- SPFeBlend* object = this;
-
- SPFeBlend *feBlend = SP_FEBLEND(object);
- (void)feBlend;
-
Inkscape::Filters::FilterBlendMode mode;
int input;
+
switch(key) {
/*DEAL WITH SETTING ATTRIBUTES HERE*/
case SP_ATTR_MODE:
mode = sp_feBlend_readmode(value);
- if (mode != feBlend->blend_mode) {
- feBlend->blend_mode = mode;
- object->parent->requestModified(SP_OBJECT_MODIFIED_FLAG);
+
+ if (mode != this->blend_mode) {
+ this->blend_mode = mode;
+ this->parent->requestModified(SP_OBJECT_MODIFIED_FLAG);
}
break;
case SP_ATTR_IN2:
- input = sp_filter_primitive_read_in(feBlend, value);
- if (input != feBlend->in2) {
- feBlend->in2 = input;
- object->parent->requestModified(SP_OBJECT_MODIFIED_FLAG);
+ input = sp_filter_primitive_read_in(this, value);
+
+ if (input != this->in2) {
+ this->in2 = input;
+ this->parent->requestModified(SP_OBJECT_MODIFIED_FLAG);
}
break;
default:
@@ -151,25 +148,21 @@ void SPFeBlend::set(unsigned int key, gchar const *value) {
* Receives update notifications.
*/
void SPFeBlend::update(SPCtx *ctx, guint flags) {
- SPFeBlend* object = this;
-
- SPFeBlend *blend = SP_FEBLEND(object);
-
if (flags & SP_OBJECT_MODIFIED_FLAG) {
- object->readAttr( "mode" );
- object->readAttr( "in2" );
+ this->readAttr( "mode" );
+ this->readAttr( "in2" );
}
/* Unlike normal in, in2 is required attribute. Make sure, we can call
* it by some name. */
- if (blend->in2 == Inkscape::Filters::NR_FILTER_SLOT_NOT_SET ||
- blend->in2 == Inkscape::Filters::NR_FILTER_UNNAMED_SLOT)
+ if (this->in2 == Inkscape::Filters::NR_FILTER_SLOT_NOT_SET ||
+ this->in2 == Inkscape::Filters::NR_FILTER_UNNAMED_SLOT)
{
- SPFilter *parent = SP_FILTER(object->parent);
- blend->in2 = sp_filter_primitive_name_previous_out(blend);
+ SPFilter *parent = SP_FILTER(this->parent);
+ this->in2 = sp_filter_primitive_name_previous_out(this);
- //XML Tree being used directly here while it shouldn't be.
- object->getRepr()->setAttribute("in2", sp_filter_name_for_image(parent, blend->in2));
+ // TODO: XML Tree being used directly here while it shouldn't be.
+ this->getRepr()->setAttribute("in2", sp_filter_name_for_image(parent, this->in2));
}
SPFilterPrimitive::update(ctx, flags);
@@ -179,31 +172,34 @@ void SPFeBlend::update(SPCtx *ctx, guint flags) {
* Writes its settings to an incoming repr object, if any.
*/
Inkscape::XML::Node* SPFeBlend::write(Inkscape::XML::Document *doc, Inkscape::XML::Node *repr, guint flags) {
- SPFeBlend* object = this;
-
- SPFeBlend *blend = SP_FEBLEND(object);
- SPFilter *parent = SP_FILTER(object->parent);
+ SPFilter *parent = SP_FILTER(this->parent);
if (!repr) {
repr = doc->createElement("svg:feBlend");
}
- gchar const *out_name = sp_filter_name_for_image(parent, blend->in2);
+ gchar const *out_name = sp_filter_name_for_image(parent, this->in2);
+
if (out_name) {
repr->setAttribute("in2", out_name);
} else {
SPObject *i = parent->children;
- while (i && i->next != object) i = i->next;
+
+ while (i && i->next != this) {
+ i = i->next;
+ }
+
SPFilterPrimitive *i_prim = SP_FILTER_PRIMITIVE(i);
out_name = sp_filter_name_for_image(parent, i_prim->image_out);
repr->setAttribute("in2", out_name);
+
if (!out_name) {
g_warning("Unable to set in2 for feBlend");
}
}
char const *mode;
- switch(blend->blend_mode) {
+ switch(this->blend_mode) {
case Inkscape::Filters::BLEND_NORMAL:
mode = "normal"; break;
case Inkscape::Filters::BLEND_MULTIPLY:
@@ -217,6 +213,7 @@ Inkscape::XML::Node* SPFeBlend::write(Inkscape::XML::Document *doc, Inkscape::XM
default:
mode = 0;
}
+
repr->setAttribute("mode", mode);
SPFilterPrimitive::write(doc, repr, flags);
@@ -225,22 +222,18 @@ Inkscape::XML::Node* SPFeBlend::write(Inkscape::XML::Document *doc, Inkscape::XM
}
void SPFeBlend::build_renderer(Inkscape::Filters::Filter* filter) {
- SPFeBlend* primitive = this;
-
- g_assert(primitive != NULL);
+ g_assert(this != NULL);
g_assert(filter != NULL);
- SPFeBlend *sp_blend = SP_FEBLEND(primitive);
-
int primitive_n = filter->add_primitive(Inkscape::Filters::NR_FILTER_BLEND);
Inkscape::Filters::FilterPrimitive *nr_primitive = filter->get_primitive(primitive_n);
Inkscape::Filters::FilterBlend *nr_blend = dynamic_cast<Inkscape::Filters::FilterBlend*>(nr_primitive);
g_assert(nr_blend != NULL);
- sp_filter_primitive_renderer_common(primitive, nr_primitive);
+ sp_filter_primitive_renderer_common(this, nr_primitive);
- nr_blend->set_mode(sp_blend->blend_mode);
- nr_blend->set_input(1, sp_blend->in2);
+ nr_blend->set_mode(this->blend_mode);
+ nr_blend->set_input(1, this->in2);
}
/*
diff --git a/src/filters/blend.h b/src/filters/blend.h
index 4377f2cab..f8b7bd2cb 100644
--- a/src/filters/blend.h
+++ b/src/filters/blend.h
@@ -27,6 +27,7 @@ public:
Inkscape::Filters::FilterBlendMode blend_mode;
int in2;
+protected:
virtual void build(SPDocument* doc, Inkscape::XML::Node* repr);
virtual void release();
diff --git a/src/filters/colormatrix.cpp b/src/filters/colormatrix.cpp
index 28f848ec7..58f601a65 100644
--- a/src/filters/colormatrix.cpp
+++ b/src/filters/colormatrix.cpp
@@ -39,9 +39,9 @@ namespace {
bool colorMatrixRegistered = SPFactory::instance().registerObject("svg:feColorMatrix", createColorMatrix);
}
-SPFeColorMatrix::SPFeColorMatrix() : SPFilterPrimitive() {
- this->value = 0;
- this->type = Inkscape::Filters::COLORMATRIX_MATRIX;
+SPFeColorMatrix::SPFeColorMatrix()
+ : SPFilterPrimitive(), type(Inkscape::Filters::COLORMATRIX_MATRIX), value(0)
+{
}
SPFeColorMatrix::~SPFeColorMatrix() {
@@ -55,11 +55,9 @@ SPFeColorMatrix::~SPFeColorMatrix() {
void SPFeColorMatrix::build(SPDocument *document, Inkscape::XML::Node *repr) {
SPFilterPrimitive::build(document, repr);
- SPFeColorMatrix* object = this;
-
/*LOAD ATTRIBUTES FROM REPR HERE*/
- object->readAttr( "type" );
- object->readAttr( "values" );
+ this->readAttr( "type" );
+ this->readAttr( "values" );
}
/**
@@ -70,7 +68,10 @@ void SPFeColorMatrix::release() {
}
static Inkscape::Filters::FilterColorMatrixType sp_feColorMatrix_read_type(gchar const *value){
- if (!value) return Inkscape::Filters::COLORMATRIX_MATRIX; //matrix is default
+ if (!value) {
+ return Inkscape::Filters::COLORMATRIX_MATRIX; //matrix is default
+ }
+
switch(value[0]){
case 'm':
if (strcmp(value, "matrix") == 0) return Inkscape::Filters::COLORMATRIX_MATRIX;
@@ -85,6 +86,7 @@ static Inkscape::Filters::FilterColorMatrixType sp_feColorMatrix_read_type(gchar
if (strcmp(value, "luminanceToAlpha") == 0) return Inkscape::Filters::COLORMATRIX_LUMINANCETOALPHA;
break;
}
+
return Inkscape::Filters::COLORMATRIX_MATRIX; //matrix is default
}
@@ -92,26 +94,23 @@ static Inkscape::Filters::FilterColorMatrixType sp_feColorMatrix_read_type(gchar
* Sets a specific value in the SPFeColorMatrix.
*/
void SPFeColorMatrix::set(unsigned int key, gchar const *str) {
- SPFeColorMatrix* object = this;
-
- SPFeColorMatrix *feColorMatrix = SP_FECOLORMATRIX(object);
- (void)feColorMatrix;
-
Inkscape::Filters::FilterColorMatrixType read_type;
+
/*DEAL WITH SETTING ATTRIBUTES HERE*/
switch(key) {
case SP_ATTR_TYPE:
read_type = sp_feColorMatrix_read_type(str);
- if (feColorMatrix->type != read_type){
- feColorMatrix->type = read_type;
- object->parent->requestModified(SP_OBJECT_MODIFIED_FLAG);
+
+ if (this->type != read_type){
+ this->type = read_type;
+ this->parent->requestModified(SP_OBJECT_MODIFIED_FLAG);
}
break;
case SP_ATTR_VALUES:
if (str){
- feColorMatrix->values = helperfns_read_vector(str);
- feColorMatrix->value = helperfns_read_number(str, HELPERFNS_NO_WARNING);
- object->parent->requestModified(SP_OBJECT_MODIFIED_FLAG);
+ this->values = helperfns_read_vector(str);
+ this->value = helperfns_read_number(str, HELPERFNS_NO_WARNING);
+ this->parent->requestModified(SP_OBJECT_MODIFIED_FLAG);
}
break;
default:
@@ -124,8 +123,6 @@ void SPFeColorMatrix::set(unsigned int key, gchar const *str) {
* Receives update notifications.
*/
void SPFeColorMatrix::update(SPCtx *ctx, guint flags) {
- SPFeColorMatrix* object = this;
-
if (flags & (SP_OBJECT_MODIFIED_FLAG | SP_OBJECT_STYLE_MODIFIED_FLAG |
SP_OBJECT_VIEWPORT_MODIFIED_FLAG)) {
@@ -140,12 +137,10 @@ void SPFeColorMatrix::update(SPCtx *ctx, guint flags) {
* Writes its settings to an incoming repr object, if any.
*/
Inkscape::XML::Node* SPFeColorMatrix::write(Inkscape::XML::Document *doc, Inkscape::XML::Node *repr, guint flags) {
- SPFeColorMatrix* object = this;
-
/* TODO: Don't just clone, but create a new repr node and write all
* relevant values into it */
if (!repr) {
- repr = object->getRepr()->duplicate(doc);
+ repr = this->getRepr()->duplicate(doc);
}
SPFilterPrimitive::write(doc, repr, flags);
@@ -154,22 +149,18 @@ Inkscape::XML::Node* SPFeColorMatrix::write(Inkscape::XML::Document *doc, Inksca
}
void SPFeColorMatrix::build_renderer(Inkscape::Filters::Filter* filter) {
- SPFeColorMatrix* primitive = this;
-
- g_assert(primitive != NULL);
+ g_assert(this != NULL);
g_assert(filter != NULL);
- SPFeColorMatrix *sp_colormatrix = SP_FECOLORMATRIX(primitive);
-
int primitive_n = filter->add_primitive(Inkscape::Filters::NR_FILTER_COLORMATRIX);
Inkscape::Filters::FilterPrimitive *nr_primitive = filter->get_primitive(primitive_n);
Inkscape::Filters::FilterColorMatrix *nr_colormatrix = dynamic_cast<Inkscape::Filters::FilterColorMatrix*>(nr_primitive);
g_assert(nr_colormatrix != NULL);
- sp_filter_primitive_renderer_common(primitive, nr_primitive);
- nr_colormatrix->set_type(sp_colormatrix->type);
- nr_colormatrix->set_value(sp_colormatrix->value);
- nr_colormatrix->set_values(sp_colormatrix->values);
+ sp_filter_primitive_renderer_common(this, nr_primitive);
+ nr_colormatrix->set_type(this->type);
+ nr_colormatrix->set_value(this->value);
+ nr_colormatrix->set_values(this->values);
}
/*
diff --git a/src/filters/colormatrix.h b/src/filters/colormatrix.h
index 3239d2f8d..4d11964dd 100644
--- a/src/filters/colormatrix.h
+++ b/src/filters/colormatrix.h
@@ -27,6 +27,7 @@ public:
gdouble value;
std::vector<gdouble> values;
+protected:
virtual void build(SPDocument* doc, Inkscape::XML::Node* repr);
virtual void release();
diff --git a/src/filters/componenttransfer.cpp b/src/filters/componenttransfer.cpp
index 4d6206bf7..96d1ea0bf 100644
--- a/src/filters/componenttransfer.cpp
+++ b/src/filters/componenttransfer.cpp
@@ -37,8 +37,9 @@ namespace {
bool componentTransferRegistered = SPFactory::instance().registerObject("svg:feComponentTransfer", createComponentTransfer);
}
-SPFeComponentTransfer::SPFeComponentTransfer() : SPFilterPrimitive() {
- this->renderer = NULL;
+SPFeComponentTransfer::SPFeComponentTransfer()
+ : SPFilterPrimitive(), renderer(NULL)
+{
}
SPFeComponentTransfer::~SPFeComponentTransfer() {
@@ -95,28 +96,20 @@ static void sp_feComponentTransfer_children_modified(SPFeComponentTransfer *sp_c
* Callback for child_added event.
*/
void SPFeComponentTransfer::child_added(Inkscape::XML::Node *child, Inkscape::XML::Node *ref) {
- SPFeComponentTransfer* object = this;
-
- SPFeComponentTransfer *f = SP_FECOMPONENTTRANSFER(object);
-
SPFilterPrimitive::child_added(child, ref);
- sp_feComponentTransfer_children_modified(f);
- object->parent->requestModified(SP_OBJECT_MODIFIED_FLAG);
+ sp_feComponentTransfer_children_modified(this);
+ this->parent->requestModified(SP_OBJECT_MODIFIED_FLAG);
}
/**
* Callback for remove_child event.
*/
void SPFeComponentTransfer::remove_child(Inkscape::XML::Node *child) {
- SPFeComponentTransfer* object = this;
-
- SPFeComponentTransfer *f = SP_FECOMPONENTTRANSFER(object);
-
SPFilterPrimitive::remove_child(child);
- sp_feComponentTransfer_children_modified(f);
- object->parent->requestModified(SP_OBJECT_MODIFIED_FLAG);
+ sp_feComponentTransfer_children_modified(this);
+ this->parent->requestModified(SP_OBJECT_MODIFIED_FLAG);
}
/**
@@ -130,11 +123,6 @@ void SPFeComponentTransfer::release() {
* Sets a specific value in the SPFeComponentTransfer.
*/
void SPFeComponentTransfer::set(unsigned int key, gchar const *value) {
- SPFeComponentTransfer* object = this;
-
- SPFeComponentTransfer *feComponentTransfer = SP_FECOMPONENTTRANSFER(object);
- (void)feComponentTransfer;
-
switch(key) {
/*DEAL WITH SETTING ATTRIBUTES HERE*/
default:
@@ -147,8 +135,6 @@ void SPFeComponentTransfer::set(unsigned int key, gchar const *value) {
* Receives update notifications.
*/
void SPFeComponentTransfer::update(SPCtx *ctx, guint flags) {
- SPFeComponentTransfer* object = this;
-
if (flags & (SP_OBJECT_MODIFIED_FLAG | SP_OBJECT_STYLE_MODIFIED_FLAG |
SP_OBJECT_VIEWPORT_MODIFIED_FLAG)) {
@@ -163,12 +149,10 @@ void SPFeComponentTransfer::update(SPCtx *ctx, guint flags) {
* Writes its settings to an incoming repr object, if any.
*/
Inkscape::XML::Node* SPFeComponentTransfer::write(Inkscape::XML::Document *doc, Inkscape::XML::Node *repr, guint flags) {
- SPFeComponentTransfer* object = this;
-
/* TODO: Don't just clone, but create a new repr node and write all
* relevant values into it */
if (!repr) {
- repr = object->getRepr()->duplicate(doc);
+ repr = this->getRepr()->duplicate(doc);
}
SPFilterPrimitive::write(doc, repr, flags);
@@ -177,23 +161,19 @@ Inkscape::XML::Node* SPFeComponentTransfer::write(Inkscape::XML::Document *doc,
}
void SPFeComponentTransfer::build_renderer(Inkscape::Filters::Filter* filter) {
- SPFeComponentTransfer* primitive = this;
-
- g_assert(primitive != NULL);
+ g_assert(this != NULL);
g_assert(filter != NULL);
- SPFeComponentTransfer *sp_componenttransfer = SP_FECOMPONENTTRANSFER(primitive);
-
int primitive_n = filter->add_primitive(Inkscape::Filters::NR_FILTER_COMPONENTTRANSFER);
Inkscape::Filters::FilterPrimitive *nr_primitive = filter->get_primitive(primitive_n);
Inkscape::Filters::FilterComponentTransfer *nr_componenttransfer = dynamic_cast<Inkscape::Filters::FilterComponentTransfer*>(nr_primitive);
g_assert(nr_componenttransfer != NULL);
- sp_componenttransfer->renderer = nr_componenttransfer;
- sp_filter_primitive_renderer_common(primitive, nr_primitive);
+ this->renderer = nr_componenttransfer;
+ sp_filter_primitive_renderer_common(this, nr_primitive);
- sp_feComponentTransfer_children_modified(sp_componenttransfer); //do we need it?!
+ sp_feComponentTransfer_children_modified(this); //do we need it?!
}
/*
diff --git a/src/filters/componenttransfer.h b/src/filters/componenttransfer.h
index 79d842b77..3aab5cf49 100644
--- a/src/filters/componenttransfer.h
+++ b/src/filters/componenttransfer.h
@@ -28,6 +28,7 @@ public:
Inkscape::Filters::FilterComponentTransfer *renderer;
+protected:
virtual void build(SPDocument* doc, Inkscape::XML::Node* repr);
virtual void release();
diff --git a/src/filters/composite.cpp b/src/filters/composite.cpp
index 28147fa80..3c214a7a1 100644
--- a/src/filters/composite.cpp
+++ b/src/filters/composite.cpp
@@ -35,13 +35,10 @@ namespace {
bool compositeRegistered = SPFactory::instance().registerObject("svg:feComposite", createComposite);
}
-SPFeComposite::SPFeComposite() : SPFilterPrimitive() {
- this->composite_operator = COMPOSITE_DEFAULT;
- this->k1 = 0;
- this->k2 = 0;
- this->k3 = 0;
- this->k4 = 0;
- this->in2 = Inkscape::Filters::NR_FILTER_SLOT_NOT_SET;
+SPFeComposite::SPFeComposite()
+ : SPFilterPrimitive(), composite_operator(COMPOSITE_DEFAULT),
+ k1(0), k2(0), k3(0), k4(0), in2(Inkscape::Filters::NR_FILTER_SLOT_NOT_SET)
+{
}
SPFeComposite::~SPFeComposite() {
@@ -53,29 +50,27 @@ SPFeComposite::~SPFeComposite() {
* sp-object-repr.cpp's repr_name_entries array.
*/
void SPFeComposite::build(SPDocument *document, Inkscape::XML::Node *repr) {
- SPFeComposite* object = this;
-
SPFilterPrimitive::build(document, repr);
- SPFeComposite *comp = SP_FECOMPOSITE(object);
+ this->readAttr( "operator" );
- object->readAttr( "operator" );
- if (comp->composite_operator == COMPOSITE_ARITHMETIC) {
- object->readAttr( "k1" );
- object->readAttr( "k2" );
- object->readAttr( "k3" );
- object->readAttr( "k4" );
+ if (this->composite_operator == COMPOSITE_ARITHMETIC) {
+ this->readAttr( "k1" );
+ this->readAttr( "k2" );
+ this->readAttr( "k3" );
+ this->readAttr( "k4" );
}
- object->readAttr( "in2" );
+
+ this->readAttr( "in2" );
/* Unlike normal in, in2 is required attribute. Make sure, we can call
* it by some name. */
- if (comp->in2 == Inkscape::Filters::NR_FILTER_SLOT_NOT_SET ||
- comp->in2 == Inkscape::Filters::NR_FILTER_UNNAMED_SLOT)
+ if (this->in2 == Inkscape::Filters::NR_FILTER_SLOT_NOT_SET ||
+ this->in2 == Inkscape::Filters::NR_FILTER_UNNAMED_SLOT)
{
- SPFilter *parent = SP_FILTER(object->parent);
- comp->in2 = sp_filter_primitive_name_previous_out(comp);
- repr->setAttribute("in2", sp_filter_name_for_image(parent, comp->in2));
+ SPFilter *parent = SP_FILTER(this->parent);
+ this->in2 = sp_filter_primitive_name_previous_out(this);
+ repr->setAttribute("in2", sp_filter_name_for_image(parent, this->in2));
}
}
@@ -88,14 +83,24 @@ void SPFeComposite::release() {
static FeCompositeOperator
sp_feComposite_read_operator(gchar const *value) {
- if (!value) return COMPOSITE_DEFAULT;
-
- if (strcmp(value, "over") == 0) return COMPOSITE_OVER;
- else if (strcmp(value, "in") == 0) return COMPOSITE_IN;
- else if (strcmp(value, "out") == 0) return COMPOSITE_OUT;
- else if (strcmp(value, "atop") == 0) return COMPOSITE_ATOP;
- else if (strcmp(value, "xor") == 0) return COMPOSITE_XOR;
- else if (strcmp(value, "arithmetic") == 0) return COMPOSITE_ARITHMETIC;
+ if (!value) {
+ return COMPOSITE_DEFAULT;
+ }
+
+ if (strcmp(value, "over") == 0) {
+ return COMPOSITE_OVER;
+ } else if (strcmp(value, "in") == 0) {
+ return COMPOSITE_IN;
+ } else if (strcmp(value, "out") == 0) {
+ return COMPOSITE_OUT;
+ } else if (strcmp(value, "atop") == 0) {
+ return COMPOSITE_ATOP;
+ } else if (strcmp(value, "xor") == 0) {
+ return COMPOSITE_XOR;
+ } else if (strcmp(value, "arithmetic") == 0) {
+ return COMPOSITE_ARITHMETIC;
+ }
+
return COMPOSITE_DEFAULT;
}
@@ -103,65 +108,61 @@ sp_feComposite_read_operator(gchar const *value) {
* Sets a specific value in the SPFeComposite.
*/
void SPFeComposite::set(unsigned int key, gchar const *value) {
- SPFeComposite* object = this;
-
- SPFeComposite *feComposite = SP_FECOMPOSITE(object);
- (void)feComposite;
-
int input;
FeCompositeOperator op;
double k_n;
+
switch(key) {
/*DEAL WITH SETTING ATTRIBUTES HERE*/
case SP_ATTR_OPERATOR:
op = sp_feComposite_read_operator(value);
- if (op != feComposite->composite_operator) {
- feComposite->composite_operator = op;
- object->parent->requestModified(SP_OBJECT_MODIFIED_FLAG);
+ if (op != this->composite_operator) {
+ this->composite_operator = op;
+ this->parent->requestModified(SP_OBJECT_MODIFIED_FLAG);
}
break;
case SP_ATTR_K1:
k_n = value ? helperfns_read_number(value) : 0;
- if (k_n != feComposite->k1) {
- feComposite->k1 = k_n;
- if (feComposite->composite_operator == COMPOSITE_ARITHMETIC)
- object->parent->requestModified(SP_OBJECT_MODIFIED_FLAG);
+ if (k_n != this->k1) {
+ this->k1 = k_n;
+ if (this->composite_operator == COMPOSITE_ARITHMETIC)
+ this->parent->requestModified(SP_OBJECT_MODIFIED_FLAG);
}
break;
case SP_ATTR_K2:
k_n = value ? helperfns_read_number(value) : 0;
- if (k_n != feComposite->k2) {
- feComposite->k2 = k_n;
- if (feComposite->composite_operator == COMPOSITE_ARITHMETIC)
- object->parent->requestModified(SP_OBJECT_MODIFIED_FLAG);
+ if (k_n != this->k2) {
+ this->k2 = k_n;
+ if (this->composite_operator == COMPOSITE_ARITHMETIC)
+ this->parent->requestModified(SP_OBJECT_MODIFIED_FLAG);
}
break;
case SP_ATTR_K3:
k_n = value ? helperfns_read_number(value) : 0;
- if (k_n != feComposite->k3) {
- feComposite->k3 = k_n;
- if (feComposite->composite_operator == COMPOSITE_ARITHMETIC)
- object->parent->requestModified(SP_OBJECT_MODIFIED_FLAG);
+ if (k_n != this->k3) {
+ this->k3 = k_n;
+ if (this->composite_operator == COMPOSITE_ARITHMETIC)
+ this->parent->requestModified(SP_OBJECT_MODIFIED_FLAG);
}
break;
case SP_ATTR_K4:
k_n = value ? helperfns_read_number(value) : 0;
- if (k_n != feComposite->k4) {
- feComposite->k4 = k_n;
- if (feComposite->composite_operator == COMPOSITE_ARITHMETIC)
- object->parent->requestModified(SP_OBJECT_MODIFIED_FLAG);
+ if (k_n != this->k4) {
+ this->k4 = k_n;
+ if (this->composite_operator == COMPOSITE_ARITHMETIC)
+ this->parent->requestModified(SP_OBJECT_MODIFIED_FLAG);
}
break;
case SP_ATTR_IN2:
- input = sp_filter_primitive_read_in(feComposite, value);
- if (input != feComposite->in2) {
- feComposite->in2 = input;
- object->parent->requestModified(SP_OBJECT_MODIFIED_FLAG);
+ input = sp_filter_primitive_read_in(this, value);
+ if (input != this->in2) {
+ this->in2 = input;
+ this->parent->requestModified(SP_OBJECT_MODIFIED_FLAG);
}
break;
@@ -175,10 +176,6 @@ void SPFeComposite::set(unsigned int key, gchar const *value) {
* Receives update notifications.
*/
void SPFeComposite::update(SPCtx *ctx, guint flags) {
- SPFeComposite* object = this;
-
- SPFeComposite *comp = SP_FECOMPOSITE(object);
-
if (flags & (SP_OBJECT_MODIFIED_FLAG | SP_OBJECT_STYLE_MODIFIED_FLAG |
SP_OBJECT_VIEWPORT_MODIFIED_FLAG)) {
@@ -188,14 +185,14 @@ void SPFeComposite::update(SPCtx *ctx, guint flags) {
/* Unlike normal in, in2 is required attribute. Make sure, we can call
* it by some name. */
- if (comp->in2 == Inkscape::Filters::NR_FILTER_SLOT_NOT_SET ||
- comp->in2 == Inkscape::Filters::NR_FILTER_UNNAMED_SLOT)
+ if (this->in2 == Inkscape::Filters::NR_FILTER_SLOT_NOT_SET ||
+ this->in2 == Inkscape::Filters::NR_FILTER_UNNAMED_SLOT)
{
- SPFilter *parent = SP_FILTER(object->parent);
- comp->in2 = sp_filter_primitive_name_previous_out(comp);
+ SPFilter *parent = SP_FILTER(this->parent);
+ this->in2 = sp_filter_primitive_name_previous_out(this);
//XML Tree being used directly here while it shouldn't be.
- object->getRepr()->setAttribute("in2", sp_filter_name_for_image(parent, comp->in2));
+ this->getRepr()->setAttribute("in2", sp_filter_name_for_image(parent, this->in2));
}
SPFilterPrimitive::update(ctx, flags);
@@ -205,31 +202,35 @@ void SPFeComposite::update(SPCtx *ctx, guint flags) {
* Writes its settings to an incoming repr object, if any.
*/
Inkscape::XML::Node* SPFeComposite::write(Inkscape::XML::Document *doc, Inkscape::XML::Node *repr, guint flags) {
- SPFeComposite* object = this;
-
- SPFeComposite *comp = SP_FECOMPOSITE(object);
- SPFilter *parent = SP_FILTER(object->parent);
+ SPFilter *parent = SP_FILTER(this->parent);
if (!repr) {
repr = doc->createElement("svg:feComposite");
}
- gchar const *out_name = sp_filter_name_for_image(parent, comp->in2);
+ gchar const *out_name = sp_filter_name_for_image(parent, this->in2);
+
if (out_name) {
repr->setAttribute("in2", out_name);
} else {
SPObject *i = parent->children;
- while (i && i->next != object) i = i->next;
+
+ while (i && i->next != this) {
+ i = i->next;
+ }
+
SPFilterPrimitive *i_prim = SP_FILTER_PRIMITIVE(i);
out_name = sp_filter_name_for_image(parent, i_prim->image_out);
repr->setAttribute("in2", out_name);
+
if (!out_name) {
g_warning("Unable to set in2 for feComposite");
}
}
char const *comp_op;
- switch (comp->composite_operator) {
+
+ switch (this->composite_operator) {
case COMPOSITE_OVER:
comp_op = "over"; break;
case COMPOSITE_IN:
@@ -245,13 +246,14 @@ Inkscape::XML::Node* SPFeComposite::write(Inkscape::XML::Document *doc, Inkscape
default:
comp_op = 0;
}
+
repr->setAttribute("operator", comp_op);
- if (comp->composite_operator == COMPOSITE_ARITHMETIC) {
- sp_repr_set_svg_double(repr, "k1", comp->k1);
- sp_repr_set_svg_double(repr, "k2", comp->k2);
- sp_repr_set_svg_double(repr, "k3", comp->k3);
- sp_repr_set_svg_double(repr, "k4", comp->k4);
+ if (this->composite_operator == COMPOSITE_ARITHMETIC) {
+ sp_repr_set_svg_double(repr, "k1", this->k1);
+ sp_repr_set_svg_double(repr, "k2", this->k2);
+ sp_repr_set_svg_double(repr, "k3", this->k3);
+ sp_repr_set_svg_double(repr, "k4", this->k4);
} else {
repr->setAttribute("k1", 0);
repr->setAttribute("k2", 0);
@@ -265,25 +267,22 @@ Inkscape::XML::Node* SPFeComposite::write(Inkscape::XML::Document *doc, Inkscape
}
void SPFeComposite::build_renderer(Inkscape::Filters::Filter* filter) {
- SPFeComposite* primitive = this;
-
- g_assert(primitive != NULL);
+ g_assert(this != NULL);
g_assert(filter != NULL);
- SPFeComposite *sp_composite = SP_FECOMPOSITE(primitive);
-
int primitive_n = filter->add_primitive(Inkscape::Filters::NR_FILTER_COMPOSITE);
Inkscape::Filters::FilterPrimitive *nr_primitive = filter->get_primitive(primitive_n);
Inkscape::Filters::FilterComposite *nr_composite = dynamic_cast<Inkscape::Filters::FilterComposite*>(nr_primitive);
g_assert(nr_composite != NULL);
- sp_filter_primitive_renderer_common(primitive, nr_primitive);
+ sp_filter_primitive_renderer_common(this, nr_primitive);
+
+ nr_composite->set_operator(this->composite_operator);
+ nr_composite->set_input(1, this->in2);
- nr_composite->set_operator(sp_composite->composite_operator);
- nr_composite->set_input(1, sp_composite->in2);
- if (sp_composite->composite_operator == COMPOSITE_ARITHMETIC) {
- nr_composite->set_arithmetic(sp_composite->k1, sp_composite->k2,
- sp_composite->k3, sp_composite->k4);
+ if (this->composite_operator == COMPOSITE_ARITHMETIC) {
+ nr_composite->set_arithmetic(this->k1, this->k2,
+ this->k3, this->k4);
}
}
diff --git a/src/filters/composite.h b/src/filters/composite.h
index d4272a2b0..dc124e891 100644
--- a/src/filters/composite.h
+++ b/src/filters/composite.h
@@ -38,6 +38,7 @@ public:
double k1, k2, k3, k4;
int in2;
+protected:
virtual void build(SPDocument* doc, Inkscape::XML::Node* repr);
virtual void release();
diff --git a/src/filters/convolvematrix.cpp b/src/filters/convolvematrix.cpp
index b104a2f9f..bd710b116 100644
--- a/src/filters/convolvematrix.cpp
+++ b/src/filters/convolvematrix.cpp
@@ -67,18 +67,16 @@ SPFeConvolveMatrix::~SPFeConvolveMatrix() {
void SPFeConvolveMatrix::build(SPDocument *document, Inkscape::XML::Node *repr) {
SPFilterPrimitive::build(document, repr);
- SPFeConvolveMatrix* object = this;
-
/*LOAD ATTRIBUTES FROM REPR HERE*/
- object->readAttr( "order" );
- object->readAttr( "kernelMatrix" );
- object->readAttr( "divisor" );
- object->readAttr( "bias" );
- object->readAttr( "targetX" );
- object->readAttr( "targetY" );
- object->readAttr( "edgeMode" );
- object->readAttr( "kernelUnitLength" );
- object->readAttr( "preserveAlpha" );
+ this->readAttr( "order" );
+ this->readAttr( "kernelMatrix" );
+ this->readAttr( "divisor" );
+ this->readAttr( "bias" );
+ this->readAttr( "targetX" );
+ this->readAttr( "targetY" );
+ this->readAttr( "edgeMode" );
+ this->readAttr( "kernelUnitLength" );
+ this->readAttr( "preserveAlpha" );
}
/**
@@ -89,18 +87,28 @@ void SPFeConvolveMatrix::release() {
}
static Inkscape::Filters::FilterConvolveMatrixEdgeMode sp_feConvolveMatrix_read_edgeMode(gchar const *value){
- if (!value) return Inkscape::Filters::CONVOLVEMATRIX_EDGEMODE_DUPLICATE; //duplicate is default
- switch(value[0]){
+ if (!value) {
+ return Inkscape::Filters::CONVOLVEMATRIX_EDGEMODE_DUPLICATE; //duplicate is default
+ }
+
+ switch (value[0]) {
case 'd':
- if (strncmp(value, "duplicate", 9) == 0) return Inkscape::Filters::CONVOLVEMATRIX_EDGEMODE_DUPLICATE;
+ if (strncmp(value, "duplicate", 9) == 0) {
+ return Inkscape::Filters::CONVOLVEMATRIX_EDGEMODE_DUPLICATE;
+ }
break;
case 'w':
- if (strncmp(value, "wrap", 4) == 0) return Inkscape::Filters::CONVOLVEMATRIX_EDGEMODE_WRAP;
+ if (strncmp(value, "wrap", 4) == 0) {
+ return Inkscape::Filters::CONVOLVEMATRIX_EDGEMODE_WRAP;
+ }
break;
case 'n':
- if (strncmp(value, "none", 4) == 0) return Inkscape::Filters::CONVOLVEMATRIX_EDGEMODE_NONE;
+ if (strncmp(value, "none", 4) == 0) {
+ return Inkscape::Filters::CONVOLVEMATRIX_EDGEMODE_NONE;
+ }
break;
}
+
return Inkscape::Filters::CONVOLVEMATRIX_EDGEMODE_DUPLICATE; //duplicate is default
}
@@ -108,10 +116,6 @@ static Inkscape::Filters::FilterConvolveMatrixEdgeMode sp_feConvolveMatrix_read_
* Sets a specific value in the SPFeConvolveMatrix.
*/
void SPFeConvolveMatrix::set(unsigned int key, gchar const *value) {
- SPFeConvolveMatrix* object = this;
-
- SPFeConvolveMatrix *feConvolveMatrix = SP_FECONVOLVEMATRIX(object);
- (void)feConvolveMatrix;
double read_num;
int read_int;
bool read_bool;
@@ -120,25 +124,41 @@ void SPFeConvolveMatrix::set(unsigned int key, gchar const *value) {
switch(key) {
/*DEAL WITH SETTING ATTRIBUTES HERE*/
case SP_ATTR_ORDER:
- feConvolveMatrix->order.set(value);
+ this->order.set(value);
+
//From SVG spec: If <orderY> is not provided, it defaults to <orderX>.
- if (feConvolveMatrix->order.optNumIsSet() == false)
- feConvolveMatrix->order.setOptNumber(feConvolveMatrix->order.getNumber());
- if (feConvolveMatrix->targetXIsSet == false) feConvolveMatrix->targetX = (int) floor(feConvolveMatrix->order.getNumber()/2);
- if (feConvolveMatrix->targetYIsSet == false) feConvolveMatrix->targetY = (int) floor(feConvolveMatrix->order.getOptNumber()/2);
- object->parent->requestModified(SP_OBJECT_MODIFIED_FLAG);
+ if (this->order.optNumIsSet() == false) {
+ this->order.setOptNumber(this->order.getNumber());
+ }
+
+ if (this->targetXIsSet == false) {
+ this->targetX = (int) floor(this->order.getNumber()/2);
+ }
+
+ if (this->targetYIsSet == false) {
+ this->targetY = (int) floor(this->order.getOptNumber()/2);
+ }
+
+ this->parent->requestModified(SP_OBJECT_MODIFIED_FLAG);
break;
case SP_ATTR_KERNELMATRIX:
if (value){
- feConvolveMatrix->kernelMatrixIsSet = true;
- feConvolveMatrix->kernelMatrix = helperfns_read_vector(value);
- if (! feConvolveMatrix->divisorIsSet) {
- feConvolveMatrix->divisor = 0;
- for (unsigned int i = 0; i< feConvolveMatrix->kernelMatrix.size(); i++)
- feConvolveMatrix->divisor += feConvolveMatrix->kernelMatrix[i];
- if (feConvolveMatrix->divisor == 0) feConvolveMatrix->divisor = 1;
+ this->kernelMatrixIsSet = true;
+ this->kernelMatrix = helperfns_read_vector(value);
+
+ if (! this->divisorIsSet) {
+ this->divisor = 0;
+
+ for (unsigned int i = 0; i< this->kernelMatrix.size(); i++) {
+ this->divisor += this->kernelMatrix[i];
+ }
+
+ if (this->divisor == 0) {
+ this->divisor = 1;
+ }
}
- object->parent->requestModified(SP_OBJECT_MODIFIED_FLAG);
+
+ this->parent->requestModified(SP_OBJECT_MODIFIED_FLAG);
} else {
g_warning("For feConvolveMatrix you MUST pass a kernelMatrix parameter!");
}
@@ -146,80 +166,100 @@ void SPFeConvolveMatrix::set(unsigned int key, gchar const *value) {
case SP_ATTR_DIVISOR:
if (value) {
read_num = helperfns_read_number(value);
+
if (read_num == 0) {
// This should actually be an error, but given our UI it is more useful to simply set divisor to the default.
- if (feConvolveMatrix->kernelMatrixIsSet) {
- for (unsigned int i = 0; i< feConvolveMatrix->kernelMatrix.size(); i++)
- read_num += feConvolveMatrix->kernelMatrix[i];
+ if (this->kernelMatrixIsSet) {
+ for (unsigned int i = 0; i< this->kernelMatrix.size(); i++) {
+ read_num += this->kernelMatrix[i];
+ }
+ }
+
+ if (read_num == 0) {
+ read_num = 1;
}
- if (read_num == 0) read_num = 1;
- if (feConvolveMatrix->divisorIsSet || feConvolveMatrix->divisor!=read_num) {
- feConvolveMatrix->divisorIsSet = false;
- feConvolveMatrix->divisor = read_num;
- object->parent->requestModified(SP_OBJECT_MODIFIED_FLAG);
+
+ if (this->divisorIsSet || this->divisor!=read_num) {
+ this->divisorIsSet = false;
+ this->divisor = read_num;
+ this->parent->requestModified(SP_OBJECT_MODIFIED_FLAG);
}
- } else if (!feConvolveMatrix->divisorIsSet || feConvolveMatrix->divisor!=read_num) {
- feConvolveMatrix->divisorIsSet = true;
- feConvolveMatrix->divisor = read_num;
- object->parent->requestModified(SP_OBJECT_MODIFIED_FLAG);
+ } else if (!this->divisorIsSet || this->divisor!=read_num) {
+ this->divisorIsSet = true;
+ this->divisor = read_num;
+ this->parent->requestModified(SP_OBJECT_MODIFIED_FLAG);
}
}
break;
case SP_ATTR_BIAS:
read_num = 0;
- if (value) read_num = helperfns_read_number(value);
- if (read_num != feConvolveMatrix->bias){
- feConvolveMatrix->bias = read_num;
- object->parent->requestModified(SP_OBJECT_MODIFIED_FLAG);
+ if (value) {
+ read_num = helperfns_read_number(value);
+ }
+
+ if (read_num != this->bias){
+ this->bias = read_num;
+ this->parent->requestModified(SP_OBJECT_MODIFIED_FLAG);
}
break;
case SP_ATTR_TARGETX:
if (value) {
read_int = (int) helperfns_read_number(value);
- if (read_int < 0 || read_int > feConvolveMatrix->order.getNumber()){
+
+ if (read_int < 0 || read_int > this->order.getNumber()){
g_warning("targetX must be a value between 0 and orderX! Assuming floor(orderX/2) as default value.");
- read_int = (int) floor(feConvolveMatrix->order.getNumber()/2.0);
+ read_int = (int) floor(this->order.getNumber()/2.0);
}
- feConvolveMatrix->targetXIsSet = true;
- if (read_int != feConvolveMatrix->targetX){
- feConvolveMatrix->targetX = read_int;
- object->parent->requestModified(SP_OBJECT_MODIFIED_FLAG);
+
+ this->targetXIsSet = true;
+
+ if (read_int != this->targetX){
+ this->targetX = read_int;
+ this->parent->requestModified(SP_OBJECT_MODIFIED_FLAG);
}
}
break;
case SP_ATTR_TARGETY:
if (value) {
read_int = (int) helperfns_read_number(value);
- if (read_int < 0 || read_int > feConvolveMatrix->order.getOptNumber()){
+
+ if (read_int < 0 || read_int > this->order.getOptNumber()){
g_warning("targetY must be a value between 0 and orderY! Assuming floor(orderY/2) as default value.");
- read_int = (int) floor(feConvolveMatrix->order.getOptNumber()/2.0);
+ read_int = (int) floor(this->order.getOptNumber()/2.0);
}
- feConvolveMatrix->targetYIsSet = true;
- if (read_int != feConvolveMatrix->targetY){
- feConvolveMatrix->targetY = read_int;
- object->parent->requestModified(SP_OBJECT_MODIFIED_FLAG);
+
+ this->targetYIsSet = true;
+
+ if (read_int != this->targetY){
+ this->targetY = read_int;
+ this->parent->requestModified(SP_OBJECT_MODIFIED_FLAG);
}
}
break;
case SP_ATTR_EDGEMODE:
read_mode = sp_feConvolveMatrix_read_edgeMode(value);
- if (read_mode != feConvolveMatrix->edgeMode){
- feConvolveMatrix->edgeMode = read_mode;
- object->parent->requestModified(SP_OBJECT_MODIFIED_FLAG);
+
+ if (read_mode != this->edgeMode){
+ this->edgeMode = read_mode;
+ this->parent->requestModified(SP_OBJECT_MODIFIED_FLAG);
}
break;
case SP_ATTR_KERNELUNITLENGTH:
- feConvolveMatrix->kernelUnitLength.set(value);
+ this->kernelUnitLength.set(value);
+
//From SVG spec: If the <dy> value is not specified, it defaults to the same value as <dx>.
- if (feConvolveMatrix->kernelUnitLength.optNumIsSet() == false)
- feConvolveMatrix->kernelUnitLength.setOptNumber(feConvolveMatrix->kernelUnitLength.getNumber());
- object->parent->requestModified(SP_OBJECT_MODIFIED_FLAG);
+ if (this->kernelUnitLength.optNumIsSet() == false) {
+ this->kernelUnitLength.setOptNumber(this->kernelUnitLength.getNumber());
+ }
+
+ this->parent->requestModified(SP_OBJECT_MODIFIED_FLAG);
break;
case SP_ATTR_PRESERVEALPHA:
read_bool = helperfns_read_bool(value, false);
- if (read_bool != feConvolveMatrix->preserveAlpha){
- feConvolveMatrix->preserveAlpha = read_bool;
- object->parent->requestModified(SP_OBJECT_MODIFIED_FLAG);
+
+ if (read_bool != this->preserveAlpha){
+ this->preserveAlpha = read_bool;
+ this->parent->requestModified(SP_OBJECT_MODIFIED_FLAG);
}
break;
default:
@@ -233,8 +273,6 @@ void SPFeConvolveMatrix::set(unsigned int key, gchar const *value) {
* Receives update notifications.
*/
void SPFeConvolveMatrix::update(SPCtx *ctx, guint flags) {
- SPFeConvolveMatrix* object = this;
-
if (flags & (SP_OBJECT_MODIFIED_FLAG | SP_OBJECT_STYLE_MODIFIED_FLAG |
SP_OBJECT_VIEWPORT_MODIFIED_FLAG)) {
@@ -249,12 +287,10 @@ void SPFeConvolveMatrix::update(SPCtx *ctx, guint flags) {
* Writes its settings to an incoming repr object, if any.
*/
Inkscape::XML::Node* SPFeConvolveMatrix::write(Inkscape::XML::Document *doc, Inkscape::XML::Node *repr, guint flags) {
- SPFeConvolveMatrix* object = this;
-
/* TODO: Don't just clone, but create a new repr node and write all
* relevant values into it */
if (!repr) {
- repr = object->getRepr()->duplicate(doc);
+ repr = this->getRepr()->duplicate(doc);
}
@@ -264,28 +300,24 @@ Inkscape::XML::Node* SPFeConvolveMatrix::write(Inkscape::XML::Document *doc, Ink
}
void SPFeConvolveMatrix::build_renderer(Inkscape::Filters::Filter* filter) {
- SPFeConvolveMatrix* primitive = this;
-
- g_assert(primitive != NULL);
+ g_assert(this != NULL);
g_assert(filter != NULL);
- SPFeConvolveMatrix *sp_convolve = SP_FECONVOLVEMATRIX(primitive);
-
int primitive_n = filter->add_primitive(Inkscape::Filters::NR_FILTER_CONVOLVEMATRIX);
Inkscape::Filters::FilterPrimitive *nr_primitive = filter->get_primitive(primitive_n);
Inkscape::Filters::FilterConvolveMatrix *nr_convolve = dynamic_cast<Inkscape::Filters::FilterConvolveMatrix*>(nr_primitive);
g_assert(nr_convolve != NULL);
- sp_filter_primitive_renderer_common(primitive, nr_primitive);
+ sp_filter_primitive_renderer_common(this, nr_primitive);
- nr_convolve->set_targetX(sp_convolve->targetX);
- nr_convolve->set_targetY(sp_convolve->targetY);
- nr_convolve->set_orderX( (int)sp_convolve->order.getNumber() );
- nr_convolve->set_orderY( (int)sp_convolve->order.getOptNumber() );
- nr_convolve->set_kernelMatrix(sp_convolve->kernelMatrix);
- nr_convolve->set_divisor(sp_convolve->divisor);
- nr_convolve->set_bias(sp_convolve->bias);
- nr_convolve->set_preserveAlpha(sp_convolve->preserveAlpha);
+ nr_convolve->set_targetX(this->targetX);
+ nr_convolve->set_targetY(this->targetY);
+ nr_convolve->set_orderX( (int)this->order.getNumber() );
+ nr_convolve->set_orderY( (int)this->order.getOptNumber() );
+ nr_convolve->set_kernelMatrix(this->kernelMatrix);
+ nr_convolve->set_divisor(this->divisor);
+ nr_convolve->set_bias(this->bias);
+ nr_convolve->set_preserveAlpha(this->preserveAlpha);
}
/*
Local Variables:
diff --git a/src/filters/convolvematrix.h b/src/filters/convolvematrix.h
index 21bf210c4..abcf52384 100644
--- a/src/filters/convolvematrix.h
+++ b/src/filters/convolvematrix.h
@@ -39,6 +39,7 @@ public:
bool divisorIsSet;
bool kernelMatrixIsSet;
+protected:
virtual void build(SPDocument* doc, Inkscape::XML::Node* repr);
virtual void release();
diff --git a/src/filters/diffuselighting.cpp b/src/filters/diffuselighting.cpp
index c6c0ef311..09179a69d 100644
--- a/src/filters/diffuselighting.cpp
+++ b/src/filters/diffuselighting.cpp
@@ -71,13 +71,11 @@ SPFeDiffuseLighting::~SPFeDiffuseLighting() {
void SPFeDiffuseLighting::build(SPDocument *document, Inkscape::XML::Node *repr) {
SPFilterPrimitive::build(document, repr);
- SPFeDiffuseLighting* object = this;
-
/*LOAD ATTRIBUTES FROM REPR HERE*/
- object->readAttr( "surfaceScale" );
- object->readAttr( "diffuseConstant" );
- object->readAttr( "kernelUnitLength" );
- object->readAttr( "lighting-color" );
+ this->readAttr( "surfaceScale" );
+ this->readAttr( "diffuseConstant" );
+ this->readAttr( "kernelUnitLength" );
+ this->readAttr( "lighting-color" );
}
/**
@@ -91,85 +89,100 @@ void SPFeDiffuseLighting::release() {
* Sets a specific value in the SPFeDiffuseLighting.
*/
void SPFeDiffuseLighting::set(unsigned int key, gchar const *value) {
- SPFeDiffuseLighting* object = this;
-
- SPFeDiffuseLighting *feDiffuseLighting = SP_FEDIFFUSELIGHTING(object);
gchar const *cend_ptr = NULL;
gchar *end_ptr = NULL;
switch(key) {
/*DEAL WITH SETTING ATTRIBUTES HERE*/
-//TODO test forbidden values
+ //TODO test forbidden values
case SP_ATTR_SURFACESCALE:
end_ptr = NULL;
+
if (value) {
- feDiffuseLighting->surfaceScale = g_ascii_strtod(value, &end_ptr);
+ this->surfaceScale = g_ascii_strtod(value, &end_ptr);
+
if (end_ptr) {
- feDiffuseLighting->surfaceScale_set = TRUE;
+ this->surfaceScale_set = TRUE;
}
}
+
if (!value || !end_ptr) {
- feDiffuseLighting->surfaceScale = 1;
- feDiffuseLighting->surfaceScale_set = FALSE;
+ this->surfaceScale = 1;
+ this->surfaceScale_set = FALSE;
}
- if (feDiffuseLighting->renderer) {
- feDiffuseLighting->renderer->surfaceScale = feDiffuseLighting->surfaceScale;
+
+ if (this->renderer) {
+ this->renderer->surfaceScale = this->surfaceScale;
}
- object->parent->requestModified(SP_OBJECT_MODIFIED_FLAG);
+
+ this->parent->requestModified(SP_OBJECT_MODIFIED_FLAG);
break;
case SP_ATTR_DIFFUSECONSTANT:
end_ptr = NULL;
+
if (value) {
- feDiffuseLighting->diffuseConstant = g_ascii_strtod(value, &end_ptr);
- if (end_ptr && feDiffuseLighting->diffuseConstant >= 0) {
- feDiffuseLighting->diffuseConstant_set = TRUE;
+ this->diffuseConstant = g_ascii_strtod(value, &end_ptr);
+
+ if (end_ptr && this->diffuseConstant >= 0) {
+ this->diffuseConstant_set = TRUE;
} else {
end_ptr = NULL;
- g_warning("feDiffuseLighting: diffuseConstant should be a positive number ... defaulting to 1");
+ g_warning("this: diffuseConstant should be a positive number ... defaulting to 1");
}
}
+
if (!value || !end_ptr) {
- feDiffuseLighting->diffuseConstant = 1;
- feDiffuseLighting->diffuseConstant_set = FALSE;
+ this->diffuseConstant = 1;
+ this->diffuseConstant_set = FALSE;
}
- if (feDiffuseLighting->renderer) {
- feDiffuseLighting->renderer->diffuseConstant = feDiffuseLighting->diffuseConstant;
- }
- object->parent->requestModified(SP_OBJECT_MODIFIED_FLAG);
+
+ if (this->renderer) {
+ this->renderer->diffuseConstant = this->diffuseConstant;
+ }
+
+ this->parent->requestModified(SP_OBJECT_MODIFIED_FLAG);
break;
case SP_ATTR_KERNELUNITLENGTH:
//TODO kernelUnit
- //feDiffuseLighting->kernelUnitLength.set(value);
+ //this->kernelUnitLength.set(value);
/*TODOif (feDiffuseLighting->renderer) {
feDiffuseLighting->renderer->surfaceScale = feDiffuseLighting->renderer;
}
*/
- object->parent->requestModified(SP_OBJECT_MODIFIED_FLAG);
+ this->parent->requestModified(SP_OBJECT_MODIFIED_FLAG);
break;
case SP_PROP_LIGHTING_COLOR:
cend_ptr = NULL;
- feDiffuseLighting->lighting_color = sp_svg_read_color(value, &cend_ptr, 0xffffffff);
+ this->lighting_color = sp_svg_read_color(value, &cend_ptr, 0xffffffff);
+
//if a value was read
if (cend_ptr) {
while (g_ascii_isspace(*cend_ptr)) {
++cend_ptr;
}
+
if (strneq(cend_ptr, "icc-color(", 10)) {
- if (!feDiffuseLighting->icc) feDiffuseLighting->icc = new SVGICCColor();
- if ( ! sp_svg_read_icc_color( cend_ptr, feDiffuseLighting->icc ) ) {
- delete feDiffuseLighting->icc;
- feDiffuseLighting->icc = NULL;
+ if (!this->icc) {
+ this->icc = new SVGICCColor();
+ }
+
+ if ( ! sp_svg_read_icc_color( cend_ptr, this->icc ) ) {
+ delete this->icc;
+ this->icc = NULL;
}
}
- feDiffuseLighting->lighting_color_set = TRUE;
+
+ this->lighting_color_set = TRUE;
} else {
//lighting_color already contains the default value
- feDiffuseLighting->lighting_color_set = FALSE;
+ this->lighting_color_set = FALSE;
}
- if (feDiffuseLighting->renderer) {
- feDiffuseLighting->renderer->lighting_color = feDiffuseLighting->lighting_color;
+
+ if (this->renderer) {
+ this->renderer->lighting_color = this->lighting_color;
}
- object->parent->requestModified(SP_OBJECT_MODIFIED_FLAG);
+
+ this->parent->requestModified(SP_OBJECT_MODIFIED_FLAG);
break;
default:
SPFilterPrimitive::set(key, value);
@@ -181,13 +194,11 @@ void SPFeDiffuseLighting::set(unsigned int key, gchar const *value) {
* Receives update notifications.
*/
void SPFeDiffuseLighting::update(SPCtx *ctx, guint flags) {
- SPFeDiffuseLighting* object = this;
-
if (flags & (SP_OBJECT_MODIFIED_FLAG)) {
- object->readAttr( "surfaceScale" );
- object->readAttr( "diffuseConstant" );
- object->readAttr( "kernelUnit" );
- object->readAttr( "lighting-color" );
+ this->readAttr( "surfaceScale" );
+ this->readAttr( "diffuseConstant" );
+ this->readAttr( "kernelUnit" );
+ this->readAttr( "lighting-color" );
}
SPFilterPrimitive::update(ctx, flags);
@@ -197,32 +208,33 @@ void SPFeDiffuseLighting::update(SPCtx *ctx, guint flags) {
* Writes its settings to an incoming repr object, if any.
*/
Inkscape::XML::Node* SPFeDiffuseLighting::write(Inkscape::XML::Document *doc, Inkscape::XML::Node *repr, guint flags) {
- SPFeDiffuseLighting* object = this;
-
- SPFeDiffuseLighting *fediffuselighting = SP_FEDIFFUSELIGHTING(object);
-
/* TODO: Don't just clone, but create a new repr node and write all
* relevant values _and children_ into it */
if (!repr) {
- repr = object->getRepr()->duplicate(doc);
+ repr = this->getRepr()->duplicate(doc);
//repr = doc->createElement("svg:feDiffuseLighting");
}
- if (fediffuselighting->surfaceScale_set)
- sp_repr_set_css_double(repr, "surfaceScale", fediffuselighting->surfaceScale);
- else
+ if (this->surfaceScale_set) {
+ sp_repr_set_css_double(repr, "surfaceScale", this->surfaceScale);
+ } else {
repr->setAttribute("surfaceScale", NULL);
- if (fediffuselighting->diffuseConstant_set)
- sp_repr_set_css_double(repr, "diffuseConstant", fediffuselighting->diffuseConstant);
- else
+ }
+
+ if (this->diffuseConstant_set) {
+ sp_repr_set_css_double(repr, "diffuseConstant", this->diffuseConstant);
+ } else {
repr->setAttribute("diffuseConstant", NULL);
- /*TODO kernelUnits */
- if (fediffuselighting->lighting_color_set) {
+ }
+
+ /*TODO kernelUnits */
+ if (this->lighting_color_set) {
gchar c[64];
- sp_svg_write_color(c, sizeof(c), fediffuselighting->lighting_color);
+ sp_svg_write_color(c, sizeof(c), this->lighting_color);
repr->setAttribute("lighting-color", c);
- } else
+ } else {
repr->setAttribute("lighting-color", NULL);
+ }
SPFilterPrimitive::write(doc, repr, flags);
@@ -233,38 +245,27 @@ Inkscape::XML::Node* SPFeDiffuseLighting::write(Inkscape::XML::Document *doc, In
* Callback for child_added event.
*/
void SPFeDiffuseLighting::child_added(Inkscape::XML::Node *child, Inkscape::XML::Node *ref) {
- SPFeDiffuseLighting* object = this;
-
- SPFeDiffuseLighting *f = SP_FEDIFFUSELIGHTING(object);
-
SPFilterPrimitive::child_added(child, ref);
- sp_feDiffuseLighting_children_modified(f);
- object->parent->requestModified(SP_OBJECT_MODIFIED_FLAG);
+ sp_feDiffuseLighting_children_modified(this);
+ this->parent->requestModified(SP_OBJECT_MODIFIED_FLAG);
}
/**
* Callback for remove_child event.
*/
void SPFeDiffuseLighting::remove_child(Inkscape::XML::Node *child) {
- SPFeDiffuseLighting* object = this;
-
- SPFeDiffuseLighting *f = SP_FEDIFFUSELIGHTING(object);
-
SPFilterPrimitive::remove_child(child);
- sp_feDiffuseLighting_children_modified(f);
- object->parent->requestModified(SP_OBJECT_MODIFIED_FLAG);
+ sp_feDiffuseLighting_children_modified(this);
+ this->parent->requestModified(SP_OBJECT_MODIFIED_FLAG);
}
void SPFeDiffuseLighting::order_changed(Inkscape::XML::Node *child, Inkscape::XML::Node *old_ref, Inkscape::XML::Node *new_ref) {
- SPFeDiffuseLighting* object = this;
-
- SPFeDiffuseLighting *f = SP_FEDIFFUSELIGHTING(object);
SPFilterPrimitive::order_changed(child, old_ref, new_ref);
- sp_feDiffuseLighting_children_modified(f);
- object->parent->requestModified(SP_OBJECT_MODIFIED_FLAG);
+ sp_feDiffuseLighting_children_modified(this);
+ this->parent->requestModified(SP_OBJECT_MODIFIED_FLAG);
}
static void sp_feDiffuseLighting_children_modified(SPFeDiffuseLighting *sp_diffuselighting)
@@ -287,39 +288,38 @@ static void sp_feDiffuseLighting_children_modified(SPFeDiffuseLighting *sp_diffu
}
void SPFeDiffuseLighting::build_renderer(Inkscape::Filters::Filter* filter) {
- SPFeDiffuseLighting* primitive = this;
-
- g_assert(primitive != NULL);
+ g_assert(this != NULL);
g_assert(filter != NULL);
- SPFeDiffuseLighting *sp_diffuselighting = SP_FEDIFFUSELIGHTING(primitive);
-
int primitive_n = filter->add_primitive(Inkscape::Filters::NR_FILTER_DIFFUSELIGHTING);
Inkscape::Filters::FilterPrimitive *nr_primitive = filter->get_primitive(primitive_n);
Inkscape::Filters::FilterDiffuseLighting *nr_diffuselighting = dynamic_cast<Inkscape::Filters::FilterDiffuseLighting*>(nr_primitive);
g_assert(nr_diffuselighting != NULL);
- sp_diffuselighting->renderer = nr_diffuselighting;
- sp_filter_primitive_renderer_common(primitive, nr_primitive);
+ this->renderer = nr_diffuselighting;
+ sp_filter_primitive_renderer_common(this, nr_primitive);
- nr_diffuselighting->diffuseConstant = sp_diffuselighting->diffuseConstant;
- nr_diffuselighting->surfaceScale = sp_diffuselighting->surfaceScale;
- nr_diffuselighting->lighting_color = sp_diffuselighting->lighting_color;
- nr_diffuselighting->set_icc(sp_diffuselighting->icc);
+ nr_diffuselighting->diffuseConstant = this->diffuseConstant;
+ nr_diffuselighting->surfaceScale = this->surfaceScale;
+ nr_diffuselighting->lighting_color = this->lighting_color;
+ nr_diffuselighting->set_icc(this->icc);
//We assume there is at most one child
nr_diffuselighting->light_type = Inkscape::Filters::NO_LIGHT;
- if (SP_IS_FEDISTANTLIGHT(primitive->children)) {
+
+ if (SP_IS_FEDISTANTLIGHT(this->children)) {
nr_diffuselighting->light_type = Inkscape::Filters::DISTANT_LIGHT;
- nr_diffuselighting->light.distant = SP_FEDISTANTLIGHT(primitive->children);
+ nr_diffuselighting->light.distant = SP_FEDISTANTLIGHT(this->children);
}
- if (SP_IS_FEPOINTLIGHT(primitive->children)) {
+
+ if (SP_IS_FEPOINTLIGHT(this->children)) {
nr_diffuselighting->light_type = Inkscape::Filters::POINT_LIGHT;
- nr_diffuselighting->light.point = SP_FEPOINTLIGHT(primitive->children);
+ nr_diffuselighting->light.point = SP_FEPOINTLIGHT(this->children);
}
- if (SP_IS_FESPOTLIGHT(primitive->children)) {
+
+ if (SP_IS_FESPOTLIGHT(this->children)) {
nr_diffuselighting->light_type = Inkscape::Filters::SPOT_LIGHT;
- nr_diffuselighting->light.spot = SP_FESPOTLIGHT(primitive->children);
+ nr_diffuselighting->light.spot = SP_FESPOTLIGHT(this->children);
}
//nr_offset->set_dx(sp_offset->dx);
diff --git a/src/filters/diffuselighting.h b/src/filters/diffuselighting.h
index 0434e0638..e33584b4f 100644
--- a/src/filters/diffuselighting.h
+++ b/src/filters/diffuselighting.h
@@ -40,6 +40,7 @@ public:
Inkscape::Filters::FilterDiffuseLighting *renderer;
SVGICCColor *icc;
+protected:
virtual void build(SPDocument* doc, Inkscape::XML::Node* repr);
virtual void release();
diff --git a/src/filters/displacementmap.cpp b/src/filters/displacementmap.cpp
index 03b2834b6..473e4913f 100644
--- a/src/filters/displacementmap.cpp
+++ b/src/filters/displacementmap.cpp
@@ -51,25 +51,22 @@ SPFeDisplacementMap::~SPFeDisplacementMap() {
* sp-object-repr.cpp's repr_name_entries array.
*/
void SPFeDisplacementMap::build(SPDocument *document, Inkscape::XML::Node *repr) {
- SPFeDisplacementMap* object = this;
-
SPFilterPrimitive::build(document, repr);
/*LOAD ATTRIBUTES FROM REPR HERE*/
- object->readAttr( "scale" );
- object->readAttr( "in2" );
- object->readAttr( "xChannelSelector" );
- object->readAttr( "yChannelSelector" );
+ this->readAttr( "scale" );
+ this->readAttr( "in2" );
+ this->readAttr( "xChannelSelector" );
+ this->readAttr( "yChannelSelector" );
/* Unlike normal in, in2 is required attribute. Make sure, we can call
* it by some name. */
- SPFeDisplacementMap *disp = SP_FEDISPLACEMENTMAP(object);
- if (disp->in2 == Inkscape::Filters::NR_FILTER_SLOT_NOT_SET ||
- disp->in2 == Inkscape::Filters::NR_FILTER_UNNAMED_SLOT)
+ if (this->in2 == Inkscape::Filters::NR_FILTER_SLOT_NOT_SET ||
+ this->in2 == Inkscape::Filters::NR_FILTER_UNNAMED_SLOT)
{
- SPFilter *parent = SP_FILTER(object->parent);
- disp->in2 = sp_filter_primitive_name_previous_out(disp);
- repr->setAttribute("in2", sp_filter_name_for_image(parent, disp->in2));
+ SPFilter *parent = SP_FILTER(this->parent);
+ this->in2 = sp_filter_primitive_name_previous_out(this);
+ repr->setAttribute("in2", sp_filter_name_for_image(parent, this->in2));
}
}
@@ -83,6 +80,7 @@ void SPFeDisplacementMap::release() {
static FilterDisplacementMapChannelSelector sp_feDisplacementMap_readChannelSelector(gchar const *value)
{
if (!value) return DISPLACEMENTMAP_CHANNEL_ALPHA;
+
switch (value[0]) {
case 'R':
return DISPLACEMENTMAP_CHANNEL_RED;
@@ -101,6 +99,7 @@ static FilterDisplacementMapChannelSelector sp_feDisplacementMap_readChannelSele
g_warning("Invalid attribute for Channel Selector. Valid modes are 'R', 'G', 'B' or 'A'");
break;
}
+
return DISPLACEMENTMAP_CHANNEL_ALPHA; //default is Alpha Channel
}
@@ -108,41 +107,42 @@ static FilterDisplacementMapChannelSelector sp_feDisplacementMap_readChannelSele
* Sets a specific value in the SPFeDisplacementMap.
*/
void SPFeDisplacementMap::set(unsigned int key, gchar const *value) {
- SPFeDisplacementMap* object = this;
-
- SPFeDisplacementMap *feDisplacementMap = SP_FEDISPLACEMENTMAP(object);
- (void)feDisplacementMap;
int input;
double read_num;
FilterDisplacementMapChannelSelector read_selector;
+
switch(key) {
/*DEAL WITH SETTING ATTRIBUTES HERE*/
case SP_ATTR_XCHANNELSELECTOR:
read_selector = sp_feDisplacementMap_readChannelSelector(value);
- if (read_selector != feDisplacementMap->xChannelSelector){
- feDisplacementMap->xChannelSelector = read_selector;
- object->parent->requestModified(SP_OBJECT_MODIFIED_FLAG);
+
+ if (read_selector != this->xChannelSelector){
+ this->xChannelSelector = read_selector;
+ this->parent->requestModified(SP_OBJECT_MODIFIED_FLAG);
}
break;
case SP_ATTR_YCHANNELSELECTOR:
read_selector = sp_feDisplacementMap_readChannelSelector(value);
- if (read_selector != feDisplacementMap->yChannelSelector){
- feDisplacementMap->yChannelSelector = read_selector;
- object->parent->requestModified(SP_OBJECT_MODIFIED_FLAG);
+
+ if (read_selector != this->yChannelSelector){
+ this->yChannelSelector = read_selector;
+ this->parent->requestModified(SP_OBJECT_MODIFIED_FLAG);
}
break;
case SP_ATTR_SCALE:
read_num = value ? helperfns_read_number(value) : 0;
- if (read_num != feDisplacementMap->scale) {
- feDisplacementMap->scale = read_num;
- object->parent->requestModified(SP_OBJECT_MODIFIED_FLAG);
+
+ if (read_num != this->scale) {
+ this->scale = read_num;
+ this->parent->requestModified(SP_OBJECT_MODIFIED_FLAG);
}
break;
case SP_ATTR_IN2:
- input = sp_filter_primitive_read_in(feDisplacementMap, value);
- if (input != feDisplacementMap->in2) {
- feDisplacementMap->in2 = input;
- object->parent->requestModified(SP_OBJECT_MODIFIED_FLAG);
+ input = sp_filter_primitive_read_in(this, value);
+
+ if (input != this->in2) {
+ this->in2 = input;
+ this->parent->requestModified(SP_OBJECT_MODIFIED_FLAG);
}
break;
default:
@@ -155,8 +155,6 @@ void SPFeDisplacementMap::set(unsigned int key, gchar const *value) {
* Receives update notifications.
*/
void SPFeDisplacementMap::update(SPCtx *ctx, guint flags) {
- SPFeDisplacementMap* object = this;
-
if (flags & (SP_OBJECT_MODIFIED_FLAG | SP_OBJECT_STYLE_MODIFIED_FLAG |
SP_OBJECT_VIEWPORT_MODIFIED_FLAG)) {
@@ -166,15 +164,14 @@ void SPFeDisplacementMap::update(SPCtx *ctx, guint flags) {
/* Unlike normal in, in2 is required attribute. Make sure, we can call
* it by some name. */
- SPFeDisplacementMap *disp = SP_FEDISPLACEMENTMAP(object);
- if (disp->in2 == Inkscape::Filters::NR_FILTER_SLOT_NOT_SET ||
- disp->in2 == Inkscape::Filters::NR_FILTER_UNNAMED_SLOT)
+ if (this->in2 == Inkscape::Filters::NR_FILTER_SLOT_NOT_SET ||
+ this->in2 == Inkscape::Filters::NR_FILTER_UNNAMED_SLOT)
{
- SPFilter *parent = SP_FILTER(object->parent);
- disp->in2 = sp_filter_primitive_name_previous_out(disp);
+ SPFilter *parent = SP_FILTER(this->parent);
+ this->in2 = sp_filter_primitive_name_previous_out(this);
//XML Tree being used directly here while it shouldn't be.
- object->getRepr()->setAttribute("in2", sp_filter_name_for_image(parent, disp->in2));
+ this->getRepr()->setAttribute("in2", sp_filter_name_for_image(parent, this->in2));
}
SPFilterPrimitive::update(ctx, flags);
@@ -199,34 +196,36 @@ static char const * get_channelselector_name(FilterDisplacementMapChannelSelecto
* Writes its settings to an incoming repr object, if any.
*/
Inkscape::XML::Node* SPFeDisplacementMap::write(Inkscape::XML::Document *doc, Inkscape::XML::Node *repr, guint flags) {
- SPFeDisplacementMap* object = this;
-
- SPFeDisplacementMap *disp = SP_FEDISPLACEMENTMAP(object);
- SPFilter *parent = SP_FILTER(object->parent);
+ SPFilter *parent = SP_FILTER(this->parent);
if (!repr) {
repr = doc->createElement("svg:feDisplacementMap");
}
- gchar const *out_name = sp_filter_name_for_image(parent, disp->in2);
+ gchar const *out_name = sp_filter_name_for_image(parent, this->in2);
if (out_name) {
repr->setAttribute("in2", out_name);
} else {
SPObject *i = parent->children;
- while (i && i->next != object) i = i->next;
+
+ while (i && i->next != this) {
+ i = i->next;
+ }
+
SPFilterPrimitive *i_prim = SP_FILTER_PRIMITIVE(i);
out_name = sp_filter_name_for_image(parent, i_prim->image_out);
repr->setAttribute("in2", out_name);
+
if (!out_name) {
g_warning("Unable to set in2 for feDisplacementMap");
}
}
- sp_repr_set_svg_double(repr, "scale", disp->scale);
+ sp_repr_set_svg_double(repr, "scale", this->scale);
repr->setAttribute("xChannelSelector",
- get_channelselector_name(disp->xChannelSelector));
+ get_channelselector_name(this->xChannelSelector));
repr->setAttribute("yChannelSelector",
- get_channelselector_name(disp->yChannelSelector));
+ get_channelselector_name(this->yChannelSelector));
SPFilterPrimitive::write(doc, repr, flags);
@@ -234,24 +233,20 @@ Inkscape::XML::Node* SPFeDisplacementMap::write(Inkscape::XML::Document *doc, In
}
void SPFeDisplacementMap::build_renderer(Inkscape::Filters::Filter* filter) {
- SPFeDisplacementMap* primitive = this;
-
- g_assert(primitive != NULL);
+ g_assert(this != NULL);
g_assert(filter != NULL);
- SPFeDisplacementMap *sp_displacement_map = SP_FEDISPLACEMENTMAP(primitive);
-
int primitive_n = filter->add_primitive(Inkscape::Filters::NR_FILTER_DISPLACEMENTMAP);
Inkscape::Filters::FilterPrimitive *nr_primitive = filter->get_primitive(primitive_n);
Inkscape::Filters::FilterDisplacementMap *nr_displacement_map = dynamic_cast<Inkscape::Filters::FilterDisplacementMap*>(nr_primitive);
g_assert(nr_displacement_map != NULL);
- sp_filter_primitive_renderer_common(primitive, nr_primitive);
+ sp_filter_primitive_renderer_common(this, nr_primitive);
- nr_displacement_map->set_input(1, sp_displacement_map->in2);
- nr_displacement_map->set_scale(sp_displacement_map->scale);
- nr_displacement_map->set_channel_selector(0, sp_displacement_map->xChannelSelector);
- nr_displacement_map->set_channel_selector(1, sp_displacement_map->yChannelSelector);
+ nr_displacement_map->set_input(1, this->in2);
+ nr_displacement_map->set_scale(this->scale);
+ nr_displacement_map->set_channel_selector(0, this->xChannelSelector);
+ nr_displacement_map->set_channel_selector(1, this->yChannelSelector);
}
/*
diff --git a/src/filters/displacementmap.h b/src/filters/displacementmap.h
index 484e25861..3100e66b7 100644
--- a/src/filters/displacementmap.h
+++ b/src/filters/displacementmap.h
@@ -35,6 +35,7 @@ public:
FilterDisplacementMapChannelSelector xChannelSelector;
FilterDisplacementMapChannelSelector yChannelSelector;
+protected:
virtual void build(SPDocument* doc, Inkscape::XML::Node* repr);
virtual void release();
diff --git a/src/filters/flood.cpp b/src/filters/flood.cpp
index a3d357b64..134492d34 100644
--- a/src/filters/flood.cpp
+++ b/src/filters/flood.cpp
@@ -55,11 +55,9 @@ SPFeFlood::~SPFeFlood() {
void SPFeFlood::build(SPDocument *document, Inkscape::XML::Node *repr) {
SPFilterPrimitive::build(document, repr);
- SPFeFlood* object = this;
-
/*LOAD ATTRIBUTES FROM REPR HERE*/
- object->readAttr( "flood-opacity" );
- object->readAttr( "flood-color" );
+ this->readAttr( "flood-opacity" );
+ this->readAttr( "flood-color" );
}
/**
@@ -73,10 +71,6 @@ void SPFeFlood::release() {
* Sets a specific value in the SPFeFlood.
*/
void SPFeFlood::set(unsigned int key, gchar const *value) {
- SPFeFlood* object = this;
-
- SPFeFlood *feFlood = SP_FEFLOOD(object);
- (void)feFlood;
gchar const *cend_ptr = NULL;
gchar *end_ptr = NULL;
guint32 read_color;
@@ -89,8 +83,8 @@ void SPFeFlood::set(unsigned int key, gchar const *value) {
cend_ptr = NULL;
read_color = sp_svg_read_color(value, &cend_ptr, 0xffffffff);
- if (cend_ptr && read_color != feFlood->color){
- feFlood->color = read_color;
+ if (cend_ptr && read_color != this->color){
+ this->color = read_color;
dirty=true;
}
@@ -98,36 +92,42 @@ void SPFeFlood::set(unsigned int key, gchar const *value) {
while (g_ascii_isspace(*cend_ptr)) {
++cend_ptr;
}
+
if (strneq(cend_ptr, "icc-color(", 10)) {
- if (!feFlood->icc) feFlood->icc = new SVGICCColor();
- if ( ! sp_svg_read_icc_color( cend_ptr, feFlood->icc ) ) {
- delete feFlood->icc;
- feFlood->icc = NULL;
+ if (!this->icc) {
+ this->icc = new SVGICCColor();
+ }
+
+ if ( ! sp_svg_read_icc_color( cend_ptr, this->icc ) ) {
+ delete this->icc;
+ this->icc = NULL;
}
+
dirty = true;
}
}
- if (dirty)
- object->parent->requestModified(SP_OBJECT_MODIFIED_FLAG);
+
+ if (dirty) {
+ this->parent->requestModified(SP_OBJECT_MODIFIED_FLAG);
+ }
break;
case SP_PROP_FLOOD_OPACITY:
if (value) {
read_num = g_ascii_strtod(value, &end_ptr);
- if (end_ptr != NULL)
- {
- if (*end_ptr)
- {
+
+ if (end_ptr != NULL) {
+ if (*end_ptr) {
g_warning("Unable to convert \"%s\" to number", value);
read_num = 1;
}
}
- }
- else {
+ } else {
read_num = 1;
}
- if (read_num != feFlood->opacity){
- feFlood->opacity = read_num;
- object->parent->requestModified(SP_OBJECT_MODIFIED_FLAG);
+
+ if (read_num != this->opacity) {
+ this->opacity = read_num;
+ this->parent->requestModified(SP_OBJECT_MODIFIED_FLAG);
}
break;
default:
@@ -140,8 +140,6 @@ void SPFeFlood::set(unsigned int key, gchar const *value) {
* Receives update notifications.
*/
void SPFeFlood::update(SPCtx *ctx, guint flags) {
- SPFeFlood* object = this;
-
if (flags & (SP_OBJECT_MODIFIED_FLAG | SP_OBJECT_STYLE_MODIFIED_FLAG |
SP_OBJECT_VIEWPORT_MODIFIED_FLAG)) {
@@ -156,12 +154,10 @@ void SPFeFlood::update(SPCtx *ctx, guint flags) {
* Writes its settings to an incoming repr object, if any.
*/
Inkscape::XML::Node* SPFeFlood::write(Inkscape::XML::Document *doc, Inkscape::XML::Node *repr, guint flags) {
- SPFeFlood* object = this;
-
/* TODO: Don't just clone, but create a new repr node and write all
* relevant values into it */
if (!repr) {
- repr = object->getRepr()->duplicate(doc);
+ repr = this->getRepr()->duplicate(doc);
}
SPFilterPrimitive::write(doc, repr, flags);
@@ -170,24 +166,19 @@ Inkscape::XML::Node* SPFeFlood::write(Inkscape::XML::Document *doc, Inkscape::XM
}
void SPFeFlood::build_renderer(Inkscape::Filters::Filter* filter) {
- SPFeFlood* primitive = this;
-
- g_assert(primitive != NULL);
+ g_assert(this != NULL);
g_assert(filter != NULL);
- SPFeFlood *sp_flood = SP_FEFLOOD(primitive);
- (void)sp_flood;
-
int primitive_n = filter->add_primitive(Inkscape::Filters::NR_FILTER_FLOOD);
Inkscape::Filters::FilterPrimitive *nr_primitive = filter->get_primitive(primitive_n);
Inkscape::Filters::FilterFlood *nr_flood = dynamic_cast<Inkscape::Filters::FilterFlood*>(nr_primitive);
g_assert(nr_flood != NULL);
- sp_filter_primitive_renderer_common(primitive, nr_primitive);
+ sp_filter_primitive_renderer_common(this, nr_primitive);
- nr_flood->set_opacity(sp_flood->opacity);
- nr_flood->set_color(sp_flood->color);
- nr_flood->set_icc(sp_flood->icc);
+ nr_flood->set_opacity(this->opacity);
+ nr_flood->set_color(this->color);
+ nr_flood->set_icc(this->icc);
}
/*
diff --git a/src/filters/flood.h b/src/filters/flood.h
index 699157d48..67369a794 100644
--- a/src/filters/flood.h
+++ b/src/filters/flood.h
@@ -27,6 +27,7 @@ public:
SVGICCColor *icc;
double opacity;
+protected:
virtual void build(SPDocument* doc, Inkscape::XML::Node* repr);
virtual void release();
diff --git a/src/filters/gaussian-blur.cpp b/src/filters/gaussian-blur.cpp
index e2f58f476..fc1e65925 100644
--- a/src/filters/gaussian-blur.cpp
+++ b/src/filters/gaussian-blur.cpp
@@ -54,9 +54,7 @@ SPGaussianBlur::~SPGaussianBlur() {
void SPGaussianBlur::build(SPDocument *document, Inkscape::XML::Node *repr) {
SPFilterPrimitive::build(document, repr);
- SPGaussianBlur* object = this;
-
- object->readAttr( "stdDeviation" );
+ this->readAttr( "stdDeviation" );
}
/**
@@ -70,14 +68,10 @@ void SPGaussianBlur::release() {
* Sets a specific value in the SPGaussianBlur.
*/
void SPGaussianBlur::set(unsigned int key, gchar const *value) {
- SPGaussianBlur* object = this;
-
- SPGaussianBlur *gaussianBlur = SP_GAUSSIANBLUR(object);
-
switch(key) {
case SP_ATTR_STDDEVIATION:
- gaussianBlur->stdDeviation.set(value);
- object->parent->requestModified(SP_OBJECT_MODIFIED_FLAG);
+ this->stdDeviation.set(value);
+ this->parent->requestModified(SP_OBJECT_MODIFIED_FLAG);
break;
default:
SPFilterPrimitive::set(key, value);
@@ -89,10 +83,8 @@ void SPGaussianBlur::set(unsigned int key, gchar const *value) {
* Receives update notifications.
*/
void SPGaussianBlur::update(SPCtx *ctx, guint flags) {
- SPGaussianBlur* object = this;
-
if (flags & SP_OBJECT_MODIFIED_FLAG) {
- object->readAttr( "stdDeviation" );
+ this->readAttr( "stdDeviation" );
}
SPFilterPrimitive::update(ctx, flags);
@@ -102,12 +94,10 @@ void SPGaussianBlur::update(SPCtx *ctx, guint flags) {
* Writes its settings to an incoming repr object, if any.
*/
Inkscape::XML::Node* SPGaussianBlur::write(Inkscape::XML::Document *doc, Inkscape::XML::Node *repr, guint flags) {
- SPGaussianBlur* object = this;
-
/* TODO: Don't just clone, but create a new repr node and write all
* relevant values into it */
if (!repr) {
- repr = object->getRepr()->duplicate(doc);
+ repr = this->getRepr()->duplicate(doc);
}
SPFilterPrimitive::write(doc, repr, flags);
@@ -119,6 +109,7 @@ void sp_gaussianBlur_setDeviation(SPGaussianBlur *blur, float num)
{
blur->stdDeviation.setNumber(num);
}
+
void sp_gaussianBlur_setDeviation(SPGaussianBlur *blur, float num, float optnum)
{
blur->stdDeviation.setNumber(num);
@@ -126,23 +117,22 @@ void sp_gaussianBlur_setDeviation(SPGaussianBlur *blur, float num, float optnum
}
void SPGaussianBlur::build_renderer(Inkscape::Filters::Filter* filter) {
- SPGaussianBlur* primitive = this;
-
- SPGaussianBlur *sp_blur = SP_GAUSSIANBLUR(primitive);
-
int handle = filter->add_primitive(Inkscape::Filters::NR_FILTER_GAUSSIANBLUR);
Inkscape::Filters::FilterPrimitive *nr_primitive = filter->get_primitive(handle);
Inkscape::Filters::FilterGaussian *nr_blur = dynamic_cast<Inkscape::Filters::FilterGaussian*>(nr_primitive);
- sp_filter_primitive_renderer_common(primitive, nr_primitive);
+ sp_filter_primitive_renderer_common(this, nr_primitive);
+
+ gfloat num = this->stdDeviation.getNumber();
- gfloat num = sp_blur->stdDeviation.getNumber();
if (num >= 0.0) {
- gfloat optnum = sp_blur->stdDeviation.getOptNumber();
- if(optnum >= 0.0)
+ gfloat optnum = this->stdDeviation.getOptNumber();
+
+ if(optnum >= 0.0) {
nr_blur->set_deviation((double) num, (double) optnum);
- else
+ } else {
nr_blur->set_deviation((double) num);
+ }
}
}
diff --git a/src/filters/gaussian-blur.h b/src/filters/gaussian-blur.h
index 4a8a58d36..b0e725a50 100644
--- a/src/filters/gaussian-blur.h
+++ b/src/filters/gaussian-blur.h
@@ -26,6 +26,7 @@ public:
/** stdDeviation attribute */
NumberOptNumber stdDeviation;
+protected:
virtual void build(SPDocument* doc, Inkscape::XML::Node* repr);
virtual void release();
diff --git a/src/filters/image.cpp b/src/filters/image.cpp
index 150e9a33f..a454061c9 100644
--- a/src/filters/image.cpp
+++ b/src/filters/image.cpp
@@ -59,30 +59,27 @@ SPFeImage::~SPFeImage() {
* sp-object-repr.cpp's repr_name_entries array.
*/
void SPFeImage::build(SPDocument *document, Inkscape::XML::Node *repr) {
- SPFeImage* object = this;
-
// Save document reference so we can load images with relative paths.
- SPFeImage *feImage = SP_FEIMAGE(object);
- feImage->document = document;
+ this->document = document;
SPFilterPrimitive::build(document, repr);
/*LOAD ATTRIBUTES FROM REPR HERE*/
- object->readAttr( "preserveAspectRatio" );
- object->readAttr( "xlink:href" );
+ this->readAttr( "preserveAspectRatio" );
+ this->readAttr( "xlink:href" );
}
/**
* Drops any allocated memory.
*/
void SPFeImage::release() {
- SPFeImage* object = this;
+ this->_image_modified_connection.disconnect();
+ this->_href_modified_connection.disconnect();
- SPFeImage *feImage = SP_FEIMAGE(object);
- feImage->_image_modified_connection.disconnect();
- feImage->_href_modified_connection.disconnect();
- if (feImage->SVGElemRef) delete feImage->SVGElemRef;
+ if (this->SVGElemRef) {
+ delete this->SVGElemRef;
+ }
SPFilterPrimitive::release();
}
@@ -110,42 +107,38 @@ static void sp_feImage_href_modified(SPObject* /*old_elem*/, SPObject* new_elem,
* Sets a specific value in the SPFeImage.
*/
void SPFeImage::set(unsigned int key, gchar const *value) {
- SPFeImage* object = this;
-
- SPFeImage *feImage = SP_FEIMAGE(object);
- (void)feImage;
switch(key) {
/*DEAL WITH SETTING ATTRIBUTES HERE*/
case SP_ATTR_XLINK_HREF:
- if (feImage->href) {
- g_free(feImage->href);
+ if (this->href) {
+ g_free(this->href);
}
- feImage->href = (value) ? g_strdup (value) : NULL;
- if (!feImage->href) return;
- delete feImage->SVGElemRef;
- feImage->SVGElemRef = 0;
- feImage->SVGElem = 0;
- feImage->_image_modified_connection.disconnect();
- feImage->_href_modified_connection.disconnect();
+ this->href = (value) ? g_strdup (value) : NULL;
+ if (!this->href) return;
+ delete this->SVGElemRef;
+ this->SVGElemRef = 0;
+ this->SVGElem = 0;
+ this->_image_modified_connection.disconnect();
+ this->_href_modified_connection.disconnect();
try{
- Inkscape::URI SVGElem_uri(feImage->href);
- feImage->SVGElemRef = new Inkscape::URIReference(feImage->document);
- feImage->SVGElemRef->attach(SVGElem_uri);
- feImage->from_element = true;
- feImage->_href_modified_connection = feImage->SVGElemRef->changedSignal().connect(sigc::bind(sigc::ptr_fun(&sp_feImage_href_modified), object));
- if (SPObject *elemref = feImage->SVGElemRef->getObject()) {
- feImage->SVGElem = SP_ITEM(elemref);
- feImage->_image_modified_connection = ((SPObject*) feImage->SVGElem)->connectModified(sigc::bind(sigc::ptr_fun(&sp_feImage_elem_modified), object));
- object->requestModified(SP_OBJECT_MODIFIED_FLAG);
+ Inkscape::URI SVGElem_uri(this->href);
+ this->SVGElemRef = new Inkscape::URIReference(this->document);
+ this->SVGElemRef->attach(SVGElem_uri);
+ this->from_element = true;
+ this->_href_modified_connection = this->SVGElemRef->changedSignal().connect(sigc::bind(sigc::ptr_fun(&sp_feImage_href_modified), this));
+ if (SPObject *elemref = this->SVGElemRef->getObject()) {
+ this->SVGElem = SP_ITEM(elemref);
+ this->_image_modified_connection = ((SPObject*) this->SVGElem)->connectModified(sigc::bind(sigc::ptr_fun(&sp_feImage_elem_modified), this));
+ this->requestModified(SP_OBJECT_MODIFIED_FLAG);
break;
} else {
- g_warning("SVG element URI was not found in the document while loading feImage");
+ g_warning("SVG element URI was not found in the document while loading this");
}
}
// catches either MalformedURIException or UnsupportedURIException
catch(const Inkscape::BadURIException & e)
{
- feImage->from_element = false;
+ this->from_element = false;
/* This occurs when using external image as the source */
//g_warning("caught Inkscape::BadURIException in sp_feImage_set");
break;
@@ -155,9 +148,9 @@ void SPFeImage::set(unsigned int key, gchar const *value) {
case SP_ATTR_PRESERVEASPECTRATIO:
/* Copied from sp-image.cpp */
/* Do setup before, so we can use break to escape */
- feImage->aspect_align = SP_ASPECT_XMID_YMID; // Default
- feImage->aspect_clip = SP_ASPECT_MEET; // Default
- object->requestDisplayUpdate(SP_OBJECT_MODIFIED_FLAG | SP_OBJECT_VIEWPORT_MODIFIED_FLAG);
+ this->aspect_align = SP_ASPECT_XMID_YMID; // Default
+ this->aspect_clip = SP_ASPECT_MEET; // Default
+ this->requestDisplayUpdate(SP_OBJECT_MODIFIED_FLAG | SP_OBJECT_VIEWPORT_MODIFIED_FLAG);
if (value) {
int len;
gchar c[256];
@@ -208,8 +201,8 @@ void SPFeImage::set(unsigned int key, gchar const *value) {
break;
}
}
- feImage->aspect_align = align;
- feImage->aspect_clip = clip;
+ this->aspect_align = align;
+ this->aspect_clip = clip;
}
break;
@@ -223,8 +216,6 @@ void SPFeImage::set(unsigned int key, gchar const *value) {
* Receives update notifications.
*/
void SPFeImage::update(SPCtx *ctx, guint flags) {
- SPFeImage* object = this;
-
if (flags & (SP_OBJECT_MODIFIED_FLAG | SP_OBJECT_STYLE_MODIFIED_FLAG |
SP_OBJECT_VIEWPORT_MODIFIED_FLAG)) {
@@ -238,12 +229,10 @@ void SPFeImage::update(SPCtx *ctx, guint flags) {
* Writes its settings to an incoming repr object, if any.
*/
Inkscape::XML::Node* SPFeImage::write(Inkscape::XML::Document *doc, Inkscape::XML::Node *repr, guint flags) {
- SPFeImage* object = this;
-
/* TODO: Don't just clone, but create a new repr node and write all
* relevant values into it */
if (!repr) {
- repr = object->getRepr()->duplicate(doc);
+ repr = this->getRepr()->duplicate(doc);
}
SPFilterPrimitive::write(doc, repr, flags);
@@ -252,26 +241,22 @@ Inkscape::XML::Node* SPFeImage::write(Inkscape::XML::Document *doc, Inkscape::XM
}
void SPFeImage::build_renderer(Inkscape::Filters::Filter* filter) {
- SPFeImage* primitive = this;
-
- g_assert(primitive != NULL);
+ g_assert(this != NULL);
g_assert(filter != NULL);
- SPFeImage *sp_image = SP_FEIMAGE(primitive);
-
int primitive_n = filter->add_primitive(Inkscape::Filters::NR_FILTER_IMAGE);
Inkscape::Filters::FilterPrimitive *nr_primitive = filter->get_primitive(primitive_n);
Inkscape::Filters::FilterImage *nr_image = dynamic_cast<Inkscape::Filters::FilterImage*>(nr_primitive);
g_assert(nr_image != NULL);
- sp_filter_primitive_renderer_common(primitive, nr_primitive);
+ sp_filter_primitive_renderer_common(this, nr_primitive);
- nr_image->from_element = sp_image->from_element;
- nr_image->SVGElem = sp_image->SVGElem;
- nr_image->set_align( sp_image->aspect_align );
- nr_image->set_clip( sp_image->aspect_clip );
- nr_image->set_href(sp_image->href);
- nr_image->set_document(sp_image->document);
+ nr_image->from_element = this->from_element;
+ nr_image->SVGElem = this->SVGElem;
+ nr_image->set_align( this->aspect_align );
+ nr_image->set_clip( this->aspect_clip );
+ nr_image->set_href(this->href);
+ nr_image->set_document(this->document);
}
/*
diff --git a/src/filters/image.h b/src/filters/image.h
index 1554dc5e8..8bbab2614 100644
--- a/src/filters/image.h
+++ b/src/filters/image.h
@@ -39,6 +39,7 @@ public:
sigc::connection _image_modified_connection;
sigc::connection _href_modified_connection;
+protected:
virtual void build(SPDocument* doc, Inkscape::XML::Node* repr);
virtual void release();
diff --git a/src/filters/merge.cpp b/src/filters/merge.cpp
index 3b126f747..882ab36dd 100644
--- a/src/filters/merge.cpp
+++ b/src/filters/merge.cpp
@@ -60,11 +60,6 @@ void SPFeMerge::release() {
* Sets a specific value in the SPFeMerge.
*/
void SPFeMerge::set(unsigned int key, gchar const *value) {
- SPFeMerge* object = this;
-
- SPFeMerge *feMerge = SP_FEMERGE(object);
- (void)feMerge;
-
switch(key) {
/*DEAL WITH SETTING ATTRIBUTES HERE*/
default:
@@ -77,10 +72,8 @@ void SPFeMerge::set(unsigned int key, gchar const *value) {
* Receives update notifications.
*/
void SPFeMerge::update(SPCtx *ctx, guint flags) {
- SPFeMerge* object = this;
-
if (flags & SP_OBJECT_MODIFIED_FLAG) {
- object->parent->requestModified(SP_OBJECT_MODIFIED_FLAG);
+ this->parent->requestModified(SP_OBJECT_MODIFIED_FLAG);
}
SPFilterPrimitive::update(ctx, flags);
@@ -90,12 +83,10 @@ void SPFeMerge::update(SPCtx *ctx, guint flags) {
* Writes its settings to an incoming repr object, if any.
*/
Inkscape::XML::Node* SPFeMerge::write(Inkscape::XML::Document *doc, Inkscape::XML::Node *repr, guint flags) {
- SPFeMerge* object = this;
-
/* TODO: Don't just clone, but create a new repr node and write all
* relevant values into it. And child nodes, too! */
if (!repr) {
- repr = object->getRepr()->duplicate(doc);
+ repr = this->getRepr()->duplicate(doc);
}
@@ -105,29 +96,26 @@ Inkscape::XML::Node* SPFeMerge::write(Inkscape::XML::Document *doc, Inkscape::XM
}
void SPFeMerge::build_renderer(Inkscape::Filters::Filter* filter) {
- SPFeMerge* primitive = this;
-
- g_assert(primitive != NULL);
+ g_assert(this != NULL);
g_assert(filter != NULL);
- SPFeMerge *sp_merge = SP_FEMERGE(primitive);
- (void)sp_merge;
-
int primitive_n = filter->add_primitive(Inkscape::Filters::NR_FILTER_MERGE);
Inkscape::Filters::FilterPrimitive *nr_primitive = filter->get_primitive(primitive_n);
Inkscape::Filters::FilterMerge *nr_merge = dynamic_cast<Inkscape::Filters::FilterMerge*>(nr_primitive);
g_assert(nr_merge != NULL);
- sp_filter_primitive_renderer_common(primitive, nr_primitive);
+ sp_filter_primitive_renderer_common(this, nr_primitive);
- SPObject *input = primitive->children;
+ SPObject *input = this->children;
int in_nr = 0;
+
while (input) {
if (SP_IS_FEMERGENODE(input)) {
SPFeMergeNode *node = SP_FEMERGENODE(input);
nr_merge->set_input(in_nr, node->input);
in_nr++;
}
+
input = input->next;
}
}
diff --git a/src/filters/merge.h b/src/filters/merge.h
index a2034bc08..c7d2ce45b 100644
--- a/src/filters/merge.h
+++ b/src/filters/merge.h
@@ -20,6 +20,7 @@ public:
SPFeMerge();
virtual ~SPFeMerge();
+protected:
virtual void build(SPDocument* doc, Inkscape::XML::Node* repr);
virtual void release();
diff --git a/src/filters/morphology.cpp b/src/filters/morphology.cpp
index 14783584f..d3611b081 100644
--- a/src/filters/morphology.cpp
+++ b/src/filters/morphology.cpp
@@ -54,11 +54,9 @@ SPFeMorphology::~SPFeMorphology() {
void SPFeMorphology::build(SPDocument *document, Inkscape::XML::Node *repr) {
SPFilterPrimitive::build(document, repr);
- SPFeMorphology* object = this;
-
/*LOAD ATTRIBUTES FROM REPR HERE*/
- object->readAttr( "operator" );
- object->readAttr( "radius" );
+ this->readAttr( "operator" );
+ this->readAttr( "radius" );
}
/**
@@ -69,15 +67,23 @@ void SPFeMorphology::release() {
}
static Inkscape::Filters::FilterMorphologyOperator sp_feMorphology_read_operator(gchar const *value){
- if (!value) return Inkscape::Filters::MORPHOLOGY_OPERATOR_ERODE; //erode is default
+ if (!value) {
+ return Inkscape::Filters::MORPHOLOGY_OPERATOR_ERODE; //erode is default
+ }
+
switch(value[0]){
case 'e':
- if (strncmp(value, "erode", 5) == 0) return Inkscape::Filters::MORPHOLOGY_OPERATOR_ERODE;
+ if (strncmp(value, "erode", 5) == 0) {
+ return Inkscape::Filters::MORPHOLOGY_OPERATOR_ERODE;
+ }
break;
case 'd':
- if (strncmp(value, "dilate", 6) == 0) return Inkscape::Filters::MORPHOLOGY_OPERATOR_DILATE;
+ if (strncmp(value, "dilate", 6) == 0) {
+ return Inkscape::Filters::MORPHOLOGY_OPERATOR_DILATE;
+ }
break;
}
+
return Inkscape::Filters::MORPHOLOGY_OPERATOR_ERODE; //erode is default
}
@@ -85,27 +91,27 @@ static Inkscape::Filters::FilterMorphologyOperator sp_feMorphology_read_operator
* Sets a specific value in the SPFeMorphology.
*/
void SPFeMorphology::set(unsigned int key, gchar const *value) {
- SPFeMorphology* object = this;
-
- SPFeMorphology *feMorphology = SP_FEMORPHOLOGY(object);
- (void)feMorphology;
-
Inkscape::Filters::FilterMorphologyOperator read_operator;
+
switch(key) {
/*DEAL WITH SETTING ATTRIBUTES HERE*/
case SP_ATTR_OPERATOR:
read_operator = sp_feMorphology_read_operator(value);
- if (read_operator != feMorphology->Operator){
- feMorphology->Operator = read_operator;
- object->parent->requestModified(SP_OBJECT_MODIFIED_FLAG);
+
+ if (read_operator != this->Operator){
+ this->Operator = read_operator;
+ this->parent->requestModified(SP_OBJECT_MODIFIED_FLAG);
}
break;
case SP_ATTR_RADIUS:
- feMorphology->radius.set(value);
+ this->radius.set(value);
+
//From SVG spec: If <y-radius> is not provided, it defaults to <x-radius>.
- if (feMorphology->radius.optNumIsSet() == false)
- feMorphology->radius.setOptNumber(feMorphology->radius.getNumber());
- object->parent->requestModified(SP_OBJECT_MODIFIED_FLAG);
+ if (this->radius.optNumIsSet() == false) {
+ this->radius.setOptNumber(this->radius.getNumber());
+ }
+
+ this->parent->requestModified(SP_OBJECT_MODIFIED_FLAG);
break;
default:
SPFilterPrimitive::set(key, value);
@@ -118,8 +124,6 @@ void SPFeMorphology::set(unsigned int key, gchar const *value) {
* Receives update notifications.
*/
void SPFeMorphology::update(SPCtx *ctx, guint flags) {
- SPFeMorphology* object = this;
-
if (flags & (SP_OBJECT_MODIFIED_FLAG | SP_OBJECT_STYLE_MODIFIED_FLAG |
SP_OBJECT_VIEWPORT_MODIFIED_FLAG)) {
@@ -134,12 +138,10 @@ void SPFeMorphology::update(SPCtx *ctx, guint flags) {
* Writes its settings to an incoming repr object, if any.
*/
Inkscape::XML::Node* SPFeMorphology::write(Inkscape::XML::Document *doc, Inkscape::XML::Node *repr, guint flags) {
- SPFeMorphology* object = this;
-
/* TODO: Don't just clone, but create a new repr node and write all
* relevant values into it */
if (!repr) {
- repr = object->getRepr()->duplicate(doc);
+ repr = this->getRepr()->duplicate(doc);
}
SPFilterPrimitive::write(doc, repr, flags);
@@ -148,23 +150,19 @@ Inkscape::XML::Node* SPFeMorphology::write(Inkscape::XML::Document *doc, Inkscap
}
void SPFeMorphology::build_renderer(Inkscape::Filters::Filter* filter) {
- SPFeMorphology* primitive = this;
-
- g_assert(primitive != NULL);
+ g_assert(this != NULL);
g_assert(filter != NULL);
- SPFeMorphology *sp_morphology = SP_FEMORPHOLOGY(primitive);
-
int primitive_n = filter->add_primitive(Inkscape::Filters::NR_FILTER_MORPHOLOGY);
Inkscape::Filters::FilterPrimitive *nr_primitive = filter->get_primitive(primitive_n);
Inkscape::Filters::FilterMorphology *nr_morphology = dynamic_cast<Inkscape::Filters::FilterMorphology*>(nr_primitive);
g_assert(nr_morphology != NULL);
- sp_filter_primitive_renderer_common(primitive, nr_primitive);
+ sp_filter_primitive_renderer_common(this, nr_primitive);
- nr_morphology->set_operator(sp_morphology->Operator);
- nr_morphology->set_xradius( sp_morphology->radius.getNumber() );
- nr_morphology->set_yradius( sp_morphology->radius.getOptNumber() );
+ nr_morphology->set_operator(this->Operator);
+ nr_morphology->set_xradius( this->radius.getNumber() );
+ nr_morphology->set_yradius( this->radius.getOptNumber() );
}
/*
diff --git a/src/filters/morphology.h b/src/filters/morphology.h
index 97ab55751..786d444f3 100644
--- a/src/filters/morphology.h
+++ b/src/filters/morphology.h
@@ -27,6 +27,7 @@ public:
Inkscape::Filters::FilterMorphologyOperator Operator;
NumberOptNumber radius;
+protected:
virtual void build(SPDocument* doc, Inkscape::XML::Node* repr);
virtual void release();
diff --git a/src/filters/offset.cpp b/src/filters/offset.cpp
index 22582c167..234a1a964 100644
--- a/src/filters/offset.cpp
+++ b/src/filters/offset.cpp
@@ -49,12 +49,10 @@ SPFeOffset::~SPFeOffset() {
* sp-object-repr.cpp's repr_name_entries array.
*/
void SPFeOffset::build(SPDocument *document, Inkscape::XML::Node *repr) {
- SPFeOffset* object = this;
-
SPFilterPrimitive::build(document, repr);
- object->readAttr( "dx" );
- object->readAttr( "dy" );
+ this->readAttr( "dx" );
+ this->readAttr( "dy" );
}
/**
@@ -68,24 +66,23 @@ void SPFeOffset::release() {
* Sets a specific value in the SPFeOffset.
*/
void SPFeOffset::set(unsigned int key, gchar const *value) {
- SPFeOffset* object = this;
-
- SPFeOffset *feOffset = SP_FEOFFSET(object);
-
double read_num;
+
switch(key) {
case SP_ATTR_DX:
read_num = value ? helperfns_read_number(value) : 0;
- if (read_num != feOffset->dx) {
- feOffset->dx = read_num;
- object->parent->requestModified(SP_OBJECT_MODIFIED_FLAG);
+
+ if (read_num != this->dx) {
+ this->dx = read_num;
+ this->parent->requestModified(SP_OBJECT_MODIFIED_FLAG);
}
break;
case SP_ATTR_DY:
read_num = value ? helperfns_read_number(value) : 0;
- if (read_num != feOffset->dy) {
- feOffset->dy = read_num;
- object->parent->requestModified(SP_OBJECT_MODIFIED_FLAG);
+
+ if (read_num != this->dy) {
+ this->dy = read_num;
+ this->parent->requestModified(SP_OBJECT_MODIFIED_FLAG);
}
break;
@@ -100,11 +97,9 @@ void SPFeOffset::set(unsigned int key, gchar const *value) {
* Receives update notifications.
*/
void SPFeOffset::update(SPCtx *ctx, guint flags) {
- SPFeOffset* object = this;
-
if (flags & SP_OBJECT_MODIFIED_FLAG) {
- object->readAttr( "dx" );
- object->readAttr( "dy" );
+ this->readAttr( "dx" );
+ this->readAttr( "dy" );
}
SPFilterPrimitive::update(ctx, flags);
@@ -114,12 +109,10 @@ void SPFeOffset::update(SPCtx *ctx, guint flags) {
* Writes its settings to an incoming repr object, if any.
*/
Inkscape::XML::Node* SPFeOffset::write(Inkscape::XML::Document *doc, Inkscape::XML::Node *repr, guint flags) {
- SPFeOffset* object = this;
-
/* TODO: Don't just clone, but create a new repr node and write all
* relevant values into it */
if (!repr) {
- repr = object->getRepr()->duplicate(doc);
+ repr = this->getRepr()->duplicate(doc);
}
SPFilterPrimitive::write(doc, repr, flags);
@@ -128,22 +121,18 @@ Inkscape::XML::Node* SPFeOffset::write(Inkscape::XML::Document *doc, Inkscape::X
}
void SPFeOffset::build_renderer(Inkscape::Filters::Filter* filter) {
- SPFeOffset* primitive = this;
-
- g_assert(primitive != NULL);
+ g_assert(this != NULL);
g_assert(filter != NULL);
- SPFeOffset *sp_offset = SP_FEOFFSET(primitive);
-
int primitive_n = filter->add_primitive(Inkscape::Filters::NR_FILTER_OFFSET);
Inkscape::Filters::FilterPrimitive *nr_primitive = filter->get_primitive(primitive_n);
Inkscape::Filters::FilterOffset *nr_offset = dynamic_cast<Inkscape::Filters::FilterOffset*>(nr_primitive);
g_assert(nr_offset != NULL);
- sp_filter_primitive_renderer_common(primitive, nr_primitive);
+ sp_filter_primitive_renderer_common(this, nr_primitive);
- nr_offset->set_dx(sp_offset->dx);
- nr_offset->set_dy(sp_offset->dy);
+ nr_offset->set_dx(this->dx);
+ nr_offset->set_dy(this->dy);
}
diff --git a/src/filters/offset.h b/src/filters/offset.h
index 0f0ee63ee..10bed3338 100644
--- a/src/filters/offset.h
+++ b/src/filters/offset.h
@@ -24,6 +24,7 @@ public:
double dx, dy;
+protected:
virtual void build(SPDocument* doc, Inkscape::XML::Node* repr);
virtual void release();
diff --git a/src/filters/specularlighting.cpp b/src/filters/specularlighting.cpp
index bb291f2a9..6cdd5d9ba 100644
--- a/src/filters/specularlighting.cpp
+++ b/src/filters/specularlighting.cpp
@@ -71,16 +71,14 @@ SPFeSpecularLighting::~SPFeSpecularLighting() {
* sp-object-repr.cpp's repr_name_entries array.
*/
void SPFeSpecularLighting::build(SPDocument *document, Inkscape::XML::Node *repr) {
- SPFeSpecularLighting* object = this;
-
SPFilterPrimitive::build(document, repr);
/*LOAD ATTRIBUTES FROM REPR HERE*/
- object->readAttr( "surfaceScale" );
- object->readAttr( "specularConstant" );
- object->readAttr( "specularExponent" );
- object->readAttr( "kernelUnitLength" );
- object->readAttr( "lighting-color" );
+ this->readAttr( "surfaceScale" );
+ this->readAttr( "specularConstant" );
+ this->readAttr( "specularExponent" );
+ this->readAttr( "kernelUnitLength" );
+ this->readAttr( "lighting-color" );
}
/**
@@ -94,108 +92,106 @@ void SPFeSpecularLighting::release() {
* Sets a specific value in the SPFeSpecularLighting.
*/
void SPFeSpecularLighting::set(unsigned int key, gchar const *value) {
- SPFeSpecularLighting* object = this;
-
- SPFeSpecularLighting *feSpecularLighting = SP_FESPECULARLIGHTING(object);
gchar const *cend_ptr = NULL;
gchar *end_ptr = NULL;
+
switch(key) {
/*DEAL WITH SETTING ATTRIBUTES HERE*/
//TODO test forbidden values
case SP_ATTR_SURFACESCALE:
end_ptr = NULL;
if (value) {
- feSpecularLighting->surfaceScale = g_ascii_strtod(value, &end_ptr);
+ this->surfaceScale = g_ascii_strtod(value, &end_ptr);
if (end_ptr) {
- feSpecularLighting->surfaceScale_set = TRUE;
+ this->surfaceScale_set = TRUE;
} else {
- g_warning("feSpecularLighting: surfaceScale should be a number ... defaulting to 1");
+ g_warning("this: surfaceScale should be a number ... defaulting to 1");
}
}
//if the attribute is not set or has an unreadable value
if (!value || !end_ptr) {
- feSpecularLighting->surfaceScale = 1;
- feSpecularLighting->surfaceScale_set = FALSE;
+ this->surfaceScale = 1;
+ this->surfaceScale_set = FALSE;
}
- if (feSpecularLighting->renderer) {
- feSpecularLighting->renderer->surfaceScale = feSpecularLighting->surfaceScale;
+ if (this->renderer) {
+ this->renderer->surfaceScale = this->surfaceScale;
}
- object->parent->requestModified(SP_OBJECT_MODIFIED_FLAG);
+ this->parent->requestModified(SP_OBJECT_MODIFIED_FLAG);
break;
case SP_ATTR_SPECULARCONSTANT:
end_ptr = NULL;
if (value) {
- feSpecularLighting->specularConstant = g_ascii_strtod(value, &end_ptr);
- if (end_ptr && feSpecularLighting->specularConstant >= 0) {
- feSpecularLighting->specularConstant_set = TRUE;
+ this->specularConstant = g_ascii_strtod(value, &end_ptr);
+ if (end_ptr && this->specularConstant >= 0) {
+ this->specularConstant_set = TRUE;
} else {
end_ptr = NULL;
- g_warning("feSpecularLighting: specularConstant should be a positive number ... defaulting to 1");
+ g_warning("this: specularConstant should be a positive number ... defaulting to 1");
}
}
if (!value || !end_ptr) {
- feSpecularLighting->specularConstant = 1;
- feSpecularLighting->specularConstant_set = FALSE;
+ this->specularConstant = 1;
+ this->specularConstant_set = FALSE;
}
- if (feSpecularLighting->renderer) {
- feSpecularLighting->renderer->specularConstant = feSpecularLighting->specularConstant;
+ if (this->renderer) {
+ this->renderer->specularConstant = this->specularConstant;
}
- object->parent->requestModified(SP_OBJECT_MODIFIED_FLAG);
+ this->parent->requestModified(SP_OBJECT_MODIFIED_FLAG);
break;
case SP_ATTR_SPECULAREXPONENT:
end_ptr = NULL;
if (value) {
- feSpecularLighting->specularExponent = g_ascii_strtod(value, &end_ptr);
- if (feSpecularLighting->specularExponent >= 1 && feSpecularLighting->specularExponent <= 128) {
- feSpecularLighting->specularExponent_set = TRUE;
+ this->specularExponent = g_ascii_strtod(value, &end_ptr);
+ if (this->specularExponent >= 1 && this->specularExponent <= 128) {
+ this->specularExponent_set = TRUE;
} else {
end_ptr = NULL;
- g_warning("feSpecularLighting: specularExponent should be a number in range [1, 128] ... defaulting to 1");
+ g_warning("this: specularExponent should be a number in range [1, 128] ... defaulting to 1");
}
}
if (!value || !end_ptr) {
- feSpecularLighting->specularExponent = 1;
- feSpecularLighting->specularExponent_set = FALSE;
+ this->specularExponent = 1;
+ this->specularExponent_set = FALSE;
}
- if (feSpecularLighting->renderer) {
- feSpecularLighting->renderer->specularExponent = feSpecularLighting->specularExponent;
+ if (this->renderer) {
+ this->renderer->specularExponent = this->specularExponent;
}
- object->parent->requestModified(SP_OBJECT_MODIFIED_FLAG);
+ this->parent->requestModified(SP_OBJECT_MODIFIED_FLAG);
break;
case SP_ATTR_KERNELUNITLENGTH:
//TODO kernelUnit
- //feSpecularLighting->kernelUnitLength.set(value);
+ //this->kernelUnitLength.set(value);
/*TODOif (feSpecularLighting->renderer) {
feSpecularLighting->renderer->surfaceScale = feSpecularLighting->renderer;
}
*/
- object->parent->requestModified(SP_OBJECT_MODIFIED_FLAG);
+ this->parent->requestModified(SP_OBJECT_MODIFIED_FLAG);
break;
case SP_PROP_LIGHTING_COLOR:
cend_ptr = NULL;
- feSpecularLighting->lighting_color = sp_svg_read_color(value, &cend_ptr, 0xffffffff);
+ this->lighting_color = sp_svg_read_color(value, &cend_ptr, 0xffffffff);
//if a value was read
if (cend_ptr) {
while (g_ascii_isspace(*cend_ptr)) {
++cend_ptr;
}
if (strneq(cend_ptr, "icc-color(", 10)) {
- if (!feSpecularLighting->icc) feSpecularLighting->icc = new SVGICCColor();
- if ( ! sp_svg_read_icc_color( cend_ptr, feSpecularLighting->icc ) ) {
- delete feSpecularLighting->icc;
- feSpecularLighting->icc = NULL;
+ if (!this->icc) this->icc = new SVGICCColor();
+ if ( ! sp_svg_read_icc_color( cend_ptr, this->icc ) ) {
+ delete this->icc;
+ this->icc = NULL;
}
}
- feSpecularLighting->lighting_color_set = TRUE;
+ this->lighting_color_set = TRUE;
} else {
//lighting_color already contains the default value
- feSpecularLighting->lighting_color_set = FALSE;
+ this->lighting_color_set = FALSE;
}
- if (feSpecularLighting->renderer) {
- feSpecularLighting->renderer->lighting_color = feSpecularLighting->lighting_color;
+ if (this->renderer) {
+ this->renderer->lighting_color = this->lighting_color;
}
- object->parent->requestModified(SP_OBJECT_MODIFIED_FLAG);
+ this->parent->requestModified(SP_OBJECT_MODIFIED_FLAG);
break;
default:
SPFilterPrimitive::set(key, value);
@@ -207,14 +203,12 @@ void SPFeSpecularLighting::set(unsigned int key, gchar const *value) {
* Receives update notifications.
*/
void SPFeSpecularLighting::update(SPCtx *ctx, guint flags) {
- SPFeSpecularLighting* object = this;
-
if (flags & (SP_OBJECT_MODIFIED_FLAG)) {
- object->readAttr( "surfaceScale" );
- object->readAttr( "specularConstant" );
- object->readAttr( "specularExponent" );
- object->readAttr( "kernelUnitLength" );
- object->readAttr( "lighting-color" );
+ this->readAttr( "surfaceScale" );
+ this->readAttr( "specularConstant" );
+ this->readAttr( "specularExponent" );
+ this->readAttr( "kernelUnitLength" );
+ this->readAttr( "lighting-color" );
}
SPFilterPrimitive::update(ctx, flags);
@@ -224,29 +218,32 @@ void SPFeSpecularLighting::update(SPCtx *ctx, guint flags) {
* Writes its settings to an incoming repr object, if any.
*/
Inkscape::XML::Node* SPFeSpecularLighting::write(Inkscape::XML::Document *doc, Inkscape::XML::Node *repr, guint flags) {
- SPFeSpecularLighting* object = this;
-
- SPFeSpecularLighting *fespecularlighting = SP_FESPECULARLIGHTING(object);
-
/* TODO: Don't just clone, but create a new repr node and write all
* relevant values _and children_ into it */
if (!repr) {
- repr = object->getRepr()->duplicate(doc);
+ repr = this->getRepr()->duplicate(doc);
//repr = doc->createElement("svg:feSpecularLighting");
}
- if (fespecularlighting->surfaceScale_set)
- sp_repr_set_css_double(repr, "surfaceScale", fespecularlighting->surfaceScale);
- if (fespecularlighting->specularConstant_set)
- sp_repr_set_css_double(repr, "specularConstant", fespecularlighting->specularConstant);
- if (fespecularlighting->specularExponent_set)
- sp_repr_set_css_double(repr, "specularExponent", fespecularlighting->specularExponent);
- /*TODO kernelUnits */
- if (fespecularlighting->lighting_color_set) {
+ if (this->surfaceScale_set) {
+ sp_repr_set_css_double(repr, "surfaceScale", this->surfaceScale);
+ }
+
+ if (this->specularConstant_set) {
+ sp_repr_set_css_double(repr, "specularConstant", this->specularConstant);
+ }
+
+ if (this->specularExponent_set) {
+ sp_repr_set_css_double(repr, "specularExponent", this->specularExponent);
+ }
+
+ /*TODO kernelUnits */
+ if (this->lighting_color_set) {
gchar c[64];
- sp_svg_write_color(c, sizeof(c), fespecularlighting->lighting_color);
+ sp_svg_write_color(c, sizeof(c), this->lighting_color);
repr->setAttribute("lighting-color", c);
}
+
SPFilterPrimitive::write(doc, repr, flags);
return repr;
@@ -256,94 +253,84 @@ Inkscape::XML::Node* SPFeSpecularLighting::write(Inkscape::XML::Document *doc, I
* Callback for child_added event.
*/
void SPFeSpecularLighting::child_added(Inkscape::XML::Node *child, Inkscape::XML::Node *ref) {
- SPFeSpecularLighting* object = this;
-
- SPFeSpecularLighting *f = SP_FESPECULARLIGHTING(object);
-
SPFilterPrimitive::child_added(child, ref);
- sp_feSpecularLighting_children_modified(f);
- object->parent->requestModified(SP_OBJECT_MODIFIED_FLAG);
+ sp_feSpecularLighting_children_modified(this);
+ this->parent->requestModified(SP_OBJECT_MODIFIED_FLAG);
}
/**
* Callback for remove_child event.
*/
void SPFeSpecularLighting::remove_child(Inkscape::XML::Node *child) {
- SPFeSpecularLighting* object = this;
-
- SPFeSpecularLighting *f = SP_FESPECULARLIGHTING(object);
-
SPFilterPrimitive::remove_child(child);
- sp_feSpecularLighting_children_modified(f);
- object->parent->requestModified(SP_OBJECT_MODIFIED_FLAG);
+ sp_feSpecularLighting_children_modified(this);
+ this->parent->requestModified(SP_OBJECT_MODIFIED_FLAG);
}
void SPFeSpecularLighting::order_changed(Inkscape::XML::Node *child, Inkscape::XML::Node *old_ref, Inkscape::XML::Node *new_ref) {
- SPFeSpecularLighting* object = this;
-
- SPFeSpecularLighting *f = SP_FESPECULARLIGHTING(object);
SPFilterPrimitive::order_changed(child, old_ref, new_ref);
- sp_feSpecularLighting_children_modified(f);
- object->parent->requestModified(SP_OBJECT_MODIFIED_FLAG);
+ sp_feSpecularLighting_children_modified(this);
+ this->parent->requestModified(SP_OBJECT_MODIFIED_FLAG);
}
-static void sp_feSpecularLighting_children_modified(SPFeSpecularLighting *sp_specularlighting)
-{
- if (sp_specularlighting->renderer) {
+static void sp_feSpecularLighting_children_modified(SPFeSpecularLighting *sp_specularlighting) {
+ if (sp_specularlighting->renderer) {
sp_specularlighting->renderer->light_type = Inkscape::Filters::NO_LIGHT;
+
if (SP_IS_FEDISTANTLIGHT(sp_specularlighting->children)) {
sp_specularlighting->renderer->light_type = Inkscape::Filters::DISTANT_LIGHT;
sp_specularlighting->renderer->light.distant = SP_FEDISTANTLIGHT(sp_specularlighting->children);
}
+
if (SP_IS_FEPOINTLIGHT(sp_specularlighting->children)) {
sp_specularlighting->renderer->light_type = Inkscape::Filters::POINT_LIGHT;
sp_specularlighting->renderer->light.point = SP_FEPOINTLIGHT(sp_specularlighting->children);
}
+
if (SP_IS_FESPOTLIGHT(sp_specularlighting->children)) {
sp_specularlighting->renderer->light_type = Inkscape::Filters::SPOT_LIGHT;
sp_specularlighting->renderer->light.spot = SP_FESPOTLIGHT(sp_specularlighting->children);
}
- }
+ }
}
void SPFeSpecularLighting::build_renderer(Inkscape::Filters::Filter* filter) {
- SPFeSpecularLighting* primitive = this;
-
- g_assert(primitive != NULL);
+ g_assert(this != NULL);
g_assert(filter != NULL);
- SPFeSpecularLighting *sp_specularlighting = SP_FESPECULARLIGHTING(primitive);
-
int primitive_n = filter->add_primitive(Inkscape::Filters::NR_FILTER_SPECULARLIGHTING);
Inkscape::Filters::FilterPrimitive *nr_primitive = filter->get_primitive(primitive_n);
Inkscape::Filters::FilterSpecularLighting *nr_specularlighting = dynamic_cast<Inkscape::Filters::FilterSpecularLighting*>(nr_primitive);
g_assert(nr_specularlighting != NULL);
- sp_specularlighting->renderer = nr_specularlighting;
- sp_filter_primitive_renderer_common(primitive, nr_primitive);
+ this->renderer = nr_specularlighting;
+ sp_filter_primitive_renderer_common(this, nr_primitive);
- nr_specularlighting->specularConstant = sp_specularlighting->specularConstant;
- nr_specularlighting->specularExponent = sp_specularlighting->specularExponent;
- nr_specularlighting->surfaceScale = sp_specularlighting->surfaceScale;
- nr_specularlighting->lighting_color = sp_specularlighting->lighting_color;
- nr_specularlighting->set_icc(sp_specularlighting->icc);
+ nr_specularlighting->specularConstant = this->specularConstant;
+ nr_specularlighting->specularExponent = this->specularExponent;
+ nr_specularlighting->surfaceScale = this->surfaceScale;
+ nr_specularlighting->lighting_color = this->lighting_color;
+ nr_specularlighting->set_icc(this->icc);
//We assume there is at most one child
nr_specularlighting->light_type = Inkscape::Filters::NO_LIGHT;
- if (SP_IS_FEDISTANTLIGHT(primitive->children)) {
+
+ if (SP_IS_FEDISTANTLIGHT(this->children)) {
nr_specularlighting->light_type = Inkscape::Filters::DISTANT_LIGHT;
- nr_specularlighting->light.distant = SP_FEDISTANTLIGHT(primitive->children);
+ nr_specularlighting->light.distant = SP_FEDISTANTLIGHT(this->children);
}
- if (SP_IS_FEPOINTLIGHT(primitive->children)) {
+
+ if (SP_IS_FEPOINTLIGHT(this->children)) {
nr_specularlighting->light_type = Inkscape::Filters::POINT_LIGHT;
- nr_specularlighting->light.point = SP_FEPOINTLIGHT(primitive->children);
+ nr_specularlighting->light.point = SP_FEPOINTLIGHT(this->children);
}
- if (SP_IS_FESPOTLIGHT(primitive->children)) {
+
+ if (SP_IS_FESPOTLIGHT(this->children)) {
nr_specularlighting->light_type = Inkscape::Filters::SPOT_LIGHT;
- nr_specularlighting->light.spot = SP_FESPOTLIGHT(primitive->children);
+ nr_specularlighting->light.spot = SP_FESPOTLIGHT(this->children);
}
//nr_offset->set_dx(sp_offset->dx);
diff --git a/src/filters/specularlighting.h b/src/filters/specularlighting.h
index 2e6cde922..081d0e0ed 100644
--- a/src/filters/specularlighting.h
+++ b/src/filters/specularlighting.h
@@ -46,6 +46,7 @@ public:
Inkscape::Filters::FilterSpecularLighting *renderer;
+protected:
virtual void build(SPDocument* doc, Inkscape::XML::Node* repr);
virtual void release();
diff --git a/src/filters/tile.cpp b/src/filters/tile.cpp
index 4bb93603c..19e96f47d 100644
--- a/src/filters/tile.cpp
+++ b/src/filters/tile.cpp
@@ -58,11 +58,6 @@ void SPFeTile::release() {
* Sets a specific value in the SPFeTile.
*/
void SPFeTile::set(unsigned int key, gchar const *value) {
- SPFeTile* object = this;
-
- SPFeTile *feTile = SP_FETILE(object);
- (void)feTile;
-
switch(key) {
/*DEAL WITH SETTING ATTRIBUTES HERE*/
default:
@@ -75,8 +70,6 @@ void SPFeTile::set(unsigned int key, gchar const *value) {
* Receives update notifications.
*/
void SPFeTile::update(SPCtx *ctx, guint flags) {
- SPFeTile* object = this;
-
if (flags & (SP_OBJECT_MODIFIED_FLAG | SP_OBJECT_STYLE_MODIFIED_FLAG |
SP_OBJECT_VIEWPORT_MODIFIED_FLAG)) {
@@ -91,12 +84,10 @@ void SPFeTile::update(SPCtx *ctx, guint flags) {
* Writes its settings to an incoming repr object, if any.
*/
Inkscape::XML::Node* SPFeTile::write(Inkscape::XML::Document *doc, Inkscape::XML::Node *repr, guint flags) {
- SPFeTile* object = this;
-
/* TODO: Don't just clone, but create a new repr node and write all
* relevant values into it */
if (!repr) {
- repr = object->getRepr()->duplicate(doc);
+ repr = this->getRepr()->duplicate(doc);
}
SPFilterPrimitive::write(doc, repr, flags);
@@ -105,20 +96,15 @@ Inkscape::XML::Node* SPFeTile::write(Inkscape::XML::Document *doc, Inkscape::XML
}
void SPFeTile::build_renderer(Inkscape::Filters::Filter* filter) {
- SPFeTile* primitive = this;
-
- g_assert(primitive != NULL);
+ g_assert(this != NULL);
g_assert(filter != NULL);
- SPFeTile *sp_tile = SP_FETILE(primitive);
- (void)sp_tile;
-
int primitive_n = filter->add_primitive(Inkscape::Filters::NR_FILTER_TILE);
Inkscape::Filters::FilterPrimitive *nr_primitive = filter->get_primitive(primitive_n);
Inkscape::Filters::FilterTile *nr_tile = dynamic_cast<Inkscape::Filters::FilterTile*>(nr_primitive);
g_assert(nr_tile != NULL);
- sp_filter_primitive_renderer_common(primitive, nr_primitive);
+ sp_filter_primitive_renderer_common(this, nr_primitive);
}
/*
diff --git a/src/filters/tile.h b/src/filters/tile.h
index 35266c611..184858a3d 100644
--- a/src/filters/tile.h
+++ b/src/filters/tile.h
@@ -23,6 +23,7 @@ public:
SPFeTile();
virtual ~SPFeTile();
+protected:
virtual void build(SPDocument* doc, Inkscape::XML::Node* repr);
virtual void release();
diff --git a/src/filters/turbulence.cpp b/src/filters/turbulence.cpp
index caf93c3c0..d33667a8c 100644
--- a/src/filters/turbulence.cpp
+++ b/src/filters/turbulence.cpp
@@ -56,16 +56,14 @@ SPFeTurbulence::~SPFeTurbulence() {
* sp-object-repr.cpp's repr_name_entries array.
*/
void SPFeTurbulence::build(SPDocument *document, Inkscape::XML::Node *repr) {
- SPFeTurbulence* object = this;
-
SPFilterPrimitive::build(document, repr);
/*LOAD ATTRIBUTES FROM REPR HERE*/
- object->readAttr( "baseFrequency" );
- object->readAttr( "numOctaves" );
- object->readAttr( "seed" );
- object->readAttr( "stitchTiles" );
- object->readAttr( "type" );
+ this->readAttr( "baseFrequency" );
+ this->readAttr( "numOctaves" );
+ this->readAttr( "seed" );
+ this->readAttr( "stitchTiles" );
+ this->readAttr( "type" );
}
/**
@@ -76,28 +74,44 @@ void SPFeTurbulence::release() {
}
static bool sp_feTurbulence_read_stitchTiles(gchar const *value){
- if (!value) return false; // 'noStitch' is default
+ if (!value) {
+ return false; // 'noStitch' is default
+ }
+
switch(value[0]){
case 's':
- if (strncmp(value, "stitch", 6) == 0) return true;
+ if (strncmp(value, "stitch", 6) == 0) {
+ return true;
+ }
break;
case 'n':
- if (strncmp(value, "noStitch", 8) == 0) return false;
+ if (strncmp(value, "noStitch", 8) == 0) {
+ return false;
+ }
break;
}
+
return false; // 'noStitch' is default
}
static Inkscape::Filters::FilterTurbulenceType sp_feTurbulence_read_type(gchar const *value){
- if (!value) return Inkscape::Filters::TURBULENCE_TURBULENCE; // 'turbulence' is default
+ if (!value) {
+ return Inkscape::Filters::TURBULENCE_TURBULENCE; // 'turbulence' is default
+ }
+
switch(value[0]){
case 'f':
- if (strncmp(value, "fractalNoise", 12) == 0) return Inkscape::Filters::TURBULENCE_FRACTALNOISE;
+ if (strncmp(value, "fractalNoise", 12) == 0) {
+ return Inkscape::Filters::TURBULENCE_FRACTALNOISE;
+ }
break;
case 't':
- if (strncmp(value, "turbulence", 10) == 0) return Inkscape::Filters::TURBULENCE_TURBULENCE;
+ if (strncmp(value, "turbulence", 10) == 0) {
+ return Inkscape::Filters::TURBULENCE_TURBULENCE;
+ }
break;
}
+
return Inkscape::Filters::TURBULENCE_TURBULENCE; // 'turbulence' is default
}
@@ -105,11 +119,6 @@ static Inkscape::Filters::FilterTurbulenceType sp_feTurbulence_read_type(gchar c
* Sets a specific value in the SPFeTurbulence.
*/
void SPFeTurbulence::set(unsigned int key, gchar const *value) {
- SPFeTurbulence* object = this;
-
- SPFeTurbulence *feTurbulence = SP_FETURBULENCE(object);
- (void)feTurbulence;
-
int read_int;
double read_num;
bool read_bool;
@@ -117,45 +126,54 @@ void SPFeTurbulence::set(unsigned int key, gchar const *value) {
switch(key) {
/*DEAL WITH SETTING ATTRIBUTES HERE*/
-
case SP_ATTR_BASEFREQUENCY:
- feTurbulence->baseFrequency.set(value);
- //From SVG spec: If two <number>s are provided, the first number represents a base frequency in the X direction and the second value represents a base frequency in the Y direction. If one number is provided, then that value is used for both X and Y.
- if (feTurbulence->baseFrequency.optNumIsSet() == false)
- feTurbulence->baseFrequency.setOptNumber(feTurbulence->baseFrequency.getNumber());
- feTurbulence->updated = false;
- object->parent->requestModified(SP_OBJECT_MODIFIED_FLAG);
+ this->baseFrequency.set(value);
+
+ // From SVG spec: If two <number>s are provided, the first number represents
+ // a base frequency in the X direction and the second value represents a base
+ // frequency in the Y direction. If one number is provided, then that value is
+ // used for both X and Y.
+ if (this->baseFrequency.optNumIsSet() == false) {
+ this->baseFrequency.setOptNumber(this->baseFrequency.getNumber());
+ }
+
+ this->updated = false;
+ this->parent->requestModified(SP_OBJECT_MODIFIED_FLAG);
break;
case SP_ATTR_NUMOCTAVES:
read_int = value ? (int)floor(helperfns_read_number(value)) : 1;
- if (read_int != feTurbulence->numOctaves){
- feTurbulence->numOctaves = read_int;
- feTurbulence->updated = false;
- object->parent->requestModified(SP_OBJECT_MODIFIED_FLAG);
+
+ if (read_int != this->numOctaves){
+ this->numOctaves = read_int;
+ this->updated = false;
+ this->parent->requestModified(SP_OBJECT_MODIFIED_FLAG);
}
break;
case SP_ATTR_SEED:
read_num = value ? helperfns_read_number(value) : 0;
- if (read_num != feTurbulence->seed){
- feTurbulence->seed = read_num;
- feTurbulence->updated = false;
- object->parent->requestModified(SP_OBJECT_MODIFIED_FLAG);
+
+ if (read_num != this->seed){
+ this->seed = read_num;
+ this->updated = false;
+ this->parent->requestModified(SP_OBJECT_MODIFIED_FLAG);
}
break;
case SP_ATTR_STITCHTILES:
read_bool = sp_feTurbulence_read_stitchTiles(value);
- if (read_bool != feTurbulence->stitchTiles){
- feTurbulence->stitchTiles = read_bool;
- feTurbulence->updated = false;
- object->parent->requestModified(SP_OBJECT_MODIFIED_FLAG);
+
+ if (read_bool != this->stitchTiles){
+ this->stitchTiles = read_bool;
+ this->updated = false;
+ this->parent->requestModified(SP_OBJECT_MODIFIED_FLAG);
}
break;
case SP_ATTR_TYPE:
read_type = sp_feTurbulence_read_type(value);
- if (read_type != feTurbulence->type){
- feTurbulence->type = read_type;
- feTurbulence->updated = false;
- object->parent->requestModified(SP_OBJECT_MODIFIED_FLAG);
+
+ if (read_type != this->type){
+ this->type = read_type;
+ this->updated = false;
+ this->parent->requestModified(SP_OBJECT_MODIFIED_FLAG);
}
break;
default:
@@ -168,8 +186,6 @@ void SPFeTurbulence::set(unsigned int key, gchar const *value) {
* Receives update notifications.
*/
void SPFeTurbulence::update(SPCtx *ctx, guint flags) {
- SPFeTurbulence* object = this;
-
if (flags & (SP_OBJECT_MODIFIED_FLAG | SP_OBJECT_STYLE_MODIFIED_FLAG |
SP_OBJECT_VIEWPORT_MODIFIED_FLAG)) {
@@ -184,12 +200,10 @@ void SPFeTurbulence::update(SPCtx *ctx, guint flags) {
* Writes its settings to an incoming repr object, if any.
*/
Inkscape::XML::Node* SPFeTurbulence::write(Inkscape::XML::Document *doc, Inkscape::XML::Node *repr, guint flags) {
- SPFeTurbulence* object = this;
-
/* TODO: Don't just clone, but create a new repr node and write all
* relevant values into it */
if (!repr) {
- repr = object->getRepr()->duplicate(doc);
+ repr = this->getRepr()->duplicate(doc);
}
SPFilterPrimitive::write(doc, repr, flags);
@@ -201,27 +215,23 @@ Inkscape::XML::Node* SPFeTurbulence::write(Inkscape::XML::Document *doc, Inkscap
}
void SPFeTurbulence::build_renderer(Inkscape::Filters::Filter* filter) {
- SPFeTurbulence* primitive = this;
-
- g_assert(primitive != NULL);
+ g_assert(this != NULL);
g_assert(filter != NULL);
- SPFeTurbulence *sp_turbulence = SP_FETURBULENCE(primitive);
-
int primitive_n = filter->add_primitive(Inkscape::Filters::NR_FILTER_TURBULENCE);
Inkscape::Filters::FilterPrimitive *nr_primitive = filter->get_primitive(primitive_n);
Inkscape::Filters::FilterTurbulence *nr_turbulence = dynamic_cast<Inkscape::Filters::FilterTurbulence*>(nr_primitive);
g_assert(nr_turbulence != NULL);
- sp_filter_primitive_renderer_common(primitive, nr_primitive);
+ sp_filter_primitive_renderer_common(this, nr_primitive);
- nr_turbulence->set_baseFrequency(0, sp_turbulence->baseFrequency.getNumber());
- nr_turbulence->set_baseFrequency(1, sp_turbulence->baseFrequency.getOptNumber());
- nr_turbulence->set_numOctaves(sp_turbulence->numOctaves);
- nr_turbulence->set_seed(sp_turbulence->seed);
- nr_turbulence->set_stitchTiles(sp_turbulence->stitchTiles);
- nr_turbulence->set_type(sp_turbulence->type);
- nr_turbulence->set_updated(sp_turbulence->updated);
+ nr_turbulence->set_baseFrequency(0, this->baseFrequency.getNumber());
+ nr_turbulence->set_baseFrequency(1, this->baseFrequency.getOptNumber());
+ nr_turbulence->set_numOctaves(this->numOctaves);
+ nr_turbulence->set_seed(this->seed);
+ nr_turbulence->set_stitchTiles(this->stitchTiles);
+ nr_turbulence->set_type(this->type);
+ nr_turbulence->set_updated(this->updated);
}
/*
diff --git a/src/filters/turbulence.h b/src/filters/turbulence.h
index 4c61665fe..d6046036a 100644
--- a/src/filters/turbulence.h
+++ b/src/filters/turbulence.h
@@ -36,6 +36,7 @@ public:
SVGLength x, y, height, width;
bool updated;
+protected:
virtual void build(SPDocument* doc, Inkscape::XML::Node* repr);
virtual void release();
diff --git a/src/sp-flowdiv.cpp b/src/sp-flowdiv.cpp
index 13233748d..867e68441 100644
--- a/src/sp-flowdiv.cpp
+++ b/src/sp-flowdiv.cpp
@@ -6,10 +6,6 @@
#endif
#include "xml/repr.h"
-//#include "svg/svg.h"
-
-//#include "style.h"
-
#include "sp-flowdiv.h"
#include "sp-string.h"
#include "document.h"
@@ -55,7 +51,6 @@ void SPFlowdiv::release() {
}
void SPFlowdiv::update(SPCtx *ctx, unsigned int flags) {
- SPFlowdiv* object = this;
SPItemCtx *ictx = reinterpret_cast<SPItemCtx *>(ctx);
SPItemCtx cctx = *ictx;
@@ -64,17 +59,21 @@ void SPFlowdiv::update(SPCtx *ctx, unsigned int flags) {
if (flags & SP_OBJECT_MODIFIED_FLAG) {
flags |= SP_OBJECT_PARENT_MODIFIED_FLAG;
}
+
flags &= SP_OBJECT_MODIFIED_CASCADE;
GSList* l = NULL;
- for (SPObject *child = object->firstChild() ; child ; child = child->getNext() ) {
+ for (SPObject *child = this->firstChild() ; child ; child = child->getNext() ) {
sp_object_ref(child);
l = g_slist_prepend(l, child);
}
+
l = g_slist_reverse(l);
+
while (l) {
SPObject *child = SP_OBJECT(l->data);
l = g_slist_remove(l, child);
+
if (flags || (child->uflags & (SP_OBJECT_MODIFIED_FLAG | SP_OBJECT_CHILD_MODIFIED_FLAG))) {
if (SP_IS_ITEM(child)) {
SPItem const &chi = *SP_ITEM(child);
@@ -85,41 +84,43 @@ void SPFlowdiv::update(SPCtx *ctx, unsigned int flags) {
child->updateDisplay(ctx, flags);
}
}
+
sp_object_unref(child);
}
}
void SPFlowdiv::modified(unsigned int flags) {
- SPFlowdiv* object = this;
-
SPItem::modified(flags);
if (flags & SP_OBJECT_MODIFIED_FLAG) {
flags |= SP_OBJECT_PARENT_MODIFIED_FLAG;
}
+
flags &= SP_OBJECT_MODIFIED_CASCADE;
GSList *l = NULL;
- for ( SPObject *child = object->firstChild() ; child ; child = child->getNext() ) {
+ for ( SPObject *child = this->firstChild() ; child ; child = child->getNext() ) {
sp_object_ref(child);
l = g_slist_prepend(l, child);
}
+
l = g_slist_reverse (l);
+
while (l) {
SPObject *child = SP_OBJECT(l->data);
l = g_slist_remove(l, child);
+
if (flags || (child->mflags & (SP_OBJECT_MODIFIED_FLAG | SP_OBJECT_CHILD_MODIFIED_FLAG))) {
child->emitModified(flags);
}
+
sp_object_unref(child);
}
}
void SPFlowdiv::build(SPDocument *doc, Inkscape::XML::Node *repr) {
- SPFlowdiv* object = this;
-
- object->_requireSVGVersion(Inkscape::Version(1, 2));
+ this->_requireSVGVersion(Inkscape::Version(1, 2));
SPItem::build(doc, repr);
}
@@ -130,15 +131,16 @@ void SPFlowdiv::set(unsigned int key, const gchar* value) {
Inkscape::XML::Node* SPFlowdiv::write(Inkscape::XML::Document *xml_doc, Inkscape::XML::Node *repr, guint flags) {
- SPFlowdiv* object = this;
-
if ( flags & SP_OBJECT_WRITE_BUILD ) {
if ( repr == NULL ) {
repr = xml_doc->createElement("svg:flowDiv");
}
+
GSList *l = NULL;
- for (SPObject* child = object->firstChild() ; child ; child = child->getNext() ) {
+
+ for (SPObject* child = this->firstChild() ; child ; child = child->getNext() ) {
Inkscape::XML::Node* c_repr = NULL;
+
if ( SP_IS_FLOWTSPAN (child) ) {
c_repr = child->updateRepr(xml_doc, NULL, flags);
} else if ( SP_IS_FLOWPARA(child) ) {
@@ -146,17 +148,19 @@ Inkscape::XML::Node* SPFlowdiv::write(Inkscape::XML::Document *xml_doc, Inkscape
} else if ( SP_IS_STRING(child) ) {
c_repr = xml_doc->createTextNode(SP_STRING(child)->string.c_str());
}
+
if ( c_repr ) {
l = g_slist_prepend (l, c_repr);
}
}
+
while ( l ) {
repr->addChild((Inkscape::XML::Node *) l->data, NULL);
Inkscape::GC::release((Inkscape::XML::Node *) l->data);
l = g_slist_remove(l, l->data);
}
} else {
- for ( SPObject* child = object->firstChild() ; child ; child = child->getNext() ) {
+ for ( SPObject* child = this->firstChild() ; child ; child = child->getNext() ) {
if ( SP_IS_FLOWTSPAN (child) ) {
child->updateRepr(flags);
} else if ( SP_IS_FLOWPARA(child) ) {
@@ -188,8 +192,6 @@ void SPFlowtspan::release() {
}
void SPFlowtspan::update(SPCtx *ctx, unsigned int flags) {
- SPFlowtspan* object = this;
-
SPItemCtx *ictx = reinterpret_cast<SPItemCtx *>(ctx);
SPItemCtx cctx = *ictx;
@@ -198,17 +200,21 @@ void SPFlowtspan::update(SPCtx *ctx, unsigned int flags) {
if (flags & SP_OBJECT_MODIFIED_FLAG) {
flags |= SP_OBJECT_PARENT_MODIFIED_FLAG;
}
+
flags &= SP_OBJECT_MODIFIED_CASCADE;
GSList* l = NULL;
- for ( SPObject *child = object->firstChild() ; child ; child = child->getNext() ) {
+ for ( SPObject *child = this->firstChild() ; child ; child = child->getNext() ) {
sp_object_ref(child);
l = g_slist_prepend(l, child);
}
+
l = g_slist_reverse (l);
+
while (l) {
SPObject *child = SP_OBJECT(l->data);
l = g_slist_remove(l, child);
+
if (flags || (child->uflags & (SP_OBJECT_MODIFIED_FLAG | SP_OBJECT_CHILD_MODIFIED_FLAG))) {
if (SP_IS_ITEM(child)) {
SPItem const &chi = *SP_ITEM(child);
@@ -219,39 +225,42 @@ void SPFlowtspan::update(SPCtx *ctx, unsigned int flags) {
child->updateDisplay(ctx, flags);
}
}
+
sp_object_unref(child);
}
}
void SPFlowtspan::modified(unsigned int flags) {
- SPFlowtspan* object = this;
-
SPItem::modified(flags);
if (flags & SP_OBJECT_MODIFIED_FLAG) {
flags |= SP_OBJECT_PARENT_MODIFIED_FLAG;
}
+
flags &= SP_OBJECT_MODIFIED_CASCADE;
GSList *l = NULL;
- for ( SPObject *child = object->firstChild() ; child ; child = child->getNext() ) {
+ for ( SPObject *child = this->firstChild() ; child ; child = child->getNext() ) {
sp_object_ref(child);
l = g_slist_prepend(l, child);
}
+
l = g_slist_reverse (l);
+
while (l) {
SPObject *child = SP_OBJECT(l->data);
l = g_slist_remove(l, child);
+
if (flags || (child->mflags & (SP_OBJECT_MODIFIED_FLAG | SP_OBJECT_CHILD_MODIFIED_FLAG))) {
child->emitModified(flags);
}
+
sp_object_unref(child);
}
}
-void SPFlowtspan::build(SPDocument *doc, Inkscape::XML::Node *repr)
-{
+void SPFlowtspan::build(SPDocument *doc, Inkscape::XML::Node *repr) {
SPItem::build(doc, repr);
}
@@ -259,17 +268,17 @@ void SPFlowtspan::set(unsigned int key, const gchar* value) {
SPItem::set(key, value);
}
-Inkscape::XML::Node *SPFlowtspan::write(Inkscape::XML::Document *xml_doc, Inkscape::XML::Node *repr, guint flags)
-{
- SPFlowtspan* object = this;
-
+Inkscape::XML::Node *SPFlowtspan::write(Inkscape::XML::Document *xml_doc, Inkscape::XML::Node *repr, guint flags) {
if ( flags&SP_OBJECT_WRITE_BUILD ) {
if ( repr == NULL ) {
repr = xml_doc->createElement("svg:flowSpan");
}
+
GSList *l = NULL;
- for ( SPObject* child = object->firstChild() ; child ; child = child->getNext() ) {
+
+ for ( SPObject* child = this->firstChild() ; child ; child = child->getNext() ) {
Inkscape::XML::Node* c_repr = NULL;
+
if ( SP_IS_FLOWTSPAN(child) ) {
c_repr = child->updateRepr(xml_doc, NULL, flags);
} else if ( SP_IS_FLOWPARA(child) ) {
@@ -277,17 +286,19 @@ Inkscape::XML::Node *SPFlowtspan::write(Inkscape::XML::Document *xml_doc, Inksca
} else if ( SP_IS_STRING(child) ) {
c_repr = xml_doc->createTextNode(SP_STRING(child)->string.c_str());
}
+
if ( c_repr ) {
l = g_slist_prepend(l, c_repr);
}
}
+
while ( l ) {
repr->addChild((Inkscape::XML::Node *) l->data, NULL);
Inkscape::GC::release((Inkscape::XML::Node *) l->data);
l = g_slist_remove(l, l->data);
}
} else {
- for ( SPObject* child = object->firstChild() ; child ; child = child->getNext() ) {
+ for ( SPObject* child = this->firstChild() ; child ; child = child->getNext() ) {
if ( SP_IS_FLOWTSPAN(child) ) {
child->updateRepr(flags);
} else if ( SP_IS_FLOWPARA(child) ) {
@@ -304,8 +315,6 @@ Inkscape::XML::Node *SPFlowtspan::write(Inkscape::XML::Document *xml_doc, Inksca
}
-
-
/*
*
*/
@@ -319,10 +328,7 @@ void SPFlowpara::release() {
SPItem::release();
}
-void SPFlowpara::update(SPCtx *ctx, unsigned int flags)
-{
- SPFlowpara* object = this;
-
+void SPFlowpara::update(SPCtx *ctx, unsigned int flags) {
SPItemCtx *ictx = reinterpret_cast<SPItemCtx *>(ctx);
SPItemCtx cctx = *ictx;
@@ -331,17 +337,21 @@ void SPFlowpara::update(SPCtx *ctx, unsigned int flags)
if (flags & SP_OBJECT_MODIFIED_FLAG) {
flags |= SP_OBJECT_PARENT_MODIFIED_FLAG;
}
+
flags &= SP_OBJECT_MODIFIED_CASCADE;
GSList* l = NULL;
- for ( SPObject *child = object->firstChild() ; child ; child = child->getNext() ) {
+ for ( SPObject *child = this->firstChild() ; child ; child = child->getNext() ) {
sp_object_ref(child);
l = g_slist_prepend(l, child);
}
+
l = g_slist_reverse (l);
+
while (l) {
SPObject *child = SP_OBJECT(l->data);
l = g_slist_remove(l, child);
+
if (flags || (child->uflags & (SP_OBJECT_MODIFIED_FLAG | SP_OBJECT_CHILD_MODIFIED_FLAG))) {
if (SP_IS_ITEM(child)) {
SPItem const &chi = *SP_ITEM(child);
@@ -352,39 +362,42 @@ void SPFlowpara::update(SPCtx *ctx, unsigned int flags)
child->updateDisplay(ctx, flags);
}
}
+
sp_object_unref(child);
}
}
void SPFlowpara::modified(unsigned int flags) {
- SPFlowpara* object = this;
-
SPItem::modified(flags);
if (flags & SP_OBJECT_MODIFIED_FLAG) {
flags |= SP_OBJECT_PARENT_MODIFIED_FLAG;
}
+
flags &= SP_OBJECT_MODIFIED_CASCADE;
GSList *l = NULL;
- for ( SPObject *child = object->firstChild() ; child ; child = child->getNext() ) {
+ for ( SPObject *child = this->firstChild() ; child ; child = child->getNext() ) {
sp_object_ref(child);
l = g_slist_prepend(l, child);
}
+
l = g_slist_reverse (l);
+
while (l) {
SPObject *child = SP_OBJECT(l->data);
l = g_slist_remove(l, child);
+
if (flags || (child->mflags & (SP_OBJECT_MODIFIED_FLAG | SP_OBJECT_CHILD_MODIFIED_FLAG))) {
child->emitModified(flags);
}
+
sp_object_unref(child);
}
}
-void SPFlowpara::build(SPDocument *doc, Inkscape::XML::Node *repr)
-{
+void SPFlowpara::build(SPDocument *doc, Inkscape::XML::Node *repr) {
SPItem::build(doc, repr);
}
@@ -392,15 +405,17 @@ void SPFlowpara::set(unsigned int key, const gchar* value) {
SPItem::set(key, value);
}
-Inkscape::XML::Node *SPFlowpara::write(Inkscape::XML::Document *xml_doc, Inkscape::XML::Node *repr, guint flags)
-{
- SPFlowpara* object = this;
-
+Inkscape::XML::Node *SPFlowpara::write(Inkscape::XML::Document *xml_doc, Inkscape::XML::Node *repr, guint flags) {
if ( flags&SP_OBJECT_WRITE_BUILD ) {
- if ( repr == NULL ) repr = xml_doc->createElement("svg:flowPara");
+ if ( repr == NULL ) {
+ repr = xml_doc->createElement("svg:flowPara");
+ }
+
GSList *l = NULL;
- for ( SPObject* child = object->firstChild() ; child ; child = child->getNext() ) {
+
+ for ( SPObject* child = this->firstChild() ; child ; child = child->getNext() ) {
Inkscape::XML::Node* c_repr = NULL;
+
if ( SP_IS_FLOWTSPAN(child) ) {
c_repr = child->updateRepr(xml_doc, NULL, flags);
} else if ( SP_IS_FLOWPARA(child) ) {
@@ -408,17 +423,19 @@ Inkscape::XML::Node *SPFlowpara::write(Inkscape::XML::Document *xml_doc, Inkscap
} else if ( SP_IS_STRING(child) ) {
c_repr = xml_doc->createTextNode(SP_STRING(child)->string.c_str());
}
+
if ( c_repr ) {
l = g_slist_prepend(l, c_repr);
}
}
+
while ( l ) {
repr->addChild((Inkscape::XML::Node *) l->data, NULL);
Inkscape::GC::release((Inkscape::XML::Node *) l->data);
l = g_slist_remove(l, l->data);
}
} else {
- for ( SPObject* child = object->firstChild() ; child ; child = child->getNext() ) {
+ for ( SPObject* child = this->firstChild() ; child ; child = child->getNext() ) {
if ( SP_IS_FLOWTSPAN(child) ) {
child->updateRepr(flags);
} else if ( SP_IS_FLOWPARA(child) ) {
@@ -455,16 +472,15 @@ void SPFlowline::modified(unsigned int flags) {
if (flags & SP_OBJECT_MODIFIED_FLAG) {
flags |= SP_OBJECT_PARENT_MODIFIED_FLAG;
}
+
flags &= SP_OBJECT_MODIFIED_CASCADE;
}
-Inkscape::XML::Node *SPFlowline::write(Inkscape::XML::Document *xml_doc, Inkscape::XML::Node *repr, guint flags)
-{
+Inkscape::XML::Node *SPFlowline::write(Inkscape::XML::Document *xml_doc, Inkscape::XML::Node *repr, guint flags) {
if ( flags & SP_OBJECT_WRITE_BUILD ) {
if ( repr == NULL ) {
repr = xml_doc->createElement("svg:flowLine");
}
- } else {
}
SPObject::write(xml_doc, repr, flags);
@@ -493,16 +509,15 @@ void SPFlowregionbreak::modified(unsigned int flags) {
if (flags & SP_OBJECT_MODIFIED_FLAG) {
flags |= SP_OBJECT_PARENT_MODIFIED_FLAG;
}
+
flags &= SP_OBJECT_MODIFIED_CASCADE;
}
-Inkscape::XML::Node *SPFlowregionbreak::write(Inkscape::XML::Document *xml_doc, Inkscape::XML::Node *repr, guint flags)
-{
+Inkscape::XML::Node *SPFlowregionbreak::write(Inkscape::XML::Document *xml_doc, Inkscape::XML::Node *repr, guint flags) {
if ( flags & SP_OBJECT_WRITE_BUILD ) {
if ( repr == NULL ) {
repr = xml_doc->createElement("svg:flowLine");
}
- } else {
}
SPObject::write(xml_doc, repr, flags);
diff --git a/src/sp-flowdiv.h b/src/sp-flowdiv.h
index 8fa64e2b8..9980dc4da 100644
--- a/src/sp-flowdiv.h
+++ b/src/sp-flowdiv.h
@@ -28,6 +28,7 @@ public:
SPFlowdiv();
virtual ~SPFlowdiv();
+protected:
virtual void build(SPDocument *document, Inkscape::XML::Node *repr);
virtual void release();
virtual void update(SPCtx* ctx, guint flags);
@@ -42,6 +43,7 @@ public:
SPFlowtspan();
virtual ~SPFlowtspan();
+protected:
virtual void build(SPDocument *document, Inkscape::XML::Node *repr);
virtual void release();
virtual void update(SPCtx* ctx, guint flags);
@@ -56,6 +58,7 @@ public:
SPFlowpara();
virtual ~SPFlowpara();
+protected:
virtual void build(SPDocument *document, Inkscape::XML::Node *repr);
virtual void release();
virtual void update(SPCtx* ctx, guint flags);
@@ -71,6 +74,7 @@ public:
SPFlowline();
virtual ~SPFlowline();
+protected:
virtual void release();
virtual void modified(unsigned int flags);
@@ -82,6 +86,7 @@ public:
SPFlowregionbreak();
virtual ~SPFlowregionbreak();
+protected:
virtual void release();
virtual void modified(unsigned int flags);
diff --git a/src/sp-font-face.cpp b/src/sp-font-face.cpp
index 39242b870..9782f0c83 100644
--- a/src/sp-font-face.cpp
+++ b/src/sp-font-face.cpp
@@ -327,59 +327,48 @@ SPFontFace::~SPFontFace() {
void SPFontFace::build(SPDocument *document, Inkscape::XML::Node *repr) {
SPObject::build(document, repr);
- SPFontFace* object = this;
-
- object->readAttr( "font-family" );
- object->readAttr( "font-style" );
- object->readAttr( "font-variant" );
- object->readAttr( "font-weight" );
- object->readAttr( "font-stretch" );
- object->readAttr( "font-size" );
- object->readAttr( "unicode-range" );
- object->readAttr( "units-per-em" );
- object->readAttr( "panose-1" );
- object->readAttr( "stem-v" );
- object->readAttr( "stem-h" );
- object->readAttr( "slope" );
- object->readAttr( "cap-height" );
- object->readAttr( "x-height" );
- object->readAttr( "accent-height" );
- object->readAttr( "ascent" );
- object->readAttr( "descent" );
- object->readAttr( "widths" );
- object->readAttr( "bbox" );
- object->readAttr( "ideographic" );
- object->readAttr( "alphabetic" );
- object->readAttr( "mathematical" );
- object->readAttr( "ranging" );
- object->readAttr( "v-ideogaphic" );
- object->readAttr( "v-alphabetic" );
- object->readAttr( "v-mathematical" );
- object->readAttr( "v-hanging" );
- object->readAttr( "underline-position" );
- object->readAttr( "underline-thickness" );
- object->readAttr( "strikethrough-position" );
- object->readAttr( "strikethrough-thickness" );
- object->readAttr( "overline-position" );
- object->readAttr( "overline-thickness" );
-}
-
-static void sp_fontface_children_modified(SPFontFace */*sp_fontface*/)
-{
+ this->readAttr( "font-family" );
+ this->readAttr( "font-style" );
+ this->readAttr( "font-variant" );
+ this->readAttr( "font-weight" );
+ this->readAttr( "font-stretch" );
+ this->readAttr( "font-size" );
+ this->readAttr( "unicode-range" );
+ this->readAttr( "units-per-em" );
+ this->readAttr( "panose-1" );
+ this->readAttr( "stem-v" );
+ this->readAttr( "stem-h" );
+ this->readAttr( "slope" );
+ this->readAttr( "cap-height" );
+ this->readAttr( "x-height" );
+ this->readAttr( "accent-height" );
+ this->readAttr( "ascent" );
+ this->readAttr( "descent" );
+ this->readAttr( "widths" );
+ this->readAttr( "bbox" );
+ this->readAttr( "ideographic" );
+ this->readAttr( "alphabetic" );
+ this->readAttr( "mathematical" );
+ this->readAttr( "ranging" );
+ this->readAttr( "v-ideogaphic" );
+ this->readAttr( "v-alphabetic" );
+ this->readAttr( "v-mathematical" );
+ this->readAttr( "v-hanging" );
+ this->readAttr( "underline-position" );
+ this->readAttr( "underline-thickness" );
+ this->readAttr( "strikethrough-position" );
+ this->readAttr( "strikethrough-thickness" );
+ this->readAttr( "overline-position" );
+ this->readAttr( "overline-thickness" );
}
/**
* Callback for child_added event.
*/
void SPFontFace::child_added(Inkscape::XML::Node *child, Inkscape::XML::Node *ref) {
- SPFontFace* object = this;
-
- SPFontFace *f = SP_FONTFACE(object);
-
SPObject::child_added(child, ref);
- sp_fontface_children_modified(f);
- object->parent->requestModified(SP_OBJECT_MODIFIED_FLAG);
+ this->parent->requestModified(SP_OBJECT_MODIFIED_FLAG);
}
@@ -387,14 +376,9 @@ void SPFontFace::child_added(Inkscape::XML::Node *child, Inkscape::XML::Node *re
* Callback for remove_child event.
*/
void SPFontFace::remove_child(Inkscape::XML::Node *child) {
- SPFontFace* object = this;
-
- SPFontFace *f = SP_FONTFACE(object);
-
SPObject::remove_child(child);
- sp_fontface_children_modified(f);
- object->parent->requestModified(SP_OBJECT_MODIFIED_FLAG);
+ this->parent->requestModified(SP_OBJECT_MODIFIED_FLAG);
}
void SPFontFace::release() {
@@ -402,9 +386,6 @@ void SPFontFace::release() {
}
void SPFontFace::set(unsigned int key, const gchar *value) {
- SPFontFace* object = this;
-
- SPFontFace *face = SP_FONTFACE(object);
std::vector<FontFaceStyleType> style;
std::vector<FontFaceVariantType> variant;
std::vector<FontFaceWeightType> weight;
@@ -412,22 +393,24 @@ void SPFontFace::set(unsigned int key, const gchar *value) {
switch (key) {
case SP_PROP_FONT_FAMILY:
- if (face->font_family) {
- g_free(face->font_family);
+ if (this->font_family) {
+ g_free(this->font_family);
}
- face->font_family = g_strdup(value);
- object->requestModified(SP_OBJECT_MODIFIED_FLAG);
+
+ this->font_family = g_strdup(value);
+ this->requestModified(SP_OBJECT_MODIFIED_FLAG);
break;
case SP_PROP_FONT_STYLE:
style = sp_read_fontFaceStyleType(value);
- if (face->font_style.size() != style.size()){
- face->font_style = style;
- object->requestModified(SP_OBJECT_MODIFIED_FLAG);
+
+ if (this->font_style.size() != style.size()){
+ this->font_style = style;
+ this->requestModified(SP_OBJECT_MODIFIED_FLAG);
} else {
for (unsigned int i=0;i<style.size();i++){
- if (style[i] != face->font_style[i]){
- face->font_style = style;
- object->requestModified(SP_OBJECT_MODIFIED_FLAG);
+ if (style[i] != this->font_style[i]){
+ this->font_style = style;
+ this->requestModified(SP_OBJECT_MODIFIED_FLAG);
break;
}
}
@@ -435,14 +418,15 @@ void SPFontFace::set(unsigned int key, const gchar *value) {
break;
case SP_PROP_FONT_VARIANT:
variant = sp_read_fontFaceVariantType(value);
- if (face->font_variant.size() != variant.size()){
- face->font_variant = variant;
- object->requestModified(SP_OBJECT_MODIFIED_FLAG);
+
+ if (this->font_variant.size() != variant.size()){
+ this->font_variant = variant;
+ this->requestModified(SP_OBJECT_MODIFIED_FLAG);
} else {
for (unsigned int i=0;i<variant.size();i++){
- if (variant[i] != face->font_variant[i]){
- face->font_variant = variant;
- object->requestModified(SP_OBJECT_MODIFIED_FLAG);
+ if (variant[i] != this->font_variant[i]){
+ this->font_variant = variant;
+ this->requestModified(SP_OBJECT_MODIFIED_FLAG);
break;
}
}
@@ -450,14 +434,15 @@ void SPFontFace::set(unsigned int key, const gchar *value) {
break;
case SP_PROP_FONT_WEIGHT:
weight = sp_read_fontFaceWeightType(value);
- if (face->font_weight.size() != weight.size()){
- face->font_weight = weight;
- object->requestModified(SP_OBJECT_MODIFIED_FLAG);
+
+ if (this->font_weight.size() != weight.size()){
+ this->font_weight = weight;
+ this->requestModified(SP_OBJECT_MODIFIED_FLAG);
} else {
for (unsigned int i=0;i<weight.size();i++){
- if (weight[i] != face->font_weight[i]){
- face->font_weight = weight;
- object->requestModified(SP_OBJECT_MODIFIED_FLAG);
+ if (weight[i] != this->font_weight[i]){
+ this->font_weight = weight;
+ this->requestModified(SP_OBJECT_MODIFIED_FLAG);
break;
}
}
@@ -465,14 +450,15 @@ void SPFontFace::set(unsigned int key, const gchar *value) {
break;
case SP_PROP_FONT_STRETCH:
stretch = sp_read_fontFaceStretchType(value);
- if (face->font_stretch.size() != stretch.size()){
- face->font_stretch = stretch;
- object->requestModified(SP_OBJECT_MODIFIED_FLAG);
+
+ if (this->font_stretch.size() != stretch.size()){
+ this->font_stretch = stretch;
+ this->requestModified(SP_OBJECT_MODIFIED_FLAG);
} else {
for (unsigned int i=0;i<stretch.size();i++){
- if (stretch[i] != face->font_stretch[i]){
- face->font_stretch = stretch;
- object->requestModified(SP_OBJECT_MODIFIED_FLAG);
+ if (stretch[i] != this->font_stretch[i]){
+ this->font_stretch = stretch;
+ this->requestModified(SP_OBJECT_MODIFIED_FLAG);
break;
}
}
@@ -481,207 +467,230 @@ void SPFontFace::set(unsigned int key, const gchar *value) {
case SP_ATTR_UNITS_PER_EM:
{
double number = value ? g_ascii_strtod(value, 0) : 0;
- if (number != face->units_per_em){
- face->units_per_em = number;
- object->requestModified(SP_OBJECT_MODIFIED_FLAG);
+
+ if (number != this->units_per_em){
+ this->units_per_em = number;
+ this->requestModified(SP_OBJECT_MODIFIED_FLAG);
}
break;
}
case SP_ATTR_STEMV:
{
double number = value ? g_ascii_strtod(value, 0) : 0;
- if (number != face->stemv){
- face->stemv = number;
- object->requestModified(SP_OBJECT_MODIFIED_FLAG);
+
+ if (number != this->stemv){
+ this->stemv = number;
+ this->requestModified(SP_OBJECT_MODIFIED_FLAG);
}
break;
}
case SP_ATTR_STEMH:
{
double number = value ? g_ascii_strtod(value, 0) : 0;
- if (number != face->stemh){
- face->stemh = number;
- object->requestModified(SP_OBJECT_MODIFIED_FLAG);
+
+ if (number != this->stemh){
+ this->stemh = number;
+ this->requestModified(SP_OBJECT_MODIFIED_FLAG);
}
break;
}
case SP_ATTR_SLOPE:
{
double number = value ? g_ascii_strtod(value, 0) : 0;
- if (number != face->slope){
- face->slope = number;
- object->requestModified(SP_OBJECT_MODIFIED_FLAG);
+
+ if (number != this->slope){
+ this->slope = number;
+ this->requestModified(SP_OBJECT_MODIFIED_FLAG);
}
break;
}
case SP_ATTR_CAP_HEIGHT:
{
double number = value ? g_ascii_strtod(value, 0) : 0;
- if (number != face->cap_height){
- face->cap_height = number;
- object->requestModified(SP_OBJECT_MODIFIED_FLAG);
+
+ if (number != this->cap_height){
+ this->cap_height = number;
+ this->requestModified(SP_OBJECT_MODIFIED_FLAG);
}
break;
}
case SP_ATTR_X_HEIGHT:
{
double number = value ? g_ascii_strtod(value, 0) : 0;
- if (number != face->x_height){
- face->x_height = number;
- object->requestModified(SP_OBJECT_MODIFIED_FLAG);
+
+ if (number != this->x_height){
+ this->x_height = number;
+ this->requestModified(SP_OBJECT_MODIFIED_FLAG);
}
break;
}
case SP_ATTR_ACCENT_HEIGHT:
{
double number = value ? g_ascii_strtod(value, 0) : 0;
- if (number != face->accent_height){
- face->accent_height = number;
- object->requestModified(SP_OBJECT_MODIFIED_FLAG);
+
+ if (number != this->accent_height){
+ this->accent_height = number;
+ this->requestModified(SP_OBJECT_MODIFIED_FLAG);
}
break;
}
case SP_ATTR_ASCENT:
{
double number = value ? g_ascii_strtod(value, 0) : 0;
- if (number != face->ascent){
- face->ascent = number;
- object->requestModified(SP_OBJECT_MODIFIED_FLAG);
+
+ if (number != this->ascent){
+ this->ascent = number;
+ this->requestModified(SP_OBJECT_MODIFIED_FLAG);
}
break;
}
case SP_ATTR_DESCENT:
{
double number = value ? g_ascii_strtod(value, 0) : 0;
- if (number != face->descent){
- face->descent = number;
- object->requestModified(SP_OBJECT_MODIFIED_FLAG);
+
+ if (number != this->descent){
+ this->descent = number;
+ this->requestModified(SP_OBJECT_MODIFIED_FLAG);
}
break;
}
case SP_ATTR_IDEOGRAPHIC:
{
double number = value ? g_ascii_strtod(value, 0) : 0;
- if (number != face->ideographic){
- face->ideographic = number;
- object->requestModified(SP_OBJECT_MODIFIED_FLAG);
+
+ if (number != this->ideographic){
+ this->ideographic = number;
+ this->requestModified(SP_OBJECT_MODIFIED_FLAG);
}
break;
}
case SP_ATTR_ALPHABETIC:
{
double number = value ? g_ascii_strtod(value, 0) : 0;
- if (number != face->alphabetic){
- face->alphabetic = number;
- object->requestModified(SP_OBJECT_MODIFIED_FLAG);
+
+ if (number != this->alphabetic){
+ this->alphabetic = number;
+ this->requestModified(SP_OBJECT_MODIFIED_FLAG);
}
break;
}
case SP_ATTR_MATHEMATICAL:
{
double number = value ? g_ascii_strtod(value, 0) : 0;
- if (number != face->mathematical){
- face->mathematical = number;
- object->requestModified(SP_OBJECT_MODIFIED_FLAG);
+
+ if (number != this->mathematical){
+ this->mathematical = number;
+ this->requestModified(SP_OBJECT_MODIFIED_FLAG);
}
break;
}
case SP_ATTR_HANGING:
{
double number = value ? g_ascii_strtod(value, 0) : 0;
- if (number != face->hanging){
- face->hanging = number;
- object->requestModified(SP_OBJECT_MODIFIED_FLAG);
+
+ if (number != this->hanging){
+ this->hanging = number;
+ this->requestModified(SP_OBJECT_MODIFIED_FLAG);
}
break;
}
case SP_ATTR_V_IDEOGRAPHIC:
{
double number = value ? g_ascii_strtod(value, 0) : 0;
- if (number != face->v_ideographic){
- face->v_ideographic = number;
- object->requestModified(SP_OBJECT_MODIFIED_FLAG);
+
+ if (number != this->v_ideographic){
+ this->v_ideographic = number;
+ this->requestModified(SP_OBJECT_MODIFIED_FLAG);
}
break;
}
case SP_ATTR_V_ALPHABETIC:
{
double number = value ? g_ascii_strtod(value, 0) : 0;
- if (number != face->v_alphabetic){
- face->v_alphabetic = number;
- object->requestModified(SP_OBJECT_MODIFIED_FLAG);
+
+ if (number != this->v_alphabetic){
+ this->v_alphabetic = number;
+ this->requestModified(SP_OBJECT_MODIFIED_FLAG);
}
break;
}
case SP_ATTR_V_MATHEMATICAL:
{
double number = value ? g_ascii_strtod(value, 0) : 0;
- if (number != face->v_mathematical){
- face->v_mathematical = number;
- object->requestModified(SP_OBJECT_MODIFIED_FLAG);
+
+ if (number != this->v_mathematical){
+ this->v_mathematical = number;
+ this->requestModified(SP_OBJECT_MODIFIED_FLAG);
}
break;
}
case SP_ATTR_V_HANGING:
{
double number = value ? g_ascii_strtod(value, 0) : 0;
- if (number != face->v_hanging){
- face->v_hanging = number;
- object->requestModified(SP_OBJECT_MODIFIED_FLAG);
+
+ if (number != this->v_hanging){
+ this->v_hanging = number;
+ this->requestModified(SP_OBJECT_MODIFIED_FLAG);
}
break;
}
case SP_ATTR_UNDERLINE_POSITION:
{
double number = value ? g_ascii_strtod(value, 0) : 0;
- if (number != face->underline_position){
- face->underline_position = number;
- object->requestModified(SP_OBJECT_MODIFIED_FLAG);
+
+ if (number != this->underline_position){
+ this->underline_position = number;
+ this->requestModified(SP_OBJECT_MODIFIED_FLAG);
}
break;
}
case SP_ATTR_UNDERLINE_THICKNESS:
{
double number = value ? g_ascii_strtod(value, 0) : 0;
- if (number != face->underline_thickness){
- face->underline_thickness = number;
- object->requestModified(SP_OBJECT_MODIFIED_FLAG);
+
+ if (number != this->underline_thickness){
+ this->underline_thickness = number;
+ this->requestModified(SP_OBJECT_MODIFIED_FLAG);
}
break;
}
case SP_ATTR_STRIKETHROUGH_POSITION:
{
double number = value ? g_ascii_strtod(value, 0) : 0;
- if (number != face->strikethrough_position){
- face->strikethrough_position = number;
- object->requestModified(SP_OBJECT_MODIFIED_FLAG);
+
+ if (number != this->strikethrough_position){
+ this->strikethrough_position = number;
+ this->requestModified(SP_OBJECT_MODIFIED_FLAG);
}
break;
}
case SP_ATTR_STRIKETHROUGH_THICKNESS:
{
double number = value ? g_ascii_strtod(value, 0) : 0;
- if (number != face->strikethrough_thickness){
- face->strikethrough_thickness = number;
- object->requestModified(SP_OBJECT_MODIFIED_FLAG);
+
+ if (number != this->strikethrough_thickness){
+ this->strikethrough_thickness = number;
+ this->requestModified(SP_OBJECT_MODIFIED_FLAG);
}
break;
}
case SP_ATTR_OVERLINE_POSITION:
{
double number = value ? g_ascii_strtod(value, 0) : 0;
- if (number != face->overline_position){
- face->overline_position = number;
- object->requestModified(SP_OBJECT_MODIFIED_FLAG);
+
+ if (number != this->overline_position){
+ this->overline_position = number;
+ this->requestModified(SP_OBJECT_MODIFIED_FLAG);
}
break;
}
case SP_ATTR_OVERLINE_THICKNESS:
{
double number = value ? g_ascii_strtod(value, 0) : 0;
- if (number != face->overline_thickness){
- face->overline_thickness = number;
- object->requestModified(SP_OBJECT_MODIFIED_FLAG);
+
+ if (number != this->overline_thickness){
+ this->overline_thickness = number;
+ this->requestModified(SP_OBJECT_MODIFIED_FLAG);
}
break;
}
@@ -695,42 +704,40 @@ void SPFontFace::set(unsigned int key, const gchar *value) {
* Receives update notifications.
*/
void SPFontFace::update(SPCtx *ctx, guint flags) {
- SPFontFace* object = this;
-
if (flags & (SP_OBJECT_MODIFIED_FLAG)) {
- object->readAttr( "font-family" );
- object->readAttr( "font-style" );
- object->readAttr( "font-variant" );
- object->readAttr( "font-weight" );
- object->readAttr( "font-stretch" );
- object->readAttr( "font-size" );
- object->readAttr( "unicode-range" );
- object->readAttr( "units-per-em" );
- object->readAttr( "panose-1" );
- object->readAttr( "stemv" );
- object->readAttr( "stemh" );
- object->readAttr( "slope" );
- object->readAttr( "cap-height" );
- object->readAttr( "x-height" );
- object->readAttr( "accent-height" );
- object->readAttr( "ascent" );
- object->readAttr( "descent" );
- object->readAttr( "widths" );
- object->readAttr( "bbox" );
- object->readAttr( "ideographic" );
- object->readAttr( "alphabetic" );
- object->readAttr( "mathematical" );
- object->readAttr( "hanging" );
- object->readAttr( "v-ideographic" );
- object->readAttr( "v-alphabetic" );
- object->readAttr( "v-mathematical" );
- object->readAttr( "v-hanging" );
- object->readAttr( "underline-position" );
- object->readAttr( "underline-thickness" );
- object->readAttr( "strikethrough-position" );
- object->readAttr( "strikethrough-thickness" );
- object->readAttr( "overline-position" );
- object->readAttr( "overline-thickness" );
+ this->readAttr( "font-family" );
+ this->readAttr( "font-style" );
+ this->readAttr( "font-variant" );
+ this->readAttr( "font-weight" );
+ this->readAttr( "font-stretch" );
+ this->readAttr( "font-size" );
+ this->readAttr( "unicode-range" );
+ this->readAttr( "units-per-em" );
+ this->readAttr( "panose-1" );
+ this->readAttr( "stemv" );
+ this->readAttr( "stemh" );
+ this->readAttr( "slope" );
+ this->readAttr( "cap-height" );
+ this->readAttr( "x-height" );
+ this->readAttr( "accent-height" );
+ this->readAttr( "ascent" );
+ this->readAttr( "descent" );
+ this->readAttr( "widths" );
+ this->readAttr( "bbox" );
+ this->readAttr( "ideographic" );
+ this->readAttr( "alphabetic" );
+ this->readAttr( "mathematical" );
+ this->readAttr( "hanging" );
+ this->readAttr( "v-ideographic" );
+ this->readAttr( "v-alphabetic" );
+ this->readAttr( "v-mathematical" );
+ this->readAttr( "v-hanging" );
+ this->readAttr( "underline-position" );
+ this->readAttr( "underline-thickness" );
+ this->readAttr( "strikethrough-position" );
+ this->readAttr( "strikethrough-thickness" );
+ this->readAttr( "overline-position" );
+ this->readAttr( "overline-thickness" );
}
SPObject::update(ctx, flags);
@@ -739,10 +746,6 @@ void SPFontFace::update(SPCtx *ctx, guint flags) {
#define COPY_ATTR(rd,rs,key) (rd)->setAttribute((key), rs->attribute(key));
Inkscape::XML::Node* SPFontFace::write(Inkscape::XML::Document *xml_doc, Inkscape::XML::Node *repr, guint flags) {
- SPFontFace* object = this;
-
- SPFontFace *face = SP_FONTFACE(object);
-
if ((flags & SP_OBJECT_WRITE_BUILD) && !repr) {
repr = xml_doc->createElement("svg:font-face");
}
@@ -755,69 +758,69 @@ Inkscape::XML::Node* SPFontFace::write(Inkscape::XML::Document *xml_doc, Inkscap
//sp_repr_set_svg_double(repr, "font-stretch", face->font_stretch);
//sp_repr_set_svg_double(repr, "font-size", face->font_size);
//sp_repr_set_svg_double(repr, "unicode-range", face->unicode_range);
- sp_repr_set_svg_double(repr, "units-per-em", face->units_per_em);
+ sp_repr_set_svg_double(repr, "units-per-em", this->units_per_em);
//sp_repr_set_svg_double(repr, "panose-1", face->panose_1);
- sp_repr_set_svg_double(repr, "stemv", face->stemv);
- sp_repr_set_svg_double(repr, "stemh", face->stemh);
- sp_repr_set_svg_double(repr, "slope", face->slope);
- sp_repr_set_svg_double(repr, "cap-height", face->cap_height);
- sp_repr_set_svg_double(repr, "x-height", face->x_height);
- sp_repr_set_svg_double(repr, "accent-height", face->accent_height);
- sp_repr_set_svg_double(repr, "ascent", face->ascent);
- sp_repr_set_svg_double(repr, "descent", face->descent);
+ sp_repr_set_svg_double(repr, "stemv", this->stemv);
+ sp_repr_set_svg_double(repr, "stemh", this->stemh);
+ sp_repr_set_svg_double(repr, "slope", this->slope);
+ sp_repr_set_svg_double(repr, "cap-height", this->cap_height);
+ sp_repr_set_svg_double(repr, "x-height", this->x_height);
+ sp_repr_set_svg_double(repr, "accent-height", this->accent_height);
+ sp_repr_set_svg_double(repr, "ascent", this->ascent);
+ sp_repr_set_svg_double(repr, "descent", this->descent);
//sp_repr_set_svg_double(repr, "widths", face->widths);
//sp_repr_set_svg_double(repr, "bbox", face->bbox);
- sp_repr_set_svg_double(repr, "ideographic", face->ideographic);
- sp_repr_set_svg_double(repr, "alphabetic", face->alphabetic);
- sp_repr_set_svg_double(repr, "mathematical", face->mathematical);
- sp_repr_set_svg_double(repr, "hanging", face->hanging);
- sp_repr_set_svg_double(repr, "v-ideographic", face->v_ideographic);
- sp_repr_set_svg_double(repr, "v-alphabetic", face->v_alphabetic);
- sp_repr_set_svg_double(repr, "v-mathematical", face->v_mathematical);
- sp_repr_set_svg_double(repr, "v-hanging", face->v_hanging);
- sp_repr_set_svg_double(repr, "underline-position", face->underline_position);
- sp_repr_set_svg_double(repr, "underline-thickness", face->underline_thickness);
- sp_repr_set_svg_double(repr, "strikethrough-position", face->strikethrough_position);
- sp_repr_set_svg_double(repr, "strikethrough-thickness", face->strikethrough_thickness);
- sp_repr_set_svg_double(repr, "overline-position", face->overline_position);
- sp_repr_set_svg_double(repr, "overline-thickness", face->overline_thickness);
-
- if (repr != object->getRepr()) {
+ sp_repr_set_svg_double(repr, "ideographic", this->ideographic);
+ sp_repr_set_svg_double(repr, "alphabetic", this->alphabetic);
+ sp_repr_set_svg_double(repr, "mathematical", this->mathematical);
+ sp_repr_set_svg_double(repr, "hanging", this->hanging);
+ sp_repr_set_svg_double(repr, "v-ideographic", this->v_ideographic);
+ sp_repr_set_svg_double(repr, "v-alphabetic", this->v_alphabetic);
+ sp_repr_set_svg_double(repr, "v-mathematical", this->v_mathematical);
+ sp_repr_set_svg_double(repr, "v-hanging", this->v_hanging);
+ sp_repr_set_svg_double(repr, "underline-position", this->underline_position);
+ sp_repr_set_svg_double(repr, "underline-thickness", this->underline_thickness);
+ sp_repr_set_svg_double(repr, "strikethrough-position", this->strikethrough_position);
+ sp_repr_set_svg_double(repr, "strikethrough-thickness", this->strikethrough_thickness);
+ sp_repr_set_svg_double(repr, "overline-position", this->overline_position);
+ sp_repr_set_svg_double(repr, "overline-thickness", this->overline_thickness);
+
+ if (repr != this->getRepr()) {
// In all COPY_ATTR given below the XML tree is
// being used directly while it shouldn't be.
- COPY_ATTR(repr, object->getRepr(), "font-family");
- COPY_ATTR(repr, object->getRepr(), "font-style");
- COPY_ATTR(repr, object->getRepr(), "font-variant");
- COPY_ATTR(repr, object->getRepr(), "font-weight");
- COPY_ATTR(repr, object->getRepr(), "font-stretch");
- COPY_ATTR(repr, object->getRepr(), "font-size");
- COPY_ATTR(repr, object->getRepr(), "unicode-range");
- COPY_ATTR(repr, object->getRepr(), "units-per-em");
- COPY_ATTR(repr, object->getRepr(), "panose-1");
- COPY_ATTR(repr, object->getRepr(), "stemv");
- COPY_ATTR(repr, object->getRepr(), "stemh");
- COPY_ATTR(repr, object->getRepr(), "slope");
- COPY_ATTR(repr, object->getRepr(), "cap-height");
- COPY_ATTR(repr, object->getRepr(), "x-height");
- COPY_ATTR(repr, object->getRepr(), "accent-height");
- COPY_ATTR(repr, object->getRepr(), "ascent");
- COPY_ATTR(repr, object->getRepr(), "descent");
- COPY_ATTR(repr, object->getRepr(), "widths");
- COPY_ATTR(repr, object->getRepr(), "bbox");
- COPY_ATTR(repr, object->getRepr(), "ideographic");
- COPY_ATTR(repr, object->getRepr(), "alphabetic");
- COPY_ATTR(repr, object->getRepr(), "mathematical");
- COPY_ATTR(repr, object->getRepr(), "hanging");
- COPY_ATTR(repr, object->getRepr(), "v-ideographic");
- COPY_ATTR(repr, object->getRepr(), "v-alphabetic");
- COPY_ATTR(repr, object->getRepr(), "v-mathematical");
- COPY_ATTR(repr, object->getRepr(), "v-hanging");
- COPY_ATTR(repr, object->getRepr(), "underline-position");
- COPY_ATTR(repr, object->getRepr(), "underline-thickness");
- COPY_ATTR(repr, object->getRepr(), "strikethrough-position");
- COPY_ATTR(repr, object->getRepr(), "strikethrough-thickness");
- COPY_ATTR(repr, object->getRepr(), "overline-position");
- COPY_ATTR(repr, object->getRepr(), "overline-thickness");
+ COPY_ATTR(repr, this->getRepr(), "font-family");
+ COPY_ATTR(repr, this->getRepr(), "font-style");
+ COPY_ATTR(repr, this->getRepr(), "font-variant");
+ COPY_ATTR(repr, this->getRepr(), "font-weight");
+ COPY_ATTR(repr, this->getRepr(), "font-stretch");
+ COPY_ATTR(repr, this->getRepr(), "font-size");
+ COPY_ATTR(repr, this->getRepr(), "unicode-range");
+ COPY_ATTR(repr, this->getRepr(), "units-per-em");
+ COPY_ATTR(repr, this->getRepr(), "panose-1");
+ COPY_ATTR(repr, this->getRepr(), "stemv");
+ COPY_ATTR(repr, this->getRepr(), "stemh");
+ COPY_ATTR(repr, this->getRepr(), "slope");
+ COPY_ATTR(repr, this->getRepr(), "cap-height");
+ COPY_ATTR(repr, this->getRepr(), "x-height");
+ COPY_ATTR(repr, this->getRepr(), "accent-height");
+ COPY_ATTR(repr, this->getRepr(), "ascent");
+ COPY_ATTR(repr, this->getRepr(), "descent");
+ COPY_ATTR(repr, this->getRepr(), "widths");
+ COPY_ATTR(repr, this->getRepr(), "bbox");
+ COPY_ATTR(repr, this->getRepr(), "ideographic");
+ COPY_ATTR(repr, this->getRepr(), "alphabetic");
+ COPY_ATTR(repr, this->getRepr(), "mathematical");
+ COPY_ATTR(repr, this->getRepr(), "hanging");
+ COPY_ATTR(repr, this->getRepr(), "v-ideographic");
+ COPY_ATTR(repr, this->getRepr(), "v-alphabetic");
+ COPY_ATTR(repr, this->getRepr(), "v-mathematical");
+ COPY_ATTR(repr, this->getRepr(), "v-hanging");
+ COPY_ATTR(repr, this->getRepr(), "underline-position");
+ COPY_ATTR(repr, this->getRepr(), "underline-thickness");
+ COPY_ATTR(repr, this->getRepr(), "strikethrough-position");
+ COPY_ATTR(repr, this->getRepr(), "strikethrough-thickness");
+ COPY_ATTR(repr, this->getRepr(), "overline-position");
+ COPY_ATTR(repr, this->getRepr(), "overline-thickness");
}
SPObject::write(xml_doc, repr, flags);
diff --git a/src/sp-font-face.h b/src/sp-font-face.h
index 688f3735e..b119d1079 100644
--- a/src/sp-font-face.h
+++ b/src/sp-font-face.h
@@ -110,6 +110,7 @@ public:
double overline_position;
double overline_thickness;
+protected:
virtual void build(SPDocument* doc, Inkscape::XML::Node* repr);
virtual void release();
diff --git a/src/sp-font.cpp b/src/sp-font.cpp
index b85d25918..4ac3278d7 100644
--- a/src/sp-font.cpp
+++ b/src/sp-font.cpp
@@ -55,32 +55,23 @@ SPFont::~SPFont() {
void SPFont::build(SPDocument *document, Inkscape::XML::Node *repr) {
SPObject::build(document, repr);
- SPFont* object = this;
-
- object->readAttr( "horiz-origin-x" );
- object->readAttr( "horiz-origin-y" );
- object->readAttr( "horiz-adv-x" );
- object->readAttr( "vert-origin-x" );
- object->readAttr( "vert-origin-y" );
- object->readAttr( "vert-adv-y" );
-
- document->addResource("font", object);
-}
-
-static void sp_font_children_modified(SPFont */*sp_font*/)
-{
+ this->readAttr( "horiz-origin-x" );
+ this->readAttr( "horiz-origin-y" );
+ this->readAttr( "horiz-adv-x" );
+ this->readAttr( "vert-origin-x" );
+ this->readAttr( "vert-origin-y" );
+ this->readAttr( "vert-adv-y" );
+
+ document->addResource("font", this);
}
/**
* Callback for child_added event.
*/
void SPFont::child_added(Inkscape::XML::Node *child, Inkscape::XML::Node *ref) {
- SPFont* object = this;
- SPFont *f = SP_FONT(object);
SPObject::child_added(child, ref);
- sp_font_children_modified(f);
- object->parent->requestModified(SP_OBJECT_MODIFIED_FLAG);
+ this->parent->requestModified(SP_OBJECT_MODIFIED_FLAG);
}
@@ -88,81 +79,77 @@ void SPFont::child_added(Inkscape::XML::Node *child, Inkscape::XML::Node *ref) {
* Callback for remove_child event.
*/
void SPFont::remove_child(Inkscape::XML::Node* child) {
- SPFont* object = this;
- SPFont *f = SP_FONT(object);
-
SPObject::remove_child(child);
- sp_font_children_modified(f);
- object->parent->requestModified(SP_OBJECT_MODIFIED_FLAG);
+ this->parent->requestModified(SP_OBJECT_MODIFIED_FLAG);
}
void SPFont::release() {
- //SPFont *font = SP_FONT(object);
- SPFont* object = this;
-
- object->document->removeResource("font", object);
+ this->document->removeResource("font", this);
SPObject::release();
}
void SPFont::set(unsigned int key, const gchar *value) {
- SPFont* object = this;
- SPFont *font = SP_FONT(object);
-
// TODO these are floating point, so some epsilon comparison would be good
switch (key) {
case SP_ATTR_HORIZ_ORIGIN_X:
{
double number = value ? g_ascii_strtod(value, 0) : 0;
- if (number != font->horiz_origin_x){
- font->horiz_origin_x = number;
- object->requestModified(SP_OBJECT_MODIFIED_FLAG);
+
+ if (number != this->horiz_origin_x){
+ this->horiz_origin_x = number;
+ this->requestModified(SP_OBJECT_MODIFIED_FLAG);
}
break;
}
case SP_ATTR_HORIZ_ORIGIN_Y:
{
double number = value ? g_ascii_strtod(value, 0) : 0;
- if (number != font->horiz_origin_y){
- font->horiz_origin_y = number;
- object->requestModified(SP_OBJECT_MODIFIED_FLAG);
+
+ if (number != this->horiz_origin_y){
+ this->horiz_origin_y = number;
+ this->requestModified(SP_OBJECT_MODIFIED_FLAG);
}
break;
}
case SP_ATTR_HORIZ_ADV_X:
{
double number = value ? g_ascii_strtod(value, 0) : FNT_DEFAULT_ADV;
- if (number != font->horiz_adv_x){
- font->horiz_adv_x = number;
- object->requestModified(SP_OBJECT_MODIFIED_FLAG);
+
+ if (number != this->horiz_adv_x){
+ this->horiz_adv_x = number;
+ this->requestModified(SP_OBJECT_MODIFIED_FLAG);
}
break;
}
case SP_ATTR_VERT_ORIGIN_X:
{
double number = value ? g_ascii_strtod(value, 0) : FNT_DEFAULT_ADV / 2.0;
- if (number != font->vert_origin_x){
- font->vert_origin_x = number;
- object->requestModified(SP_OBJECT_MODIFIED_FLAG);
+
+ if (number != this->vert_origin_x){
+ this->vert_origin_x = number;
+ this->requestModified(SP_OBJECT_MODIFIED_FLAG);
}
break;
}
case SP_ATTR_VERT_ORIGIN_Y:
{
double number = value ? g_ascii_strtod(value, 0) : FNT_DEFAULT_ASCENT;
- if (number != font->vert_origin_y){
- font->vert_origin_y = number;
- object->requestModified(SP_OBJECT_MODIFIED_FLAG);
+
+ if (number != this->vert_origin_y){
+ this->vert_origin_y = number;
+ this->requestModified(SP_OBJECT_MODIFIED_FLAG);
}
break;
}
case SP_ATTR_VERT_ADV_Y:
{
double number = value ? g_ascii_strtod(value, 0) : FNT_UNITS_PER_EM;
- if (number != font->vert_adv_y){
- font->vert_adv_y = number;
- object->requestModified(SP_OBJECT_MODIFIED_FLAG);
+
+ if (number != this->vert_adv_y){
+ this->vert_adv_y = number;
+ this->requestModified(SP_OBJECT_MODIFIED_FLAG);
}
break;
}
@@ -176,15 +163,13 @@ void SPFont::set(unsigned int key, const gchar *value) {
* Receives update notifications.
*/
void SPFont::update(SPCtx *ctx, guint flags) {
- SPFont* object = this;
-
if (flags & (SP_OBJECT_MODIFIED_FLAG)) {
- object->readAttr( "horiz-origin-x" );
- object->readAttr( "horiz-origin-y" );
- object->readAttr( "horiz-adv-x" );
- object->readAttr( "vert-origin-x" );
- object->readAttr( "vert-origin-y" );
- object->readAttr( "vert-adv-y" );
+ this->readAttr( "horiz-origin-x" );
+ this->readAttr( "horiz-origin-y" );
+ this->readAttr( "horiz-adv-x" );
+ this->readAttr( "vert-origin-x" );
+ this->readAttr( "vert-origin-y" );
+ this->readAttr( "vert-adv-y" );
}
SPObject::update(ctx, flags);
@@ -193,29 +178,26 @@ void SPFont::update(SPCtx *ctx, guint flags) {
#define COPY_ATTR(rd,rs,key) (rd)->setAttribute((key), rs->attribute(key));
Inkscape::XML::Node* SPFont::write(Inkscape::XML::Document *xml_doc, Inkscape::XML::Node *repr, guint flags) {
- SPFont* object = this;
- SPFont *font = SP_FONT(object);
-
if ((flags & SP_OBJECT_WRITE_BUILD) && !repr) {
- repr = xml_doc->createElement("svg:font");
+ repr = xml_doc->createElement("svg:this");
}
- sp_repr_set_svg_double(repr, "horiz-origin-x", font->horiz_origin_x);
- sp_repr_set_svg_double(repr, "horiz-origin-y", font->horiz_origin_y);
- sp_repr_set_svg_double(repr, "horiz-adv-x", font->horiz_adv_x);
- sp_repr_set_svg_double(repr, "vert-origin-x", font->vert_origin_x);
- sp_repr_set_svg_double(repr, "vert-origin-y", font->vert_origin_y);
- sp_repr_set_svg_double(repr, "vert-adv-y", font->vert_adv_y);
+ sp_repr_set_svg_double(repr, "horiz-origin-x", this->horiz_origin_x);
+ sp_repr_set_svg_double(repr, "horiz-origin-y", this->horiz_origin_y);
+ sp_repr_set_svg_double(repr, "horiz-adv-x", this->horiz_adv_x);
+ sp_repr_set_svg_double(repr, "vert-origin-x", this->vert_origin_x);
+ sp_repr_set_svg_double(repr, "vert-origin-y", this->vert_origin_y);
+ sp_repr_set_svg_double(repr, "vert-adv-y", this->vert_adv_y);
- if (repr != object->getRepr()) {
+ if (repr != this->getRepr()) {
// All the below COPY_ATTR funtions are directly using
// the XML Tree while they shouldn't
- COPY_ATTR(repr, object->getRepr(), "horiz-origin-x");
- COPY_ATTR(repr, object->getRepr(), "horiz-origin-y");
- COPY_ATTR(repr, object->getRepr(), "horiz-adv-x");
- COPY_ATTR(repr, object->getRepr(), "vert-origin-x");
- COPY_ATTR(repr, object->getRepr(), "vert-origin-y");
- COPY_ATTR(repr, object->getRepr(), "vert-adv-y");
+ COPY_ATTR(repr, this->getRepr(), "horiz-origin-x");
+ COPY_ATTR(repr, this->getRepr(), "horiz-origin-y");
+ COPY_ATTR(repr, this->getRepr(), "horiz-adv-x");
+ COPY_ATTR(repr, this->getRepr(), "vert-origin-x");
+ COPY_ATTR(repr, this->getRepr(), "vert-origin-y");
+ COPY_ATTR(repr, this->getRepr(), "vert-adv-y");
}
SPObject::write(xml_doc, repr, flags);
diff --git a/src/sp-font.h b/src/sp-font.h
index f88d522eb..cbc63b69d 100644
--- a/src/sp-font.h
+++ b/src/sp-font.h
@@ -33,6 +33,7 @@ public:
double vert_origin_y;
double vert_adv_y;
+protected:
virtual void build(SPDocument* doc, Inkscape::XML::Node* repr);
virtual void release();
diff --git a/src/sp-glyph-kerning.cpp b/src/sp-glyph-kerning.cpp
index 287ade4b8..be47c7621 100644
--- a/src/sp-glyph-kerning.cpp
+++ b/src/sp-glyph-kerning.cpp
@@ -39,15 +39,13 @@ SPGlyphKerning::~SPGlyphKerning() {
}
void SPGlyphKerning::build(SPDocument *document, Inkscape::XML::Node *repr) {
- SPGlyphKerning* object = this;
-
SPObject::build(document, repr);
- object->readAttr( "u1" );
- object->readAttr( "g1" );
- object->readAttr( "u2" );
- object->readAttr( "g2" );
- object->readAttr( "k" );
+ this->readAttr( "u1" );
+ this->readAttr( "g1" );
+ this->readAttr( "u2" );
+ this->readAttr( "g2" );
+ this->readAttr( "k" );
}
void SPGlyphKerning::release() {
@@ -55,72 +53,84 @@ void SPGlyphKerning::release() {
}
GlyphNames::GlyphNames(const gchar* value){
- if (value) this->names = strdup(value);
+ if (value) {
+ this->names = strdup(value);
+ }
}
GlyphNames::~GlyphNames(){
- if (this->names) g_free(this->names);
+ if (this->names) {
+ g_free(this->names);
+ }
}
bool GlyphNames::contains(const char* name){
- if (!(this->names) || !name) return false;
+ if (!(this->names) || !name) {
+ return false;
+ }
+
std::istringstream is(this->names);
std::string str;
std::string s(name);
- while (is >> str){
- if (str == s) return true;
+
+ while (is >> str) {
+ if (str == s) {
+ return true;
+ }
}
+
return false;
}
void SPGlyphKerning::set(unsigned int key, const gchar *value) {
- SPGlyphKerning* object = this;
-
- SPGlyphKerning * glyphkern = (SPGlyphKerning*) object; //even if it is a VKern this will work. I did it this way just to avoind warnings.
-
switch (key) {
case SP_ATTR_U1:
{
- if (glyphkern->u1) {
- delete glyphkern->u1;
+ if (this->u1) {
+ delete this->u1;
}
- glyphkern->u1 = new UnicodeRange(value);
- object->requestModified(SP_OBJECT_MODIFIED_FLAG);
+
+ this->u1 = new UnicodeRange(value);
+ this->requestModified(SP_OBJECT_MODIFIED_FLAG);
break;
}
case SP_ATTR_U2:
{
- if (glyphkern->u2) {
- delete glyphkern->u2;
+ if (this->u2) {
+ delete this->u2;
}
- glyphkern->u2 = new UnicodeRange(value);
- object->requestModified(SP_OBJECT_MODIFIED_FLAG);
+
+ this->u2 = new UnicodeRange(value);
+ this->requestModified(SP_OBJECT_MODIFIED_FLAG);
break;
}
case SP_ATTR_G1:
{
- if (glyphkern->g1) {
- delete glyphkern->g1;
+ if (this->g1) {
+ delete this->g1;
}
- glyphkern->g1 = new GlyphNames(value);
- object->requestModified(SP_OBJECT_MODIFIED_FLAG);
+
+ this->g1 = new GlyphNames(value);
+ this->requestModified(SP_OBJECT_MODIFIED_FLAG);
break;
}
case SP_ATTR_G2:
{
- if (glyphkern->g2) {
- delete glyphkern->g2;
+ if (this->g2) {
+ delete this->g2;
}
- glyphkern->g2 = new GlyphNames(value);
- object->requestModified(SP_OBJECT_MODIFIED_FLAG);
+
+ this->g2 = new GlyphNames(value);
+ this->requestModified(SP_OBJECT_MODIFIED_FLAG);
break;
}
case SP_ATTR_K:
{
double number = value ? g_ascii_strtod(value, 0) : 0;
- if (number != glyphkern->k){
- glyphkern->k = number;
- object->requestModified(SP_OBJECT_MODIFIED_FLAG);
+
+ if (number != this->k){
+ this->k = number;
+ this->requestModified(SP_OBJECT_MODIFIED_FLAG);
}
break;
}
@@ -136,17 +146,12 @@ void SPGlyphKerning::set(unsigned int key, const gchar *value) {
* * Receives update notifications.
* */
void SPGlyphKerning::update(SPCtx *ctx, guint flags) {
- SPGlyphKerning* object = this;
-
- SPGlyphKerning *glyph = (SPGlyphKerning *)object;
- (void)glyph;
-
if (flags & SP_OBJECT_MODIFIED_FLAG) {
/* do something to trigger redisplay, updates? */
- object->readAttr( "u1" );
- object->readAttr( "u2" );
- object->readAttr( "g2" );
- object->readAttr( "k" );
+ this->readAttr( "u1" );
+ this->readAttr( "u2" );
+ this->readAttr( "g2" );
+ this->readAttr( "k" );
}
SPObject::update(ctx, flags);
@@ -155,13 +160,9 @@ void SPGlyphKerning::update(SPCtx *ctx, guint flags) {
#define COPY_ATTR(rd,rs,key) (rd)->setAttribute((key), rs->attribute(key));
Inkscape::XML::Node* SPGlyphKerning::write(Inkscape::XML::Document *xml_doc, Inkscape::XML::Node *repr, guint flags) {
- SPGlyphKerning* object = this;
-
- // SPGlyphKerning *glyph = SP_GLYPH_KERNING(object);
-
- if ((flags & SP_OBJECT_WRITE_BUILD) && !repr) {
- repr = xml_doc->createElement("svg:glyphkerning");//fix this!
- }
+ if ((flags & SP_OBJECT_WRITE_BUILD) && !repr) {
+ repr = xml_doc->createElement("svg:glyphkerning");//fix this!
+ }
/* I am commenting out this part because I am not certain how does it work. I will have to study it later. Juca
repr->setAttribute("unicode", glyph->unicode);
@@ -175,19 +176,19 @@ Inkscape::XML::Node* SPGlyphKerning::write(Inkscape::XML::Document *xml_doc, Ink
sp_repr_set_svg_double(repr, "vert-origin-y", glyph->vert_origin_y);
sp_repr_set_svg_double(repr, "vert-adv-y", glyph->vert_adv_y);
*/
- if (repr != object->getRepr()) {
- // All the COPY_ATTR functions below use
- // XML Tree directly, while they shouldn't.
- COPY_ATTR(repr, object->getRepr(), "u1");
- COPY_ATTR(repr, object->getRepr(), "g1");
- COPY_ATTR(repr, object->getRepr(), "u2");
- COPY_ATTR(repr, object->getRepr(), "g2");
- COPY_ATTR(repr, object->getRepr(), "k");
- }
-
- SPObject::write(xml_doc, repr, flags);
-
- return repr;
+ if (repr != this->getRepr()) {
+ // All the COPY_ATTR functions below use
+ // XML Tree directly, while they shouldn't.
+ COPY_ATTR(repr, this->getRepr(), "u1");
+ COPY_ATTR(repr, this->getRepr(), "g1");
+ COPY_ATTR(repr, this->getRepr(), "u2");
+ COPY_ATTR(repr, this->getRepr(), "g2");
+ COPY_ATTR(repr, this->getRepr(), "k");
+ }
+
+ SPObject::write(xml_doc, repr, flags);
+
+ return repr;
}
/*
Local Variables:
diff --git a/src/sp-glyph-kerning.h b/src/sp-glyph-kerning.h
index b805c353a..b579e5e2e 100644
--- a/src/sp-glyph-kerning.h
+++ b/src/sp-glyph-kerning.h
@@ -57,6 +57,7 @@ public:
GlyphNames* g2;
double k;
+protected:
virtual void build(SPDocument* doc, Inkscape::XML::Node* repr);
virtual void release();
diff --git a/src/sp-glyph.cpp b/src/sp-glyph.cpp
index f18c3ef6d..695af03ba 100644
--- a/src/sp-glyph.cpp
+++ b/src/sp-glyph.cpp
@@ -35,8 +35,6 @@ namespace {
SPGlyph::SPGlyph() : SPObject() {
//TODO: correct these values:
- new (&this->unicode) Glib::ustring();
- new (&this->glyph_name) Glib::ustring();
this->d = NULL;
this->orientation = GLYPH_ORIENTATION_BOTH;
this->arabic_form = GLYPH_ARABIC_FORM_INITIAL;
@@ -53,18 +51,16 @@ SPGlyph::~SPGlyph() {
void SPGlyph::build(SPDocument *document, Inkscape::XML::Node *repr) {
SPObject::build(document, repr);
- SPGlyph* object = this;
-
- object->readAttr( "unicode" );
- object->readAttr( "glyph-name" );
- object->readAttr( "d" );
- object->readAttr( "orientation" );
- object->readAttr( "arabic-form" );
- object->readAttr( "lang" );
- object->readAttr( "horiz-adv-x" );
- object->readAttr( "vert-origin-x" );
- object->readAttr( "vert-origin-y" );
- object->readAttr( "vert-adv-y" );
+ this->readAttr( "unicode" );
+ this->readAttr( "glyph-name" );
+ this->readAttr( "d" );
+ this->readAttr( "orientation" );
+ this->readAttr( "arabic-form" );
+ this->readAttr( "lang" );
+ this->readAttr( "horiz-adv-x" );
+ this->readAttr( "vert-origin-x" );
+ this->readAttr( "vert-origin-y" );
+ this->readAttr( "vert-adv-y" );
}
void SPGlyph::release() {
@@ -72,24 +68,40 @@ void SPGlyph::release() {
}
static glyphArabicForm sp_glyph_read_arabic_form(gchar const *value){
- if (!value) return GLYPH_ARABIC_FORM_INITIAL; //TODO: verify which is the default default (for me, the spec is not clear)
+ if (!value) {
+ return GLYPH_ARABIC_FORM_INITIAL; //TODO: verify which is the default default (for me, the spec is not clear)
+ }
+
switch(value[0]){
case 'i':
- if (strncmp(value, "initial", 7) == 0) return GLYPH_ARABIC_FORM_INITIAL;
- if (strncmp(value, "isolated", 8) == 0) return GLYPH_ARABIC_FORM_ISOLATED;
+ if (strncmp(value, "initial", 7) == 0) {
+ return GLYPH_ARABIC_FORM_INITIAL;
+ }
+
+ if (strncmp(value, "isolated", 8) == 0) {
+ return GLYPH_ARABIC_FORM_ISOLATED;
+ }
break;
case 'm':
- if (strncmp(value, "medial", 6) == 0) return GLYPH_ARABIC_FORM_MEDIAL;
+ if (strncmp(value, "medial", 6) == 0) {
+ return GLYPH_ARABIC_FORM_MEDIAL;
+ }
break;
case 't':
- if (strncmp(value, "terminal", 8) == 0) return GLYPH_ARABIC_FORM_TERMINAL;
+ if (strncmp(value, "terminal", 8) == 0) {
+ return GLYPH_ARABIC_FORM_TERMINAL;
+ }
break;
}
+
return GLYPH_ARABIC_FORM_INITIAL; //TODO: VERIFY DEFAULT!
}
static glyphOrientation sp_glyph_read_orientation(gchar const *value){
- if (!value) return GLYPH_ORIENTATION_BOTH;
+ if (!value) {
+ return GLYPH_ORIENTATION_BOTH;
+ }
+
switch(value[0]){
case 'h':
return GLYPH_ORIENTATION_HORIZONTAL;
@@ -98,95 +110,112 @@ static glyphOrientation sp_glyph_read_orientation(gchar const *value){
return GLYPH_ORIENTATION_VERTICAL;
break;
}
+
//ERROR? TODO: VERIFY PROPER ERROR HANDLING
return GLYPH_ORIENTATION_BOTH;
}
void SPGlyph::set(unsigned int key, const gchar *value) {
- SPGlyph* object = this;
-
- SPGlyph *glyph = SP_GLYPH(object);
-
switch (key) {
case SP_ATTR_UNICODE:
{
- glyph->unicode.clear();
- if (value) glyph->unicode.append(value);
- object->requestModified(SP_OBJECT_MODIFIED_FLAG);
+ this->unicode.clear();
+
+ if (value) {
+ this->unicode.append(value);
+ }
+
+ this->requestModified(SP_OBJECT_MODIFIED_FLAG);
break;
}
case SP_ATTR_GLYPH_NAME:
{
- glyph->glyph_name.clear();
- if (value) glyph->glyph_name.append(value);
- object->requestModified(SP_OBJECT_MODIFIED_FLAG);
+ this->glyph_name.clear();
+
+ if (value) {
+ this->glyph_name.append(value);
+ }
+
+ this->requestModified(SP_OBJECT_MODIFIED_FLAG);
break;
}
case SP_ATTR_D:
{
- if (glyph->d) g_free(glyph->d);
- glyph->d = g_strdup(value);
- object->requestModified(SP_OBJECT_MODIFIED_FLAG);
+ if (this->d) {
+ g_free(this->d);
+ }
+
+ this->d = g_strdup(value);
+ this->requestModified(SP_OBJECT_MODIFIED_FLAG);
break;
}
case SP_ATTR_ORIENTATION:
{
glyphOrientation orient = sp_glyph_read_orientation(value);
- if (glyph->orientation != orient){
- glyph->orientation = orient;
- object->requestModified(SP_OBJECT_MODIFIED_FLAG);
+
+ if (this->orientation != orient){
+ this->orientation = orient;
+ this->requestModified(SP_OBJECT_MODIFIED_FLAG);
}
break;
}
case SP_ATTR_ARABIC_FORM:
{
glyphArabicForm form = sp_glyph_read_arabic_form(value);
- if (glyph->arabic_form != form){
- glyph->arabic_form = form;
- object->requestModified(SP_OBJECT_MODIFIED_FLAG);
+
+ if (this->arabic_form != form){
+ this->arabic_form = form;
+ this->requestModified(SP_OBJECT_MODIFIED_FLAG);
}
break;
}
case SP_ATTR_LANG:
{
- if (glyph->lang) g_free(glyph->lang);
- glyph->lang = g_strdup(value);
- object->requestModified(SP_OBJECT_MODIFIED_FLAG);
+ if (this->lang) {
+ g_free(this->lang);
+ }
+
+ this->lang = g_strdup(value);
+ this->requestModified(SP_OBJECT_MODIFIED_FLAG);
break;
}
case SP_ATTR_HORIZ_ADV_X:
{
double number = value ? g_ascii_strtod(value, 0) : 0;
- if (number != glyph->horiz_adv_x){
- glyph->horiz_adv_x = number;
- object->requestModified(SP_OBJECT_MODIFIED_FLAG);
+
+ if (number != this->horiz_adv_x){
+ this->horiz_adv_x = number;
+ this->requestModified(SP_OBJECT_MODIFIED_FLAG);
}
break;
}
case SP_ATTR_VERT_ORIGIN_X:
{
double number = value ? g_ascii_strtod(value, 0) : 0;
- if (number != glyph->vert_origin_x){
- glyph->vert_origin_x = number;
- object->requestModified(SP_OBJECT_MODIFIED_FLAG);
+
+ if (number != this->vert_origin_x){
+ this->vert_origin_x = number;
+ this->requestModified(SP_OBJECT_MODIFIED_FLAG);
}
break;
}
case SP_ATTR_VERT_ORIGIN_Y:
{
double number = value ? g_ascii_strtod(value, 0) : 0;
- if (number != glyph->vert_origin_y){
- glyph->vert_origin_y = number;
- object->requestModified(SP_OBJECT_MODIFIED_FLAG);
+
+ if (number != this->vert_origin_y){
+ this->vert_origin_y = number;
+ this->requestModified(SP_OBJECT_MODIFIED_FLAG);
}
break;
}
case SP_ATTR_VERT_ADV_Y:
{
double number = value ? g_ascii_strtod(value, 0) : 0;
- if (number != glyph->vert_adv_y){
- glyph->vert_adv_y = number;
- object->requestModified(SP_OBJECT_MODIFIED_FLAG);
+
+ if (number != this->vert_adv_y){
+ this->vert_adv_y = number;
+ this->requestModified(SP_OBJECT_MODIFIED_FLAG);
}
break;
}
@@ -202,23 +231,18 @@ void SPGlyph::set(unsigned int key, const gchar *value) {
* * Receives update notifications.
* */
void SPGlyph::update(SPCtx *ctx, guint flags) {
- SPGlyph* object = this;
-
- SPGlyph *glyph = SP_GLYPH(object);
- (void)glyph;
-
if (flags & SP_OBJECT_MODIFIED_FLAG) {
/* do something to trigger redisplay, updates? */
- object->readAttr( "unicode" );
- object->readAttr( "glyph-name" );
- object->readAttr( "d" );
- object->readAttr( "orientation" );
- object->readAttr( "arabic-form" );
- object->readAttr( "lang" );
- object->readAttr( "horiz-adv-x" );
- object->readAttr( "vert-origin-x" );
- object->readAttr( "vert-origin-y" );
- object->readAttr( "vert-adv-y" );
+ this->readAttr( "unicode" );
+ this->readAttr( "glyph-name" );
+ this->readAttr( "d" );
+ this->readAttr( "orientation" );
+ this->readAttr( "arabic-form" );
+ this->readAttr( "lang" );
+ this->readAttr( "horiz-adv-x" );
+ this->readAttr( "vert-origin-x" );
+ this->readAttr( "vert-origin-y" );
+ this->readAttr( "vert-adv-y" );
}
SPObject::update(ctx, flags);
@@ -227,13 +251,9 @@ void SPGlyph::update(SPCtx *ctx, guint flags) {
#define COPY_ATTR(rd,rs,key) (rd)->setAttribute((key), rs->attribute(key));
Inkscape::XML::Node* SPGlyph::write(Inkscape::XML::Document *xml_doc, Inkscape::XML::Node *repr, guint flags) {
- SPGlyph* object = this;
-
- // SPGlyph *glyph = SP_GLYPH(object);
-
- if ((flags & SP_OBJECT_WRITE_BUILD) && !repr) {
- repr = xml_doc->createElement("svg:glyph");
- }
+ if ((flags & SP_OBJECT_WRITE_BUILD) && !repr) {
+ repr = xml_doc->createElement("svg:glyph");
+ }
/* I am commenting out this part because I am not certain how does it work. I will have to study it later. Juca
repr->setAttribute("unicode", glyph->unicode);
@@ -247,24 +267,24 @@ Inkscape::XML::Node* SPGlyph::write(Inkscape::XML::Document *xml_doc, Inkscape::
sp_repr_set_svg_double(repr, "vert-origin-y", glyph->vert_origin_y);
sp_repr_set_svg_double(repr, "vert-adv-y", glyph->vert_adv_y);
*/
- if (repr != object->getRepr()) {
- // All the COPY_ATTR functions below use
- // XML Tree directly while they shouldn't.
- COPY_ATTR(repr, object->getRepr(), "unicode");
- COPY_ATTR(repr, object->getRepr(), "glyph-name");
- COPY_ATTR(repr, object->getRepr(), "d");
- COPY_ATTR(repr, object->getRepr(), "orientation");
- COPY_ATTR(repr, object->getRepr(), "arabic-form");
- COPY_ATTR(repr, object->getRepr(), "lang");
- COPY_ATTR(repr, object->getRepr(), "horiz-adv-x");
- COPY_ATTR(repr, object->getRepr(), "vert-origin-x");
- COPY_ATTR(repr, object->getRepr(), "vert-origin-y");
- COPY_ATTR(repr, object->getRepr(), "vert-adv-y");
- }
+ if (repr != this->getRepr()) {
+ // All the COPY_ATTR functions below use
+ // XML Tree directly while they shouldn't.
+ COPY_ATTR(repr, this->getRepr(), "unicode");
+ COPY_ATTR(repr, this->getRepr(), "glyph-name");
+ COPY_ATTR(repr, this->getRepr(), "d");
+ COPY_ATTR(repr, this->getRepr(), "orientation");
+ COPY_ATTR(repr, this->getRepr(), "arabic-form");
+ COPY_ATTR(repr, this->getRepr(), "lang");
+ COPY_ATTR(repr, this->getRepr(), "horiz-adv-x");
+ COPY_ATTR(repr, this->getRepr(), "vert-origin-x");
+ COPY_ATTR(repr, this->getRepr(), "vert-origin-y");
+ COPY_ATTR(repr, this->getRepr(), "vert-adv-y");
+ }
- SPObject::write(xml_doc, repr, flags);
+ SPObject::write(xml_doc, repr, flags);
- return repr;
+ return repr;
}
/*
Local Variables:
diff --git a/src/sp-glyph.h b/src/sp-glyph.h
index fbb3aa2ff..79ed256e9 100644
--- a/src/sp-glyph.h
+++ b/src/sp-glyph.h
@@ -50,6 +50,7 @@ public:
double vert_origin_y;
double vert_adv_y;
+protected:
virtual void build(SPDocument* doc, Inkscape::XML::Node* repr);
virtual void release();
diff --git a/src/sp-guide.cpp b/src/sp-guide.cpp
index 4fc6e34bb..b0f4aab49 100644
--- a/src/sp-guide.cpp
+++ b/src/sp-guide.cpp
@@ -139,54 +139,46 @@ static void sp_guide_get_property(GObject *object, guint prop_id, GValue *value,
void SPGuide::build(SPDocument *document, Inkscape::XML::Node *repr) {
SPObject::build(document, repr);
- SPGuide* object = this;
-
- object->readAttr( "inkscape:label" );
- object->readAttr( "orientation" );
- object->readAttr( "position" );
+ this->readAttr( "inkscape:label" );
+ this->readAttr( "orientation" );
+ this->readAttr( "position" );
/* Register */
- document->addResource("guide", object);
+ document->addResource("guide", this);
}
void SPGuide::release() {
- SPGuide* object = this;
- SPGuide *guide = (SPGuide *) object;
-
- while (guide->views) {
- sp_guideline_delete(SP_GUIDELINE(guide->views->data));
- guide->views = g_slist_remove(guide->views, guide->views->data);
+ while (this->views) {
+ sp_guideline_delete(SP_GUIDELINE(this->views->data));
+ this->views = g_slist_remove(this->views, this->views->data);
}
- if (object->document) {
+ if (this->document) {
// Unregister ourselves
- object->document->removeResource("guide", object);
+ this->document->removeResource("guide", this);
}
SPObject::release();
}
void SPGuide::set(unsigned int key, const gchar *value) {
- SPGuide* object = this;
- SPGuide *guide = SP_GUIDE(object);
-
switch (key) {
case SP_ATTR_INKSCAPE_LABEL:
if (value) {
- guide->label = g_strdup(value);
+ this->label = g_strdup(value);
} else {
- guide->label = NULL;
+ this->label = NULL;
}
- sp_guide_set_label(*guide, guide->label, false);
+ sp_guide_set_label(*this, this->label, false);
break;
case SP_ATTR_ORIENTATION:
{
if (value && !strcmp(value, "horizontal")) {
/* Visual representation of a horizontal line, constrain vertically (y coordinate). */
- guide->normal_to_line = Geom::Point(0., 1.);
+ this->normal_to_line = Geom::Point(0., 1.);
} else if (value && !strcmp(value, "vertical")) {
- guide->normal_to_line = Geom::Point(1., 0.);
+ this->normal_to_line = Geom::Point(1., 0.);
} else if (value) {
gchar ** strarray = g_strsplit(value, ",", 2);
double newx, newy;
@@ -196,16 +188,16 @@ void SPGuide::set(unsigned int key, const gchar *value) {
if (success == 2 && (fabs(newx) > 1e-6 || fabs(newy) > 1e-6)) {
Geom::Point direction(newx, newy);
direction.normalize();
- guide->normal_to_line = direction;
+ this->normal_to_line = direction;
} else {
// default to vertical line for bad arguments
- guide->normal_to_line = Geom::Point(1., 0.);
+ this->normal_to_line = Geom::Point(1., 0.);
}
} else {
// default to vertical line for bad arguments
- guide->normal_to_line = Geom::Point(1., 0.);
+ this->normal_to_line = Geom::Point(1., 0.);
}
- sp_guide_set_normal(*guide, guide->normal_to_line, false);
+ sp_guide_set_normal(*this, this->normal_to_line, false);
}
break;
case SP_ATTR_POSITION:
@@ -217,23 +209,23 @@ void SPGuide::set(unsigned int key, const gchar *value) {
success += sp_svg_number_read_d(strarray[1], &newy);
g_strfreev (strarray);
if (success == 2) {
- guide->point_on_line = Geom::Point(newx, newy);
+ this->point_on_line = Geom::Point(newx, newy);
} else if (success == 1) {
// before 0.46 style guideline definition.
- const gchar *attr = object->getRepr()->attribute("orientation");
+ const gchar *attr = this->getRepr()->attribute("orientation");
if (attr && !strcmp(attr, "horizontal")) {
- guide->point_on_line = Geom::Point(0, newx);
+ this->point_on_line = Geom::Point(0, newx);
} else {
- guide->point_on_line = Geom::Point(newx, 0);
+ this->point_on_line = Geom::Point(newx, 0);
}
}
} else {
// default to (0,0) for bad arguments
- guide->point_on_line = Geom::Point(0,0);
+ this->point_on_line = Geom::Point(0,0);
}
// update position in non-committing way
// fixme: perhaps we need to add an update method instead, and request_update here
- sp_guide_moveto(*guide, guide->point_on_line, false);
+ sp_guide_moveto(*this, this->point_on_line, false);
}
break;
default:
diff --git a/src/sp-guide.h b/src/sp-guide.h
index 748420d40..18e07d719 100644
--- a/src/sp-guide.h
+++ b/src/sp-guide.h
@@ -51,6 +51,7 @@ public:
Geom::Point getPositionFrom(Geom::Point const &pt) const;
double getDistanceFrom(Geom::Point const &pt) const;
+protected:
virtual void build(SPDocument* doc, Inkscape::XML::Node* repr);
virtual void release();
virtual void set(unsigned int key, const gchar* value);