From 6c0ac68e05e397cc753703cc5ccb174a9fa1a0a5 Mon Sep 17 00:00:00 2001 From: PJ Fanning Date: Mon, 23 Oct 2017 20:27:47 +0000 Subject: [PATCH] Remove more deprecated code git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1813085 13f79535-47bb-0310-9956-ffa450edef68 --- src/java/org/apache/poi/util/TempFile.java | 5 -- .../poi/xssf/usermodel/TestXSSFCellStyle.java | 3 + .../poi/hwpf/model/BytePropertyNode.java | 24 +------- .../src/org/apache/poi/hwpf/model/CHPX.java | 60 +++++++------------ .../poi/hwpf/model/CharIndexTranslator.java | 26 -------- .../poi/hwpf/model/PAPFormattedDiskPage.java | 26 +------- .../src/org/apache/poi/hwpf/model/PAPX.java | 19 ------ .../poi/hssf/usermodel/TestHSSFPalette.java | 6 ++ .../apache/poi/ss/util/BaseTestCellUtil.java | 25 +------- 9 files changed, 35 insertions(+), 159 deletions(-) diff --git a/src/java/org/apache/poi/util/TempFile.java b/src/java/org/apache/poi/util/TempFile.java index ceb7c1d1c..e0a2eaca2 100644 --- a/src/java/org/apache/poi/util/TempFile.java +++ b/src/java/org/apache/poi/util/TempFile.java @@ -69,9 +69,4 @@ public final class TempFile { public static File createTempDirectory(String name) throws IOException { return strategy.createTempDirectory(name); } - - /** - * @deprecated POI 3.15 beta 3. Moved to {@link org.apache.poi.util.DefaultTempFileCreationStrategy}. - */ - public static class DefaultTempFileCreationStrategy extends org.apache.poi.util.DefaultTempFileCreationStrategy {} } diff --git a/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFCellStyle.java b/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFCellStyle.java index 1b1c84270..d7b632f38 100644 --- a/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFCellStyle.java +++ b/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFCellStyle.java @@ -571,6 +571,7 @@ public class TestXSSFCellStyle { } @Test + @SuppressWarnings("deprecation") public void testGetFillForegroundColor() throws IOException { XSSFWorkbook wb = new XSSFWorkbook(); StylesTable styles = wb.getStylesSource(); @@ -581,11 +582,13 @@ public class TestXSSFCellStyle { assertEquals(IndexedColors.AUTOMATIC.getIndex(), defaultStyle.getFillForegroundColor()); assertEquals(null, defaultStyle.getFillForegroundXSSFColor()); assertEquals(FillPatternType.NO_FILL, defaultStyle.getFillPattern()); + assertEquals(FillPatternType.NO_FILL, defaultStyle.getFillPatternEnum()); XSSFCellStyle customStyle = wb.createCellStyle(); customStyle.setFillPattern(FillPatternType.SOLID_FOREGROUND); assertEquals(FillPatternType.SOLID_FOREGROUND, customStyle.getFillPattern()); + assertEquals(FillPatternType.SOLID_FOREGROUND, customStyle.getFillPatternEnum()); assertEquals(3, styles.getFills().size()); customStyle.setFillForegroundColor(IndexedColors.BRIGHT_GREEN.getIndex()); diff --git a/src/scratchpad/src/org/apache/poi/hwpf/model/BytePropertyNode.java b/src/scratchpad/src/org/apache/poi/hwpf/model/BytePropertyNode.java index d0bf3ef33..f0fe0711e 100644 --- a/src/scratchpad/src/org/apache/poi/hwpf/model/BytePropertyNode.java +++ b/src/scratchpad/src/org/apache/poi/hwpf/model/BytePropertyNode.java @@ -30,28 +30,8 @@ package org.apache.poi.hwpf.model; public abstract class BytePropertyNode> extends PropertyNode { - private final int startBytes; - private final int endBytes; - - /** - * @param fcStart The start of the text for this property, in _bytes_ - * @param fcEnd The end of the text for this property, in _bytes_ - * @deprecated - */ - public BytePropertyNode(int fcStart, int fcEnd, CharIndexTranslator translator, Object buf) { - super( - translator.getCharIndex(fcStart), - translator.getCharIndex(fcEnd, translator.getCharIndex(fcStart)), - buf - ); - - if ( fcStart > fcEnd ) - throw new IllegalArgumentException( "fcStart (" + fcStart - + ") > fcEnd (" + fcEnd + ")" ); - - this.startBytes = fcStart; - this.endBytes = fcEnd; - } + private final int startBytes; + private final int endBytes; public BytePropertyNode( int charStart, int charEnd, Object buf ) { diff --git a/src/scratchpad/src/org/apache/poi/hwpf/model/CHPX.java b/src/scratchpad/src/org/apache/poi/hwpf/model/CHPX.java index 62cce2e7a..ee928dfdf 100644 --- a/src/scratchpad/src/org/apache/poi/hwpf/model/CHPX.java +++ b/src/scratchpad/src/org/apache/poi/hwpf/model/CHPX.java @@ -24,60 +24,42 @@ import org.apache.poi.util.Internal; /** * DANGER - works in bytes! - * + *

* Make sure you call getStart() / getEnd() when you want characters - * (normal use), but getStartByte() / getEndByte() when you're - * reading in / writing out! + * (normal use), but getStartByte() / getEndByte() when you're + * reading in / writing out! * * @author Ryan Ackley */ @Internal -@SuppressWarnings( "deprecation" ) -public final class CHPX extends BytePropertyNode -{ +@SuppressWarnings("deprecation") +public final class CHPX extends BytePropertyNode { - @Deprecated - public CHPX(int fcStart, int fcEnd, CharIndexTranslator translator, byte[] grpprl) - { - super(fcStart, translator.lookIndexBackward(fcEnd), translator, new SprmBuffer(grpprl, 0)); - } - - @Deprecated - public CHPX(int fcStart, int fcEnd, CharIndexTranslator translator, SprmBuffer buf) - { - super(fcStart, translator.lookIndexBackward(fcEnd), translator ,buf); - } - - CHPX( int charStart, int charEnd, SprmBuffer buf ) - { - super( charStart, charEnd, buf ); + CHPX(int charStart, int charEnd, SprmBuffer buf) { + super(charStart, charEnd, buf); } - public byte[] getGrpprl() - { - return ((SprmBuffer)_buf).toByteArray(); - } + public byte[] getGrpprl() { + return ((SprmBuffer) _buf).toByteArray(); + } - public SprmBuffer getSprmBuf() - { - return (SprmBuffer)_buf; - } + public SprmBuffer getSprmBuf() { + return (SprmBuffer) _buf; + } - public CharacterProperties getCharacterProperties( StyleSheet ss, short istd ) - { - if ( ss == null ) - { + public CharacterProperties getCharacterProperties(StyleSheet ss, short istd) { + if (ss == null) { // TODO Fix up for Word 6/95 return new CharacterProperties(); } - CharacterProperties baseStyle = ss.getCharacterStyle( istd ); + CharacterProperties baseStyle = ss.getCharacterStyle(istd); return CharacterSprmUncompressor.uncompressCHP( - ss, baseStyle, getGrpprl(), 0 ); + ss, baseStyle, getGrpprl(), 0); } - public String toString() { - return "CHPX from " + getStart() + " to " + getEnd() + - " (in bytes " + getStartBytes() + " to " + getEndBytes() + ")"; - } + public String toString() { + return "CHPX from " + getStart() + " to " + getEnd() + + " (in bytes " + getStartBytes() + " to " + getEndBytes() + ")"; + } } diff --git a/src/scratchpad/src/org/apache/poi/hwpf/model/CharIndexTranslator.java b/src/scratchpad/src/org/apache/poi/hwpf/model/CharIndexTranslator.java index f59da4f0e..2ab1735cd 100644 --- a/src/scratchpad/src/org/apache/poi/hwpf/model/CharIndexTranslator.java +++ b/src/scratchpad/src/org/apache/poi/hwpf/model/CharIndexTranslator.java @@ -30,32 +30,6 @@ public interface CharIndexTranslator { */ int getByteIndex( int charPos ); - /** - * Calculates the char index of the given byte index. Look forward if index - * is not in table - * - * @param bytePos - * The character offset to check - * @return the char index - * @deprecated This API were based on incorrect assumption that single byte - * offset corresponds to single char offset - */ - @Deprecated - int getCharIndex(int bytePos); - - /** - * Calculates the char index of the given byte index. - * Look forward if index is not in table - * - * @param bytePos The character offset to check - * @param startCP look from this characted position - * @return the char index - * @deprecated This API were based on incorrect assumption that single byte - * offset corresponds to single char offset - */ - @Deprecated - int getCharIndex(int bytePos, int startCP); - /** * Finds character ranges that includes specified byte range. * diff --git a/src/scratchpad/src/org/apache/poi/hwpf/model/PAPFormattedDiskPage.java b/src/scratchpad/src/org/apache/poi/hwpf/model/PAPFormattedDiskPage.java index 8e535bc6f..6ab39d9c5 100644 --- a/src/scratchpad/src/org/apache/poi/hwpf/model/PAPFormattedDiskPage.java +++ b/src/scratchpad/src/org/apache/poi/hwpf/model/PAPFormattedDiskPage.java @@ -52,37 +52,15 @@ public final class PAPFormattedDiskPage extends FormattedDiskPage { private ArrayList _papxList = new ArrayList<>(); private ArrayList _overFlow; - /** - * @deprecated Use {@link #PAPFormattedDiskPage()} instead - */ - public PAPFormattedDiskPage( byte[] dataStream ) - { - this(); - } - public PAPFormattedDiskPage() - { - } - /** - * Creates a PAPFormattedDiskPage from a 512 byte array - * - * @deprecated Use - * {@link #PAPFormattedDiskPage(byte[], byte[], int, CharIndexTranslator)} - * instead - */ - public PAPFormattedDiskPage( byte[] documentStream, byte[] dataStream, - int offset, int fcMin, TextPieceTable tpt ) - { - this( documentStream, dataStream, offset, tpt ); - } + public PAPFormattedDiskPage() { } /** * Creates a PAPFormattedDiskPage from a 512 byte array */ public PAPFormattedDiskPage( byte[] documentStream, byte[] dataStream, - int offset, CharIndexTranslator translator ) - { + int offset, CharIndexTranslator translator ) { super( documentStream, offset ); for ( int x = 0; x < _crun; x++ ) { diff --git a/src/scratchpad/src/org/apache/poi/hwpf/model/PAPX.java b/src/scratchpad/src/org/apache/poi/hwpf/model/PAPX.java index 06f79e8fe..34f72d227 100644 --- a/src/scratchpad/src/org/apache/poi/hwpf/model/PAPX.java +++ b/src/scratchpad/src/org/apache/poi/hwpf/model/PAPX.java @@ -40,15 +40,6 @@ public final class PAPX extends BytePropertyNode { private ParagraphHeight _phe; - public PAPX(int fcStart, int fcEnd, CharIndexTranslator translator, byte[] papx, ParagraphHeight phe, byte[] dataStream) - { - super(fcStart, fcEnd, translator, new SprmBuffer(papx, 2)); - _phe = phe; - SprmBuffer buf = findHuge(new SprmBuffer(papx, 2), dataStream); - if(buf != null) - _buf = buf; - } - public PAPX( int charStart, int charEnd, byte[] papx, ParagraphHeight phe, byte[] dataStream ) { @@ -59,16 +50,6 @@ public final class PAPX extends BytePropertyNode { _buf = buf; } - @Deprecated - public PAPX(int fcStart, int fcEnd, CharIndexTranslator translator, SprmBuffer buf, byte[] dataStream) - { - super(fcStart, fcEnd, translator, buf); - _phe = new ParagraphHeight(); - buf = findHuge(buf, dataStream); - if(buf != null) - _buf = buf; - } - public PAPX( int charStart, int charEnd, SprmBuffer buf ) { super( charStart, charEnd, buf ); diff --git a/src/testcases/org/apache/poi/hssf/usermodel/TestHSSFPalette.java b/src/testcases/org/apache/poi/hssf/usermodel/TestHSSFPalette.java index 58e07d65b..9338dfa65 100644 --- a/src/testcases/org/apache/poi/hssf/usermodel/TestHSSFPalette.java +++ b/src/testcases/org/apache/poi/hssf/usermodel/TestHSSFPalette.java @@ -86,6 +86,7 @@ public final class TestHSSFPalette { /** * Uses the palette from cell stylings */ + @SuppressWarnings("deprecation") @Test public void testPaletteFromCellColours() { HSSFWorkbook book = HSSFTestDataSamples.openSampleWorkbook("SimpleWithColours.xls"); @@ -104,6 +105,7 @@ public final class TestHSSFPalette { assertEquals(64, cellA.getCellStyle().getFillBackgroundColor()); assertEquals(Font.COLOR_NORMAL, cellA.getCellStyle().getFont(book).getColor()); assertEquals(FillPatternType.NO_FILL, cellA.getCellStyle().getFillPattern()); + assertEquals(FillPatternType.NO_FILL, cellA.getCellStyle().getFillPatternEnum()); assertEquals("0:0:0", p.getColor((short)64).getHexString()); assertEquals(null, p.getColor((short)32767)); @@ -113,6 +115,7 @@ public final class TestHSSFPalette { assertEquals(64, cellB.getCellStyle().getFillBackgroundColor()); assertEquals(10, cellB.getCellStyle().getFont(book).getColor()); assertEquals(FillPatternType.NO_FILL, cellB.getCellStyle().getFillPattern()); + assertEquals(FillPatternType.NO_FILL, cellB.getCellStyle().getFillPatternEnum()); assertEquals("0:0:0", p.getColor((short)64).getHexString()); assertEquals("FFFF:0:0", p.getColor((short)10).getHexString()); @@ -122,6 +125,7 @@ public final class TestHSSFPalette { assertEquals(64, cellC.getCellStyle().getFillBackgroundColor()); assertEquals(10, cellC.getCellStyle().getFont(book).getColor()); assertEquals(FillPatternType.SOLID_FOREGROUND, cellC.getCellStyle().getFillPattern()); + assertEquals(FillPatternType.SOLID_FOREGROUND, cellC.getCellStyle().getFillPatternEnum()); assertEquals("0:FFFF:0", p.getColor((short)11).getHexString()); assertEquals("FFFF:0:0", p.getColor((short)10).getHexString()); @@ -131,6 +135,7 @@ public final class TestHSSFPalette { assertEquals(64, cellD.getCellStyle().getFillBackgroundColor()); assertEquals(14, cellD.getCellStyle().getFont(book).getColor()); assertEquals(FillPatternType.NO_FILL, cellD.getCellStyle().getFillPattern()); + assertEquals(FillPatternType.NO_FILL, cellD.getCellStyle().getFillPatternEnum()); assertEquals("FFFF:FFFF:0", p.getColor((short)13).getHexString()); assertEquals("FFFF:0:FFFF", p.getColor((short)14).getHexString()); @@ -140,6 +145,7 @@ public final class TestHSSFPalette { assertEquals(64, cellE.getCellStyle().getFillBackgroundColor()); assertEquals(14, cellE.getCellStyle().getFont(book).getColor()); assertEquals(FillPatternType.NO_FILL, cellE.getCellStyle().getFillPattern()); + assertEquals(FillPatternType.NO_FILL, cellE.getCellStyle().getFillPatternEnum()); assertEquals("FFFF:FFFF:0", p.getColor((short)13).getHexString()); assertEquals("FFFF:0:FFFF", p.getColor((short)14).getHexString()); } diff --git a/src/testcases/org/apache/poi/ss/util/BaseTestCellUtil.java b/src/testcases/org/apache/poi/ss/util/BaseTestCellUtil.java index 08bb9d4b2..c4bb0fc88 100644 --- a/src/testcases/org/apache/poi/ss/util/BaseTestCellUtil.java +++ b/src/testcases/org/apache/poi/ss/util/BaseTestCellUtil.java @@ -356,30 +356,7 @@ public class BaseTestCellUtil { wb2.close(); } } - - /** - * bug 55555 - * @deprecated Replaced by {@link #setFillForegroundColorBeforeFillBackgroundColorEnum()} - * @since POI 3.15 beta 3 - */ - @Deprecated - // bug 55555 - @Test - public void setFillForegroundColorBeforeFillBackgroundColor() throws IOException { - Workbook wb1 = _testDataProvider.createWorkbook(); - Cell A1 = wb1.createSheet().createRow(0).createCell(0); - Map properties = new HashMap<>(); - properties.put(CellUtil.FILL_PATTERN, FillPatternType.BRICKS); - properties.put(CellUtil.FILL_FOREGROUND_COLOR, IndexedColors.BLUE.index); - properties.put(CellUtil.FILL_BACKGROUND_COLOR, IndexedColors.RED.index); - - CellUtil.setCellStyleProperties(A1, properties); - CellStyle style = A1.getCellStyle(); - assertEquals("fill pattern", FillPatternType.BRICKS, style.getFillPattern()); - assertEquals("fill foreground color", IndexedColors.BLUE, IndexedColors.fromInt(style.getFillForegroundColor())); - assertEquals("fill background color", IndexedColors.RED, IndexedColors.fromInt(style.getFillBackgroundColor())); - wb1.close(); - } + /** * bug 55555 * @since POI 3.15 beta 3