Code

Filters. Custom predefined filters update and new ABC filters.
[inkscape.git] / src / sp-symbol.cpp
index 064c43442f4929bd2206541f71eac6704b4ae751..6c8d3cd82a7433e64b6f2d70f52f0ec237b62e27 100644 (file)
@@ -1,10 +1,9 @@
-#define __SP_SYMBOL_C__
-
 /*
  * SVG <symbol> implementation
  *
  * Authors:
  *   Lauris Kaplinski <lauris@kaplinski.com>
+ *   Abhishek Sharma
  *
  * Copyright (C) 1999-2003 Lauris Kaplinski
  *
@@ -20,6 +19,7 @@
 
 #include "libnr/nr-matrix-fns.h"
 #include "libnr/nr-matrix-ops.h"
+#include <2geom/transforms.h>
 #include "display/nr-arena-group.h"
 #include "xml/repr.h"
 #include "attributes.h"
@@ -40,7 +40,7 @@ static Inkscape::XML::Node *sp_symbol_write (SPObject *object, Inkscape::XML::Do
 
 static NRArenaItem *sp_symbol_show (SPItem *item, NRArena *arena, unsigned int key, unsigned int flags);
 static void sp_symbol_hide (SPItem *item, unsigned int key);
-static void sp_symbol_bbox(SPItem const *item, NRRect *bbox, NR::Matrix const &transform, unsigned const flags);
+static void sp_symbol_bbox(SPItem const *item, NRRect *bbox, Geom::Matrix const &transform, unsigned const flags);
 static void sp_symbol_print (SPItem *item, SPPrintContext *ctx);
 
 static SPGroupClass *parent_class;
@@ -109,8 +109,8 @@ sp_symbol_build (SPObject *object, SPDocument *document, Inkscape::XML::Node *re
     group = (SPGroup *) object;
     symbol = (SPSymbol *) object;
 
-    sp_object_read_attr (object, "viewBox");
-    sp_object_read_attr (object, "preserveAspectRatio");
+    object->readAttr( "viewBox" );
+    object->readAttr( "preserveAspectRatio" );
 
     if (((SPObjectClass *) parent_class)->build)
         ((SPObjectClass *) parent_class)->build (object, document, repr);
@@ -200,7 +200,7 @@ sp_symbol_set (SPObject *object, unsigned int key, const gchar *value)
                 align = SP_ASPECT_XMIN_YMID;
             } else if (!strcmp (c, "xMidYMid")) {
                 align = SP_ASPECT_XMID_YMID;
-            } else if (!strcmp (c, "xMaxYMin")) {
+            } else if (!strcmp (c, "xMaxYMid")) {
                 align = SP_ASPECT_XMAX_YMID;
             } else if (!strcmp (c, "xMinYMax")) {
                 align = SP_ASPECT_XMIN_YMAX;
@@ -213,7 +213,7 @@ sp_symbol_set (SPObject *object, unsigned int key, const gchar *value)
             }
             clip = SP_ASPECT_MEET;
             while (*e && *e == 32) e += 1;
-            if (e) {
+            if (*e) {
                 if (!strcmp (e, "meet")) {
                     clip = SP_ASPECT_MEET;
                 } else if (!strcmp (e, "slice")) {
@@ -269,7 +269,7 @@ sp_symbol_update (SPObject *object, SPCtx *ctx, guint flags)
 
         /* Calculate child to parent transformation */
         /* Apply parent <use> translation (set up as vewport) */
-        symbol->c2p = NR::Matrix(NR::translate(rctx.vp.x0, rctx.vp.y0));
+        symbol->c2p = Geom::Matrix(Geom::Translate(rctx.vp.x0, rctx.vp.y0));
 
         if (symbol->viewBox_set) {
             double x, y, width, height;
@@ -352,7 +352,7 @@ sp_symbol_update (SPObject *object, SPCtx *ctx, guint flags)
             rctx.vp.y0 = symbol->viewBox.y0;
             rctx.vp.x1 = symbol->viewBox.x1;
             rctx.vp.y1 = symbol->viewBox.y1;
-            rctx.i2vp = NR::identity();
+            rctx.i2vp = Geom::identity();
         }
 
         /* And invoke parent method */
@@ -392,11 +392,15 @@ sp_symbol_write (SPObject *object, Inkscape::XML::Document *xml_doc, Inkscape::X
         repr = xml_doc->createElement("svg:symbol");
     }
 
-    repr->setAttribute("viewBox", object->repr->attribute("viewBox"));
-    repr->setAttribute("preserveAspectRatio", object->repr->attribute("preserveAspectRatio"));
+    //XML Tree being used directly here while it shouldn't be.
+    repr->setAttribute("viewBox", object->getRepr()->attribute("viewBox"));
+       
+    //XML Tree being used directly here while it shouldn't be.
+    repr->setAttribute("preserveAspectRatio", object->getRepr()->attribute("preserveAspectRatio"));
 
-    if (((SPObjectClass *) (parent_class))->write)
+    if (((SPObjectClass *) (parent_class))->write) {
         ((SPObjectClass *) (parent_class))->write (object, xml_doc, repr, flags);
+    }
 
     return repr;
 }
@@ -441,7 +445,7 @@ sp_symbol_hide (SPItem *item, unsigned int key)
 }
 
 static void
-sp_symbol_bbox(SPItem const *item, NRRect *bbox, NR::Matrix const &transform, unsigned const flags)
+sp_symbol_bbox(SPItem const *item, NRRect *bbox, Geom::Matrix const &transform, unsigned const flags)
 {
     SPSymbol const *symbol = SP_SYMBOL(item);
 
@@ -449,7 +453,7 @@ sp_symbol_bbox(SPItem const *item, NRRect *bbox, NR::Matrix const &transform, un
         /* Cloned <symbol> is actually renderable */
 
         if (((SPItemClass *) (parent_class))->bbox) {
-            Geom::Matrix const a( symbol->c2p * (Geom::Matrix)transform );
+            Geom::Matrix const a( symbol->c2p * transform );
             ((SPItemClass *) (parent_class))->bbox(item, bbox, a, flags);
         }
     }