diff options
Diffstat (limited to 'src/ui/dialog/spellcheck.cpp')
| -rw-r--r-- | src/ui/dialog/spellcheck.cpp | 88 |
1 files changed, 45 insertions, 43 deletions
diff --git a/src/ui/dialog/spellcheck.cpp b/src/ui/dialog/spellcheck.cpp index 00bd445bf..8a4ddc57e 100644 --- a/src/ui/dialog/spellcheck.cpp +++ b/src/ui/dialog/spellcheck.cpp @@ -590,52 +590,54 @@ SpellCheck::nextWord() // draw rect std::vector<Geom::Point> points = _layout->createSelectionShape(_begin_w, _end_w, _text->i2dt_affine()); - Geom::Point tl, br; - tl = br = points.front(); - for (unsigned i = 0 ; i < points.size() ; i ++) { - if (points[i][Geom::X] < tl[Geom::X]) - tl[Geom::X] = points[i][Geom::X]; - if (points[i][Geom::Y] < tl[Geom::Y]) - tl[Geom::Y] = points[i][Geom::Y]; - if (points[i][Geom::X] > br[Geom::X]) - br[Geom::X] = points[i][Geom::X]; - if (points[i][Geom::Y] > br[Geom::Y]) - br[Geom::Y] = points[i][Geom::Y]; - } + if (points.size() >= 4) { // we may not have a single quad if this is a clipped part of text on path; in that case skip drawing the rect + Geom::Point tl, br; + tl = br = points.front(); + for (unsigned i = 0 ; i < points.size() ; i ++) { + if (points[i][Geom::X] < tl[Geom::X]) + tl[Geom::X] = points[i][Geom::X]; + if (points[i][Geom::Y] < tl[Geom::Y]) + tl[Geom::Y] = points[i][Geom::Y]; + if (points[i][Geom::X] > br[Geom::X]) + br[Geom::X] = points[i][Geom::X]; + if (points[i][Geom::Y] > br[Geom::Y]) + br[Geom::Y] = points[i][Geom::Y]; + } - // expand slightly - Geom::Rect area = Geom::Rect(tl, br); - double mindim = fabs(tl[Geom::Y] - br[Geom::Y]); - if (fabs(tl[Geom::X] - br[Geom::X]) < mindim) - mindim = fabs(tl[Geom::X] - br[Geom::X]); - area.expandBy(MAX(0.05 * mindim, 1)); - - // create canvas path rectangle, red stroke - SPCanvasItem *rect = sp_canvas_bpath_new(sp_desktop_sketch(desktop), NULL); - sp_canvas_bpath_set_stroke(SP_CANVAS_BPATH(rect), 0xff0000ff, 3.0, SP_STROKE_LINEJOIN_MITER, SP_STROKE_LINECAP_BUTT); - sp_canvas_bpath_set_fill(SP_CANVAS_BPATH(rect), 0, SP_WIND_RULE_NONZERO); - SPCurve *curve = new SPCurve(); - curve->moveto(area.corner(0)); - curve->lineto(area.corner(1)); - curve->lineto(area.corner(2)); - curve->lineto(area.corner(3)); - curve->lineto(area.corner(0)); - sp_canvas_bpath_set_bpath(SP_CANVAS_BPATH(rect), curve); - sp_canvas_item_show(rect); - _rects = g_slist_prepend(_rects, rect); - - // scroll to make it all visible - Geom::Point const center = desktop->get_display_area().midpoint(); - area.expandBy(0.5 * mindim); - Geom::Point scrollto; - double dist = 0; - for (unsigned corner = 0; corner < 4; corner ++) { - if (Geom::L2(area.corner(corner) - center) > dist) { - dist = Geom::L2(area.corner(corner) - center); - scrollto = area.corner(corner); + // expand slightly + Geom::Rect area = Geom::Rect(tl, br); + double mindim = fabs(tl[Geom::Y] - br[Geom::Y]); + if (fabs(tl[Geom::X] - br[Geom::X]) < mindim) + mindim = fabs(tl[Geom::X] - br[Geom::X]); + area.expandBy(MAX(0.05 * mindim, 1)); + + // create canvas path rectangle, red stroke + SPCanvasItem *rect = sp_canvas_bpath_new(sp_desktop_sketch(desktop), NULL); + sp_canvas_bpath_set_stroke(SP_CANVAS_BPATH(rect), 0xff0000ff, 3.0, SP_STROKE_LINEJOIN_MITER, SP_STROKE_LINECAP_BUTT); + sp_canvas_bpath_set_fill(SP_CANVAS_BPATH(rect), 0, SP_WIND_RULE_NONZERO); + SPCurve *curve = new SPCurve(); + curve->moveto(area.corner(0)); + curve->lineto(area.corner(1)); + curve->lineto(area.corner(2)); + curve->lineto(area.corner(3)); + curve->lineto(area.corner(0)); + sp_canvas_bpath_set_bpath(SP_CANVAS_BPATH(rect), curve); + sp_canvas_item_show(rect); + _rects = g_slist_prepend(_rects, rect); + + // scroll to make it all visible + Geom::Point const center = desktop->get_display_area().midpoint(); + area.expandBy(0.5 * mindim); + Geom::Point scrollto; + double dist = 0; + for (unsigned corner = 0; corner < 4; corner ++) { + if (Geom::L2(area.corner(corner) - center) > dist) { + dist = Geom::L2(area.corner(corner) - center); + scrollto = area.corner(corner); + } } + desktop->scroll_to_point (scrollto, 1.0); } - desktop->scroll_to_point (scrollto, 1.0); // select text; if in Text tool, position cursor to the beginning of word // unless it is already in the word |
