Code

Merge and cleanup of GSoC C++-ification project.
[inkscape.git] / src / sp-ellipse.cpp
index 7eb473d0310523f70046e05dac0df40caf4b92b6..ef58e4d6e316b6866ff46efaa3a9dc139270c5fb 100644 (file)
@@ -1,5 +1,3 @@
-#define __SP_ELLIPSE_C__
-
 /*
  * SVG <ellipse> and related implementations
  *
@@ -7,6 +5,7 @@
  *   Lauris Kaplinski <lauris@kaplinski.com>
  *   Mitsuru Oka
  *   bulia byak <buliabyak@users.sf.net>
+ *   Abhishek Sharma
  *
  * Copyright (C) 1999-2002 Lauris Kaplinski
  * Copyright (C) 2000-2001 Ximian, Inc.
@@ -144,16 +143,18 @@ sp_genericellipse_update(SPObject *object, SPCtx *ctx, guint flags)
         SPGenericEllipse *ellipse = (SPGenericEllipse *) object;
         SPStyle const *style = object->style;
         Geom::OptRect viewbox = ((SPItemCtx const *) ctx)->vp;
-        double const dx = viewbox->width();
-        double const dy = viewbox->height();
-        double const dr = sqrt(dx*dx + dy*dy)/sqrt(2);
-        double const em = style->font_size.computed;
-        double const ex = em * 0.5; // fixme: get from pango or libnrtype
-        ellipse->cx.update(em, ex, dx);
-        ellipse->cy.update(em, ex, dy);
-        ellipse->rx.update(em, ex, dr);
-        ellipse->ry.update(em, ex, dr);
-        ((SPShape *) object)->setShape();
+        if (viewbox) {
+            double const dx = viewbox->width();
+            double const dy = viewbox->height();
+            double const dr = sqrt(dx*dx + dy*dy)/sqrt(2);
+            double const em = style->font_size.computed;
+            double const ex = em * 0.5; // fixme: get from pango or libnrtype
+            ellipse->cx.update(em, ex, dx);
+            ellipse->cy.update(em, ex, dy);
+            ellipse->rx.update(em, ex, dr);
+            ellipse->ry.update(em, ex, dr);
+            static_cast<SPShape *>(object)->setShape();
+        }
     }
 
     if (((SPObjectClass *) ge_parent_class)->update)
@@ -433,10 +434,10 @@ sp_ellipse_build(SPObject *object, SPDocument *document, Inkscape::XML::Node *re
     if (((SPObjectClass *) ellipse_parent_class)->build)
         (* ((SPObjectClass *) ellipse_parent_class)->build) (object, document, repr);
 
-    object->readAttr( "cx");
-    object->readAttr( "cy");
-    object->readAttr( "rx");
-    object->readAttr( "ry");
+    object->readAttr( "cx" );
+    object->readAttr( "cy" );
+    object->readAttr( "rx" );
+    object->readAttr( "ry" );
 }
 
 static Inkscape::XML::Node *
@@ -581,9 +582,9 @@ sp_circle_build(SPObject *object, SPDocument *document, Inkscape::XML::Node *rep
     if (((SPObjectClass *) circle_parent_class)->build)
         (* ((SPObjectClass *) circle_parent_class)->build)(object, document, repr);
 
-    object->readAttr( "cx");
-    object->readAttr( "cy");
-    object->readAttr( "r");
+    object->readAttr( "cx" );
+    object->readAttr( "cy" );
+    object->readAttr( "r" );
 }
 
 static Inkscape::XML::Node *
@@ -706,14 +707,14 @@ sp_arc_build(SPObject *object, SPDocument *document, Inkscape::XML::Node *repr)
     if (((SPObjectClass *) arc_parent_class)->build)
         (* ((SPObjectClass *) arc_parent_class)->build) (object, document, repr);
 
-    object->readAttr( "sodipodi:cx");
-    object->readAttr( "sodipodi:cy");
-    object->readAttr( "sodipodi:rx");
-    object->readAttr( "sodipodi:ry");
+    object->readAttr( "sodipodi:cx" );
+    object->readAttr( "sodipodi:cy" );
+    object->readAttr( "sodipodi:rx" );
+    object->readAttr( "sodipodi:ry" );
 
-    object->readAttr( "sodipodi:start");
-    object->readAttr( "sodipodi:end");
-    object->readAttr( "sodipodi:open");
+    object->readAttr( "sodipodi:start" );
+    object->readAttr( "sodipodi:end" );
+    object->readAttr( "sodipodi:open" );
 }
 
 /*
@@ -923,4 +924,4 @@ Geom::Point sp_arc_get_xy(SPArc *arc, gdouble arg)
   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 :