mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-08-14 09:59:20 +02:00
LazReport, fix loading of old binary reports (older than version 28), modified patch from Tsvetoslav, issue #27179
git-svn-id: trunk@49154 -
This commit is contained in:
parent
3be8873d05
commit
a16431b3ac
@ -20,7 +20,7 @@ uses
|
|||||||
Dialogs, Menus, Variants, DB, Graphics, Printers, osPrinters, LazUTF8, DOM,
|
Dialogs, Menus, Variants, DB, Graphics, Printers, osPrinters, LazUTF8, DOM,
|
||||||
XMLWrite, XMLRead, XMLConf, LCLType, LCLIntf, TypInfo, LR_View, LR_Pars,
|
XMLWrite, XMLRead, XMLConf, LCLType, LCLIntf, TypInfo, LR_View, LR_Pars,
|
||||||
LR_Intrp, LR_DSet, LR_DBSet, LR_DBRel, LR_Const, DbCtrls, LazUtf8Classes,
|
LR_Intrp, LR_DSet, LR_DBSet, LR_DBRel, LR_Const, DbCtrls, LazUtf8Classes,
|
||||||
LazLoggerBase;
|
LCLProc;
|
||||||
|
|
||||||
const
|
const
|
||||||
lrMaxBandsInReport = 256; //temp fix. in future need remove this limit
|
lrMaxBandsInReport = 256; //temp fix. in future need remove this limit
|
||||||
@ -2727,12 +2727,13 @@ var
|
|||||||
i : Integer;
|
i : Integer;
|
||||||
begin
|
begin
|
||||||
{$IFDEF DebugLR}
|
{$IFDEF DebugLR}
|
||||||
DebugLn('%s.TfrView.LoadFromStream begin StreamMode=%d ClassName=%s',
|
DebugLn('%s.TfrView.LoadFromStream begin StreamMode=%d ClassName=%s Stream.Position=%d',
|
||||||
[name,Ord(StreamMode),ClassName]);
|
[name,Ord(StreamMode),ClassName, Stream.Position]);
|
||||||
{$ENDIF}
|
{$ENDIF}
|
||||||
with Stream do
|
with Stream do
|
||||||
begin
|
begin
|
||||||
// if StreamMode = smDesigning then
|
|
||||||
|
if (frVersion>27) or ((frVersion=27) and lrCanReadName(Stream)) or (StreamMode = smDesigning) then
|
||||||
begin
|
begin
|
||||||
if frVersion >= 23 then
|
if frVersion >= 23 then
|
||||||
fName := ReadString(Stream)
|
fName := ReadString(Stream)
|
||||||
@ -2806,7 +2807,7 @@ begin
|
|||||||
|
|
||||||
end;
|
end;
|
||||||
{$IFDEF DebugLR}
|
{$IFDEF DebugLR}
|
||||||
DebugLn('%s.TfrView.LoadFromStream end',[name]);
|
DebugLn('%s.TfrView.LoadFromStream end Position=%d',[name, Stream.Position]);
|
||||||
{$ENDIF}
|
{$ENDIF}
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
@ -69,6 +69,7 @@ function lrStrToDateTime(AValue: string): TDateTime;
|
|||||||
function lrExpandVariables(const S:string):string;
|
function lrExpandVariables(const S:string):string;
|
||||||
procedure lrNormalizeLocaleFloats(DisableLocale: boolean);
|
procedure lrNormalizeLocaleFloats(DisableLocale: boolean);
|
||||||
function lrConfigFolderName(ACreatePath: boolean): string;
|
function lrConfigFolderName(ACreatePath: boolean): string;
|
||||||
|
function lrCanReadName(Stream: TStream): boolean;
|
||||||
|
|
||||||
procedure CanvasTextRectJustify(const Canvas:TCanvas;
|
procedure CanvasTextRectJustify(const Canvas:TCanvas;
|
||||||
const ARect: TRect; X1, X2, Y: integer; const Text: string;
|
const ARect: TRect; X1, X2, Y: integer; const Text: string;
|
||||||
@ -923,6 +924,34 @@ begin
|
|||||||
raise EInOutError.Create(SysUtils.Format(lrsUnableToCreateConfigDirectoryS,[Result]));
|
raise EInOutError.Create(SysUtils.Format(lrsUnableToCreateConfigDirectoryS,[Result]));
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
function lrCanReadName(Stream: TStream): boolean;
|
||||||
|
var
|
||||||
|
oldPosition: Int64;
|
||||||
|
aName: string;
|
||||||
|
n: Integer;
|
||||||
|
begin
|
||||||
|
// normally stream is seek-able so this should work....
|
||||||
|
oldPosition := stream.Position;
|
||||||
|
result := false;
|
||||||
|
try
|
||||||
|
try
|
||||||
|
n := stream.ReadWord;
|
||||||
|
setLength(aName, n);
|
||||||
|
stream.Read(aName[1], n);
|
||||||
|
if (n>0) and (stream.ReadByte=0) then begin
|
||||||
|
// unfortunately, objects names are not validated
|
||||||
|
// only check standard names here
|
||||||
|
while (n>0) and (aName[n] in ['a'..'z','A'..'Z','0'..'9','_']) do
|
||||||
|
dec(n);
|
||||||
|
result := (n=0);
|
||||||
|
end;
|
||||||
|
except
|
||||||
|
end;
|
||||||
|
finally
|
||||||
|
Stream.Position := oldPosition;
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
|
||||||
function UTF8Desc(S: string; var Desc: string): Integer;
|
function UTF8Desc(S: string; var Desc: string): Integer;
|
||||||
// create Desc as an array with Desc[i] is the size of the UTF-8 codepoint
|
// create Desc as an array with Desc[i] is the size of the UTF-8 codepoint
|
||||||
var
|
var
|
||||||
|
Loading…
Reference in New Issue
Block a user