memo: Changes the LFM writer to store the lines without wordwrap so that this information is not lost, see bug #30659

git-svn-id: trunk@53052 -
This commit is contained in:
sekelsenmat 2016-09-29 07:47:23 +00:00
parent b7265a7a7e
commit 9ead143427
5 changed files with 68 additions and 5 deletions

View File

@ -26,7 +26,7 @@ uses
// rtl+ftl
Classes, SysUtils,
// LCL
LCLProc, LCLType, Graphics, Controls, StdCtrls, LazUtf8Classes,
LCLProc, LCLType, Graphics, Controls, StdCtrls, LazUtf8Classes, textstrings,
// LCL Carbon
CarbonEdits, CarbonListViews;
@ -80,7 +80,7 @@ type
{ TCarbonMemoStrings }
TCarbonMemoStrings = class(TStrings)
TCarbonMemoStrings = class(TCustomMemoStrings)
private
FOwner: TCarbonMemo; // Carbon memo control owning strings
protected

View File

@ -27,7 +27,7 @@ uses
MacOSAll, CocoaAll, Classes, sysutils,
// LCL
Controls, StdCtrls, Graphics, LCLType, LMessages, LCLProc, LCLMessageGlue,
LazUtf8Classes,
LazUtf8Classes, textstrings,
// Widgetset
WSStdCtrls, WSLCLClasses, WSControls, WSProc,
// LCL Cocoa
@ -134,7 +134,7 @@ type
{ TCocoaMemoStrings }
TCocoaMemoStrings = class(TStrings)
TCocoaMemoStrings = class(TCustomMemoStrings)
private
FTextView: NSTextView;
public

View File

@ -113,6 +113,11 @@ end;"/>
<ValueDescriptions Count="2"/>
</Item2>
</BuildMacros>
<Linking>
<Debugging>
<DebugInfoType Value="dsDwarf2"/>
</Debugging>
</Linking>
<Other>
<CompilerMessages>
<IgnoredMessages idx5044="True"/>

View File

@ -13,6 +13,11 @@
</SearchPaths>
<Conditionals Value="if SrcOS&lt;>'win' then
UnitPath := 'nonwin32';"/>
<Linking>
<Debugging>
<DebugInfoType Value="dsDwarf2"/>
</Debugging>
</Linking>
<Other>
<Verbosity>
<ShowNotes Value="False"/>

View File

@ -16,6 +16,10 @@
TTextStrings is a TStrings descendent that is optimized for handling the
complete text as whole (instead of as line by line as in TStringList).
TCustomMemoStrings is a TStrings descendent which works around the behavior
of TMemo.Lines, which contains the text with wordwrap line endings, in order
to store the text in the LFM without those wordwrap line endings. See bug 30659
}
unit TextStrings;
@ -37,7 +41,14 @@ type
end;
PTextLineRange = ^TTextLineRange;
TTextStrings = class(TStrings)
TCustomMemoStrings = class(TStrings)
protected
procedure DoReadData(Reader: TReader); virtual;
procedure DoWriteData(Writer: TWriter); virtual;
procedure DefineProperties(Filer: TFiler); override;
end;
TTextStrings = class(TCustomMemoStrings)
private
FOnChange: TNotifyEvent;
FOnChanging: TNotifyEvent;
@ -90,6 +101,48 @@ type
implementation
{ TCustomMemoStrings }
procedure TCustomMemoStrings.DoReadData(Reader: TReader);
begin
Reader.ReadListBegin;
BeginUpdate;
try
Clear;
while not Reader.EndOfList do
Add(Reader.ReadString);
finally
EndUpdate;
end;
Reader.ReadListEnd;
end;
procedure TCustomMemoStrings.DoWriteData(Writer: TWriter);
var
i: Integer;
lStringsNoWordWrap: TStringList;
begin
lStringsNoWordWrap := TStringList.Create;
try
lStringsNoWordWrap.Text := Text;
Writer.WriteListBegin;
for i := 0 to lStringsNoWordWrap.Count - 1 do
Writer.WriteString(lStringsNoWordWrap.Strings[i]);
Writer.WriteListEnd;
finally
lStringsNoWordWrap.Free;
end;
end;
procedure TCustomMemoStrings.DefineProperties(Filer: TFiler);
var
HasData: Boolean;
begin
HasData := Count > 0;
Filer.DefineProperty('Strings', @DoReadData, @DoWriteData, HasData);
end;
{ TTextStrings }
function TTextStrings.GetTextStr: string;