You've already forked lazarus-ccr
fpspreadsheet: Add check for non-empty cells to stop removing of the dummy ods "repeated" rows.
git-svn-id: https://svn.code.sf.net/p/lazarus-ccr/svn@8821 8e941d3f-bd1b-0410-a28a-d453659cc2b4
This commit is contained in:
@ -109,6 +109,7 @@ type
|
|||||||
function FindNumFormatByName(ANumFmtName: String): Integer;
|
function FindNumFormatByName(ANumFmtName: String): Integer;
|
||||||
function FindRowStyleByName(AStyleName: String): Integer;
|
function FindRowStyleByName(AStyleName: String): Integer;
|
||||||
function FindTableStyleByName(AStyleName: String): Integer;
|
function FindTableStyleByName(AStyleName: String): Integer;
|
||||||
|
function NodeIsEmptyCell(ACellNode: TDOMNode): Boolean;
|
||||||
procedure ReadCell(ANode: TDOMNode; ARow, ACol: Integer;
|
procedure ReadCell(ANode: TDOMNode; ARow, ACol: Integer;
|
||||||
AFormatIndex: Integer; out AColsRepeated: Integer);
|
AFormatIndex: Integer; out AColsRepeated: Integer);
|
||||||
procedure ReadCellImages(ANode: TDOMNode; ARow, ACol: Cardinal);
|
procedure ReadCellImages(ANode: TDOMNode; ARow, ACol: Cardinal);
|
||||||
@ -1595,6 +1596,18 @@ begin
|
|||||||
Result := -1;
|
Result := -1;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
function TsSpreadOpenDocReader.NodeIsEmptyCell(ACellNode: TDOMNode): Boolean;
|
||||||
|
var
|
||||||
|
valuestr: String;
|
||||||
|
typestr: String;
|
||||||
|
formulastr: String;
|
||||||
|
begin
|
||||||
|
valueStr := GetAttrValue(ACellNode, 'office:value');
|
||||||
|
typestr := GetAttrValue(ACellNode, 'office:value-type');
|
||||||
|
formulaStr := GetAttrValue(ACellNode, 'table:formula');
|
||||||
|
Result := (valueStr <> '') or (typeStr <> '') or (formulaStr <> '');
|
||||||
|
end;
|
||||||
|
|
||||||
procedure TsSpreadOpenDocReader.ReadAutomaticStyles(AStylesNode: TDOMNode);
|
procedure TsSpreadOpenDocReader.ReadAutomaticStyles(AStylesNode: TDOMNode);
|
||||||
var
|
var
|
||||||
nodeName: String;
|
nodeName: String;
|
||||||
@ -4895,7 +4908,7 @@ end;
|
|||||||
these dummy cells there would be an extreme time and memory penalty. }
|
these dummy cells there would be an extreme time and memory penalty. }
|
||||||
procedure TsSpreadOpenDocReader.RemoveDummyRows(ATableNode: TDOMNode);
|
procedure TsSpreadOpenDocReader.RemoveDummyRows(ATableNode: TDOMNode);
|
||||||
var
|
var
|
||||||
rowNode, prevNode: TDOMNode;
|
rowNode, cellNode, prevNode: TDOMNode;
|
||||||
nodeName: String;
|
nodeName: String;
|
||||||
s: String;
|
s: String;
|
||||||
rowsRepeated: Integer;
|
rowsRepeated: Integer;
|
||||||
@ -4909,7 +4922,7 @@ begin
|
|||||||
if nodeName = 'table:table-row' then
|
if nodeName = 'table:table-row' then
|
||||||
begin
|
begin
|
||||||
// If, coming from the end, we find a row with a large "number-rows-repeated"
|
// If, coming from the end, we find a row with a large "number-rows-repeated"
|
||||||
// value
|
// value --> remove it
|
||||||
s := GetAttrValue(rowNode, 'table:number-rows-repeated');
|
s := GetAttrValue(rowNode, 'table:number-rows-repeated');
|
||||||
if s <> '' then
|
if s <> '' then
|
||||||
begin
|
begin
|
||||||
@ -4921,7 +4934,19 @@ begin
|
|||||||
rowNode := prevNode;
|
rowNode := prevNode;
|
||||||
continue;
|
continue;
|
||||||
end;
|
end;
|
||||||
end
|
end;
|
||||||
|
// If there is no "number-rows-repeated" row we check whether the row contains
|
||||||
|
// non-empty cells. In this case, we would have left the dummy block
|
||||||
|
// and must stop removing rows.
|
||||||
|
cellNode := rowNode.FirstChild;
|
||||||
|
while cellNode <> nil do
|
||||||
|
begin
|
||||||
|
nodeName := cellNode.NodeName;
|
||||||
|
if nodeName = 'table:table-cell' then
|
||||||
|
if NodeIsEmptyCell(cellNode) then
|
||||||
|
exit;
|
||||||
|
cellNode := cellNode.NextSibling;
|
||||||
|
end;
|
||||||
end;
|
end;
|
||||||
rowNode := rowNode.PreviousSibling;
|
rowNode := rowNode.PreviousSibling;
|
||||||
end;
|
end;
|
||||||
|
Reference in New Issue
Block a user