Remove use of deprecated methods

git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1812907 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
PJ Fanning 2017-10-22 12:45:35 +00:00
parent dffa1ccd9c
commit 2cd8c7bc65
17 changed files with 155 additions and 234 deletions

View File

@ -156,7 +156,7 @@ public class SVTableCellEditor extends AbstractCellEditor implements TableCellEd
Font font = new Font(f.getFontName(),fontstyle,fontheight);
editor.setFont(font);
if (style.getFillPatternEnum() == FillPatternType.SOLID_FOREGROUND) {
if (style.getFillPattern() == FillPatternType.SOLID_FOREGROUND) {
editor.setBackground(getAWTColor(style.getFillForegroundColor(), white));
} else {
editor.setBackground(white);
@ -187,7 +187,7 @@ public class SVTableCellEditor extends AbstractCellEditor implements TableCellEd
default:
editor.setText("?");
}
switch (style.getAlignmentEnum()) {
switch (style.getAlignment()) {
case LEFT:
case JUSTIFY:
case FILL:

View File

@ -151,7 +151,7 @@ public class SVTableCellRenderer extends JLabel
HSSFFont f = wb.getFontAt(s.getFontIndex());
setFont(SVTableUtils.makeFont(f));
if (s.getFillPatternEnum() == FillPatternType.SOLID_FOREGROUND) {
if (s.getFillPattern() == FillPatternType.SOLID_FOREGROUND) {
setBackground(SVTableUtils.getAWTColor(s.getFillForegroundColor(), SVTableUtils.white));
} else setBackground(SVTableUtils.white);
@ -195,7 +195,7 @@ public class SVTableCellRenderer extends JLabel
setValue("?");
}
//Set the text alignment of the cell
switch (s.getAlignmentEnum()) {
switch (s.getAlignment()) {
case LEFT:
case JUSTIFY:
case FILL:

View File

@ -330,8 +330,8 @@ public class ExcelComparator {
*/
private void isCellAlignmentMatches(Locator loc1, Locator loc2) {
// TODO: check for NPE
HorizontalAlignment align1 = loc1.cell.getCellStyle().getAlignmentEnum();
HorizontalAlignment align2 = loc2.cell.getCellStyle().getAlignmentEnum();
HorizontalAlignment align1 = loc1.cell.getCellStyle().getAlignment();
HorizontalAlignment align2 = loc2.cell.getCellStyle().getAlignment();
if (align1 != align2) {
addMessage(loc1, loc2,
"Cell Alignment does not Match ::",
@ -460,8 +460,8 @@ public class ExcelComparator {
*/
private void isCellFillPatternMatches(Locator loc1, Locator loc2) {
// TOOO: Check for NPE
FillPatternType fill1 = loc1.cell.getCellStyle().getFillPatternEnum();
FillPatternType fill2 = loc2.cell.getCellStyle().getFillPatternEnum();
FillPatternType fill1 = loc1.cell.getCellStyle().getFillPattern();
FillPatternType fill2 = loc2.cell.getCellStyle().getFillPattern();
if (fill1 != fill2) {
addMessage(loc1, loc2,
"Cell Fill pattern does not Match ::",

View File

@ -44,7 +44,7 @@ public class HSSFHtmlHelper implements HtmlHelper {
@Override
public void colorStyles(CellStyle style, Formatter out) {
HSSFCellStyle cs = (HSSFCellStyle) style;
out.format(" /* fill pattern = %d */%n", cs.getFillPatternEnum().getCode());
out.format(" /* fill pattern = %d */%n", cs.getFillPattern().getCode());
styleColor(out, "background-color", cs.getFillForegroundColor());
styleColor(out, "color", cs.getFont(wb).getColor());
styleColor(out, "border-left-color", cs.getLeftBorderColor());

View File

@ -289,8 +289,8 @@ public class ToHtml {
}
private void styleContents(CellStyle style) {
styleOut("text-align", style.getAlignmentEnum(), HALIGN);
styleOut("vertical-align", style.getVerticalAlignmentEnum(), VALIGN);
styleOut("text-align", style.getAlignment(), HALIGN);
styleOut("vertical-align", style.getVerticalAlignment(), VALIGN);
fontStyle(style);
borderStyles(style);
helper.colorStyles(style, out);
@ -493,7 +493,7 @@ public class ToHtml {
}
private String tagStyle(Cell cell, CellStyle style) {
if (style.getAlignmentEnum() == HorizontalAlignment.GENERAL) {
if (style.getAlignment() == HorizontalAlignment.GENERAL) {
switch (ultimateCellType(cell)) {
case STRING:
return "style=\"text-align: left;\"";

View File

@ -272,25 +272,16 @@ public final class HSSFCellStyle implements CellStyle {
_format.setAlignment(align.getCode());
}
/**
* get the type of horizontal alignment for the cell
* @return align - the type of alignment
* @deprecated POI 3.15 beta 3. Use {@link #getAlignmentEnum()} instead.
*/
@Deprecated
@Override
public short getAlignment()
public HorizontalAlignment getAlignment()
{
return _format.getAlignment();
return HorizontalAlignment.forInt(_format.getAlignment());
}
/**
* get the type of horizontal alignment for the cell
* @return align - the type of alignment
*/
@Override
public HorizontalAlignment getAlignmentEnum()
{
return HorizontalAlignment.forInt(_format.getAlignment());
return getAlignment();
}
/**
@ -324,28 +315,16 @@ public final class HSSFCellStyle implements CellStyle {
_format.setVerticalAlignment(align.getCode());
}
/**
* get the type of vertical alignment for the cell
* @return align the type of alignment
* @see VerticalAlignment
* @deprecated POI 3.15 beta 3. Use {@link #getVerticalAlignmentEnum()} instead.
*/
@Deprecated
@Override
public short getVerticalAlignment()
{
return _format.getVerticalAlignment();
}
/**
* get the type of vertical alignment for the cell
* @return align the type of alignment
*/
@Override
public VerticalAlignment getVerticalAlignmentEnum()
{
public VerticalAlignment getVerticalAlignment() {
return VerticalAlignment.forInt(_format.getVerticalAlignment());
}
@Override
public VerticalAlignment getVerticalAlignmentEnum() {
return getVerticalAlignment();
}
/**
* set the degree of rotation for the text in the cell
*
@ -649,28 +628,15 @@ public final class HSSFCellStyle implements CellStyle {
_format.setAdtlFillPattern(fp.getCode());
}
/**
* get the fill pattern
* @return fill pattern
* @deprecated POI 3.15 beta 3. This method will return {@link FillPatternType} in the future. Use {@link #setFillPattern(FillPatternType)} instead.
*/
@Deprecated
@Override
public short getFillPattern()
{
return getFillPatternEnum().getCode();
}
/**
* get the fill pattern
* @return fill pattern
*/
@Override
public FillPatternType getFillPatternEnum()
public FillPatternType getFillPattern()
{
return FillPatternType.forInt(_format.getAdtlFillPattern());
}
@Override
public FillPatternType getFillPatternEnum() { return getFillPattern(); }
/**
* Checks if the background and foreground fills are set correctly when one
* or the other is set to the default color.

View File

@ -17,6 +17,8 @@
package org.apache.poi.ss.usermodel;
import org.apache.poi.util.Removal;
public interface CellStyle {
/**
@ -113,13 +115,15 @@ public interface CellStyle {
/**
* get the type of horizontal alignment for the cell
* @return align - the type of alignment
* @deprecated POI 3.15 beta 3. Use {@link #getAlignmentEnum()} instead.
*/
short getAlignment();
HorizontalAlignment getAlignment();
/**
* get the type of horizontal alignment for the cell
* @return align - the type of alignment
* @deprecated use <code>getAlignment()</code> instead
*/
@Removal(version = "4.2")
HorizontalAlignment getAlignmentEnum();
/**
@ -129,14 +133,12 @@ public interface CellStyle {
*
* @param wrapped wrap text or not
*/
void setWrapText(boolean wrapped);
/**
* get whether the text should be wrapped
* @return wrap text or not
*/
boolean getWrapText();
/**
@ -148,13 +150,15 @@ public interface CellStyle {
/**
* get the type of vertical alignment for the cell
* @return align the type of alignment
* @deprecated POI 3.15 beta 3. Use {@link #getVerticalAlignmentEnum()} instead.
*/
short getVerticalAlignment();
VerticalAlignment getVerticalAlignment();
/**
* get the type of vertical alignment for the cell
* @return align the type of alignment
* @deprecated use <code>getVerticalAlignment()</code> instead
*/
@Removal(version = "4.2")
VerticalAlignment getVerticalAlignmentEnum();
/**
@ -335,16 +339,21 @@ public interface CellStyle {
void setFillPattern(FillPatternType fp);
/**
* get the fill pattern (??) - set to 1 to fill with foreground color
* @return fill pattern
* @deprecated POI 3.15 beta 3. This method will return {@link FillPatternType} in the future. Use {@link #setFillPattern(FillPatternType)} instead.
* Get the fill pattern
*
* @return the fill pattern, default value is {@link FillPatternType#NO_FILL}
* @since POI 4.0.0
*/
short getFillPattern();
FillPatternType getFillPattern();
/**
* get the fill pattern (??) - set to 1 to fill with foreground color
* @return fill pattern
* Get the fill pattern
*
* @return the fill pattern, default value is {@link FillPatternType#NO_FILL}
* @since POI 3.15 beta 3
* @deprecated use <code>getFillPattern()</code> instead
*/
@Removal(version = "4.2")
FillPatternType getFillPatternEnum();
/**
@ -352,7 +361,6 @@ public interface CellStyle {
*
* @param bg color
*/
void setFillBackgroundColor(short bg);
/**

View File

@ -335,15 +335,15 @@ public final class CellUtil {
*/
private static Map<String, Object> getFormatProperties(CellStyle style) {
Map<String, Object> properties = new HashMap<>();
put(properties, ALIGNMENT, style.getAlignmentEnum());
put(properties, VERTICAL_ALIGNMENT, style.getVerticalAlignmentEnum());
put(properties, ALIGNMENT, style.getAlignment());
put(properties, VERTICAL_ALIGNMENT, style.getVerticalAlignment());
put(properties, BORDER_BOTTOM, style.getBorderBottomEnum());
put(properties, BORDER_LEFT, style.getBorderLeftEnum());
put(properties, BORDER_RIGHT, style.getBorderRightEnum());
put(properties, BORDER_TOP, style.getBorderTopEnum());
put(properties, BOTTOM_BORDER_COLOR, style.getBottomBorderColor());
put(properties, DATA_FORMAT, style.getDataFormat());
put(properties, FILL_PATTERN, style.getFillPatternEnum());
put(properties, FILL_PATTERN, style.getFillPattern());
put(properties, FILL_FOREGROUND_COLOR, style.getFillForegroundColor());
put(properties, FILL_BACKGROUND_COLOR, style.getFillBackgroundColor());
put(properties, FONT, style.getFontIndex());

View File

@ -217,24 +217,8 @@ public class XSSFCellStyle implements CellStyle {
_cellXf.setApplyBorder(true);
}
/**
* Get the type of horizontal alignment for the cell
*
* @return short - the type of alignment
* @deprecated POI 3.15 beta 3. Use {@link #getAlignmentEnum()} instead.
*/
@Override
public short getAlignment() {
return getAlignmentEnum().getCode();
}
/**
* Get the type of horizontal alignment for the cell
*
* @return HorizontalAlignment - the type of alignment
*/
@Override
public HorizontalAlignment getAlignmentEnum() {
public HorizontalAlignment getAlignment() {
CTCellAlignment align = _cellXf.getAlignment();
if(align != null && align.isSetHorizontal()) {
return HorizontalAlignment.forInt(align.getHorizontal().intValue()-1);
@ -242,6 +226,10 @@ public class XSSFCellStyle implements CellStyle {
return HorizontalAlignment.GENERAL;
}
@Override
public HorizontalAlignment getAlignmentEnum() {
return getAlignment();
}
/**
* Get the type of border to use for the bottom border of the cell
* Will be removed when {@link #getBorderBottom()} returns a BorderStyle enum
@ -494,23 +482,8 @@ public class XSSFCellStyle implements CellStyle {
return fillForegroundColor;
}
/**
* Get the fill pattern
* @return fill pattern, default value is the code for {@link org.apache.poi.ss.usermodel.FillPatternType#NO_FILL}
* @deprecated POI 3.15 beta 3. This method will return {@link FillPatternType} in the future. Use {@link #setFillPattern(FillPatternType)} instead.
*/
@Override
public short getFillPattern() {
return getFillPatternEnum().getCode();
}
/**
* Get the fill pattern
*
* @return the fill pattern, default value is {@link FillPatternType#NO_FILL}
*/
@Override
public FillPatternType getFillPatternEnum() {
public FillPatternType getFillPattern() {
// bug 56295: handle missing applyFill attribute as "true" because Excel does as well
if(_cellXf.isSetApplyFill() && !_cellXf.getApplyFill()) return FillPatternType.NO_FILL;
@ -522,6 +495,11 @@ public class XSSFCellStyle implements CellStyle {
return FillPatternType.forInt(ptrn.intValue() - 1);
}
@Override
public FillPatternType getFillPatternEnum() {
return getFillPattern();
}
/**
* Gets the font for this style
* @return Font - font
@ -708,24 +686,8 @@ public class XSSFCellStyle implements CellStyle {
return border.getBorderColor(BorderSide.TOP);
}
/**
* Get the type of vertical alignment for the cell
*
* @return align the type of alignment, default value is {@link org.apache.poi.ss.usermodel.VerticalAlignment}
* @deprecated POI 3.15 beta 3. Use {@link #getVerticalAlignmentEnum()} instead.
*/
@Override
public short getVerticalAlignment() {
return getVerticalAlignmentEnum().getCode();
}
/**
* Get the type of vertical alignment for the cell
*
* @return the type of alignment, default value is {@link VerticalAlignment#BOTTOM}
*/
@Override
public VerticalAlignment getVerticalAlignmentEnum() {
public VerticalAlignment getVerticalAlignment() {
CTCellAlignment align = _cellXf.getAlignment();
if(align != null && align.isSetVertical()) {
return VerticalAlignment.forInt(align.getVertical().intValue()-1);
@ -733,6 +695,11 @@ public class XSSFCellStyle implements CellStyle {
return VerticalAlignment.BOTTOM;
}
@Override
public VerticalAlignment getVerticalAlignmentEnum() {
return getVerticalAlignment();
}
/**
* Whether the text should be wrapped
*

View File

@ -555,7 +555,7 @@ public class TestXSSFCellStyle {
HSSFCellStyle style2 = wb2.createCellStyle();
assertEquals(style2.getFillBackgroundColor(), style1.getFillBackgroundColor());
assertEquals(style2.getFillForegroundColor(), style1.getFillForegroundColor());
assertEquals(style2.getFillPatternEnum(), style1.getFillPatternEnum());
assertEquals(style2.getFillPattern(), style1.getFillPattern());
assertEquals(style2.getFillPattern(), style1.getFillPattern());
assertEquals(style2.getLeftBorderColor(), style1.getLeftBorderColor());
@ -570,7 +570,6 @@ public class TestXSSFCellStyle {
wb2.close();
}
@SuppressWarnings("deprecation")
@Test
public void testGetFillForegroundColor() throws IOException {
XSSFWorkbook wb = new XSSFWorkbook();
@ -581,14 +580,12 @@ public class TestXSSFCellStyle {
XSSFCellStyle defaultStyle = wb.getCellStyleAt((short)0);
assertEquals(IndexedColors.AUTOMATIC.getIndex(), defaultStyle.getFillForegroundColor());
assertEquals(null, defaultStyle.getFillForegroundXSSFColor());
assertEquals(FillPatternType.NO_FILL, defaultStyle.getFillPatternEnum());
assertEquals(FillPatternType.NO_FILL.getCode(), defaultStyle.getFillPattern());
assertEquals(FillPatternType.NO_FILL, defaultStyle.getFillPattern());
XSSFCellStyle customStyle = wb.createCellStyle();
customStyle.setFillPattern(FillPatternType.SOLID_FOREGROUND);
assertEquals(FillPatternType.SOLID_FOREGROUND, customStyle.getFillPatternEnum());
assertEquals(FillPatternType.SOLID_FOREGROUND.getCode(), customStyle.getFillPattern());
assertEquals(FillPatternType.SOLID_FOREGROUND, customStyle.getFillPattern());
assertEquals(3, styles.getFills().size());
customStyle.setFillForegroundColor(IndexedColors.BRIGHT_GREEN.getIndex());
@ -599,8 +596,7 @@ public class TestXSSFCellStyle {
XSSFCellStyle style = wb.createCellStyle();
style.setFillPattern(FillPatternType.SOLID_FOREGROUND);
assertEquals(FillPatternType.SOLID_FOREGROUND, style.getFillPatternEnum());
assertEquals(FillPatternType.SOLID_FOREGROUND.getCode(), style.getFillPattern());
assertEquals(FillPatternType.SOLID_FOREGROUND, style.getFillPattern());
assertEquals(4, styles.getFills().size());
style.setFillForegroundColor(IndexedColors.BRIGHT_GREEN.getIndex());
@ -612,17 +608,14 @@ public class TestXSSFCellStyle {
wb.close();
}
@SuppressWarnings("deprecation")
@Test
public void testGetFillPattern() {
assertEquals(STPatternType.INT_DARK_GRAY-1, cellStyle.getFillPatternEnum().getCode());
assertEquals(STPatternType.INT_DARK_GRAY-1, cellStyle.getFillPattern());
assertEquals(STPatternType.INT_DARK_GRAY-1, cellStyle.getFillPattern().getCode());
int num = stylesTable.getFills().size();
cellStyle.setFillPattern(FillPatternType.SOLID_FOREGROUND);
assertEquals(FillPatternType.SOLID_FOREGROUND, cellStyle.getFillPatternEnum());
assertEquals(FillPatternType.SOLID_FOREGROUND.getCode(), cellStyle.getFillPattern());
assertEquals(FillPatternType.SOLID_FOREGROUND, cellStyle.getFillPattern());
assertEquals(num + 1, stylesTable.getFills().size());
int fillId = (int)cellStyle.getCoreXf().getFillId();
assertTrue(fillId > 0);
@ -637,8 +630,7 @@ public class TestXSSFCellStyle {
assertEquals(num + 1, stylesTable.getFills().size());
cellStyle.setFillPattern(FillPatternType.NO_FILL);
assertEquals(FillPatternType.NO_FILL, cellStyle.getFillPatternEnum());
assertEquals(FillPatternType.NO_FILL.getCode(), cellStyle.getFillPattern());
assertEquals(FillPatternType.NO_FILL, cellStyle.getFillPattern());
fillId = (int)cellStyle.getCoreXf().getFillId();
ctFill2 = stylesTable.getFillAt(fillId).getCTFill();
assertFalse(ctFill2.getPatternFill().isSetPatternType());
@ -677,25 +669,21 @@ public class TestXSSFCellStyle {
assertEquals((short)13, cellStyle.getIndention());
}
@SuppressWarnings("deprecation")
@Test
public void testGetSetAlignment() {
assertNull(cellStyle.getCellAlignment().getCTCellAlignment().getHorizontal());
assertEquals(HorizontalAlignment.GENERAL, cellStyle.getAlignmentEnum());
assertEquals(HorizontalAlignment.GENERAL, cellStyle.getAlignment());
cellStyle.setAlignment(HorizontalAlignment.LEFT);
assertEquals(HorizontalAlignment.LEFT.getCode(), cellStyle.getAlignment());
assertEquals(HorizontalAlignment.LEFT, cellStyle.getAlignmentEnum());
assertEquals(HorizontalAlignment.LEFT, cellStyle.getAlignment());
assertEquals(STHorizontalAlignment.LEFT, cellStyle.getCellAlignment().getCTCellAlignment().getHorizontal());
cellStyle.setAlignment(HorizontalAlignment.JUSTIFY);
assertEquals(HorizontalAlignment.JUSTIFY.getCode(), cellStyle.getAlignment());
assertEquals(HorizontalAlignment.JUSTIFY, cellStyle.getAlignmentEnum());
assertEquals(HorizontalAlignment.JUSTIFY, cellStyle.getAlignment());
assertEquals(STHorizontalAlignment.JUSTIFY, cellStyle.getCellAlignment().getCTCellAlignment().getHorizontal());
cellStyle.setAlignment(HorizontalAlignment.CENTER);
assertEquals(HorizontalAlignment.CENTER.getCode(), cellStyle.getAlignment());
assertEquals(HorizontalAlignment.CENTER, cellStyle.getAlignmentEnum());
assertEquals(HorizontalAlignment.CENTER, cellStyle.getAlignment());
assertEquals(STHorizontalAlignment.CENTER, cellStyle.getCellAlignment().getCTCellAlignment().getHorizontal());
}
@ -717,21 +705,17 @@ public class TestXSSFCellStyle {
assertEquals(ReadingOrder.CONTEXT.getCode(), cellStyle.getCellAlignment().getCTCellAlignment().getReadingOrder());
}
@SuppressWarnings("deprecation")
@Test
public void testGetSetVerticalAlignment() {
assertEquals(VerticalAlignment.BOTTOM, cellStyle.getVerticalAlignmentEnum());
assertEquals(VerticalAlignment.BOTTOM.getCode(), cellStyle.getVerticalAlignment());
assertEquals(VerticalAlignment.BOTTOM, cellStyle.getVerticalAlignment());
assertNull(cellStyle.getCellAlignment().getCTCellAlignment().getVertical());
cellStyle.setVerticalAlignment(VerticalAlignment.CENTER);
assertEquals(VerticalAlignment.CENTER.getCode(), cellStyle.getVerticalAlignment());
assertEquals(VerticalAlignment.CENTER, cellStyle.getVerticalAlignmentEnum());
assertEquals(VerticalAlignment.CENTER, cellStyle.getVerticalAlignment());
assertEquals(STVerticalAlignment.CENTER, cellStyle.getCellAlignment().getCTCellAlignment().getVertical());
cellStyle.setVerticalAlignment(VerticalAlignment.JUSTIFY);
assertEquals(VerticalAlignment.JUSTIFY.getCode(), cellStyle.getVerticalAlignment());
assertEquals(VerticalAlignment.JUSTIFY, cellStyle.getVerticalAlignmentEnum());
assertEquals(VerticalAlignment.JUSTIFY, cellStyle.getVerticalAlignment());
assertEquals(STVerticalAlignment.JUSTIFY, cellStyle.getCellAlignment().getCTCellAlignment().getVertical());
}
@ -761,17 +745,17 @@ public class TestXSSFCellStyle {
orig.setFont(fnt);
orig.setDataFormat((short)18);
assertEquals(HorizontalAlignment.RIGHT, orig.getAlignmentEnum());
assertEquals(HorizontalAlignment.RIGHT, orig.getAlignment());
assertEquals(fnt, orig.getFont());
assertEquals(18, orig.getDataFormat());
XSSFCellStyle clone = wb.createCellStyle();
assertFalse(HorizontalAlignment.RIGHT == clone.getAlignmentEnum());
assertFalse(HorizontalAlignment.RIGHT == clone.getAlignment());
assertFalse(fnt == clone.getFont());
assertFalse(18 == clone.getDataFormat());
clone.cloneStyleFrom(orig);
assertEquals(HorizontalAlignment.RIGHT, clone.getAlignmentEnum());
assertEquals(HorizontalAlignment.RIGHT, clone.getAlignment());
assertEquals(fnt, clone.getFont());
assertEquals(18, clone.getDataFormat());
assertEquals(2, wb.getNumberOfFonts());
@ -806,7 +790,7 @@ public class TestXSSFCellStyle {
orig.setFont(fnt);
orig.setDataFormat(fmt.getFormat("Test##"));
assertTrue(HorizontalAlignment.RIGHT == orig.getAlignmentEnum());
assertTrue(HorizontalAlignment.RIGHT == orig.getAlignment());
assertTrue(fnt == orig.getFont());
assertTrue(fmt.getFormat("Test##") == orig.getDataFormat());
@ -826,7 +810,7 @@ public class TestXSSFCellStyle {
assertEquals(1, wbClone.getNumberOfFonts());
assertEquals(0, wbClone.getStylesSource().getNumberFormats().size());
assertFalse(HorizontalAlignment.RIGHT == clone.getAlignmentEnum());
assertFalse(HorizontalAlignment.RIGHT == clone.getAlignment());
assertNotEquals("TestingFont", clone.getFont().getFontName());
clone.cloneStyleFrom(orig);
@ -835,7 +819,7 @@ public class TestXSSFCellStyle {
assertEquals(2, wbClone.getNumCellStyles());
assertEquals(1, wbClone.getStylesSource().getNumberFormats().size());
assertEquals(HorizontalAlignment.RIGHT, clone.getAlignmentEnum());
assertEquals(HorizontalAlignment.RIGHT, clone.getAlignment());
assertEquals("TestingFont", clone.getFont().getFontName());
assertEquals(fmtClone.getFormat("Test##"), clone.getDataFormat());
assertFalse(fmtClone.getFormat("Test##") == fmt.getFormat("Test##"));
@ -847,7 +831,7 @@ public class TestXSSFCellStyle {
assertEquals(1, wbReload.getStylesSource().getNumberFormats().size());
XSSFCellStyle reload = wbReload.getCellStyleAt((short)1);
assertEquals(HorizontalAlignment.RIGHT, reload.getAlignmentEnum());
assertEquals(HorizontalAlignment.RIGHT, reload.getAlignment());
assertEquals("TestingFont", reload.getFont().getFontName());
assertEquals(fmtClone.getFormat("Test##"), reload.getDataFormat());
assertFalse(fmtClone.getFormat("Test##") == fmt.getFormat("Test##"));
@ -951,7 +935,7 @@ public class TestXSSFCellStyle {
@Test
public void testSetColor() throws IOException {
Workbook wb = new XSSFWorkbook();
try(Workbook wb = new XSSFWorkbook()) {
Sheet sheet = wb.createSheet();
Row row = sheet.createRow(0);
@ -972,21 +956,17 @@ public class TestXSSFCellStyle {
cell.setCellStyle(cellStyle2);
Workbook wbBack = XSSFTestDataSamples.writeOutAndReadBack(wb);
try (Workbook wbBack = XSSFTestDataSamples.writeOutAndReadBack(wb)) {
Cell cellBack = wbBack.getSheetAt(0).getRow(0).getCell(1);
assertNotNull(cellBack);
CellStyle styleBack = cellBack.getCellStyle();
assertEquals(IndexedColors.DARK_BLUE.getIndex(), styleBack.getFillBackgroundColor());
assertEquals(IndexedColors.DARK_BLUE.getIndex(), styleBack.getFillForegroundColor());
assertEquals(HorizontalAlignment.RIGHT, styleBack.getAlignmentEnum());
assertEquals(VerticalAlignment.TOP, styleBack.getVerticalAlignmentEnum());
assertEquals(FillPatternType.SOLID_FOREGROUND, styleBack.getFillPatternEnum());
//noinspection deprecation
assertEquals(FillPatternType.SOLID_FOREGROUND.getCode(), styleBack.getFillPattern());
wbBack.close();
wb.close();
assertEquals(HorizontalAlignment.RIGHT, styleBack.getAlignment());
assertEquals(VerticalAlignment.TOP, styleBack.getVerticalAlignment());
assertEquals(FillPatternType.SOLID_FOREGROUND, styleBack.getFillPattern());
}
}
}
public static void copyStyles(Workbook reference, Workbook target) {
@ -1070,7 +1050,7 @@ public class TestXSSFCellStyle {
assertNull(cellStyle.getFillBackgroundColorColor());
cellStyle.setFillPattern(FillPatternType.NO_FILL);
assertEquals(FillPatternType.NO_FILL, cellStyle.getFillPatternEnum());
assertEquals(FillPatternType.NO_FILL, cellStyle.getFillPattern());
cellStyle.setBottomBorderColor(null);
assertNull(cellStyle.getBottomBorderXSSFColor());

View File

@ -195,7 +195,7 @@ public class ExcelToFoConverter extends AbstractExcelConverter
*/
protected boolean isEmptyStyle( CellStyle cellStyle ) {
return cellStyle == null || (
cellStyle.getFillPattern() == 0
cellStyle.getFillPattern() == FillPatternType.NO_FILL
&& cellStyle.getBorderTopEnum() == BorderStyle.NONE
&& cellStyle.getBorderRightEnum() == BorderStyle.NONE
&& cellStyle.getBorderBottomEnum() == BorderStyle.NONE
@ -336,16 +336,16 @@ public class ExcelToFoConverter extends AbstractExcelConverter
{
blockTarget.setAttribute( "white-space-collapse", "false" );
{
String textAlign = ExcelToFoUtils.getAlign( cellStyle.getAlignmentEnum() );
String textAlign = ExcelToFoUtils.getAlign( cellStyle.getAlignment() );
if ( ExcelToFoUtils.isNotEmpty( textAlign ) )
blockTarget.setAttribute( "text-align", textAlign );
}
if ( cellStyle.getFillPatternEnum() == FillPatternType.NO_FILL )
if ( cellStyle.getFillPattern() == FillPatternType.NO_FILL )
{
// no fill
}
else if ( cellStyle.getFillPatternEnum() == FillPatternType.SOLID_FOREGROUND )
else if ( cellStyle.getFillPattern() == FillPatternType.SOLID_FOREGROUND )
{
final HSSFColor foregroundColor = cellStyle
.getFillForegroundColorColor();

View File

@ -190,9 +190,9 @@ public class ExcelToHtmlConverter extends AbstractExcelConverter
StringBuilder style = new StringBuilder();
style.append( "white-space:pre-wrap;" );
ExcelToHtmlUtils.appendAlign( style, cellStyle.getAlignmentEnum() );
ExcelToHtmlUtils.appendAlign( style, cellStyle.getAlignment() );
switch (cellStyle.getFillPatternEnum()) {
switch (cellStyle.getFillPattern()) {
// no fill
case NO_FILL: break;
case SOLID_FOREGROUND:
@ -444,7 +444,7 @@ public class ExcelToHtmlConverter extends AbstractExcelConverter
innerDivStyle.append( "overflow:hidden;max-height:" );
innerDivStyle.append( normalHeightPt );
innerDivStyle.append( "pt;white-space:nowrap;" );
ExcelToHtmlUtils.appendAlign( innerDivStyle, cellStyle.getAlignmentEnum() );
ExcelToHtmlUtils.appendAlign( innerDivStyle, cellStyle.getAlignment() );
htmlDocumentFacade.addStyleClass( outerDiv, cssClassPrefixDiv,
innerDivStyle.toString() );

View File

@ -232,17 +232,17 @@ public final class TestCellStyle extends TestCase {
orig.setFont(fnt);
orig.setDataFormat((short)18);
assertEquals(HorizontalAlignment.JUSTIFY, orig.getAlignmentEnum());
assertEquals(HorizontalAlignment.JUSTIFY, orig.getAlignment());
assertEquals(fnt, orig.getFont(wb));
assertEquals(18, orig.getDataFormat());
HSSFCellStyle clone = wb.createCellStyle();
assertFalse(HorizontalAlignment.RIGHT == clone.getAlignmentEnum());
assertFalse(HorizontalAlignment.RIGHT == clone.getAlignment());
assertFalse(fnt == clone.getFont(wb));
assertFalse(18 == clone.getDataFormat());
clone.cloneStyleFrom(orig);
assertEquals(HorizontalAlignment.JUSTIFY, clone.getAlignmentEnum());
assertEquals(HorizontalAlignment.JUSTIFY, clone.getAlignment());
assertEquals(fnt, clone.getFont(wb));
assertEquals(18, clone.getDataFormat());
assertEquals(5, wb.getNumberOfFonts());
@ -268,7 +268,7 @@ public final class TestCellStyle extends TestCase {
orig.setFont(fnt);
orig.setDataFormat(fmt.getFormat("Test##"));
assertEquals(HorizontalAlignment.RIGHT, orig.getAlignmentEnum());
assertEquals(HorizontalAlignment.RIGHT, orig.getAlignment());
assertEquals(fnt, orig.getFont(wbOrig));
assertEquals(fmt.getFormat("Test##"), orig.getDataFormat());
@ -280,11 +280,11 @@ public final class TestCellStyle extends TestCase {
HSSFCellStyle clone = wbClone.createCellStyle();
assertEquals(4, wbClone.getNumberOfFonts());
assertFalse(HorizontalAlignment.RIGHT == clone.getAlignmentEnum());
assertFalse(HorizontalAlignment.RIGHT == clone.getAlignment());
assertFalse("TestingFont" == clone.getFont(wbClone).getFontName());
clone.cloneStyleFrom(orig);
assertEquals(HorizontalAlignment.RIGHT, clone.getAlignmentEnum());
assertEquals(HorizontalAlignment.RIGHT, clone.getAlignment());
assertEquals("TestingFont", clone.getFont(wbClone).getFontName());
assertEquals(fmtClone.getFormat("Test##"), clone.getDataFormat());
assertFalse(fmtClone.getFormat("Test##") == fmt.getFormat("Test##"));

View File

@ -103,7 +103,7 @@ public final class TestHSSFPalette {
assertEquals(64, cellA.getCellStyle().getFillForegroundColor());
assertEquals(64, cellA.getCellStyle().getFillBackgroundColor());
assertEquals(Font.COLOR_NORMAL, cellA.getCellStyle().getFont(book).getColor());
assertEquals(FillPatternType.NO_FILL, cellA.getCellStyle().getFillPatternEnum());
assertEquals(FillPatternType.NO_FILL, cellA.getCellStyle().getFillPattern());
assertEquals("0:0:0", p.getColor((short)64).getHexString());
assertEquals(null, p.getColor((short)32767));
@ -112,7 +112,7 @@ public final class TestHSSFPalette {
assertEquals(64, cellB.getCellStyle().getFillForegroundColor());
assertEquals(64, cellB.getCellStyle().getFillBackgroundColor());
assertEquals(10, cellB.getCellStyle().getFont(book).getColor());
assertEquals(FillPatternType.NO_FILL, cellB.getCellStyle().getFillPatternEnum());
assertEquals(FillPatternType.NO_FILL, cellB.getCellStyle().getFillPattern());
assertEquals("0:0:0", p.getColor((short)64).getHexString());
assertEquals("FFFF:0:0", p.getColor((short)10).getHexString());
@ -121,7 +121,7 @@ public final class TestHSSFPalette {
assertEquals(11, cellC.getCellStyle().getFillForegroundColor());
assertEquals(64, cellC.getCellStyle().getFillBackgroundColor());
assertEquals(10, cellC.getCellStyle().getFont(book).getColor());
assertEquals(FillPatternType.SOLID_FOREGROUND, cellC.getCellStyle().getFillPatternEnum());
assertEquals(FillPatternType.SOLID_FOREGROUND, cellC.getCellStyle().getFillPattern());
assertEquals("0:FFFF:0", p.getColor((short)11).getHexString());
assertEquals("FFFF:0:0", p.getColor((short)10).getHexString());
@ -130,7 +130,7 @@ public final class TestHSSFPalette {
assertEquals(13, cellD.getCellStyle().getFillForegroundColor());
assertEquals(64, cellD.getCellStyle().getFillBackgroundColor());
assertEquals(14, cellD.getCellStyle().getFont(book).getColor());
assertEquals(FillPatternType.NO_FILL, cellD.getCellStyle().getFillPatternEnum());
assertEquals(FillPatternType.NO_FILL, cellD.getCellStyle().getFillPattern());
assertEquals("FFFF:FFFF:0", p.getColor((short)13).getHexString());
assertEquals("FFFF:0:FFFF", p.getColor((short)14).getHexString());
@ -139,7 +139,7 @@ public final class TestHSSFPalette {
assertEquals(13, cellE.getCellStyle().getFillForegroundColor());
assertEquals(64, cellE.getCellStyle().getFillBackgroundColor());
assertEquals(14, cellE.getCellStyle().getFont(book).getColor());
assertEquals(FillPatternType.NO_FILL, cellE.getCellStyle().getFillPatternEnum());
assertEquals(FillPatternType.NO_FILL, cellE.getCellStyle().getFillPattern());
assertEquals("FFFF:FFFF:0", p.getColor((short)13).getHexString());
assertEquals("FFFF:0:FFFF", p.getColor((short)14).getHexString());
}

View File

@ -160,7 +160,7 @@ public final class TestRowStyle extends TestCase {
assertEquals("Right Border Style for row:", BorderStyle.THIN, cs.getBorderRightEnum());
assertEquals("Top Border Style for row:", BorderStyle.THIN, cs.getBorderTopEnum());
assertEquals("FillForegroundColor for row:", 0xA, cs.getFillForegroundColor());
assertEquals("FillPattern for row:", FillPatternType.BRICKS, cs.getFillPatternEnum());
assertEquals("FillPattern for row:", FillPatternType.BRICKS, cs.getFillPattern());
rownum++;
if (rownum >= 100) break; // I feel too lazy to check if this isreqd :-/
@ -169,7 +169,7 @@ public final class TestRowStyle extends TestCase {
assertNotNull("Row is not null", r);
cs2 = r.getRowStyle();
assertEquals("FillForegroundColor for row: ", cs2.getFillForegroundColor(), (short) 0x0);
assertEquals("FillPattern for row: ", cs2.getFillPatternEnum(), FillPatternType.BRICKS);
assertEquals("FillPattern for row: ", cs2.getFillPattern(), FillPatternType.BRICKS);
}
IOUtils.closeQuietly(wb2);
}

View File

@ -715,7 +715,7 @@ public abstract class BaseTestCell {
assertFalse(style.getHidden());
assertEquals(0, style.getIndention());
assertEquals(0, style.getFontIndex());
assertEquals(HorizontalAlignment.GENERAL, style.getAlignmentEnum());
assertEquals(HorizontalAlignment.GENERAL, style.getAlignment());
assertEquals(0, style.getDataFormat());
assertEquals(false, style.getWrapText());

View File

@ -224,17 +224,17 @@ public class BaseTestCellUtil {
// should be assertSame, but a new HSSFCellStyle is returned for each getCellStyle() call.
// HSSFCellStyle wraps an underlying style record, and the underlying
// style record is the same between multiple getCellStyle() calls.
assertEquals(HorizontalAlignment.GENERAL, A1.getCellStyle().getAlignmentEnum());
assertEquals(HorizontalAlignment.GENERAL, B1.getCellStyle().getAlignmentEnum());
assertEquals(HorizontalAlignment.GENERAL, A1.getCellStyle().getAlignment());
assertEquals(HorizontalAlignment.GENERAL, B1.getCellStyle().getAlignment());
// get/set alignment modifies the cell's style
CellUtil.setAlignment(A1, HorizontalAlignment.RIGHT);
assertEquals(HorizontalAlignment.RIGHT, A1.getCellStyle().getAlignmentEnum());
assertEquals(HorizontalAlignment.RIGHT, A1.getCellStyle().getAlignment());
// get/set alignment doesn't affect the style of cells with
// the same style prior to modifying the style
assertNotEquals(A1.getCellStyle(), B1.getCellStyle());
assertEquals(HorizontalAlignment.GENERAL, B1.getCellStyle().getAlignmentEnum());
assertEquals(HorizontalAlignment.GENERAL, B1.getCellStyle().getAlignment());
wb.close();
}
@ -252,17 +252,17 @@ public class BaseTestCellUtil {
// should be assertSame, but a new HSSFCellStyle is returned for each getCellStyle() call.
// HSSFCellStyle wraps an underlying style record, and the underlying
// style record is the same between multiple getCellStyle() calls.
assertEquals(HorizontalAlignment.GENERAL, A1.getCellStyle().getAlignmentEnum());
assertEquals(HorizontalAlignment.GENERAL, B1.getCellStyle().getAlignmentEnum());
assertEquals(HorizontalAlignment.GENERAL, A1.getCellStyle().getAlignment());
assertEquals(HorizontalAlignment.GENERAL, B1.getCellStyle().getAlignment());
// get/set alignment modifies the cell's style
CellUtil.setAlignment(A1, HorizontalAlignment.RIGHT);
assertEquals(HorizontalAlignment.RIGHT, A1.getCellStyle().getAlignmentEnum());
assertEquals(HorizontalAlignment.RIGHT, A1.getCellStyle().getAlignment());
// get/set alignment doesn't affect the style of cells with
// the same style prior to modifying the style
assertNotEquals(A1.getCellStyle(), B1.getCellStyle());
assertEquals(HorizontalAlignment.GENERAL, B1.getCellStyle().getAlignmentEnum());
assertEquals(HorizontalAlignment.GENERAL, B1.getCellStyle().getAlignment());
wb.close();
}
@ -280,17 +280,17 @@ public class BaseTestCellUtil {
// should be assertSame, but a new HSSFCellStyle is returned for each getCellStyle() call.
// HSSFCellStyle wraps an underlying style record, and the underlying
// style record is the same between multiple getCellStyle() calls.
assertEquals(VerticalAlignment.BOTTOM, A1.getCellStyle().getVerticalAlignmentEnum());
assertEquals(VerticalAlignment.BOTTOM, B1.getCellStyle().getVerticalAlignmentEnum());
assertEquals(VerticalAlignment.BOTTOM, A1.getCellStyle().getVerticalAlignment());
assertEquals(VerticalAlignment.BOTTOM, B1.getCellStyle().getVerticalAlignment());
// get/set alignment modifies the cell's style
CellUtil.setVerticalAlignment(A1, VerticalAlignment.TOP);
assertEquals(VerticalAlignment.TOP, A1.getCellStyle().getVerticalAlignmentEnum());
assertEquals(VerticalAlignment.TOP, A1.getCellStyle().getVerticalAlignment());
// get/set alignment doesn't affect the style of cells with
// the same style prior to modifying the style
assertNotEquals(A1.getCellStyle(), B1.getCellStyle());
assertEquals(VerticalAlignment.BOTTOM, B1.getCellStyle().getVerticalAlignmentEnum());
assertEquals(VerticalAlignment.BOTTOM, B1.getCellStyle().getVerticalAlignment());
wb.close();
}
@ -375,7 +375,7 @@ public class BaseTestCellUtil {
CellUtil.setCellStyleProperties(A1, properties);
CellStyle style = A1.getCellStyle();
assertEquals("fill pattern", FillPatternType.BRICKS, style.getFillPatternEnum());
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();
@ -395,7 +395,7 @@ public class BaseTestCellUtil {
CellUtil.setCellStyleProperties(A1, properties);
CellStyle style = A1.getCellStyle();
assertEquals("fill pattern", FillPatternType.BRICKS, style.getFillPatternEnum());
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()));