forked from unidoc/unioffice
/
tbllook.go
93 lines (83 loc) · 2.68 KB
/
tbllook.go
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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
// Copyright 2017 Baliance. All rights reserved.
//
// Use of this source code is governed by the terms of the Affero GNU General
// Public License version 3.0 as published by the Free Software Foundation and
// appearing in the file LICENSE included in the packaging of this file. A
// commercial license can be purchased by contacting sales@baliance.com.
package document
import (
st "baliance.com/gooxml/schema/soo/ofc/sharedTypes"
"baliance.com/gooxml/schema/soo/wml"
)
// TableLook is the conditional formatting associated with a table style that
// has been assigned to a table.
type TableLook struct {
x *wml.CT_TblLook
}
// X returns the inner wrapped XML type.
func (t TableLook) X() *wml.CT_TblLook {
return t.x
}
// SetFirstColumn controls the conditional formatting for the first column in a table.
func (t TableLook) SetFirstColumn(on bool) {
if !on {
t.x.FirstColumnAttr = &st.ST_OnOff{}
t.x.FirstColumnAttr.ST_OnOff1 = st.ST_OnOff1Off
} else {
t.x.FirstColumnAttr = &st.ST_OnOff{}
t.x.FirstColumnAttr.ST_OnOff1 = st.ST_OnOff1On
}
}
// SetFirstRow controls the conditional formatting for the first row in a table.
func (t TableLook) SetFirstRow(on bool) {
if !on {
t.x.FirstRowAttr = &st.ST_OnOff{}
t.x.FirstRowAttr.ST_OnOff1 = st.ST_OnOff1Off
} else {
t.x.FirstRowAttr = &st.ST_OnOff{}
t.x.FirstRowAttr.ST_OnOff1 = st.ST_OnOff1On
}
}
// SetLastColumn controls the conditional formatting for the last column in a table.
func (t TableLook) SetLastColumn(on bool) {
if !on {
t.x.LastColumnAttr = &st.ST_OnOff{}
t.x.LastColumnAttr.ST_OnOff1 = st.ST_OnOff1Off
} else {
t.x.LastColumnAttr = &st.ST_OnOff{}
t.x.LastColumnAttr.ST_OnOff1 = st.ST_OnOff1On
}
}
// SetLastRow controls the conditional formatting for the last row in a table.
// This is called the 'Total' row within Word.
func (t TableLook) SetLastRow(on bool) {
if !on {
t.x.LastRowAttr = &st.ST_OnOff{}
t.x.LastRowAttr.ST_OnOff1 = st.ST_OnOff1Off
} else {
t.x.LastRowAttr = &st.ST_OnOff{}
t.x.LastRowAttr.ST_OnOff1 = st.ST_OnOff1On
}
}
// SetHorizontalBanding controls the conditional formatting for horizontal banding.
func (t TableLook) SetHorizontalBanding(on bool) {
if !on {
// inverted logic
t.x.NoHBandAttr = &st.ST_OnOff{}
t.x.NoHBandAttr.ST_OnOff1 = st.ST_OnOff1On
} else {
t.x.NoHBandAttr = &st.ST_OnOff{}
t.x.NoHBandAttr.ST_OnOff1 = st.ST_OnOff1Off
}
}
// SetVerticalBanding controls the conditional formatting for vertical banding.
func (t TableLook) SetVerticalBanding(on bool) {
if !on {
// inverted logic
t.x.NoVBandAttr = &st.ST_OnOff{}
t.x.NoVBandAttr.ST_OnOff1 = st.ST_OnOff1On
} else {
t.x.NoVBandAttr = &st.ST_OnOff{}
t.x.NoVBandAttr.ST_OnOff1 = st.ST_OnOff1Off
}
}