=== modified file 'src/box3d.cpp' Index: src/box3d.cpp =================================================================== --- src/box3d.cpp.orig +++ src/box3d.cpp @@ -15,12 +15,14 @@ * Released under GNU GPL, read the file 'COPYING' for more information */ +#include "box3d.h" + #include #include "attributes.h" #include "xml/document.h" #include "xml/repr.h" -#include "box3d.h" +#include "bad-uri-exception.h" #include "box3d-side.h" #include "ui/tools/box3d-tool.h" #include "proj_pt.h" Index: src/filters/image.cpp =================================================================== --- src/filters/image.cpp.orig +++ src/filters/image.cpp @@ -14,14 +14,17 @@ * Released under GNU GPL, read the file 'COPYING' for more information */ +#include "image.h" + #include + +#include "bad-uri-exception.h" #include "display/nr-filter-image.h" #include "uri.h" #include "uri-references.h" #include "enums.h" #include "attributes.h" #include "svg/svg.h" -#include "image.h" #include "xml/repr.h" #include Index: src/inkgc/gc-core.h =================================================================== --- src/inkgc/gc-core.h.orig +++ src/inkgc/gc-core.h @@ -18,7 +18,7 @@ #include #include -#include + #ifdef HAVE_GC_GC_H # include #else @@ -137,7 +137,6 @@ inline void *operator new(std::size_t si Inkscape::GC::CollectionPolicy collect, Inkscape::GC::CleanupFunc cleanup=NULL, void *data=NULL) -throw(std::bad_alloc) { using namespace Inkscape::GC; @@ -168,7 +167,6 @@ inline void *operator new(std::size_t si Inkscape::GC::ScanPolicy scan, Inkscape::GC::CleanupFunc cleanup=NULL, void *data=NULL) -throw(std::bad_alloc) { return operator new(size, scan, Inkscape::GC::AUTO, cleanup, data); } @@ -178,7 +176,6 @@ inline void *operator new[](std::size_t Inkscape::GC::CollectionPolicy collect, Inkscape::GC::CleanupFunc cleanup=NULL, void *data=NULL) -throw(std::bad_alloc) { return operator new(size, scan, collect, cleanup, data); } @@ -187,7 +184,6 @@ inline void *operator new[](std::size_t Inkscape::GC::ScanPolicy scan, Inkscape::GC::CleanupFunc cleanup=NULL, void *data=NULL) -throw(std::bad_alloc) { return operator new[](size, scan, Inkscape::GC::AUTO, cleanup, data); } Index: src/inkgc/gc-managed.h =================================================================== --- src/inkgc/gc-managed.h.orig +++ src/inkgc/gc-managed.h @@ -30,7 +30,6 @@ public: void *operator new(std::size_t size, ScanPolicy scan=default_scan, CollectionPolicy collect=default_collect) - throw (std::bad_alloc) { return ::operator new(size, scan, collect); } @@ -38,7 +37,6 @@ public: void *operator new[](std::size_t size, ScanPolicy scan=default_scan, CollectionPolicy collect=default_collect) - throw (std::bad_alloc) { return ::operator new[](size, scan, collect); } Index: src/inkgc/gc.cpp =================================================================== --- src/inkgc/gc.cpp.orig +++ src/inkgc/gc.cpp @@ -173,7 +173,7 @@ public: {} }; -Ops const &get_ops() throw (InvalidGCModeError) { +Ops const &get_ops() { char *mode_string=std::getenv("_INKSCAPE_GC"); if (mode_string) { if (!std::strcmp(mode_string, "enable")) { Index: src/live_effects/lpeobject-reference.cpp =================================================================== --- src/live_effects/lpeobject-reference.cpp.orig +++ src/live_effects/lpeobject-reference.cpp @@ -6,10 +6,12 @@ * Released under GNU GPL, read the file 'COPYING' for more information. */ +#include "live_effects/lpeobject-reference.h" + #include #include "enums.h" -#include "live_effects/lpeobject-reference.h" +#include "bad-uri-exception.h" #include "live_effects/lpeobject.h" #include "uri.h" Index: src/live_effects/parameter/path.cpp =================================================================== --- src/live_effects/parameter/path.cpp.orig +++ src/live_effects/parameter/path.cpp @@ -5,10 +5,16 @@ * Released under GNU GPL, read the file 'COPYING' for more information */ -#include "ui/widget/point.h" +#include "live_effects/parameter/path.h" + #include -#include "live_effects/parameter/path.h" +#include +#include + +#include "bad-uri-exception.h" +#include "ui/widget/point.h" + #include "live_effects/effect.h" #include "svg/svg.h" #include <2geom/svg-path-parser.h> @@ -17,7 +23,6 @@ #include <2geom/d2.h> #include "widgets/icon.h" -#include #include "selection-chemistry.h" #include "xml/repr.h" #include "desktop.h" @@ -44,8 +49,6 @@ #include "ui/tool/multi-path-manipulator.h" #include "ui/tool/shape-record.h" -#include -#include #include "ui/icon-names.h" namespace Inkscape { Index: src/sp-conn-end.cpp =================================================================== --- src/sp-conn-end.cpp.orig +++ src/sp-conn-end.cpp @@ -1,11 +1,12 @@ +#include "sp-conn-end.h" #include #include #include +#include "bad-uri-exception.h" #include "display/curve.h" #include "xml/repr.h" -#include "sp-conn-end.h" #include "sp-path.h" #include "uri.h" #include "document.h" Index: src/sp-filter.cpp =================================================================== --- src/sp-filter.cpp.orig +++ src/sp-filter.cpp @@ -17,16 +17,17 @@ # include "config.h" #endif +#include "sp-filter.h" + #include #include -using std::map; -using std::pair; #include + +#include "bad-uri-exception.h" #include "attributes.h" #include "display/nr-filter.h" #include "document.h" -#include "sp-filter.h" #include "sp-filter-reference.h" #include "sp-filter-primitive.h" #include "sp-item.h" @@ -35,6 +36,9 @@ using std::pair; #include #include +using std::map; +using std::pair; + #define SP_MACROS_SILENT #include "macros.h" Index: src/sp-gradient.cpp =================================================================== --- src/sp-gradient.cpp.orig +++ src/sp-gradient.cpp @@ -24,6 +24,8 @@ #define noSP_GRADIENT_VERBOSE //#define OBJECT_TRACE +#include "bad-uri-exception.h" + #include #include Index: src/sp-hatch.cpp =================================================================== --- src/sp-hatch.cpp.orig +++ src/sp-hatch.cpp @@ -12,11 +12,14 @@ * Released under GNU GPL, read the file 'COPYING' for more information */ + #include #include + #include <2geom/transforms.h> #include +#include "bad-uri-exception.h" #include "svg/svg.h" #include "display/cairo-utils.h" #include "display/drawing-context.h" Index: src/sp-item.cpp =================================================================== --- src/sp-item.cpp.orig +++ src/sp-item.cpp @@ -17,6 +17,10 @@ #endif #include "sp-item.h" + +#include + +#include "bad-uri-exception.h" #include "svg/svg.h" #include "print.h" #include "display/drawing-item.h" @@ -25,10 +29,7 @@ #include "uri.h" #include "inkscape.h" #include "desktop.h" - - #include "style.h" -#include #include "sp-root.h" #include "sp-clippath.h" #include "sp-mask.h" Index: src/sp-lpe-item.cpp =================================================================== --- src/sp-lpe-item.cpp.orig +++ src/sp-lpe-item.cpp @@ -16,10 +16,11 @@ # include "config.h" #endif -#include "ui/tool/multi-path-manipulator.h" - #include +#include "bad-uri-exception.h" +#include "ui/tool/multi-path-manipulator.h" + #include "live_effects/effect.h" #include "live_effects/lpe-path_length.h" #include "live_effects/lpeobject.h" Index: src/sp-offset.cpp =================================================================== --- src/sp-offset.cpp.orig +++ src/sp-offset.cpp @@ -18,13 +18,17 @@ # include "config.h" #endif +#include "sp-offset.h" + #include #include +#include + +#include "bad-uri-exception.h" #include "svg/svg.h" #include "attributes.h" #include "display/curve.h" -#include #include "livarot/Path.h" #include "livarot/Shape.h" @@ -32,7 +36,6 @@ #include "enums.h" #include "preferences.h" #include "sp-text.h" -#include "sp-offset.h" #include "sp-use-reference.h" #include "uri.h" Index: src/sp-pattern.cpp =================================================================== --- src/sp-pattern.cpp.orig +++ src/sp-pattern.cpp @@ -16,12 +16,15 @@ #include "config.h" #endif +#include "sp-pattern.h" + #include #include #include #include <2geom/transforms.h> #include +#include "bad-uri-exception.h" #include "svg/svg.h" #include "display/cairo-utils.h" #include "display/drawing-context.h" @@ -32,7 +35,6 @@ #include "document-private.h" #include "uri.h" #include "style.h" -#include "sp-pattern.h" #include "xml/repr.h" #include "sp-factory.h" Index: src/sp-tag-use-reference.cpp =================================================================== --- src/sp-tag-use-reference.cpp.orig +++ src/sp-tag-use-reference.cpp @@ -6,13 +6,15 @@ * Released under GNU GPL, read the file 'COPYING' for more information. */ +#include "sp-tag-use-reference.h" + #include #include #include #include "enums.h" -#include "sp-tag-use-reference.h" +#include "bad-uri-exception.h" #include "display/curve.h" #include "livarot/Path.h" #include "preferences.h" Index: src/sp-tag-use.cpp =================================================================== --- src/sp-tag-use.cpp.orig +++ src/sp-tag-use.cpp @@ -10,10 +10,14 @@ * Released under GNU GPL, read the file 'COPYING' for more information */ +#include "sp-tag-use.h" + #include #include #include + +#include "bad-uri-exception.h" #include "display/drawing-group.h" #include "attributes.h" #include "document.h" @@ -23,7 +27,6 @@ #include "style.h" #include "sp-factory.h" #include "sp-symbol.h" -#include "sp-tag-use.h" #include "sp-tag-use-reference.h" SPTagUse::SPTagUse() Index: src/sp-tag-use.h =================================================================== --- src/sp-tag-use.h.orig +++ src/sp-tag-use.h @@ -22,6 +22,7 @@ #define SP_TAG_USE(obj) (dynamic_cast (obj)) #define SP_IS_TAG_USE(obj) (dynamic_cast (obj) != NULL) +class SPItem; class SPTagUse; class SPTagUseReference; Index: src/sp-tref.cpp =================================================================== --- src/sp-tref.cpp.orig +++ src/sp-tref.cpp @@ -16,14 +16,16 @@ * Released under GNU GPL, read the file 'COPYING' for more information */ +#include "sp-tref.h" + #include +#include "bad-uri-exception.h" #include "attributes.h" #include "document.h" #include "sp-factory.h" #include "sp-text.h" #include "sp-tspan.h" -#include "sp-tref.h" #include "style.h" #include "text-editing.h" #include "uri.h" Index: src/sp-use-reference.cpp =================================================================== --- src/sp-use-reference.cpp.orig +++ src/sp-use-reference.cpp @@ -7,12 +7,14 @@ * Released under GNU GPL, read the file 'COPYING' for more information. */ +#include "sp-use-reference.h" + #include #include #include +#include "bad-uri-exception.h" #include "enums.h" -#include "sp-use-reference.h" #include "display/curve.h" #include "livarot/Path.h" Index: src/sp-use.cpp =================================================================== --- src/sp-use.cpp.orig +++ src/sp-use.cpp @@ -19,6 +19,8 @@ #include <2geom/transforms.h> #include #include + +#include "bad-uri-exception.h" #include "display/drawing-group.h" #include "attributes.h" #include "document.h" Index: src/style-internal.cpp =================================================================== --- src/style-internal.cpp.orig +++ src/style-internal.cpp @@ -28,6 +28,8 @@ #include "style-internal.h" #include "style-enums.h" +#include +#include "bad-uri-exception.h" #include "style.h" #include "svg/svg.h" @@ -45,8 +47,6 @@ #include #include -#include - // TODO REMOVE OR MAKE MEMBER FUNCTIONS void sp_style_fill_paint_server_ref_changed( SPObject *old_ref, SPObject *ref, SPStyle *style); void sp_style_stroke_paint_server_ref_changed(SPObject *old_ref, SPObject *ref, SPStyle *style); Index: src/style.cpp =================================================================== --- src/style.cpp.orig +++ src/style.cpp @@ -23,10 +23,15 @@ # include "config.h" #endif +#include "style.h" + #include #include #include +#include + +#include "bad-uri-exception.h" #include "libcroco/cr-sel-eng.h" #include "xml/croco-node-iface.h" @@ -43,7 +48,6 @@ #include "sp-paint-server.h" #include "streq.h" #include "strneq.h" -#include "style.h" #include "svg/css-ostringstream.h" #include "xml/repr.h" #include "xml/simple-document.h" @@ -58,8 +62,6 @@ #include <2geom/math-utils.h> -#include - using Inkscape::CSSOStringStream; using std::vector; Index: src/trace/trace.h =================================================================== --- src/trace/trace.h.orig +++ src/trace/trace.h @@ -13,10 +13,6 @@ # include "config.h" #endif -#ifdef HAVE_STDLIB_H -# include -#endif - #ifdef HAVE_STRING_H # include #endif Index: src/ui/tools/flood-tool.cpp =================================================================== --- src/ui/tools/flood-tool.cpp.orig +++ src/ui/tools/flood-tool.cpp @@ -21,6 +21,7 @@ #include "config.h" #endif +#include #include "trace/potrace/inkscape-potrace.h" #include <2geom/pathvector.h> #include @@ -196,6 +197,21 @@ inline unsigned char * get_trace_pixel(g } /** + * \brief Check whether two unsigned integers are close to each other + * + * \param[in] a The 1st unsigned int + * \param[in] b The 2nd unsigned int + * \param[in] d The threshold for comparison + * + * \return true if |a-b| <= d; false otherwise + */ +static bool compare_guint32(guint32 const a, guint32 const b, guint32 const d) +{ + const int difference = std::abs(static_cast(a) - static_cast(b)); + return difference <= d; +} + +/** * Compare a pixel in a pixel buffer with another pixel to determine if a point should be included in the fill operation. * @param check The pixel in the pixel buffer to check. * @param orig The original selected pixel to use as the fill target color. @@ -206,7 +222,6 @@ inline unsigned char * get_trace_pixel(g */ static bool compare_pixels(guint32 check, guint32 orig, guint32 merged_orig_pixel, guint32 dtc, int threshold, PaintBucketChannels method) { - int diff = 0; float hsl_check[3] = {0,0,0}, hsl_orig[3] = {0,0,0}; guint32 ac = 0, rc = 0, gc = 0, bc = 0; @@ -232,27 +247,35 @@ static bool compare_pixels(guint32 check switch (method) { case FLOOD_CHANNELS_ALPHA: - return abs(static_cast(ac) - ao) <= threshold; + return compare_guint32(ac, ao, threshold); case FLOOD_CHANNELS_R: - return abs(static_cast(ac ? unpremul_alpha(rc, ac) : 0) - (ao ? unpremul_alpha(ro, ao) : 0)) <= threshold; + return compare_guint32(ac ? unpremul_alpha(rc, ac) : 0, + ao ? unpremul_alpha(ro, ao) : 0, + threshold); case FLOOD_CHANNELS_G: - return abs(static_cast(ac ? unpremul_alpha(gc, ac) : 0) - (ao ? unpremul_alpha(go, ao) : 0)) <= threshold; + return compare_guint32(ac ? unpremul_alpha(gc, ac) : 0, + ao ? unpremul_alpha(go, ao) : 0, + threshold); case FLOOD_CHANNELS_B: - return abs(static_cast(ac ? unpremul_alpha(bc, ac) : 0) - (ao ? unpremul_alpha(bo, ao) : 0)) <= threshold; + return compare_guint32(ac ? unpremul_alpha(bc, ac) : 0, + ao ? unpremul_alpha(bo, ao) : 0, + threshold); case FLOOD_CHANNELS_RGB: - guint32 amc, rmc, bmc, gmc; - //amc = 255*255 - (255-ac)*(255-ad); amc = (amc + 127) / 255; - //amc = (255-ac)*ad + 255*ac; amc = (amc + 127) / 255; - amc = 255; // Why are we looking at desktop? Cairo version ignores destop alpha - rmc = (255-ac)*rd + 255*rc; rmc = (rmc + 127) / 255; - gmc = (255-ac)*gd + 255*gc; gmc = (gmc + 127) / 255; - bmc = (255-ac)*bd + 255*bc; bmc = (bmc + 127) / 255; - - diff += abs(static_cast(amc ? unpremul_alpha(rmc, amc) : 0) - (amop ? unpremul_alpha(rmop, amop) : 0)); - diff += abs(static_cast(amc ? unpremul_alpha(gmc, amc) : 0) - (amop ? unpremul_alpha(gmop, amop) : 0)); - diff += abs(static_cast(amc ? unpremul_alpha(bmc, amc) : 0) - (amop ? unpremul_alpha(bmop, amop) : 0)); - return ((diff / 3) <= ((threshold * 3) / 4)); - + { + guint32 amc, rmc, bmc, gmc; + //amc = 255*255 - (255-ac)*(255-ad); amc = (amc + 127) / 255; + //amc = (255-ac)*ad + 255*ac; amc = (amc + 127) / 255; + amc = 255; // Why are we looking at desktop? Cairo version ignores destop alpha + rmc = (255-ac)*rd + 255*rc; rmc = (rmc + 127) / 255; + gmc = (255-ac)*gd + 255*gc; gmc = (gmc + 127) / 255; + bmc = (255-ac)*bd + 255*bc; bmc = (bmc + 127) / 255; + + int diff = 0; // The total difference between each of the 3 color components + diff += std::abs(static_cast(amc ? unpremul_alpha(rmc, amc) : 0) - static_cast(amop ? unpremul_alpha(rmop, amop) : 0)); + diff += std::abs(static_cast(amc ? unpremul_alpha(gmc, amc) : 0) - static_cast(amop ? unpremul_alpha(gmop, amop) : 0)); + diff += std::abs(static_cast(amc ? unpremul_alpha(bmc, amc) : 0) - static_cast(amop ? unpremul_alpha(bmop, amop) : 0)); + return ((diff / 3) <= ((threshold * 3) / 4)); + } case FLOOD_CHANNELS_H: return ((int)(fabs(hsl_check[0] - hsl_orig[0]) * 100.0) <= threshold); case FLOOD_CHANNELS_S: Index: src/uri-references.cpp =================================================================== --- src/uri-references.cpp.orig +++ src/uri-references.cpp @@ -11,17 +11,20 @@ * Released under GNU GPL, read the file 'COPYING' for more information */ +#include "uri-references.h" + #include #include #include +#include + +#include "bad-uri-exception.h" #include "document.h" #include "sp-object.h" #include "uri.h" -#include "uri-references.h" #include "extract-uri.h" #include "sp-tag-use.h" -#include #include namespace Inkscape { @@ -104,7 +107,7 @@ bool URIReference::_acceptObject(SPObjec -void URIReference::attach(const URI &uri) throw(BadURIException) +void URIReference::attach(const URI &uri) { SPDocument *document = NULL; Index: src/uri-references.h =================================================================== --- src/uri-references.h.orig +++ src/uri-references.h @@ -20,7 +20,6 @@ #include #include -#include "bad-uri-exception.h" #include "sp-object.h" #include "sp-item.h" #include "sp-use.h" @@ -66,7 +65,7 @@ public: * @param rel_document document for relative URIs * @param uri the URI to watch */ - void attach(URI const& uri) throw(BadURIException); + void attach(URI const& uri); /** * Detaches from the currently attached URI target, if any; Index: src/uri.cpp =================================================================== --- src/uri.cpp.orig +++ src/uri.cpp @@ -8,12 +8,14 @@ * Released under GNU GPL, read the file 'COPYING' for more information */ -#include #include "uri.h" + #include #include #include +#include "bad-uri-exception.h" + namespace Inkscape { URI::URI() { @@ -26,7 +28,7 @@ URI::URI(const URI &uri) { _impl = uri._impl; } -URI::URI(gchar const *preformed) throw(BadURIException) { +URI::URI(gchar const *preformed) { xmlURIPtr uri; if (!preformed) { throw MalformedURIException(); @@ -133,7 +135,7 @@ const gchar *URI::Impl::getOpaque() cons return (gchar *)_uri->opaque; } -gchar *URI::to_native_filename(gchar const* uri) throw(BadURIException) +gchar *URI::to_native_filename(gchar const* uri) { gchar *filename = NULL; URI tmp(uri); @@ -167,7 +169,7 @@ const std::string URI::getFullPath(std:: /* TODO !!! proper error handling */ -gchar *URI::toNativeFilename() const throw(BadURIException) { +gchar *URI::toNativeFilename() const { gchar *uriString = toString(); if (isRelativePath()) { return uriString; @@ -182,7 +184,7 @@ gchar *URI::toNativeFilename() const thr } } -URI URI::fromUtf8( gchar const* path ) throw (BadURIException) { +URI URI::fromUtf8( gchar const* path ) { if ( !path ) { throw MalformedURIException(); } @@ -216,7 +218,7 @@ URI URI::fromUtf8( gchar const* path ) t } /* TODO !!! proper error handling */ -URI URI::from_native_filename(gchar const *path) throw(BadURIException) { +URI URI::from_native_filename(gchar const *path) { gchar *uri = g_filename_to_uri(path, NULL, NULL); URI result(uri); g_free( uri ); Index: src/uri.h =================================================================== --- src/uri.h.orig +++ src/uri.h @@ -13,7 +13,6 @@ #include #include -#include "bad-uri-exception.h" #include namespace Inkscape { @@ -37,7 +36,7 @@ public: * * @param preformed Properly quoted C-style string to be represented. */ - explicit URI(char const *preformed) throw(BadURIException); + explicit URI(char const *preformed); /** * Destructor. @@ -98,15 +97,15 @@ public: const char *getOpaque() const { return _impl->getOpaque(); } - static URI fromUtf8( char const* path ) throw (BadURIException); + static URI fromUtf8( char const* path ); - static URI from_native_filename(char const *path) throw(BadURIException); + static URI from_native_filename(char const *path); - static char *to_native_filename(char const* uri) throw(BadURIException); + static char *to_native_filename(char const* uri); const std::string getFullPath(std::string const &base) const; - char *toNativeFilename() const throw(BadURIException); + char *toNativeFilename() const; /** * Returns a glib string version of this URI.