v0.0.500
Some checks failed
Build Docker and Deploy / Run goext test-suite (push) Has been cancelled
Some checks failed
Build Docker and Deploy / Run goext test-suite (push) Has been cancelled
This commit is contained in:
@@ -38,24 +38,6 @@ type TableBuilder struct {
|
||||
debug *bool
|
||||
}
|
||||
|
||||
type TableCell struct {
|
||||
Content string
|
||||
Style TableCellStyleOpt
|
||||
}
|
||||
|
||||
type TableCellStyleOpt struct {
|
||||
MultiCell *bool
|
||||
Ellipsize *bool
|
||||
PaddingHorz *float64
|
||||
MinWidth *float64
|
||||
|
||||
PDFCellOpt
|
||||
}
|
||||
|
||||
type tableRow struct {
|
||||
cells []TableCell
|
||||
}
|
||||
|
||||
func (r tableRow) maxFontSize(defaultFontSize float64) float64 {
|
||||
mfs := defaultFontSize
|
||||
for _, cell := range r.cells {
|
||||
@@ -91,10 +73,10 @@ func (b *TableBuilder) AddRow(cells ...TableCell) *TableBuilder {
|
||||
return b
|
||||
}
|
||||
|
||||
func (b *TableBuilder) AddRowWithStyle(style TableCellStyleOpt, cells ...string) *TableBuilder {
|
||||
func (b *TableBuilder) AddRowWithStyle(style *TableCellStyleOpt, cells ...string) *TableBuilder {
|
||||
tcels := make([]TableCell, 0, len(cells))
|
||||
for _, cell := range cells {
|
||||
tcels = append(tcels, TableCell{Content: cell, Style: style})
|
||||
tcels = append(tcels, TableCell{Content: cell, Style: *style})
|
||||
}
|
||||
|
||||
b.rows = append(b.rows, tableRow{cells: tcels})
|
||||
@@ -113,6 +95,10 @@ func (b *TableBuilder) AddRowDefaultStyle(cells ...string) *TableBuilder {
|
||||
return b
|
||||
}
|
||||
|
||||
func (b *TableBuilder) BuildRow() *TableRowBuilder {
|
||||
return &TableRowBuilder{tabbuilder: b, cells: make([]TableCell, 0)}
|
||||
}
|
||||
|
||||
func (b *TableBuilder) Build() {
|
||||
builder := b.builder
|
||||
|
||||
@@ -148,15 +134,15 @@ func (b *TableBuilder) Build() {
|
||||
str := cell.Content
|
||||
style := cell.Style
|
||||
|
||||
ellipsize := langext.Coalesce(style.Ellipsize, true)
|
||||
cellPaddingHorz := langext.Coalesce(style.PaddingHorz, 2)
|
||||
ellipsize := langext.Coalesce(style.ellipsize, true)
|
||||
cellPaddingHorz := langext.Coalesce(style.paddingHorz, 2)
|
||||
|
||||
bx := builder.GetX()
|
||||
by := builder.GetY()
|
||||
|
||||
cellWidth := columnWidths[cellIdx]
|
||||
|
||||
if langext.Coalesce(style.MultiCell, true) {
|
||||
if langext.Coalesce(style.multiCell, true) {
|
||||
|
||||
builder.MultiCell(str, style.PDFCellOpt.Copy().ToMulti().Width(cellWidth).Debug(debug))
|
||||
|
||||
@@ -230,8 +216,8 @@ func (b *TableBuilder) calculateColumns() []float64 {
|
||||
for _, row := range b.rows {
|
||||
if len(row.cells) > colIdx {
|
||||
|
||||
ph := langext.Coalesce(row.cells[colIdx].Style.PaddingHorz, 2)
|
||||
mw := langext.Coalesce(row.cells[colIdx].Style.MinWidth, 0)
|
||||
ph := langext.Coalesce(row.cells[colIdx].Style.paddingHorz, 2)
|
||||
mw := langext.Coalesce(row.cells[colIdx].Style.minWidth, 0)
|
||||
|
||||
minWidth = max(minWidth, ph+mw)
|
||||
|
||||
@@ -344,8 +330,8 @@ func defaultTableStyle() *TableCellStyleOpt {
|
||||
FillColorHex(uint32(0xF0F0F0)).
|
||||
TextColorHex(uint32(0x000000)).
|
||||
FillBackground(true),
|
||||
MinWidth: langext.Ptr(float64(5)),
|
||||
Ellipsize: langext.PTrue,
|
||||
MultiCell: langext.PFalse,
|
||||
minWidth: langext.Ptr(float64(5)),
|
||||
ellipsize: langext.PTrue,
|
||||
multiCell: langext.PFalse,
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user