You've already forked lazarus-ccr
fpspreadsheet: Add reading support of page breaks to ODS format.
git-svn-id: https://svn.code.sf.net/p/lazarus-ccr/svn@7072 8e941d3f-bd1b-0410-a28a-d453659cc2b4
This commit is contained in:
@ -368,7 +368,9 @@ const
|
|||||||
('0.74pt', '1.76pt', '0.74pt', '0.74pt', '2.49pt', '0.74pt', '0.74pt',
|
('0.74pt', '1.76pt', '0.74pt', '0.74pt', '2.49pt', '0.74pt', '0.74pt',
|
||||||
'1.76pt', '0.74pt', '1.76pt', '0.74pt', '1.76pt', '1.76pt');
|
'1.76pt', '0.74pt', '1.76pt', '0.74pt', '1.76pt', '1.76pt');
|
||||||
|
|
||||||
FALSE_TRUE: Array[boolean] of String = ('false', 'true');
|
FALSE_TRUE: array[boolean] of String = ('false', 'true');
|
||||||
|
|
||||||
|
PAGE_BREAK: array[boolean] of string = ('auto', 'page');
|
||||||
|
|
||||||
COLWIDTH_EPS = 1e-3;
|
COLWIDTH_EPS = 1e-3;
|
||||||
ROWHEIGHT_EPS = 1e-3;
|
ROWHEIGHT_EPS = 1e-3;
|
||||||
@ -388,6 +390,7 @@ type
|
|||||||
public
|
public
|
||||||
Name: String;
|
Name: String;
|
||||||
ColWidth: Double; // in workbook units
|
ColWidth: Double; // in workbook units
|
||||||
|
PageBreak: Boolean; // Indicator that col follows a page break
|
||||||
end;
|
end;
|
||||||
|
|
||||||
{ Column data items stored in the ColumnList }
|
{ Column data items stored in the ColumnList }
|
||||||
@ -397,6 +400,7 @@ type
|
|||||||
ColStyleIndex: integer; // index into FColumnStyleList of reader
|
ColStyleIndex: integer; // index into FColumnStyleList of reader
|
||||||
DefaultCellStyleIndex: Integer; // Index of default cell style in FCellStyleList of reader
|
DefaultCellStyleIndex: Integer; // Index of default cell style in FCellStyleList of reader
|
||||||
Hidden: Boolean; // Indicates that column is hidden
|
Hidden: Boolean; // Indicates that column is hidden
|
||||||
|
PageBreak: Boolean; // Indicates that page break occurs at left of column
|
||||||
end;
|
end;
|
||||||
|
|
||||||
{ Row style items stored in RowStyleList of the reader }
|
{ Row style items stored in RowStyleList of the reader }
|
||||||
@ -405,6 +409,7 @@ type
|
|||||||
Name: String;
|
Name: String;
|
||||||
RowHeight: Double; // in workbook units
|
RowHeight: Double; // in workbook units
|
||||||
RowHeightType: TsRowHeightType;
|
RowHeightType: TsRowHeightType;
|
||||||
|
PageBreak: Boolean;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
{ PageLayout items stored in PageLayoutList }
|
{ PageLayout items stored in PageLayoutList }
|
||||||
@ -1157,6 +1162,10 @@ begin
|
|||||||
if colData.Hidden then
|
if colData.Hidden then
|
||||||
sheet.HideCol(colIndex);
|
sheet.HideCol(colIndex);
|
||||||
|
|
||||||
|
// Column page break flag
|
||||||
|
if colData.PageBreak then
|
||||||
|
sheet.AddPageBreakToCol(colIndex);
|
||||||
|
|
||||||
// Note: we don't store the column format index here; this is done in the
|
// Note: we don't store the column format index here; this is done in the
|
||||||
// row/cell reading method (ReadRowsAndCells).
|
// row/cell reading method (ReadRowsAndCells).
|
||||||
end;
|
end;
|
||||||
@ -1939,6 +1948,7 @@ var
|
|||||||
colsRepeated: Integer;
|
colsRepeated: Integer;
|
||||||
j: Integer;
|
j: Integer;
|
||||||
isHidden: Boolean;
|
isHidden: Boolean;
|
||||||
|
isPageBreak: Boolean;
|
||||||
begin
|
begin
|
||||||
s := GetAttrValue(AColNode, 'table:style-name');
|
s := GetAttrValue(AColNode, 'table:style-name');
|
||||||
colStyleIndex := FindColStyleByName(s);
|
colStyleIndex := FindColStyleByName(s);
|
||||||
@ -1949,8 +1959,10 @@ var
|
|||||||
s := GetAttrValue(AColNode, 'table:visibility');
|
s := GetAttrValue(AColNode, 'table:visibility');
|
||||||
isHidden := (s = 'collapse');
|
isHidden := (s = 'collapse');
|
||||||
|
|
||||||
|
isPageBreak := TColumnStyleData(FColumnStyleList[colStyleIndex]).PageBreak;
|
||||||
|
|
||||||
s := GetAttrValue(AColNode, 'table:default-cell-style-name');
|
s := GetAttrValue(AColNode, 'table:default-cell-style-name');
|
||||||
if (s <> '') or isHidden then
|
if (s <> '') or isHidden or isPageBreak then
|
||||||
begin
|
begin
|
||||||
defCellStyleIndex := FCellFormatList.FindIndexOfName(s); //FindCellStyleByName(s);
|
defCellStyleIndex := FCellFormatList.FindIndexOfName(s); //FindCellStyleByName(s);
|
||||||
colData := TColumnData.Create;
|
colData := TColumnData.Create;
|
||||||
@ -1958,6 +1970,7 @@ var
|
|||||||
colData.ColStyleIndex := colStyleIndex;
|
colData.ColStyleIndex := colStyleIndex;
|
||||||
colData.DefaultCellStyleIndex := defCellStyleIndex;
|
colData.DefaultCellStyleIndex := defCellStyleIndex;
|
||||||
colData.Hidden := isHidden;
|
colData.Hidden := isHidden;
|
||||||
|
colData.PageBreak := isPageBreak;
|
||||||
FColumnList.Add(colData);
|
FColumnList.Add(colData);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
@ -1975,31 +1988,11 @@ var
|
|||||||
colData.ColStyleIndex := colStyleIndex;
|
colData.ColStyleIndex := colStyleIndex;
|
||||||
colData.DefaultCellStyleIndex := defCellStyleIndex;
|
colData.DefaultCellStyleIndex := defCellStyleIndex;
|
||||||
colData.Hidden := isHidden;
|
colData.Hidden := isHidden;
|
||||||
|
colData.PageBreak := isPageBreak;
|
||||||
FColumnList.Add(colData);
|
FColumnList.Add(colData);
|
||||||
inc(col);
|
inc(col);
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
(*
|
|
||||||
|
|
||||||
if (s = '') and (not isHidden) then
|
|
||||||
inc(col)
|
|
||||||
else
|
|
||||||
begin
|
|
||||||
colsRepeated := StrToInt(s);
|
|
||||||
if (defCellStyleIndex > -1) or isHidden then begin
|
|
||||||
for j:=1 to colsRepeated-1 do
|
|
||||||
begin
|
|
||||||
colData := TColumnData.Create;
|
|
||||||
colData.Col := col + j;
|
|
||||||
colData.ColStyleIndex := colStyleIndex;
|
|
||||||
colData.DefaultCellStyleIndex := defCellStyleIndex;
|
|
||||||
colData.Hidden := isHidden;
|
|
||||||
FColumnList.Add(colData);
|
|
||||||
end;
|
|
||||||
end;
|
|
||||||
inc(col, colsRepeated);
|
|
||||||
end;
|
|
||||||
*)
|
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
@ -2039,11 +2032,13 @@ var
|
|||||||
styleName: String;
|
styleName: String;
|
||||||
styleChildNode: TDOMNode;
|
styleChildNode: TDOMNode;
|
||||||
colWidth: double;
|
colWidth: double;
|
||||||
|
colPageBreak: Boolean;
|
||||||
s: String;
|
s: String;
|
||||||
begin
|
begin
|
||||||
styleName := GetAttrValue(AStyleNode, 'style:name');
|
styleName := GetAttrValue(AStyleNode, 'style:name');
|
||||||
styleChildNode := AStyleNode.FirstChild;
|
styleChildNode := AStyleNode.FirstChild;
|
||||||
colWidth := -1;
|
colWidth := -1;
|
||||||
|
colPageBreak := false;
|
||||||
|
|
||||||
while Assigned(styleChildNode) do
|
while Assigned(styleChildNode) do
|
||||||
begin
|
begin
|
||||||
@ -2051,11 +2046,11 @@ begin
|
|||||||
begin
|
begin
|
||||||
s := GetAttrValue(styleChildNode, 'style:column-width');
|
s := GetAttrValue(styleChildNode, 'style:column-width');
|
||||||
if s <> '' then
|
if s <> '' then
|
||||||
begin
|
|
||||||
colWidth := (FWorkbook as TsWorkbook).ConvertUnits(HTMLLengthStrToPts(s), suPoints, FWorkbook.Units);
|
|
||||||
// convert to workbook units
|
// convert to workbook units
|
||||||
break;
|
colWidth := (FWorkbook as TsWorkbook).ConvertUnits(HTMLLengthStrToPts(s), suPoints, FWorkbook.Units);
|
||||||
end;
|
s := GetAttrValue(styleChildNode, 'fo:break-before');
|
||||||
|
if s = 'page' then
|
||||||
|
colPageBreak := true;
|
||||||
end;
|
end;
|
||||||
styleChildNode := styleChildNode.NextSibling;
|
styleChildNode := styleChildNode.NextSibling;
|
||||||
end;
|
end;
|
||||||
@ -2063,6 +2058,7 @@ begin
|
|||||||
colStyle := TColumnStyleData.Create;
|
colStyle := TColumnStyleData.Create;
|
||||||
colStyle.Name := styleName;
|
colStyle.Name := styleName;
|
||||||
colStyle.ColWidth := colWidth;
|
colStyle.ColWidth := colWidth;
|
||||||
|
colStyle.PageBreak := colPageBreak;
|
||||||
FColumnStyleList.Add(colStyle);
|
FColumnStyleList.Add(colStyle);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
@ -2806,9 +2802,10 @@ var
|
|||||||
|
|
||||||
procedure AddToCellText(AText: String);
|
procedure AddToCellText(AText: String);
|
||||||
begin
|
begin
|
||||||
if cellText = ''
|
if cellText = '' then
|
||||||
then cellText := AText
|
cellText := AText
|
||||||
else cellText := cellText + AText;
|
else
|
||||||
|
cellText := cellText + AText;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
begin
|
begin
|
||||||
@ -3708,6 +3705,7 @@ var
|
|||||||
styleIndex: Integer;
|
styleIndex: Integer;
|
||||||
firstStyleIndex: Integer;
|
firstStyleIndex: Integer;
|
||||||
rowHidden: Boolean;
|
rowHidden: Boolean;
|
||||||
|
rowPageBreak: Boolean;
|
||||||
begin
|
begin
|
||||||
// Read rowstyle
|
// Read rowstyle
|
||||||
rowStyleName := GetAttrValue(ARowNode, 'table:style-name');
|
rowStyleName := GetAttrValue(ARowNode, 'table:style-name');
|
||||||
@ -3717,11 +3715,17 @@ var
|
|||||||
rowStyle := TRowStyleData(FRowStyleList[rowStyleIndex]);
|
rowStyle := TRowStyleData(FRowStyleList[rowStyleIndex]);
|
||||||
rowHeight := rowStyle.RowHeight; // in Workbook units (see ReadRowStyles)
|
rowHeight := rowStyle.RowHeight; // in Workbook units (see ReadRowStyles)
|
||||||
rowHeightType := rowStyle.RowHeightType;
|
rowHeightType := rowStyle.RowHeightType;
|
||||||
|
rowPageBreak := rowStyle.PageBreak;
|
||||||
end else begin
|
end else begin
|
||||||
rowHeight := (FWorksheet as TsWorksheet).ReadDefaultRowHeight(FWorkbook.Units);
|
rowHeight := (FWorksheet as TsWorksheet).ReadDefaultRowHeight(FWorkbook.Units);
|
||||||
rowHeightTYpe := rhtDefault;
|
rowHeightTYpe := rhtDefault;
|
||||||
|
rowPageBreak := false;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
// If the row contains the PageBreak flag we add store it in a row record.
|
||||||
|
if rowPageBreak then
|
||||||
|
(FWorksheet as TsWorksheet).AddPageBreakToRow(row);
|
||||||
|
|
||||||
col := 0;
|
col := 0;
|
||||||
firstStyleIndex := -1;
|
firstStyleIndex := -1;
|
||||||
hasRowFormat := true;
|
hasRowFormat := true;
|
||||||
@ -3904,6 +3908,7 @@ var
|
|||||||
styleName, nodename: String;
|
styleName, nodename: String;
|
||||||
styleChildNode: TDOMNode;
|
styleChildNode: TDOMNode;
|
||||||
rowHeight: Double;
|
rowHeight: Double;
|
||||||
|
rowPageBreak: Boolean;
|
||||||
s: String;
|
s: String;
|
||||||
rowStyle: TRowStyleData;
|
rowStyle: TRowStyleData;
|
||||||
rowHeightType: TsRowHeightType;
|
rowHeightType: TsRowHeightType;
|
||||||
@ -3912,6 +3917,7 @@ begin
|
|||||||
styleChildNode := AStyleNode.FirstChild;
|
styleChildNode := AStyleNode.FirstChild;
|
||||||
rowHeight := 0;
|
rowHeight := 0;
|
||||||
rowHeightType := rhtCustom;
|
rowHeightType := rhtCustom;
|
||||||
|
rowPageBreak := false;
|
||||||
|
|
||||||
while Assigned(styleChildNode) do
|
while Assigned(styleChildNode) do
|
||||||
begin
|
begin
|
||||||
@ -3925,6 +3931,10 @@ begin
|
|||||||
s := GetAttrValue(styleChildNode, 'style:use-optimal-row-height');
|
s := GetAttrValue(styleChildNode, 'style:use-optimal-row-height');
|
||||||
if s = 'true' then
|
if s = 'true' then
|
||||||
rowHeightType := rhtAuto;
|
rowHeightType := rhtAuto;
|
||||||
|
// Page break
|
||||||
|
s := GetAttrValue(styleChildNode, 'fo:break-before');
|
||||||
|
if s = 'page' then
|
||||||
|
rowPageBreak := true;
|
||||||
end;
|
end;
|
||||||
styleChildNode := styleChildNode.NextSibling;
|
styleChildNode := styleChildNode.NextSibling;
|
||||||
end;
|
end;
|
||||||
@ -3933,6 +3943,7 @@ begin
|
|||||||
rowStyle.Name := styleName;
|
rowStyle.Name := styleName;
|
||||||
rowStyle.RowHeight := rowHeight;
|
rowStyle.RowHeight := rowHeight;
|
||||||
rowStyle.RowHeightType := rowHeightType;
|
rowStyle.RowHeightType := rowHeightType;
|
||||||
|
rowStyle.PageBreak := rowPageBreak;
|
||||||
FRowStyleList.Add(rowStyle);
|
FRowStyleList.Add(rowStyle);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user