You've already forked lazarus-ccr
fpspreadsheet: Fix ODS reader crashing when finding unexpected nodes among row nodes (see http://forum.lazarus.freepascal.org/index.php/topic,25624.msg157029.html#msg157029).
Fix the ODS reader detecting underlined font style for the file of this discussion. Fix incorrect row height calculation of TsWorksheetGrid introduced in the previous commit. git-svn-id: https://svn.code.sf.net/p/lazarus-ccr/svn@3544 8e941d3f-bd1b-0410-a28a-d453659cc2b4
This commit is contained in:
@@ -1161,9 +1161,11 @@ begin
|
|||||||
Include(fntStyles, fssItalic);
|
Include(fntStyles, fssItalic);
|
||||||
if GetAttrValue(ANode, 'fo:font-weight') = 'bold' then
|
if GetAttrValue(ANode, 'fo:font-weight') = 'bold' then
|
||||||
Include(fntStyles, fssBold);
|
Include(fntStyles, fssBold);
|
||||||
if GetAttrValue(ANode, 'style:text-underline-style') <> '' then
|
s := GetAttrValue(ANode, 'style:text-underline-style');
|
||||||
|
if not ((s = '') or (s = 'none')) then
|
||||||
Include(fntStyles, fssUnderline);
|
Include(fntStyles, fssUnderline);
|
||||||
if GetAttrValue(ANode, 'style:text-strike-through-style') <> '' then
|
s := GetAttrValue(ANode, 'style:text-strike-through-style');
|
||||||
|
if not ((s = '') or (s = 'none')) then
|
||||||
Include(fntStyles, fssStrikeout);
|
Include(fntStyles, fssStrikeout);
|
||||||
|
|
||||||
s := GetAttrValue(ANode, 'fo:color');
|
s := GetAttrValue(ANode, 'fo:color');
|
||||||
@@ -1782,6 +1784,7 @@ var
|
|||||||
col: Integer;
|
col: Integer;
|
||||||
cell: PCell;
|
cell: PCell;
|
||||||
cellNode, rowNode: TDOMNode;
|
cellNode, rowNode: TDOMNode;
|
||||||
|
nodeName: String;
|
||||||
paramValueType, paramFormula, tableStyleName: String;
|
paramValueType, paramFormula, tableStyleName: String;
|
||||||
paramColsSpanned, paramRowsSpanned: String;
|
paramColsSpanned, paramRowsSpanned: String;
|
||||||
paramColsRepeated, paramRowsRepeated: String;
|
paramColsRepeated, paramRowsRepeated: String;
|
||||||
@@ -1800,10 +1803,15 @@ begin
|
|||||||
|
|
||||||
rowNode := ATableNode.FindNode('table:table-row');
|
rowNode := ATableNode.FindNode('table:table-row');
|
||||||
while Assigned(rowNode) do begin
|
while Assigned(rowNode) do begin
|
||||||
// These nodes occur due to indentation spaces which are not skipped
|
nodename := rowNode.NodeName;
|
||||||
|
|
||||||
|
// Skip all non table-row nodes:
|
||||||
|
// Nodes '#text' 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
|
||||||
if rowNode.NodeName = '#text' then begin
|
// And there are other nodes like 'table:named-expression' which we don't
|
||||||
|
// need (at the moment)
|
||||||
|
if nodeName <> 'table:table-row' then begin
|
||||||
rowNode := rowNode.NextSibling;
|
rowNode := rowNode.NextSibling;
|
||||||
Continue;
|
Continue;
|
||||||
end;
|
end;
|
||||||
@@ -1811,23 +1819,27 @@ begin
|
|||||||
// Read rowstyle
|
// Read rowstyle
|
||||||
rowStyleName := GetAttrValue(rowNode, 'table:style-name');
|
rowStyleName := GetAttrValue(rowNode, 'table:style-name');
|
||||||
rowStyleIndex := FindRowStyleByName(rowStyleName);
|
rowStyleIndex := FindRowStyleByName(rowStyleName);
|
||||||
rowStyle := TRowStyleData(FRowStyleList[rowStyleIndex]);
|
if rowStyleIndex > -1 then begin // just for safety
|
||||||
rowHeight := rowStyle.RowHeight; // in mm (see ReadRowStyles)
|
rowStyle := TRowStyleData(FRowStyleList[rowStyleIndex]);
|
||||||
rowHeight := mmToPts(rowHeight) / Workbook.GetDefaultFontSize;
|
rowHeight := rowStyle.RowHeight; // in mm (see ReadRowStyles)
|
||||||
if rowHeight > ROW_HEIGHT_CORRECTION
|
rowHeight := mmToPts(rowHeight) / Workbook.GetDefaultFontSize;
|
||||||
then rowHeight := rowHeight - ROW_HEIGHT_CORRECTION // in "lines"
|
if rowHeight > ROW_HEIGHT_CORRECTION
|
||||||
else rowHeight := 0;
|
then rowHeight := rowHeight - ROW_HEIGHT_CORRECTION // in "lines"
|
||||||
autoRowHeight := rowStyle.AutoRowHeight;
|
else rowHeight := 0;
|
||||||
|
autoRowHeight := rowStyle.AutoRowHeight;
|
||||||
|
end else
|
||||||
|
autoRowHeight := true;
|
||||||
|
|
||||||
col := 0;
|
col := 0;
|
||||||
|
|
||||||
//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
|
||||||
|
nodeName := cellNode.NodeName;
|
||||||
// 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
|
||||||
if cellNode.NodeName = '#text' then begin
|
if nodeName = '#text' then begin
|
||||||
cellNode := cellNode.NextSibling;
|
cellNode := cellNode.NextSibling;
|
||||||
Continue;
|
Continue;
|
||||||
end;
|
end;
|
||||||
|
@@ -2146,12 +2146,9 @@ begin
|
|||||||
end;
|
end;
|
||||||
|
|
||||||
if FWorksheet <> nil then begin
|
if FWorksheet <> nil then begin
|
||||||
lCell := FDrawingCell;
|
|
||||||
{
|
|
||||||
r := ARow - FHeaderCount;
|
r := ARow - FHeaderCount;
|
||||||
c := ACol - FHeaderCount;
|
c := ACol - FHeaderCount;
|
||||||
lCell := FWorksheet.FindCell(r, c);
|
lCell := FWorksheet.FindCell(r, c);
|
||||||
}
|
|
||||||
if lCell <> nil then begin
|
if lCell <> nil then begin
|
||||||
Result := FWorksheet.ReadAsUTF8Text(lCell);
|
Result := FWorksheet.ReadAsUTF8Text(lCell);
|
||||||
if lCell^.TextRotation = rtStacked then begin
|
if lCell^.TextRotation = rtStacked then begin
|
||||||
|
Reference in New Issue
Block a user