2019-07-25 19:43:46 +03:00
|
|
|
// Copyright 2017 FoxyUtils ehf. All rights reserved.
|
2017-12-16 07:32:08 -06:00
|
|
|
//
|
2020-08-08 01:01:05 +00:00
|
|
|
// Use of this software package and source code is governed by the terms of the
|
|
|
|
// UniDoc End User License Agreement (EULA) that is available at:
|
|
|
|
// https://unidoc.io/eula/
|
|
|
|
// A trial license code for evaluation can be obtained at https://unidoc.io.
|
2017-12-16 07:32:08 -06:00
|
|
|
|
|
|
|
package document
|
|
|
|
|
2019-05-04 11:18:06 +03:00
|
|
|
import "github.com/unidoc/unioffice/schema/soo/wml"
|
2017-12-16 07:32:08 -06:00
|
|
|
|
|
|
|
// NumberingDefinition defines a numbering definition for a list of pragraphs.
|
|
|
|
type NumberingDefinition struct {
|
2018-01-04 18:57:30 -06:00
|
|
|
x *wml.CT_AbstractNum
|
2017-12-16 07:32:08 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
// X returns the inner wrapped XML type.
|
2018-01-04 18:57:30 -06:00
|
|
|
func (n NumberingDefinition) X() *wml.CT_AbstractNum {
|
2017-12-16 07:32:08 -06:00
|
|
|
return n.x
|
|
|
|
}
|
|
|
|
|
|
|
|
// AbstractNumberID returns the ID that is unique within all numbering
|
|
|
|
// definitions that is used to assign the definition to a paragraph.
|
|
|
|
func (n NumberingDefinition) AbstractNumberID() int64 {
|
2018-01-04 18:57:30 -06:00
|
|
|
return n.x.AbstractNumIdAttr
|
2017-12-16 07:32:08 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
// Levels returns all of the numbering levels defined in the definition.
|
|
|
|
func (n NumberingDefinition) Levels() []NumberingLevel {
|
|
|
|
ret := []NumberingLevel{}
|
2018-01-04 18:57:30 -06:00
|
|
|
for _, nl := range n.x.Lvl {
|
2017-12-16 07:32:08 -06:00
|
|
|
ret = append(ret, NumberingLevel{nl})
|
|
|
|
}
|
|
|
|
return ret
|
|
|
|
}
|
|
|
|
|
|
|
|
// AddLevel adds a new numbering level to a NumberingDefinition.
|
|
|
|
func (n NumberingDefinition) AddLevel() NumberingLevel {
|
2018-01-04 18:57:30 -06:00
|
|
|
nl := wml.NewCT_Lvl()
|
2018-11-15 13:19:15 +01:00
|
|
|
nl.Start = &wml.CT_DecimalNumber{ValAttr: 1}
|
2018-01-04 18:57:30 -06:00
|
|
|
nl.IlvlAttr = int64(len(n.x.Lvl))
|
|
|
|
n.x.Lvl = append(n.x.Lvl, nl)
|
2017-12-16 07:32:08 -06:00
|
|
|
return NumberingLevel{nl}
|
|
|
|
}
|
2018-11-15 13:19:15 +01:00
|
|
|
|
|
|
|
// MultiLevelType returns the multilevel type, or ST_MultiLevelTypeUnset if not set.
|
|
|
|
func (n NumberingDefinition) MultiLevelType() wml.ST_MultiLevelType {
|
|
|
|
if n.x.MultiLevelType != nil {
|
|
|
|
return n.x.MultiLevelType.ValAttr
|
|
|
|
} else {
|
|
|
|
return wml.ST_MultiLevelTypeUnset
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// SetMultiLevelType sets the multilevel type.
|
|
|
|
func (n NumberingDefinition) SetMultiLevelType(t wml.ST_MultiLevelType) {
|
|
|
|
if t == wml.ST_MultiLevelTypeUnset {
|
|
|
|
n.x.MultiLevelType = nil
|
|
|
|
} else {
|
|
|
|
n.x.MultiLevelType = wml.NewCT_MultiLevelType()
|
|
|
|
n.x.MultiLevelType.ValAttr = t
|
|
|
|
}
|
|
|
|
}
|