-
Notifications
You must be signed in to change notification settings - Fork 0
/
vml_shape.go
45 lines (37 loc) · 1.08 KB
/
vml_shape.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
// 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 vml
import (
"encoding/xml"
"strconv"
"strings"
"github.com/roboninc/ooxml/index"
"github.com/roboninc/ooxml/ml"
)
// Shape is direct mapping of CT_Shape
type Shape struct {
XMLName xml.Name `xml:"shape"`
Type string `xml:"type,attr,omitempty"`
ShapeType
}
func (s *Shape) MarshalXML(e *xml.Encoder, start xml.StartElement) error {
return e.EncodeElement(*s, xml.StartElement{Name: ml.ApplyNamespacePrefix(ml.NamespaceVML, start.Name)})
}
// Hash builds hash code for all required values of Shape to use as unique index
func (s *Shape) Hash() index.Code {
shape := s
if shape == nil {
shape = &Shape{}
}
clientData := shape.ClientData
if clientData == nil {
clientData = &ClientData{}
}
return index.Hash(strings.Join([]string{
shape.Type,
strconv.FormatInt(int64(shape.Spt), 10),
strconv.FormatInt(int64(clientData.Column), 10),
strconv.FormatInt(int64(clientData.Row), 10),
}, ":"))
}