diff options
| author | MenTaLguY <mental@rydia.net> | 2007-03-04 19:06:34 +0000 |
|---|---|---|
| committer | mental <mental@users.sourceforge.net> | 2007-03-04 19:06:34 +0000 |
| commit | 06b346c6b592e8a0d9609e42c5a509ee9ebe519b (patch) | |
| tree | d11771089b02bc74843859851025824a6d8ac3b9 /src/sp-item.cpp | |
| parent | replace use of invokeBbox in flood fill tool (diff) | |
| download | inkscape-06b346c6b592e8a0d9609e42c5a509ee9ebe519b.tar.gz inkscape-06b346c6b592e8a0d9609e42c5a509ee9ebe519b.zip | |
adapt code to new Maybe/bbox regime
(bzr r2538)
Diffstat (limited to 'src/sp-item.cpp')
| -rw-r--r-- | src/sp-item.cpp | 31 |
1 files changed, 15 insertions, 16 deletions
diff --git a/src/sp-item.cpp b/src/sp-item.cpp index c2ef93714..2d3ab3ea3 100644 --- a/src/sp-item.cpp +++ b/src/sp-item.cpp @@ -277,12 +277,12 @@ SPItem::setExplicitlyHidden(bool const val) { */ void SPItem::setCenter(NR::Point object_centre) { - NR::Rect bbox = getBounds(sp_item_i2d_affine(this)); - if (!bbox.isEmpty()) { - transform_center_x = object_centre[NR::X] - bbox.midpoint()[NR::X]; + NR::Maybe<NR::Rect> bbox = getBounds(sp_item_i2d_affine(this)); + if (bbox) { + transform_center_x = object_centre[NR::X] - bbox->midpoint()[NR::X]; if (fabs(transform_center_x) < 1e-5) // rounding error transform_center_x = 0; - transform_center_y = object_centre[NR::Y] - bbox.midpoint()[NR::Y]; + transform_center_y = object_centre[NR::Y] - bbox->midpoint()[NR::Y]; if (fabs(transform_center_y) < 1e-5) // rounding error transform_center_y = 0; } @@ -299,9 +299,9 @@ bool SPItem::isCenterSet() { } NR::Point SPItem::getCenter() { - NR::Rect bbox = getBounds(sp_item_i2d_affine(this)); - if (!bbox.isEmpty()) { - return bbox.midpoint() + NR::Point (this->transform_center_x, this->transform_center_y); + NR::Maybe<NR::Rect> bbox = getBounds(sp_item_i2d_affine(this)); + if (bbox) { + return bbox->midpoint() + NR::Point (this->transform_center_x, this->transform_center_y); } else { return NR::Point (0, 0); // something's wrong! } @@ -634,12 +634,9 @@ sp_item_write(SPObject *const object, Inkscape::XML::Node *repr, guint flags) { SPItem *item = SP_ITEM(object); - gchar c[256]; - if (sp_svg_transform_write(c, 256, item->transform)) { - repr->setAttribute("transform", c); - } else { - repr->setAttribute("transform", NULL); - } + gchar *c = sp_svg_transform_write(item->transform); + repr->setAttribute("transform", c); + g_free(c); SPObject const *const parent = SP_OBJECT_PARENT(object); /** \todo Can someone please document why this is conditional on having @@ -812,12 +809,14 @@ NR::Rect sp_item_bbox_desktop(SPItem *item) static void sp_item_private_snappoints(SPItem const *item, SnapPointsIter p) { - NR::Rect const bbox = item->getBounds(sp_item_i2d_affine(item)); + NR::Maybe<NR::Rect> bbox = item->getBounds(sp_item_i2d_affine(item)); /* Just a pair of opposite corners of the bounding box suffices given that we don't yet support angled guide lines. */ - *p = bbox.min(); - *p = bbox.max(); + if (bbox) { + *p = bbox->min(); + *p = bbox->max(); + } } void sp_item_snappoints(SPItem const *item, SnapPointsIter p) |
