mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-04-24 09:39:26 +02:00
LazReport, some refactoring to get information from custom preview report
git-svn-id: trunk@28929 -
This commit is contained in:
parent
83eb831066
commit
b5a9ad4484
@ -621,6 +621,10 @@ msgstr "&Variable"
|
||||
msgid "Va&riables..."
|
||||
msgstr "Va&riablen ..."
|
||||
|
||||
#: lr_const.sexportfilterindexerror
|
||||
msgid "Export filter index out range"
|
||||
msgstr ""
|
||||
|
||||
#: lr_const.sfieldsformaviabledb
|
||||
msgid "&Available DB's"
|
||||
msgstr "&Verfügbare Datenbanken"
|
||||
|
@ -610,6 +610,10 @@ msgstr ""
|
||||
msgid "Va&riables..."
|
||||
msgstr ""
|
||||
|
||||
#: lr_const.sexportfilterindexerror
|
||||
msgid "Export filter index out range"
|
||||
msgstr ""
|
||||
|
||||
#: lr_const.sfieldsformaviabledb
|
||||
msgid "&Available DB's"
|
||||
msgstr "BDs &Disponibles"
|
||||
|
@ -619,6 +619,10 @@ msgstr "&Variable"
|
||||
msgid "Va&riables..."
|
||||
msgstr "Va&riables..."
|
||||
|
||||
#: lr_const.sexportfilterindexerror
|
||||
msgid "Export filter index out range"
|
||||
msgstr ""
|
||||
|
||||
#: lr_const.sfieldsformaviabledb
|
||||
msgid "&Available DB's"
|
||||
msgstr "BDD D&isponible"
|
||||
|
@ -610,6 +610,10 @@ msgstr "&Variabel"
|
||||
msgid "Va&riables..."
|
||||
msgstr "Va&riabel..."
|
||||
|
||||
#: lr_const.sexportfilterindexerror
|
||||
msgid "Export filter index out range"
|
||||
msgstr ""
|
||||
|
||||
#: lr_const.sfieldsformaviabledb
|
||||
msgid "&Available DB's"
|
||||
msgstr "DB Tersedi&a"
|
||||
|
@ -612,6 +612,10 @@ msgstr "&Kintamasis"
|
||||
msgid "Va&riables..."
|
||||
msgstr "&Kintamieji..."
|
||||
|
||||
#: lr_const.sexportfilterindexerror
|
||||
msgid "Export filter index out range"
|
||||
msgstr ""
|
||||
|
||||
#: lr_const.sfieldsformaviabledb
|
||||
msgid "&Available DB's"
|
||||
msgstr "Esamos duomenų b&azės"
|
||||
|
@ -610,6 +610,10 @@ msgstr "&Variável"
|
||||
msgid "Va&riables..."
|
||||
msgstr "Va&riáveis..."
|
||||
|
||||
#: lr_const.sexportfilterindexerror
|
||||
msgid "Export filter index out range"
|
||||
msgstr ""
|
||||
|
||||
#: lr_const.sfieldsformaviabledb
|
||||
msgid "&Available DB's"
|
||||
msgstr "BD´s &Disponíveis"
|
||||
|
@ -613,6 +613,10 @@ msgstr "&Zmienna"
|
||||
msgid "Va&riables..."
|
||||
msgstr "Zmie&nne..."
|
||||
|
||||
#: lr_const.sexportfilterindexerror
|
||||
msgid "Export filter index out range"
|
||||
msgstr ""
|
||||
|
||||
#: lr_const.sfieldsformaviabledb
|
||||
msgid "&Available DB's"
|
||||
msgstr "&Dostępne bazy danych"
|
||||
|
@ -605,6 +605,10 @@ msgstr ""
|
||||
msgid "Va&riables..."
|
||||
msgstr ""
|
||||
|
||||
#: lr_const.sexportfilterindexerror
|
||||
msgid "Export filter index out range"
|
||||
msgstr ""
|
||||
|
||||
#: lr_const.sfieldsformaviabledb
|
||||
msgid "&Available DB's"
|
||||
msgstr ""
|
||||
|
@ -610,6 +610,10 @@ msgstr "&Переменная"
|
||||
msgid "Va&riables..."
|
||||
msgstr "Пере&менные..."
|
||||
|
||||
#: lr_const.sexportfilterindexerror
|
||||
msgid "Export filter index out range"
|
||||
msgstr ""
|
||||
|
||||
#: lr_const.sfieldsformaviabledb
|
||||
msgid "&Available DB's"
|
||||
msgstr "&Доступные БД"
|
||||
|
@ -273,6 +273,7 @@ resourcestring
|
||||
SFilterParam = 'Average font height:';
|
||||
sFrom = 'from';
|
||||
sDefaultPrinter = 'Default printer';
|
||||
sExportFilterIndexError = 'Export filter index out range';
|
||||
|
||||
//--- PrintForm resources ---------------------------------------------------
|
||||
sPrintFormPrint = 'Print';
|
||||
|
@ -64,9 +64,10 @@ type
|
||||
procedure Last;
|
||||
procedure SaveToFile;
|
||||
procedure LoadFromFile;
|
||||
procedure Print;
|
||||
function Print: boolean;
|
||||
procedure Edit;
|
||||
procedure Find;
|
||||
function ExportTo(AFileName: string): boolean;
|
||||
property AllPages: Integer read GetAllPages;
|
||||
property Page: Integer read GetPage write SetPage;
|
||||
property Zoom: Double read GetZoom write SetZoom;
|
||||
@ -189,6 +190,8 @@ type
|
||||
MousePos: TPoint; var Handled: Boolean);
|
||||
procedure MouseWheelUp(Sender: TObject; Shift: TShiftState;
|
||||
MousePos: TPoint; var Handled: Boolean);
|
||||
function ExportToWithFilterIndex(AFilterIndex:Integer; AFileName: string): boolean;
|
||||
function Print: boolean;
|
||||
public
|
||||
{ Public declarations }
|
||||
procedure Show_Modal(ADoc: Pointer);
|
||||
@ -333,9 +336,9 @@ begin
|
||||
FWindow.LoadBtnClick(nil);
|
||||
end;
|
||||
|
||||
procedure TfrPreview.Print;
|
||||
function TfrPreview.Print: boolean;
|
||||
begin
|
||||
FWindow.PrintBtnClick(nil);
|
||||
result := FWindow.Print;
|
||||
end;
|
||||
|
||||
procedure TfrPreview.Edit;
|
||||
@ -348,6 +351,21 @@ begin
|
||||
FWindow.FindBtnClick(nil);
|
||||
end;
|
||||
|
||||
function TfrPreview.ExportTo(AFileName: string): boolean;
|
||||
var
|
||||
i: Integer;
|
||||
AExt: string;
|
||||
begin
|
||||
result := false;
|
||||
AExt := ExtractFileExt(AFileName);
|
||||
for i:=0 to frFiltersCount-1 do
|
||||
if SameText(AExt, ExtractFileExt(frFilters[i].FilterExt)) then begin
|
||||
FWindow.ExportToWithFilterIndex(i, AFileName);
|
||||
result := true;
|
||||
break;
|
||||
end;
|
||||
end;
|
||||
|
||||
{----------------------------------------------------------------------------}
|
||||
procedure TfrPBox.WMEraseBackground(var Message: TLMEraseBkgnd);
|
||||
begin
|
||||
@ -614,6 +632,63 @@ begin
|
||||
else Show;
|
||||
end;
|
||||
|
||||
function TfrPreviewForm.Print: boolean;
|
||||
var
|
||||
Pages: String;
|
||||
ind: Integer;
|
||||
begin
|
||||
result := false;
|
||||
if (EMFPages = nil) or (Printer.Printers.Count = 0) then Exit;
|
||||
ind := Printer.PrinterIndex;
|
||||
frPrintForm := TfrPrintForm.Create(nil);
|
||||
with frPrintForm do
|
||||
begin
|
||||
if ShowModal = mrOk then
|
||||
begin
|
||||
if Printer.PrinterIndex <> ind then
|
||||
begin
|
||||
if TfrReport(Doc).CanRebuild then
|
||||
begin
|
||||
if TfrReport(Doc).ChangePrinter(ind, Printer.PrinterIndex) then
|
||||
begin
|
||||
TfrEMFPages(EMFPages).Free;
|
||||
EMFPages := nil;
|
||||
TfrReport(Doc).PrepareReport;
|
||||
Connect(Doc);
|
||||
end
|
||||
else Exit;
|
||||
end;
|
||||
end;
|
||||
|
||||
if RB1.Checked then
|
||||
Pages := ''
|
||||
else
|
||||
if RB2.Checked then
|
||||
Pages := IntToStr(CurPage)
|
||||
else
|
||||
Pages := E2.Text;
|
||||
|
||||
ConnectBack;
|
||||
TfrReport(Doc).PrintPreparedReport(Pages, StrToInt(E1.Text));
|
||||
Connect(Doc);
|
||||
RedrawAll;
|
||||
result := true;
|
||||
end;
|
||||
Free;
|
||||
end;
|
||||
end;
|
||||
|
||||
function TfrPreviewForm.ExportToWithFilterIndex(AFilterIndex: Integer;
|
||||
AFileName: string):boolean;
|
||||
begin
|
||||
if (AFilterIndex<0) or (AFilterIndex>=frFiltersCount) then
|
||||
raise exception.Create(sExportFilterIndexError);
|
||||
|
||||
ConnectBack;
|
||||
TfrReport(Doc).ExportTo(frFilters[AFilterIndex].ClassRef, AFileName);
|
||||
Connect(Doc);
|
||||
end;
|
||||
|
||||
procedure TfrPreviewForm.Connect(ADoc: Pointer);
|
||||
begin
|
||||
Doc := ADoc;
|
||||
@ -1012,56 +1087,15 @@ begin
|
||||
SaveToFile(FileName)
|
||||
else
|
||||
begin
|
||||
ConnectBack;
|
||||
TfrReport(Doc).ExportTo(frFilters[FilterIndex - 2].ClassRef,
|
||||
ExportToWithFilterIndex(FilterIndex-2,
|
||||
ChangeFileExt(FileName, Copy(frFilters[FilterIndex - 2].FilterExt, 2, 255)));
|
||||
Connect(Doc);
|
||||
end;
|
||||
end;
|
||||
end;
|
||||
|
||||
procedure TfrPreviewForm.PrintBtnClick(Sender: TObject);
|
||||
var
|
||||
Pages: String;
|
||||
ind: Integer;
|
||||
begin
|
||||
if (EMFPages = nil) or (Printer.Printers.Count = 0) then Exit;
|
||||
ind := Printer.PrinterIndex;
|
||||
frPrintForm := TfrPrintForm.Create(nil);
|
||||
with frPrintForm do
|
||||
begin
|
||||
if ShowModal = mrOk then
|
||||
begin
|
||||
if Printer.PrinterIndex <> ind then
|
||||
begin
|
||||
if TfrReport(Doc).CanRebuild then
|
||||
begin
|
||||
if TfrReport(Doc).ChangePrinter(ind, Printer.PrinterIndex) then
|
||||
begin
|
||||
TfrEMFPages(EMFPages).Free;
|
||||
EMFPages := nil;
|
||||
TfrReport(Doc).PrepareReport;
|
||||
Connect(Doc);
|
||||
end
|
||||
else Exit;
|
||||
end;
|
||||
end;
|
||||
|
||||
if RB1.Checked then
|
||||
Pages := ''
|
||||
else
|
||||
if RB2.Checked then
|
||||
Pages := IntToStr(CurPage)
|
||||
else
|
||||
Pages := E2.Text;
|
||||
|
||||
ConnectBack;
|
||||
TfrReport(Doc).PrintPreparedReport(Pages, StrToInt(E1.Text));
|
||||
Connect(Doc);
|
||||
RedrawAll;
|
||||
end;
|
||||
Free;
|
||||
end;
|
||||
Print;
|
||||
end;
|
||||
|
||||
procedure TfrPreviewForm.ExitBtnClick(Sender: TObject);
|
||||
|
Loading…
Reference in New Issue
Block a user