Skip to content

Commit bfa81ac

Browse files
committed
This closes qax-os#2234, allowing insert ICO format images
1 parent 3d23585 commit bfa81ac

File tree

5 files changed

+16
-15
lines changed

5 files changed

+16
-15
lines changed

picture.go

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -63,11 +63,11 @@ func parseGraphicOptions(opts *GraphicOptions) *GraphicOptions {
6363

6464
// AddPicture provides the method to add picture in a sheet by given picture
6565
// format set (such as offset, scale, aspect ratio setting and print settings)
66-
// and file path, supported image types: BMP, EMF, EMZ, GIF, JPEG, JPG, PNG,
67-
// SVG, TIF, TIFF, WMF, and WMZ. This function is concurrency-safe. Note that
68-
// this function only supports adding pictures placed over the cells currently,
69-
// and doesn't support adding pictures placed in cells or creating the Kingsoft
70-
// WPS Office embedded image cells. For example:
66+
// and file path, supported image types: BMP, EMF, EMZ, GIF, ICO, JPEG, JPG,
67+
// PNG, SVG, TIF, TIFF, WMF, and WMZ. This function is concurrency-safe. Note
68+
// that this function only supports adding pictures placed over the cells
69+
// currently, and doesn't support adding pictures placed in cells or creating
70+
// the Kingsoft WPS Office embedded image cells. For example:
7171
//
7272
// package main
7373
//
@@ -186,10 +186,10 @@ func (f *File) AddPicture(sheet, cell, name string, opts *GraphicOptions) error
186186
// AddPictureFromBytes provides the method to add picture in a sheet by given
187187
// picture format set (such as offset, scale, aspect ratio setting and print
188188
// settings), file base name, extension name and file bytes, supported image
189-
// types: EMF, EMZ, GIF, JPEG, JPG, PNG, SVG, TIF, TIFF, WMF, and WMZ. Note that
190-
// this function only supports adding pictures placed over the cells currently,
191-
// and doesn't support adding pictures placed in cells or creating the Kingsoft
192-
// WPS Office embedded image cells. For example:
189+
// types: EMF, EMZ, GIF, ICO, JPEG, JPG, PNG, SVG, TIF, TIFF, WMF, and WMZ. Note
190+
// that this function only supports adding pictures placed over the cells
191+
// currently, and doesn't support adding pictures placed in cells or creating
192+
// the Kingsoft WPS Office embedded image cells. For example:
193193
//
194194
// package main
195195
//

sheet.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -527,7 +527,7 @@ func (f *File) getSheetXMLPath(sheet string) (string, bool) {
527527
}
528528

529529
// SetSheetBackground provides a function to set background picture by given
530-
// worksheet name and file path. Supported image types: BMP, EMF, EMZ, GIF,
530+
// worksheet name and file path. Supported image types: BMP, EMF, EMZ, GIF, ICO,
531531
// JPEG, JPG, PNG, SVG, TIF, TIFF, WMF, and WMZ.
532532
func (f *File) SetSheetBackground(sheet, picture string) error {
533533
var err error
@@ -541,7 +541,7 @@ func (f *File) SetSheetBackground(sheet, picture string) error {
541541

542542
// SetSheetBackgroundFromBytes provides a function to set background picture by
543543
// given worksheet name, extension name and image data. Supported image types:
544-
// BMP, EMF, EMZ, GIF, JPEG, JPG, PNG, SVG, TIF, TIFF, WMF, and WMZ.
544+
// BMP, EMF, EMZ, GIF, ICO, JPEG, JPG, PNG, SVG, TIF, TIFF, WMF, and WMZ.
545545
func (f *File) SetSheetBackgroundFromBytes(sheet, extension string, picture []byte) error {
546546
if len(picture) == 0 {
547547
return ErrParameterInvalid

templates.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -492,8 +492,9 @@ var supportedDefinedNameAfterStartCharCodeRange = []int{
492492
// supportedImageTypes defined supported image types.
493493
var supportedImageTypes = map[string]string{
494494
".bmp": ".bmp", ".emf": ".emf", ".emz": ".emz", ".gif": ".gif",
495-
".jpeg": ".jpeg", ".jpg": ".jpeg", ".png": ".png", ".svg": ".svg",
496-
".tif": ".tiff", ".tiff": ".tiff", ".wmf": ".wmf", ".wmz": ".wmz",
495+
".ico": ".ico", ".jpeg": ".jpeg", ".jpg": ".jpeg", ".png": ".png",
496+
".svg": ".svg", ".tif": ".tiff", ".tiff": ".tiff", ".wmf": ".wmf",
497+
".wmz": ".wmz",
497498
}
498499

499500
// supportedCalcMode defined supported formula calculate mode.

vml.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1110,7 +1110,7 @@ func extractVMLFont(font []decodeVMLFont) []RichTextRun {
11101110

11111111
// AddHeaderFooterImage provides a mechanism to set the graphics that can be
11121112
// referenced in the header and footer definitions via &G, supported image
1113-
// types: EMF, EMZ, GIF, JPEG, JPG, PNG, SVG, TIF, TIFF, WMF, and WMZ.
1113+
// types: EMF, EMZ, GIF, ICO, JPEG, JPG, PNG, SVG, TIF, TIFF, WMF, and WMZ.
11141114
//
11151115
// The extension should be provided with a "." in front, e.g. ".png".
11161116
// The width and height should have units in them, e.g. "100pt".

workbook.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -310,7 +310,7 @@ func (f *File) setContentTypePartRelsExtensions() error {
310310
// for relationship parts and the Main Document part.
311311
func (f *File) setContentTypePartImageExtensions() error {
312312
imageTypes := map[string]string{
313-
"bmp": "image/", "jpeg": "image/", "png": "image/", "gif": "image/",
313+
"bmp": "image/", "ico": "image/x-", "jpeg": "image/", "png": "image/", "gif": "image/",
314314
"svg": "image/", "tiff": "image/", "emf": "image/x-", "wmf": "image/x-",
315315
"emz": "image/x-", "wmz": "image/x-",
316316
}

0 commit comments

Comments
 (0)