diff options
| author | Adib Taraben <theadib@gmail.com> | 2009-03-17 22:03:14 +0000 |
|---|---|---|
| committer | theadib <theadib@users.sourceforge.net> | 2009-03-17 22:03:14 +0000 |
| commit | ae23aedad6bd0fef5a682672e867b7737bc18c0e (patch) | |
| tree | c37cd51ba7f36703e08750425123076347c50b40 /src | |
| parent | "Align nodes" icons fixed (diff) | |
| download | inkscape-ae23aedad6bd0fef5a682672e867b7737bc18c0e.tar.gz inkscape-ae23aedad6bd0fef5a682672e867b7737bc18c0e.zip | |
resolve Bug #339349, drop shadow effect broken
(bzr r7514)
Diffstat (limited to 'src')
| -rw-r--r-- | src/helper-fns.h | 61 |
1 files changed, 53 insertions, 8 deletions
diff --git a/src/helper-fns.h b/src/helper-fns.h index 43c90063b..9d3380bf2 100644 --- a/src/helper-fns.h +++ b/src/helper-fns.h @@ -1,12 +1,12 @@ #ifndef SEEN_HELPER_FNS_H #define SEEN_HELPER_FNS_H /** \file - * + * * Some helper functions - * + * * Authors: * Felipe CorrĂȘa da Silva Sanches <felipe.sanches@gmail.com> - * + * * * Copyright (C) 2006 Hugo Rodrigues * @@ -22,17 +22,22 @@ // can be more clear. #define HELPERFNS_NO_WARNING false -/* Setting warning to false disables conversion error warnings from +/* convert localized ascii representation to double + * the function can only be used to convert numbers as given by gui elements that use localized representation + * @param value ascii representation of the number + * @return the converted number + * + * Setting warning to false disables conversion error warnings from * this function. This can be useful in places, where the input type * is not known beforehand. For example, see sp_feColorMatrix_set in * sp-fecolormatrix.cpp */ inline double helperfns_read_number(gchar const *value, bool warning = true) { if (!value) return 0; char *end; - double ret = g_ascii_strtod(value, &end); + double ret = g_strtod(value, &end); if (*end) { if (warning) { - g_warning("Unable to convert \"%s\" to number", value); + g_warning("helper-fns::helperfns_read_number() Unable to convert \"%s\" to number", value); } // We could leave this out, too. If strtod can't convert // anything, it will return zero. @@ -54,19 +59,59 @@ inline bool helperfns_read_bool(gchar const *value, bool default_value){ return default_value; } +/* convert localized ascii representation to double + * the function can only be used to convert numbers as given by gui elements that use localized representation + * numbers are delimeted by space + * @param value ascii representation of the number + * @param size number of elements in string + * @return the vector of the converted numbers + */ inline std::vector<gdouble> helperfns_read_vector(const gchar* value, int size){ std::vector<gdouble> v(size, (gdouble) 0); std::istringstream is(value); - for(int i = 0; i < size && (is >> v[i]); i++){}; + for(int i = 0; i < size; i++){ + std::string str; + is >> str; + char *end; + + double ret = g_strtod(str.c_str(), &end); + if (*end) { + g_warning("helper-fns::helperfns_read_vector() Unable to convert \"%s\" to number", str.c_str()); + // We could leave this out, too. If strtod can't convert + // anything, it will return zero. + ret = 0; + } + v[i] = ret; + }; return v; } +/* convert localized ascii representation to double + * the function can only be used to convert numbers as given by gui elements that use localized representation + * numbers are delimeted by space + * @param value ascii representation of the number + * @return the vector of the converted numbers + */ inline std::vector<gdouble> helperfns_read_vector(const gchar* value){ std::vector<gdouble> v; std::istringstream is(value); gdouble d; - while (is >> d){ + std::string str; + + is >> str; + while(str.size()) + { + char *end; + double ret = g_strtod(str.c_str(), &end); + if (*end){ + g_warning("helper-fns::helperfns_read_vector() Unable to convert \"%s\" to number", str.c_str()); + // We could leave this out, too. If strtod can't convert + // anything, it will return zero. + ret = 0; + } v.push_back(d); + + is >> str; } return v; } |
