1
0
mirror of https://github.com/fumiama/go-docx.git synced 2026-06-27 14:40:24 +08:00

优化代码结构

This commit is contained in:
源文雨
2023-02-08 16:19:09 +08:00
parent d8f39cecf1
commit 7ff4850504
16 changed files with 153 additions and 114 deletions

View File

@@ -1,18 +1,19 @@
package docxlib
import "strconv"
import (
"strconv"
"sync/atomic"
)
// when adding an hyperlink we need to store a reference in the relationship field
func (f *DocxLib) addLinkRelation(link string) string {
func (f *Docx) addLinkRelation(link string) string {
rel := &Relationship{
ID: "rId" + strconv.Itoa(f.rId),
ID: "rId" + strconv.Itoa(int(atomic.AddUintptr(&f.rId, 1))),
Type: REL_HYPERLINK,
Target: link,
TargetMode: REL_TARGETMODE,
}
f.rId += 1
f.DocRelation.Relationships = append(f.DocRelation.Relationships, rel)
return rel.ID