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

View File

@ -1593,7 +1593,9 @@ const
ABorderStyle.LineStyle := lsDotted;
// 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
begin
if (ADrawDirection = drawVert) and (ACoord = ARect.Right-1) and width3
@ -1607,7 +1609,8 @@ const
dec(ARect.Bottom);
end;
end;
if ABorderStyle.LineStyle in [lsMedium, lsThick] then
if ABorderStyle.LineStyle in [lsMedium, lsMediumDash, lsMediumDashDot,
lsMediumDashDotDot, lsSlantDashDot, lsThick] then
begin
if (ADrawDirection = drawHor) then
dec(ARect.Right, 1)
@ -1617,7 +1620,8 @@ const
// Painting
case ABorderStyle.LineStyle of
lsThin, lsMedium, lsThick, lsDotted, lsDashed:
lsThin, lsMedium, lsThick, lsDotted, lsDashed, lsDashDot, lsDashDotDot,
lsMediumDash, lsMediumDashDot, lsMediumDashDotDot, lsSlantDashDot:
case ADrawDirection of
drawHor : Canvas.Line(ARect.Left, ACoord, ARect.Right, ACoord);
drawVert : Canvas.Line(ACoord, ARect.Top, ACoord, ARect.Bottom);

View File

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

View File

@ -1549,34 +1549,34 @@ begin
if dw <> 0 then
begin
Include(fmt.Border, cbWest);
fmt.BorderStyles[cbWest].LineStyle := TsLineStyle(dw);
fmt.BorderStyles[cbWest].LineStyle := TsLineStyle(dw-1);
Include(fmt.UsedFormattingFields, uffBorder);
end;
dw := rec.Border_BkGr1 and MASK_XF_BORDER_RIGHT;
if dw <> 0 then
begin
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);
end;
dw := rec.Border_BkGr1 and MASK_XF_BORDER_TOP;
if dw <> 0 then
begin
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);
end;
dw := rec.Border_BkGr1 and MASK_XF_BORDER_BOTTOM;
if dw <> 0 then
begin
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);
end;
dw := rec.Border_BkGr2 and MASK_XF_BORDER_DIAGONAL;
if dw <> 0 then
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;
if rec.Border_BkGr1 and MASK_XF_BORDER_SHOW_DIAGONAL_UP <> 0 then
Include(fmt.Border, cbDiagUp);