You've already forked lazarus-ccr
fpspreadsheet: Fix incorrect characters in label cells read from of ods files. Partial fix of negative values forgetting the red color in case of built-in format nfCurrencyRed.
git-svn-id: https://svn.code.sf.net/p/lazarus-ccr/svn@3188 8e941d3f-bd1b-0410-a28a-d453659cc2b4
This commit is contained in:
@ -19,7 +19,7 @@ var
|
|||||||
MyDir: string;
|
MyDir: string;
|
||||||
number1, number2, number3, number4,
|
number1, number2, number3, number4,
|
||||||
number5, number6, number7, number8: Double;
|
number5, number6, number7, number8: Double;
|
||||||
row: Integer;
|
row: Integer = 7;
|
||||||
begin
|
begin
|
||||||
MyDir := ExtractFilePath(ParamStr(0));
|
MyDir := ExtractFilePath(ParamStr(0));
|
||||||
number1 := 1.23456789;
|
number1 := 1.23456789;
|
||||||
@ -36,7 +36,7 @@ begin
|
|||||||
MyWorksheet := MyWorkbook.AddWorksheet('My Worksheet');
|
MyWorksheet := MyWorkbook.AddWorksheet('My Worksheet');
|
||||||
|
|
||||||
// Write some cells
|
// Write some cells
|
||||||
//MyWorksheet.WriteNumber(0, 0, 1.0);// A1
|
MyWorksheet.WriteNumber(0, 0, 1.0);// A1
|
||||||
MyWorksheet.WriteNumber(0, 1, 2.0);// B1
|
MyWorksheet.WriteNumber(0, 1, 2.0);// B1
|
||||||
MyWorksheet.WriteNumber(0, 2, 3.0);// C1
|
MyWorksheet.WriteNumber(0, 2, 3.0);// C1
|
||||||
MyWorksheet.WriteNumber(0, 3, 4.0);// D1
|
MyWorksheet.WriteNumber(0, 3, 4.0);// D1
|
||||||
@ -49,7 +49,6 @@ begin
|
|||||||
MyWorksheet.WriteFont(0, 1, 'Times New Roman', 16, [], scRed);
|
MyWorksheet.WriteFont(0, 1, 'Times New Roman', 16, [], scRed);
|
||||||
|
|
||||||
// Show number formats
|
// Show number formats
|
||||||
row := 7;
|
|
||||||
MyWorksheet.WriteUTF8Text(row, 0, 'Number formats:');
|
MyWorksheet.WriteUTF8Text(row, 0, 'Number formats:');
|
||||||
inc(row);
|
inc(row);
|
||||||
MyWorksheet.WriteUTF8Text(row, 0, 'nfGeneral');
|
MyWorksheet.WriteUTF8Text(row, 0, 'nfGeneral');
|
||||||
|
@ -1186,8 +1186,24 @@ procedure TsSpreadOpenDocReader.ReadLabel(ARow: Word; ACol: Word; ACellNode: TDO
|
|||||||
var
|
var
|
||||||
cellText: String;
|
cellText: String;
|
||||||
styleName: String;
|
styleName: String;
|
||||||
|
childnode: TDOMNode;
|
||||||
begin
|
begin
|
||||||
cellText := ACellNode.TextContent;
|
// cellText := ACellNode.TextContent;
|
||||||
|
{ We were forced to activate PreserveWhiteSpace in the DOMParser in order to
|
||||||
|
catch the spaces inserted in formatting texts. However, this adds lots of
|
||||||
|
garbage into the cellText if is is read by means of above statement. Done
|
||||||
|
like below is much better: }
|
||||||
|
cellText := '';
|
||||||
|
childnode := ACellNode.FirstChild;
|
||||||
|
while Assigned(childnode) do begin
|
||||||
|
case childnode.NodeType of
|
||||||
|
TEXT_NODE, COMMENT_NODE, PROCESSING_INSTRUCTION_NODE: ; // ignored
|
||||||
|
else
|
||||||
|
cellText := cellText + childnode.TextContent;
|
||||||
|
end;
|
||||||
|
childnode := childnode.NextSibling;
|
||||||
|
end;
|
||||||
|
|
||||||
FWorkSheet.WriteUTF8Text(ARow, ACol, cellText);
|
FWorkSheet.WriteUTF8Text(ARow, ACol, cellText);
|
||||||
|
|
||||||
styleName := GetAttrValue(ACellNode, 'table:style-name');
|
styleName := GetAttrValue(ACellNode, 'table:style-name');
|
||||||
@ -1331,8 +1347,12 @@ procedure TsSpreadOpenDocReader.ReadNumFormats(AStylesNode: TDOMNode);
|
|||||||
grouping: Boolean;
|
grouping: Boolean;
|
||||||
nex: Integer;
|
nex: Integer;
|
||||||
cs: String;
|
cs: String;
|
||||||
|
color: TsColorValue;
|
||||||
|
idx: Integer;
|
||||||
|
hasColor: Boolean;
|
||||||
begin
|
begin
|
||||||
fmt := '';
|
fmt := '';
|
||||||
|
hasColor := false;
|
||||||
node := ANumFormatNode.FirstChild;
|
node := ANumFormatNode.FirstChild;
|
||||||
while Assigned(node) do begin
|
while Assigned(node) do begin
|
||||||
nodeName := node.NodeName;
|
nodeName := node.NodeName;
|
||||||
@ -1370,6 +1390,18 @@ procedure TsSpreadOpenDocReader.ReadNumFormats(AStylesNode: TDOMNode);
|
|||||||
fmt := fmt + childNode.NodeValue;
|
fmt := fmt + childNode.NodeValue;
|
||||||
childNode := childNode.NextSibling;
|
childNode := childNode.NextSibling;
|
||||||
end;
|
end;
|
||||||
|
end else
|
||||||
|
if nodeName = 'style:text-properties' then begin
|
||||||
|
s := GetAttrValue(node, 'fo:color');
|
||||||
|
color := HTMLColorStrToColor(s);
|
||||||
|
idx := FWorkbook.AddColorToPalette(color);
|
||||||
|
{
|
||||||
|
if idx < 8 then
|
||||||
|
fmt := Format('[%s]%s', [FWorkbook.GetColorName(idx), fmt])
|
||||||
|
else
|
||||||
|
fmt := Format('[Color%d]%s', [idx, fmt]);
|
||||||
|
}
|
||||||
|
hasColor := true;
|
||||||
end;
|
end;
|
||||||
node := node.NextSibling;
|
node := node.NextSibling;
|
||||||
end;
|
end;
|
||||||
@ -1380,8 +1412,9 @@ procedure TsSpreadOpenDocReader.ReadNumFormats(AStylesNode: TDOMNode);
|
|||||||
|
|
||||||
if ANumFormatNode.NodeName = 'number:percentage-style' then
|
if ANumFormatNode.NodeName = 'number:percentage-style' then
|
||||||
nf := nfPercentage
|
nf := nfPercentage
|
||||||
else if ANumFormatNode.NodeName = 'number:currency-style' then
|
else if ANumFormatNode.NodeName = 'number:currency-style' then begin
|
||||||
nf := nfCurrency;
|
if hasColor then nf := nfCurrencyRed else nf := nfCurrency;
|
||||||
|
end;
|
||||||
|
|
||||||
NumFormatList.AddFormat(ANumFormatName, fmt, nf);
|
NumFormatList.AddFormat(ANumFormatName, fmt, nf);
|
||||||
end;
|
end;
|
||||||
@ -1602,7 +1635,6 @@ begin
|
|||||||
//process each cell of the row
|
//process each cell of the row
|
||||||
cellNode := rowNode.FindNode('table:table-cell');
|
cellNode := rowNode.FindNode('table:table-cell');
|
||||||
while Assigned(cellNode) do begin
|
while Assigned(cellNode) do begin
|
||||||
|
|
||||||
// These nodes occur due to indentation spaces which are not skipped
|
// These nodes occur due to indentation spaces which are not skipped
|
||||||
// automatically any more due to PreserveWhiteSpace option applied
|
// automatically any more due to PreserveWhiteSpace option applied
|
||||||
// to ReadXMLFile
|
// to ReadXMLFile
|
||||||
|
@ -2631,7 +2631,8 @@ begin
|
|||||||
if row <> nil then
|
if row <> nil then
|
||||||
Result := row^.Height
|
Result := row^.Height
|
||||||
else
|
else
|
||||||
Result := CalcAutoRowHeight(ARow); //FWorkbook.DefaultRowHeight;
|
//Result := CalcAutoRowHeight(ARow);
|
||||||
|
Result := FWorkbook.DefaultRowHeight;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure TsWorksheet.RemoveAllRows;
|
procedure TsWorksheet.RemoveAllRows;
|
||||||
|
Reference in New Issue
Block a user