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
This commit is contained in:
wp_xxyyzz
2019-07-27 16:19:41 +00:00
parent 65a63b37d9
commit a66ccaf563
2 changed files with 18 additions and 7 deletions

View File

@ -97,7 +97,7 @@ type
FRichTextFontList: TFPList; FRichTextFontList: TFPList;
FRepeatedCols: TsRowColRange; FRepeatedCols: TsRowColRange;
FRepeatedRows: TsRowColRange; FRepeatedRows: TsRowColRange;
procedure ApplyColWidths; procedure ApplyColData;
procedure ApplyStyleToCell(ACell: PCell; AStyleIndex: Integer); procedure ApplyStyleToCell(ACell: PCell; AStyleIndex: Integer);
function ApplyStyleToCell(ACell: PCell; AStyleName: String): Boolean; function ApplyStyleToCell(ACell: PCell; AStyleName: String): Boolean;
function ApplyTableStyle(ASheet: TsBasicWorksheet; function ApplyTableStyle(ASheet: TsBasicWorksheet;
@ -1110,9 +1110,10 @@ begin
FNumFormatList.Add('N0:'); FNumFormatList.Add('N0:');
end; end;
{ Creates for each non-default column width stored internally in FColumnList { Creates for each non-default column width as well as non-default column
a TCol record in the current worksheet. } property stored internally in FColumnList a TCol record in the
procedure TsSpreadOpenDocReader.ApplyColWidths; current worksheet. }
procedure TsSpreadOpenDocReader.ApplyColData;
var var
colIndex: Integer; colIndex: Integer;
colData: TColumnData; colData: TColumnData;
@ -1128,6 +1129,15 @@ begin
sheet := FWorksheet as TsWorksheet; sheet := FWorksheet as TsWorksheet;
defColWidth := sheet.ReadDefaultColWidth(FWorkbook.Units); defColWidth := sheet.ReadDefaultColWidth(FWorkbook.Units);
lastOccCol := sheet.GetLastOccupiedColIndex; 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 for i:=0 to FColumnList.Count-1 do
begin begin
colData := TColumnData(FColumnList[i]); colData := TColumnData(FColumnList[i]);
@ -1149,6 +1159,7 @@ begin
else else
fmtIndex := 0; fmtIndex := 0;
} }
// Prepare column record for the worksheet // Prepare column record for the worksheet
colWidth := colStyle.ColWidth; // is already in workbook units colWidth := colStyle.ColWidth; // is already in workbook units
if SameValue(colWidth, defColWidth, COLWIDTH_EPS) then if SameValue(colWidth, defColWidth, COLWIDTH_EPS) then
@ -2651,7 +2662,7 @@ begin
// Apply table style // Apply table style
ApplyTableStyle(FWorksheet, tablestylename); ApplyTableStyle(FWorksheet, tablestylename);
// Handle columns // Handle columns
ApplyColWidths; ApplyColData;
// Page layout // Page layout
FixCols(FWorksheet); FixCols(FWorksheet);
FixRows(FWorksheet); FixRows(FWorksheet);

View File

@ -479,10 +479,10 @@ begin
// to the DefaultRowHeight ... // to the DefaultRowHeight ...
sheet.WriteDefaultRowHeight(h, FWorkbook.Units); 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 for r := sheet.Rows.Count-1 downto 0 do begin
lRow := PRow(sheet.Rows[r]); 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); sheet.RemoveRow(lRow^.Row);
end; end;
end; end;