From c4724b28de497ad5e3325bcb2d339be66cdc5851 Mon Sep 17 00:00:00 2001 From: wp_xxyyzz Date: Sat, 3 May 2014 17:30:29 +0000 Subject: [PATCH] fpspreadsheet: Cell border linestyles supported by BIFF8, but not supported by fpspreadsheet, are replaced by similar linestyles now. git-svn-id: https://svn.code.sf.net/p/lazarus-ccr/svn@3000 8e941d3f-bd1b-0410-a28a-d453659cc2b4 --- components/fpspreadsheet/xlsbiff8.pas | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/components/fpspreadsheet/xlsbiff8.pas b/components/fpspreadsheet/xlsbiff8.pas index 764c73585..2ce2b978a 100755 --- a/components/fpspreadsheet/xlsbiff8.pas +++ b/components/fpspreadsheet/xlsbiff8.pas @@ -1977,6 +1977,17 @@ begin end; procedure TsSpreadBIFF8Reader.ReadXF(const AStream: TStream); + + function FixLineStyle(dw: DWord): TsLineStyle; + { Not all line styles defined in BIFF8 are supported by fpspreadsheet. } + begin + case dw of + $01..$06: result := TsLineStyle(dw-1); + $07: Result := lsDotted; + else Result := lsDashed; + end; + end; + type TXFRecord = packed record // see p. 224 FontIndex: Word; // Offset 0, Size 2 @@ -2040,22 +2051,22 @@ begin dw := xf.Border_Background_1 and MASK_XF_BORDER_LEFT; if dw <> 0 then begin Include(lData.Borders, cbWest); - lData.BorderStyles[cbWest].LineStyle := TsLineStyle(dw - 1); + lData.BorderStyles[cbWest].LineStyle := FixLineStyle(dw); end; dw := xf.Border_Background_1 and MASK_XF_BORDER_RIGHT; if dw <> 0 then begin Include(lData.Borders, cbEast); - lData.BorderStyles[cbEast].LineStyle := TsLineStyle(dw shr 4 - 1); + lData.BorderStyles[cbEast].LineStyle := FixLineStyle(dw shr 4); end; dw := xf.Border_Background_1 and MASK_XF_BORDER_TOP; if dw <> 0 then begin Include(lData.Borders, cbNorth); - lData.BorderStyles[cbNorth].LineStyle := TsLineStyle(dw shr 8 - 1); + lData.BorderStyles[cbNorth].LineStyle := FixLineStyle(dw shr 8); end; dw := xf.Border_Background_1 and MASK_XF_BORDER_BOTTOM; if dw <> 0 then begin Include(lData.Borders, cbSouth); - lData.BorderStyles[cbSouth].LineStyle := TsLineStyle(dw shr 12 - 1); + lData.BorderStyles[cbSouth].LineStyle := FixLineStyle(dw shr 12); end; // Border line colors