summaryrefslogtreecommitdiff
path: root/picture.go
diff options
context:
space:
mode:
authorxuri <xuri.me@gmail.com>2021-07-04 12:13:06 +0800
committerxuri <xuri.me@gmail.com>2021-07-04 12:13:06 +0800
commit0e02329bedf6648259fd219642bb907bdb07fd21 (patch)
tree16551d2174313dad46c3e276a6e27ffee5213bda /picture.go
parent5ec61310dc55c9af93d66e6d225f721738416d1f (diff)
This closes #861, support concurrency get cell picture and remove unused internal function `getSheetNameByID`
Diffstat (limited to 'picture.go')
-rw-r--r--picture.go20
1 files changed, 11 insertions, 9 deletions
diff --git a/picture.go b/picture.go
index 052ec83..09283c8 100644
--- a/picture.go
+++ b/picture.go
@@ -189,7 +189,7 @@ func (f *File) deleteSheetRelationships(sheet, rID string) {
sheetRels.Relationships = append(sheetRels.Relationships[:k], sheetRels.Relationships[k+1:]...)
}
}
- f.Relationships[rels] = sheetRels
+ f.Relationships.Store(rels, sheetRels)
}
// addSheetLegacyDrawing provides a function to add legacy drawing element to
@@ -228,11 +228,12 @@ func (f *File) countDrawings() int {
c1++
}
}
- for rel := range f.Drawings {
- if strings.Contains(rel, "xl/drawings/drawing") {
+ f.Drawings.Range(func(rel, value interface{}) bool {
+ if strings.Contains(rel.(string), "xl/drawings/drawing") {
c2++
}
- }
+ return true
+ })
if c1 < c2 {
return c2
}
@@ -296,7 +297,7 @@ func (f *File) addDrawingPicture(sheet, drawingXML, cell, file string, width, he
FPrintsWithSheet: formatSet.FPrintsWithSheet,
}
content.TwoCellAnchor = append(content.TwoCellAnchor, &twoCellAnchor)
- f.Drawings[drawingXML] = content
+ f.Drawings.Store(drawingXML, content)
return err
}
@@ -582,12 +583,13 @@ func (f *File) getDrawingRelationships(rels, rID string) *xlsxRelationship {
// drawingsWriter provides a function to save xl/drawings/drawing%d.xml after
// serialize structure.
func (f *File) drawingsWriter() {
- for path, d := range f.Drawings {
+ f.Drawings.Range(func(path, d interface{}) bool {
if d != nil {
- v, _ := xml.Marshal(d)
- f.saveFileList(path, v)
+ v, _ := xml.Marshal(d.(*xlsxWsDr))
+ f.saveFileList(path.(string), v)
}
- }
+ return true
+ })
}
// drawingResize calculate the height and width after resizing.