fpspreadsheet: Support reading and writing of all additional linetypes of biff8 and ooxml.

git-svn-id: https://svn.code.sf.net/p/lazarus-ccr/svn@4229 8e941d3f-bd1b-0410-a28a-d453659cc2b4
This commit is contained in:
wp_xxyyzz
2015-07-30 19:08:39 +00:00
parent b6a8d809bb
commit 9c0df635f8
4 changed files with 41 additions and 23 deletions

View File

@ -291,12 +291,12 @@ const
// lsThin, lsMedium, lsDashed, lsDotted, lsThick, lsDouble, lsHair // lsThin, lsMedium, lsDashed, lsDotted, lsThick, lsDouble, lsHair
// lsMediumDash, lsDashDot, lsMediumDashDot, lsDashDotDot, lsMediumDashDotDot, lsSlantDashDot // lsMediumDash, lsDashDot, lsMediumDashDot, lsDashDotDot, lsMediumDashDotDot, lsSlantDashDot
BORDER_LINESTYLES: array[TsLineStyle] of string = ( BORDER_LINESTYLES: array[TsLineStyle] of string = (
'solid', 'solid', 'dashed', 'fine-dashed', 'solid', 'double', 'dotted', 'solid', 'solid', 'dashed', 'fine-dashed', 'solid', 'double-thin', 'dotted',
'dashed', 'dash-dot', 'dash-dot', 'dash-dot-dot', 'dash-dot-dot', 'slanted-dash-dot' // to be checked! 'dashed', 'dash-dot', 'dash-dot', 'dash-dot-dot', 'dash-dot-dot', 'dash-dot'
); );
BORDER_LINEWIDTHS: array[TsLinestyle] of string = BORDER_LINEWIDTHS: array[TsLinestyle] of string =
('0.002cm', '2pt', '0.002cm', '0.002cm', '3pt', '0.039cm', '0.002cm', ('0.74pt', '1.76pt', '0.74pt', '0.74pt', '2.49pt', '0.74pt', '0.74pt',
'2pt', '0.002cm', '2pt', '0.002cm', '2pt', '2pt'); '1.76pt', '0.74pt', '1.76pt', '0.74pt', '1.76pt', '1.76pt');
FALSE_TRUE: Array[boolean] of String = ('false', 'true'); FALSE_TRUE: Array[boolean] of String = ('false', 'true');
@ -3118,7 +3118,9 @@ var
for i:=0 to L.Count-1 do for i:=0 to L.Count-1 do
begin begin
s := L[i]; s := L[i];
if (s = 'solid') or (s = 'dashed') or (s = 'fine-dashed') or (s = 'dotted') or (s = 'double') if (s = 'solid') or (s = 'dashed') or (s = 'fine-dashed') or
(s = 'dotted') or (s = 'double') or (s = 'dash-dot') or
(s = 'dash-dot-dot') or (s = 'double-thin')
then begin then begin
linestyle := s; linestyle := s;
continue; continue;
@ -3146,19 +3148,31 @@ var
fmt.BorderStyles[ABorder].LineStyle := lsThin; fmt.BorderStyles[ABorder].LineStyle := lsThin;
if (linestyle = 'solid') then if (linestyle = 'solid') then
begin begin
if (wid >= 3 - EPS) then fmt.BorderStyles[ABorder].LineStyle := lsThick if (wid >= 2.4 - EPS) then fmt.BorderStyles[ABorder].LineStyle := lsThick
else if (wid >= 2 - EPS) then fmt.BorderStyles[ABorder].LineStyle := lsMedium else if (wid >= 1.7 - EPS) then fmt.BorderStyles[ABorder].LineStyle := lsMedium
end else end else
if (linestyle = 'dotted') then if (linestyle = 'dotted') then
fmt.BorderStyles[ABorder].LineStyle := lsHair fmt.BorderStyles[ABorder].LineStyle := lsHair
else else
if (linestyle = 'dashed') then if (linestyle = 'dashed') then
fmt.BorderStyles[ABorder].LineStyle := lsDashed begin
else if (wid >= 1.7 - EPS) then fmt.BorderStyles[ABorder].LineStyle := lsMediumDash
else fmt.BorderStyles[ABorder].LineStyle := lsDashed
end else
if (linestyle = 'dash-dot') then
begin
if (wid >= 1.7 - EPS) then fmt.BorderStyles[ABorder].LineStyle := lsMediumDashDot
else fmt.BorderStyles[ABorder].LineStyle := lsDashDot
end else
if (linestyle = 'dash-dot-dot') then
begin
if (wid >= 1.7 - EPS) then fmt.BorderStyles[ABorder].LineStyle := lsMediumDashDotDot
else fmt.BorderStyles[ABorder].LineStyle := lsDashDotDot
end else
if (linestyle = 'fine-dashed') then if (linestyle = 'fine-dashed') then
fmt.BorderStyles[ABorder].LineStyle := lsDotted fmt.BorderStyles[ABorder].LineStyle := lsDotted
else else
if (linestyle = 'double') then if (linestyle = 'double') or (linestyle = 'double-thin') then
fmt.BorderStyles[ABorder].LineStyle := lsDouble; fmt.BorderStyles[ABorder].LineStyle := lsDouble;
fmt.BorderStyles[ABorder].Color := IfThen(rgb = scNotDefined, scBlack, rgb); fmt.BorderStyles[ABorder].Color := IfThen(rgb = scNotDefined, scBlack, rgb);
finally finally

View File

@ -1593,7 +1593,9 @@ const
ABorderStyle.LineStyle := lsDotted; ABorderStyle.LineStyle := lsDotted;
// Tuning the rectangle to avoid issues at the grid borders and to get nice corners // Tuning the rectangle to avoid issues at the grid borders and to get nice corners
if (ABorderStyle.LineStyle in [lsMedium, lsThick, lsDouble]) then begin if (ABorderStyle.LineStyle in [lsMedium, lsMediumDash, lsMediumDashDot,
lsMediumDashDotDot, lsSlantDashDot, lsThick, lsDouble]) then
begin
if ACol = ColCount-1 then if ACol = ColCount-1 then
begin begin
if (ADrawDirection = drawVert) and (ACoord = ARect.Right-1) and width3 if (ADrawDirection = drawVert) and (ACoord = ARect.Right-1) and width3
@ -1607,7 +1609,8 @@ const
dec(ARect.Bottom); dec(ARect.Bottom);
end; end;
end; end;
if ABorderStyle.LineStyle in [lsMedium, lsThick] then if ABorderStyle.LineStyle in [lsMedium, lsMediumDash, lsMediumDashDot,
lsMediumDashDotDot, lsSlantDashDot, lsThick] then
begin begin
if (ADrawDirection = drawHor) then if (ADrawDirection = drawHor) then
dec(ARect.Right, 1) dec(ARect.Right, 1)
@ -1617,7 +1620,8 @@ const
// Painting // Painting
case ABorderStyle.LineStyle of case ABorderStyle.LineStyle of
lsThin, lsMedium, lsThick, lsDotted, lsDashed: lsThin, lsMedium, lsThick, lsDotted, lsDashed, lsDashDot, lsDashDotDot,
lsMediumDash, lsMediumDashDot, lsMediumDashDotDot, lsSlantDashDot:
case ADrawDirection of case ADrawDirection of
drawHor : Canvas.Line(ARect.Left, ACoord, ARect.Right, ACoord); drawHor : Canvas.Line(ARect.Left, ACoord, ARect.Right, ACoord);
drawVert : Canvas.Line(ACoord, ARect.Top, ACoord, ARect.Bottom); drawVert : Canvas.Line(ACoord, ARect.Top, ACoord, ARect.Bottom);

View File

@ -1657,12 +1657,12 @@ var
lsDashed, lsDotted, lsDashed, lsDotted,
lsThick, lsDouble, lsThick, lsDouble,
lsHair : Result := ALineStyle; lsHair : Result := ALineStyle;
lsMediumDash : Result := lsMedium; lsMediumDash : Result := lsDashed;
lsDashDot : Result := lsDashed; lsDashDot : Result := lsDotted;
lsMediumDashDot : Result := lsMedium; lsMediumDashDot : Result := lsDashed;
lsDashDotDot : Result := lsDotted; lsDashDotDot : Result := lsDotted;
lsMediumDashDotDot : Result := lsMedium; lsMediumDashDotDot : Result := lsDashed;
lsSlantDashDot : Result := lsMedium; lsSlantDashDot : Result := lsDashed;
else raise Exception.Create('[TsSpreadBIFF5Writer.WriteXF] Linestyle not supported.'); else raise Exception.Create('[TsSpreadBIFF5Writer.WriteXF] Linestyle not supported.');
end; end;
end; end;

View File

@ -1549,34 +1549,34 @@ begin
if dw <> 0 then if dw <> 0 then
begin begin
Include(fmt.Border, cbWest); Include(fmt.Border, cbWest);
fmt.BorderStyles[cbWest].LineStyle := TsLineStyle(dw); fmt.BorderStyles[cbWest].LineStyle := TsLineStyle(dw-1);
Include(fmt.UsedFormattingFields, uffBorder); Include(fmt.UsedFormattingFields, uffBorder);
end; end;
dw := rec.Border_BkGr1 and MASK_XF_BORDER_RIGHT; dw := rec.Border_BkGr1 and MASK_XF_BORDER_RIGHT;
if dw <> 0 then if dw <> 0 then
begin begin
Include(fmt.Border, cbEast); Include(fmt.Border, cbEast);
fmt.BorderStyles[cbEast].LineStyle := TsLineStyle(dw shr 4); fmt.BorderStyles[cbEast].LineStyle := TsLineStyle((dw shr 4)-1);
Include(fmt.UsedFormattingFields, uffBorder); Include(fmt.UsedFormattingFields, uffBorder);
end; end;
dw := rec.Border_BkGr1 and MASK_XF_BORDER_TOP; dw := rec.Border_BkGr1 and MASK_XF_BORDER_TOP;
if dw <> 0 then if dw <> 0 then
begin begin
Include(fmt.Border, cbNorth); Include(fmt.Border, cbNorth);
fmt.BorderStyles[cbNorth].LineStyle := TsLineStyle(dw shr 8); fmt.BorderStyles[cbNorth].LineStyle := TsLineStyle((dw shr 8)-1);
Include(fmt.UsedFormattingFields, uffBorder); Include(fmt.UsedFormattingFields, uffBorder);
end; end;
dw := rec.Border_BkGr1 and MASK_XF_BORDER_BOTTOM; dw := rec.Border_BkGr1 and MASK_XF_BORDER_BOTTOM;
if dw <> 0 then if dw <> 0 then
begin begin
Include(fmt.Border, cbSouth); Include(fmt.Border, cbSouth);
fmt.BorderStyles[cbSouth].LineStyle := TsLineStyle(dw shr 12); fmt.BorderStyles[cbSouth].LineStyle := TsLineStyle((dw shr 12)-1);
Include(fmt.UsedFormattingFields, uffBorder); Include(fmt.UsedFormattingFields, uffBorder);
end; end;
dw := rec.Border_BkGr2 and MASK_XF_BORDER_DIAGONAL; dw := rec.Border_BkGr2 and MASK_XF_BORDER_DIAGONAL;
if dw <> 0 then if dw <> 0 then
begin begin
fmt.BorderStyles[cbDiagUp].LineStyle := TsLineStyle(dw shr 21); fmt.BorderStyles[cbDiagUp].LineStyle := TsLineStyle((dw shr 21)-1);
fmt.BorderStyles[cbDiagDown].LineStyle := fmt.BorderStyles[cbDiagUp].LineStyle; fmt.BorderStyles[cbDiagDown].LineStyle := fmt.BorderStyles[cbDiagUp].LineStyle;
if rec.Border_BkGr1 and MASK_XF_BORDER_SHOW_DIAGONAL_UP <> 0 then if rec.Border_BkGr1 and MASK_XF_BORDER_SHOW_DIAGONAL_UP <> 0 then
Include(fmt.Border, cbDiagUp); Include(fmt.Border, cbDiagUp);