diff --git a/src/sp-tspan.cpp b/src/sp-tspan.cpp
index 8050cdbf911424b08ab4d0645a33e86c3f190f9b..2afd75e75992d303453514f2e9a76c9d06402057 100644 (file)
--- a/src/sp-tspan.cpp
+++ b/src/sp-tspan.cpp
-#define __SP_TSPAN_C__
-
/*
* SVG <text> and <tspan> implementation
*
* Author:
* Lauris Kaplinski <lauris@kaplinski.com>
* bulia byak <buliabyak@users.sf.net>
+ * Jon A. Cruz <jon@joncruz.org>
+ * Abhishek Sharma
*
* Copyright (C) 1999-2002 Lauris Kaplinski
* Copyright (C) 2000-2001 Ximian, Inc.
# include "config.h"
#endif
+#include <cstring>
+#include <string>
#include <glibmm/i18n.h>
#include <livarot/Path.h>
static void sp_tspan_set(SPObject *object, unsigned key, gchar const *value);
static void sp_tspan_update(SPObject *object, SPCtx *ctx, guint flags);
static void sp_tspan_modified(SPObject *object, unsigned flags);
-static void sp_tspan_bbox(SPItem const *item, NRRect *bbox, NR::Matrix const &transform, unsigned const flags);
-static Inkscape::XML::Node *sp_tspan_write(SPObject *object, Inkscape::XML::Node *repr, guint flags);
+static void sp_tspan_bbox(SPItem const *item, NRRect *bbox, Geom::Matrix const &transform, unsigned const flags);
+static Inkscape::XML::Node *sp_tspan_write(SPObject *object, Inkscape::XML::Document *doc, Inkscape::XML::Node *repr, guint flags);
static char *sp_tspan_description (SPItem *item);
static SPItemClass *tspan_parent_class;
{
//SPTSpan *tspan = SP_TSPAN(object);
- sp_object_read_attr(object, "x");
- sp_object_read_attr(object, "y");
- sp_object_read_attr(object, "dx");
- sp_object_read_attr(object, "dy");
- sp_object_read_attr(object, "rotate");
- sp_object_read_attr(object, "sodipodi:role");
+ object->readAttr( "x" );
+ object->readAttr( "y" );
+ object->readAttr( "dx" );
+ object->readAttr( "dy" );
+ object->readAttr( "rotate" );
+ object->readAttr( "sodipodi:role" );
if (((SPObjectClass *) tspan_parent_class)->build)
((SPObjectClass *) tspan_parent_class)->build(object, doc, repr);
}
}
-static void
-sp_tspan_update(SPObject *object, SPCtx *ctx, guint flags)
+static void sp_tspan_update(SPObject *object, SPCtx *ctx, guint flags)
{
- if (((SPObjectClass *) tspan_parent_class)->update)
+ if (((SPObjectClass *) tspan_parent_class)->update) {
((SPObjectClass *) tspan_parent_class)->update(object, ctx, flags);
+ }
- if (flags & SP_OBJECT_MODIFIED_FLAG) flags |= SP_OBJECT_PARENT_MODIFIED_FLAG;
+ if (flags & SP_OBJECT_MODIFIED_FLAG) {
+ flags |= SP_OBJECT_PARENT_MODIFIED_FLAG;
+ }
flags &= SP_OBJECT_MODIFIED_CASCADE;
- SPObject *ochild;
- for ( ochild = sp_object_first_child(object) ; ochild ; ochild = SP_OBJECT_NEXT(ochild) ) {
+ for ( SPObject *ochild = object->firstChild() ; ochild ; ochild = ochild->getNext() ) {
if ( flags || ( ochild->uflags & SP_OBJECT_MODIFIED_FLAG )) {
ochild->updateDisplay(ctx, flags);
}
}
}
-static void
-sp_tspan_modified(SPObject *object, unsigned flags)
+static void sp_tspan_modified(SPObject *object, unsigned flags)
{
- if (((SPObjectClass *) tspan_parent_class)->modified)
+ if (((SPObjectClass *) tspan_parent_class)->modified) {
((SPObjectClass *) tspan_parent_class)->modified(object, flags);
+ }
- if (flags & SP_OBJECT_MODIFIED_FLAG)
+ if (flags & SP_OBJECT_MODIFIED_FLAG) {
flags |= SP_OBJECT_PARENT_MODIFIED_FLAG;
+ }
flags &= SP_OBJECT_MODIFIED_CASCADE;
- SPObject *ochild;
- for ( ochild = sp_object_first_child(object) ; ochild ; ochild = SP_OBJECT_NEXT(ochild) ) {
+ for ( SPObject *ochild = object->firstChild() ; ochild ; ochild = ochild->getNext() ) {
if (flags || (ochild->mflags & SP_OBJECT_MODIFIED_FLAG)) {
ochild->emitModified(flags);
}
}
}
-static void sp_tspan_bbox(SPItem const *item, NRRect *bbox, NR::Matrix const &transform, unsigned const /*flags*/)
+static void sp_tspan_bbox(SPItem const *item, NRRect *bbox, Geom::Matrix const &transform, unsigned const /*flags*/)
{
// find out the ancestor text which holds our layout
SPObject *parent_text = SP_OBJECT(item);
- for (; parent_text != NULL && !SP_IS_TEXT(parent_text); parent_text = SP_OBJECT_PARENT (parent_text));
+ for (; parent_text != NULL && !SP_IS_TEXT(parent_text); parent_text = SP_OBJECT_PARENT (parent_text)){};
if (parent_text == NULL) return;
// get the bbox of our portion of the layout
@@ -214,7 +217,7 @@ static void sp_tspan_bbox(SPItem const *item, NRRect *bbox, NR::Matrix const &tr
// Add stroke width
SPStyle* style=SP_OBJECT_STYLE (item);
if (!style->stroke.isNone()) {
- double const scale = expansion(transform);
+ double const scale = transform.descrim();
if ( fabs(style->stroke_width.computed * scale) > 0.01 ) { // sinon c'est 0=oon veut pas de bord
double const width = MAX(0.125, style->stroke_width.computed * scale);
if ( fabs(bbox->x1 - bbox->x0) > -0.00001 && fabs(bbox->y1 - bbox->y0) > -0.00001 ) {
@@ -228,11 +231,10 @@ static void sp_tspan_bbox(SPItem const *item, NRRect *bbox, NR::Matrix const &tr
}
static Inkscape::XML::Node *
-sp_tspan_write(SPObject *object, Inkscape::XML::Node *repr, guint flags)
+sp_tspan_write(SPObject *object, Inkscape::XML::Document *xml_doc, Inkscape::XML::Node *repr, guint flags)
{
SPTSpan *tspan = SP_TSPAN(object);
- Inkscape::XML::Document *xml_doc = sp_document_repr_doc(SP_OBJECT_DOCUMENT(object));
-
+
if ((flags & SP_OBJECT_WRITE_BUILD) && !repr) {
repr = xml_doc->createElement("svg:tspan");
}
if ( flags&SP_OBJECT_WRITE_BUILD ) {
GSList *l = NULL;
- for (SPObject* child = sp_object_first_child(object) ; child != NULL ; child = SP_OBJECT_NEXT(child) ) {
+ for (SPObject* child = object->firstChild() ; child ; child = child->getNext() ) {
Inkscape::XML::Node* c_repr=NULL;
if ( SP_IS_TSPAN(child) || SP_IS_TREF(child) ) {
- c_repr = child->updateRepr(NULL, flags);
+ c_repr = child->updateRepr(xml_doc, NULL, flags);
} else if ( SP_IS_TEXTPATH(child) ) {
- //c_repr = child->updateRepr(NULL, flags); // shouldn't happen
+ //c_repr = child->updateRepr(xml_doc, NULL, flags); // shouldn't happen
} else if ( SP_IS_STRING(child) ) {
c_repr = xml_doc->createTextNode(SP_STRING(child)->string.c_str());
}
- if ( c_repr ) l = g_slist_prepend(l, c_repr);
+ if ( c_repr ) {
+ l = g_slist_prepend(l, c_repr);
+ }
}
while ( l ) {
repr->addChild((Inkscape::XML::Node *) l->data, NULL);
l = g_slist_remove(l, l->data);
}
} else {
- for (SPObject* child = sp_object_first_child(object) ; child != NULL ; child = SP_OBJECT_NEXT(child) ) {
+ for (SPObject* child = object->firstChild() ; child ; child = child->getNext() ) {
if ( SP_IS_TSPAN(child) || SP_IS_TREF(child) ) {
child->updateRepr(flags);
} else if ( SP_IS_TEXTPATH(child) ) {
- //c_repr = child->updateRepr(NULL, flags); // shouldn't happen
+ //c_repr = child->updateRepr(xml_doc, NULL, flags); // shouldn't happen
} else if ( SP_IS_STRING(child) ) {
SP_OBJECT_REPR(child)->setContent(SP_STRING(child)->string.c_str());
}
}
}
- if (((SPObjectClass *) tspan_parent_class)->write)
- ((SPObjectClass *) tspan_parent_class)->write(object, repr, flags);
+ if (((SPObjectClass *) tspan_parent_class)->write) {
+ ((SPObjectClass *) tspan_parent_class)->write(object, xml_doc, repr, flags);
+ }
return repr;
}
static void sp_textpath_set(SPObject *object, unsigned key, gchar const *value);
static void sp_textpath_update(SPObject *object, SPCtx *ctx, guint flags);
static void sp_textpath_modified(SPObject *object, unsigned flags);
-static Inkscape::XML::Node *sp_textpath_write(SPObject *object, Inkscape::XML::Node *repr, guint flags);
+static Inkscape::XML::Node *sp_textpath_write(SPObject *object, Inkscape::XML::Document *doc, Inkscape::XML::Node *repr, guint flags);
static SPItemClass *textpath_parent_class;
((SPObjectClass *) textpath_parent_class)->release(object);
}
-static void
-sp_textpath_build(SPObject *object, SPDocument *doc, Inkscape::XML::Node *repr)
+static void sp_textpath_build(SPObject *object, SPDocument *doc, Inkscape::XML::Node *repr)
{
- //SPTextPath *textpath = SP_TEXTPATH(object);
-
- sp_object_read_attr(object, "x");
- sp_object_read_attr(object, "y");
- sp_object_read_attr(object, "dx");
- sp_object_read_attr(object, "dy");
- sp_object_read_attr(object, "rotate");
- sp_object_read_attr(object, "startOffset");
- sp_object_read_attr(object, "xlink:href");
-
- bool no_content=true;
+ object->readAttr( "x" );
+ object->readAttr( "y" );
+ object->readAttr( "dx" );
+ object->readAttr( "dy" );
+ object->readAttr( "rotate" );
+ object->readAttr( "startOffset" );
+ object->readAttr( "xlink:href" );
+
+ bool no_content = true;
for (Inkscape::XML::Node* rch = repr->firstChild() ; rch != NULL; rch = rch->next()) {
- if ( rch->type() == Inkscape::XML::TEXT_NODE ) {no_content=false;break;}
+ if ( rch->type() == Inkscape::XML::TEXT_NODE )
+ {
+ no_content = false;
+ break;
+ }
}
if ( no_content ) {
- Inkscape::XML::Document *xml_doc = sp_document_repr_doc(doc);
+ Inkscape::XML::Document *xml_doc = doc->getReprDoc();
Inkscape::XML::Node* rch = xml_doc->createTextNode("");
repr->addChild(rch, NULL);
}
- if (((SPObjectClass *) textpath_parent_class)->build)
+ if (((SPObjectClass *) textpath_parent_class)->build) {
((SPObjectClass *) textpath_parent_class)->build(object, doc, repr);
+ }
}
static void
}
}
-static void
-sp_textpath_update(SPObject *object, SPCtx *ctx, guint flags)
+static void sp_textpath_update(SPObject *object, SPCtx *ctx, guint flags)
{
SPTextPath *textpath = SP_TEXTPATH(object);
- textpath->isUpdating=true;
- if ( textpath->sourcePath->sourceDirty ) refresh_textpath_source(textpath);
- textpath->isUpdating=false;
+ textpath->isUpdating = true;
+ if ( textpath->sourcePath->sourceDirty ) {
+ refresh_textpath_source(textpath);
+ }
+ textpath->isUpdating = false;
- if (((SPObjectClass *) textpath_parent_class)->update)
+ if (((SPObjectClass *) textpath_parent_class)->update) {
((SPObjectClass *) textpath_parent_class)->update(object, ctx, flags);
+ }
- if (flags & SP_OBJECT_MODIFIED_FLAG) flags |= SP_OBJECT_PARENT_MODIFIED_FLAG;
+ if (flags & SP_OBJECT_MODIFIED_FLAG) {
+ flags |= SP_OBJECT_PARENT_MODIFIED_FLAG;
+ }
flags &= SP_OBJECT_MODIFIED_CASCADE;
- SPObject *ochild;
- for ( ochild = sp_object_first_child(object) ; ochild ; ochild = SP_OBJECT_NEXT(ochild) ) {
+ for ( SPObject *ochild = object->firstChild() ; ochild ; ochild = ochild->getNext() ) {
if ( flags || ( ochild->uflags & SP_OBJECT_MODIFIED_FLAG )) {
ochild->updateDisplay(ctx, flags);
}
}
}
-static void
-sp_textpath_modified(SPObject *object, unsigned flags)
+static void sp_textpath_modified(SPObject *object, unsigned flags)
{
- if (((SPObjectClass *) textpath_parent_class)->modified)
+ if (((SPObjectClass *) textpath_parent_class)->modified) {
((SPObjectClass *) textpath_parent_class)->modified(object, flags);
+ }
- if (flags & SP_OBJECT_MODIFIED_FLAG)
+ if (flags & SP_OBJECT_MODIFIED_FLAG) {
flags |= SP_OBJECT_PARENT_MODIFIED_FLAG;
+ }
flags &= SP_OBJECT_MODIFIED_CASCADE;
- SPObject *ochild;
- for ( ochild = sp_object_first_child(object) ; ochild ; ochild = SP_OBJECT_NEXT(ochild) ) {
+ for ( SPObject *ochild = object->firstChild() ; ochild ; ochild = ochild->getNext() ) {
if (flags || (ochild->mflags & SP_OBJECT_MODIFIED_FLAG)) {
ochild->emitModified(flags);
}
}
}
static Inkscape::XML::Node *
-sp_textpath_write(SPObject *object, Inkscape::XML::Node *repr, guint flags)
+sp_textpath_write(SPObject *object, Inkscape::XML::Document *xml_doc, Inkscape::XML::Node *repr, guint flags)
{
SPTextPath *textpath = SP_TEXTPATH(object);
- Inkscape::XML::Document *xml_doc = sp_document_repr_doc(SP_OBJECT_DOCUMENT(object));
-
+
if ((flags & SP_OBJECT_WRITE_BUILD) && !repr) {
repr = xml_doc->createElement("svg:textPath");
}
if ( flags&SP_OBJECT_WRITE_BUILD ) {
GSList *l = NULL;
- for (SPObject* child = sp_object_first_child(object) ; child != NULL ; child = SP_OBJECT_NEXT(child) ) {
+ for (SPObject* child = object->firstChild() ; child ; child = child->getNext() ) {
Inkscape::XML::Node* c_repr=NULL;
if ( SP_IS_TSPAN(child) || SP_IS_TREF(child) ) {
- c_repr = child->updateRepr(NULL, flags);
+ c_repr = child->updateRepr(xml_doc, NULL, flags);
} else if ( SP_IS_TEXTPATH(child) ) {
- //c_repr = child->updateRepr(NULL, flags); // shouldn't happen
+ //c_repr = child->updateRepr(xml_doc, NULL, flags); // shouldn't happen
} else if ( SP_IS_STRING(child) ) {
c_repr = xml_doc->createTextNode(SP_STRING(child)->string.c_str());
}
- if ( c_repr ) l = g_slist_prepend(l, c_repr);
+ if ( c_repr ) {
+ l = g_slist_prepend(l, c_repr);
+ }
}
while ( l ) {
repr->addChild((Inkscape::XML::Node *) l->data, NULL);
l = g_slist_remove(l, l->data);
}
} else {
- for (SPObject* child = sp_object_first_child(object) ; child != NULL ; child = SP_OBJECT_NEXT(child) ) {
+ for (SPObject* child = object->firstChild() ; child ; child = child->getNext() ) {
if ( SP_IS_TSPAN(child) || SP_IS_TREF(child) ) {
child->updateRepr(flags);
} else if ( SP_IS_TEXTPATH(child) ) {
- //c_repr = child->updateRepr(NULL, flags); // shouldn't happen
+ //c_repr = child->updateRepr(xml_doc, NULL, flags); // shouldn't happen
} else if ( SP_IS_STRING(child) ) {
SP_OBJECT_REPR(child)->setContent(SP_STRING(child)->string.c_str());
}
}
}
- if (((SPObjectClass *) textpath_parent_class)->write)
- ((SPObjectClass *) textpath_parent_class)->write(object, repr, flags);
+ if (((SPObjectClass *) textpath_parent_class)->write) {
+ ((SPObjectClass *) textpath_parent_class)->write(object, xml_doc, repr, flags);
+ }
return repr;
}
SPObject *text = SP_OBJECT_PARENT(tp);
NRRect bbox;
- sp_item_invoke_bbox(SP_ITEM(text), &bbox, sp_item_i2doc_affine(SP_ITEM(text)), TRUE);
- NR::Point xy(bbox.x0, bbox.y0);
+ SP_ITEM(text)->invoke_bbox( &bbox, SP_ITEM(text)->i2doc_affine(), TRUE);
+ Geom::Point xy(bbox.x0, bbox.y0);
// make a list of textpath children
GSList *tp_reprs = NULL;
// set x/y on text
/* fixme: Yuck, is this really the right test? */
- if (xy[NR::X] != 1e18 && xy[NR::Y] != 1e18) {
- sp_repr_set_svg_double(SP_OBJECT_REPR(text), "x", xy[NR::X]);
- sp_repr_set_svg_double(SP_OBJECT_REPR(text), "y", xy[NR::Y]);
+ if (xy[Geom::X] != 1e18 && xy[Geom::Y] != 1e18) {
+ sp_repr_set_svg_double(SP_OBJECT_REPR(text), "x", xy[Geom::X]);
+ sp_repr_set_svg_double(SP_OBJECT_REPR(text), "y", xy[Geom::Y]);
}
}
fill-column:99
End:
*/
-// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=99 :
+// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:fileencoding=utf-8:textwidth=99 :