2019-07-25 19:43:46 +03:00
|
|
|
// Copyright 2017 FoxyUtils ehf. All rights reserved.
|
2017-09-06 13:31:07 -04:00
|
|
|
//
|
|
|
|
// 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
|
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-21 02:21:00 +03:00
|
|
|
// commercial license can be purchased on https://unidoc.io.
|
2017-09-06 13:31:07 -04:00
|
|
|
|
|
|
|
package spreadsheet
|
|
|
|
|
|
|
|
import (
|
2019-05-04 11:18:06 +03:00
|
|
|
"github.com/unidoc/unioffice"
|
|
|
|
"github.com/unidoc/unioffice/color"
|
|
|
|
"github.com/unidoc/unioffice/measurement"
|
|
|
|
"github.com/unidoc/unioffice/schema/soo/sml"
|
2017-09-06 13:31:07 -04:00
|
|
|
)
|
|
|
|
|
|
|
|
// RichTextRun is a segment of text within a cell that is directly formatted.
|
|
|
|
type RichTextRun struct {
|
|
|
|
x *sml.CT_RElt
|
|
|
|
}
|
|
|
|
|
|
|
|
// X returns the inner wrapped XML type.
|
|
|
|
func (r RichTextRun) X() *sml.CT_RElt {
|
|
|
|
return r.x
|
|
|
|
}
|
|
|
|
|
|
|
|
// SetText sets the text to be displayed.
|
|
|
|
func (r RichTextRun) SetText(s string) {
|
|
|
|
r.x.T = s
|
|
|
|
}
|
|
|
|
|
|
|
|
func (r RichTextRun) ensureRpr() {
|
|
|
|
if r.x.RPr == nil {
|
|
|
|
r.x.RPr = sml.NewCT_RPrElt()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// SetBold causes the text to be displayed in bold.
|
|
|
|
func (r RichTextRun) SetBold(b bool) {
|
|
|
|
r.ensureRpr()
|
|
|
|
r.x.RPr.B = sml.NewCT_BooleanProperty()
|
2019-05-04 13:54:29 +00:00
|
|
|
r.x.RPr.B.ValAttr = unioffice.Bool(b)
|
2017-09-06 13:31:07 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
// SetColor sets the text color.
|
|
|
|
func (r RichTextRun) SetColor(c color.Color) {
|
|
|
|
r.ensureRpr()
|
|
|
|
r.x.RPr.Color = sml.NewCT_Color()
|
2020-06-18 04:43:35 +07:00
|
|
|
rgbAttr := "ff" + *c.AsRGBString()
|
|
|
|
r.x.RPr.Color.RgbAttr = &rgbAttr
|
2017-09-06 13:31:07 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
// SetItalic causes the text to be displayed in italic.
|
|
|
|
func (r RichTextRun) SetItalic(b bool) {
|
|
|
|
r.ensureRpr()
|
|
|
|
r.x.RPr.I = sml.NewCT_BooleanProperty()
|
2019-05-04 13:54:29 +00:00
|
|
|
r.x.RPr.I.ValAttr = unioffice.Bool(b)
|
2017-09-06 13:31:07 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
// SetUnderline controls if the run is underlined.
|
|
|
|
func (r RichTextRun) SetUnderline(u sml.ST_UnderlineValues) {
|
|
|
|
r.ensureRpr()
|
|
|
|
r.x.RPr.U = sml.NewCT_UnderlineProperty()
|
|
|
|
r.x.RPr.U.ValAttr = u
|
|
|
|
}
|
|
|
|
|
|
|
|
// SetSize sets the text size for a rich text run.
|
|
|
|
func (r RichTextRun) SetSize(m measurement.Distance) {
|
|
|
|
r.ensureRpr()
|
|
|
|
r.x.RPr.Sz = sml.NewCT_FontSize()
|
|
|
|
r.x.RPr.Sz.ValAttr = float64(m / measurement.Point)
|
|
|
|
}
|
|
|
|
|
|
|
|
// SetFont sets the font name for a rich text run.
|
|
|
|
func (r RichTextRun) SetFont(s string) {
|
|
|
|
r.ensureRpr()
|
|
|
|
r.x.RPr.RFont = sml.NewCT_FontName()
|
|
|
|
r.x.RPr.RFont.ValAttr = s
|
|
|
|
}
|