diff options
| author | Markus Engel <markus.engel@tum.de> | 2012-08-21 19:40:53 +0000 |
|---|---|---|
| committer | Markus Engel <markus.engel@tum.de> | 2012-08-21 19:40:53 +0000 |
| commit | a7737572814d97dfa1fc286c369e375a1f58089b (patch) | |
| tree | ef435b0bfe90e6db00329659cdb08470d4c9b3c7 /src/sp-missing-glyph.cpp | |
| parent | Added "virtual pad" to SPDefs. (diff) | |
| download | inkscape-a7737572814d97dfa1fc286c369e375a1f58089b.tar.gz inkscape-a7737572814d97dfa1fc286c369e375a1f58089b.zip | |
Added "virtual pad" to SPMissingGlyph.
(bzr r11608.1.44)
Diffstat (limited to 'src/sp-missing-glyph.cpp')
| -rw-r--r-- | src/sp-missing-glyph.cpp | 104 |
1 files changed, 63 insertions, 41 deletions
diff --git a/src/sp-missing-glyph.cpp b/src/sp-missing-glyph.cpp index fdf75253e..778a9945a 100644 --- a/src/sp-missing-glyph.cpp +++ b/src/sp-missing-glyph.cpp @@ -66,8 +66,18 @@ static void sp_missing_glyph_class_init(SPMissingGlyphClass *gc) sp_object_class->write = sp_missing_glyph_write; } +CMissingGlyph::CMissingGlyph(SPMissingGlyph* mg) : CObject(mg) { + this->spmissingglyph = mg; +} + +CMissingGlyph::~CMissingGlyph() { +} + static void sp_missing_glyph_init(SPMissingGlyph *glyph) { + glyph->cmissingglyph = new CMissingGlyph(glyph); + glyph->cobject = glyph->cmissingglyph; + //TODO: correct these values: glyph->d = NULL; glyph->horiz_adv_x = 0; @@ -76,11 +86,10 @@ static void sp_missing_glyph_init(SPMissingGlyph *glyph) glyph->vert_adv_y = 0; } -static void sp_missing_glyph_build(SPObject *object, SPDocument *document, Inkscape::XML::Node *repr) -{ - if (((SPObjectClass *) (parent_class))->build) { - ((SPObjectClass *) (parent_class))->build(object, document, repr); - } +void CMissingGlyph::onBuild(SPDocument* doc, Inkscape::XML::Node* repr) { + SPMissingGlyph* object = this->spmissingglyph; + + CObject::onBuild(doc, repr); object->readAttr( "d" ); object->readAttr( "horiz-adv-x" ); @@ -89,17 +98,23 @@ static void sp_missing_glyph_build(SPObject *object, SPDocument *document, Inksc object->readAttr( "vert-adv-y" ); } -static void sp_missing_glyph_release(SPObject *object) +static void sp_missing_glyph_build(SPObject *object, SPDocument *document, Inkscape::XML::Node *repr) { - //SPMissingGlyph *glyph = SP_MISSING_GLYPH(object); + ((SPMissingGlyph*)object)->cmissingglyph->onBuild(document, repr); +} - if (((SPObjectClass *) parent_class)->release) { - ((SPObjectClass *) parent_class)->release(object); - } +void CMissingGlyph::onRelease() { + CObject::onRelease(); } -static void sp_missing_glyph_set(SPObject *object, unsigned int key, const gchar *value) +static void sp_missing_glyph_release(SPObject *object) { + ((SPMissingGlyph*)object)->cmissingglyph->onRelease(); +} + +void CMissingGlyph::onSet(unsigned int key, const gchar* value) { + SPMissingGlyph* object = this->spmissingglyph; + SPMissingGlyph *glyph = SP_MISSING_GLYPH(object); switch (key) { @@ -150,47 +165,54 @@ static void sp_missing_glyph_set(SPObject *object, unsigned int key, const gchar } default: { - if (((SPObjectClass *) (parent_class))->set) { - ((SPObjectClass *) (parent_class))->set(object, key, value); - } + CObject::onSet(key, value); break; } } } +static void sp_missing_glyph_set(SPObject *object, unsigned int key, const gchar *value) +{ + ((SPMissingGlyph*)object)->cmissingglyph->onSet(key, value); +} + #define COPY_ATTR(rd,rs,key) (rd)->setAttribute((key), rs->attribute(key)); -static Inkscape::XML::Node *sp_missing_glyph_write(SPObject *object, Inkscape::XML::Document *xml_doc, Inkscape::XML::Node *repr, guint flags) -{ -// SPMissingGlyph *glyph = SP_MISSING_GLYPH(object); +Inkscape::XML::Node* CMissingGlyph::onWrite(Inkscape::XML::Document* xml_doc, Inkscape::XML::Node* repr, guint flags) { + SPMissingGlyph* object = this->spmissingglyph; - if ((flags & SP_OBJECT_WRITE_BUILD) && !repr) { - repr = xml_doc->createElement("svg:glyph"); - } + // SPMissingGlyph *glyph = SP_MISSING_GLYPH(object); -/* 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("d", glyph->d); - 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(), "d"); - 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 ((flags & SP_OBJECT_WRITE_BUILD) && !repr) { + repr = xml_doc->createElement("svg:glyph"); + } - if (((SPObjectClass *) (parent_class))->write) { - ((SPObjectClass *) (parent_class))->write(object, xml_doc, repr, flags); - } + /* 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("d", glyph->d); + 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(), "d"); + 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"); + } + + CObject::onWrite(xml_doc, repr, flags); - return repr; + return repr; +} + +static Inkscape::XML::Node *sp_missing_glyph_write(SPObject *object, Inkscape::XML::Document *xml_doc, Inkscape::XML::Node *repr, guint flags) +{ + return ((SPMissingGlyph*)object)->cmissingglyph->onWrite(xml_doc, repr, flags); } #endif //#ifdef ENABLE_SVG_FONTS /* |
