From 06b346c6b592e8a0d9609e42c5a509ee9ebe519b Mon Sep 17 00:00:00 2001 From: MenTaLguY Date: Sun, 4 Mar 2007 19:06:34 +0000 Subject: adapt code to new Maybe/bbox regime (bzr r2538) --- src/selection.cpp | 21 +++++++++------------ 1 file changed, 9 insertions(+), 12 deletions(-) (limited to 'src/selection.cpp') diff --git a/src/selection.cpp b/src/selection.cpp index a27e45cb2..82c82b523 100644 --- a/src/selection.cpp +++ b/src/selection.cpp @@ -317,21 +317,18 @@ NRRect *Selection::bounds(NRRect *bbox) const NR::Rect Selection::bounds() const { GSList const *items = const_cast(this)->itemList(); - if (!items) { - return NR::Rect(NR::Point(0, 0), NR::Point(0, 0)); - } - - GSList const *i = items; - NR::Rect bbox = sp_item_bbox_desktop(SP_ITEM(i->data)); - GSList const *i_start = i; - while (i != NULL) { - if (i != i_start) - bbox = NR::Rect::union_bounds(bbox, sp_item_bbox_desktop(SP_ITEM(i->data))); - i = i->next; + NR::Maybe bbox = NR::Nothing(); + for ( GSList const *i = items ; i != NULL ; i = i->next ) { + bbox = NR::Rect::union_bounds(bbox, sp_item_bbox_desktop(SP_ITEM(i->data))); } - return bbox; + // TODO: return NR::Maybe + if (bbox) { + return *bbox; + } else { + return NR::Rect(NR::Point(0, 0), NR::Point(0, 0)); + } } NRRect *Selection::boundsInDocument(NRRect *bbox) const { -- cgit v1.2.3