Code

Merge and cleanup of GSoC C++-ification project.
[inkscape.git] / src / conditions.cpp
index 7087abac252753cedaa028fa633807d8544d3fd6..d35f18cf1f66391e942ce2ef2422ec77c9de0ca6 100644 (file)
@@ -1,10 +1,9 @@
-#define __SP_CONDITIONS_CPP__
-
 /*
  * SVG conditional attribute evaluation
  *
  * Authors:
  *   Andrius R. <knutux@gmail.com>
+ *   Abhishek Sharma
  *
  * Copyright (C) 2006 authors
  *
@@ -39,21 +38,16 @@ static Condition _condition_handlers[] = {
     { "requiredExtensions", evaluateRequiredExtensions },
 };
 
-/* function which evaluates if item should be displayed */
+// function which evaluates if item should be displayed
 bool sp_item_evaluate(SPItem const *item) {
-    //Inkscape::XML::Node *grepr = SP_OBJECT_REPR (item);
-    
-    for ( unsigned int i = 0 ; i < sizeof(_condition_handlers)/sizeof(_condition_handlers[0]) ; i++ ) {
-        //gchar const *value = grepr->attribute(_condition_handlers[i].attribute);
+    bool needDisplay = true;
+    for ( unsigned int i = 0 ; needDisplay && (i < sizeof(_condition_handlers) / sizeof(_condition_handlers[0])) ; i++ ) {
         gchar const *value = item->getAttribute(_condition_handlers[i].attribute);
-        if ( NULL == value )
-            continue;
-
-        if (!_condition_handlers[i].evaluator(item, value))
-            return false;
+        if ( value && !_condition_handlers[i].evaluator(item, value) ) {
+            needDisplay = false;
+        }
     }
-
-    return true;
+    return needDisplay;
 }
 
 #define ISALNUM(c)    (((c) >= 'a' && (c) <= 'z') || ((c) >= 'A' && (c) <= 'Z') || ((c) >= '0' && (c) <= '9'))
@@ -460,4 +454,4 @@ zu Zulu
   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 :