From a3b813b5b27f754d86b041a594f113b6c04a9789 Mon Sep 17 00:00:00 2001 From: johanengelen Date: Mon, 7 Jul 2008 14:06:53 +0000 Subject: [PATCH] fix number of marker counting in shape --- src/sp-shape.cpp | 40 ++++++++++++++++++++++++++++++++-------- 1 file changed, 32 insertions(+), 8 deletions(-) diff --git a/src/sp-shape.cpp b/src/sp-shape.cpp index e38dba48f..308b5a1ba 100644 --- a/src/sp-shape.cpp +++ b/src/sp-shape.cpp @@ -799,20 +799,44 @@ sp_shape_has_markers (SPShape const *shape) int sp_shape_number_of_markers (SPShape *shape, int type) { -// TODO fixme: this looks very bad that the type parameter is ignored. Geom::PathVector const & pathv = shape->curve->get_pathvector(); - guint n = shape->marker[SP_MARKER_LOC_START] ? pathv.size() : 0; + switch(type) { + case SP_MARKER_LOC_START: + return shape->marker[SP_MARKER_LOC_START] ? pathv.size() : 0; - for(Geom::PathVector::const_iterator path_it = pathv.begin(); path_it != pathv.end(); ++path_it) { - n += shape->marker[SP_MARKER_LOC_MID] ? path_it->size() : 0; + case SP_MARKER_LOC_MID: + { + if ( shape->marker[SP_MARKER_LOC_MID] ) { + guint n = 0; + for(Geom::PathVector::const_iterator path_it = pathv.begin(); path_it != pathv.end(); ++path_it) { + n += path_it->size(); + n += path_it->closed() ? 1 : 0; + } + return n; + } else { + return 0; + } + } - if ( shape->marker[SP_MARKER_LOC_END] && !path_it->empty()) { - n++; + case SP_MARKER_LOC_END: + { + if ( shape->marker[SP_MARKER_LOC_END] ) { + guint n = 0; + for(Geom::PathVector::const_iterator path_it = pathv.begin(); path_it != pathv.end(); ++path_it) { + if (!path_it->empty()) { + n++; + } + } + return n; + } else { + return 0; + } } - } - return n; + default: + return 0; + } } /** -- 2.30.2