unioffice/document/paragraphspacing.go
Vyacheslav Zgordan dd7713e1e3 Functions2 (#348)
* MATCH, IFS, MAXA, MINA
* OFFSET fixed
* ISBLANK, ISERR, ISERROR, ISEVEN ,ISFORMULA, ISNONTEXT, ISNUMBER, ISODD, ISTEXT
* ISLEAPYEAR, ISLOGICAL, ISNA, ISREF
* FIND, FINDB
* SEARCH, SEARCHB
* CONCAT, CONCATENATE
* YEAR, YEARFRAC
* CONCAT is fixed, now TRUE and FALSE are concatenated instead of 1 and 0 in case of boolean results
* NOW, TODAY, TIME, TIMEVALUE
* DATE
* DATEDIF
2019-11-20 23:21:00 +00:00

65 lines
2.2 KiB
Go

// Copyright 2018 FoxyUtils ehf. 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 on https://unidoc.io.
package document
import (
"github.com/unidoc/unioffice"
"github.com/unidoc/unioffice/measurement"
"github.com/unidoc/unioffice/schema/soo/ofc/sharedTypes"
"github.com/unidoc/unioffice/schema/soo/wml"
)
// ParagraphSpacing controls the spacing for a paragraph and its lines.
type ParagraphSpacing struct {
x *wml.CT_Spacing
}
// SetBefore sets the spacing that comes before the paragraph.
func (p ParagraphSpacing) SetBefore(before measurement.Distance) {
p.x.BeforeAttr = &sharedTypes.ST_TwipsMeasure{}
p.x.BeforeAttr.ST_UnsignedDecimalNumber = unioffice.Uint64(uint64(before / measurement.Twips))
}
// SetAfter sets the spacing that comes after the paragraph.
func (p ParagraphSpacing) SetAfter(after measurement.Distance) {
p.x.AfterAttr = &sharedTypes.ST_TwipsMeasure{}
p.x.AfterAttr.ST_UnsignedDecimalNumber = unioffice.Uint64(uint64(after / measurement.Twips))
}
// SetLineSpacing sets the spacing between lines in a paragraph.
func (p ParagraphSpacing) SetLineSpacing(d measurement.Distance, rule wml.ST_LineSpacingRule) {
if rule == wml.ST_LineSpacingRuleUnset {
p.x.LineRuleAttr = wml.ST_LineSpacingRuleUnset
p.x.LineAttr = nil
} else {
p.x.LineRuleAttr = rule
p.x.LineAttr = &wml.ST_SignedTwipsMeasure{}
p.x.LineAttr.Int64 = unioffice.Int64(int64(d / measurement.Twips))
}
}
// SetBeforeAuto controls if spacing before a paragraph is automatically determined.
func (p ParagraphSpacing) SetBeforeAuto(b bool) {
if b {
p.x.BeforeAutospacingAttr = &sharedTypes.ST_OnOff{}
p.x.BeforeAutospacingAttr.Bool = unioffice.Bool(true)
} else {
p.x.BeforeAutospacingAttr = nil
}
}
// SetAfterAuto controls if spacing after a paragraph is automatically determined.
func (p ParagraphSpacing) SetAfterAuto(b bool) {
if b {
p.x.AfterAutospacingAttr = &sharedTypes.ST_OnOff{}
p.x.AfterAutospacingAttr.Bool = unioffice.Bool(true)
} else {
p.x.AfterAutospacingAttr = nil
}
}