LazReport, added LoadFromXMLStream method

git-svn-id: trunk@26698 -
This commit is contained in:
jesus 2010-07-16 20:15:05 +00:00
parent 87dd07beb4
commit 761b821f12

View File

@ -16,9 +16,9 @@ interface
uses uses
SysUtils, Classes, MaskUtils, Controls, FileUtil, Forms, ComCtrls, Dialogs, SysUtils, Classes, MaskUtils, Controls, FileUtil, Forms, ComCtrls, Dialogs,
Menus, Variants, DB, Graphics, Printers, osPrinters, XMLConf, LCLType, LCLIntf, Menus, Variants, DB, Graphics, Printers, osPrinters, DOM, XMLRead, XMLConf, LCLType,
TypInfo, LCLProc,{$IFDEF UNIX}SysUtilsAdds,{$ENDIF} LR_View, LR_Pars, LR_Intrp, LCLIntf, TypInfo, LCLProc,{$IFDEF UNIX}SysUtilsAdds,{$ENDIF} LR_View, LR_Pars,
LR_DSet, LR_DBSet, LR_DBRel, LR_Const; LR_Intrp, LR_DSet, LR_DBSet, LR_DBRel, LR_Const;
const const
// object flags // object flags
@ -144,6 +144,7 @@ type
TLrXMLConfig = class (TXMLConfig) TLrXMLConfig = class (TXMLConfig)
public public
procedure LoadFromStream(const Stream: TStream);
procedure SetValue(const APath: string; const AValue: string); overload; procedure SetValue(const APath: string; const AValue: string); overload;
function GetValue(const APath: string; const ADefault: string): string; overload; function GetValue(const APath: string; const ADefault: string): string; overload;
end; end;
@ -944,6 +945,7 @@ type
procedure SaveToStream(Stream: TStream); procedure SaveToStream(Stream: TStream);
procedure LoadFromFile(const FName: String); procedure LoadFromFile(const FName: String);
procedure LoadFromXMLFile(const Fname: String); procedure LoadFromXMLFile(const Fname: String);
procedure LoadFromXMLStream(const Stream: TStream);
procedure SaveToFile(FName: String); procedure SaveToFile(FName: String);
procedure SavetoXML(XML: TLrXMLConfig; const Path: String); procedure SavetoXML(XML: TLrXMLConfig; const Path: String);
procedure SaveToXMLFile(const FName: String); procedure SaveToXMLFile(const FName: String);
@ -7909,6 +7911,20 @@ begin
end; end;
end; end;
procedure TfrReport.LoadFromXMLStream(const Stream: TStream);
var
XML: TLrXMLConfig;
begin
XML := TLrXMLConfig.Create(nil);
XML.LoadFromStream(Stream);
try
LoadFromXML(XML, 'LazReport/');
FileName := '-stream-';
finally
XML.Free;
end;
end;
procedure TfrReport.SaveToFile(FName: String); procedure TfrReport.SaveToFile(FName: String);
var var
Stream: TFileStream; Stream: TFileStream;
@ -10092,6 +10108,28 @@ end;
{ TLrXMLConfig } { TLrXMLConfig }
procedure TLrXMLConfig.LoadFromStream(const Stream: TStream);
begin
Flush;
FreeAndNil(Doc);
if csLoading in ComponentState then
exit;
if assigned(Stream) and not StartEmpty then
ReadXMLFile(Doc, Stream);
if not Assigned(Doc) then
Doc := TXMLDocument.Create;
if not Assigned(Doc.DocumentElement) then
Doc.AppendChild(Doc.CreateElement(RootName))
else
if Doc.DocumentElement.NodeName <> RootName then
raise EXMLConfigError.Create(SWrongRootName);
end;
procedure TLrXMLConfig.SetValue(const APath: string; const AValue: string); procedure TLrXMLConfig.SetValue(const APath: string; const AValue: string);
begin begin
inherited SetValue(UTF8Decode(APath), UTF8Decode(AValue)); inherited SetValue(UTF8Decode(APath), UTF8Decode(AValue));