diff --git a/col.go b/col.go index 72db4be907..5af4302c75 100644 --- a/col.go +++ b/col.go @@ -556,26 +556,7 @@ func flatCols(col xlsxCol, cols []xlsxCol, replacer func(fc, c xlsxCol) xlsxCol) // width # Width of object frame. // height # Height of object frame. // -// xAbs # Absolute distance to left side of object. -// yAbs # Absolute distance to top side of object. -// -func (f *File) positionObjectPixels(sheet string, col, row, x1, y1, width, height int) (int, int, int, int, int, int, int, int) { - xAbs := 0 - yAbs := 0 - - // Calculate the absolute x offset of the top-left vertex. - for colID := 1; colID <= col; colID++ { - xAbs += f.getColWidth(sheet, colID) - } - xAbs += x1 - - // Calculate the absolute y offset of the top-left vertex. - // Store the column change to allow optimisations. - for rowID := 1; rowID <= row; rowID++ { - yAbs += f.getRowHeight(sheet, rowID) - } - yAbs += y1 - +func (f *File) positionObjectPixels(sheet string, col, row, x1, y1, width, height int) (int, int, int, int, int, int) { // Adjust start column for offsets that are greater than the col width. for x1 >= f.getColWidth(sheet, col) { x1 -= f.getColWidth(sheet, col) @@ -610,7 +591,7 @@ func (f *File) positionObjectPixels(sheet string, col, row, x1, y1, width, heigh // The end vertices are whatever is left from the width and height. x2 := width y2 := height - return col, row, xAbs, yAbs, colEnd, rowEnd, x2, y2 + return col, row, colEnd, rowEnd, x2, y2 } // getColWidth provides a function to get column width in pixels by given diff --git a/drawing.go b/drawing.go index 6c2f6357f5..913a7456d2 100644 --- a/drawing.go +++ b/drawing.go @@ -1180,7 +1180,7 @@ func (f *File) addDrawingChart(sheet, drawingXML, cell string, width, height, rI width = int(float64(width) * formatSet.XScale) height = int(float64(height) * formatSet.YScale) - colStart, rowStart, _, _, colEnd, rowEnd, x2, y2 := + colStart, rowStart, colEnd, rowEnd, x2, y2 := f.positionObjectPixels(sheet, colIdx, rowIdx, formatSet.OffsetX, formatSet.OffsetY, width, height) content, cNvPrID := f.drawingParser(drawingXML) twoCellAnchor := xdrCellAnchor{} diff --git a/picture.go b/picture.go index 9a646379c3..2f685ffa6e 100644 --- a/picture.go +++ b/picture.go @@ -259,7 +259,7 @@ func (f *File) addDrawingPicture(sheet, drawingXML, cell, file string, width, he } col-- row-- - colStart, rowStart, _, _, colEnd, rowEnd, x2, y2 := + colStart, rowStart, colEnd, rowEnd, x2, y2 := f.positionObjectPixels(sheet, col, row, formatSet.OffsetX, formatSet.OffsetY, width, height) content, cNvPrID := f.drawingParser(drawingXML) twoCellAnchor := xdrCellAnchor{} diff --git a/shape.go b/shape.go index 0a5164b4a1..2600e901f6 100644 --- a/shape.go +++ b/shape.go @@ -324,7 +324,7 @@ func (f *File) addDrawingShape(sheet, drawingXML, cell string, formatSet *format width := int(float64(formatSet.Width) * formatSet.Format.XScale) height := int(float64(formatSet.Height) * formatSet.Format.YScale) - colStart, rowStart, _, _, colEnd, rowEnd, x2, y2 := + colStart, rowStart, colEnd, rowEnd, x2, y2 := f.positionObjectPixels(sheet, colIdx, rowIdx, formatSet.Format.OffsetX, formatSet.Format.OffsetY, width, height) content, cNvPrID := f.drawingParser(drawingXML)