mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-11-07 12:49:29 +01:00
TurboPower_iPro: Remove occasional empty line at top of document. Fix horizontal text alignment in table cells.
git-svn-id: trunk@50145 -
This commit is contained in:
parent
9eae75a03b
commit
bb0313a2d6
@ -228,6 +228,9 @@ type
|
|||||||
|
|
||||||
{ TIpHtmlBaseLayouter }
|
{ TIpHtmlBaseLayouter }
|
||||||
|
|
||||||
|
TIpHtmlNodeIterator = procedure (ANode: TIpHtmlNode; AProps: TIpHtmlProps;
|
||||||
|
var Done: Boolean);
|
||||||
|
|
||||||
// Abstract base class for the HTML Layout engine
|
// Abstract base class for the HTML Layout engine
|
||||||
TIpHtmlBaseLayouter = class
|
TIpHtmlBaseLayouter = class
|
||||||
protected
|
protected
|
||||||
@ -236,6 +239,8 @@ type
|
|||||||
FCurProps : TIpHtmlProps;
|
FCurProps : TIpHtmlProps;
|
||||||
FBlockMin, FBlockMax : Integer;
|
FBlockMin, FBlockMax : Integer;
|
||||||
function GetProps: TIpHtmlProps;
|
function GetProps: TIpHtmlProps;
|
||||||
|
procedure RemoveLeadingLFs;
|
||||||
|
procedure RemoveDuplicateLFs;
|
||||||
public
|
public
|
||||||
FPageRect : TRect;
|
FPageRect : TRect;
|
||||||
constructor Create(AOwner: TIpHtmlNodeCore); virtual;
|
constructor Create(AOwner: TIpHtmlNodeCore); virtual;
|
||||||
@ -246,6 +251,7 @@ type
|
|||||||
procedure CalcMinMaxPropWidth(RenderProps: TIpHtmlProps;
|
procedure CalcMinMaxPropWidth(RenderProps: TIpHtmlProps;
|
||||||
var aMin, aMax: Integer); virtual; abstract;
|
var aMin, aMax: Integer); virtual; abstract;
|
||||||
procedure Render(RenderProps: TIpHtmlProps); virtual; abstract;
|
procedure Render(RenderProps: TIpHtmlProps); virtual; abstract;
|
||||||
|
procedure IterateParents(AProc: TIpHtmlNodeIterator);
|
||||||
public
|
public
|
||||||
property Props : TIpHtmlProps read GetProps;
|
property Props : TIpHtmlProps read GetProps;
|
||||||
end;
|
end;
|
||||||
@ -3577,6 +3583,52 @@ begin
|
|||||||
Result := FOwner.Props;
|
Result := FOwner.Props;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
procedure TIpHtmlBaseLayouter.IterateParents(AProc: TIpHtmlNodeIterator);
|
||||||
|
var
|
||||||
|
p: TIpHtmlNode;
|
||||||
|
done: Boolean;
|
||||||
|
begin
|
||||||
|
p := FOwner; //.FParentNode;
|
||||||
|
done := false;
|
||||||
|
while Assigned(p) do
|
||||||
|
begin
|
||||||
|
AProc(p, Props, done);
|
||||||
|
if done then
|
||||||
|
break
|
||||||
|
else
|
||||||
|
p := p.FParentNode;
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
|
||||||
|
procedure TIpHtmlBaseLayouter.RemoveLeadingLFs;
|
||||||
|
begin
|
||||||
|
while PIpHtmlElement(FElementQueue[0])^.ElementType in [etSoftLF, etHardLF] do
|
||||||
|
FElementQueue.Delete(0);
|
||||||
|
end;
|
||||||
|
|
||||||
|
procedure TIpHtmlBaseLayouter.RemoveDuplicateLFs;
|
||||||
|
var
|
||||||
|
i: Integer;
|
||||||
|
begin
|
||||||
|
i := pred(FElementQueue.Count);
|
||||||
|
while i >= 0 do begin
|
||||||
|
case PIpHtmlElement(FElementQueue[i])^.ElementType of
|
||||||
|
etSoftLF:
|
||||||
|
if (i > 0) and (PIpHtmlElement(FElementQueue[i-1])^.ElementType in [etSoftLF, etHardLF])
|
||||||
|
then FElementQueue.Delete(i);
|
||||||
|
{
|
||||||
|
etHardLF:
|
||||||
|
if (i > 0) and (PIpHtmlElement(FElementQueue[i-1])^.ElementType in [etSoftLF, etHardLF])
|
||||||
|
then begin
|
||||||
|
FElementQueue.Delete(i-1);
|
||||||
|
dec(i);
|
||||||
|
end;
|
||||||
|
}
|
||||||
|
end;
|
||||||
|
dec(i);
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
|
||||||
{ TIpHtmlBaseTableLayouter }
|
{ TIpHtmlBaseTableLayouter }
|
||||||
|
|
||||||
constructor TIpHtmlBaseTableLayouter.Create(AOwner: TIpHtmlNodeCore);
|
constructor TIpHtmlBaseTableLayouter.Create(AOwner: TIpHtmlNodeCore);
|
||||||
@ -7583,7 +7635,7 @@ end;
|
|||||||
|
|
||||||
function TIpHtml.ParseCellAlign(Default : TIpHtmlAlign): TIpHtmlAlign;
|
function TIpHtml.ParseCellAlign(Default : TIpHtmlAlign): TIpHtmlAlign;
|
||||||
begin
|
begin
|
||||||
Result := GetAlignmentForStr(FindAttribute(htmlAttrALIGN), haCenter);
|
Result := GetAlignmentForStr(FindAttribute(htmlAttrALIGN), Default);
|
||||||
// if FlagErrors then
|
// if FlagErrors then
|
||||||
// ReportError(SHtmlInvAlign);
|
// ReportError(SHtmlInvAlign);
|
||||||
end;
|
end;
|
||||||
@ -9183,7 +9235,9 @@ begin
|
|||||||
EnqueueElement(Owner.HardLF);
|
EnqueueElement(Owner.HardLF);
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
inherited Enqueue;
|
inherited Enqueue;
|
||||||
|
|
||||||
if FChildren.Count > 0 then begin
|
if FChildren.Count > 0 then begin
|
||||||
if not (FParentNode is TIpHtmlNodeTD) then begin
|
if not (FParentNode is TIpHtmlNodeTD) then begin
|
||||||
EnqueueElement(Owner.SoftLF);
|
EnqueueElement(Owner.SoftLF);
|
||||||
@ -10157,6 +10211,7 @@ begin
|
|||||||
end;
|
end;
|
||||||
}
|
}
|
||||||
EnqueueElement(Owner.SoftLF);
|
EnqueueElement(Owner.SoftLF);
|
||||||
|
EnqueueElement(Owner.HardLF);
|
||||||
|
|
||||||
EnqueueElement(Element);
|
EnqueueElement(Element);
|
||||||
|
|
||||||
@ -11037,8 +11092,10 @@ begin
|
|||||||
if FChildren.Count > 0 then
|
if FChildren.Count > 0 then
|
||||||
EnqueueElement(Owner.HardLF);
|
EnqueueElement(Owner.HardLF);
|
||||||
inherited Enqueue;
|
inherited Enqueue;
|
||||||
|
{
|
||||||
if FChildren.Count > 0 then
|
if FChildren.Count > 0 then
|
||||||
EnqueueElement(Owner.HardLF);
|
EnqueueElement(Owner.HardLF);
|
||||||
|
}
|
||||||
end;
|
end;
|
||||||
|
|
||||||
{ TIpHtmlNodeBLOCKQUOTE }
|
{ TIpHtmlNodeBLOCKQUOTE }
|
||||||
@ -15627,7 +15684,6 @@ begin
|
|||||||
FElementName := 'td';
|
FElementName := 'td';
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
|
||||||
{ TIpHtmlNodeCAPTION }
|
{ TIpHtmlNodeCAPTION }
|
||||||
|
|
||||||
constructor TIpHtmlNodeCAPTION.Create(ParentNode: TIpHtmlNode);
|
constructor TIpHtmlNodeCAPTION.Create(ParentNode: TIpHtmlNode);
|
||||||
|
|||||||
@ -183,7 +183,13 @@ end;
|
|||||||
|
|
||||||
procedure TIpNodeBlockLayouter.Layout(RenderProps: TIpHtmlProps; TargetRect: TRect);
|
procedure TIpNodeBlockLayouter.Layout(RenderProps: TIpHtmlProps; TargetRect: TRect);
|
||||||
begin
|
begin
|
||||||
if EqualRect(TargetRect, FBlockOwner.PageRect) then Exit;
|
if EqualRect(TargetRect, FBlockOwner.PageRect) then
|
||||||
|
exit;
|
||||||
|
|
||||||
|
if FBlockOwner is TIpHtmlNodeBody then
|
||||||
|
RemoveLeadingLFs;
|
||||||
|
RemoveDuplicateLFs;
|
||||||
|
|
||||||
if not RenderProps.IsEqualTo(Props) then
|
if not RenderProps.IsEqualTo(Props) then
|
||||||
begin
|
begin
|
||||||
Props.Assign(RenderProps);
|
Props.Assign(RenderProps);
|
||||||
@ -505,7 +511,7 @@ begin
|
|||||||
FBlockDescent := PropA.tmDescent;
|
FBlockDescent := PropA.tmDescent;
|
||||||
end;
|
end;
|
||||||
if (FCurProps = nil) or not BIsEqualTo(FCurProps) then begin
|
if (FCurProps = nil) or not BIsEqualTo(FCurProps) then begin
|
||||||
FAl := Alignment;
|
FAl := self.Props.Alignment; // was: FAl := Alignment
|
||||||
FVAL := VAlignment;
|
FVAL := VAlignment;
|
||||||
FBaseOffset := FontBaseline;
|
FBaseOffset := FontBaseline;
|
||||||
aPrefor := Preformatted;
|
aPrefor := Preformatted;
|
||||||
@ -1358,25 +1364,63 @@ begin
|
|||||||
inherited Destroy;
|
inherited Destroy;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
procedure GetAlignment(ANode: TIpHtmlNode; AProps: TIpHtmlProps; var Done: Boolean);
|
||||||
|
begin
|
||||||
|
if (ANode is TIpHtmlNodeSpan) then
|
||||||
|
begin
|
||||||
|
if (ANode as TIpHtmlNodeSpan).Align <> haDefault then
|
||||||
|
begin
|
||||||
|
AProps.Alignment := (ANode as TIpHtmlNodeSpan).Align;
|
||||||
|
Done := true;
|
||||||
|
end;
|
||||||
|
end else
|
||||||
|
if (ANode is TIpHtmlNodeTableHeaderOrCell) then
|
||||||
|
begin
|
||||||
|
if (ANode as TIpHtmlNodeTableHeaderOrCell).Align <> haDefault then
|
||||||
|
begin
|
||||||
|
AProps.Alignment := (ANode as TIpHtmlNodeTableHeaderOrCell).Align;
|
||||||
|
Done := true;
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
|
||||||
procedure TIpNodeTableElemLayouter.Layout(RenderProps: TIpHtmlProps; TargetRect: TRect);
|
procedure TIpNodeTableElemLayouter.Layout(RenderProps: TIpHtmlProps; TargetRect: TRect);
|
||||||
begin
|
begin
|
||||||
Props.Assign(RenderProps);
|
Props.Assign(RenderProps);
|
||||||
|
|
||||||
|
IterateParents(@GetAlignment);
|
||||||
|
if (Props.Alignment = haDefault) then
|
||||||
|
begin
|
||||||
|
if (FOwner is TIpHtmlNodeTD) then
|
||||||
|
Props.Alignment := haLeft
|
||||||
|
else
|
||||||
|
if (FOwner is TIpHtmlNodeTH) then
|
||||||
|
Props.Alignment := haCenter;
|
||||||
|
end;
|
||||||
|
|
||||||
|
{
|
||||||
if FTableElemOwner.Align <> haDefault then
|
if FTableElemOwner.Align <> haDefault then
|
||||||
Props.Alignment := FTableElemOwner.Align
|
Props.Alignment := FTableElemOwner.Align
|
||||||
else
|
else
|
||||||
if FOwner is TIpHtmlNodeTH then
|
if FOwner is TIpHtmlNodeTH then
|
||||||
Props.Alignment := haCenter;
|
Props.Alignment := haCenter;
|
||||||
|
}
|
||||||
|
|
||||||
if FOwner is TIpHtmlNodeTH then
|
if FOwner is TIpHtmlNodeTH then
|
||||||
Props.FontStyle := Props.FontStyle + [fsBold];
|
Props.FontStyle := Props.FontStyle + [fsBold];
|
||||||
|
|
||||||
if FTableElemOwner.NoWrap then
|
if FTableElemOwner.NoWrap then
|
||||||
Props.NoBreak := True;
|
Props.NoBreak := True;
|
||||||
|
|
||||||
case FTableElemOwner.VAlign of
|
case FTableElemOwner.VAlign of
|
||||||
hva3Default :;
|
hva3Default :;
|
||||||
else
|
else
|
||||||
Props.VAlignment := FTableElemOwner.VAlign;
|
Props.VAlignment := FTableElemOwner.VAlign;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
if FTableElemOwner.BgColor <> -1 then
|
if FTableElemOwner.BgColor <> -1 then
|
||||||
Props.BgColor := FTableElemOwner.BgColor;
|
Props.BgColor := FTableElemOwner.BgColor;
|
||||||
|
|
||||||
inherited Layout(Props, TargetRect);
|
inherited Layout(Props, TargetRect);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user