query_set_components_layout_rule.go
1.5 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
package domain
const (
CellTypeTable = "Table"
CellTypeTableField = "TableField"
CellTypeText = "Text"
CellTypeNull = "Null"
)
const (
DirectionNone = "Null"
DirectionRight = "Right"
DirectionDown = "Down"
)
type LayoutRule struct {
LayoutRuleItem
}
type LayoutRuleItem struct {
Cells []*LayoutCell `json:"cells"`
}
type LayoutCell struct {
Type string `json:"type,omitempty"` // Table TableField Text Null
Data *LayoutCellData `json:"data,omitempty"`
Direction string `json:"direction,omitempty"` // 向右:Right 向下:Down
Position *Location `json:"position"`
X int `json:"-"`
Y int `json:"-"`
Length int `json:"-"`
BlockData []string `json:"-"`
ImageData string `json:"-"`
}
type Location struct {
X int `json:"x"`
Y int `json:"y"`
}
type LayoutCellData struct {
//Table *Table `json:"table,omitempty"`
//Field *Field `json:"field,omitempty"`
TableField *TableField `json:"tableField"`
Text string `json:"text,omitempty"`
}
func (l *LayoutRuleItem) LayoutCells() []*LayoutCell {
var cells = make([]*LayoutCell, 0)
//for i, rows := range l.Cells {
// for j, item := range rows {
// if item.Type == CellTypeNull || item.Type == "" {
// continue
// }
// item.X = i
// item.Y = j
// cells = append(cells, item)
// }
//}
for _, item := range l.Cells {
item.X = item.Position.X
item.Y = item.Position.Y
cells = append(cells, item)
}
return cells
}