mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-11-21 15:10:04 +01:00
Turbopower_ipro: Fix copying of table cells to clipboard.
git-svn-id: trunk@50166 -
This commit is contained in:
parent
461ea447a4
commit
14b69d092f
@ -332,7 +332,7 @@ type
|
|||||||
procedure UnmarkControl; virtual;
|
procedure UnmarkControl; virtual;
|
||||||
procedure HideUnmarkedControl; virtual;
|
procedure HideUnmarkedControl; virtual;
|
||||||
procedure EnumChildren(EnumProc: TIpHtmlNodeEnumProc; UserData: Pointer); virtual;
|
procedure EnumChildren(EnumProc: TIpHtmlNodeEnumProc; UserData: Pointer); virtual;
|
||||||
procedure AppendSelection(var S : string); virtual;
|
procedure AppendSelection(var S : string; var Completed: Boolean); virtual;
|
||||||
public
|
public
|
||||||
constructor Create(ParentNode : TIpHtmlNode);
|
constructor Create(ParentNode : TIpHtmlNode);
|
||||||
destructor Destroy; override;
|
destructor Destroy; override;
|
||||||
@ -368,7 +368,7 @@ type
|
|||||||
protected
|
protected
|
||||||
procedure ReportDrawRects(M : TRectMethod); override;
|
procedure ReportDrawRects(M : TRectMethod); override;
|
||||||
procedure ReportMapRects(M : TRectMethod); override;
|
procedure ReportMapRects(M : TRectMethod); override;
|
||||||
procedure AppendSelection(var S : string); override;
|
procedure AppendSelection(var S : string; var Completed: Boolean); override;
|
||||||
procedure EnumChildren(EnumProc: TIpHtmlNodeEnumProc; UserData: Pointer); override;
|
procedure EnumChildren(EnumProc: TIpHtmlNodeEnumProc; UserData: Pointer); override;
|
||||||
public
|
public
|
||||||
constructor Create(ParentNode : TIpHtmlNode);
|
constructor Create(ParentNode : TIpHtmlNode);
|
||||||
@ -487,7 +487,6 @@ type
|
|||||||
|
|
||||||
TIpHtmlNodeBlock = class(TIpHtmlNodeCore)
|
TIpHtmlNodeBlock = class(TIpHtmlNodeCore)
|
||||||
private
|
private
|
||||||
function CheckSelection(aSelIndex: Integer): Boolean;
|
|
||||||
function GetPageRect: TRect;
|
function GetPageRect: TRect;
|
||||||
protected
|
protected
|
||||||
FLayouter : TIpHtmlBaseLayouter;
|
FLayouter : TIpHtmlBaseLayouter;
|
||||||
@ -502,7 +501,7 @@ type
|
|||||||
function GetHeight(const RenderProps: TIpHtmlProps; const Width: Integer): Integer;
|
function GetHeight(const RenderProps: TIpHtmlProps; const Width: Integer): Integer;
|
||||||
procedure InvalidateSize; override;
|
procedure InvalidateSize; override;
|
||||||
procedure ReportCurDrawRects(aOwner: TIpHtmlNode; M : TRectMethod); override;
|
procedure ReportCurDrawRects(aOwner: TIpHtmlNode; M : TRectMethod); override;
|
||||||
procedure AppendSelection(var S : string); override;
|
procedure AppendSelection(var S : string; var Completed: Boolean); override;
|
||||||
procedure SetBackground(const AValue: string);
|
procedure SetBackground(const AValue: string);
|
||||||
procedure SetBgColor(const AValue: TColor);
|
procedure SetBgColor(const AValue: TColor);
|
||||||
procedure SetTextColor(const AValue: TColor);
|
procedure SetTextColor(const AValue: TColor);
|
||||||
@ -1472,7 +1471,7 @@ type
|
|||||||
procedure SetBgColor(const AValue: TColor);
|
procedure SetBgColor(const AValue: TColor);
|
||||||
procedure SetTextColor(const AValue: TColor);
|
procedure SetTextColor(const AValue: TColor);
|
||||||
protected
|
protected
|
||||||
procedure AppendSelection(var S: String); override;
|
procedure AppendSelection(var S: String; var Completed: Boolean); override;
|
||||||
public
|
public
|
||||||
constructor Create(ParentNode : TIpHtmlNode);
|
constructor Create(ParentNode : TIpHtmlNode);
|
||||||
procedure SetProps(const RenderProps: TIpHtmlProps); override;
|
procedure SetProps(const RenderProps: TIpHtmlProps); override;
|
||||||
@ -1499,7 +1498,7 @@ type
|
|||||||
FWidth: TIpHtmlLength;
|
FWidth: TIpHtmlLength;
|
||||||
FVAlign: TIpHtmlVAlign3;
|
FVAlign: TIpHtmlVAlign3;
|
||||||
protected
|
protected
|
||||||
procedure AppendSelection(var S: String); override;
|
procedure AppendSelection(var S: String; var Completed: Boolean); override;
|
||||||
procedure DimChanged(Sender: TObject);
|
procedure DimChanged(Sender: TObject);
|
||||||
public
|
public
|
||||||
FPadRect : TRect;
|
FPadRect : TRect;
|
||||||
@ -2693,7 +2692,7 @@ uses
|
|||||||
{$IFDEF Html_Print}
|
{$IFDEF Html_Print}
|
||||||
Printers, PrintersDlgs, IpHtmlPv,
|
Printers, PrintersDlgs, IpHtmlPv,
|
||||||
{$ENDIF}
|
{$ENDIF}
|
||||||
ipHtmlBlockLayout, ipHtmlTableLayout;
|
StrUtils, ipHtmlBlockLayout, ipHtmlTableLayout;
|
||||||
|
|
||||||
{$R *.res}
|
{$R *.res}
|
||||||
|
|
||||||
@ -3841,7 +3840,7 @@ begin
|
|||||||
FParentNode.ReportCurDrawRects(Owner, M);
|
FParentNode.ReportCurDrawRects(Owner, M);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure TIpHtmlNode.AppendSelection(var S: string);
|
procedure TIpHtmlNode.AppendSelection(var S: string; var Completed: Boolean);
|
||||||
begin
|
begin
|
||||||
end;
|
end;
|
||||||
|
|
||||||
@ -4286,13 +4285,17 @@ begin
|
|||||||
TIpHtmlNode(FChildren[i]).EnumChildren(EnumProc, UserData);
|
TIpHtmlNode(FChildren[i]).EnumChildren(EnumProc, UserData);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure TIpHtmlNodeMulti.AppendSelection(var S: string);
|
procedure TIpHtmlNodeMulti.AppendSelection(var S: string; var Completed: Boolean);
|
||||||
var
|
var
|
||||||
i : Integer;
|
i : Integer;
|
||||||
begin
|
begin
|
||||||
inherited;
|
if Completed then
|
||||||
|
exit;
|
||||||
for i := 0 to Pred(FChildren.Count) do
|
for i := 0 to Pred(FChildren.Count) do
|
||||||
TIpHtmlNode(FChildren[i]).AppendSelection(S);
|
begin
|
||||||
|
TIpHtmlNode(FChildren[i]).AppendSelection(S, Completed);
|
||||||
|
if Completed then exit;
|
||||||
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
{ TIpHtmlNodeBODY }
|
{ TIpHtmlNodeBODY }
|
||||||
@ -7768,7 +7771,6 @@ begin
|
|||||||
if not FAllSelected
|
if not FAllSelected
|
||||||
and ((FStartSel.x < 0) or (FEndSel.x < 0)) then Exit;
|
and ((FStartSel.x < 0) or (FEndSel.x < 0)) then Exit;
|
||||||
|
|
||||||
|
|
||||||
if not FAllSelected then begin
|
if not FAllSelected then begin
|
||||||
CurBlock := nil;
|
CurBlock := nil;
|
||||||
// search blocks that intersect the selection
|
// search blocks that intersect the selection
|
||||||
@ -8551,11 +8553,14 @@ end;
|
|||||||
procedure TIpHtml.CopyToClipboard;
|
procedure TIpHtml.CopyToClipboard;
|
||||||
var
|
var
|
||||||
S : string;
|
S : string;
|
||||||
|
completed: Boolean;
|
||||||
begin
|
begin
|
||||||
if HaveSelection then begin
|
if HaveSelection then begin
|
||||||
S := '';
|
S := '';
|
||||||
if FHtml <> nil then
|
if FHtml <> nil then begin
|
||||||
FHtml.AppendSelection(S);
|
completed := false; // terminate recursion if selection-end-point is found
|
||||||
|
FHtml.AppendSelection(S, completed);
|
||||||
|
end;
|
||||||
if S <> '' then begin
|
if S <> '' then begin
|
||||||
Clipboard.Open;
|
Clipboard.Open;
|
||||||
try
|
try
|
||||||
@ -9121,56 +9126,67 @@ begin
|
|||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
function TIpHtmlNodeBlock.CheckSelection(aSelIndex: Integer): Boolean;
|
|
||||||
var
|
|
||||||
CurElem : PIpHtmlElement;
|
|
||||||
R : TRect;
|
|
||||||
begin
|
|
||||||
CurElem := PIpHtmlElement(FLayouter.FElementQueue[aSelIndex]);
|
|
||||||
R := CurElem.WordRect2;
|
|
||||||
if (R.Bottom <> 0) and (R.Top > Owner.FStartSel.Y)
|
|
||||||
and (R.Bottom < Owner.FEndSel.Y) then
|
|
||||||
Exit(False)
|
|
||||||
else
|
|
||||||
if PtInRect(R, Owner.FStartSel) or PtInRect(R, Owner.FEndSel) then
|
|
||||||
Exit(False)
|
|
||||||
else
|
|
||||||
if (R.Bottom >= Owner.FStartSel.Y) and (R.Top <= Owner.FEndSel.Y)
|
|
||||||
and (R.Left >= Owner.FStartSel.X) and (R.Right <= Owner.FEndSel.X) then
|
|
||||||
Exit(False);
|
|
||||||
Result := True;
|
|
||||||
end;
|
|
||||||
|
|
||||||
function TIpHtmlNodeBlock.GetPageRect: TRect;
|
function TIpHtmlNodeBlock.GetPageRect: TRect;
|
||||||
begin
|
begin
|
||||||
Result := FLayouter.FPageRect;
|
Result := FLayouter.FPageRect;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure TIpHtmlNodeBlock.AppendSelection(var S: string);
|
procedure TIpHtmlNodeBlock.AppendSelection(var S: string; var Completed: Boolean);
|
||||||
var
|
var
|
||||||
LastY, StartSelIndex, EndSelIndex, i : Integer;
|
//LastY,
|
||||||
|
StartSelIndex, EndSelIndex, i, istart, iend : Integer;
|
||||||
CurElem : PIpHtmlElement;
|
CurElem : PIpHtmlElement;
|
||||||
R : TRect;
|
R : TRect;
|
||||||
LFDone : Boolean;
|
LFDone : Boolean;
|
||||||
|
EndPt: TPoint;
|
||||||
begin
|
begin
|
||||||
if not Owner.FAllSelected then begin
|
if Completed then
|
||||||
StartSelIndex := 0;
|
exit;
|
||||||
while StartSelIndex < FLayouter.FElementQueue.Count do begin
|
|
||||||
if not CheckSelection(StartSelIndex) then
|
StartSelIndex := 0;
|
||||||
Break;
|
EndSelIndex := pred(FLayouter.FElementQueue.Count);
|
||||||
Inc(StartSelIndex);
|
if not Owner.FAllSelected then
|
||||||
|
begin
|
||||||
|
// Find elements which contain the start-/end-selection-points
|
||||||
|
// Note: they may not be in correct order because the y coords of the start/end
|
||||||
|
// clicks may be reversed if in the same line of an etObject element!
|
||||||
|
istart := -1;
|
||||||
|
iend := -1;
|
||||||
|
for i:=0 to pred(FLayouter.FElementQueue.Count) do
|
||||||
|
begin
|
||||||
|
CurElem := PIpHtmlElement(FLayouter.FElementQueue[i]);
|
||||||
|
if PtInRect(CurElem^.WordRect2, Owner.FStartSel) then
|
||||||
|
istart := i;
|
||||||
|
if PtInRect(CurElem^.WordRect2, Owner.FEndSel) then
|
||||||
|
iend := i;
|
||||||
|
if (istart <> -1) and (iend <> -1) then
|
||||||
|
break;
|
||||||
end;
|
end;
|
||||||
EndSelIndex := Pred(FLayouter.FElementQueue.Count);
|
if (istart <> -1) and (iend <> -1) then
|
||||||
while EndSelIndex >= 0 do begin
|
begin
|
||||||
if not CheckSelection(EndSelIndex) then
|
if istart < iend then
|
||||||
Break;
|
begin
|
||||||
Dec(EndSelIndex);
|
StartSelIndex := istart;
|
||||||
|
EndSelIndex := iend;
|
||||||
|
EndPt := Owner.FEndSel;
|
||||||
|
end else
|
||||||
|
begin
|
||||||
|
StartSelIndex := iend;
|
||||||
|
EndSelIndex := istart;
|
||||||
|
EndPt := Owner.FStartSel;
|
||||||
|
end;
|
||||||
|
end else
|
||||||
|
if (istart <> -1) and (iend = -1) then
|
||||||
|
StartSelIndex := istart
|
||||||
|
else
|
||||||
|
if (istart = -1) and (iend <> -1) then
|
||||||
|
begin
|
||||||
|
EndSelIndex := iend;
|
||||||
|
EndPt := Owner.FEndSel;
|
||||||
end;
|
end;
|
||||||
end else begin
|
|
||||||
StartSelIndex := 0;
|
|
||||||
EndSelIndex := FLayouter.FElementQueue.Count - 1;
|
|
||||||
end;
|
end;
|
||||||
LastY := -1;
|
|
||||||
|
//LastY := -1;
|
||||||
LFDone := True;
|
LFDone := True;
|
||||||
for i := StartSelIndex to EndSelIndex do begin
|
for i := StartSelIndex to EndSelIndex do begin
|
||||||
CurElem := PIpHtmlElement(FLayouter.FElementQueue[i]);
|
CurElem := PIpHtmlElement(FLayouter.FElementQueue[i]);
|
||||||
@ -9181,6 +9197,7 @@ begin
|
|||||||
LFDone := True;
|
LFDone := True;
|
||||||
end;
|
end;
|
||||||
}
|
}
|
||||||
|
|
||||||
case CurElem.ElementType of
|
case CurElem.ElementType of
|
||||||
etWord :
|
etWord :
|
||||||
begin
|
begin
|
||||||
@ -9189,7 +9206,7 @@ begin
|
|||||||
end;
|
end;
|
||||||
etObject :
|
etObject :
|
||||||
begin
|
begin
|
||||||
TIpHtmlNodeAlignInline(CurElem.Owner).AppendSelection(S);
|
TIpHtmlNodeAlignInline(CurElem.Owner).AppendSelection(S, Completed);
|
||||||
LFDone := False;
|
LFDone := False;
|
||||||
end;
|
end;
|
||||||
etSoftLF..etClearBoth :
|
etSoftLF..etClearBoth :
|
||||||
@ -9198,7 +9215,16 @@ begin
|
|||||||
LFDone := True;
|
LFDone := True;
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
LastY := R.Top;
|
//LastY := R.Top;
|
||||||
|
|
||||||
|
// Prevent running over selection end if there is a etObject at this level
|
||||||
|
// of recursion.
|
||||||
|
if not Owner.FAllSelected then
|
||||||
|
if PtInRect(R, EndPt) then
|
||||||
|
begin
|
||||||
|
Completed := true;
|
||||||
|
exit;
|
||||||
|
end;
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
@ -10346,13 +10372,15 @@ begin
|
|||||||
FTextColor := -1;
|
FTextColor := -1;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure TIpHtmlNodeTR.AppendSelection(var S: String);
|
procedure TIpHtmlNodeTR.AppendSelection(var S: String; var Completed: Boolean);
|
||||||
var
|
var
|
||||||
prev: TIpHtmlNode;
|
prev: TIpHtmlNode;
|
||||||
begin
|
begin
|
||||||
|
if Completed then
|
||||||
|
exit;
|
||||||
prev := GetPrevSiblingNode(Self);
|
prev := GetPrevSiblingNode(Self);
|
||||||
if prev is TIpHtmlNodeTR then S := S + LineEnding;
|
if prev is TIpHtmlNodeTR then S := S + LineEnding;
|
||||||
inherited AppendSelection(S);
|
inherited AppendSelection(S, Completed);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure TIpHtmlNodeTR.SetBgColor(const AValue: TColor);
|
procedure TIpHtmlNodeTR.SetBgColor(const AValue: TColor);
|
||||||
@ -12476,13 +12504,16 @@ begin
|
|||||||
inherited;
|
inherited;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure TIpHtmlNodeTableHeaderOrCell.AppendSelection(var S: String);
|
procedure TIpHtmlNodeTableHeaderOrCell.AppendSelection(var S: String;
|
||||||
|
var Completed: Boolean);
|
||||||
var
|
var
|
||||||
prev: TIpHtmlNode;
|
prev: TIpHtmlNode;
|
||||||
begin
|
begin
|
||||||
|
if Completed then
|
||||||
|
exit;
|
||||||
prev := GetPrevSiblingNode(self);
|
prev := GetPrevSiblingNode(self);
|
||||||
if prev is TIpHtmlNodeTableHeaderOrCell then S := S + #9;
|
if prev is TIpHtmlNodeTableHeaderOrCell then S := S + #9;
|
||||||
inherited AppendSelection(S);
|
inherited AppendSelection(S, Completed);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure TIpHtmlNodeTableHeaderOrCell.CalcMinMaxPropWidth(RenderProps: TIpHtmlProps;
|
procedure TIpHtmlNodeTableHeaderOrCell.CalcMinMaxPropWidth(RenderProps: TIpHtmlProps;
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user