Skip to content

Commit

Permalink
feat: 完善Num设置
Browse files Browse the repository at this point in the history
  • Loading branch information
guoqiang committed Dec 23, 2024
1 parent b2ba179 commit 7f2acfd
Showing 1 changed file with 38 additions and 2 deletions.
40 changes: 38 additions & 2 deletions apipara.go
Original file line number Diff line number Diff line change
Expand Up @@ -80,14 +80,50 @@ func (p *Paragraph) Style(val string) *Paragraph {
}

// NumPr number properties
func (p *Paragraph) NumPr(val string) *Paragraph {
func (p *Paragraph) NumPr(numId, ilvl string) *Paragraph {
if p.Properties == nil {
p.Properties = &ParagraphProperties{}
}
// Initialize run properties if not exist
if p.Properties.RunProperties == nil {
p.Properties.RunProperties = &RunProperties{}
}
p.Properties.NumProperties = &NumProperties{
NumId: &NumId{
Val: val,
Val: numId,
},
Ilvl: &Ilevel{
Val: ilvl,
},
}
return p
}

// NumFont sets the font for numbering
func (p *Paragraph) NumFont(ascii, eastAsia, hansi, hint string) *Paragraph {
if p.Properties == nil {
p.Properties = &ParagraphProperties{}
}
if p.Properties.RunProperties == nil {
p.Properties.RunProperties = &RunProperties{}
}
p.Properties.RunProperties.Fonts = &RunFonts{
ASCII: ascii,
EastAsia: eastAsia,
HAnsi: hansi,
Hint: hint,
}
return p
}

// NumSize sets the size for numbering
func (p *Paragraph) NumSize(size string) *Paragraph {
if p.Properties == nil {
p.Properties = &ParagraphProperties{}
}
if p.Properties.RunProperties == nil {
p.Properties.RunProperties = &RunProperties{}
}
p.Properties.RunProperties.Size = &Size{Val: size}
return p
}

0 comments on commit 7f2acfd

Please sign in to comment.