You've already forked lazarus-ccr
fpspreadsheet: Support for writing headers/footer images to xlsx. Remove some compiler hints and warnings.
git-svn-id: https://svn.code.sf.net/p/lazarus-ccr/svn@4532 8e941d3f-bd1b-0410-a28a-d453659cc2b4
This commit is contained in:
@ -159,7 +159,7 @@ begin
|
||||
// Do not try to interpret the strings. --> everything is a LABEL cell.
|
||||
if not CSVParams.DetectContentType then
|
||||
begin
|
||||
FWorksheet.WriteUTF8Text(cell, AText);
|
||||
FWorksheet.WriteText(cell, AText);
|
||||
exit;
|
||||
end;
|
||||
|
||||
@ -192,7 +192,7 @@ begin
|
||||
end;
|
||||
|
||||
// What is left is handled as a TEXT cell
|
||||
FWorksheet.WriteUTF8Text(cell, AText);
|
||||
FWorksheet.WriteText(cell, AText);
|
||||
end;
|
||||
|
||||
procedure TsCSVReader.ReadFormula(AStream: TStream);
|
||||
|
@ -9,7 +9,8 @@ uses
|
||||
|
||||
type
|
||||
TsHeaderFooterToken = (hftText, hftNewLine,
|
||||
hftSheetName, hftPath, hftFileName, hftDate, hftTime, hftPage, hftPageCount);
|
||||
hftSheetName, hftPath, hftFileName, hftDate, hftTime, hftPage, hftPageCount,
|
||||
hftImage);
|
||||
|
||||
TsHeaderFooterFontStyle = (hfsBold, hfsItalic, hfsUnderline, hfsDblUnderline,
|
||||
hfsStrikeout, hfsShadow, hfsOutline, hfsSubscript, hfsSuperScript);
|
||||
@ -36,8 +37,6 @@ type
|
||||
FontIndex: Integer;
|
||||
end;
|
||||
|
||||
TsHeaderFooterSectionIndex = (hfsLeft, hfsCenter, hfsRight);
|
||||
|
||||
TsHeaderFooterSection = array of TsHeaderFooterElement;
|
||||
|
||||
TsHeaderFooterSections = array[TsHeaderFooterSectionIndex] of TsHeaderFooterSection;
|
||||
@ -50,6 +49,7 @@ type
|
||||
FStart: PChar;
|
||||
FEnd: PChar;
|
||||
FCurrFont: TsHeaderFooterFont;
|
||||
FIgnoreFonts: Boolean;
|
||||
function NextToken: Char;
|
||||
function PrevToken: Char;
|
||||
procedure ScanFont;
|
||||
@ -77,10 +77,12 @@ type
|
||||
procedure UseSection(AIndex: TsHeaderFooterSectionIndex); virtual;
|
||||
public
|
||||
constructor Create; overload;
|
||||
constructor Create(AText: String); overload;
|
||||
constructor Create(AText: String; AFontList: TList;
|
||||
ADefaultFont: TsHeaderFooterFont); overload;
|
||||
destructor Destroy; override;
|
||||
function BuildHeaderFooter: String;
|
||||
function IsImageInSection(ASection: TsHeaderFooterSectionIndex): Boolean;
|
||||
property Sections:TsHeaderFooterSections read FSections;
|
||||
end;
|
||||
|
||||
@ -150,6 +152,14 @@ begin
|
||||
FCurrText := '';
|
||||
end;
|
||||
|
||||
constructor TsHeaderFooterParser.Create(AText: String);
|
||||
begin
|
||||
Create;
|
||||
FParseText := AText;
|
||||
FIgnoreFonts := true;
|
||||
Parse;
|
||||
end;
|
||||
|
||||
constructor TsHeaderFooterParser.Create(AText: String; AFontList: TList;
|
||||
ADefaultFont: TsHeaderFooterFont);
|
||||
begin
|
||||
@ -160,6 +170,7 @@ begin
|
||||
|
||||
Create;
|
||||
|
||||
FIgnoreFonts := false;
|
||||
FFontList := AFontList;
|
||||
FDefaultFont := ADefaultFont;
|
||||
FCurrFont := TsHeaderFooterFont.Create;
|
||||
@ -195,7 +206,7 @@ begin
|
||||
FCurrText := '';
|
||||
end else
|
||||
TextValue := '';
|
||||
FontIndex := GetCurrFontIndex;
|
||||
if FIgnoreFonts then FontIndex := -1 else FontIndex := GetCurrFontIndex;
|
||||
end;
|
||||
end;
|
||||
|
||||
@ -274,6 +285,7 @@ begin
|
||||
hftTime : Result := Result + '&T';
|
||||
hftPage : Result := Result + '&P';
|
||||
hftPageCount : Result := Result + '&N';
|
||||
hftImage : Result := Result + '&G';
|
||||
hftNewLine : Result := Result + LineEnding;
|
||||
end;
|
||||
end; // for element
|
||||
@ -310,6 +322,17 @@ begin
|
||||
end;
|
||||
end;
|
||||
|
||||
function TsHeaderFooterParser.IsImageInSection(
|
||||
ASection: TsHeaderFooterSectionIndex): Boolean;
|
||||
var
|
||||
element: TsHeaderFooterElement;
|
||||
begin
|
||||
Result := true;
|
||||
for element in FSections[ASection] do
|
||||
if element.Token = hftImage then exit;
|
||||
Result := false;
|
||||
end;
|
||||
|
||||
function TsHeaderFooterParser.NextToken: Char;
|
||||
begin
|
||||
if FCurrent < FEnd then begin
|
||||
@ -438,6 +461,7 @@ begin
|
||||
'T': AddElement(hftTime);
|
||||
'P': AddElement(hftPage);
|
||||
'N': AddElement(hftPageCount);
|
||||
'G': AddElement(hftImage);
|
||||
'"': ScanFont;
|
||||
'0'..'9', '.': ScanFontSize;
|
||||
'K': ScanFontColor;
|
||||
@ -458,10 +482,13 @@ procedure TsHeaderFooterParser.UseSection(AIndex: TsHeaderFooterSectionIndex);
|
||||
begin
|
||||
if FCurrText <> '' then
|
||||
AddCurrTextElement;
|
||||
FCurrFont.FontName := FDefaultFont.FontName;
|
||||
FCurrFont.Size := FDefaultFont.Size;
|
||||
FCurrFont.Style := FDefaultFont.Style;
|
||||
FCurrFont.Color := FDefaultFont.Color;
|
||||
if not FIgnoreFonts then
|
||||
begin
|
||||
FCurrFont.FontName := FDefaultFont.FontName;
|
||||
FCurrFont.Size := FDefaultFont.Size;
|
||||
FCurrFont.Style := FDefaultFont.Style;
|
||||
FCurrFont.Color := FDefaultFont.Color;
|
||||
end;
|
||||
FCurrSection := AIndex;
|
||||
end;
|
||||
|
||||
|
@ -251,7 +251,7 @@ begin
|
||||
// Case: Do not try to interpret the strings. --> everything is a LABEL cell.
|
||||
if not HTMLParams.DetectContentType then
|
||||
begin
|
||||
FWorksheet.WriteUTF8Text(cell, AText, FCurrRichTextParams);
|
||||
FWorksheet.WriteText(cell, AText, FCurrRichTextParams);
|
||||
exit;
|
||||
end;
|
||||
|
||||
@ -284,7 +284,7 @@ begin
|
||||
end;
|
||||
|
||||
// What is left is handled as a TEXT cell
|
||||
FWorksheet.WriteUTF8Text(cell, AText, FCurrRichTextParams);
|
||||
FWorksheet.WriteText(cell, AText, FCurrRichTextParams);
|
||||
end;
|
||||
|
||||
{ Stores a font in the internal font list. Does not allow duplicates. }
|
||||
|
@ -1818,7 +1818,7 @@ begin
|
||||
|
||||
if ExtractErrorFromNode(ACellNode, errValue) then
|
||||
FWorkSheet.WriteErrorValue(cell, errValue) else
|
||||
FWorksheet.WriteUTF8Text(cell, 'ERROR');
|
||||
FWorksheet.WriteText(cell, 'ERROR');
|
||||
|
||||
styleName := GetAttrValue(ACellNode, 'table:style-name');
|
||||
ApplyStyleToCell(cell, stylename);
|
||||
@ -2129,7 +2129,7 @@ begin
|
||||
if (node <> nil) and (node.FirstChild <> nil) then
|
||||
begin
|
||||
valueStr := node.FirstChild.Nodevalue;
|
||||
FWorksheet.WriteUTF8Text(cell, valueStr);
|
||||
FWorksheet.WriteText(cell, valueStr);
|
||||
end;
|
||||
end else
|
||||
// (d) boolean
|
||||
@ -2142,11 +2142,11 @@ begin
|
||||
begin
|
||||
if ExtractErrorFromNode(ACellNode, errorValue) then
|
||||
FWorksheet.WriteErrorValue(cell, errorValue) else
|
||||
FWorksheet.WriteUTF8Text(cell, 'ERROR');
|
||||
FWorksheet.WriteText(cell, 'ERROR');
|
||||
end else
|
||||
// (e) Text
|
||||
if (valueStr <> '') then
|
||||
FWorksheet.WriteUTF8Text(cell, valueStr);
|
||||
FWorksheet.WriteText(cell, valueStr);
|
||||
|
||||
if FIsVirtualMode then
|
||||
Workbook.OnReadCellData(Workbook, ARow, ACol, cell);
|
||||
@ -2449,7 +2449,7 @@ begin
|
||||
childnode := childnode.NextSibling;
|
||||
end;
|
||||
|
||||
FWorkSheet.WriteUTF8Text(cell, cellText, rtParams);
|
||||
FWorkSheet.WriteText(cell, cellText, rtParams);
|
||||
if hyperlink <> '' then
|
||||
begin
|
||||
// ODS sees relative paths relative to the internal own file structure
|
||||
@ -3003,7 +3003,6 @@ var
|
||||
i, p: Integer;
|
||||
r1,c1,r2,c2: Cardinal;
|
||||
inName: Boolean;
|
||||
ch:Char;
|
||||
begin
|
||||
s := GetAttrValue(ATableNode, 'table:print-ranges');
|
||||
if s = '' then
|
||||
@ -3026,10 +3025,8 @@ begin
|
||||
inc(i);
|
||||
p := i;
|
||||
if p <= Length(s) then
|
||||
begin
|
||||
ch := s[p];
|
||||
Continue;
|
||||
end else
|
||||
Continue
|
||||
else
|
||||
break;
|
||||
end;
|
||||
end;
|
||||
|
@ -1,5 +1,7 @@
|
||||
unit fpsPageLayout;
|
||||
|
||||
{$mode objfpc}{$H+}
|
||||
|
||||
interface
|
||||
|
||||
uses
|
||||
@ -27,15 +29,15 @@ type
|
||||
FOptions: TsPrintOptions;
|
||||
FHeaders: array[0..2] of String;
|
||||
FFooters: array[0..2] of String;
|
||||
FHeaderImages: array[TsHeaderFooterSection] of TsHeaderFooterImage;
|
||||
FFooterImages: array[TsHeaderFooterSection] of TsHeaderFooterImage;
|
||||
FHeaderImages: TsHeaderFooterImages;
|
||||
FFooterImages: TsHeaderFooterImages;
|
||||
FRepeatedCols: TsRowColRange;
|
||||
FRepeatedRows: TsRowColRange;
|
||||
FPrintRanges: TsCellRangeArray;
|
||||
|
||||
function GetFooterImages(ASection: TsHeaderFooterSection): TsHeaderFooterImage;
|
||||
function GetFooterImages(ASection: TsHeaderFooterSectionIndex): TsHeaderFooterImage;
|
||||
function GetFooters(AIndex: Integer): String;
|
||||
function GetHeaderImages(ASection: TsHeaderFooterSection): TsHeaderFooterImage;
|
||||
function GetHeaderImages(ASection: TsHeaderFooterSectionIndex): TsHeaderFooterImage;
|
||||
function GetHeaders(AIndex: Integer): String;
|
||||
procedure SetFitHeightToPages(AValue: Integer);
|
||||
procedure SetFitWidthToPages(AValue: Integer);
|
||||
@ -44,15 +46,21 @@ type
|
||||
procedure SetScalingFactor(AValue: Integer);
|
||||
procedure SetStartPageNumber(AValue: Integer);
|
||||
|
||||
protected
|
||||
function JoinHeaderFooterText(const ALeft, ACenter, ARight: String): String;
|
||||
procedure SplitHeaderFooterText(const AText: String; out ALeft, ACenter, ARight: String);
|
||||
|
||||
public
|
||||
constructor Create(AWorksheet: pointer);
|
||||
procedure Assign(ASource: TsPageLayout);
|
||||
|
||||
{ Images embedded in header and/or footer }
|
||||
procedure AddHeaderImage(AHeaderIndex: Integer;
|
||||
ASection: TsHeaderFooterSection; const AFilename: String);
|
||||
ASection: TsHeaderFooterSectionIndex; const AFilename: String);
|
||||
procedure AddFooterImage(AFooterIndex: Integer;
|
||||
ASection: TsHeaderFooterSection; const AFilename: String);
|
||||
ASection: TsHeaderFooterSectionIndex; const AFilename: String);
|
||||
procedure GetImageSections(out AHeaderTags, AFooterTags: String);
|
||||
function HasHeaderFooterImages: Boolean;
|
||||
|
||||
{ Repeated rows and columns }
|
||||
function HasRepeatedCols: Boolean;
|
||||
@ -130,7 +138,7 @@ type
|
||||
- sheet name: &A
|
||||
- file name without path: &F
|
||||
- file path without file name: &Z
|
||||
- image: &G (must be provided by "AddHeaderImage" or "AddFooterImage")
|
||||
- image: &G (filename must be provided by "AddHeaderImage" or "AddFooterImage")
|
||||
- bold/italic/underlining/double underlining/strike out/shadowed/
|
||||
outlined/superscript/subscript on/off:
|
||||
&B / &I / &U / &E / &S / &H
|
||||
@ -156,10 +164,10 @@ type
|
||||
read GetPrintRange;
|
||||
|
||||
{@@ Images inserted into footer }
|
||||
property FooterImages[ASection: TsHeaderFooterSection]: TsHeaderFooterImage
|
||||
property FooterImages[ASection: TsHeaderFooterSectionIndex]: TsHeaderFooterImage
|
||||
read GetFooterImages;
|
||||
{@@ Images inserted into header }
|
||||
property HeaderImages[ASection: TsHeaderFooterSection]: TsHeaderFooterImage
|
||||
property HeaderImages[ASection: TsHeaderFooterSectionIndex]: TsHeaderFooterImage
|
||||
read GetHeaderImages;
|
||||
end;
|
||||
|
||||
@ -168,11 +176,11 @@ implementation
|
||||
|
||||
uses
|
||||
Math,
|
||||
fpsUtils, fpSpreadsheet;
|
||||
fpsUtils, fpsHeaderFooterParser, fpSpreadsheet;
|
||||
|
||||
constructor TsPageLayout.Create(AWorksheet: Pointer);
|
||||
var
|
||||
hfs: TsHeaderFooterSection;
|
||||
sec: TsHeaderFooterSectionIndex;
|
||||
i: Integer;
|
||||
begin
|
||||
inherited Create;
|
||||
@ -198,10 +206,10 @@ begin
|
||||
for i:=0 to 2 do FHeaders[i] := '';
|
||||
for i:=0 to 2 do FFooters[i] := '';
|
||||
|
||||
for hfs in TsHeaderFooterSection do
|
||||
for sec in TsHeaderFooterSectionIndex do
|
||||
begin
|
||||
InitHeaderFooterImageRecord(FHeaderImages[hfs]);
|
||||
InitHeaderFooterImageRecord(FFooterImages[hfs]);
|
||||
InitHeaderFooterImageRecord(FHeaderImages[sec]);
|
||||
InitHeaderFooterImageRecord(FFooterImages[sec]);
|
||||
end;
|
||||
|
||||
FRepeatedRows.FirstIndex := UNASSIGNED_ROW_COL_INDEX;
|
||||
@ -214,7 +222,7 @@ end;
|
||||
procedure TsPageLayout.Assign(ASource: TsPageLayout);
|
||||
var
|
||||
i: Integer;
|
||||
hfs: TsHeaderFooterSection;
|
||||
sec: TsHeaderFooterSectionIndex;
|
||||
begin
|
||||
FOrientation := ASource.Orientation;
|
||||
FPageWidth := ASource.PageWidth;
|
||||
@ -236,10 +244,10 @@ begin
|
||||
FHeaders[i] := ASource.Headers[i];
|
||||
FFooters[i] := ASource.Footers[i];
|
||||
end;
|
||||
for hfs in TsHeaderFooterSection do
|
||||
for sec in TsHeaderFooterSectionIndex do
|
||||
begin
|
||||
FHeaderImages[hfs] := ASource.HeaderImages[hfs];
|
||||
FFooterImages[hfs] := ASource.FooterImages[hfs];
|
||||
FHeaderImages[sec] := ASource.HeaderImages[sec];
|
||||
FFooterImages[sec] := ASource.FooterImages[sec];
|
||||
end;
|
||||
FRepeatedCols := ASource.RepeatedCols;
|
||||
FRepeatedRows := ASource.RepeatedRows;
|
||||
@ -249,10 +257,11 @@ begin
|
||||
end;
|
||||
|
||||
procedure TsPageLayout.AddHeaderImage(AHeaderIndex: Integer;
|
||||
ASection: TsHeaderFooterSection; const AFilename: String);
|
||||
ASection: TsHeaderFooterSectionIndex; const AFilename: String);
|
||||
var
|
||||
book: TsWorkbook;
|
||||
idx: Integer;
|
||||
s: Array[TsHeaderFooterSectionIndex] of String;
|
||||
begin
|
||||
if FWorksheet = nil then
|
||||
raise Exception.Create('[TsPageLayout.AddHeaderImage] Worksheet is nil.');
|
||||
@ -264,14 +273,17 @@ begin
|
||||
book.GetEmbeddedStream(idx).LoadFromFile(AFileName);
|
||||
end;
|
||||
FHeaderImages[ASection].Index := idx;
|
||||
FHeaders[AHeaderIndex] := FHeaders[AHeaderIndex] + '&G';
|
||||
SplitHeaderFooterText(FHeaders[AHeaderIndex], s[hfsLeft], s[hfsCenter], s[hfsRight]);
|
||||
s[ASection] := s[ASection] + '&G';
|
||||
FHeaders[AHeaderIndex] := JoinHeaderFooterText(s[hfsLeft], s[hfsCenter], s[hfsRight]);
|
||||
end;
|
||||
|
||||
procedure TsPageLayout.AddFooterImage(AFooterIndex: Integer;
|
||||
ASection: TsHeaderFooterSection; const AFileName: String);
|
||||
ASection: TsHeaderFooterSectionIndex; const AFileName: String);
|
||||
var
|
||||
book: TsWorkbook;
|
||||
idx: Integer;
|
||||
s: Array[TsHeaderFooterSectionIndex] of String;
|
||||
begin
|
||||
if FWorksheet = nil then
|
||||
raise Exception.Create('[TsPageLayout.AddFooterImage] Worksheet is nil.');
|
||||
@ -283,7 +295,9 @@ begin
|
||||
book.GetEmbeddedStream(idx).LoadFromFile(AFileName);
|
||||
end;
|
||||
FFooterImages[ASection].Index := idx;
|
||||
FFooters[AFooterIndex] := FFooters[AFooterIndex] + '&G';
|
||||
SplitHeaderFooterText(FHeaders[AFooterIndex], s[hfsLeft], s[hfsCenter], s[hfsRight]);
|
||||
s[ASection] := s[ASection] + '&G';
|
||||
FHeaders[AFooterIndex] := JoinHeaderFooterText(s[hfsLeft], s[hfsCenter], s[hfsRight]);
|
||||
end;
|
||||
|
||||
{@@ ----------------------------------------------------------------------------
|
||||
@ -325,7 +339,7 @@ begin
|
||||
end;
|
||||
|
||||
function TsPageLayout.GetFooterImages(
|
||||
ASection: TsHeaderFooterSection): TsHeaderFooterImage;
|
||||
ASection: TsHeaderFooterSectionIndex): TsHeaderFooterImage;
|
||||
begin
|
||||
Result := FFooterImages[ASection];
|
||||
end;
|
||||
@ -338,8 +352,47 @@ begin
|
||||
raise Exception.Create('[TsPageLayout.GetFooters] Illegal index.');
|
||||
end;
|
||||
|
||||
{@@ ----------------------------------------------------------------------------
|
||||
Checks all sections of the headers and footers for images.
|
||||
Creates a 3-character-string for the header and the footer containing an "L"
|
||||
at the first position if any of the three header texts contains a "%G" in
|
||||
the left section.
|
||||
Dto. for the other sections.
|
||||
Only one image per section is allowed! Sections violating this are marked by "x"
|
||||
-------------------------------------------------------------------------------}
|
||||
procedure TsPageLayout.GetImageSections(out AHeaderTags, AFooterTags: String);
|
||||
|
||||
procedure Process(AText: String; var ATags: String);
|
||||
var
|
||||
hfp: TsHeaderFooterParser;
|
||||
begin
|
||||
hfp := TsHeaderFooterParser.Create(AText); //, booknil, nil);
|
||||
try
|
||||
if hfp.IsImageInSection(hfsLeft) then
|
||||
ATags[1] := IfThen(ATags[1] = ' ', 'L', 'x');
|
||||
if hfp.IsImageInSection(hfsCenter) then
|
||||
ATags[2] := IfThen(ATags[2] = ' ', 'C', 'x');
|
||||
if hfp.IsImageInSection(hfsRight) then
|
||||
ATags[3] := IfThen(ATags[3] = ' ', 'R', 'x');
|
||||
finally
|
||||
hfp.Free;
|
||||
end;
|
||||
end;
|
||||
|
||||
var
|
||||
i: Integer;
|
||||
begin
|
||||
AHeaderTags := ' ';
|
||||
for i:=0 to 2 do
|
||||
Process(FHeaders[i], AHeaderTags);
|
||||
|
||||
AFooterTags := ' ';
|
||||
for i:=0 to 2 do
|
||||
Process(FFooters[i], AFooterTags);
|
||||
end;
|
||||
|
||||
function TsPageLayout.GetHeaderImages(
|
||||
ASection: TsHeaderFooterSection): TsHeaderFooterImage;
|
||||
ASection: TsHeaderFooterSectionIndex): TsHeaderFooterImage;
|
||||
begin
|
||||
Result := FHeaderImages[ASection];
|
||||
end;
|
||||
@ -363,6 +416,22 @@ begin
|
||||
raise Exception.Create('[TsPageLayout.GetPrintRange] Illegal index.');
|
||||
end;
|
||||
|
||||
{@@ ----------------------------------------------------------------------------
|
||||
Checks whether the header or footer of the worksheet contains embedded images
|
||||
-------------------------------------------------------------------------------}
|
||||
function TsPageLayout.HasHeaderFooterImages: Boolean;
|
||||
var
|
||||
sec: TsHeaderFooterSectionIndex;
|
||||
begin
|
||||
Result := true;
|
||||
for sec in TsHeaderFooterSectionIndex do
|
||||
begin
|
||||
if FHeaderImages[sec].Index >= 0 then Exit;
|
||||
if FFooterImages[sec].Index >= 0 then Exit;
|
||||
end;
|
||||
Result := false;
|
||||
end;
|
||||
|
||||
{@@ ----------------------------------------------------------------------------
|
||||
Checks whether the worksheet defines columns to be printed repeatedly at the
|
||||
left of each printed page
|
||||
@ -381,6 +450,24 @@ begin
|
||||
Result := Cardinal(FRepeatedRows.FirstIndex) <> Cardinal(UNASSIGNED_ROW_COL_INDEX);
|
||||
end;
|
||||
|
||||
{@@ ----------------------------------------------------------------------------
|
||||
Combines the three strings for the left, center and right header/footer
|
||||
sections to a valid header/footer string. Inserts "&L", "&C" and "&R" codes.
|
||||
-------------------------------------------------------------------------------}
|
||||
function TsPageLayout.JoinHeaderFooterText(
|
||||
const ALeft, ACenter, ARight: String): String;
|
||||
begin
|
||||
Result := '';
|
||||
if (ALeft = '') and (ARight = '') then
|
||||
begin
|
||||
Result := ACenter;
|
||||
exit;
|
||||
end;
|
||||
if (ALeft <> '') then Result := '&L' + ALeft;
|
||||
if (ACenter <> '') then Result := Result + '&C' + ACenter;
|
||||
if (ARight <> '') then Result := Result + '&R' + ARight;
|
||||
end;
|
||||
|
||||
{@@ ----------------------------------------------------------------------------
|
||||
Returns the count of print ranges defined for this worksheet
|
||||
-------------------------------------------------------------------------------}
|
||||
@ -462,4 +549,59 @@ begin
|
||||
Include(FOptions, poUseStartPageNumber);
|
||||
end;
|
||||
|
||||
procedure TsPageLayout.SplitHeaderFooterText(const AText: String;
|
||||
out ALeft, ACenter, ARight: String);
|
||||
var
|
||||
pL, pC, pR: Integer;
|
||||
P, PStart: PChar;
|
||||
begin
|
||||
ALeft := '';
|
||||
ACenter := '';
|
||||
ARight := '';
|
||||
if AText = '' then
|
||||
exit;
|
||||
|
||||
P := PChar(AText);
|
||||
PStart := P;
|
||||
pL := 0;
|
||||
pC := 0;
|
||||
pR := 0;
|
||||
while (P^ <> #0) do begin
|
||||
if P^ = '&' then
|
||||
begin
|
||||
inc(P);
|
||||
if (P^ = 'L') or (P^ = 'l') then
|
||||
pL := PtrUInt(P) - PtrUInt(PStart)
|
||||
else
|
||||
if (P^ = 'C') or (P^ = 'c') then
|
||||
pC := PtrUInt(P) - PtrUInt(PStart)
|
||||
else
|
||||
if (P^ = 'R') or (P^ = 'r') then
|
||||
pR := PtrUInt(P) - PtrUInt(PStart);
|
||||
end;
|
||||
inc(P);
|
||||
end;
|
||||
if (pL > 0) then
|
||||
begin
|
||||
if pC > 0 then
|
||||
ALeft := Copy(AText, pL+2, pC - pL - 1)
|
||||
else
|
||||
if pR > 0 then
|
||||
ARight := Copy(AText, pL, pR - pL - 1)
|
||||
else
|
||||
ALeft := Copy(AText, pL+2, MaxInt);
|
||||
exit;
|
||||
end;
|
||||
if (pC > 0) then
|
||||
begin
|
||||
if pR > 0 then
|
||||
ACenter := Copy(AText, pC+2, pR - pC - 1)
|
||||
else
|
||||
ACenter := Copy(AText, pC+2, MaxInt);
|
||||
exit;
|
||||
end;
|
||||
if (pR > 0) then
|
||||
ARight := Copy(AText, pR+2, MaxInt);
|
||||
end;
|
||||
|
||||
end.
|
||||
|
@ -92,7 +92,12 @@ resourcestring
|
||||
|
||||
rsCannotSortMerged = 'The cell range cannot be sorted because it contains merged cells.';
|
||||
|
||||
// PageLayout
|
||||
rsDifferentSheetPrintRange = 'Print range "%s" requires a different worksheet.';
|
||||
rsFooter = 'Footer';
|
||||
rsHeader = 'Header';
|
||||
rsIncorrectPositionOfImageInHeaderFooter = 'Incorrect position of %%G code in %s';
|
||||
rsOnlyOneHeaderFooterImageAllowed = 'Only one image per %s section allowed.';
|
||||
|
||||
// Colors
|
||||
rsAqua = 'aqua';
|
||||
|
@ -701,7 +701,10 @@ type
|
||||
TsPrintOptions = set of TsPrintOption;
|
||||
|
||||
{@@ Headers and footers are divided into three parts: left, center and right }
|
||||
TsHeaderFooterSection = (hfsLeft, hfsCenter, hfsRight);
|
||||
TsHeaderFooterSectionIndex = (hfsLeft, hfsCenter, hfsRight);
|
||||
|
||||
{@@ Array with all possible images in a header or a footer }
|
||||
TsHeaderFooterImages = array[TsHeaderFooterSectionIndex] of TsHeaderFooterImage;
|
||||
|
||||
const
|
||||
{@@ Indexes to be used for the various headers and footers }
|
||||
|
@ -111,6 +111,7 @@ function GetFormatFromFileName(const AFileName: TFileName;
|
||||
procedure EnsureOrder(var a,b: Integer); overload;
|
||||
procedure EnsureOrder(var a,b: Cardinal); overload;
|
||||
function IfThen(ACondition: Boolean; AValue1,AValue2: TsNumberFormat): TsNumberFormat; overload;
|
||||
function IfThen(ACondition: Boolean; AValue1,AValue2: Char): Char; overload;
|
||||
|
||||
procedure FloatToFraction(AValue: Double; AMaxDenominator: Int64;
|
||||
out ANumerator, ADenominator: Int64);
|
||||
@ -1209,6 +1210,11 @@ begin
|
||||
if ACondition then Result := AValue1 else Result := AValue2;
|
||||
end;
|
||||
|
||||
function IfThen(ACondition: Boolean; AValue1, AValue2: char): char;
|
||||
begin
|
||||
if ACondition then Result := AValue1 else Result := AValue2;
|
||||
end;
|
||||
|
||||
{@@ ----------------------------------------------------------------------------
|
||||
Approximates a floating point value as a fraction and returns the values of
|
||||
numerator and denominator.
|
||||
|
@ -652,7 +652,7 @@ begin
|
||||
cell := @FVirtualCell;
|
||||
end else
|
||||
cell := FWorksheet.AddCell(ARow, ACol);
|
||||
FWorksheet.WriteUTF8Text(cell, valueStr);
|
||||
FWorksheet.WriteText(cell, valueStr);
|
||||
|
||||
{ Apply formatting to cell }
|
||||
ApplyCellFormatting(cell, XF);
|
||||
|
@ -399,7 +399,7 @@ var
|
||||
ansistr: ansiString;
|
||||
defName: String;
|
||||
rpnformula: TsRPNFormula;
|
||||
extsheetIndex: Integer;
|
||||
{%H-}extsheetIndex: Integer;
|
||||
sheetIndex: Integer;
|
||||
begin
|
||||
// Options
|
||||
@ -652,7 +652,7 @@ begin
|
||||
|
||||
{ Save the data string to cell }
|
||||
valueStr := ConvertEncoding(ansistr, FCodePage, encodingUTF8);
|
||||
FWorksheet.WriteUTF8Text(cell, valuestr);
|
||||
FWorksheet.WriteText(cell, valuestr);
|
||||
|
||||
{ Read rich-text formatting runs }
|
||||
B := AStream.ReadByte;
|
||||
@ -1065,7 +1065,7 @@ begin
|
||||
|
||||
{ Save the data }
|
||||
valueStr := ConvertEncoding(ansistr, FCodePage, encodingUTF8);
|
||||
FWorksheet.WriteUTF8Text(cell, valueStr); //ISO_8859_1ToUTF8(ansistr));
|
||||
FWorksheet.WriteText(cell, valueStr); //ISO_8859_1ToUTF8(ansistr));
|
||||
|
||||
{ Add attributes }
|
||||
ApplyCellFormatting(cell, XF);
|
||||
|
@ -1029,7 +1029,7 @@ begin
|
||||
end else
|
||||
cell := FWorksheet.AddCell(ARow, ACol); // "real" cell
|
||||
|
||||
FWorksheet.WriteUTF8Text(cell, UTF16ToUTF8(wideStrValue));
|
||||
FWorksheet.WriteText(cell, UTF16ToUTF8(wideStrValue));
|
||||
|
||||
{ Add attributes }
|
||||
ApplyCellFormatting(cell, XF);
|
||||
@ -1272,7 +1272,7 @@ begin
|
||||
cell := FWorksheet.AddCell(ARow, ACol); // "real" cell
|
||||
|
||||
{ Save the data string}
|
||||
FWorksheet.WriteUTF8Text(cell, UTF16ToUTF8(wideStrValue));
|
||||
FWorksheet.WriteText(cell, UTF16ToUTF8(wideStrValue));
|
||||
|
||||
{ Read rich-text formatting runs }
|
||||
L := WordLEToN(AStream.ReadWord);
|
||||
@ -1421,7 +1421,7 @@ begin
|
||||
end else
|
||||
cell := FWorksheet.AddCell(ARow, ACol);
|
||||
|
||||
FWorksheet.WriteUTF8Text(cell, FSharedStringTable[SSTIndex]);
|
||||
FWorksheet.WriteText(cell, FSharedStringTable[SSTIndex]);
|
||||
|
||||
{ Add attributes }
|
||||
ApplyCellFormatting(cell, XF);
|
||||
|
@ -900,7 +900,6 @@ procedure TsBIFFDefinedName.UpdateSheetIndex(ASheetName: String; ASheetIndex: In
|
||||
var
|
||||
elem: TsFormulaElement;
|
||||
i, p: Integer;
|
||||
s: String;
|
||||
begin
|
||||
for i:=0 to Length(FFormula)-1 do begin
|
||||
elem := FFormula[i];
|
||||
@ -1200,7 +1199,6 @@ end;
|
||||
|
||||
procedure TsSpreadBIFFReader.FixDefinedNames(AWorksheet: TsWorksheet);
|
||||
var
|
||||
sheetName1, sheetName2: String;
|
||||
i: Integer;
|
||||
defname: TsBiffDefinedName;
|
||||
sheetIndex: Integer;
|
||||
@ -2184,6 +2182,7 @@ end;
|
||||
function TsSpreadBIFFReader.ReadRPNCellRange3D(AStream: TStream;
|
||||
var ARPNItem: PRPNItem): Boolean;
|
||||
begin
|
||||
Unused(AStream, ARPNItem);
|
||||
Result := false; // "false" means: "not supported"
|
||||
// must be overridden
|
||||
end;
|
||||
@ -2433,7 +2432,6 @@ function TsSpreadBIFFReader.ReadRPNTokenArray(AStream: TStream;
|
||||
ARpnTokenArraySize: Word; out ARpnFormula: TsRPNFormula; ACell: PCell = nil;
|
||||
ASharedFormulaBase: PCell = nil): Boolean;
|
||||
var
|
||||
n: Word;
|
||||
p0: Int64;
|
||||
token: Byte;
|
||||
rpnItem: PRPNItem;
|
||||
@ -2442,7 +2440,6 @@ var
|
||||
flags: TsRelFlags;
|
||||
r, c, r2, c2: Cardinal;
|
||||
dr, dc, dr2, dc2: Integer;
|
||||
sheetIndex: Integer;
|
||||
fek: TFEKind;
|
||||
exprDef: TsBuiltInExprIdentifierDef;
|
||||
funcCode: Word;
|
||||
@ -3302,6 +3299,8 @@ end;
|
||||
procedure TsSpreadBIFFWriter.WriteDefinedName(AStream: TStream;
|
||||
AWorksheet: TsWorksheet; const AName: String; AIndexToREF: Word);
|
||||
begin
|
||||
Unused(AStream, AWorksheet);
|
||||
Unused(Aname, AIndexToREF);
|
||||
// Override
|
||||
end;
|
||||
|
||||
|
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user