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

View File

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