From 8a5364b8b7d89d23fbcfe977a90e19ba5bbbf5ae Mon Sep 17 00:00:00 2001 From: wp_xxyyzz Date: Sat, 23 Jan 2016 18:15:21 +0000 Subject: [PATCH] fpspeadsheet: Fix infinite loop in TsWorksheet if word-wrapped cell gets narrower than the width of a character. git-svn-id: https://svn.code.sf.net/p/lazarus-ccr/svn@4463 8e941d3f-bd1b-0410-a28a-d453659cc2b4 --- components/fpspreadsheet/fpspreadsheetgrid.pas | 6 +++--- components/fpspreadsheet/fpsvisualutils.pas | 5 ++++- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/components/fpspreadsheet/fpspreadsheetgrid.pas b/components/fpspreadsheet/fpspreadsheetgrid.pas index b2f105a00..75b2b551a 100644 --- a/components/fpspreadsheet/fpspreadsheetgrid.pas +++ b/components/fpspreadsheet/fpspreadsheetgrid.pas @@ -2191,9 +2191,9 @@ begin temp_rct := rct; // for i := gc1 to gc2 do begin for i:= gc2 downto gc1 do begin - //starting from last col will insure drawing grid lines below text - //when text is overflow in RTL and have no problem in LTR - // modification by "shobits1" + // Starting from last col will insure drawing grid lines below text + // when text is overflow in RTL and have no problem in LTR + // (Modification by "shobits1" - ok) ColRowToOffset(true, true, i, temp_rct.Left, temp_rct.Right); if HorizontalIntersect(temp_rct, clipArea) and (i <> gc) then begin diff --git a/components/fpspreadsheet/fpsvisualutils.pas b/components/fpspreadsheet/fpsvisualutils.pas index bbe487823..d242fc282 100644 --- a/components/fpspreadsheet/fpsvisualutils.pas +++ b/components/fpspreadsheet/fpsvisualutils.pas @@ -1439,7 +1439,10 @@ begin begin // (b) This is the only word in the line --> we break at the // current cursor position. - UTF8Delete(part, UTF8Length(part), 1); + if Length(part) = 1 then + NextChar(1) + else + UTF8Delete(part, UTF8Length(part), 1); end; EOL := true; break;