mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-06-20 22:48:15 +02:00
fpvectorial: Reimplements table caption as a special row, which is more elegant
git-svn-id: trunk@47857 -
This commit is contained in:
parent
f198c69aea
commit
a045a18155
@ -1151,7 +1151,6 @@ type
|
|||||||
PreferredWidth : TvDimension; // Optional. Units mm.
|
PreferredWidth : TvDimension; // Optional. Units mm.
|
||||||
CellSpacing : Double; // Units mm. Gap between Cells.
|
CellSpacing : Double; // Units mm. Gap between Cells.
|
||||||
BackgroundColor : TFPColor; // Optional.
|
BackgroundColor : TFPColor; // Optional.
|
||||||
Caption: string; // Its a first row without border
|
|
||||||
|
|
||||||
constructor create(APage : TvPage); override;
|
constructor create(APage : TvPage); override;
|
||||||
destructor destroy; override;
|
destructor destroy; override;
|
||||||
@ -1161,6 +1160,7 @@ type
|
|||||||
function GetRow(AIndex: Integer) : TvTableRow;
|
function GetRow(AIndex: Integer) : TvTableRow;
|
||||||
//
|
//
|
||||||
function AddColWidth(AValue : Double) : Integer;
|
function AddColWidth(AValue : Double) : Integer;
|
||||||
|
function GetColCount(): Integer;
|
||||||
//
|
//
|
||||||
procedure Render(ADest: TFPCustomCanvas; var ARenderInfo: TvRenderInfo; ADestX: Integer = 0;
|
procedure Render(ADest: TFPCustomCanvas; var ARenderInfo: TvRenderInfo; ADestX: Integer = 0;
|
||||||
ADestY: Integer = 0; AMulX: Double = 1.0; AMulY: Double = 1.0); override;
|
ADestY: Integer = 0; AMulX: Double = 1.0; AMulY: Double = 1.0); override;
|
||||||
@ -1713,7 +1713,9 @@ begin
|
|||||||
CurCell := CurRow.GetCell(col);
|
CurCell := CurRow.GetCell(col);
|
||||||
//DebugStr := ((CurCell.GetFirstEntity() as TvParagraph).GetFirstEntity() as TvText).Value.Text;
|
//DebugStr := ((CurCell.GetFirstEntity() as TvParagraph).GetFirstEntity() as TvText).Value.Text;
|
||||||
|
|
||||||
if OriginalColWidthsInMM[col] > 0 then
|
// skip cells with span since they are complex
|
||||||
|
// skip columns with width pre-set
|
||||||
|
if (OriginalColWidthsInMM[col] > 0) or (CurCell.SpannedCols > 0) then
|
||||||
begin
|
begin
|
||||||
TableWidth := TableWidth + ColWidthsInMM[col];
|
TableWidth := TableWidth + ColWidthsInMM[col];
|
||||||
Continue;
|
Continue;
|
||||||
@ -1803,6 +1805,27 @@ begin
|
|||||||
ColWidths[High(ColWidths)] := AValue;
|
ColWidths[High(ColWidths)] := AValue;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
function TvTable.GetColCount(): Integer;
|
||||||
|
var
|
||||||
|
row, col, CurRowColCount: Integer;
|
||||||
|
CurRow: TvTableRow;
|
||||||
|
CurCell: TvTableCell;
|
||||||
|
begin
|
||||||
|
Result := 0;
|
||||||
|
for row := 0 to GetRowCount()-1 do
|
||||||
|
begin
|
||||||
|
CurRow := GetRow(row);
|
||||||
|
CurRowColCount := 0;
|
||||||
|
for col := 0 to CurRow.GetCellCount()-1 do
|
||||||
|
begin
|
||||||
|
CurCell := CurRow.GetCell(col);
|
||||||
|
CurRowColCount := CurRowColCount + CurCell.SpannedCols + 1;
|
||||||
|
end;
|
||||||
|
|
||||||
|
Result := Max(Result, CurRowColCount);
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
|
||||||
procedure TvTable.Render(ADest: TFPCustomCanvas; var ARenderInfo: TvRenderInfo;
|
procedure TvTable.Render(ADest: TFPCustomCanvas; var ARenderInfo: TvRenderInfo;
|
||||||
ADestX: Integer; ADestY: Integer; AMulX: Double; AMulY: Double);
|
ADestX: Integer; ADestY: Integer; AMulX: Double; AMulY: Double);
|
||||||
|
|
||||||
@ -1843,7 +1866,6 @@ var
|
|||||||
i: Integer;
|
i: Integer;
|
||||||
lCurRow: TvTableRow;
|
lCurRow: TvTableRow;
|
||||||
begin
|
begin
|
||||||
FExtraDebugStr := Format(' Caption=%s', [Caption]);
|
|
||||||
Result := inherited GenerateDebugTree(ADestRoutine, APageItem);
|
Result := inherited GenerateDebugTree(ADestRoutine, APageItem);
|
||||||
|
|
||||||
// data which goes into a separate item
|
// data which goes into a separate item
|
||||||
|
@ -174,6 +174,9 @@ var
|
|||||||
CurTable: TvTable;
|
CurTable: TvTable;
|
||||||
lCurNode, lCurSubnode: TDOMNode;
|
lCurNode, lCurSubnode: TDOMNode;
|
||||||
lNodeName, lNodeValue: DOMString;
|
lNodeName, lNodeValue: DOMString;
|
||||||
|
CurRow: TvTableRow;
|
||||||
|
Caption_Cell: TvTableCell;
|
||||||
|
CurCellPara: TvParagraph;
|
||||||
begin
|
begin
|
||||||
Result := nil;
|
Result := nil;
|
||||||
CurTable := AData.AddTable();
|
CurTable := AData.AddTable();
|
||||||
@ -186,7 +189,11 @@ begin
|
|||||||
case lNodeName of
|
case lNodeName of
|
||||||
'caption':
|
'caption':
|
||||||
begin
|
begin
|
||||||
CurTable.Caption := GetTextContentFromNode(lCurNode);
|
CurRow := CurTable.AddRow();
|
||||||
|
Caption_Cell := CurRow.AddCell();
|
||||||
|
CurCellPara := Caption_Cell.AddParagraph();
|
||||||
|
CurCellPara.Style := ADoc.StyleTextBodyCentralized;
|
||||||
|
CurCellPara.AddText(GetTextContentFromNode(lCurNode));
|
||||||
end;
|
end;
|
||||||
'tbody':
|
'tbody':
|
||||||
begin
|
begin
|
||||||
@ -202,6 +209,9 @@ begin
|
|||||||
|
|
||||||
lCurNode := lCurNode.NextSibling;
|
lCurNode := lCurNode.NextSibling;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
// the caption spans all columns
|
||||||
|
Caption_Cell.SpannedCols := CurTable.GetColCount()-1;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
function TvHTMLVectorialReader.ReadTableRowNode(ATable: TvTable; ANode: TDOMNode;
|
function TvHTMLVectorialReader.ReadTableRowNode(ATable: TvTable; ANode: TDOMNode;
|
||||||
|
Loading…
Reference in New Issue
Block a user