Code

Refactoring SPColor to C++ and removing legacy CMYK implementation
[inkscape.git] / src / dialogs / unclump.cpp
index f067aef5f85601ca55833f6f857fe7e964602afb..eb5870d2eb77f51dea44c9dcc4e2c7451862f784 100644 (file)
@@ -11,6 +11,7 @@
  */
 
 
+#include <algorithm>
 #include <map>
 #include "libnr/nr-matrix-ops.h"
 #include "sp-item.h"
@@ -34,10 +35,15 @@ unclump_center (SPItem *item)
         return i->second;
     }
 
-    NR::Rect const r = item->getBounds(sp_item_i2d_affine(item));
-    NR::Point const c = r.midpoint();
-    c_cache[SP_OBJECT_ID(item)] = c;
-    return c; 
+    NR::Maybe<NR::Rect> r = item->getBounds(sp_item_i2d_affine(item));
+    if (r) {
+       NR::Point const c = r->midpoint();
+       c_cache[SP_OBJECT_ID(item)] = c;
+        return c; 
+    } else {
+       // FIXME
+        return NR::Point(0, 0);
+    }
 }
 
 NR::Point
@@ -48,9 +54,13 @@ unclump_wh (SPItem *item)
     if ( i != wh_cache.end() ) {
         wh = i->second;
     } else {
-        NR::Rect const r = item->getBounds(sp_item_i2d_affine(item));
-        wh = r.dimensions();
-        wh_cache[SP_OBJECT_ID(item)] = wh;
+        NR::Maybe<NR::Rect> r = item->getBounds(sp_item_i2d_affine(item));
+       if (r) {
+            wh = r->dimensions();
+            wh_cache[SP_OBJECT_ID(item)] = wh;
+        } else {
+           wh = NR::Point(0, 0);
+        }
     }
 
     return wh;