mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-06-28 11:08:23 +02:00
LCL: fixed TTextSTrings.AddStrings with objects and multi lines, bug #24749
git-svn-id: trunk@42103 -
This commit is contained in:
parent
de66005a39
commit
d63a40c020
@ -706,18 +706,45 @@ var
|
|||||||
s: String;
|
s: String;
|
||||||
i: Integer;
|
i: Integer;
|
||||||
OldCount: Integer;
|
OldCount: Integer;
|
||||||
|
AddEachLine: Boolean;
|
||||||
begin
|
begin
|
||||||
if TheStrings.Count=0 then exit;
|
if TheStrings.Count=0 then exit;
|
||||||
OldCount:=Count;
|
AddEachLine:=false;
|
||||||
if (FText<>'') and (not (FText[length(FText)] in [#10,#13])) then
|
if FArraysValid then begin
|
||||||
s:=LineEnding
|
for i:=0 to FLineCount-1 do
|
||||||
else
|
if FLineRanges[i].TheObject<>nil then begin
|
||||||
s:='';
|
// objects have to be kept
|
||||||
FArraysValid:=false;
|
AddEachLine:=true;
|
||||||
FText:=FText+s+TheStrings.Text;
|
break;
|
||||||
BuildArrays;
|
end;
|
||||||
for i:=0 to TheStrings.Count-1 do
|
end;
|
||||||
FLineRanges[i+OldCount].TheObject:=TheStrings.Objects[i];
|
if not AddEachLine then begin
|
||||||
|
for i:=0 to TheStrings.Count-1 do begin
|
||||||
|
s:=TheStrings[i];
|
||||||
|
if (Pos(#10,s)>0) or (Pos(#13,s)>0) then begin
|
||||||
|
// TheStrings contains a line with line breaks (multi lines)
|
||||||
|
AddEachLine:=true;
|
||||||
|
break;
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
if AddEachLine then begin
|
||||||
|
// append line by line, this can be very slow
|
||||||
|
for i:=0 to TheStrings.Count-1 do
|
||||||
|
AddObject(TheStrings[i],TheStrings.Objects[i]);
|
||||||
|
end else begin
|
||||||
|
// append the whole text at once
|
||||||
|
OldCount:=Count;
|
||||||
|
if (FText<>'') and (not (FText[length(FText)] in [#10,#13])) then
|
||||||
|
s:=LineEnding
|
||||||
|
else
|
||||||
|
s:='';
|
||||||
|
FArraysValid:=false;
|
||||||
|
FText:=FText+s+TheStrings.Text;
|
||||||
|
BuildArrays;
|
||||||
|
for i:=0 to TheStrings.Count-1 do
|
||||||
|
FLineRanges[i+OldCount].TheObject:=TheStrings.Objects[i];
|
||||||
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
end.
|
end.
|
||||||
|
Loading…
Reference in New Issue
Block a user