From a66ccaf563c60d170e97f4784dcde9082674527d Mon Sep 17 00:00:00 2001 From: wp_xxyyzz Date: Sat, 27 Jul 2019 16:19:41 +0000 Subject: [PATCH] fpspreadsheet: Fix remaining pagebreak fails of ODS reader. All tests passed now. git-svn-id: https://svn.code.sf.net/p/lazarus-ccr/svn@7078 8e941d3f-bd1b-0410-a28a-d453659cc2b4 --- .../source/common/fpsopendocument.pas | 21 ++++++++++++++----- .../source/common/fpsreaderwriter.pas | 4 ++-- 2 files changed, 18 insertions(+), 7 deletions(-) diff --git a/components/fpspreadsheet/source/common/fpsopendocument.pas b/components/fpspreadsheet/source/common/fpsopendocument.pas index 3981caeed..e424759d3 100644 --- a/components/fpspreadsheet/source/common/fpsopendocument.pas +++ b/components/fpspreadsheet/source/common/fpsopendocument.pas @@ -97,7 +97,7 @@ type FRichTextFontList: TFPList; FRepeatedCols: TsRowColRange; FRepeatedRows: TsRowColRange; - procedure ApplyColWidths; + procedure ApplyColData; procedure ApplyStyleToCell(ACell: PCell; AStyleIndex: Integer); function ApplyStyleToCell(ACell: PCell; AStyleName: String): Boolean; function ApplyTableStyle(ASheet: TsBasicWorksheet; @@ -1110,9 +1110,10 @@ begin FNumFormatList.Add('N0:'); end; -{ Creates for each non-default column width stored internally in FColumnList - a TCol record in the current worksheet. } -procedure TsSpreadOpenDocReader.ApplyColWidths; +{ Creates for each non-default column width as well as non-default column + property stored internally in FColumnList a TCol record in the + current worksheet. } +procedure TsSpreadOpenDocReader.ApplyColData; var colIndex: Integer; colData: TColumnData; @@ -1128,6 +1129,15 @@ begin sheet := FWorksheet as TsWorksheet; defColWidth := sheet.ReadDefaultColWidth(FWorkbook.Units); lastOccCol := sheet.GetLastOccupiedColIndex; + + for i:=0 to FColumnList.Count-1 do begin + colData := TColumnData(FColumnList[i]); + if (colData.Col > lastOccCol) then begin + if colData.Hidden or colData.PageBreak then + lastOccCol := colData.Col + end; + end; + for i:=0 to FColumnList.Count-1 do begin colData := TColumnData(FColumnList[i]); @@ -1149,6 +1159,7 @@ begin else fmtIndex := 0; } + // Prepare column record for the worksheet colWidth := colStyle.ColWidth; // is already in workbook units if SameValue(colWidth, defColWidth, COLWIDTH_EPS) then @@ -2651,7 +2662,7 @@ begin // Apply table style ApplyTableStyle(FWorksheet, tablestylename); // Handle columns - ApplyColWidths; + ApplyColData; // Page layout FixCols(FWorksheet); FixRows(FWorksheet); diff --git a/components/fpspreadsheet/source/common/fpsreaderwriter.pas b/components/fpspreadsheet/source/common/fpsreaderwriter.pas index 86215b829..98a5eb9e5 100644 --- a/components/fpspreadsheet/source/common/fpsreaderwriter.pas +++ b/components/fpspreadsheet/source/common/fpsreaderwriter.pas @@ -479,10 +479,10 @@ begin // to the DefaultRowHeight ... sheet.WriteDefaultRowHeight(h, FWorkbook.Units); - // ... and delete all visible row records with default format. + // ... and delete all visible row records with default properties. for r := sheet.Rows.Count-1 downto 0 do begin lRow := PRow(sheet.Rows[r]); - if (lRow^.FormatIndex = 0) and not (croHidden in lRow^.Options) then + if (lRow^.FormatIndex = 0) and ([croHidden, croPageBreak] * lRow^.Options = []) then sheet.RemoveRow(lRow^.Row); end; end;