fpspreadsheet: Fix centering of worksheet in xlsx print-out. Fix print page orientation in ods.

git-svn-id: https://svn.code.sf.net/p/lazarus-ccr/svn@9507 8e941d3f-bd1b-0410-a28a-d453659cc2b4
This commit is contained in:
wp_xxyyzz 2024-11-30 16:41:58 +00:00
parent 03cf0e9c90
commit 43f8e27ce2
3 changed files with 30 additions and 7 deletions

View File

@ -925,9 +925,10 @@ uses
{ TsChartColor }
{@@ Helper function to create a record with a color for the fpspreadsheet charts.
The record contains a Transparency field.
The record contains a Transparency field in addition to the standard TsColor
field.
@param AColor RGB color
@param AColor RGB color
@param ATransparency Transparency of the color, value between 0.0 and 1.0
@returns A TsChartColor record

View File

@ -9074,16 +9074,24 @@ function TsSpreadOpenDocWriter.WritePageLayoutXMLAsString(AStyleName: String;
APageLayout.FooterMargin, APageLayout.BottomMargin);
Result := Format(
'fo:page-width="%.2fmm" fo:page-height="%.2fmm" '+
'fo:margin-top="%.2fmm" fo:margin-bottom="%.2fmm" '+
'fo:margin-left="%.2fmm" fo:margin-right="%.2fmm" ', [
APageLayout.PageWidth, APageLayout.PageHeight,
topmargin, bottommargin,
APageLayout.LeftMargin, APageLayout.RightMargin
], FPointSeparatorSettings);
if APageLayout.Orientation = spoLandscape then
Result := Result + 'style:print-orientation="landscape" ';
Result := Result + Format(
'fo:page-width="%.2fmm" fo:page-height="%.2fmm" '+
'style:print-orientation="landscape" ', [
APageLayout.PageHeight, APagelayout.PageWidth // Width and hight must be exchanged
], FPointSeparatorSettings)
else
Result := Result + Format(
'fo:page-width="%.2fmm" fo:page-height="%.2fmm" ', [
APageLayout.PageWidth, APageLayout.PageHeight
], FPointSeparatorSettings);
if poPrintPagesByRows in APageLayout.Options then
Result := Result + 'style:print-page-order="ltr" ';

View File

@ -3801,6 +3801,14 @@ begin
s := GetAttrValue(ANode, 'gridLines');
if StrIsTrue(s) then
with sheet.PageLayout do Options := Options + [poPrintGridLines];
s := GetAttrValue(ANode, 'horizontalCentered');
if StrIsTrue(s) then
with sheet.PageLayout do Options := Options + [poHorCentered];
s := GetAttrValue(ANode, 'verticalCentered');
if StrIsTrue(s) then
with sheet.PageLayout do Options := Options + [poVertCentered];
end;
procedure TsSpreadOOXMLReader.ReadRels(AStream: TStream; ARelsFile: String;
@ -5966,13 +5974,19 @@ end;
procedure TsSpreadOOXMLWriter.WritePrintOptions(AStream: TStream;
AWorksheet: TsBasicWorksheet);
var
sheet: TsWorksheet;
s: String;
begin
sheet := AWorksheet as TsWorksheet;
s := '';
if poPrintGridLines in (AWorksheet as TsWorksheet).PageLayout.Options then
if poPrintGridLines in sheet.PageLayout.Options then
s := s + ' gridLines="1"';
if poPrintHeaders in (AWorksheet as TsWorksheet).PageLayout.Options then
if poPrintHeaders in sheet.PageLayout.Options then
s := s + ' headings="1"';
if poHorCentered in sheet.PageLayout.Options then
s := s + ' horizontalCentered="1"';
if poVertCentered in sheet.PageLayout.Options then
s := s + ' verticalCentered="1"';
if s <> '' then
AppendToStream(AStream,