mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-09-02 09:00:58 +02:00
LazReport, fix compile lrSpreadsheetExport with latest laz_fpspreadsheet + start work on exporting images, patch from Aleksey Lagunov
git-svn-id: trunk@51891 -
This commit is contained in:
parent
4aad165455
commit
bcfb267d17
File diff suppressed because one or more lines are too long
@ -52,6 +52,7 @@ type
|
|||||||
FDeleteEmptyRow: boolean;
|
FDeleteEmptyRow: boolean;
|
||||||
FExportMatrix:TExportMatrix;
|
FExportMatrix:TExportMatrix;
|
||||||
FExportPrintRange: boolean;
|
FExportPrintRange: boolean;
|
||||||
|
FExportImages: boolean;
|
||||||
FExportURL: boolean;
|
FExportURL: boolean;
|
||||||
FMergeCell: boolean;
|
FMergeCell: boolean;
|
||||||
FOpenAfterExport: boolean;
|
FOpenAfterExport: boolean;
|
||||||
@ -66,7 +67,6 @@ type
|
|||||||
procedure ExportColWidth;
|
procedure ExportColWidth;
|
||||||
procedure ExportRowHight;
|
procedure ExportRowHight;
|
||||||
procedure DoExportPrintRange;
|
procedure DoExportPrintRange;
|
||||||
//procedure ExportData;
|
|
||||||
procedure ExportData1;
|
procedure ExportData1;
|
||||||
|
|
||||||
procedure MakeWorksheet;
|
procedure MakeWorksheet;
|
||||||
@ -99,12 +99,13 @@ type
|
|||||||
property MergeCell:boolean read FMergeCell write FMergeCell;
|
property MergeCell:boolean read FMergeCell write FMergeCell;
|
||||||
property ExportURL:boolean read FExportURL write FExportURL;
|
property ExportURL:boolean read FExportURL write FExportURL;
|
||||||
property ExportPrintRange:boolean read FExportPrintRange write FExportPrintRange;
|
property ExportPrintRange:boolean read FExportPrintRange write FExportPrintRange;
|
||||||
|
property ExportImages:boolean read FExportImages write FExportImages;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
implementation
|
implementation
|
||||||
uses LCLType, le_e_spreadsheet_params, fpsTypes, fpsutils, fpsAllFormats,
|
uses LCLType, le_e_spreadsheet_params, fpsTypes, fpsutils, fpsAllFormats,
|
||||||
LazUTF8Classes, Forms, Controls, LCLIntf, LazFileUtils, le_e_spreadsheet_consts,
|
LazUTF8Classes, Forms, Controls, LCLIntf, LazFileUtils, le_e_spreadsheet_consts,
|
||||||
lrSpreadSheetExp, math;
|
lrSpreadSheetExp, math, fpsPageLayout;
|
||||||
|
|
||||||
const
|
const
|
||||||
ssAligns : array [TAlignment] of TsHorAlignment = (haLeft, haRight, haCenter);
|
ssAligns : array [TAlignment] of TsHorAlignment = (haLeft, haRight, haCenter);
|
||||||
@ -177,7 +178,9 @@ begin
|
|||||||
end;
|
end;
|
||||||
|
|
||||||
if (X1>0) and (Y1>0) and (X2>X1) and (Y2>Y1) then
|
if (X1>0) and (Y1>0) and (X2>X1) and (Y2>Y1) then
|
||||||
FWorksheet.AddPrintRange(Y1, X1, Y2, X2);
|
begin
|
||||||
|
FWorksheet.PageLayout.AddPrintRange(Y1, X1, Y2, X2);
|
||||||
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
function sftofs(AFont:TFont):TsFontStyles;
|
function sftofs(AFont:TFont):TsFontStyles;
|
||||||
@ -195,67 +198,7 @@ begin
|
|||||||
if fsUnderline in AFont.Style then
|
if fsUnderline in AFont.Style then
|
||||||
Result:=Result + [fssUnderline];
|
Result:=Result + [fssUnderline];
|
||||||
end;
|
end;
|
||||||
{
|
|
||||||
procedure TlrSpreadSheetExportFilter.ExportData;
|
|
||||||
var
|
|
||||||
R:TExportObject;
|
|
||||||
y: Integer;
|
|
||||||
x: Integer;
|
|
||||||
scFrm:TsCellBorders;
|
|
||||||
|
|
||||||
begin
|
|
||||||
for y:=0 to FExportMatrix.RowCount do
|
|
||||||
for x:=0 to FExportMatrix.ColumnCount do
|
|
||||||
begin
|
|
||||||
R:=FExportMatrix.Objects[X, Y];
|
|
||||||
if Assigned(R) then
|
|
||||||
begin
|
|
||||||
if R.Text<>'' then
|
|
||||||
begin
|
|
||||||
FWorksheet.WriteUTF8Text(Y, X, TrimRight(R.Texts.Text));
|
|
||||||
if R.Angle <> 0 then
|
|
||||||
FWorksheet.WriteTextRotation(Y, X, rt90DegreeCounterClockwiseRotation);
|
|
||||||
FWorksheet.WriteVertAlignment(Y, X, ssLayout[R.Layout]);
|
|
||||||
FWorksheet.WriteWordwrap(Y, X, R.WordWrap);
|
|
||||||
end;
|
|
||||||
FWorksheet.WriteBackgroundColor(Y, X, R.FillColor);
|
|
||||||
|
|
||||||
if (R.Col < R.MergedCol) or (R.Row < R.MergedRow) then
|
|
||||||
FWorksheet.MergeCells(Y, X, R.MergedRow, R.MergedCol);
|
|
||||||
|
|
||||||
if Assigned(R.Font) then
|
|
||||||
FWorksheet.WriteFont(Y, X, R.Font.Name, R.Font.Size, sftofs(R.Font), R.Font.Color, fpNormal);
|
|
||||||
|
|
||||||
FWorksheet.WriteHorAlignment(Y, X, ssAligns[R.Alignment]);
|
|
||||||
|
|
||||||
scFrm:=[];
|
|
||||||
if frbLeft in R.Frames then
|
|
||||||
begin
|
|
||||||
FWorksheet.WriteBorderColor(Y, X, cbEast, R.FrameColor);
|
|
||||||
scFrm:=scFrm + [cbEast]
|
|
||||||
end;
|
|
||||||
if frbTop in R.Frames then
|
|
||||||
begin
|
|
||||||
FWorksheet.WriteBorderColor(Y, X, cbNorth, R.FrameColor);
|
|
||||||
scFrm:=scFrm + [cbNorth]
|
|
||||||
end;
|
|
||||||
if frbBottom in R.Frames then
|
|
||||||
begin
|
|
||||||
FWorksheet.WriteBorderColor(Y, X, cbSouth, R.FrameColor);
|
|
||||||
scFrm:=scFrm + [cbSouth]
|
|
||||||
end;
|
|
||||||
if frbRight in R.Frames then
|
|
||||||
begin
|
|
||||||
FWorksheet.WriteBorderColor(Y, X, cbWest, R.FrameColor);
|
|
||||||
scFrm:=scFrm + [cbWest]
|
|
||||||
end;
|
|
||||||
|
|
||||||
if scFrm <> [] then
|
|
||||||
FWorksheet.WriteBorders(Y, X, scFrm);
|
|
||||||
end;
|
|
||||||
end;
|
|
||||||
end;
|
|
||||||
}
|
|
||||||
procedure TlrSpreadSheetExportFilter.ExportData1;
|
procedure TlrSpreadSheetExportFilter.ExportData1;
|
||||||
var
|
var
|
||||||
R: Integer;
|
R: Integer;
|
||||||
@ -277,15 +220,23 @@ begin
|
|||||||
begin
|
begin
|
||||||
X:=Cel.Col;
|
X:=Cel.Col;
|
||||||
Y:=Row.Row;
|
Y:=Row.Row;
|
||||||
if Cel.Text<>'' then
|
if (Cel.ObjType = gtMemo) and (Cel.Text<>'') then
|
||||||
begin
|
begin
|
||||||
FWorksheet.WriteUTF8Text(Y, X, TrimRight(Cel.Texts.Text));
|
FWorksheet.WriteUTF8Text(Y, X, TrimRight(Cel.Texts.Text));
|
||||||
if Cel.Angle <> 0 then
|
if Cel.Angle <> 0 then
|
||||||
FWorksheet.WriteTextRotation(Y, X, rt90DegreeCounterClockwiseRotation);
|
FWorksheet.WriteTextRotation(Y, X, rt90DegreeCounterClockwiseRotation);
|
||||||
FWorksheet.WriteVertAlignment(Y, X, ssLayout[Cel.Layout]);
|
FWorksheet.WriteVertAlignment(Y, X, ssLayout[Cel.Layout]);
|
||||||
FWorksheet.WriteWordwrap(Y, X, Cel.WordWrap);
|
FWorksheet.WriteWordwrap(Y, X, Cel.WordWrap);
|
||||||
end;
|
|
||||||
FWorksheet.WriteBackgroundColor(Y, X, Cel.FillColor);
|
FWorksheet.WriteBackgroundColor(Y, X, Cel.FillColor);
|
||||||
|
end
|
||||||
|
{ this code for export images - not work. in progress
|
||||||
|
else
|
||||||
|
if (Cel.ObjType = gtPicture) and (Assigned(Cel.Picture)) then
|
||||||
|
begin
|
||||||
|
FWorksheet.WriteImage(Y, X, '/home/work/demos/Demo_65_ODSWrite/lazarus32x32.png');
|
||||||
|
end};
|
||||||
|
|
||||||
|
|
||||||
if (Cel.Col < Cel.MergedCol) or (Cel.Row < Cel.MergedRow) then
|
if (Cel.Col < Cel.MergedCol) or (Cel.Row < Cel.MergedRow) then
|
||||||
FWorksheet.MergeCells(Y, X, Cel.MergedRow, Cel.MergedCol);
|
FWorksheet.MergeCells(Y, X, Cel.MergedRow, Cel.MergedCol);
|
||||||
@ -343,7 +294,12 @@ begin
|
|||||||
ExportRowHight;
|
ExportRowHight;
|
||||||
ExportData1;
|
ExportData1;
|
||||||
if FExportPrintRange then
|
if FExportPrintRange then
|
||||||
|
begin
|
||||||
DoExportPrintRange;
|
DoExportPrintRange;
|
||||||
|
FWorksheet.PageLayout.Options := FWorksheet.PageLayout.Options + [poFitPages];
|
||||||
|
FWorksheet.PageLayout.FitWidthToPages := 1; // all columns on one page width
|
||||||
|
FWorksheet.PageLayout.FitHeightToPages := 0;
|
||||||
|
end;
|
||||||
|
|
||||||
FWorksheet:=nil;
|
FWorksheet:=nil;
|
||||||
FExportMatrix.Clear;
|
FExportMatrix.Clear;
|
||||||
@ -360,6 +316,7 @@ begin
|
|||||||
leSpreadsheetParamsForm.RadioButton5.Checked:=FDataGrouping = ldgAllInOnePage;
|
leSpreadsheetParamsForm.RadioButton5.Checked:=FDataGrouping = ldgAllInOnePage;
|
||||||
leSpreadsheetParamsForm.RadioButton6.Checked:=FDataGrouping = ldgChunks;
|
leSpreadsheetParamsForm.RadioButton6.Checked:=FDataGrouping = ldgChunks;
|
||||||
leSpreadsheetParamsForm.SpinEdit1.Value:=FDataGroupingChunks;
|
leSpreadsheetParamsForm.SpinEdit1.Value:=FDataGroupingChunks;
|
||||||
|
leSpreadsheetParamsForm.CheckBox1.Checked:=FExportImages;
|
||||||
leSpreadsheetParamsForm.CheckBox4.Checked:=FOpenAfterExport;
|
leSpreadsheetParamsForm.CheckBox4.Checked:=FOpenAfterExport;
|
||||||
leSpreadsheetParamsForm.CheckBox2.Checked:=FMergeCell;
|
leSpreadsheetParamsForm.CheckBox2.Checked:=FMergeCell;
|
||||||
leSpreadsheetParamsForm.CheckBox6.Checked:=FDeleteEmptyRow;
|
leSpreadsheetParamsForm.CheckBox6.Checked:=FDeleteEmptyRow;
|
||||||
@ -380,6 +337,7 @@ begin
|
|||||||
FDataGrouping:=ldgChunks;
|
FDataGrouping:=ldgChunks;
|
||||||
FDataGroupingChunks:=leSpreadsheetParamsForm.SpinEdit1.Value;
|
FDataGroupingChunks:=leSpreadsheetParamsForm.SpinEdit1.Value;
|
||||||
end;
|
end;
|
||||||
|
FExportImages := leSpreadsheetParamsForm.CheckBox1.Checked;
|
||||||
FOpenAfterExport:= leSpreadsheetParamsForm.CheckBox4.Checked;
|
FOpenAfterExport:= leSpreadsheetParamsForm.CheckBox4.Checked;
|
||||||
FMergeCell := leSpreadsheetParamsForm.CheckBox2.Checked;
|
FMergeCell := leSpreadsheetParamsForm.CheckBox2.Checked;
|
||||||
FDeleteEmptyRow := leSpreadsheetParamsForm.CheckBox6.Checked;
|
FDeleteEmptyRow := leSpreadsheetParamsForm.CheckBox6.Checked;
|
||||||
@ -412,6 +370,7 @@ begin
|
|||||||
FDeleteEmptyRow:=lrSpreadSheetExportComponent.DeleteEmptyRow;
|
FDeleteEmptyRow:=lrSpreadSheetExportComponent.DeleteEmptyRow;
|
||||||
FExportURL:=lrSpreadSheetExportComponent.ExportURL;
|
FExportURL:=lrSpreadSheetExportComponent.ExportURL;
|
||||||
FExportPrintRange:=lrSpreadSheetExportComponent.ExportPrintRange;
|
FExportPrintRange:=lrSpreadSheetExportComponent.ExportPrintRange;
|
||||||
|
FExportImages:=lrSpreadSheetExportComponent.ExportImages;
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
begin
|
begin
|
||||||
@ -422,6 +381,7 @@ begin
|
|||||||
FDeleteEmptyRow:=false;
|
FDeleteEmptyRow:=false;
|
||||||
FExportURL:=false;
|
FExportURL:=false;
|
||||||
FExportPrintRange:=false;
|
FExportPrintRange:=false;
|
||||||
|
FExportImages:=false;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
FExportMatrix:=TExportMatrix.Create;
|
FExportMatrix:=TExportMatrix.Create;
|
||||||
|
@ -72,6 +72,8 @@ type
|
|||||||
FAngle:byte;
|
FAngle:byte;
|
||||||
FWordWrap: boolean;
|
FWordWrap: boolean;
|
||||||
|
|
||||||
|
FPicture: TPicture;
|
||||||
|
|
||||||
function GetText: string;
|
function GetText: string;
|
||||||
public
|
public
|
||||||
constructor Create(AObj:TfrView);
|
constructor Create(AObj:TfrView);
|
||||||
@ -99,6 +101,8 @@ type
|
|||||||
property Layout : TTextLayout read FLayout;
|
property Layout : TTextLayout read FLayout;
|
||||||
property WordWrap:boolean read FWordWrap;
|
property WordWrap:boolean read FWordWrap;
|
||||||
property URLInfo: string read FURLInfo write FURLInfo;
|
property URLInfo: string read FURLInfo write FURLInfo;
|
||||||
|
property Picture: TPicture read FPicture;
|
||||||
|
|
||||||
end;
|
end;
|
||||||
|
|
||||||
{ TExportRows }
|
{ TExportRows }
|
||||||
@ -127,6 +131,7 @@ type
|
|||||||
TExportMatrix =class
|
TExportMatrix =class
|
||||||
private
|
private
|
||||||
FDeleteEmptyRow: boolean;
|
FDeleteEmptyRow: boolean;
|
||||||
|
FExportImages: boolean;
|
||||||
FMergeCell: boolean;
|
FMergeCell: boolean;
|
||||||
FRows:TFpList;
|
FRows:TFpList;
|
||||||
FColWidth:TBoundArray;
|
FColWidth:TBoundArray;
|
||||||
@ -164,6 +169,7 @@ type
|
|||||||
property DeleteEmptyRow:boolean read FDeleteEmptyRow write FDeleteEmptyRow;
|
property DeleteEmptyRow:boolean read FDeleteEmptyRow write FDeleteEmptyRow;
|
||||||
property MergeCell:boolean read FMergeCell write FMergeCell;
|
property MergeCell:boolean read FMergeCell write FMergeCell;
|
||||||
property PageMargin:integer read FPageMargin write FPageMargin;
|
property PageMargin:integer read FPageMargin write FPageMargin;
|
||||||
|
property ExportImages:boolean read FExportImages write FExportImages;
|
||||||
|
|
||||||
property Rows:TFpList read FRows;
|
property Rows:TFpList read FRows;
|
||||||
end;
|
end;
|
||||||
@ -288,7 +294,11 @@ begin
|
|||||||
end
|
end
|
||||||
else
|
else
|
||||||
if AObj is TfrPictureView then
|
if AObj is TfrPictureView then
|
||||||
FObjType:=gtPicture
|
begin
|
||||||
|
FObjType:=gtPicture;
|
||||||
|
FPicture := TPicture.Create;
|
||||||
|
FPicture.Assign(TfrPictureView(AObj).Picture);
|
||||||
|
end
|
||||||
else
|
else
|
||||||
if AObj is TfrLineView then
|
if AObj is TfrLineView then
|
||||||
FObjType:=gtLine;
|
FObjType:=gtLine;
|
||||||
@ -301,6 +311,9 @@ begin
|
|||||||
FreeAndNil(FTexts);
|
FreeAndNil(FTexts);
|
||||||
if Assigned(FFont) then
|
if Assigned(FFont) then
|
||||||
FreeAndNil(FFont);
|
FreeAndNil(FFont);
|
||||||
|
|
||||||
|
if Assigned(FPicture) then
|
||||||
|
FreeAndNil(FPicture);
|
||||||
inherited Destroy;
|
inherited Destroy;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
@ -634,12 +647,12 @@ var
|
|||||||
R: TExportRow;
|
R: TExportRow;
|
||||||
begin
|
begin
|
||||||
Result:=nil;
|
Result:=nil;
|
||||||
if AObj is TfrMemoView then
|
if (AObj is TfrMemoView) or ((AObj is TfrPictureView) and FExportImages) then
|
||||||
begin
|
begin
|
||||||
R:=FindRow(AObj.Y);
|
R:=FindRow(AObj.Y);
|
||||||
Result:=R.ExportObject(AObj);
|
Result:=R.ExportObject(AObj);
|
||||||
Result.Top:=R.Top;
|
Result.Top:=R.Top;
|
||||||
end;
|
end
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure TExportMatrix.PrepareData;
|
procedure TExportMatrix.PrepareData;
|
||||||
|
@ -50,6 +50,7 @@ type
|
|||||||
FDataGrouping: TlreDataGrouping;
|
FDataGrouping: TlreDataGrouping;
|
||||||
FDataGroupingChunks: integer;
|
FDataGroupingChunks: integer;
|
||||||
FDeleteEmptyRow: boolean;
|
FDeleteEmptyRow: boolean;
|
||||||
|
FExportImages: boolean;
|
||||||
FExportPrintRange: boolean;
|
FExportPrintRange: boolean;
|
||||||
FExportURL: boolean;
|
FExportURL: boolean;
|
||||||
FMergeCell: boolean;
|
FMergeCell: boolean;
|
||||||
@ -61,6 +62,7 @@ type
|
|||||||
public
|
public
|
||||||
constructor Create(AOwner: TComponent); override;
|
constructor Create(AOwner: TComponent); override;
|
||||||
destructor Destroy; override;
|
destructor Destroy; override;
|
||||||
|
property ExportImages:boolean read FExportImages write FExportImages;
|
||||||
published
|
published
|
||||||
property DataGrouping:TlreDataGrouping read FDataGrouping write FDataGrouping;
|
property DataGrouping:TlreDataGrouping read FDataGrouping write FDataGrouping;
|
||||||
property DataGroupingChunks:integer read FDataGroupingChunks write FDataGroupingChunks;
|
property DataGroupingChunks:integer read FDataGroupingChunks write FDataGroupingChunks;
|
||||||
|
Loading…
Reference in New Issue
Block a user