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-glyph.cpp | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) (limited to 'src/sp-glyph.cpp') diff --git a/src/sp-glyph.cpp b/src/sp-glyph.cpp index 719375688..15b718fd0 100644 --- a/src/sp-glyph.cpp +++ b/src/sp-glyph.cpp @@ -63,7 +63,7 @@ static void sp_glyph_class_init(SPGlyphClass *gc) parent_class = (SPObjectClass*)g_type_class_peek_parent(gc); - sp_object_class->build = sp_glyph_build; + //sp_object_class->build = sp_glyph_build; sp_object_class->release = sp_glyph_release; sp_object_class->set = sp_glyph_set; sp_object_class->write = sp_glyph_write; @@ -88,9 +88,10 @@ static void sp_glyph_init(SPGlyph *glyph) static void sp_glyph_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( "unicode" ); object->readAttr( "glyph-name" ); -- 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-glyph.cpp | 334 ++++++++++++++++++++++++++++++++++++++++++++----------- 1 file changed, 270 insertions(+), 64 deletions(-) (limited to 'src/sp-glyph.cpp') diff --git a/src/sp-glyph.cpp b/src/sp-glyph.cpp index 15b718fd0..9905988f3 100644 --- a/src/sp-glyph.cpp +++ b/src/sp-glyph.cpp @@ -64,14 +64,24 @@ static void sp_glyph_class_init(SPGlyphClass *gc) parent_class = (SPObjectClass*)g_type_class_peek_parent(gc); //sp_object_class->build = sp_glyph_build; - sp_object_class->release = sp_glyph_release; - sp_object_class->set = sp_glyph_set; - sp_object_class->write = sp_glyph_write; - sp_object_class->update = sp_glyph_update; +// sp_object_class->release = sp_glyph_release; +// sp_object_class->set = sp_glyph_set; +// sp_object_class->write = sp_glyph_write; +// sp_object_class->update = sp_glyph_update; +} + +CGlyph::CGlyph(SPGlyph* glyph) : CObject(glyph) { + this->spglyph = glyph; +} + +CGlyph::~CGlyph() { } static void sp_glyph_init(SPGlyph *glyph) { + glyph->cglyph = new CGlyph(glyph); + glyph->cobject = glyph->cglyph; + //TODO: correct these values: new (&glyph->unicode) Glib::ustring(); @@ -86,32 +96,56 @@ static void sp_glyph_init(SPGlyph *glyph) glyph->vert_adv_y = 0; } -static void sp_glyph_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( "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" ); +//static void sp_glyph_build(SPObject *object, SPDocument *document, Inkscape::XML::Node *repr) +//{ +//// if (((SPObjectClass *) (parent_class))->build) { +//// ((SPObjectClass *) (parent_class))->build(object, document, repr); +//// } +// +// 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" ); +//} + +void CGlyph::onBuild(SPDocument *document, Inkscape::XML::Node *repr) { + // if (((SPObjectClass *) (parent_class))->build) { + // ((SPObjectClass *) (parent_class))->build(object, document, repr); + // } + CObject::onBuild(document, repr); + + SPGlyph* object = this->spglyph; + + 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" ); } static void sp_glyph_release(SPObject *object) { //SPGlyph *glyph = SP_GLYPH(object); - if (((SPObjectClass *) parent_class)->release) { - ((SPObjectClass *) parent_class)->release(object); - } +// if (((SPObjectClass *) parent_class)->release) { +// ((SPObjectClass *) parent_class)->release(object); +// } + ((SPGlyph*)object)->cglyph->onRelease(); +} + +void CGlyph::onRelease() { + CObject::onRelease(); } static glyphArabicForm sp_glyph_read_arabic_form(gchar const *value){ @@ -147,6 +181,105 @@ static glyphOrientation sp_glyph_read_orientation(gchar const *value){ static void sp_glyph_set(SPObject *object, unsigned int key, const gchar *value) { +// 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); +// break; +// } +// case SP_ATTR_GLYPH_NAME: +// { +// glyph->glyph_name.clear(); +// if (value) glyph->glyph_name.append(value); +// object->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); +// 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); +// } +// 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); +// } +// break; +// } +// case SP_ATTR_LANG: +// { +// if (glyph->lang) g_free(glyph->lang); +// glyph->lang = g_strdup(value); +// object->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); +// } +// 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); +// } +// 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); +// } +// 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); +// } +// break; +// } +// default: +// { +// if (((SPObjectClass *) (parent_class))->set) { +// ((SPObjectClass *) (parent_class))->set(object, key, value); +// } +// break; +// } +// } + ((SPGlyph*)object)->cglyph->onSet(key, value); +} + +void CGlyph::onSet(unsigned int key, const gchar *value) { + SPGlyph* object = this->spglyph; + SPGlyph *glyph = SP_GLYPH(object); switch (key) { @@ -234,9 +367,10 @@ static void sp_glyph_set(SPObject *object, unsigned int key, const gchar *value) } 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; } } @@ -248,6 +382,32 @@ static void sp_glyph_set(SPObject *object, unsigned int key, const gchar *value) static void sp_glyph_update(SPObject *object, SPCtx *ctx, guint flags) { +// 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" ); +// } +// +// if (((SPObjectClass *) parent_class)->update) { +// ((SPObjectClass *) parent_class)->update(object, ctx, flags); +// } + ((SPGlyph*)object)->cglyph->onUpdate(ctx, flags); +} + +void CGlyph::onUpdate(SPCtx *ctx, guint flags) { + SPGlyph* object = this->spglyph; + SPGlyph *glyph = SP_GLYPH(object); (void)glyph; @@ -265,53 +425,99 @@ sp_glyph_update(SPObject *object, SPCtx *ctx, guint flags) object->readAttr( "vert-adv-y" ); } - 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_glyph_write(SPObject *object, Inkscape::XML::Document *xml_doc, Inkscape::XML::Node *repr, guint flags) { -// SPGlyph *glyph = SP_GLYPH(object); +//// SPGlyph *glyph = SP_GLYPH(object); +// +// 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); +// repr->setAttribute("glyph-name", glyph->glyph_name); +// repr->setAttribute("d", glyph->d); +// sp_repr_set_svg_double(repr, "orientation", (double) glyph->orientation); +// sp_repr_set_svg_double(repr, "arabic-form", (double) glyph->arabic_form); +// repr->setAttribute("lang", glyph->lang); +// sp_repr_set_svg_double(repr, "horiz-adv-x", glyph->horiz_adv_x); +// sp_repr_set_svg_double(repr, "vert-origin-x", glyph->vert_origin_x); +// 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 (((SPObjectClass *) (parent_class))->write) { +// ((SPObjectClass *) (parent_class))->write(object, xml_doc, repr, flags); +// } +// +// return repr; + return ((SPGlyph*)object)->cglyph->onWrite(xml_doc, repr, flags); +} - if ((flags & SP_OBJECT_WRITE_BUILD) && !repr) { - repr = xml_doc->createElement("svg:glyph"); - } +Inkscape::XML::Node* CGlyph::onWrite(Inkscape::XML::Document *xml_doc, Inkscape::XML::Node *repr, guint flags) { + SPGlyph* object = this->spglyph; -/* 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); - repr->setAttribute("glyph-name", glyph->glyph_name); - repr->setAttribute("d", glyph->d); - sp_repr_set_svg_double(repr, "orientation", (double) glyph->orientation); - sp_repr_set_svg_double(repr, "arabic-form", (double) glyph->arabic_form); - repr->setAttribute("lang", glyph->lang); - sp_repr_set_svg_double(repr, "horiz-adv-x", glyph->horiz_adv_x); - sp_repr_set_svg_double(repr, "vert-origin-x", glyph->vert_origin_x); - 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"); - } + // SPGlyph *glyph = SP_GLYPH(object); - if (((SPObjectClass *) (parent_class))->write) { - ((SPObjectClass *) (parent_class))->write(object, xml_doc, repr, flags); - } + 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); + repr->setAttribute("glyph-name", glyph->glyph_name); + repr->setAttribute("d", glyph->d); + sp_repr_set_svg_double(repr, "orientation", (double) glyph->orientation); + sp_repr_set_svg_double(repr, "arabic-form", (double) glyph->arabic_form); + repr->setAttribute("lang", glyph->lang); + sp_repr_set_svg_double(repr, "horiz-adv-x", glyph->horiz_adv_x); + sp_repr_set_svg_double(repr, "vert-origin-x", glyph->vert_origin_x); + 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 (((SPObjectClass *) (parent_class))->write) { +// ((SPObjectClass *) (parent_class))->write(object, xml_doc, repr, flags); +// } + CObject::onWrite(xml_doc, repr, flags); - return repr; + return repr; } #endif //#ifdef ENABLE_SVG_FONTS /* -- 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-glyph.cpp | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) (limited to 'src/sp-glyph.cpp') diff --git a/src/sp-glyph.cpp b/src/sp-glyph.cpp index 6aa72d8b1..332b720bc 100644 --- a/src/sp-glyph.cpp +++ b/src/sp-glyph.cpp @@ -56,8 +56,8 @@ static void sp_glyph_init(SPGlyph *glyph) glyph->vert_adv_y = 0; } -void CGlyph::onBuild(SPDocument *document, Inkscape::XML::Node *repr) { - CObject::onBuild(document, repr); +void CGlyph::build(SPDocument *document, Inkscape::XML::Node *repr) { + CObject::build(document, repr); SPGlyph* object = this->spglyph; @@ -73,8 +73,8 @@ void CGlyph::onBuild(SPDocument *document, Inkscape::XML::Node *repr) { object->readAttr( "vert-adv-y" ); } -void CGlyph::onRelease() { - CObject::onRelease(); +void CGlyph::release() { + CObject::release(); } static glyphArabicForm sp_glyph_read_arabic_form(gchar const *value){ @@ -108,7 +108,7 @@ static glyphOrientation sp_glyph_read_orientation(gchar const *value){ return GLYPH_ORIENTATION_BOTH; } -void CGlyph::onSet(unsigned int key, const gchar *value) { +void CGlyph::set(unsigned int key, const gchar *value) { SPGlyph* object = this->spglyph; SPGlyph *glyph = SP_GLYPH(object); @@ -198,7 +198,7 @@ void CGlyph::onSet(unsigned int key, const gchar *value) { } default: { - CObject::onSet(key, value); + CObject::set(key, value); break; } } @@ -207,7 +207,7 @@ void CGlyph::onSet(unsigned int key, const gchar *value) { /** * * Receives update notifications. * */ -void CGlyph::onUpdate(SPCtx *ctx, guint flags) { +void CGlyph::update(SPCtx *ctx, guint flags) { SPGlyph* object = this->spglyph; SPGlyph *glyph = SP_GLYPH(object); @@ -227,12 +227,12 @@ void CGlyph::onUpdate(SPCtx *ctx, guint flags) { object->readAttr( "vert-adv-y" ); } - CObject::onUpdate(ctx, flags); + CObject::update(ctx, flags); } #define COPY_ATTR(rd,rs,key) (rd)->setAttribute((key), rs->attribute(key)); -Inkscape::XML::Node* CGlyph::onWrite(Inkscape::XML::Document *xml_doc, Inkscape::XML::Node *repr, guint flags) { +Inkscape::XML::Node* CGlyph::write(Inkscape::XML::Document *xml_doc, Inkscape::XML::Node *repr, guint flags) { SPGlyph* object = this->spglyph; // SPGlyph *glyph = SP_GLYPH(object); @@ -268,7 +268,7 @@ Inkscape::XML::Node* CGlyph::onWrite(Inkscape::XML::Document *xml_doc, Inkscape: COPY_ATTR(repr, object->getRepr(), "vert-adv-y"); } - 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-glyph.cpp | 1 + 1 file changed, 1 insertion(+) (limited to 'src/sp-glyph.cpp') diff --git a/src/sp-glyph.cpp b/src/sp-glyph.cpp index 332b720bc..1554fa08f 100644 --- a/src/sp-glyph.cpp +++ b/src/sp-glyph.cpp @@ -38,6 +38,7 @@ CGlyph::~CGlyph() { static void sp_glyph_init(SPGlyph *glyph) { glyph->cglyph = new CGlyph(glyph); + glyph->typeHierarchy.insert(typeid(SPGlyph)); delete glyph->cobject; glyph->cobject = glyph->cglyph; -- 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-glyph.cpp | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) (limited to 'src/sp-glyph.cpp') diff --git a/src/sp-glyph.cpp b/src/sp-glyph.cpp index 1554fa08f..2ab62c575 100644 --- a/src/sp-glyph.cpp +++ b/src/sp-glyph.cpp @@ -22,7 +22,7 @@ #include "document.h" #include -G_DEFINE_TYPE(SPGlyph, sp_glyph, SP_TYPE_OBJECT); +G_DEFINE_TYPE(SPGlyph, sp_glyph, G_TYPE_OBJECT); static void sp_glyph_class_init(SPGlyphClass *gc) { @@ -35,8 +35,9 @@ CGlyph::CGlyph(SPGlyph* glyph) : CObject(glyph) { CGlyph::~CGlyph() { } -static void sp_glyph_init(SPGlyph *glyph) -{ +SPGlyph::SPGlyph() : SPObject() { + SPGlyph* glyph = this; + glyph->cglyph = new CGlyph(glyph); glyph->typeHierarchy.insert(typeid(SPGlyph)); @@ -57,6 +58,11 @@ static void sp_glyph_init(SPGlyph *glyph) glyph->vert_adv_y = 0; } +static void sp_glyph_init(SPGlyph *glyph) +{ + new (glyph) SPGlyph(); +} + void CGlyph::build(SPDocument *document, Inkscape::XML::Node *repr) { CObject::build(document, repr); -- 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-glyph.cpp | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'src/sp-glyph.cpp') diff --git a/src/sp-glyph.cpp b/src/sp-glyph.cpp index 2ab62c575..85c7beb4f 100644 --- a/src/sp-glyph.cpp +++ b/src/sp-glyph.cpp @@ -22,6 +22,16 @@ #include "document.h" #include +#include "sp-factory.h" + +namespace { + SPObject* createGlyph() { + return new SPGlyph(); + } + + bool glyphRegistered = SPFactory::instance().registerObject("svg:glyph", createGlyph); +} + G_DEFINE_TYPE(SPGlyph, sp_glyph, G_TYPE_OBJECT); static void sp_glyph_class_init(SPGlyphClass *gc) -- 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-glyph.cpp | 66 ++++++++++++++++++++------------------------------------ 1 file changed, 23 insertions(+), 43 deletions(-) (limited to 'src/sp-glyph.cpp') diff --git a/src/sp-glyph.cpp b/src/sp-glyph.cpp index 85c7beb4f..6acef4db9 100644 --- a/src/sp-glyph.cpp +++ b/src/sp-glyph.cpp @@ -32,51 +32,31 @@ namespace { bool glyphRegistered = SPFactory::instance().registerObject("svg:glyph", createGlyph); } -G_DEFINE_TYPE(SPGlyph, sp_glyph, G_TYPE_OBJECT); - -static void sp_glyph_class_init(SPGlyphClass *gc) -{ -} - -CGlyph::CGlyph(SPGlyph* glyph) : CObject(glyph) { - this->spglyph = glyph; -} - -CGlyph::~CGlyph() { -} - -SPGlyph::SPGlyph() : SPObject() { - SPGlyph* glyph = this; - - glyph->cglyph = new CGlyph(glyph); - glyph->typeHierarchy.insert(typeid(SPGlyph)); - - delete glyph->cobject; - glyph->cobject = glyph->cglyph; +SPGlyph::SPGlyph() : SPObject(), CObject(this) { + delete this->cobject; + this->cobject = this; //TODO: correct these values: - new (&glyph->unicode) Glib::ustring(); - new (&glyph->glyph_name) Glib::ustring(); - glyph->d = NULL; - glyph->orientation = GLYPH_ORIENTATION_BOTH; - glyph->arabic_form = GLYPH_ARABIC_FORM_INITIAL; - glyph->lang = NULL; - glyph->horiz_adv_x = 0; - glyph->vert_origin_x = 0; - glyph->vert_origin_y = 0; - glyph->vert_adv_y = 0; + 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; + this->lang = NULL; + this->horiz_adv_x = 0; + this->vert_origin_x = 0; + this->vert_origin_y = 0; + this->vert_adv_y = 0; } -static void sp_glyph_init(SPGlyph *glyph) -{ - new (glyph) SPGlyph(); +SPGlyph::~SPGlyph() { } -void CGlyph::build(SPDocument *document, Inkscape::XML::Node *repr) { +void SPGlyph::build(SPDocument *document, Inkscape::XML::Node *repr) { CObject::build(document, repr); - SPGlyph* object = this->spglyph; + SPGlyph* object = this; object->readAttr( "unicode" ); object->readAttr( "glyph-name" ); @@ -90,7 +70,7 @@ void CGlyph::build(SPDocument *document, Inkscape::XML::Node *repr) { object->readAttr( "vert-adv-y" ); } -void CGlyph::release() { +void SPGlyph::release() { CObject::release(); } @@ -125,8 +105,8 @@ static glyphOrientation sp_glyph_read_orientation(gchar const *value){ return GLYPH_ORIENTATION_BOTH; } -void CGlyph::set(unsigned int key, const gchar *value) { - SPGlyph* object = this->spglyph; +void SPGlyph::set(unsigned int key, const gchar *value) { + SPGlyph* object = this; SPGlyph *glyph = SP_GLYPH(object); @@ -224,8 +204,8 @@ void CGlyph::set(unsigned int key, const gchar *value) { /** * * Receives update notifications. * */ -void CGlyph::update(SPCtx *ctx, guint flags) { - SPGlyph* object = this->spglyph; +void SPGlyph::update(SPCtx *ctx, guint flags) { + SPGlyph* object = this; SPGlyph *glyph = SP_GLYPH(object); (void)glyph; @@ -249,8 +229,8 @@ void CGlyph::update(SPCtx *ctx, guint flags) { #define COPY_ATTR(rd,rs,key) (rd)->setAttribute((key), rs->attribute(key)); -Inkscape::XML::Node* CGlyph::write(Inkscape::XML::Document *xml_doc, Inkscape::XML::Node *repr, guint flags) { - SPGlyph* object = this->spglyph; +Inkscape::XML::Node* SPGlyph::write(Inkscape::XML::Document *xml_doc, Inkscape::XML::Node *repr, guint flags) { + SPGlyph* object = this; // SPGlyph *glyph = SP_GLYPH(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-glyph.cpp | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) (limited to 'src/sp-glyph.cpp') diff --git a/src/sp-glyph.cpp b/src/sp-glyph.cpp index 6acef4db9..f18c3ef6d 100644 --- a/src/sp-glyph.cpp +++ b/src/sp-glyph.cpp @@ -32,10 +32,7 @@ namespace { bool glyphRegistered = SPFactory::instance().registerObject("svg:glyph", createGlyph); } -SPGlyph::SPGlyph() : SPObject(), CObject(this) { - delete this->cobject; - this->cobject = this; - +SPGlyph::SPGlyph() : SPObject() { //TODO: correct these values: new (&this->unicode) Glib::ustring(); @@ -54,7 +51,7 @@ SPGlyph::~SPGlyph() { } void SPGlyph::build(SPDocument *document, Inkscape::XML::Node *repr) { - CObject::build(document, repr); + SPObject::build(document, repr); SPGlyph* object = this; @@ -71,7 +68,7 @@ void SPGlyph::build(SPDocument *document, Inkscape::XML::Node *repr) { } void SPGlyph::release() { - CObject::release(); + SPObject::release(); } static glyphArabicForm sp_glyph_read_arabic_form(gchar const *value){ @@ -195,7 +192,7 @@ void SPGlyph::set(unsigned int key, const gchar *value) { } default: { - CObject::set(key, value); + SPObject::set(key, value); break; } } @@ -224,7 +221,7 @@ void SPGlyph::update(SPCtx *ctx, guint flags) { object->readAttr( "vert-adv-y" ); } - CObject::update(ctx, flags); + SPObject::update(ctx, flags); } #define COPY_ATTR(rd,rs,key) (rd)->setAttribute((key), rs->attribute(key)); @@ -265,7 +262,7 @@ Inkscape::XML::Node* SPGlyph::write(Inkscape::XML::Document *xml_doc, Inkscape:: COPY_ATTR(repr, object->getRepr(), "vert-adv-y"); } - 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-glyph.cpp | 204 ++++++++++++++++++++++++++++++------------------------- 1 file changed, 112 insertions(+), 92 deletions(-) (limited to 'src/sp-glyph.cpp') 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: -- cgit v1.2.3