diff options
Diffstat (limited to 'src/sp-tref.cpp')
| -rw-r--r-- | src/sp-tref.cpp | 34 |
1 files changed, 13 insertions, 21 deletions
diff --git a/src/sp-tref.cpp b/src/sp-tref.cpp index 7c4976a11..833743d24 100644 --- a/src/sp-tref.cpp +++ b/src/sp-tref.cpp @@ -32,8 +32,6 @@ #include "text-editing.h" #include "uri.h" -#include "display/nr-arena-group.h" -#include "libnr/nr-matrix-fns.h" #include "xml/node.h" #include "xml/repr.h" @@ -65,7 +63,7 @@ static void sp_tref_update(SPObject *object, SPCtx *ctx, guint flags); static void sp_tref_modified(SPObject *object, guint flags); static Inkscape::XML::Node *sp_tref_write(SPObject *object, Inkscape::XML::Document *doc, Inkscape::XML::Node *repr, guint flags); -static void sp_tref_bbox(SPItem const *item, NRRect *bbox, Geom::Affine const &transform, unsigned const flags); +static Geom::OptRect sp_tref_bbox(SPItem const *item, Geom::Affine const &transform, SPItem::BBoxType type); static gchar *sp_tref_description(SPItem *item); static void sp_tref_href_changed(SPObject *old_ref, SPObject *ref, SPTRef *tref); @@ -316,39 +314,33 @@ sp_tref_write(SPObject *object, Inkscape::XML::Document *xml_doc, Inkscape::XML: return repr; } -/** +/* * The code for this function is swiped from the tspan bbox code, since tref should work pretty much the same way */ -static void -sp_tref_bbox(SPItem const *item, NRRect *bbox, Geom::Affine const &transform, unsigned const /*flags*/) +static Geom::OptRect +sp_tref_bbox(SPItem const *item, Geom::Affine const &transform, SPItem::BBoxType type) { + Geom::OptRect bbox; // find out the ancestor text which holds our layout SPObject const *parent_text = item; while ( parent_text && !SP_IS_TEXT(parent_text) ) { parent_text = parent_text->parent; } if (parent_text == NULL) { - return; + return bbox; } // get the bbox of our portion of the layout - SP_TEXT(parent_text)->layout.getBoundingBox( - bbox, transform, sp_text_get_length_upto(parent_text, item), sp_text_get_length_upto(item, NULL) - 1); + bbox = SP_TEXT(parent_text)->layout.bounds(transform, + sp_text_get_length_upto(parent_text, item), sp_text_get_length_upto(item, NULL) - 1); // Add stroke width - SPStyle* style = item->style; - if (!style->stroke.isNone()) { - 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 ) { - bbox->x0-=0.5*width; - bbox->x1+=0.5*width; - bbox->y0-=0.5*width; - bbox->y1+=0.5*width; - } - } + // FIXME this code is incorrect + if (bbox && type == SPItem::VISUAL_BBOX && !item->style->stroke.isNone()) { + double scale = transform.descrim(); + bbox->expandBy(0.5 * item->style->stroke_width.computed * scale); } + return bbox; } |
