You've already forked lazarus-ccr
fpspreadsheet: Read the background color of ods files. Background color of ods files is displayed in fpsGrid. Fix border partially not showing.
git-svn-id: https://svn.code.sf.net/p/lazarus-ccr/svn@3107 8e941d3f-bd1b-0410-a28a-d453659cc2b4
This commit is contained in:
@ -278,7 +278,7 @@ begin
|
|||||||
Exclude(cell^.UsedFormattingFields, uffBorder);
|
Exclude(cell^.UsedFormattingFields, uffBorder);
|
||||||
|
|
||||||
// Background color
|
// Background color
|
||||||
if styleData.BackgroundColor <> 0 then begin
|
if styleData.BackgroundColor <> scNotDefined then begin
|
||||||
Include(cell^.UsedFormattingFields, uffBackgroundColor);
|
Include(cell^.UsedFormattingFields, uffBackgroundColor);
|
||||||
cell^.BackgroundColor := styleData.BackgroundColor;
|
cell^.BackgroundColor := styleData.BackgroundColor;
|
||||||
end;
|
end;
|
||||||
@ -377,6 +377,7 @@ var
|
|||||||
BodyNode, SpreadSheetNode, TableNode, RowNode, CellNode : TDOMNode;
|
BodyNode, SpreadSheetNode, TableNode, RowNode, CellNode : TDOMNode;
|
||||||
StylesNode: TDOMNode;
|
StylesNode: TDOMNode;
|
||||||
ParamRowsRepeated, ParamColsRepeated, ParamValueType, ParamFormula : string;
|
ParamRowsRepeated, ParamColsRepeated, ParamValueType, ParamFormula : string;
|
||||||
|
TableStyleName: String;
|
||||||
RowsCount, ColsCount : integer;
|
RowsCount, ColsCount : integer;
|
||||||
begin
|
begin
|
||||||
//unzip content.xml into AFileName path
|
//unzip content.xml into AFileName path
|
||||||
@ -437,6 +438,7 @@ begin
|
|||||||
// select this cell value's type
|
// select this cell value's type
|
||||||
ParamValueType := GetAttrValue(CellNode,'office:value-type');
|
ParamValueType := GetAttrValue(CellNode,'office:value-type');
|
||||||
ParamFormula := GetAttrValue(CellNode,'table:formula');
|
ParamFormula := GetAttrValue(CellNode,'table:formula');
|
||||||
|
TableStyleName := GetAttrValue(CellNode, 'table:style-name');
|
||||||
|
|
||||||
if ParamValueType = 'string' then
|
if ParamValueType = 'string' then
|
||||||
ReadLabel(Row, Col, CellNode)
|
ReadLabel(Row, Col, CellNode)
|
||||||
@ -444,7 +446,7 @@ begin
|
|||||||
ReadNumber(Row, Col, CellNode)
|
ReadNumber(Row, Col, CellNode)
|
||||||
else if (ParamValueType = 'date') or (ParamValueType = 'time') then
|
else if (ParamValueType = 'date') or (ParamValueType = 'time') then
|
||||||
ReadDate(Row, Col, CellNode)
|
ReadDate(Row, Col, CellNode)
|
||||||
else if (ParamValueType = '') then
|
else if (ParamValueType = '') and (TableStyleName <> '') then
|
||||||
ReadBlank(Row, Col, CellNode)
|
ReadBlank(Row, Col, CellNode)
|
||||||
else if ParamFormula <> '' then
|
else if ParamFormula <> '' then
|
||||||
ReadLabel(Row, Col, CellNode);
|
ReadLabel(Row, Col, CellNode);
|
||||||
@ -479,9 +481,11 @@ end;
|
|||||||
|
|
||||||
procedure TsSpreadOpenDocReader.ReadLabel(ARow: Word; ACol: Word; ACellNode: TDOMNode);
|
procedure TsSpreadOpenDocReader.ReadLabel(ARow: Word; ACol: Word; ACellNode: TDOMNode);
|
||||||
var
|
var
|
||||||
|
cellText: String;
|
||||||
styleName: String;
|
styleName: String;
|
||||||
begin
|
begin
|
||||||
FWorkSheet.WriteUTF8Text(ARow, ACol, UTF8Encode(ACellNode.TextContent));
|
cellText := UTF8Encode(ACellNode.TextContent);
|
||||||
|
FWorkSheet.WriteUTF8Text(ARow, ACol, cellText);
|
||||||
|
|
||||||
styleName := GetAttrValue(ACellNode, 'table:style-name');
|
styleName := GetAttrValue(ACellNode, 'table:style-name');
|
||||||
ApplyStyleToCell(ARow, ACol, stylename);
|
ApplyStyleToCell(ARow, ACol, stylename);
|
||||||
@ -759,6 +763,7 @@ var
|
|||||||
wrap: Boolean;
|
wrap: Boolean;
|
||||||
borders: TsCellBorders;
|
borders: TsCellBorders;
|
||||||
borderStyles: TsCellBorderStyles;
|
borderStyles: TsCellBorderStyles;
|
||||||
|
bkClr: DWord;
|
||||||
s: String;
|
s: String;
|
||||||
|
|
||||||
procedure SetBorderStyle(ABorder: TsCellBorder; AStyleValue: String);
|
procedure SetBorderStyle(ABorder: TsCellBorder; AStyleValue: String);
|
||||||
@ -778,7 +783,7 @@ var
|
|||||||
L.StrictDelimiter := true;
|
L.StrictDelimiter := true;
|
||||||
L.DelimitedText := AStyleValue;
|
L.DelimitedText := AStyleValue;
|
||||||
wid := 0;
|
wid := 0;
|
||||||
rgb := 0;
|
rgb := DWord(-1);
|
||||||
linestyle := '';
|
linestyle := '';
|
||||||
for i:=0 to L.Count-1 do begin
|
for i:=0 to L.Count-1 do begin
|
||||||
s := L[i];
|
s := L[i];
|
||||||
@ -817,7 +822,8 @@ var
|
|||||||
else
|
else
|
||||||
if (linestyle = 'fine-dashed') then
|
if (linestyle = 'fine-dashed') then
|
||||||
borderStyles[ABorder].LineStyle := lsDotted;
|
borderStyles[ABorder].LineStyle := lsDotted;
|
||||||
borderStyles[ABorder].Color := Workbook.AddColorToPalette(LongRGBToExcelPhysical(rgb));
|
borderStyles[ABorder].Color := IfThen(rgb = DWord(-1), scBlack,
|
||||||
|
Workbook.AddColorToPalette(LongRGBToExcelPhysical(rgb)));
|
||||||
finally
|
finally
|
||||||
L.Free;
|
L.Free;
|
||||||
end;
|
end;
|
||||||
@ -845,10 +851,17 @@ begin
|
|||||||
|
|
||||||
borders := [];
|
borders := [];
|
||||||
wrap := false;
|
wrap := false;
|
||||||
|
bkClr := DWord(-1);
|
||||||
|
|
||||||
styleChildNode := styleNode.FirstChild;
|
styleChildNode := styleNode.FirstChild;
|
||||||
while Assigned(styleChildNode) do begin
|
while Assigned(styleChildNode) do begin
|
||||||
if styleChildNode.NodeName = 'style:table-cell-properties' then begin
|
if styleChildNode.NodeName = 'style:table-cell-properties' then begin
|
||||||
|
// Background color
|
||||||
|
s := GetAttrValue(styleChildNode, 'fo:background-color');
|
||||||
|
if s <> '' then begin
|
||||||
|
if s[1] = '#' then s[1] := '$';
|
||||||
|
bkClr := StrToInt(s);
|
||||||
|
end;
|
||||||
// Borders
|
// Borders
|
||||||
s := GetAttrValue(styleChildNode, 'fo:border');
|
s := GetAttrValue(styleChildNode, 'fo:border');
|
||||||
if (s <>'') then begin
|
if (s <>'') then begin
|
||||||
@ -899,7 +912,8 @@ begin
|
|||||||
style.TextRotation := trHorizontal;
|
style.TextRotation := trHorizontal;
|
||||||
style.Borders := borders;
|
style.Borders := borders;
|
||||||
style.BorderStyles := borderStyles;
|
style.BorderStyles := borderStyles;
|
||||||
style.BackgroundColor := scNotDefined;
|
style.BackgroundColor := IfThen(bkClr = DWord(-1), scNotDefined,
|
||||||
|
Workbook.AddColorToPalette(LongRGBToExcelPhysical(bkClr)));
|
||||||
|
|
||||||
styleIndex := FStyleList.Add(style);
|
styleIndex := FStyleList.Add(style);
|
||||||
end;
|
end;
|
||||||
|
Reference in New Issue
Block a user