* Added SkipLastLineBreak to TStrings (bug ID 28213)

git-svn-id: trunk@32792 -
This commit is contained in:
michael 2015-12-29 18:48:58 +00:00
parent 67d0cd1770
commit 4f82d103af
2 changed files with 26 additions and 5 deletions

View File

@ -609,6 +609,7 @@ type
FUpdateCount: Integer;
FAdapter: IStringsAdapter;
FLBS : TTextLineBreakStyle;
FSkipLastLineBreak : Boolean;
FStrictDelimiter : Boolean;
FLineBreak : String;
function GetCommaText: string;
@ -630,6 +631,8 @@ type
Function GetQuoteChar: Char;
Function GetLineBreak : String;
procedure SetLineBreak(const S : String);
Function GetSkipLastLineBreak : Boolean;
procedure SetSkipLastLineBreak(const AValue : Boolean);
protected
procedure DefineProperties(Filer: TFiler); override;
procedure Error(const Msg: string; Data: Integer);
@ -704,6 +707,7 @@ type
property Strings[Index: Integer]: string read Get write Put; default;
property Text: string read GetTextStr write SetTextStr;
property StringsAdapter: IStringsAdapter read FAdapter write SetStringsAdapter;
Property SkipLastLineBreak : Boolean Read GetSkipLastLineBreak Write SetSkipLastLineBreak;
end;
{ TStringList class }

View File

@ -80,6 +80,20 @@ begin
end;
end;
Function TStrings.GetSkipLastLineBreak : Boolean;
begin
CheckSpecialChars;
Result:=FSkipLastLineBreak;
end;
procedure TStrings.SetSkipLastLineBreak(const AValue : Boolean);
begin
CheckSpecialChars;
FSkipLastLineBreak:=AValue;
end;
Function TStrings.GetLBS : TTextLineBreakStyle;
begin
CheckSpecialChars;
@ -512,6 +526,8 @@ begin
NLS:=Length(NL);
For I:=0 to count-1 do
L:=L+Length(Strings[I])+NLS;
if SkipLastLineBreak then
Dec(L,NLS);
Setlength(Result,L);
P:=Pointer(Result);
For i:=0 To count-1 do
@ -521,11 +537,12 @@ begin
if L<>0 then
System.Move(Pointer(S)^,P^,L);
P:=P+L;
For L:=1 to NLS do
begin
P^:=NL[L];
inc(P);
end;
if (I<Count-1) or Not SkipLastLineBreak then
For L:=1 to NLS do
begin
P^:=NL[L];
inc(P);
end;
end;
end;