From 1f3e78f8963f40c7ce09a897e0e44c4b45a49575 Mon Sep 17 00:00:00 2001 From: wp_xxyyzz Date: Tue, 27 Sep 2016 17:16:47 +0000 Subject: [PATCH] fpspreadsheet: Fix word wrap algorithm getting stuck if column width is smaller than the character width. git-svn-id: https://svn.code.sf.net/p/lazarus-ccr/svn@5222 8e941d3f-bd1b-0410-a28a-d453659cc2b4 --- components/fpspreadsheet/fpsvisualutils.pas | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/components/fpspreadsheet/fpsvisualutils.pas b/components/fpspreadsheet/fpsvisualutils.pas index 493b6bdb5..2a278b4bc 100644 --- a/components/fpspreadsheet/fpsvisualutils.pas +++ b/components/fpspreadsheet/fpsvisualutils.pas @@ -737,6 +737,7 @@ procedure TsTextPainter.Prepare; var lineInfo: TsLineInfo; ts: TTextStyle; + oldPtr: PChar; begin FTotalHeight := 0; FMaxLinelen := 0; @@ -756,7 +757,10 @@ begin lineInfo := TsLineInfo.Create; lineInfo.pStart := FPtr; lineInfo.BeginsWithFontOfRtpIndex := FRtpIndex; + oldPtr := FPtr; ScanLine(lineInfo.NumSpaces, lineInfo.Width, lineInfo.Height, lineInfo.WordList); + if oldPtr = FPtr then // Detect scan is stuck + break; FLines.Add(lineinfo); FTotalHeight := FTotalHeight + IfThen(FTextRotation = rtStacked, 2, 1)*lineInfo.Height; FMaxLineLen := Max(FMaxLineLen, lineInfo.Width); @@ -947,6 +951,8 @@ begin NextChar(1) else UTF8Delete(part, UTF8Length(part), 1); + if part = '' then + EOL := true; end; EOL := true; break;