mirror of
https://github.com/fumiama/go-docx.git
synced 2026-06-29 07:30:23 +08:00
add AddInlineDrawingFrom
This commit is contained in:
29
media.go
Normal file
29
media.go
Normal file
@@ -0,0 +1,29 @@
|
||||
package docxlib
|
||||
|
||||
const MEDIA_FOLDER = `word/media/`
|
||||
|
||||
// Media is in word/media
|
||||
type Media struct {
|
||||
Name string // Name is for word/media/Name
|
||||
Data []byte // Data is data of this media
|
||||
}
|
||||
|
||||
// String is the full path of the media
|
||||
func (m *Media) String() string {
|
||||
return MEDIA_FOLDER + m.Name
|
||||
}
|
||||
|
||||
// Media get media struct pointer (or nil on notfound) by name
|
||||
func (f *Docx) Media(name string) *Media {
|
||||
i, ok := f.mediaNameIdx[name]
|
||||
if !ok {
|
||||
return nil
|
||||
}
|
||||
return &f.media[i]
|
||||
}
|
||||
|
||||
// addMedia append the media to docx's media list
|
||||
func (f *Docx) addMedia(m Media) {
|
||||
f.mediaNameIdx[m.Name] = len(f.media)
|
||||
f.media = append(f.media, m)
|
||||
}
|
||||
Reference in New Issue
Block a user