From b0a664c5d580f8ec62fcd662048973510a0a0705 Mon Sep 17 00:00:00 2001 From: mattias Date: Mon, 19 Feb 2024 17:24:58 +0100 Subject: [PATCH] turbopower_ipro: fixed init props after break line when last token hast different props than first --- .../turbopower_ipro/iphtmlblocklayout.pas | 29 ++++++++++++++----- components/turbopower_ipro/iphtmlnodes.pas | 8 ++--- 2 files changed, 25 insertions(+), 12 deletions(-) diff --git a/components/turbopower_ipro/iphtmlblocklayout.pas b/components/turbopower_ipro/iphtmlblocklayout.pas index 1826f84811..04080b2017 100644 --- a/components/turbopower_ipro/iphtmlblocklayout.pas +++ b/components/turbopower_ipro/iphtmlblocklayout.pas @@ -7,7 +7,7 @@ interface uses // LCL - LCLIntf, // Must be before Types + LCLIntf, LazLoggerBase, // Must be before Types // RTL, FCL Types, Classes, SysUtils, // LCL @@ -212,7 +212,7 @@ var R : TRect; begin OffsetRect(FPageRect, dx, dy); - for i := 0 to Pred(FElementQueue.Count) do begin + for i := 0 to FElementQueue.Count-1 do begin CurElem := PIpHtmlElement(FElementQueue[i]); R := CurElem^.WordRect2; if R.Bottom <> 0 then begin @@ -826,11 +826,11 @@ end; procedure TIpNodeBlockLayouter.LayoutQueue(TargetRect: TRect); var - WW, X0, ExpLIndent, RectWidth : Integer; + WW, X0, ExpLIndent, RectWidth, i : Integer; FirstElem, LastElem : Integer; PendingIndent, PendingOutdent : Integer; - Prefor : Boolean; - CurElem : PIpHtmlElement; + Prefor, NeedProps: Boolean; + CurElem, PropsElem: PIpHtmlElement; wi: PWordInfo; lfh: Integer; @@ -949,11 +949,24 @@ begin iElem := FirstElem; while iElem <= LastElem do begin InitInner; + NeedProps := true; while iElem < FElementQueue.Count do begin FCanBreak := False; CurElem := PIpHtmlElement(FElementQueue[iElem]); - if CurElem.Props <> nil then - ApplyQueueProps(CurElem, Prefor); + PropsElem := CurElem; + if (PropsElem.Props = nil) and NeedProps then begin + // Props exists only for elements with different attributes compared to previous sibling + // -> search previous element with Props + i := iElem; + while (i>=0) and (PIpHtmlElement(FElementQueue[i]).Props=nil) do + dec(i); + if i>=0 then + PropsElem:=PIpHtmlElement(FElementQueue[i]); + end; + if PropsElem.Props <> nil then begin + ApplyQueueProps(PropsElem, Prefor); + NeedProps:=false; + end; FSoftLF := False; case CurElem.ElementType of etWord : @@ -1289,7 +1302,7 @@ var begin P := FIpHtml.PagePtToScreen(aCurWord.WordRect2.TopLeft); - // We dont't want clipped lines at the top of the preview + // We don't want clipped lines at the top of the preview if (FIpHtml.RenderDevice = rdPreview) and (P.Y < 0) and (FIpHtml.PageViewRect.Top = FIpHtml.PageViewTop) then diff --git a/components/turbopower_ipro/iphtmlnodes.pas b/components/turbopower_ipro/iphtmlnodes.pas index eabd6bbcaf..c77d9c2249 100644 --- a/components/turbopower_ipro/iphtmlnodes.pas +++ b/components/turbopower_ipro/iphtmlnodes.pas @@ -9,7 +9,7 @@ uses // LCL LCLType, LCLIntf, // RTL, FCL - Types, Classes, SysUtils, + Types, Math, Classes, SysUtils, // LCL Graphics, GraphUtil, Controls, StdCtrls, ExtCtrls, Buttons, Dialogs, @@ -3911,18 +3911,18 @@ begin end; hfsSMALL: begin - Props.FontSize := Props.FontSize - 2; + Props.FontSize := Max(Props.FontSize - 2, 0); ElementName := 'small'; end; hfsSUB: begin - Props.FontSize := Props.FontSize - 4; + Props.FontSize := Max(Props.FontSize - 4, 0); Props.FontBaseline := Props.FontBaseline - 2; ElementName := 'sub'; end; hfsSUP: begin - Props.FontSize := Props.FontSize - 4; + Props.FontSize := Max(Props.FontSize - 4, 0); Props.FontBaseline := Props.FontBaseline + 4; ElementName := 'sup'; end;