Bug 55967 - [PATCH] XSSFPicture method to resize with different scales in width and height
Summary: [PATCH] XSSFPicture method to resize with different scales in width and height
Status: RESOLVED FIXED
Alias: None
Product: POI
Classification: Unclassified
Component: XSSF (show other bugs)
Version: 3.9-FINAL
Hardware: PC Linux
: P2 enhancement (vote)
Target Milestone: ---
Assignee: POI Developers List
URL:
Keywords:
: 57634 (view as bug list)
Depends on:
Blocks:
 
Reported: 2014-01-07 17:33 UTC by Rafael Moreti Santana
Modified: 2015-02-25 14:45 UTC (History)
2 users (show)



Attachments
Java Class to resize XSSFPicture with two different scales (2.79 KB, text/x-java)
2014-01-07 17:33 UTC, Rafael Moreti Santana
Details
JUnit test of modified resize and getPreferredSize (3.96 KB, text/x-java)
2014-01-15 15:32 UTC, Rafael Moreti Santana
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Rafael Moreti Santana 2014-01-07 17:33:40 UTC
Created attachment 31178 [details]
Java Class to resize XSSFPicture with two different scales

Because XSSFPicture is a final class, this method calls the XSSFPicture and resize it with different scales. The method getPreferredSize was modified to allow two scales. Both method can be found in the attachment of this bug.
Comment 1 Nick Burch 2014-01-08 14:32:29 UTC
Any chance you could write up a unit test or two for this new functionality?
Comment 2 Rafael Moreti Santana 2014-01-14 11:42:22 UTC
Sorry, the JUnit tests are from the company and they can't be shared. There is any test framework you use that can be shared so we can generate tests and post it here?
Comment 3 Rafael Moreti Santana 2014-01-15 15:32:45 UTC
Created attachment 31209 [details]
JUnit test of modified resize and getPreferredSize
Comment 4 Rafael Moreti Santana 2014-01-15 15:34:05 UTC
Just add an attachment that contains a JUnit test of the modified method resize.
Comment 5 Andreas Beeker 2014-11-12 00:33:58 UTC
Thank you for the patch.
I've moved the code to the common model for HSSF/XSSF.
The resizing is now based on the anchor, i.e. relative on how the picture was displayed before in the sheet, and not anymore solely on the embedded image dimensions.
If one wants to scale relatively to the embedded image, the resize() method without parameters needs to be called before the actual resize() with a parameter.
The resizing gave different results with HSSF/XSSF before, so I think it's ok to generalize it now and make it relatively to the anchor.

Now the initial position (top left corner) is kept.

I haven't changed the side effect of getPreferredSize(), although it actually sets something in the picture instead of just returning a dimension ...

Applied with r1638623
Comment 6 Andreas Beeker 2015-02-25 14:45:16 UTC
*** Bug 57634 has been marked as a duplicate of this bug. ***