From 772e84a752a58b410e8836183fd4fdc10057bbab Mon Sep 17 00:00:00 2001 From: Javen O'Neal Date: Fri, 17 Jun 2016 02:12:05 +0000 Subject: [PATCH] bug 59170: remove deprecated o.a.p.hwpf.usermodel.Pictures methods; add version when deprecated to javadoc git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1748790 13f79535-47bb-0310-9956-ffa450edef68 --- .../apache/poi/hwpf/usermodel/Picture.java | 50 +++---------------- .../poi/hwpf/usermodel/TestPictures.java | 7 +-- 2 files changed, 8 insertions(+), 49 deletions(-) diff --git a/src/scratchpad/src/org/apache/poi/hwpf/usermodel/Picture.java b/src/scratchpad/src/org/apache/poi/hwpf/usermodel/Picture.java index 670755dbf5..4a4ed2680f 100644 --- a/src/scratchpad/src/org/apache/poi/hwpf/usermodel/Picture.java +++ b/src/scratchpad/src/org/apache/poi/hwpf/usermodel/Picture.java @@ -44,38 +44,16 @@ import org.apache.poi.util.StringUtil; */ public final class Picture { - @Deprecated - public static final byte[] BMP = new byte[] { 'B', 'M' }; - public static final byte[] COMPRESSED1 = { (byte) 0xFE, 0x78, (byte) 0xDA }; public static final byte[] COMPRESSED2 = { (byte) 0xFE, 0x78, (byte) 0x9C }; - @Deprecated - public static final byte[] EMF = { 0x01, 0x00, 0x00, 0x00 }; - - @Deprecated - public static final byte[] GIF = new byte[] { 'G', 'I', 'F' }; public static final byte[] IHDR = new byte[] { 'I', 'H', 'D', 'R' }; - @Deprecated - public static final byte[] JPG = new byte[] { (byte) 0xFF, (byte) 0xD8 }; private static final POILogger log = POILogFactory .getLogger( Picture.class ); @Deprecated - public static final byte[] PNG = new byte[] { (byte) 0x89, 0x50, 0x4E, + private static final byte[] PNG = new byte[] { (byte) 0x89, 0x50, 0x4E, 0x47, 0x0D, 0x0A, 0x1A, 0x0A }; - @Deprecated - public static final byte[] TIFF = new byte[] { 0x49, 0x49, 0x2A, 0x00 }; - - @Deprecated - public static final byte[] TIFF1 = new byte[] { 0x4D, 0x4D, 0x00, 0x2A }; - @Deprecated - public static final byte[] WMF1 = { (byte) 0xD7, (byte) 0xCD, (byte) 0xC6, - (byte) 0x9A, 0x00, 0x00 }; - // Windows 3.x - @Deprecated - public static final byte[] WMF2 = { 0x01, 0x00, 0x09, 0x00, 0x00, 0x03 }; // Windows - // 3.x private static int getBigEndianInt( byte[] data, int offset ) { @@ -209,7 +187,7 @@ public final class Picture /* * http://www.codecomments.com/archive281-2004-3-158083.html * - * Algorhitm proposed by Patrick TJ McPhee: + * Algorithm proposed by Patrick TJ McPhee: * * read 2 bytes make sure they are 'ffd8'x repeatedly: read 2 bytes make * sure the first one is 'ff'x if the second one is 'd9'x stop else if @@ -302,26 +280,6 @@ public final class Picture } } - /** - * @return the horizontal aspect ratio for picture provided by user - * @deprecated use more precise {@link #getHorizontalScalingFactor()} - */ - @Deprecated - public int getAspectRatioX() - { - return _picf.getMx() / 10; - } - - /** - * @return the vertical aspect ratio for picture provided by user - * @deprecated use more precise {@link #getVerticalScalingFactor()} - */ - @Deprecated - public int getAspectRatioY() - { - return _picf.getMy() / 10; - } - /** * @return picture's content as byte array */ @@ -333,6 +291,7 @@ public final class Picture /** * @return The amount the picture has been cropped on the left in twips + * @deprecated POI 3.8 beta 4. */ @Deprecated public int getDxaCropLeft() @@ -360,6 +319,7 @@ public final class Picture /** * @return The amount the picture has been cropped on the right in twips + * @deprecated POI 3.8 beta 4. */ @Deprecated public int getDxaCropRight() @@ -380,6 +340,7 @@ public final class Picture /** * @return The amount the picture has been cropped on the bottom in twips + * @deprecated POI 3.8 beta 5. */ @Deprecated public int getDyaCropBottom() @@ -389,6 +350,7 @@ public final class Picture /** * @return The amount the picture has been cropped on the top in twips + * @deprecated POI 3.8 beta 5. */ @Deprecated public int getDyaCropTop() diff --git a/src/scratchpad/testcases/org/apache/poi/hwpf/usermodel/TestPictures.java b/src/scratchpad/testcases/org/apache/poi/hwpf/usermodel/TestPictures.java index d1d340433c..f60b010ef7 100644 --- a/src/scratchpad/testcases/org/apache/poi/hwpf/usermodel/TestPictures.java +++ b/src/scratchpad/testcases/org/apache/poi/hwpf/usermodel/TestPictures.java @@ -315,9 +315,8 @@ public final class TestPictures { assertEquals(2, pics.size()); Picture pic1 = pics.get(0); - assertEquals(27, pic1.getAspectRatioX()); + assertEquals("FIXME: unable to get image width", -1, pic1.getWidth()); assertEquals(270, pic1.getHorizontalScalingFactor()); - assertEquals(27, pic1.getAspectRatioY()); assertEquals(271, pic1.getVerticalScalingFactor()); assertEquals(12000, pic1.getDxaGoal()); // 21.17 cm / 2.54 cm/inch * 72dpi * 20 = 12000 assertEquals(9000, pic1.getDyaGoal()); // 15.88 cm / 2.54 cm/inch * 72dpi * 20 = 9000 @@ -327,10 +326,8 @@ public final class TestPictures { assertEquals(0, pic1.getDyaCropBottom()); Picture pic2 = pics.get(1); - System.out.println(pic2.getWidth()); - assertEquals(76, pic2.getAspectRatioX()); + assertEquals("FIXME: unable to get image width", -1, pic2.getWidth()); assertEquals(764, pic2.getHorizontalScalingFactor()); - assertEquals(68, pic2.getAspectRatioY()); assertEquals(685, pic2.getVerticalScalingFactor()); assertEquals(12000, pic2.getDxaGoal()); // 21.17 cm / 2.54 cm/inch * 72dpi * 20 = 12000 assertEquals(9000, pic2.getDyaGoal()); // 15.88 cm / 2.54 cm/inch * 72dpi * 20 = 9000 -- 2.39.5