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 {}
}
}
@Test
+ @SuppressWarnings("deprecation")
public void testGetFillForegroundColor() throws IOException {
XSSFWorkbook wb = new XSSFWorkbook();
StylesTable styles = wb.getStylesSource();
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());
public abstract class BytePropertyNode<T extends BytePropertyNode<T>> extends
PropertyNode<T>
{
- 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 )
{
/**
* DANGER - works in bytes!
- *
+ * <p>
* 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<CHPX>
-{
-
- @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);
- }
+@SuppressWarnings("deprecation")
+public final class CHPX extends BytePropertyNode<CHPX> {
- 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() + ")";
+ }
}
*/
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.
*
private ArrayList<PAPX> _papxList = new ArrayList<>();
private ArrayList<PAPX> _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++ )
{
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 )
{
_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 );
/**
* Uses the palette from cell stylings
*/
+ @SuppressWarnings("deprecation")
@Test
public void testPaletteFromCellColours() {
HSSFWorkbook book = HSSFTestDataSamples.openSampleWorkbook("SimpleWithColours.xls");
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));
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());
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());
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());
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());
}
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<String, Object> 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