1
0
mirror of https://github.com/fumiama/go-docx.git synced 2026-06-12 11:40:28 +08:00

House cleaning

This commit is contained in:
Gonzalo Fernandez-Victorio
2021-04-29 17:38:39 +01:00
parent eae5f90385
commit c821a33692
16 changed files with 159 additions and 144 deletions

38
link.go
View File

@@ -1,38 +0,0 @@
package docxlib
import "strconv"
func (f *Docx) addLinkRelation(link string) string {
rel := &Relationship{
ID: "rId" + strconv.Itoa(f.rId),
Type: REL_HYPERLINK,
Target: link,
TargetMode: REL_TARGETMODE,
}
f.rId += 1
f.DocRelation.Relationships = append(f.DocRelation.Relationships, rel)
return rel.ID
}
// AddLink add hyperlink to paragraph
func (p *Paragraph) AddLink(text string, link string) *Hyperlink {
rId := p.file.addLinkRelation(link)
hyperlink := &Hyperlink{
ID: rId,
Run: Run{
RunProperties: &RunProperties{
RunStyle: &RunStyle{
Val: HYPERLINK_STYLE,
},
},
InstrText: text,
},
}
p.Data = append(p.Data, ParagraphChild{Link: hyperlink})
return hyperlink
}