mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-04-23 01:19:37 +02:00
* Add import possibility
git-svn-id: trunk@57841 -
This commit is contained in:
parent
4ed3446f8f
commit
be003a0639
2
.gitattributes
vendored
2
.gitattributes
vendored
@ -1561,6 +1561,8 @@ components/fpreport/design/frmfpreportvariables.lfm svneol=native#text/plain
|
||||
components/fpreport/design/frmfpreportvariables.pp svneol=native#text/plain
|
||||
components/fpreport/design/frmideselectreportdata.lfm svneol=native#text/plain
|
||||
components/fpreport/design/frmideselectreportdata.pp svneol=native#text/plain
|
||||
components/fpreport/design/frmlazreportimportlog.lfm svneol=native#text/plain
|
||||
components/fpreport/design/frmlazreportimportlog.pp svneol=native#text/plain
|
||||
components/fpreport/design/lazfpreportdesign.lpk svneol=native#text/plain
|
||||
components/fpreport/design/lazfpreportdesign.pas svneol=native#text/plain
|
||||
components/fpreport/design/lazidefpreport.lpk svneol=native#text/plain
|
||||
|
@ -385,6 +385,9 @@ object FPReportDesignerForm: TFPReportDesignerForm
|
||||
object MISaveAs: TMenuItem
|
||||
Action = AFileSaveAs
|
||||
end
|
||||
object MIImportLazReport: TMenuItem
|
||||
Action = AImportLazreport
|
||||
end
|
||||
object MIRecent: TMenuItem
|
||||
Caption = 'Recent'
|
||||
end
|
||||
@ -1002,6 +1005,11 @@ object FPReportDesignerForm: TFPReportDesignerForm
|
||||
OnExecute = ABringToFrontExecute
|
||||
OnUpdate = ASendToBackFrontUpdate
|
||||
end
|
||||
object AImportLazreport: TAction
|
||||
Caption = 'Import Lazreport...'
|
||||
OnExecute = AImportLazreportExecute
|
||||
OnUpdate = AImportLazreportUpdate
|
||||
end
|
||||
end
|
||||
object SDReport: TSaveDialog
|
||||
DefaultExt = '.json'
|
||||
@ -2428,4 +2436,10 @@ object FPReportDesignerForm: TFPReportDesignerForm
|
||||
left = 467
|
||||
top = 209
|
||||
end
|
||||
object ODImport: TOpenDialog
|
||||
Filter = 'LazReport reports|*.lrf|All files|*.*'
|
||||
Options = [ofFileMustExist, ofEnableSizing, ofViewDetail]
|
||||
left = 483
|
||||
top = 120
|
||||
end
|
||||
end
|
||||
|
@ -34,7 +34,8 @@ type
|
||||
rdoAllowNew, // Allow user to start new report
|
||||
rdoAllowPreview, // Allow user to ask report preview
|
||||
rdoAllowBands, // Allow user to add/remove bands
|
||||
rdoAllowFileDrop // Allow user to drop files on designer, so they will be loaded.
|
||||
rdoAllowFileDrop, // Allow user to drop files on designer, so they will be loaded.
|
||||
rdoAllowImport // Allow import of other formats (needs rdoAllowLoad as well)
|
||||
);
|
||||
TFPReportDesignOptions = set of TFPReportDesignOption;
|
||||
|
||||
@ -85,6 +86,7 @@ type
|
||||
AAlign: TAction;
|
||||
ACopy: TAction;
|
||||
ABringToFront: TAction;
|
||||
AImportLazreport: TAction;
|
||||
ASendToBack: TAction;
|
||||
AEditElement: TAction;
|
||||
AFileOpenNewWindow: TAction;
|
||||
@ -120,6 +122,7 @@ type
|
||||
MenuItem2: TMenuItem;
|
||||
MenuItem3: TMenuItem;
|
||||
MenuItem4: TMenuItem;
|
||||
MIImportLazReport: TMenuItem;
|
||||
MIBringToFront: TMenuItem;
|
||||
MISendToBack: TMenuItem;
|
||||
MIEditElement: TMenuItem;
|
||||
@ -140,6 +143,7 @@ type
|
||||
MFrames: TMenuItem;
|
||||
MIRecent: TMenuItem;
|
||||
MIAddPage: TMenuItem;
|
||||
ODImport: TOpenDialog;
|
||||
PMRecent: TPopupMenu;
|
||||
PSDesign: TIniPropStorage;
|
||||
MIAlign: TMenuItem;
|
||||
@ -276,6 +280,8 @@ type
|
||||
procedure AFileSaveUpdate(Sender: TObject);
|
||||
procedure AFrameExecute(Sender: TObject);
|
||||
procedure AFrameUpdate(Sender: TObject);
|
||||
procedure AImportLazreportExecute(Sender: TObject);
|
||||
procedure AImportLazreportUpdate(Sender: TObject);
|
||||
procedure ANewExecute(Sender: TObject);
|
||||
procedure ANewNewWindowExecute(Sender: TObject);
|
||||
procedure APasteExecute(Sender: TObject);
|
||||
@ -326,6 +332,7 @@ type
|
||||
FOnOpenReport: TNotifyEvent;
|
||||
FOnSaveReport: TNotifyEvent;
|
||||
FReportDesignData : TDesignReportDataManager;
|
||||
FImportForm: TForm;
|
||||
{$IFDEF USEDEMOREPORT}
|
||||
lReportData : TFPReportUserData;
|
||||
sl: TStringList;
|
||||
@ -345,6 +352,7 @@ type
|
||||
procedure CheckLoadInitialFile;
|
||||
function CreateDesignPopupMenu(aOWner: TComponent): TPopupMenu;
|
||||
function CreateNewPage: TFPReportCustomPage;
|
||||
procedure DoImportLog(Sender: TOBject; const Msg: String);
|
||||
procedure DoPaste(Sender: TObject);
|
||||
procedure DoReportChangedByDesigner(Sender: TObject);
|
||||
procedure DoSelectionModifiedByOI(Sender: TObject);
|
||||
@ -356,6 +364,7 @@ type
|
||||
procedure ActivateDesignerForElement(AElement: TFPReportElement);
|
||||
function GetPageCopyAction(aCount: Integer): TPageCopyAction;
|
||||
function GetBandCopyAction(aCount: Integer): TBandCopyAction;
|
||||
procedure ImportLazReport;
|
||||
procedure MaybeAddFirstPage;
|
||||
procedure OpenInNewWindow(aFileName: string);
|
||||
procedure PasteBand(aControl: TFPReportDesignerControl; aAction: TBandCopyAction; var aBand: TFPReportCustomBand);
|
||||
@ -417,7 +426,7 @@ type
|
||||
|
||||
Const
|
||||
AllReportDesignOptions = [rdoManageData,rdoManageVariables,rdoAllowLoad,rdoAllowSave,rdoAllowProperties,
|
||||
rdoAllowPageAdd,rdoAllowNew, rdoAllowPreview, rdoAllowBands,rdoAllowFileDrop];
|
||||
rdoAllowPageAdd,rdoAllowNew, rdoAllowPreview, rdoAllowBands,rdoAllowFileDrop,rdoAllowImport];
|
||||
|
||||
|
||||
implementation
|
||||
@ -429,6 +438,7 @@ uses
|
||||
fpttf,
|
||||
fpreportstreamer,
|
||||
fpjson,
|
||||
fplazreport,
|
||||
Clipbrd,
|
||||
jsonparser;
|
||||
|
||||
@ -1058,6 +1068,17 @@ begin
|
||||
Result.StartDesigning;
|
||||
end;
|
||||
|
||||
procedure TFPReportDesignerForm.DoImportLog(Sender: TOBject; const Msg: String);
|
||||
begin
|
||||
if not Assigned(FImportForm) and Assigned(ReportImportFormClass) then
|
||||
begin
|
||||
FImportForm:=ReportImportFormClass.Create(Self);
|
||||
FImportForm.Show;
|
||||
end;
|
||||
if Assigned(FImportForm) and (FImportForm is TBaseImportReportForm) then
|
||||
TBaseImportReportForm(FImportForm).Log(Msg);
|
||||
end;
|
||||
|
||||
Function TFPReportDesignerForm.GetPageCopyAction(aCount : Integer) : TPageCopyAction;
|
||||
|
||||
Var
|
||||
@ -1532,6 +1553,59 @@ begin
|
||||
(Sender as TAction).Enabled:=Assigned(CurrentDesigner) and CurrentDesigner.Objects.HaveSelection;
|
||||
end;
|
||||
|
||||
procedure TFPReportDesignerForm.AImportLazreportExecute(Sender: TObject);
|
||||
begin
|
||||
if CheckSaved('import lazreport') then
|
||||
ImportLazReport;
|
||||
end;
|
||||
|
||||
procedure TFPReportDesignerForm.AImportLazreportUpdate(Sender: TObject);
|
||||
|
||||
Const
|
||||
Ops = [rdoAllowImport,rdoAllowLoad];
|
||||
|
||||
begin
|
||||
(Sender as TAction).Enabled:=(Ops * DesignOptions)=Ops;
|
||||
end;
|
||||
|
||||
Procedure TFPReportDesignerForm.ImportLazReport;
|
||||
|
||||
Var
|
||||
FN,OFN : String;
|
||||
R : TFPLazReport;
|
||||
S : TFPReportJSONStreamer;
|
||||
J : TJSONStringType;
|
||||
|
||||
begin
|
||||
With ODImport do
|
||||
If Execute then
|
||||
FN:=FileName
|
||||
else
|
||||
exit;
|
||||
OFN:=ChangeFileExt(FN,'.json');
|
||||
R:=TFPLazReport.Create(Self);
|
||||
try
|
||||
// Reset.
|
||||
FImportForm:=Nil;
|
||||
R.OnLog:=@DoImportLog;
|
||||
R.LoadFromFile(FN);
|
||||
S:=TFPReportJSONStreamer.Create(Self);
|
||||
R.WriteElement(S,Nil);
|
||||
S.JSON.Add('DesignData',TJSONObject.Create);
|
||||
J:=S.JSON.FormatJSON( );
|
||||
With TFileStream.Create(OFN,fmCreate) do
|
||||
try
|
||||
WriteBuffer(J[1],Length(J));
|
||||
finally
|
||||
Free;
|
||||
end;
|
||||
finally
|
||||
R.Free;
|
||||
end;
|
||||
LoadReportFromFile(OFN);
|
||||
DesignReport;
|
||||
end;
|
||||
|
||||
function TFPReportDesignerForm.GetModified: boolean;
|
||||
|
||||
Var
|
||||
|
37
components/fpreport/design/frmlazreportimportlog.lfm
Normal file
37
components/fpreport/design/frmlazreportimportlog.lfm
Normal file
@ -0,0 +1,37 @@
|
||||
object ReportImportLogForm: TReportImportLogForm
|
||||
Left = 491
|
||||
Height = 240
|
||||
Top = 180
|
||||
Width = 320
|
||||
Caption = 'Report import log'
|
||||
ClientHeight = 240
|
||||
ClientWidth = 320
|
||||
OnClose = FormClose
|
||||
Position = poOwnerFormCenter
|
||||
LCLVersion = '1.9.0.0'
|
||||
object ButtonPanel1: TButtonPanel
|
||||
Left = 6
|
||||
Height = 42
|
||||
Top = 192
|
||||
Width = 308
|
||||
OKButton.Name = 'OKButton'
|
||||
OKButton.DefaultCaption = True
|
||||
HelpButton.Name = 'HelpButton'
|
||||
HelpButton.DefaultCaption = True
|
||||
CloseButton.Name = 'CloseButton'
|
||||
CloseButton.DefaultCaption = True
|
||||
CancelButton.Name = 'CancelButton'
|
||||
CancelButton.DefaultCaption = True
|
||||
TabOrder = 0
|
||||
ShowButtons = [pbClose]
|
||||
end
|
||||
object MLog: TMemo
|
||||
Left = 0
|
||||
Height = 186
|
||||
Top = 0
|
||||
Width = 320
|
||||
Align = alClient
|
||||
ScrollBars = ssAutoBoth
|
||||
TabOrder = 1
|
||||
end
|
||||
end
|
48
components/fpreport/design/frmlazreportimportlog.pp
Normal file
48
components/fpreport/design/frmlazreportimportlog.pp
Normal file
@ -0,0 +1,48 @@
|
||||
unit frmlazreportimportlog;
|
||||
|
||||
{$mode objfpc}{$H+}
|
||||
|
||||
interface
|
||||
|
||||
uses
|
||||
Classes, SysUtils, Forms, Controls, Graphics, Dialogs, ButtonPanel, StdCtrls, reportdesignbaseforms;
|
||||
|
||||
type
|
||||
|
||||
{ TReportImportLogForm }
|
||||
TForm = Class(TBaseImportReportForm);
|
||||
|
||||
TReportImportLogForm = class(TForm)
|
||||
ButtonPanel1: TButtonPanel;
|
||||
MLog: TMemo;
|
||||
procedure FormClose(Sender: TObject; var CloseAction: TCloseAction);
|
||||
private
|
||||
|
||||
public
|
||||
Procedure Log(Const Msg : String); override;
|
||||
end;
|
||||
|
||||
var
|
||||
ReportImportLogForm: TReportImportLogForm;
|
||||
|
||||
implementation
|
||||
|
||||
{$R *.lfm}
|
||||
|
||||
{ TReportImportLogForm }
|
||||
|
||||
procedure TReportImportLogForm.FormClose(Sender: TObject; var CloseAction: TCloseAction);
|
||||
begin
|
||||
CloseAction:=caFree;
|
||||
end;
|
||||
|
||||
procedure TReportImportLogForm.Log(Const Msg : String);
|
||||
begin
|
||||
MLog.Lines.Add(Msg);
|
||||
Application.ProcessMessages;
|
||||
end;
|
||||
|
||||
initialization
|
||||
ReportImportFormClass:=TReportImportLogForm;
|
||||
end.
|
||||
|
@ -11,7 +11,7 @@
|
||||
<UnitOutputDirectory Value="lib/$(TargetCPU)-$(TargetOS)"/>
|
||||
</SearchPaths>
|
||||
</CompilerOptions>
|
||||
<Files Count="40">
|
||||
<Files Count="41">
|
||||
<Item1>
|
||||
<Filename Value="fpreportdesignreportdata.pp"/>
|
||||
<UnitName Value="fpreportdesignreportdata"/>
|
||||
@ -172,6 +172,10 @@
|
||||
<Filename Value="frmfpreportvariables.lfm"/>
|
||||
<Type Value="LFM"/>
|
||||
</Item40>
|
||||
<Item41>
|
||||
<Filename Value="frmlazreportimportlog.pp"/>
|
||||
<UnitName Value="frmlazreportimportlog"/>
|
||||
</Item41>
|
||||
</Files>
|
||||
<RequiredPkgs Count="5">
|
||||
<Item1>
|
||||
|
@ -12,7 +12,7 @@ uses
|
||||
frafpreportdbfdata, frafpreportjsondata, frafpreportdata, fraReportObjectInspector, frafpreportsqldbdata,
|
||||
frmfpreportalignelements, frmconfigreportdata, frmfpreportdataconnectioneditor, frmfpreportdesignermain, frmfpreportimageedit,
|
||||
frmfpreportmemoedit, frmfpreportpreviewdata, frmfpreportproperties, frmfpreportshapeedit, frmfpreportvariables,
|
||||
frmfprdresizeelements, regfpdesigner, FPReportDesigner, LazarusPackageIntf;
|
||||
frmfprdresizeelements, regfpdesigner, FPReportDesigner, frmlazreportimportlog, LazarusPackageIntf;
|
||||
|
||||
implementation
|
||||
|
||||
|
@ -11,6 +11,7 @@ uses
|
||||
sqldb,
|
||||
reportconns,
|
||||
fpreport,
|
||||
fplazreport,
|
||||
fpreportdb,
|
||||
fpreportbarcode,
|
||||
fpreportqrcode,
|
||||
@ -42,6 +43,7 @@ uses
|
||||
frmfpreportvariables,
|
||||
frmfpreportproperties,
|
||||
frmfpreportpreviewdata,
|
||||
frmlazreportimportlog,
|
||||
cfgfpreportpdfexport,
|
||||
cfgfpreportimageexport,
|
||||
cfgfpreporthtmlexport;
|
||||
|
@ -21,7 +21,7 @@ interface
|
||||
|
||||
uses
|
||||
Classes, SysUtils, fpreport, forms, db, fpreportdesignobjectlist,
|
||||
fpreportdata, fpreportdesignreportdata;
|
||||
fpreportdata;
|
||||
|
||||
Type
|
||||
{ TReportEditorForm }
|
||||
@ -110,6 +110,12 @@ Type
|
||||
end;
|
||||
TBaseReportVariablesFormClass = Class of TBaseReportVariablesForm;
|
||||
|
||||
TBaseImportReportForm = Class(TForm)
|
||||
Public
|
||||
Procedure Log(Const Msg : String); virtual; abstract;
|
||||
end;
|
||||
TBaseImportReportFormClass = Class of TBaseImportReportForm;
|
||||
|
||||
Var
|
||||
ReportDataFormClass : TBaseReportDataFormClass;
|
||||
ReportResizeFormClass : TBaseReportResizeFormClass;
|
||||
@ -117,6 +123,7 @@ Var
|
||||
ReportDataPreviewClass : TBaseReportDataPreviewFormClass;
|
||||
ReportVariablesFormClass : TBaseReportVariablesFormClass;
|
||||
ReportPropertiesFormClass : TBaseReportEditorFormClass;
|
||||
ReportImportFormClass : TBaseImportReportFormClass;
|
||||
|
||||
implementation
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user