You've already forked lazarus-ccr
fpspreadsheet: Load images for header/footer into workbook's embedded streams list.
git-svn-id: https://svn.code.sf.net/p/lazarus-ccr/svn@4531 8e941d3f-bd1b-0410-a28a-d453659cc2b4
This commit is contained in:
@ -49,10 +49,10 @@ type
|
|||||||
procedure Assign(ASource: TsPageLayout);
|
procedure Assign(ASource: TsPageLayout);
|
||||||
|
|
||||||
{ Images embedded in header and/or footer }
|
{ Images embedded in header and/or footer }
|
||||||
procedure AddHeaderImage(ASection: TsHeaderFooterSection;
|
procedure AddHeaderImage(AHeaderIndex: Integer;
|
||||||
const AFilename: String);
|
ASection: TsHeaderFooterSection; const AFilename: String);
|
||||||
procedure AddFooterImage(ASection: TsHeaderFooterSection;
|
procedure AddFooterImage(AFooterIndex: Integer;
|
||||||
const AFilename: String);
|
ASection: TsHeaderFooterSection; const AFilename: String);
|
||||||
|
|
||||||
{ Repeated rows and columns }
|
{ Repeated rows and columns }
|
||||||
function HasRepeatedCols: Boolean;
|
function HasRepeatedCols: Boolean;
|
||||||
@ -248,30 +248,42 @@ begin
|
|||||||
FPrintranges[i] := ASource.FPrintRanges[i];
|
FPrintranges[i] := ASource.FPrintRanges[i];
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure TsPageLayout.AddHeaderImage(ASection: TsHeaderFooterSection;
|
procedure TsPageLayout.AddHeaderImage(AHeaderIndex: Integer;
|
||||||
const AFilename: String);
|
ASection: TsHeaderFooterSection; const AFilename: String);
|
||||||
var
|
var
|
||||||
book: TsWorkbook;
|
book: TsWorkbook;
|
||||||
idx: Integer;
|
idx: Integer;
|
||||||
begin
|
begin
|
||||||
|
if FWorksheet = nil then
|
||||||
|
raise Exception.Create('[TsPageLayout.AddHeaderImage] Worksheet is nil.');
|
||||||
book := TsWorksheet(FWorksheet).Workbook;
|
book := TsWorksheet(FWorksheet).Workbook;
|
||||||
idx := book.FindEmbeddedStream(AFilename);
|
idx := book.FindEmbeddedStream(AFilename);
|
||||||
if idx = -1 then
|
if idx = -1 then
|
||||||
|
begin
|
||||||
idx := book.AddEmbeddedStream(AFilename);
|
idx := book.AddEmbeddedStream(AFilename);
|
||||||
|
book.GetEmbeddedStream(idx).LoadFromFile(AFileName);
|
||||||
|
end;
|
||||||
FHeaderImages[ASection].Index := idx;
|
FHeaderImages[ASection].Index := idx;
|
||||||
|
FHeaders[AHeaderIndex] := FHeaders[AHeaderIndex] + '&G';
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure TsPageLayout.AddFooterImage(ASection: TsHeaderFooterSection;
|
procedure TsPageLayout.AddFooterImage(AFooterIndex: Integer;
|
||||||
const AFileName: String);
|
ASection: TsHeaderFooterSection; const AFileName: String);
|
||||||
var
|
var
|
||||||
book: TsWorkbook;
|
book: TsWorkbook;
|
||||||
idx: Integer;
|
idx: Integer;
|
||||||
begin
|
begin
|
||||||
|
if FWorksheet = nil then
|
||||||
|
raise Exception.Create('[TsPageLayout.AddFooterImage] Worksheet is nil.');
|
||||||
book := TsWorksheet(FWorksheet).Workbook;
|
book := TsWorksheet(FWorksheet).Workbook;
|
||||||
idx := book.FindEmbeddedStream(AFilename);
|
idx := book.FindEmbeddedStream(AFilename);
|
||||||
if idx = -1 then
|
if idx = -1 then
|
||||||
|
begin
|
||||||
idx := book.AddEmbeddedStream(AFilename);
|
idx := book.AddEmbeddedStream(AFilename);
|
||||||
|
book.GetEmbeddedStream(idx).LoadFromFile(AFileName);
|
||||||
|
end;
|
||||||
FFooterImages[ASection].Index := idx;
|
FFooterImages[ASection].Index := idx;
|
||||||
|
FFooters[AFooterIndex] := FFooters[AFooterIndex] + '&G';
|
||||||
end;
|
end;
|
||||||
|
|
||||||
{@@ ----------------------------------------------------------------------------
|
{@@ ----------------------------------------------------------------------------
|
||||||
|
@ -3423,11 +3423,12 @@ end;
|
|||||||
@param ARow Index of the row at which the image begins (top edge)
|
@param ARow Index of the row at which the image begins (top edge)
|
||||||
@param ACol Index of the column at which the image begins (left edge)
|
@param ACol Index of the column at which the image begins (left edge)
|
||||||
@param AFileName Name of the image file
|
@param AFileName Name of the image file
|
||||||
@param AOffsetX The image is offset horizontally by this pixel count from
|
@param AOffsetX The image is offset horizontally from the left edge of
|
||||||
the left edge of the anchor cell. May reach into another
|
the anchor cell. May reach into another cell.
|
||||||
cell.
|
Value is in millimeters.
|
||||||
@param AOffsetY The image is offset vertically by this pixel count from the
|
@param AOffsetY The image is offset vertically from the top edge of the
|
||||||
top edge of the anchor cell. May reach into another cell.
|
anchor cell. May reach into another cell.
|
||||||
|
Value is in millimeters.
|
||||||
@param AScaleX Horizontal scaling factor of the image
|
@param AScaleX Horizontal scaling factor of the image
|
||||||
@param AScaleY Vertical scaling factor of the image
|
@param AScaleY Vertical scaling factor of the image
|
||||||
@return Index into the internal image list.
|
@return Index into the internal image list.
|
||||||
|
@ -658,15 +658,15 @@ type
|
|||||||
{ Index of format record in the workbook's FCellFormatList }
|
{ Index of format record in the workbook's FCellFormatList }
|
||||||
FormatIndex: Integer;
|
FormatIndex: Integer;
|
||||||
{ Cell content }
|
{ Cell content }
|
||||||
UTF8StringValue: String; // Strings cannot be part of a variant record
|
UTF8StringValue: String; // Strings cannot be part of a variant record
|
||||||
RichTextParams: TsRichTextParams; // Formatting of individual text ranges
|
RichTextParams: TsRichTextParams; // Formatting of individual text ranges
|
||||||
FormulaValue: String;
|
FormulaValue: String; // Formula for calculation of cell content
|
||||||
case ContentType: TCellContentType of // variant part must be at the end
|
case ContentType: TCellContentType of // variant part must be at the end
|
||||||
cctEmpty : (); // has no data at all
|
cctEmpty : (); // has no data at all
|
||||||
cctFormula : (); // FormulaValue is outside the variant record
|
cctFormula : (); // FormulaValue is outside the variant record
|
||||||
cctNumber : (Numbervalue: Double);
|
cctNumber : (Numbervalue: Double);
|
||||||
cctUTF8String : (); // UTF8StringValue is outside the variant record
|
cctUTF8String : (); // UTF8StringValue is outside the variant record
|
||||||
cctDateTime : (DateTimevalue: TDateTime);
|
cctDateTime : (DateTimeValue: TDateTime);
|
||||||
cctBool : (BoolValue: boolean);
|
cctBool : (BoolValue: boolean);
|
||||||
cctError : (ErrorValue: TsErrorValue);
|
cctError : (ErrorValue: TsErrorValue);
|
||||||
end;
|
end;
|
||||||
@ -676,16 +676,16 @@ type
|
|||||||
|
|
||||||
{@@ Embedded image }
|
{@@ Embedded image }
|
||||||
TsImage = record
|
TsImage = record
|
||||||
Row, Col: Cardinal;
|
Row, Col: Cardinal; // cell for top/left edge of the image (anchor)
|
||||||
Index: Integer;
|
Index: Integer; // index into the workbook's embedded streams list
|
||||||
OffsetX, OffsetY: Double; // mm
|
OffsetX, OffsetY: Double; // mm, relative to anchor
|
||||||
ScaleX, ScaleY: Double;
|
ScaleX, ScaleY: Double; // scaling factor of image
|
||||||
end;
|
end;
|
||||||
PsImage = ^TsImage;
|
PsImage = ^TsImage;
|
||||||
|
|
||||||
{@@ Image embedded in header or footer}
|
{@@ Image embedded in header or footer}
|
||||||
TsHeaderFooterImage = record
|
TsHeaderFooterImage = record
|
||||||
Index: Integer;
|
Index: Integer; // index into the workbook's embedded streams list
|
||||||
end;
|
end;
|
||||||
|
|
||||||
{@@ Page orientation for printing }
|
{@@ Page orientation for printing }
|
||||||
|
Reference in New Issue
Block a user