From f2323fdf82c25540c4f3a9089e44557152f1dc11 Mon Sep 17 00:00:00 2001 From: wp_xxyyzz Date: Mon, 23 Oct 2023 18:21:54 +0000 Subject: [PATCH] fpspreadsheet: Build styles from some chart properties git-svn-id: https://svn.code.sf.net/p/lazarus-ccr/svn@8975 8e941d3f-bd1b-0410-a28a-d453659cc2b4 --- .../examples/other/chart/write_chart_demo.lpr | 25 +- .../fpspreadsheet/source/common/fpschart.pas | 150 ++--- .../source/common/fpschartstyles.pas | 545 ++++++++++++++++-- .../source/common/fpsopendocument.pas | 289 ++++++++-- 4 files changed, 798 insertions(+), 211 deletions(-) diff --git a/components/fpspreadsheet/examples/other/chart/write_chart_demo.lpr b/components/fpspreadsheet/examples/other/chart/write_chart_demo.lpr index 08eb4f392..1bd9d870c 100644 --- a/components/fpspreadsheet/examples/other/chart/write_chart_demo.lpr +++ b/components/fpspreadsheet/examples/other/chart/write_chart_demo.lpr @@ -47,6 +47,21 @@ begin ch.PlotArea.Background.Style := fsSolidFill; ch.PlotArea.Background.FgColor := $F0F0F0; {$ENDIF} + ch.XAxis.ShowLabels := true; + ch.XAxis.LabelFont.Size := 8; + ch.XAxis.LabelFont.Color := scRed; + ch.XAxis.AxisLine.Color := scRed; + ch.XAxis.CaptionFont.Color := scRed; + ch.XAxis.CaptionFont.Size := 12; + + ch.YAxis.ShowLabels := true; + ch.YAxis.LabelFont.Size := 8; + ch.YAxis.LabelFont.Color := scBlue; + ch.YAxis.AxisLine.Color := scBlue; + ch.YAxis.CaptionFont.Color := scBlue; + ch.YAxis.CaptionFont.Size := 12; + ch.YAxis.LabelRotation := 90; + ch.YAxis.CaptionRotation := 90; ch.Title.Caption := 'HALLO'; ch.Title.Visible := true; @@ -54,8 +69,8 @@ begin ch.SubTitle.Caption := 'hallo'; ch.SubTitle.Visible := true; - ch.YAxis.ShowMajorGridLines := true; - ch.YAxis.ShowMinorGridLines := true; + ch.YAxis.MajorGridLines.Style := clsSolid; + ch.YAxis.MinorGridLines.Style := clsSolid; // 2nd sheet sh2 := b.AddWorksheet('test2'); @@ -84,8 +99,10 @@ begin ch.Title.Visible := true; ch.SubTitle.Caption := 'hallo'; ch.Subtitle.Visible := true; - ch.XAxis.ShowMajorGridLines := true; - ch.XAxis.ShowMinorGridLines := true; + ch.XAxis.MajorGridLines.Style := clsNoLine; + ch.XAxis.MinorGridLines.Style := clsNoLine; + ch.YAxis.MajorGridLines.Style := clsNoLine; + ch.YAxis.MinorGridLines.Style := clsNoLine; b.WriteToFile('test.xlsx', true); // Excel fails to open the file b.WriteToFile('test.ods', true); diff --git a/components/fpspreadsheet/source/common/fpschart.pas b/components/fpspreadsheet/source/common/fpschart.pas index 2934ff567..b9090f256 100644 --- a/components/fpspreadsheet/source/common/fpschart.pas +++ b/components/fpspreadsheet/source/common/fpschart.pas @@ -27,36 +27,17 @@ var type TsChart = class; - TsChartLineRec = record - Style: Integer; // index into chart's LineStyle list or predefined clsSolid/clsNoLine - Width: Double; // mm - Color: TsColor; // in hex: $00bbggrr, r=red, g=green, b=blue - Transparency: Double; // in percent - class operator = (A, B: TsChartLineRec): Boolean; - end; - TsChartLine = class Style: Integer; // index into chart's LineStyle list or predefined clsSolid/clsNoLine Width: Double; // mm Color: TsColor; // in hex: $00bbggrr, r=red, g=green, b=blue Transparency: Double; // in percent - procedure FromRecord(const ALine: TsChartLineRec); - function ToRecord: TsChartLineRec; - end; - - TsChartFillRec = record - Style: TsFillStyle; - FgColor: TsColor; - BgColor: TsColor; - class operator = (A, B: TsChartFillRec): Boolean; end; TsChartFill = class Style: TsFillStyle; FgColor: TsColor; BgColor: TsColor; - procedure FromRecord(const AFill: TsChartFillRec); - function ToRecord: TsChartFillRec; end; TsChartLineSegment = record @@ -122,7 +103,7 @@ type TsChartAxisPosition = (capStart, capEnd, capValue); TsChartType = (ctEmpty, ctBar, ctLine, ctArea, ctBarLine, ctScatter); - TsChartAxis = class(TsChartText) + TsChartAxis = class(TsChartFillElement) private FAutomaticMax: Boolean; FAutomaticMin: Boolean; @@ -132,8 +113,12 @@ type FMajorGridLines: TsChartLine; FMinorGridLines: TsChartline; FInverted: Boolean; + FCaption: String; + FCaptionFont: TsFont; + FCaptionRotation: Integer; FLabelFont: TsFont; FLabelFormat: String; + FLabelRotation: Integer; FLogarithmic: Boolean; FMajorInterval: Double; FMajorTickLines: TsChartLine; @@ -143,34 +128,35 @@ type FMinorTickLines: TsChartLine; FPosition: TsChartAxisPosition; FPositionValue: Double; - FShowMajorGridLines: Boolean; - FShowMinorGridLines: Boolean; + FShowCaption: Boolean; FShowLabels: Boolean; public constructor Create(AChart: TsChart); destructor Destroy; override; - property AutomaticMax: Boolean read FAutomaticMax write FAutomaticMax; property AutomaticMin: Boolean read FAutomaticMin write FAutomaticMin; property AutomaticMajorInterval: Boolean read FAutomaticMajorInterval write FAutomaticMajorInterval; property AutomaticMinorSteps: Boolean read FAutomaticMinorSteps write FAutomaticMinorSteps; property AxisLine: TsChartLine read FAxisLine write FAxisLine; + property Caption: String read FCaption write FCaption; + property CaptionFont: TsFont read FCaptionFont write FCaptionFont; + property CaptionRotation: Integer read FCaptionRotation write FCaptionRotation; property Inverted: Boolean read FInverted write FInverted; property LabelFont: TsFont read FLabelFont write FLabelFont; property LabelFormat: String read FLabelFormat write FLabelFormat; + property LabelRotation: Integer read FLabelRotation write FLabelRotation; property Logarithmic: Boolean read FLogarithmic write FLogarithmic; property MajorGridLines: TsChartLine read FMajorGridLines write FMajorGridLines; property MajorInterval: Double read FMajorInterval write FMajorInterval; property MajorTickLines: TsChartLine read FMajorTickLines write FMajorTickLines; property Max: Double read FMax write FMax; property Min: Double read FMin write FMin; - property MinorGrid: TsChartLine read FMinorGridLines write FMinorGridLines; + property MinorGridLines: TsChartLine read FMinorGridLines write FMinorGridLines; property MinorSteps: Double read FMinorSteps write FMinorSteps; property MinorTickLines: TsChartLine read FMinorTickLines write FMinorTickLines; property Position: TsChartAxisPosition read FPosition write FPosition; property PositionValue: Double read FPositionValue write FPositionValue; - property ShowMajorGridLines: Boolean read FShowMajorGridLines write FShowMajorGridLines; - property ShowMinorGridLines: Boolean read FShowMinorGridLines write FShowMinorGridLines; + property ShowCaption: Boolean read FShowCaption write FShowCaption; property ShowLabels: Boolean read FShowLabels write FShowLabels; end; @@ -345,52 +331,7 @@ implementation const DEFAULT_LINE_WIDTH = 0.75; // pts - -{ TsChartLineRec } -class operator TsChartLineRec.= (A, B: TsChartLineRec): Boolean; -begin - Result := (A.Style = B.Style) and (A.Width = B.Width) and - (A.Color = B.Color) and (A.Transparency = B.Transparency); -end; - -{ TsChartLine } -procedure TsChartLine.FromRecord(const ALine: TsChartLineRec); -begin - Style := ALine.Style; - Width := ALine.Width; - Color := ALine.Color; - Transparency := ALine.Transparency; -end; - -function TsChartLine.ToRecord: TsChartLineRec; -begin - Result.Style := Style; - Result.Width := Width; - Result.Color := Color; - Result.Transparency := Transparency; -end; - -{ TsChartFillRec } -class operator TsChartFillRec.= (A, B: TsChartFillRec): Boolean; -begin - Result := (A.Style = B.Style) and (A.FgColor = B.FgColor) and (A.BgColor = B.BgColor); -end; - -{ TsChartFill } -procedure TsChartFill.FromRecord(const AFill: TsChartFillRec); -begin - Style := AFill.Style; - FgColor := AFill.FgColor; - BgColor := AFill.BgColor; -end; - -function TsChartFill.ToRecord: TsChartFillRec; -begin - Result.Style := Style; - Result.BgColor := BgColor; - Result.FgColor := FgColor; -end; - + DEFAULT_FONT = 'Arial'; { TsChartLineStyle } @@ -476,8 +417,8 @@ begin inherited Create(AChart); FShowCaption := true; FFont := TsFont.Create; - FFont.FontName := ''; // replace by workbook's default font - FFont.Size := 0; // replace by workbook's default font size + FFont.FontName := DEFAULT_FONT; + FFont.Size := 10; FFont.Style := []; FFont.Color := scBlack; end; @@ -498,12 +439,22 @@ begin FAutomaticMajorInterval := true; FAutomaticMinorSteps := true; + FCaptionFont := TsFont.Create; + FCaptionFont.FontName := DEFAULT_FONT; + FCaptionFont.Size := 10; + FCaptionFont.Style := []; + FCaptionFont.Color := scBlack; + FLabelFont := TsFont.Create; - FLabelFont.FontName := ''; // replace by workbook's default font - FLabelFont.Size := 0; // Replace by workbook's default font size + FLabelFont.FontName := DEFAULT_FONT; + FLabelFont.Size := 9; FLabelFont.Style := []; FLabelFont.Color := scBlack; + FCaptionRotation := 0; + FLabelRotation := 0; + + FShowCaption := true; FShowLabels := true; FAxisLine := TsChartLine.Create; @@ -540,41 +491,10 @@ begin FMajorTickLines.Free; FAxisLine.Free; FLabelFont.Free; + FCaptionFont.Free; inherited; end; - (* -{ Determines how many labels are provided in the CategoryLabelRange. } -function TsChartAxis.GetCategoryCount: Integer; -begin - if CategoriesInCol then - Result := FLabelRange.Col2 - FLabelRange.Col1 + 1 - else - if CategoriesInCol then - Result := FLabelRange.Row2 - FLabelRange.Row1 + 1 - else - Result := 0; -end; -{ Returns true when the axis owns its own category labels. Otherwise labels - are taken from the series } -function TsChartAxis.HasCategoryLabels: Boolean; -begin - Result := CategoriesInCol or CategoriesInRow; -end; - -{ Determines whether the axis labels are taken from columns (true) or rows (false) } -function TsChartAxis.CategoriesInCol: Boolean; -begin - Result := (FCategoryLabelRange.Row1 <> FCategoryLabelRange.Row2) and - (FCategoryLabelRange.Col1 = FCategoryLabelRange.Col2); -end; - -function TsChartAxis.CategoriesInRow: Boolean; -begin - Result := (FCategoryLabelRange.Col1 <> FCategoryLabelRange.Col2) and - (FCategoryLabelRange.Row1 = FCategoryLabelRange.Row2); -end; - *) { TsChartSeries } @@ -763,31 +683,29 @@ begin FXAxis := TsChartAxis.Create(self); FXAxis.Caption := 'x axis'; + FXAxis.CaptionFont.Style := [fssBold]; FXAxis.LabelFont.Size := 9; - FXAxis.Font.Size := 10; - FXAxis.Font.Style := [fssBold]; FXAxis.Position := capStart; FX2Axis := TsChartAxis.Create(self); FX2Axis.Caption := 'Secondary x axis'; + FX2Axis.CaptionFont.Style := [fssBold]; FX2Axis.LabelFont.Size := 9; - FX2Axis.Font.Size := 10; - FX2Axis.Font.Style := [fssBold]; FX2Axis.Visible := false; FX2Axis.Position := capEnd; FYAxis := TsChartAxis.Create(self); FYAxis.Caption := 'y axis'; + FYAxis.CaptionFont.Style := [fssBold]; + FYAxis.CaptionRotation := 90; FYAxis.LabelFont.Size := 9; - FYAxis.Font.Size := 10; - FYAxis.Font.Style := [fssBold]; FYAxis.Position := capStart; FY2Axis := TsChartAxis.Create(self); FY2Axis.Caption := 'Secondary y axis'; + FY2Axis.CaptionFont.Style := [fssBold]; + FY2Axis.CaptionRotation := 90; FY2Axis.LabelFont.Size := 9; - FY2Axis.Font.Size := 10; - FY2Axis.Font.Style := [fssBold]; FY2Axis.Visible := false; FY2Axis.Position := capEnd; diff --git a/components/fpspreadsheet/source/common/fpschartstyles.pas b/components/fpspreadsheet/source/common/fpschartstyles.pas index e875b758a..4fd107944 100644 --- a/components/fpspreadsheet/source/common/fpschartstyles.pas +++ b/components/fpspreadsheet/source/common/fpschartstyles.pas @@ -1,6 +1,7 @@ unit fpsChartStyles; {$mode objfpc}{$H+} +{$modeswitch advancedrecords} interface @@ -8,92 +9,474 @@ uses Classes, SysUtils, fpsTypes, fpsChart; type - TsChartStyleType = (cstBackground, cstWall, cstFloor); + TsChartBackgroundType = (cbtBackground, cbtWall, cbtFloor); + + TsChartAxisType = (catPrimaryX, catPrimaryY, catSecondaryX, catSecondaryY); + + TsChartCaptionType = (cctTitle, cctSubtitle, + cctPrimaryX, cctPrimaryY, cctSecondaryX, cctSecondaryY); + + TsChartLineRec = record + Style: Integer; // index into chart's LineStyle list or predefined clsSolid/clsNoLine + Width: Double; // mm + Color: TsColor; // in hex: $00bbggrr, r=red, g=green, b=blue + Transparency: Double; // in percent + procedure FromLine(ALine: TsChartline); + procedure ToLine(ALine: TsChartLine); + class operator = (A, B: TsChartLineRec): Boolean; + end; + + TsChartFillRec = record + Style: TsFillStyle; + FgColor: TsColor; + BgColor: TsColor; + procedure FromFill(AFill: TsChartFill); + procedure ToFill(AFill: TsChartFill); + class operator = (A, B: TsChartFillRec): Boolean; + end; + + TsChartFontRec = record + FontName: String; + Size: Double; + Style: TsFontStyles; + Color: TsColor; + Position: TsFontPosition; + procedure FromFont(AFont: TsFont); + procedure ToFont(AFont: TsFont); + class operator = (A, B: TsChartFontRec): Boolean; + end; + + TsChartAxisRec = record + AutomaticMax: Boolean; + AutomaticMin: Boolean; + AutomaticMajorInterval: Boolean; + AutomaticMinorInterval: Boolean; + AxisLine: TsChartLineRec; + MajorGridLines: TsChartLineRec; + MinorGridLines: TsChartLineRec; + MajorTickLines: TsChartLineRec; + MinorTickLines: TsChartLineRec; + Inverted: Boolean; +// CaptionFont: TsChartFontRec; + LabelFont: TsChartFontRec; + LabelFormat: String; + LabelRotation: Integer; + Logarithmic: Boolean; + MajorInterval: Double; + MinorInterval: Double; + Position: TsChartAxisPosition; +// ShowCaption: Boolean; + ShowLabels: Boolean; + Visible: Boolean; + procedure FromAxis(Axis: TsChartAxis); + procedure ToAxis(Axis: TsChartAxis); + class operator = (A, B: TsChartAxisRec): Boolean; + end; + + TsChartCaptionRec = record + Font: TsChartFontRec; + Rotation: Integer; + Visible: Boolean; + procedure FromChart(AChart: TsChart; AType: TsChartCaptionType); + procedure ToChart(AChart: TsChart; AType: TsChartCaptionType); + class operator = (A, B: TsChartCaptionRec): Boolean; + end; + + {----------------------------------------------------------------------------} TsChartStyle = class - private - FStyleType: TsChartStyleType; public - constructor Create(AStyleType: TsChartStyleType); virtual; procedure ApplyToChart(AChart: TsChart); virtual; abstract; procedure ExtractFromChart(AChart: TsChart); virtual; abstract; - property StyleType: TsChartStyleType read FStyleType; end; TsChartBackgroundStyle = class(TsChartStyle) private + FBackgroundType: TsChartBackgroundType; FBackground: TsChartFillRec; FBorder: TsChartLineRec; public + constructor Create(AType: TsChartBackgroundType); procedure ApplyToChart(AChart: TsChart); override; procedure ExtractFromChart(AChart: TsChart); override; + property BackgroundType: TsChartBackgroundType read FBackgroundType write FBackgroundType; + property Background: TsChartFillRec read FBackground; property Border: TsChartLineRec read FBorder; end; + TsChartAxisStyle = class(TsChartStyle) + private + FAxis: TsChartAxisRec; + FAxisType: TsChartAxisType; + public + constructor Create(AType: TsChartAxisType); + procedure ApplyToChart(AChart: TsChart); override; + procedure ExtractFromChart(AChart: TsChart); override; + + property Axis: TsChartAxisRec read FAxis write FAxis; + property AxisType: TsChartAxisType read FAxisType write FAxisType; + end; + + TsChartCaptionStyle = class(TsChartStyle) + private + FCaption: TsChartCaptionRec; + FCaptionType: TsChartCaptionType; + public + constructor Create(AType: TsChartCaptionType); + procedure ApplyToChart(AChart: TsChart); override; + procedure ExtractFromChart(AChart: TsChart); override; + + property Caption: TsChartCaptionRec read FCaption write FCaption; + property CaptionType: TsChartCaptionType read FCaptionType write FCaptionType; + end; + + { ---------------------------------------------------------------------------} + TsChartStyleList = class(TFPList) protected public destructor Destroy; override; - procedure AddChartBackgroundStyle(AChart: TsChart; AStyleType: TsChartStyleType); + procedure AddChartAxisStyle(AChart: TsChart; AType: TsChartAxisType); + procedure AddChartBackgroundStyle(AChart: TsChart; AType: TsChartBackgroundType); + procedure AddChartCaptionStyle(AChart: TsChart; AType: TsChartCaptionType); procedure Clear; - function FindChartBackgroundStyle(AChart: TsChart; AStyleType: TsChartStyleType): Integer; + function FindChartAxisStyle(AChart: TsChart; AType: TsChartAxisType): Integer; + function FindChartBackgroundStyle(AChart: TsChart; AType: TsChartBackgroundType): Integer; + function FindChartCaptionStyle(AChart: TsChart; AType: TsChartCaptionType): Integer; end; implementation -{ TsChartStyle } +{==============================================================================} +{ Style records } +{==============================================================================} -constructor TsChartStyle.Create(AStyleType: TsChartStyleType); +{ TsFontRec } +procedure TsChartFontRec.FromFont(AFont: TsFont); begin - FStyleType := AStyleType; + FontName := AFont.FontName; + Size := AFont.Size; + Style := AFont.Style; + Color := AFont.Color; + Position := AFont.Position; end; +procedure TsChartFontRec.ToFont(AFont: TsFont); +begin + AFont.FontName := FontName; + AFont.Size := Size; + AFont.Style := Style; + AFont.Color := Color; + AFont.Position := Position; +end; + +class operator TsChartFontRec.= (A, B: TsChartFontRec): Boolean; +begin + Result := (A.FontName = B.FontName) and (A.Size = B.Size) and + (A.Style = B.Style) and (A.Color = B.Color) and + (A.Position = B.Position); +end; + +{ TsChartLineRec } +procedure TsChartLineRec.FromLine(ALine: TsChartLine); +begin + Style := ALine.Style; + Width := ALine.Width; + Color := ALine.Color; + Transparency := ALine.Transparency; +end; + +procedure TsChartLineRec.ToLine(ALine: TsChartLine); +begin + ALine.Style := Style; + ALine.Width := Width; + ALine.Color := Color; + ALine.Transparency := Transparency; +end; + +class operator TsChartLineRec.= (A, B: TsChartLineRec): Boolean; +begin + Result := (A.Style = B.Style) and (A.Width = B.Width) and + (A.Color = B.Color) and (A.Transparency = B.Transparency); +end; + +{ TsChartFillRec } +procedure TsChartFillRec.FromFill(AFill: TsChartFill); +begin + Style := AFill.Style; + FgColor := AFill.FgColor; + BgColor := AFill.BgColor; +end; + +procedure TsChartFillRec.ToFill(AFill: TsChartFill); +begin + AFill.Style := Style; + AFill.FgColor := FgColor; + AFill.BgColor := BgColor; +end; + +class operator TsChartFillRec.= (A, B: TsChartFillRec): Boolean; +begin + Result := (A.Style = B.Style) and (A.FgColor = B.FgColor) and (A.BgColor = B.BgColor); +end; + +{ TsChartAxisRec } +procedure TsChartAxisRec.FromAxis(Axis: TsChartAxis); +begin + AutomaticMax := Axis.AutomaticMax; + AutomaticMin := Axis.AutomaticMin; + AutomaticMajorInterval := Axis.AutomaticMajorInterval; + AutomaticMinorInterval := Axis.AutomaticMinorSteps; + AxisLine.FromLine(Axis.AxisLine); + MajorGridLines.FromLine(Axis.MajorGridLines); + MinorGridLines.FromLine(Axis.MinorGridLines); + MajorTickLines.FromLine(Axis.MajorTickLines); + MinorTickLines.FromLine(Axis.MinorTickLines); + Inverted := Axis.Inverted; +// CaptionFont.FromFont(Axis.Font); + LabelFont.FromFont(Axis.LabelFont); + LabelFormat := Axis.LabelFormat; + LabelRotation := Axis.LabelRotation; + Logarithmic := Axis.Logarithmic; + MajorInterval := Axis.MajorInterval; + MinorInterval := Axis.MinorSteps; + Position := Axis.Position; +// ShowCaption := Axis.ShowCaption; + ShowLabels := Axis.ShowLabels; + Visible := Axis.Visible; +end; + +procedure TsChartAxisRec.ToAxis(Axis: TsChartAxis); +begin + Axis.AutomaticMax := AutomaticMax; + Axis.AutomaticMin := AutomaticMin; + Axis.AutomaticMajorInterval := AutomaticMajorInterval; + Axis.AutomaticMinorSteps := AutomaticMinorInterval; + AxisLine.ToLine(Axis.AxisLine); + MajorGridLines.ToLine(Axis.MajorGridLines); + MinorGridLines.ToLine(Axis.MinorGridLines); + MajorTickLines.ToLine(Axis.MajorTickLines); + MinorTickLines.ToLine(Axis.MinorTickLines); + Axis.Inverted := Inverted; +// CaptionFont.ToFont(Axis.Font); + LabelFont.ToFont(Axis.LabelFont); + Axis.LabelFormat := LabelFormat; + Axis.LabelRotation := LabelRotation; + Axis.Logarithmic := Logarithmic; + Axis.MajorInterval := MajorInterval; + Axis.MinorSteps := MinorInterval; + Axis.Position := Position; +// Axis.ShowCaption := ShowCaption; + Axis.Visible := Visible; + Axis.ShowLabels := ShowLabels; +end; + +class operator TsChartAxisRec.= (A, B: TsChartAxisRec): Boolean; +begin + Result := (A.AutomaticMax = B.AutomaticMax) and (A.AutomaticMin = B.AutomaticMin) and + (A.AutomaticMajorInterval = B.AutomaticMajorInterval) and + (A.AutomaticMinorInterval = B.AutomaticMinorInterval) and + (A.AxisLine = B.AxisLine) and + (A.MajorGridLines = B.MajorGridLines) and + (A.MinorGridLines = B.MinorGridLines) and + (A.MajorTickLines = B.MajorTickLines) and + (A.MinorTickLines = B.MinorTickLines) and + (A.Inverted = B.Inverted) and +// (A.CaptionFont = B.CaptionFont) and + (A.LabelFont = B.LabelFont) and + (A.LabelFormat = B.LabelFormat) and + (A.LabelRotation = B.LabelRotation) and + (A.Logarithmic = B.Logarithmic) and + (A.MajorInterval = B.MajorInterval) and + (A.MinorInterval = B.MinorInterval) and + (A.Position = B.Position) and +// (A.ShowCaption = B.ShowCaption) and + (A.ShowLabels = B.ShowLabels) and + (A.Visible = B.Visible); +end; + +{ TsChartCaptionRec } + +procedure TsChartCaptionRec.FromChart(AChart: TsChart; AType: TsChartCaptionType); +begin + case AType of + cctTitle: + begin + Font.FromFont(AChart.Title.Font); + Visible := AChart.Title.ShowCaption; + end; + cctSubtitle: + begin + Font.FromFont(AChart.Subtitle.Font); + Visible := AChart.Subtitle.ShowCaption; + end; + cctPrimaryX: + begin + Font.FromFont(AChart.XAxis.CaptionFont); + Visible := AChart.XAxis.ShowCaption; + end; + cctPrimaryY: + begin + Font.FromFont(AChart.YAxis.CaptionFont); + Visible := AChart.YAxis.ShowCaption; + end; + cctSecondaryX: + begin + Font.FromFont(AChart.X2Axis.CaptionFont); + Visible := AChart.X2Axis.ShowCaption; + end; + cctSecondaryY: + begin + Font.FromFont(AChart.Y2Axis.CaptionFont); + Visible := AChart.Y2Axis.ShowCaption; + end; + end; +end; + +procedure TsChartCaptionRec.ToChart(AChart: TsChart; AType: TsChartCaptionType); +begin + case AType of + cctTitle: + begin + Font.ToFont(AChart.Title.Font); + AChart.Title.ShowCaption := Visible; + end; + cctSubtitle: + begin + Font.ToFont(AChart.Subtitle.Font); + AChart.Subtitle.ShowCaption := Visible; + end; + cctPrimaryX: + begin + Font.ToFont(AChart.XAxis.CaptionFont); + AChart.XAxis.ShowCaption := Visible; + end; + cctPrimaryY: + begin + Font.ToFont(AChart.YAxis.CaptionFont); + AChart.YAxis.ShowCaption := Visible; + end; + cctSecondaryX: + begin + Font.ToFont(AChart.X2Axis.CaptionFont); + AChart.X2Axis.ShowCaption := Visible; + end; + cctSecondaryY: + begin + Font.ToFont(AChart.Y2Axis.CaptionFont); + AChart.Y2Axis.ShowCaption := Visible; + end; + end; +end; + +class operator TsChartCaptionRec.= (A, B: TsChartCaptionRec): Boolean; +begin + Result := (A.Font = B.Font) and (A.Visible = B.Visible); +end; + + { TsChartBackgroundstyle } +constructor TsChartBackgroundStyle.Create(AType: TsChartBackgroundType); +begin + inherited Create; + FBackgroundType := AType; +end; + procedure TsChartBackgroundStyle.ApplyToChart(AChart: TsChart); begin - case FStyleType of - cstBackground: + case FBackgroundType of + cbtBackground: begin - AChart.Background.FromRecord(FBackground); - AChart.Border.FromRecord(FBorder); + FBackground.ToFill(AChart.Background); + FBorder.ToLine(AChart.Border); end; - cstWall: + cbtWall: begin - AChart.PlotArea.Background.FromRecord(FBackground); - AChart.PlotArea.Border.FromRecord(FBorder); + FBackground.ToFill(AChart.PlotArea.Background); + FBorder.ToLine(AChart.PlotArea.Border); end; - cstFloor: + cbtFloor: begin - AChart.Floor.Background.FromRecord(FBackGround); - AChart.Floor.Border.FromRecord(FBorder); + FBackground.ToFill(AChart.Floor.Background); + FBorder.ToLine(AChart.Floor.Border); end; + else + raise Exception.Create('Unknown background style.'); end; end; procedure TsChartBackgroundStyle.ExtractFromChart(AChart: TsChart); begin - case FStyleType of - cstBackground: + case FBackgroundType of + cbtBackground: begin - FBackground := AChart.Background.ToRecord; - FBorder := AChart.Border.ToRecord; + FBackground.FromFill(AChart.Background); + FBorder.FromLine(AChart.Border); end; - cstWall: + cbtWall: begin - FBackground := AChart.PlotArea.Background.ToRecord; - FBorder := AChart.PlotArea.Border.ToRecord; + FBackground.FromFill(AChart.PlotArea.Background); + FBorder.FromLine(AChart.PlotArea.Border); end; - cstFloor: + cbtFloor: begin - FBackground := AChart.Floor.Background.ToRecord; - FBorder := AChart.Floor.Border.ToRecord; + FBackground.FromFill(AChart.Floor.Background); + FBorder.FromLine(AChart.Floor.Border); end; end; end; +{ TsChartAxisStyle } + +constructor TsChartAxisStyle.Create(AType: TsChartAxisType); +begin + inherited Create; + FAxisType := AType; +end; + +procedure TsChartAxisStyle.ApplyToChart(AChart: TsChart); +begin + case FAxisType of + catPrimaryX: Axis.ToAxis(AChart.XAxis); + catPrimaryY: Axis.ToAxis(AChart.YAxis); + catSecondaryX: Axis.ToAxis(AChart.X2Axis); + catSecondaryY: Axis.ToAxis(AChart.Y2Axis); + end; +end; + +procedure TsChartAxisStyle.ExtractFromChart(AChart: TsChart); +begin + case FAxisType of + catPrimaryX: Axis.FromAxis(AChart.XAxis); + catPrimaryY: Axis.FromAxis(AChart.YAxis); + catSecondaryX: Axis.FromAxis(AChart.X2Axis); + catSecondaryY: Axis.FromAxis(AChart.Y2Axis); + end; +end; + + +{ TsChartCaptionStyle } + +constructor TsChartCaptionStyle.Create(AType: TsChartCaptionType); +begin + inherited Create; + FCaptionType := AType; +end; + +procedure TsChartCaptionStyle.ApplyToChart(AChart: TsChart); +begin + Caption.ToChart(AChart, FCaptionType); +end; + +procedure TsChartCaptionStyle.ExtractFromChart(AChart: TsChart); +begin + Caption.FromChart(AChart, FCaptionType); +end; + + { TsChartStyleList } destructor TsChartStyleList.Destroy; @@ -102,12 +485,28 @@ begin inherited; end; +{ Adds the style of the specified axis type in the given chart as new style to + the style list. But only if the same style does not yet exist. } +procedure TsChartStyleList.AddChartAxisStyle(AChart: TsChart; + AType: TsChartAxisType); +begin + FindChartAxisStyle(AChart, AType); +end; + +{ Adds the style of the specified caption in the given chart as new style to + the style list. But only if the same style does not yet exist. } +procedure TsChartStyleList.AddChartCaptionStyle(AChart: TsChart; + AType: TsChartCaptionType); +begin + FindChartCaptionStyle(AChart, AType); +end; + { Adds the style of the specified type in the given chart as new style to the style list. But only if the same style does not yet exist. } procedure TsChartStyleList.AddChartBackgroundStyle(AChart: TsChart; - AStyleType: TsChartStyleType); + AType: TsChartBackgroundType); begin - FindChartBackgroundStyle(AChart, AStyleType); + FindChartBackgroundStyle(AChart, AType); end; procedure TsChartStyleList.Clear; @@ -119,26 +518,25 @@ begin inherited Clear; end; -{ Searches whether the background style of the specified chart is already in the +{ Searches whether the style of the specified axis is already in the list. If not, a new style is created and added. - The type of the requested background must be provided as parameter. + The type of the requested axis must be provided as parameter. Returns the index of the style. } -function TsChartStyleList.FindChartBackgroundStyle(AChart: TsChart; - AStyleType: TsChartStyleType): Integer; +function TsChartStyleList.FindChartAxisStyle(AChart: TsChart; + AType: TsChartAxisType): Integer; var - newStyle, style: TsChartBackgroundStyle; + newStyle, style: TsChartAxisStyle; i: Integer; begin Result := -1; - newStyle := TsChartBackgroundStyle.Create(AStyleType); + newStyle := TsChartAxisStyle.Create(AType); newStyle.ExtractFromChart(AChart); for i := 0 to Count-1 do begin - if (TsChartStyle(Items[i]) is TsChartBackgroundStyle) and - (TsChartStyle(Items[i]).StyleType = AStyleType) then + if (TsChartStyle(Items[i]) is TsChartAxisStyle) then begin - style := TsChartBackgroundStyle(Items[i]); - if (style.Background = newStyle.Background) then + style := TsChartAxisStyle(Items[i]); + if (style.AxisType = AType) and (style.Axis = newStyle.Axis) then begin Result := i; break; @@ -151,5 +549,68 @@ begin newStyle.Free; end; +{ Searches whether the background style of the specified chart is already in the + list. If not, a new style is created and added. + The type of the requested background must be provided as parameter. + Returns the index of the style. } +function TsChartStyleList.FindChartBackgroundStyle(AChart: TsChart; + AType: TsChartBackgroundType): Integer; +var + newStyle, style: TsChartBackgroundStyle; + i: Integer; +begin + Result := -1; + newStyle := TsChartBackgroundStyle.Create(AType); + newStyle.ExtractFromChart(AChart); + for i := 0 to Count-1 do + begin + if (TsChartStyle(Items[i]) is TsChartBackgroundStyle) then + begin + style := TsChartBackgroundStyle(Items[i]); + if (style.BackgroundType = AType) and (style.Background = newStyle.Background) then + begin + Result := i; + break; + end; + end; + end; + if Result = -1 then + Result := Add(newStyle) + else + newStyle.Free; +end; + +{ Searches whether the style of the specified caption is already in the + list. If not, a new style is created and added. + The type of the requested axis must be provided as parameter. + Returns the index of the style. } +function TsChartStyleList.FindChartCaptionStyle(AChart: TsChart; + AType: TsChartCaptionType): Integer; +var + newStyle, style: TsChartCaptionStyle; + i: Integer; +begin + Result := -1; + newStyle := TsChartCaptionStyle.Create(AType); + newStyle.ExtractFromChart(AChart); + for i := 0 to Count-1 do + begin + if (TsChartStyle(Items[i]) is TsChartCaptionStyle) then + begin + style := TsChartCaptionStyle(Items[i]); + if {(style.AxisType = AType) and} (style.Caption = newStyle.Caption) then + begin + Result := i; + break; + end; + end; + end; + if Result = -1 then + Result := Add(newStyle) + else + newStyle.Free; +end; + + end. diff --git a/components/fpspreadsheet/source/common/fpsopendocument.pas b/components/fpspreadsheet/source/common/fpsopendocument.pas index 5fc8bffc6..001a37a0f 100644 --- a/components/fpspreadsheet/source/common/fpsopendocument.pas +++ b/components/fpspreadsheet/source/common/fpsopendocument.pas @@ -286,7 +286,9 @@ type function WriteWordwrapStyleXMLAsString(const AFormat: TsCellFormat): String; { Chart support } + function GetChartAxisStyleAsXML(AChart: TsChart; AStyleIndex: Integer; AIndent: Integer): String; function GetChartBackgroundStyleAsXML(AChart: TsChart; AStyleIndex: Integer; AIndent: Integer): String; + function GetChartCaptionStyleAsXML(AChart: TsChart; AStyleIndex: Integer; AIndent: Integer): String; procedure PrepareChartTable(AChart: TsChart; AWorksheet: TsBasicWorksheet); procedure WriteChart(AStream: TStream; AChart: TsChart); @@ -5887,10 +5889,23 @@ begin for i := 0 to book.GetChartCount-1 do begin chart := book.GetChartByIndex(i); - styles.AddChartBackGroundStyle(chart, cstBackground); - styles.AddChartBackgroundStyle(chart, cstWall); - styles.AddChartBackgroundStyle(chart, cstFloor); - end; + + styles.AddChartBackGroundStyle(chart, cbtBackground); + styles.AddChartBackgroundStyle(chart, cbtWall); + styles.AddChartBackgroundStyle(chart, cbtFloor); + + styles.AddChartAxisStyle(chart, catPrimaryX); + styles.AddChartAxisStyle(chart, catPrimaryY); + styles.AddChartAxisStyle(chart, catSecondaryX); + styles.AddChartAxisStyle(chart, catSecondaryY); + + styles.AddChartCaptionStyle(chart, cctPrimaryX); + styles.AddChartCaptionStyle(chart, cctPrimaryY); + styles.AddChartCaptionStyle(chart, cctSecondaryX); + styles.AddChartCaptionStyle(chart, cctSecondaryY); + styles.AddChartCaptionStyle(chart, cctTitle); + styles.AddChartCaptionStyle(chart, cctSubTitle); + end; end; procedure TsSpreadOpenDocWriter.ListAllColumnStyles; @@ -6778,44 +6793,55 @@ var axis: TsChartAxis; series: TsChartSeries; sheet: TsWorksheet; + styles: TsChartStyleList; refStr: String; - styleID, titleStyleID: Integer; - majorGridStyleID: Integer = 8; - minorGridstyleID: Integer = 9; + styleIdx, titleStyleIdx: Integer; +// styleID, titleStyleID: Integer; + majorGridStyleID: Integer = 800; + minorGridstyleID: Integer = 900; r1, c1, r2, c2: Cardinal; begin ind := DupeString(' ', AIndent); sheet := TsWorkbook(FWorkbook).GetWorksheetByIndex(AChart.SheetIndex); + styles := TsChartStyleList(FChartStyleList); if IsX then begin if IsPrimary then begin axis := AChart.XAxis; - styleID := 6; + styleIdx := styles.FindChartAxisStyle(AChart, catPrimaryX); + titleStyleIdx := styles.FindChartCaptionStyle(AChart, cctPrimaryX); + //styleID := 6; end else begin axis := AChart.X2Axis; - styleID := 10; + styleIdx := styles.FindChartAxisStyle(AChart, catSecondaryX); + titleStyleIdx := styles.FindChartCaptionStyle(AChart, cctSecondaryX); + //styleID := 10; end; - titleStyleID := 7; + //titleStyleID := 7; end else begin if IsPrimary then begin axis := AChart.YAxis; - styleID := 11; + styleIdx := styles.FindChartAxisStyle(AChart, catPrimaryY); + titleStyleIdx := styles.FindChartCaptionStyle(AChart, cctPrimaryY); + //styleID := 11; end else begin axis := AChart.Y2Axis; - styleID := 12; + styleIdx := styles.FindChartAxisStyle(AChart, catSecondaryY); + titleStyleIdx := styles.FindChartCaptionStyle(AChart, cctSecondaryY); + //styleID := 12; end; - titleStyleID := 12; + //titleStyleID := 12; end; AppendToStream(AStream, Format( ind + '' + LE, - [ AXIS_ID[IsX], AXIS_LEVEL[IsPrimary], AXIS_ID[IsX], styleID ] + [ AXIS_ID[IsX], AXIS_LEVEL[IsPrimary], AXIS_ID[IsX], styleIdx + 1 ] )); if IsX and (not AChart.IsScatterChart) and (AChart.Series.Count > 0) then @@ -6832,21 +6858,21 @@ begin )); end; - if axis.Caption <> '' then + if axis.ShowCaption and (axis.Caption <> '') then AppendToStream(AStream, Format( ind + ' ' + LE + ind + ' %s' + LE + ind + ' ' + LE, - [ titleStyleID, axis.Caption ] + [ titleStyleIdx + 1, axis.Caption ] )); - if axis.ShowMajorGridLines then + if axis.MajorGridLines.Style <> clsNoLine then AppendToStream(AStream, Format( ind + ' ' + LE, [ majorGridStyleID ] )); - if axis.ShowMinorGridLines then + if axis.MinorGridLines.Style <> clsNoLine then AppendToStream(AStream, Format( ind + ' ' + LE, [ minorGridStyleID ] @@ -6869,7 +6895,7 @@ begin if chartClass <> '' then chartClass := ' chart:class="chart:' + chartClass + '"'; - idx := TsChartStyleList(FChartStyleList).FindChartBackgroundStyle(AChart, cstBackground); + idx := TsChartStyleList(FChartStyleList).FindChartBackgroundStyle(AChart, cbtBackground); AppendToStream(AStream, Format( ' ' + LE + @@ -6962,7 +6988,7 @@ begin rfAllRel, false); count := series.YRange.Row2 - series.YRange.Row1 + 1; - seriesStyleID := 14 + ASeriesIndex; + seriesStyleID := (14 + ASeriesIndex) * 100; AppendToStream(AStream, Format( ind + ' 0 then + styleRotationAngle := 'style:rotation-ange="' + IntToStr(style.Axis.LabelRotation) + '" '; + + strokeColor := 'svg:stroke-color="' + ColorToHTMLColorStr(style.Axis.AxisLine.Color) + '" '; + + fontSize := Format('fo:font-size="%.1fpt" style:font-size-asian="%.1fpt" style:font-size-complex="%.1fpt" ', + [style.Axis.LabelFont.Size, style.Axis.LabelFont.Size, style.Axis.LabelFont.Size], + FPointSeparatorSettings + ); + fontColor := 'fo:color="' + ColorToHTMLColorStr(style.Axis.LabelFont.Color) + '" '; + + (* + + + + + *) + ind := DupeString(' ', AIndent); + Result := Format( + ind + '' + LE + + ind + ' ' + LE + + ind + ' ' + LE + + ind + ' ' + LE + + ind + '' + LE, + [ AStyleIndex + 1, + // chart-properties + displayLabels, logarithmic, styleRotationAngle, + // graphic-properties + strokeColor, + // text-properties + fontSize, fontColor + ] + ); +end; + function TsSpreadOpenDocWriter.GetChartBackgroundStyleAsXML( AChart: TsChart; AStyleIndex: Integer; AIndent: Integer): String; var @@ -7018,7 +7119,56 @@ begin ind + '' + LE + ind + ' ' + LE + ind + '' + LE, - [ AStyleIndex+1, drawStroke, strokeColor, drawFill, drawFillColor ] + [ AStyleIndex+1, + drawStroke, strokeColor, drawFill, drawFillColor ] + ); +end; + +{ + + + + +} +function TsSpreadOpenDocWriter.GetChartCaptionStyleAsXML(AChart: TsChart; + AStyleIndex: Integer; AIndent: Integer): String; +var + style: TsChartCaptionStyle; + ind: String; + fontSize: String = ''; + fontColor: String = ''; + styleRotationAngle: String = ''; +begin + Result := ''; + + if AStyleIndex = -1 then + exit; + + style := TsChartCaptionStyle(FChartStyleList[AStyleIndex]); + + if not style.Caption.Visible then + exit; + + if style.Caption.Rotation <> 0 then + styleRotationAngle := Format('style:rotation-angle="%d" ', [style.Caption.Rotation]); + + fontSize := Format('fo:font-size="%.1fpt" style:font-size-asian="%.1fpt" style:font-size-complex="%.1fpt" ', + [ style.Caption.Font.Size, style.Caption.Font.Size, style.Caption.Font.Size ], + FPointSeparatorSettings + ); + fontColor := Format('fo:color="%s" ', [ColorToHTMLColorStr(style.Caption.Font.Color)]); + + ind := DupeString(' ', AIndent); + Result := Format( + ind + '' + LE + + ind + ' ' + LE + + ind + ' ' + LE + + ind + '' + LE, + [AStyleIndex + 1, + // chart-properties + styleRotationAngle, + // text-properties + fontSize, fontColor ] ); end; @@ -7030,10 +7180,32 @@ var backGrStyleIdx: Integer; wallStyleIdx: Integer; floorStyleIdx: Integer; + xAxisStyleIdx: Integer; + yAxisStyleIdx: Integer; + x2AxisStyleIdx: Integer; + y2AxisStyleIdx: Integer; + xAxisCaptionStyleIdx: Integer; + yAxisCaptionStyleIdx: Integer; + x2AxisCaptionStyleIdx: Integer; + y2AxisCaptionStyleIdx: Integer; + titleCaptionStyleIdx: Integer; + subtitleCaptionStyleIdx: Integer; begin - backGrStyleIdx := TsChartStyleList(FChartStyleList).FindChartBackgroundStyle(AChart, cstBackground); - wallStyleIdx := TsChartStyleList(FChartStyleList).FindChartBackgroundStyle(AChart, cstWall); - floorStyleIdx := TsChartStyleList(FChartStyleList).FindChartBackgroundStyle(AChart, cstFloor); + backGrStyleIdx := TsChartStyleList(FChartStyleList).FindChartBackgroundStyle(AChart, cbtBackground); + wallStyleIdx := TsChartStyleList(FChartStyleList).FindChartBackgroundStyle(AChart, cbtWall); + floorStyleIdx := TsChartStyleList(FChartStyleList).FindChartBackgroundStyle(AChart, cbtFloor); + + xAxisStyleIdx := TsChartStyleList(FChartStyleList).FindChartAxisStyle(AChart, catPrimaryX); + yAxisStyleIdx := TsChartStyleList(FChartStyleList).FindChartAxisStyle(AChart, catPrimaryY); + x2AxisStyleIdx := TsChartStyleList(FChartStyleList).FindChartAxisStyle(AChart, catSecondaryX); + y2AxisStyleIdx := TsChartStyleList(FChartStyleList).FindChartAxisStyle(AChart, catSecondaryY); + + xAxisCaptionStyleIdx := TsChartStyleList(FChartStyleList).FindChartCaptionStyle(AChart, cctPrimaryX); + yAxisCaptionStyleIdx := TsChartStyleList(FChartStyleList).FindChartCaptionStyle(AChart, cctPrimaryY); + x2AxisCaptionStyleIdx := TsChartStyleList(FChartStyleList).FindChartCaptionStyle(AChart, cctSecondaryX); + y2AxisCaptionStyleIdx := TsChartStyleList(FChartStyleList).FindChartCaptionStyle(AChart, cctSecondaryY); + titleCaptionStyleIdx := TsChartStyleList(FChartStyleList).FindChartCaptionStyle(AChart, cctTitle); + subtitleCaptionStyleIdx := TsChartStyleList(FChartStyleList).FindChartCaptionStyle(AChart, cctSubtitle); ind := DupeString(' ', AIndent); @@ -7063,7 +7235,7 @@ begin ind + ' ' + LE + // ch 4: style for element - ind + ' ' + LE + + ind + ' ' + LE + ind + ' ' + LE + ind + ' ' + LE + @@ -7071,7 +7243,7 @@ begin ind + ' ' + LE + // ch5: style for element - ind + ' ' + LE + + ind + ' ' + LE + ind + ' ' + LE + - ind + ' ' + + ind + ' ' + LE + { ind + ' ' + LE + @@ -7092,7 +7264,9 @@ begin ind + ' ' + LE + } - // ch6: style for first element, primary x axis + // Style for first element, primary x axis + GetChartAxisStyleAsXML(AChart, xAxisStyleIdx, AIndent + 2) + + { ind + ' ' + LE + ind + ' ' + LE + ind + ' ' + LE + ind + ' ' + LE + + } // ch7: style for title at horizontal axes + GetChartCaptionStyleAsXML(AChart, xAxisCaptionStyleIdx, AIndent + 2) + + { ind + ' ' + LE + ind + ' ' + LE + ind + ' ' + LE + ind + ' ' + LE + - + } // ch8: style for major grid (all axes) - ind + ' ' + LE + + ind + ' ' + LE + ind + ' ' + LE + ind + ' ' + LE + // ch9: style for minor grid (all axes) - ind + ' ' + LE + + ind + ' ' + LE + ind + ' ' + LE + ind + ' ' + LE + // ch10: style for second element, secondary x axis - ind + ' ' + LE + + GetChartAxisStyleAsXML(AChart, x2AxisStyleIdx, AIndent + 2) + + GetChartCaptionStyleAsXML(AChart, x2AxisCaptionStyleIdx, AIndent + 2) + + { + ind + ' ' + LE + ind + ' ' + LE + ind + ' ' + LE + ind + ' ' + LE + - + } // ch11: style for third element: primary y axis - ind + ' ' + LE + + GetChartAxisStyleAsXML(AChart, yAxisStyleIdx, AIndent + 2) + + { + ind + ' ' + LE + ind + ' ' + LE + ind + ' ' + LE + ind + ' ' + LE + + } // ch12: style for vertical axis title (both y and y2 axis) - ind + ' ' + LE + + GetChartCaptionStyleAsXML(AChart, yAxisCaptionStyleIdx, AIndent + 2) + + + ind + ' ' + LE + ind + ' ' + LE + ind + ' ' + LE + ind + ' ' + // ch13: style for fourth element: secondary y axis - ind + ' ' + LE + + GetChartAxisStyleAsXML(AChart, y2AxisStyleIdx, AIndent + 2) + + GetChartCaptionStyleAsXML(AChart, y2AxisCaptionStyleIdx, AIndent + 2) + + { + ind + ' ' + LE + ind + ' ' + LE + ind + ' ' + LE + ind + ' ' + LE + + } + + // ch14: style for frist series - this is for a line series - ind + ' ' + LE + + ind + ' ' + LE + ind + ' ' + LE + + ind + ' ' + LE + ind + ' ' + LE + ind + ' ' + LE + ind + ' ' + LE + ind + ' ' + LE + // ch16: style for third series (bar series, here) - ind + ' ' + LE + + ind + ' ' + LE + ind + ' ' + LE + ind + ' ' + LE + ind + ' ' + LE + ind + ' ' + LE + // ch17: style for 4th series (bar series, here) - ind + ' ' + LE + + ind + ' ' + LE + ind + ' ' + LE + ind + ' ' + LE + ind + ' ' + LE + ind + ' ' + LE + // ch18: style for 5th series (bar series, here) - ind + ' ' + LE + + ind + ' ' + LE + ind + ' ' + LE + ind + ' ' + LE + ind + ' ' + LE + ind + ' ' + LE + // ch19: style for 6th series (bar series, here) - ind + ' ' + LE + + ind + ' ' + LE + ind + ' ' + LE + ind + ' ' + LE + ind + ' ' + LE + ind + ' ' + LE + // ch20: style for 7th series (bar series, here) - ind + ' ' + LE + + ind + ' ' + LE + ind + ' ' + LE + ind + ' ' + LE + ind + ' ' + LE + ind + ' ' + LE + // ch21: style for 8th series (bar series, here) - ind + ' ' + LE + + ind + ' ' + LE + ind + ' ' + LE + ind + ' ' + LE + ind + ' ' + LE + @@ -7574,7 +7765,7 @@ begin if IsSubTitle then begin elementName := 'subtitle'; - titleStyleID := 3; + titleStyleID := 300; cap := AChart.SubTitle.Caption; end else begin