Bug 65709 - addOlePackage Add a picture object double click picture will deform
Summary: addOlePackage Add a picture object double click picture will deform
Status: RESOLVED WONTFIX
Alias: None
Product: POI
Classification: Unclassified
Component: XSSF (show other bugs)
Version: 5.0.0-FINAL
Hardware: PC All
: P2 normal (vote)
Target Milestone: ---
Assignee: POI Developers List
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2021-11-29 09:24 UTC by buckwheat
Modified: 2021-11-29 12:44 UTC (History)
0 users



Attachments
Excel picture (32.86 KB, image/png)
2021-11-29 09:24 UTC, buckwheat
Details

Note You need to log in before you can comment on or make changes to this bug.
Description buckwheat 2021-11-29 09:24:55 UTC
Created attachment 38105 [details]
Excel picture

i want to insert a picture object can directly double-click to open
about OLE using apache-poi, 
XSSFWorkbook().addOlePackage(data, "test", "test.png", "test.png");
Function can be used normally,but 
After the attachment is clicked, a new thumbnail will be generated according to the program that opens the attachment on the computer where it is located to replace the display thumbnail I set, and the image will also be deformed.
I want to know how this problem can be solved,thanks~
Comment 1 Andreas Beeker 2021-11-29 12:44:31 UTC
There's no way to stop Office to replace the embedded package manager symbol.
The deformation of the icon is based on the replaced image and different dimension of it.
So try one of ...
* set AnchorType to MOVE_DONT_RESIZE
* invest time in creating a icon close to the one a double-click would generate and set  * or check, if the shape can be added via an OneCellAnchor.

So instead of ...

> final int oleIdx = wb.addOlePackage(content.getBytes(), objectName, objectName + fileExtension, objectName + fileExtension);
> final Drawing<?> pat = sheet.createDrawingPatriarch();
> final ClientAnchor anchor = pat.createAnchor(0, 0, 0, 0, colNo, rowNo, colNo + 1, rowNo + 2);//tweak cell ranges to minimize image distortion
> anchor.setAnchorType(ClientAnchor.AnchorType.MOVE_AND_RESIZE);

... you/we need to check how to attach a OneCellAnchor [1]


I close this issue now, as this belongs better in the  mailing list

[1] https://c-rex.net/projects/samples/ooxml/e1/Part4/OOXML_P4_DOCX_oneCellAnchor_topic_ID0EYKLPB.html