You've already forked lazarus-ccr
fpspreadsheet: Add reading of ods repeated print rows.
git-svn-id: https://svn.code.sf.net/p/lazarus-ccr/svn@4504 8e941d3f-bd1b-0410-a28a-d453659cc2b4
This commit is contained in:
@ -2199,7 +2199,12 @@ begin
|
|||||||
// Read page layout
|
// Read page layout
|
||||||
pageLayout := ReadPageLayout(StylesNode, GetAttrValue(TableNode, 'table:style-name'));
|
pageLayout := ReadPageLayout(StylesNode, GetAttrValue(TableNode, 'table:style-name'));
|
||||||
if pageLayout <> nil then
|
if pageLayout <> nil then
|
||||||
|
begin
|
||||||
|
// Protect already-known RepeatedCols/Rows
|
||||||
|
pagelayout^.RepeatedCols := FWorksheet.PageLayout.RepeatedCols;
|
||||||
|
pagelayout^.RepeatedRows := FWorksheet.PageLayout.RepeatedRows;
|
||||||
FWorksheet.PageLayout := pagelayout^;
|
FWorksheet.PageLayout := pagelayout^;
|
||||||
|
end;
|
||||||
// Read print ranges
|
// Read print ranges
|
||||||
ReadPrintRanges(TableNode, FWorksheet);
|
ReadPrintRanges(TableNode, FWorksheet);
|
||||||
// Apply table style
|
// Apply table style
|
||||||
@ -2981,8 +2986,12 @@ begin
|
|||||||
while (i <= Length(s)) and (s[i] = ' ') do
|
while (i <= Length(s)) and (s[i] = ' ') do
|
||||||
inc(i);
|
inc(i);
|
||||||
p := i;
|
p := i;
|
||||||
|
if p <= Length(s) then
|
||||||
|
begin
|
||||||
ch := s[p];
|
ch := s[p];
|
||||||
Continue;
|
Continue;
|
||||||
|
end else
|
||||||
|
break;
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
inc(i);
|
inc(i);
|
||||||
@ -3032,45 +3041,31 @@ end;
|
|||||||
procedure TsSpreadOpenDocReader.ReadRowsAndCells(ATableNode: TDOMNode);
|
procedure TsSpreadOpenDocReader.ReadRowsAndCells(ATableNode: TDOMNode);
|
||||||
var
|
var
|
||||||
row: Integer;
|
row: Integer;
|
||||||
col: Integer;
|
cellNode, rowNode, childnode: TDOMNode;
|
||||||
cellNode, rowNode: TDOMNode;
|
|
||||||
nodeName: String;
|
nodeName: String;
|
||||||
paramValueType, paramFormula, tableStyleName: String;
|
|
||||||
paramColsSpanned, paramRowsSpanned: String;
|
|
||||||
paramColsRepeated, paramRowsRepeated: String;
|
|
||||||
rowsRepeated: Integer;
|
rowsRepeated: Integer;
|
||||||
rowsSpanned: Integer;
|
r1, r2: Cardinal;
|
||||||
colsSpanned: Integer;
|
|
||||||
|
procedure ProcessRow(ARowNode: TDOMNode);
|
||||||
|
var
|
||||||
rowStyleName: String;
|
rowStyleName: String;
|
||||||
rowStyleIndex: Integer;
|
rowStyleIndex: Integer;
|
||||||
rowStyle: TRowStyleData;
|
rowStyle: TRowStyleData;
|
||||||
rowHeight: Single;
|
rowHeight: Single;
|
||||||
autoRowHeight: Boolean;
|
autoRowHeight: Boolean;
|
||||||
i, n: Integer;
|
col: Integer;
|
||||||
|
cellNode: TDOMNode;
|
||||||
|
nodeName: String;
|
||||||
cell: PCell;
|
cell: PCell;
|
||||||
begin
|
paramValueType, paramFormula, tableStyleName: String;
|
||||||
rowsRepeated := 0;
|
paramColsSpanned, paramRowsSpanned: String;
|
||||||
row := 0;
|
paramColsRepeated, paramRowsRepeated: String;
|
||||||
|
rowsSpanned: Integer;
|
||||||
rowNode := ATableNode.FindNode('table:table-row');
|
colsSpanned: Integer;
|
||||||
while Assigned(rowNode) do
|
i, n: Integer;
|
||||||
begin
|
begin
|
||||||
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
|
|
||||||
// to ReadXMLFile
|
|
||||||
// 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;
|
|
||||||
Continue;
|
|
||||||
end;
|
|
||||||
|
|
||||||
// Read rowstyle
|
// Read rowstyle
|
||||||
rowStyleName := GetAttrValue(rowNode, 'table:style-name');
|
rowStyleName := GetAttrValue(ARowNode, 'table:style-name');
|
||||||
rowStyleIndex := FindRowStyleByName(rowStyleName);
|
rowStyleIndex := FindRowStyleByName(rowStyleName);
|
||||||
if rowStyleIndex > -1 then // just for safety
|
if rowStyleIndex > -1 then // just for safety
|
||||||
begin
|
begin
|
||||||
@ -3087,7 +3082,8 @@ begin
|
|||||||
col := 0;
|
col := 0;
|
||||||
|
|
||||||
//process each cell of the row
|
//process each cell of the row
|
||||||
cellNode := rowNode.FindNode('table:table-cell');
|
cellNode := ARowNode.FirstChild;
|
||||||
|
// cellNode := rowNode.FindNode('table:table-cell');
|
||||||
while Assigned(cellNode) do
|
while Assigned(cellNode) do
|
||||||
begin
|
begin
|
||||||
nodeName := cellNode.NodeName;
|
nodeName := cellNode.NodeName;
|
||||||
@ -3098,7 +3094,7 @@ begin
|
|||||||
paramFormula := GetAttrValue(CellNode, 'table:formula');
|
paramFormula := GetAttrValue(CellNode, 'table:formula');
|
||||||
tableStyleName := GetAttrValue(CellNode, 'table:style-name');
|
tableStyleName := GetAttrValue(CellNode, 'table:style-name');
|
||||||
|
|
||||||
if ParamFormula <> '' then
|
if paramFormula <> '' then
|
||||||
ReadFormula(row, col, cellNode)
|
ReadFormula(row, col, cellNode)
|
||||||
else
|
else
|
||||||
begin
|
begin
|
||||||
@ -3179,12 +3175,46 @@ begin
|
|||||||
FWorksheet.WriteRowHeight(row + i - 1, rowHeight);
|
FWorksheet.WriteRowHeight(row + i - 1, rowHeight);
|
||||||
|
|
||||||
row := row + rowsRepeated;
|
row := row + rowsRepeated;
|
||||||
|
end;
|
||||||
|
|
||||||
|
begin
|
||||||
|
rowsRepeated := 0;
|
||||||
|
row := 0;
|
||||||
|
r1 := UNASSIGNED_ROW_COL_INDEX;
|
||||||
|
r2 := UNASSIGNED_ROW_COL_INDEX;
|
||||||
|
|
||||||
|
rownode := ATableNode.FirstChild;
|
||||||
|
while Assigned(rowNode) do
|
||||||
|
begin
|
||||||
|
nodename := rowNode.NodeName;
|
||||||
|
|
||||||
|
// Repeated print rows
|
||||||
|
if nodeName = 'table:table-header-rows' then
|
||||||
|
begin
|
||||||
|
childnode := rowNode.FirstChild;
|
||||||
|
while Assigned(childnode) do
|
||||||
|
begin
|
||||||
|
nodename := childnode.NodeName;
|
||||||
|
if nodename = 'table:table-row' then
|
||||||
|
begin
|
||||||
|
if r1 = Cardinal(UNASSIGNED_ROW_COL_INDEX) then
|
||||||
|
r1 := row;
|
||||||
|
ProcessRow(childnode);
|
||||||
|
r2 := row-1;
|
||||||
|
end;
|
||||||
|
childnode := childnode.NextSibling;
|
||||||
|
end;
|
||||||
|
end else
|
||||||
|
// "normal" rows
|
||||||
|
if nodeName = 'table:table-row' then
|
||||||
|
begin
|
||||||
|
ProcessRow(rowNode);
|
||||||
|
end;
|
||||||
rowNode := rowNode.NextSibling;
|
rowNode := rowNode.NextSibling;
|
||||||
end; // while Assigned(rowNode)
|
end;
|
||||||
|
|
||||||
cell := FWorksheet.FindCell(2, 1);
|
|
||||||
|
|
||||||
|
if r1 <> cardinal(UNASSIGNED_ROW_COL_INDEX) then
|
||||||
|
FWorksheet.SetRepeatedPrintRows(r1, r2);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure TsSpreadOpenDocReader.ReadRowStyle(AStyleNode: TDOMNode);
|
procedure TsSpreadOpenDocReader.ReadRowStyle(AStyleNode: TDOMNode);
|
||||||
|
Reference in New Issue
Block a user