forked from plandem/xlsx
-
Notifications
You must be signed in to change notification settings - Fork 0
/
visibility.go
44 lines (34 loc) · 942 Bytes
/
visibility.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
// Copyright (c) 2017 Andrey Gayvoronsky <plandem@gmail.com>
// Use of this source code is governed by a MIT-style
// license that can be found in the LICENSE file.
package primitives
import (
"encoding/xml"
)
//VisibilityType is a type to encode XSD ST_Visibility and ST_SheetState
type VisibilityType byte
//nolint
var (
ToVisibilityType map[string]VisibilityType
FromVisibilityType map[VisibilityType]string
)
func (e VisibilityType) String() string {
return FromVisibilityType[e]
}
//MarshalXMLAttr marshal VisibilityType
func (e *VisibilityType) MarshalXMLAttr(name xml.Name) (xml.Attr, error) {
attr := xml.Attr{Name: name}
if v, ok := FromVisibilityType[*e]; ok {
attr.Value = v
} else {
attr = xml.Attr{}
}
return attr, nil
}
//UnmarshalXMLAttr unmarshal VisibilityType
func (e *VisibilityType) UnmarshalXMLAttr(attr xml.Attr) error {
if v, ok := ToVisibilityType[attr.Value]; ok {
*e = v
}
return nil
}