You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@poi.apache.org by bu...@apache.org on 2022/12/05 08:27:12 UTC
[Bug 66377] New: The x coordinate value of the anchor point in the lower right corner of the image exceeds the width value of the cell
https://bz.apache.org/bugzilla/show_bug.cgi?id=66377
Bug ID: 66377
Summary: The x coordinate value of the anchor point in the
lower right corner of the image exceeds the width
value of the cell
Product: POI
Version: unspecified
Hardware: PC
Status: NEW
Severity: normal
Priority: P2
Component: SS Common
Assignee: dev@poi.apache.org
Reporter: zhangjy@cn.ibm.com
Target Milestone: ---
Created attachment 38443
--> https://bz.apache.org/bugzilla/attachment.cgi?id=38443&action=edit
debug data
I'm trying to figure out how far an image is from the padding of the cell it's
in. Currently I want to calculate the difference by the top left and bottom
right anchor coordinates of the image and the width and height of the cell the
image is in.
But I found a problem when calculating the x-coordinate of the bottom right
corner of the image and the width of the cell.
When the lower right corner of the picture is close to the right side of the
cell, the value of the x coordinate will be greater than the width of the cell,
but in fact the whole picture is inside the cell.
For details, please refer to the contents of the attachment.
The following piece of code is the part that I think has a problem with the
calculation.
Cariable dim(the cell width) is smaller than variable endD(the x-coordinate of
the bottom right corner)
org.apache.poi.ss.util.ImageUtils
private static int getDimFromCell(double imgSize, int startCell, int
startD, int endCell, int endD, int hssfUnits,
Function<Integer,Number> nextSize) {
double targetSize;
if (endCell < startCell) {
targetSize = imgSize * EMU_PER_PIXEL;
} else {
targetSize = 0;
for (int cellIdx = startCell; cellIdx<=endCell; cellIdx++) {
final double dim = nextSize.apply(cellIdx).doubleValue() *
EMU_PER_PIXEL;
double leadSpace = 0;
if (cellIdx == startCell) {
//space in the leftmost cell
leadSpace = (hssfUnits > 0)
? dim * startD/(double)hssfUnits
: startD;
}
double trailSpace = 0;
if (cellIdx == endCell) {
// space after the rightmost cell
trailSpace = (hssfUnits > 0)
? dim * (hssfUnits-endD)/(double)hssfUnits
: dim - endD;
}
targetSize += dim - leadSpace - trailSpace;
}
}
return (int)Math.rint(targetSize);
}
}
--
You are receiving this mail because:
You are the assignee for the bug.
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@poi.apache.org
For additional commands, e-mail: dev-help@poi.apache.org
[Bug 66377] The x coordinate value of the anchor point in the lower right corner of the image exceeds the width value of the cell
Posted by bu...@apache.org.
https://bz.apache.org/bugzilla/show_bug.cgi?id=66377
Dominik Stadler <do...@gmx.at> changed:
What |Removed |Added
----------------------------------------------------------------------------
OS| |All
--
You are receiving this mail because:
You are the assignee for the bug.
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@poi.apache.org
For additional commands, e-mail: dev-help@poi.apache.org