X-Git-Url: https://git.tokkee.org/?a=blobdiff_plain;f=src%2Fconditions.cpp;h=d35f18cf1f66391e942ce2ef2422ec77c9de0ca6;hb=6302669b796eadd6994ecdc2e70f0119b29194dd;hp=c431600f361d095cf8294c5fe6c2102feff6d143;hpb=b45b3ca12c271745b18a142d10a6ac8efd9f79cc;p=inkscape.git diff --git a/src/conditions.cpp b/src/conditions.cpp index c431600f3..d35f18cf1 100644 --- a/src/conditions.cpp +++ b/src/conditions.cpp @@ -1,10 +1,9 @@ -#define __SP_CONDITIONS_CPP__ - /* * SVG conditional attribute evaluation * * Authors: * Andrius R. + * Abhishek Sharma * * Copyright (C) 2006 authors * @@ -39,20 +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); - if ( NULL == value ) - continue; - - if (!_condition_handlers[i].evaluator(item, value)) - return false; + 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 ( 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')) @@ -108,7 +103,7 @@ static bool evaluateSystemLanguage(SPItem const *item, gchar const *value) { if (language_codes.empty()) return false; - Document *document = SP_OBJECT_DOCUMENT(item); + SPDocument *document = SP_OBJECT_DOCUMENT(item); Glib::ustring document_language = document->getLanguage(); if (document_language.size() == 0) @@ -459,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 :