From 4569747878f930a0992a2b089460f3f8cdcb39c5 Mon Sep 17 00:00:00 2001 From: Alex Valavanis Date: Wed, 23 Jan 2013 12:22:14 +0000 Subject: Clean up more GObject type definitions (bzr r12055) --- src/sp-font-face.cpp | 60 +++++++++++++--------------------------------------- 1 file changed, 15 insertions(+), 45 deletions(-) (limited to 'src/sp-font-face.cpp') diff --git a/src/sp-font-face.cpp b/src/sp-font-face.cpp index e9faabdc6..4288a5d64 100644 --- a/src/sp-font-face.cpp +++ b/src/sp-font-face.cpp @@ -261,9 +261,6 @@ static std::vector sp_read_fontFaceStretchType(gchar const return v; } -static void sp_fontface_class_init(SPFontFaceClass *fc); -static void sp_fontface_init(SPFontFace *font); - static void sp_fontface_build(SPObject *object, SPDocument *document, Inkscape::XML::Node *repr); static void sp_fontface_release(SPObject *object); static void sp_fontface_set(SPObject *object, unsigned int key, const gchar *value); @@ -273,37 +270,12 @@ static void sp_fontface_child_added(SPObject *object, Inkscape::XML::Node *child static void sp_fontface_remove_child(SPObject *object, Inkscape::XML::Node *child); static void sp_fontface_update(SPObject *object, SPCtx *ctx, guint flags); -static SPObjectClass *parent_class; - -GType sp_fontface_get_type(void) -{ - static GType type = 0; - - if (!type) { - GTypeInfo info = { - sizeof(SPFontFaceClass), - NULL, /* base_init */ - NULL, /* base_finalize */ - (GClassInitFunc) sp_fontface_class_init, - NULL, /* class_finalize */ - NULL, /* class_data */ - sizeof(SPFontFace), - 16, /* n_preallocs */ - (GInstanceInitFunc) sp_fontface_init, - NULL, /* value_table */ - }; - type = g_type_register_static(SP_TYPE_OBJECT, "SPFontFace", &info, (GTypeFlags) 0); - } - - return type; -} +G_DEFINE_TYPE(SPFontFace, sp_fontface, SP_TYPE_OBJECT); static void sp_fontface_class_init(SPFontFaceClass *fc) { SPObjectClass *sp_object_class = (SPObjectClass *) fc; - parent_class = (SPObjectClass *) g_type_class_ref(SP_TYPE_OBJECT); - sp_object_class->build = sp_fontface_build; sp_object_class->release = sp_fontface_release; sp_object_class->set = sp_fontface_set; @@ -369,8 +341,8 @@ static void sp_fontface_init(SPFontFace *face) static void sp_fontface_build(SPObject *object, SPDocument *document, Inkscape::XML::Node *repr) { - if (((SPObjectClass *) (parent_class))->build) { - ((SPObjectClass *) (parent_class))->build(object, document, repr); + if ((SP_OBJECT_CLASS(sp_fontface_parent_class))->build) { + (SP_OBJECT_CLASS(sp_fontface_parent_class))->build(object, document, repr); } object->readAttr( "font-family" ); @@ -420,8 +392,8 @@ sp_fontface_child_added(SPObject *object, Inkscape::XML::Node *child, Inkscape:: { SPFontFace *f = SP_FONTFACE(object); - if (((SPObjectClass *) parent_class)->child_added) - (* ((SPObjectClass *) parent_class)->child_added)(object, child, ref); + if ((SP_OBJECT_CLASS(sp_fontface_parent_class))->child_added) + (* (SP_OBJECT_CLASS(sp_fontface_parent_class))->child_added)(object, child, ref); sp_fontface_children_modified(f); object->parent->requestModified(SP_OBJECT_MODIFIED_FLAG); @@ -436,8 +408,8 @@ sp_fontface_remove_child(SPObject *object, Inkscape::XML::Node *child) { SPFontFace *f = SP_FONTFACE(object); - if (((SPObjectClass *) parent_class)->remove_child) - (* ((SPObjectClass *) parent_class)->remove_child)(object, child); + if ((SP_OBJECT_CLASS(sp_fontface_parent_class))->remove_child) + (* (SP_OBJECT_CLASS(sp_fontface_parent_class))->remove_child)(object, child); sp_fontface_children_modified(f); object->parent->requestModified(SP_OBJECT_MODIFIED_FLAG); @@ -445,10 +417,8 @@ sp_fontface_remove_child(SPObject *object, Inkscape::XML::Node *child) static void sp_fontface_release(SPObject *object) { - //SPFontFace *font = SP_FONTFACE(object); - - if (((SPObjectClass *) parent_class)->release) { - ((SPObjectClass *) parent_class)->release(object); + if ((SP_OBJECT_CLASS(sp_fontface_parent_class))->release) { + (SP_OBJECT_CLASS(sp_fontface_parent_class))->release(object); } } @@ -736,8 +706,8 @@ static void sp_fontface_set(SPObject *object, unsigned int key, const gchar *val break; } default: - if (((SPObjectClass *) (parent_class))->set) { - ((SPObjectClass *) (parent_class))->set(object, key, value); + if ((SP_OBJECT_CLASS(sp_fontface_parent_class))->set) { + (SP_OBJECT_CLASS(sp_fontface_parent_class))->set(object, key, value); } break; } @@ -785,8 +755,8 @@ sp_fontface_update(SPObject *object, SPCtx *ctx, guint flags) object->readAttr( "overline-thickness" ); } - if (((SPObjectClass *) parent_class)->update) { - ((SPObjectClass *) parent_class)->update(object, ctx, flags); + if ((SP_OBJECT_CLASS(sp_fontface_parent_class))->update) { + (SP_OBJECT_CLASS(sp_fontface_parent_class))->update(object, ctx, flags); } } @@ -873,8 +843,8 @@ static Inkscape::XML::Node *sp_fontface_write(SPObject *object, Inkscape::XML::D COPY_ATTR(repr, object->getRepr(), "overline-thickness"); } - if (((SPObjectClass *) (parent_class))->write) { - ((SPObjectClass *) (parent_class))->write(object, xml_doc, repr, flags); + if ((SP_OBJECT_CLASS(sp_fontface_parent_class))->write) { + (SP_OBJECT_CLASS(sp_fontface_parent_class))->write(object, xml_doc, repr, flags); } return repr; -- cgit v1.2.3 From a0a8d020201e0e38a63d9aa3dce228d7d9e6fb35 Mon Sep 17 00:00:00 2001 From: Markus Engel Date: Thu, 14 Mar 2013 12:42:39 +0100 Subject: Various changes. (bzr r11608.1.48) --- src/sp-font-face.cpp | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) (limited to 'src/sp-font-face.cpp') diff --git a/src/sp-font-face.cpp b/src/sp-font-face.cpp index e9faabdc6..6ca8f850c 100644 --- a/src/sp-font-face.cpp +++ b/src/sp-font-face.cpp @@ -304,7 +304,7 @@ static void sp_fontface_class_init(SPFontFaceClass *fc) parent_class = (SPObjectClass *) g_type_class_ref(SP_TYPE_OBJECT); - sp_object_class->build = sp_fontface_build; + //sp_object_class->build = sp_fontface_build; sp_object_class->release = sp_fontface_release; sp_object_class->set = sp_fontface_set; sp_object_class->write = sp_fontface_write; @@ -369,9 +369,10 @@ static void sp_fontface_init(SPFontFace *face) static void sp_fontface_build(SPObject *object, SPDocument *document, Inkscape::XML::Node *repr) { - if (((SPObjectClass *) (parent_class))->build) { - ((SPObjectClass *) (parent_class))->build(object, document, repr); - } +// if (((SPObjectClass *) (parent_class))->build) { +// ((SPObjectClass *) (parent_class))->build(object, document, repr); +// } + // CPPIFY: todo object->readAttr( "font-family" ); object->readAttr( "font-style" ); -- cgit v1.2.3 From 207c0491084f51a46bd81ec60538dc48bedfe63f Mon Sep 17 00:00:00 2001 From: Alex Valavanis Date: Sat, 16 Mar 2013 16:26:03 +0000 Subject: Drop checks for ancient dependency versions. These are satisfied elsewhere. (bzr r12213) --- src/sp-font-face.cpp | 3 --- 1 file changed, 3 deletions(-) (limited to 'src/sp-font-face.cpp') diff --git a/src/sp-font-face.cpp b/src/sp-font-face.cpp index 4288a5d64..0a649b17f 100644 --- a/src/sp-font-face.cpp +++ b/src/sp-font-face.cpp @@ -2,8 +2,6 @@ # include #endif -#ifdef ENABLE_SVG_FONTS - /* * SVG element implementation * @@ -849,7 +847,6 @@ static Inkscape::XML::Node *sp_fontface_write(SPObject *object, Inkscape::XML::D return repr; } -#endif //#ifdef ENABLE_SVG_FONTS /* Local Variables: mode:c++ -- cgit v1.2.3 From 957c3e4b7909d42c5a13f1b1dd583f877fc32259 Mon Sep 17 00:00:00 2001 From: Markus Engel Date: Sat, 30 Mar 2013 00:46:57 +0100 Subject: Removed function pointers from SPObject and subclasses. Added some missing virtual pads for classes that were hidden by preprocessor macros. (bzr r11608.1.55) --- src/sp-font-face.cpp | 641 ++++++++++++++++++++++++++++++++++++++++++++++----- 1 file changed, 579 insertions(+), 62 deletions(-) (limited to 'src/sp-font-face.cpp') diff --git a/src/sp-font-face.cpp b/src/sp-font-face.cpp index 6ca8f850c..42b447635 100644 --- a/src/sp-font-face.cpp +++ b/src/sp-font-face.cpp @@ -305,16 +305,26 @@ static void sp_fontface_class_init(SPFontFaceClass *fc) parent_class = (SPObjectClass *) g_type_class_ref(SP_TYPE_OBJECT); //sp_object_class->build = sp_fontface_build; - sp_object_class->release = sp_fontface_release; - sp_object_class->set = sp_fontface_set; - sp_object_class->write = sp_fontface_write; - sp_object_class->child_added = sp_fontface_child_added; - sp_object_class->remove_child = sp_fontface_remove_child; - sp_object_class->update = sp_fontface_update; +// sp_object_class->release = sp_fontface_release; +// sp_object_class->set = sp_fontface_set; +// sp_object_class->write = sp_fontface_write; +// sp_object_class->child_added = sp_fontface_child_added; +// sp_object_class->remove_child = sp_fontface_remove_child; +// sp_object_class->update = sp_fontface_update; +} + +CFontFace::CFontFace(SPFontFace* face) : CObject(face) { + this->spfontface = face; +} + +CFontFace::~CFontFace() { } static void sp_fontface_init(SPFontFace *face) { + face->cfontface = new CFontFace(face); + face->cobject = face->cfontface; + std::vector style; style.push_back(SP_FONTFACE_STYLE_ALL); face->font_style = style; @@ -367,46 +377,88 @@ static void sp_fontface_init(SPFontFace *face) */ } -static void sp_fontface_build(SPObject *object, SPDocument *document, Inkscape::XML::Node *repr) -{ -// if (((SPObjectClass *) (parent_class))->build) { -// ((SPObjectClass *) (parent_class))->build(object, document, repr); -// } - // CPPIFY: todo - - 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_build(SPObject *object, SPDocument *document, Inkscape::XML::Node *repr) +//{ +//// if (((SPObjectClass *) (parent_class))->build) { +//// ((SPObjectClass *) (parent_class))->build(object, document, repr); +//// } +// +// 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" ); +//} + +void CFontFace::onBuild(SPDocument *document, Inkscape::XML::Node *repr) { + // if (((SPObjectClass *) (parent_class))->build) { + // ((SPObjectClass *) (parent_class))->build(object, document, repr); + // } + CObject::onBuild(document, repr); + + SPFontFace* object = this->spfontface; + + 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*/) @@ -419,10 +471,24 @@ static void sp_fontface_children_modified(SPFontFace */*sp_fontface*/) static void sp_fontface_child_added(SPObject *object, Inkscape::XML::Node *child, Inkscape::XML::Node *ref) { +// SPFontFace *f = SP_FONTFACE(object); +// +// if (((SPObjectClass *) parent_class)->child_added) +// (* ((SPObjectClass *) parent_class)->child_added)(object, child, ref); +// +// sp_fontface_children_modified(f); +// object->parent->requestModified(SP_OBJECT_MODIFIED_FLAG); + ((SPFontFace*)object)->cfontface->onChildAdded(child, ref); +} + +void CFontFace::onChildAdded(Inkscape::XML::Node *child, Inkscape::XML::Node *ref) { + SPFontFace* object = this->spfontface; + SPFontFace *f = SP_FONTFACE(object); - if (((SPObjectClass *) parent_class)->child_added) - (* ((SPObjectClass *) parent_class)->child_added)(object, child, ref); +// if (((SPObjectClass *) parent_class)->child_added) +// (* ((SPObjectClass *) parent_class)->child_added)(object, child, ref); + CObject::onChildAdded(child, ref); sp_fontface_children_modified(f); object->parent->requestModified(SP_OBJECT_MODIFIED_FLAG); @@ -435,10 +501,24 @@ sp_fontface_child_added(SPObject *object, Inkscape::XML::Node *child, Inkscape:: static void sp_fontface_remove_child(SPObject *object, Inkscape::XML::Node *child) { +// SPFontFace *f = SP_FONTFACE(object); +// +// if (((SPObjectClass *) parent_class)->remove_child) +// (* ((SPObjectClass *) parent_class)->remove_child)(object, child); +// +// sp_fontface_children_modified(f); +// object->parent->requestModified(SP_OBJECT_MODIFIED_FLAG); + ((SPFontFace*)object)->cfontface->onRemoveChild(child); +} + +void CFontFace::onRemoveChild(Inkscape::XML::Node *child) { + SPFontFace* object = this->spfontface; + SPFontFace *f = SP_FONTFACE(object); - if (((SPObjectClass *) parent_class)->remove_child) - (* ((SPObjectClass *) parent_class)->remove_child)(object, child); +// if (((SPObjectClass *) parent_class)->remove_child) +// (* ((SPObjectClass *) parent_class)->remove_child)(object, child); + CObject::onRemoveChild(child); sp_fontface_children_modified(f); object->parent->requestModified(SP_OBJECT_MODIFIED_FLAG); @@ -448,13 +528,311 @@ static void sp_fontface_release(SPObject *object) { //SPFontFace *font = SP_FONTFACE(object); - if (((SPObjectClass *) parent_class)->release) { - ((SPObjectClass *) parent_class)->release(object); - } +// if (((SPObjectClass *) parent_class)->release) { +// ((SPObjectClass *) parent_class)->release(object); +// } + ((SPFontFace*)object)->cfontface->onRelease(); +} + +void CFontFace::onRelease() { + CObject::onRelease(); } static void sp_fontface_set(SPObject *object, unsigned int key, const gchar *value) { +// SPFontFace *face = SP_FONTFACE(object); +// std::vector style; +// std::vector variant; +// std::vector weight; +// std::vector stretch; +// +// switch (key) { +// case SP_PROP_FONT_FAMILY: +// if (face->font_family) { +// g_free(face->font_family); +// } +// face->font_family = g_strdup(value); +// object->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); +// } else { +// for (unsigned int i=0;ifont_style[i]){ +// face->font_style = style; +// object->requestModified(SP_OBJECT_MODIFIED_FLAG); +// break; +// } +// } +// } +// 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); +// } else { +// for (unsigned int i=0;ifont_variant[i]){ +// face->font_variant = variant; +// object->requestModified(SP_OBJECT_MODIFIED_FLAG); +// break; +// } +// } +// } +// 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); +// } else { +// for (unsigned int i=0;ifont_weight[i]){ +// face->font_weight = weight; +// object->requestModified(SP_OBJECT_MODIFIED_FLAG); +// break; +// } +// } +// } +// 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); +// } else { +// for (unsigned int i=0;ifont_stretch[i]){ +// face->font_stretch = stretch; +// object->requestModified(SP_OBJECT_MODIFIED_FLAG); +// break; +// } +// } +// } +// break; +// 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); +// } +// 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); +// } +// 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); +// } +// 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); +// } +// 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); +// } +// 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); +// } +// 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); +// } +// 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); +// } +// 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); +// } +// 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); +// } +// 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); +// } +// 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); +// } +// 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); +// } +// 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); +// } +// 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); +// } +// 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); +// } +// 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); +// } +// 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); +// } +// 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); +// } +// 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); +// } +// 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); +// } +// 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); +// } +// 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); +// } +// break; +// } +// default: +// if (((SPObjectClass *) (parent_class))->set) { +// ((SPObjectClass *) (parent_class))->set(object, key, value); +// } +// break; +// } + ((SPFontFace*)object)->cfontface->onSet(key, value); +} + +void CFontFace::onSet(unsigned int key, const gchar *value) { + SPFontFace* object = this->spfontface; + SPFontFace *face = SP_FONTFACE(object); std::vector style; std::vector variant; @@ -737,9 +1115,10 @@ static void sp_fontface_set(SPObject *object, unsigned int key, const gchar *val break; } default: - if (((SPObjectClass *) (parent_class))->set) { - ((SPObjectClass *) (parent_class))->set(object, key, value); - } +// if (((SPObjectClass *) (parent_class))->set) { +// ((SPObjectClass *) (parent_class))->set(object, key, value); +// } + CObject::onSet(key, value); break; } } @@ -750,6 +1129,51 @@ static void sp_fontface_set(SPObject *object, unsigned int key, const gchar *val static void sp_fontface_update(SPObject *object, SPCtx *ctx, guint flags) { +// 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" ); +// } +// +// if (((SPObjectClass *) parent_class)->update) { +// ((SPObjectClass *) parent_class)->update(object, ctx, flags); +// } + ((SPFontFace*)object)->cfontface->onUpdate(ctx, flags); +} + +void CFontFace::onUpdate(SPCtx *ctx, guint flags) { + SPFontFace* object = this->spfontface; + if (flags & (SP_OBJECT_MODIFIED_FLAG)) { object->readAttr( "font-family" ); object->readAttr( "font-style" ); @@ -786,15 +1210,106 @@ sp_fontface_update(SPObject *object, SPCtx *ctx, guint flags) object->readAttr( "overline-thickness" ); } - if (((SPObjectClass *) parent_class)->update) { - ((SPObjectClass *) parent_class)->update(object, ctx, flags); - } +// if (((SPObjectClass *) parent_class)->update) { +// ((SPObjectClass *) parent_class)->update(object, ctx, flags); +// } + CObject::onUpdate(ctx, flags); } #define COPY_ATTR(rd,rs,key) (rd)->setAttribute((key), rs->attribute(key)); static Inkscape::XML::Node *sp_fontface_write(SPObject *object, Inkscape::XML::Document *xml_doc, Inkscape::XML::Node *repr, guint flags) { +// SPFontFace *face = SP_FONTFACE(object); +// +// if ((flags & SP_OBJECT_WRITE_BUILD) && !repr) { +// repr = xml_doc->createElement("svg:font-face"); +// } +// +// //TODO: +// //sp_repr_set_svg_double(repr, "font-family", face->font_family); +// //sp_repr_set_svg_double(repr, "font-style", face->font_style); +// //sp_repr_set_svg_double(repr, "font-variant", face->font_variant); +// //sp_repr_set_svg_double(repr, "font-weight", face->font_weight); +// //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, "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, "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()) { +// // 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"); +// } +// +// if (((SPObjectClass *) (parent_class))->write) { +// ((SPObjectClass *) (parent_class))->write(object, xml_doc, repr, flags); +// } +// +// return repr; + return ((SPFontFace*)object)->cfontface->onWrite(xml_doc, repr, flags); +} + +Inkscape::XML::Node* CFontFace::onWrite(Inkscape::XML::Document *xml_doc, Inkscape::XML::Node *repr, guint flags) { + SPFontFace* object = this->spfontface; + SPFontFace *face = SP_FONTFACE(object); if ((flags & SP_OBJECT_WRITE_BUILD) && !repr) { @@ -874,12 +1389,14 @@ static Inkscape::XML::Node *sp_fontface_write(SPObject *object, Inkscape::XML::D COPY_ATTR(repr, object->getRepr(), "overline-thickness"); } - if (((SPObjectClass *) (parent_class))->write) { - ((SPObjectClass *) (parent_class))->write(object, xml_doc, repr, flags); - } +// if (((SPObjectClass *) (parent_class))->write) { +// ((SPObjectClass *) (parent_class))->write(object, xml_doc, repr, flags); +// } + CObject::onWrite(xml_doc, repr, flags); return repr; } + #endif //#ifdef ENABLE_SVG_FONTS /* Local Variables: -- cgit v1.2.3 From 7df6616da5ea2debb86838366ddf746841549cdb Mon Sep 17 00:00:00 2001 From: Markus Engel Date: Sat, 30 Mar 2013 00:56:13 +0100 Subject: Renamed virtual function names. (bzr r11608.1.57) --- src/sp-font-face.cpp | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) (limited to 'src/sp-font-face.cpp') diff --git a/src/sp-font-face.cpp b/src/sp-font-face.cpp index 38467083f..0da5f7e6a 100644 --- a/src/sp-font-face.cpp +++ b/src/sp-font-face.cpp @@ -332,8 +332,8 @@ static void sp_fontface_init(SPFontFace *face) } -void CFontFace::onBuild(SPDocument *document, Inkscape::XML::Node *repr) { - CObject::onBuild(document, repr); +void CFontFace::build(SPDocument *document, Inkscape::XML::Node *repr) { + CObject::build(document, repr); SPFontFace* object = this->spfontface; @@ -379,12 +379,12 @@ static void sp_fontface_children_modified(SPFontFace */*sp_fontface*/) /** * Callback for child_added event. */ -void CFontFace::onChildAdded(Inkscape::XML::Node *child, Inkscape::XML::Node *ref) { +void CFontFace::child_added(Inkscape::XML::Node *child, Inkscape::XML::Node *ref) { SPFontFace* object = this->spfontface; SPFontFace *f = SP_FONTFACE(object); - CObject::onChildAdded(child, ref); + CObject::child_added(child, ref); sp_fontface_children_modified(f); object->parent->requestModified(SP_OBJECT_MODIFIED_FLAG); @@ -394,22 +394,22 @@ void CFontFace::onChildAdded(Inkscape::XML::Node *child, Inkscape::XML::Node *re /** * Callback for remove_child event. */ -void CFontFace::onRemoveChild(Inkscape::XML::Node *child) { +void CFontFace::remove_child(Inkscape::XML::Node *child) { SPFontFace* object = this->spfontface; SPFontFace *f = SP_FONTFACE(object); - CObject::onRemoveChild(child); + CObject::remove_child(child); sp_fontface_children_modified(f); object->parent->requestModified(SP_OBJECT_MODIFIED_FLAG); } -void CFontFace::onRelease() { - CObject::onRelease(); +void CFontFace::release() { + CObject::release(); } -void CFontFace::onSet(unsigned int key, const gchar *value) { +void CFontFace::set(unsigned int key, const gchar *value) { SPFontFace* object = this->spfontface; SPFontFace *face = SP_FONTFACE(object); @@ -694,7 +694,7 @@ void CFontFace::onSet(unsigned int key, const gchar *value) { break; } default: - CObject::onSet(key, value); + CObject::set(key, value); break; } } @@ -702,7 +702,7 @@ void CFontFace::onSet(unsigned int key, const gchar *value) { /** * Receives update notifications. */ -void CFontFace::onUpdate(SPCtx *ctx, guint flags) { +void CFontFace::update(SPCtx *ctx, guint flags) { SPFontFace* object = this->spfontface; if (flags & (SP_OBJECT_MODIFIED_FLAG)) { @@ -741,12 +741,12 @@ void CFontFace::onUpdate(SPCtx *ctx, guint flags) { object->readAttr( "overline-thickness" ); } - CObject::onUpdate(ctx, flags); + CObject::update(ctx, flags); } #define COPY_ATTR(rd,rs,key) (rd)->setAttribute((key), rs->attribute(key)); -Inkscape::XML::Node* CFontFace::onWrite(Inkscape::XML::Document *xml_doc, Inkscape::XML::Node *repr, guint flags) { +Inkscape::XML::Node* CFontFace::write(Inkscape::XML::Document *xml_doc, Inkscape::XML::Node *repr, guint flags) { SPFontFace* object = this->spfontface; SPFontFace *face = SP_FONTFACE(object); @@ -828,7 +828,7 @@ Inkscape::XML::Node* CFontFace::onWrite(Inkscape::XML::Document *xml_doc, Inksca COPY_ATTR(repr, object->getRepr(), "overline-thickness"); } - CObject::onWrite(xml_doc, repr, flags); + CObject::write(xml_doc, repr, flags); return repr; } -- cgit v1.2.3 From a5d6e692d661f0bf7648e64e8fcb04588bb8f3ab Mon Sep 17 00:00:00 2001 From: Markus Engel Date: Mon, 1 Apr 2013 00:07:00 +0200 Subject: Prepared exchange of casting macros. (bzr r11608.1.63) --- src/sp-font-face.cpp | 1 + 1 file changed, 1 insertion(+) (limited to 'src/sp-font-face.cpp') diff --git a/src/sp-font-face.cpp b/src/sp-font-face.cpp index 0da5f7e6a..5baff2751 100644 --- a/src/sp-font-face.cpp +++ b/src/sp-font-face.cpp @@ -275,6 +275,7 @@ CFontFace::~CFontFace() { static void sp_fontface_init(SPFontFace *face) { face->cfontface = new CFontFace(face); + face->typeHierarchy.insert(typeid(SPFontFace)); delete face->cobject; face->cobject = face->cfontface; -- cgit v1.2.3 From 69f3b6f1abb2bb422935d43262e1e99aab359954 Mon Sep 17 00:00:00 2001 From: Markus Engel Date: Tue, 2 Apr 2013 01:41:30 +0200 Subject: Added constructors to SP classes. (bzr r11608.1.67) --- src/sp-font-face.cpp | 58 +++++++++++++++++++++++++++++----------------------- 1 file changed, 32 insertions(+), 26 deletions(-) (limited to 'src/sp-font-face.cpp') diff --git a/src/sp-font-face.cpp b/src/sp-font-face.cpp index 5baff2751..d946c4f20 100644 --- a/src/sp-font-face.cpp +++ b/src/sp-font-face.cpp @@ -259,7 +259,7 @@ static std::vector sp_read_fontFaceStretchType(gchar const return v; } -G_DEFINE_TYPE(SPFontFace, sp_fontface, SP_TYPE_OBJECT); +G_DEFINE_TYPE(SPFontFace, sp_fontface, G_TYPE_OBJECT); static void sp_fontface_class_init(SPFontFaceClass *fc) { @@ -272,8 +272,9 @@ CFontFace::CFontFace(SPFontFace* face) : CObject(face) { CFontFace::~CFontFace() { } -static void sp_fontface_init(SPFontFace *face) -{ +SPFontFace::SPFontFace() : SPObject() { + SPFontFace* face = this; + face->cfontface = new CFontFace(face); face->typeHierarchy.insert(typeid(SPFontFace)); @@ -296,7 +297,7 @@ static void sp_fontface_init(SPFontFace *face) stretch.push_back(SP_FONTFACE_STRETCH_NORMAL); face->font_stretch = stretch; face->font_family = NULL; - /* + //face->font_style = ; //face->font_variant = ; //face->font_weight = ; @@ -305,31 +306,36 @@ static void sp_fontface_init(SPFontFace *face) //face->unicode_range = ; face->units_per_em = 1000; //face->panose_1 = ; - face->stem_v = ; - face->stem_h = ; + face->stemv = 0; + face->stemh = 0; face->slope = 0; - face->cap_height = ; - face->x_height = ; - face->accent_height = ; - face->ascent = ; - face->descent = ; + face->cap_height = 0; + face->x_height = 0; + face->accent_height = 0; + face->ascent = 0; + face->descent = 0; face->widths = NULL; face->bbox = NULL; - face->ideographic = ; - face->alphabetic = ; - face->mathematical = ; - face->hanging = ; - face->v_ideographic = ; - face->v_alphabetic = ; - face->v_mathematical = ; - face->v_hanging = ; - face->underline_position = ; - face->underline_thickness = ; - face->strikethrough_position = ; - face->strikethrough_thickness = ; - face->overline_position = ; - face->overline_thickness = ; -*/ + face->ideographic = 0; + face->alphabetic = 0; + face->mathematical = 0; + face->hanging = 0; + face->v_ideographic = 0; + face->v_alphabetic = 0; + face->v_mathematical = 0; + face->v_hanging = 0; + face->underline_position = 0; + face->underline_thickness = 0; + face->strikethrough_position = 0; + face->strikethrough_thickness = 0; + face->overline_position = 0; + face->overline_thickness = 0; + +} + +static void sp_fontface_init(SPFontFace *face) +{ + new (face) SPFontFace(); } -- cgit v1.2.3 From d1af3566872dfff2aeec84859c87f1f8d13f79df Mon Sep 17 00:00:00 2001 From: Markus Engel Date: Tue, 2 Apr 2013 19:14:36 +0200 Subject: Registered classes with new factory. Hkern, Vkern and FeFuncX have to be rewritten, as they aren't real classes. (bzr r11608.1.69) --- src/sp-font-face.cpp | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'src/sp-font-face.cpp') diff --git a/src/sp-font-face.cpp b/src/sp-font-face.cpp index d946c4f20..6149d9af0 100644 --- a/src/sp-font-face.cpp +++ b/src/sp-font-face.cpp @@ -259,6 +259,16 @@ static std::vector sp_read_fontFaceStretchType(gchar const return v; } +#include "sp-factory.h" + +namespace { + SPObject* createFontFace() { + return new SPFontFace(); + } + + bool fontFaceRegistered = SPFactory::instance().registerObject("svg:font-face", createFontFace); +} + G_DEFINE_TYPE(SPFontFace, sp_fontface, G_TYPE_OBJECT); static void sp_fontface_class_init(SPFontFaceClass *fc) -- cgit v1.2.3 From 7b7e0294b0c06a8d3ec19b73486a91e12cf67adf Mon Sep 17 00:00:00 2001 From: Markus Engel Date: Sat, 6 Apr 2013 22:16:05 +0200 Subject: Merged more classes. (bzr r11608.1.84) --- src/sp-font-face.cpp | 132 +++++++++++++++++++++------------------------------ 1 file changed, 55 insertions(+), 77 deletions(-) (limited to 'src/sp-font-face.cpp') diff --git a/src/sp-font-face.cpp b/src/sp-font-face.cpp index 6149d9af0..d91910bec 100644 --- a/src/sp-font-face.cpp +++ b/src/sp-font-face.cpp @@ -269,90 +269,68 @@ namespace { bool fontFaceRegistered = SPFactory::instance().registerObject("svg:font-face", createFontFace); } -G_DEFINE_TYPE(SPFontFace, sp_fontface, G_TYPE_OBJECT); - -static void sp_fontface_class_init(SPFontFaceClass *fc) -{ -} - -CFontFace::CFontFace(SPFontFace* face) : CObject(face) { - this->spfontface = face; -} - -CFontFace::~CFontFace() { -} - -SPFontFace::SPFontFace() : SPObject() { - SPFontFace* face = this; - - face->cfontface = new CFontFace(face); - face->typeHierarchy.insert(typeid(SPFontFace)); - - delete face->cobject; - face->cobject = face->cfontface; +SPFontFace::SPFontFace() : SPObject(), CObject(this) { + delete this->cobject; + this->cobject = this; std::vector style; style.push_back(SP_FONTFACE_STYLE_ALL); - face->font_style = style; + this->font_style = style; std::vector variant; variant.push_back(SP_FONTFACE_VARIANT_NORMAL); - face->font_variant = variant; + this->font_variant = variant; std::vector weight; weight.push_back(SP_FONTFACE_WEIGHT_ALL); - face->font_weight = weight; + this->font_weight = weight; std::vector stretch; stretch.push_back(SP_FONTFACE_STRETCH_NORMAL); - face->font_stretch = stretch; - face->font_family = NULL; - - //face->font_style = ; - //face->font_variant = ; - //face->font_weight = ; - //face->font_stretch = ; - face->font_size = NULL; - //face->unicode_range = ; - face->units_per_em = 1000; - //face->panose_1 = ; - face->stemv = 0; - face->stemh = 0; - face->slope = 0; - face->cap_height = 0; - face->x_height = 0; - face->accent_height = 0; - face->ascent = 0; - face->descent = 0; - face->widths = NULL; - face->bbox = NULL; - face->ideographic = 0; - face->alphabetic = 0; - face->mathematical = 0; - face->hanging = 0; - face->v_ideographic = 0; - face->v_alphabetic = 0; - face->v_mathematical = 0; - face->v_hanging = 0; - face->underline_position = 0; - face->underline_thickness = 0; - face->strikethrough_position = 0; - face->strikethrough_thickness = 0; - face->overline_position = 0; - face->overline_thickness = 0; - + this->font_stretch = stretch; + this->font_family = NULL; + + //this->font_style = ; + //this->font_variant = ; + //this->font_weight = ; + //this->font_stretch = ; + this->font_size = NULL; + //this->unicode_range = ; + this->units_per_em = 1000; + //this->panose_1 = ; + this->stemv = 0; + this->stemh = 0; + this->slope = 0; + this->cap_height = 0; + this->x_height = 0; + this->accent_height = 0; + this->ascent = 0; + this->descent = 0; + this->widths = NULL; + this->bbox = NULL; + this->ideographic = 0; + this->alphabetic = 0; + this->mathematical = 0; + this->hanging = 0; + this->v_ideographic = 0; + this->v_alphabetic = 0; + this->v_mathematical = 0; + this->v_hanging = 0; + this->underline_position = 0; + this->underline_thickness = 0; + this->strikethrough_position = 0; + this->strikethrough_thickness = 0; + this->overline_position = 0; + this->overline_thickness = 0; } -static void sp_fontface_init(SPFontFace *face) -{ - new (face) SPFontFace(); +SPFontFace::~SPFontFace() { } - -void CFontFace::build(SPDocument *document, Inkscape::XML::Node *repr) { +void SPFontFace::build(SPDocument *document, Inkscape::XML::Node *repr) { CObject::build(document, repr); - SPFontFace* object = this->spfontface; + SPFontFace* object = this; object->readAttr( "font-family" ); object->readAttr( "font-style" ); @@ -396,8 +374,8 @@ static void sp_fontface_children_modified(SPFontFace */*sp_fontface*/) /** * Callback for child_added event. */ -void CFontFace::child_added(Inkscape::XML::Node *child, Inkscape::XML::Node *ref) { - SPFontFace* object = this->spfontface; +void SPFontFace::child_added(Inkscape::XML::Node *child, Inkscape::XML::Node *ref) { + SPFontFace* object = this; SPFontFace *f = SP_FONTFACE(object); @@ -411,8 +389,8 @@ void CFontFace::child_added(Inkscape::XML::Node *child, Inkscape::XML::Node *ref /** * Callback for remove_child event. */ -void CFontFace::remove_child(Inkscape::XML::Node *child) { - SPFontFace* object = this->spfontface; +void SPFontFace::remove_child(Inkscape::XML::Node *child) { + SPFontFace* object = this; SPFontFace *f = SP_FONTFACE(object); @@ -422,12 +400,12 @@ void CFontFace::remove_child(Inkscape::XML::Node *child) { object->parent->requestModified(SP_OBJECT_MODIFIED_FLAG); } -void CFontFace::release() { +void SPFontFace::release() { CObject::release(); } -void CFontFace::set(unsigned int key, const gchar *value) { - SPFontFace* object = this->spfontface; +void SPFontFace::set(unsigned int key, const gchar *value) { + SPFontFace* object = this; SPFontFace *face = SP_FONTFACE(object); std::vector style; @@ -719,8 +697,8 @@ void CFontFace::set(unsigned int key, const gchar *value) { /** * Receives update notifications. */ -void CFontFace::update(SPCtx *ctx, guint flags) { - SPFontFace* object = this->spfontface; +void SPFontFace::update(SPCtx *ctx, guint flags) { + SPFontFace* object = this; if (flags & (SP_OBJECT_MODIFIED_FLAG)) { object->readAttr( "font-family" ); @@ -763,8 +741,8 @@ void CFontFace::update(SPCtx *ctx, guint flags) { #define COPY_ATTR(rd,rs,key) (rd)->setAttribute((key), rs->attribute(key)); -Inkscape::XML::Node* CFontFace::write(Inkscape::XML::Document *xml_doc, Inkscape::XML::Node *repr, guint flags) { - SPFontFace* object = this->spfontface; +Inkscape::XML::Node* SPFontFace::write(Inkscape::XML::Document *xml_doc, Inkscape::XML::Node *repr, guint flags) { + SPFontFace* object = this; SPFontFace *face = SP_FONTFACE(object); -- cgit v1.2.3 From 27e2102f96a5554bcd5310ec11435d155773b279 Mon Sep 17 00:00:00 2001 From: Markus Engel Date: Sun, 7 Apr 2013 18:28:22 +0200 Subject: Merge Object and subclasses. Merging of SP- and C-classes complete. (bzr r11608.1.86) --- src/sp-font-face.cpp | 19 ++++++++----------- 1 file changed, 8 insertions(+), 11 deletions(-) (limited to 'src/sp-font-face.cpp') diff --git a/src/sp-font-face.cpp b/src/sp-font-face.cpp index d91910bec..39242b870 100644 --- a/src/sp-font-face.cpp +++ b/src/sp-font-face.cpp @@ -269,10 +269,7 @@ namespace { bool fontFaceRegistered = SPFactory::instance().registerObject("svg:font-face", createFontFace); } -SPFontFace::SPFontFace() : SPObject(), CObject(this) { - delete this->cobject; - this->cobject = this; - +SPFontFace::SPFontFace() : SPObject() { std::vector style; style.push_back(SP_FONTFACE_STYLE_ALL); this->font_style = style; @@ -328,7 +325,7 @@ SPFontFace::~SPFontFace() { } void SPFontFace::build(SPDocument *document, Inkscape::XML::Node *repr) { - CObject::build(document, repr); + SPObject::build(document, repr); SPFontFace* object = this; @@ -379,7 +376,7 @@ void SPFontFace::child_added(Inkscape::XML::Node *child, Inkscape::XML::Node *re SPFontFace *f = SP_FONTFACE(object); - CObject::child_added(child, ref); + SPObject::child_added(child, ref); sp_fontface_children_modified(f); object->parent->requestModified(SP_OBJECT_MODIFIED_FLAG); @@ -394,14 +391,14 @@ void SPFontFace::remove_child(Inkscape::XML::Node *child) { SPFontFace *f = SP_FONTFACE(object); - CObject::remove_child(child); + SPObject::remove_child(child); sp_fontface_children_modified(f); object->parent->requestModified(SP_OBJECT_MODIFIED_FLAG); } void SPFontFace::release() { - CObject::release(); + SPObject::release(); } void SPFontFace::set(unsigned int key, const gchar *value) { @@ -689,7 +686,7 @@ void SPFontFace::set(unsigned int key, const gchar *value) { break; } default: - CObject::set(key, value); + SPObject::set(key, value); break; } } @@ -736,7 +733,7 @@ void SPFontFace::update(SPCtx *ctx, guint flags) { object->readAttr( "overline-thickness" ); } - CObject::update(ctx, flags); + SPObject::update(ctx, flags); } #define COPY_ATTR(rd,rs,key) (rd)->setAttribute((key), rs->attribute(key)); @@ -823,7 +820,7 @@ Inkscape::XML::Node* SPFontFace::write(Inkscape::XML::Document *xml_doc, Inkscap COPY_ATTR(repr, object->getRepr(), "overline-thickness"); } - CObject::write(xml_doc, repr, flags); + SPObject::write(xml_doc, repr, flags); return repr; } -- cgit v1.2.3 From 49c324545e713c1ca375b7e559418e02ebe52945 Mon Sep 17 00:00:00 2001 From: Markus Engel Date: Thu, 1 Aug 2013 01:06:31 +0200 Subject: Replacement of unnecessary variables. (bzr r11608.1.114) --- src/sp-font-face.cpp | 499 ++++++++++++++++++++++++++------------------------- 1 file changed, 251 insertions(+), 248 deletions(-) (limited to 'src/sp-font-face.cpp') 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 style; std::vector variant; std::vector 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;ifont_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;ifont_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;ifont_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;ifont_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); -- cgit v1.2.3