turbopower_ipro: fixed init props after break line when last token hast different props than first

This commit is contained in:
mattias 2024-02-19 17:24:58 +01:00
parent 05af6f9a4f
commit b0a664c5d5
2 changed files with 25 additions and 12 deletions

View File

@ -7,7 +7,7 @@ interface
uses uses
// LCL // LCL
LCLIntf, // Must be before Types LCLIntf, LazLoggerBase, // Must be before Types
// RTL, FCL // RTL, FCL
Types, Classes, SysUtils, Types, Classes, SysUtils,
// LCL // LCL
@ -212,7 +212,7 @@ var
R : TRect; R : TRect;
begin begin
OffsetRect(FPageRect, dx, dy); 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]); CurElem := PIpHtmlElement(FElementQueue[i]);
R := CurElem^.WordRect2; R := CurElem^.WordRect2;
if R.Bottom <> 0 then begin if R.Bottom <> 0 then begin
@ -826,11 +826,11 @@ end;
procedure TIpNodeBlockLayouter.LayoutQueue(TargetRect: TRect); procedure TIpNodeBlockLayouter.LayoutQueue(TargetRect: TRect);
var var
WW, X0, ExpLIndent, RectWidth : Integer; WW, X0, ExpLIndent, RectWidth, i : Integer;
FirstElem, LastElem : Integer; FirstElem, LastElem : Integer;
PendingIndent, PendingOutdent : Integer; PendingIndent, PendingOutdent : Integer;
Prefor : Boolean; Prefor, NeedProps: Boolean;
CurElem : PIpHtmlElement; CurElem, PropsElem: PIpHtmlElement;
wi: PWordInfo; wi: PWordInfo;
lfh: Integer; lfh: Integer;
@ -949,11 +949,24 @@ begin
iElem := FirstElem; iElem := FirstElem;
while iElem <= LastElem do begin while iElem <= LastElem do begin
InitInner; InitInner;
NeedProps := true;
while iElem < FElementQueue.Count do begin while iElem < FElementQueue.Count do begin
FCanBreak := False; FCanBreak := False;
CurElem := PIpHtmlElement(FElementQueue[iElem]); CurElem := PIpHtmlElement(FElementQueue[iElem]);
if CurElem.Props <> nil then PropsElem := CurElem;
ApplyQueueProps(CurElem, Prefor); 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; FSoftLF := False;
case CurElem.ElementType of case CurElem.ElementType of
etWord : etWord :
@ -1289,7 +1302,7 @@ var
begin begin
P := FIpHtml.PagePtToScreen(aCurWord.WordRect2.TopLeft); 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 if (FIpHtml.RenderDevice = rdPreview) and
(P.Y < 0) and (FIpHtml.PageViewRect.Top = FIpHtml.PageViewTop) (P.Y < 0) and (FIpHtml.PageViewRect.Top = FIpHtml.PageViewTop)
then then

View File

@ -9,7 +9,7 @@ uses
// LCL // LCL
LCLType, LCLIntf, LCLType, LCLIntf,
// RTL, FCL // RTL, FCL
Types, Classes, SysUtils, Types, Math, Classes, SysUtils,
// LCL // LCL
Graphics, GraphUtil, Graphics, GraphUtil,
Controls, StdCtrls, ExtCtrls, Buttons, Dialogs, Controls, StdCtrls, ExtCtrls, Buttons, Dialogs,
@ -3911,18 +3911,18 @@ begin
end; end;
hfsSMALL: hfsSMALL:
begin begin
Props.FontSize := Props.FontSize - 2; Props.FontSize := Max(Props.FontSize - 2, 0);
ElementName := 'small'; ElementName := 'small';
end; end;
hfsSUB: hfsSUB:
begin begin
Props.FontSize := Props.FontSize - 4; Props.FontSize := Max(Props.FontSize - 4, 0);
Props.FontBaseline := Props.FontBaseline - 2; Props.FontBaseline := Props.FontBaseline - 2;
ElementName := 'sub'; ElementName := 'sub';
end; end;
hfsSUP: hfsSUP:
begin begin
Props.FontSize := Props.FontSize - 4; Props.FontSize := Max(Props.FontSize - 4, 0);
Props.FontBaseline := Props.FontBaseline + 4; Props.FontBaseline := Props.FontBaseline + 4;
ElementName := 'sup'; ElementName := 'sup';
end; end;