bug 59837: replace CellStyle.ALIGN_ and CellStyle.VERTICAL_ constants with HorizontalAlignment and VerticalAlignment enums

git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1752066 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Javen O'Neal 2016-07-10 08:29:02 +00:00
parent 847d90603a
commit 0f8039f3ab
6 changed files with 167 additions and 75 deletions

View File

@ -30,6 +30,8 @@ import org.apache.poi.ss.usermodel.BorderStyle;
import org.apache.poi.ss.usermodel.CellStyle; import org.apache.poi.ss.usermodel.CellStyle;
import org.apache.poi.ss.usermodel.FillPatternType; import org.apache.poi.ss.usermodel.FillPatternType;
import org.apache.poi.ss.usermodel.Font; import org.apache.poi.ss.usermodel.Font;
import org.apache.poi.ss.usermodel.HorizontalAlignment;
import org.apache.poi.ss.usermodel.VerticalAlignment;
/** /**
* High level representation of the style of a cell in a sheet of a workbook. * High level representation of the style of a cell in a sheet of a workbook.
@ -250,6 +252,7 @@ public final class HSSFCellStyle implements CellStyle {
* @see #ALIGN_FILL * @see #ALIGN_FILL
* @see #ALIGN_JUSTIFY * @see #ALIGN_JUSTIFY
* @see #ALIGN_CENTER_SELECTION * @see #ALIGN_CENTER_SELECTION
* @deprecated POI 3.15 beta 3. Use {@link #setAlignment(HorizontalAlignment)} instead.
*/ */
@Override @Override
public void setAlignment(short align) public void setAlignment(short align)
@ -257,6 +260,16 @@ public final class HSSFCellStyle implements CellStyle {
_format.setIndentNotParentAlignment(true); _format.setIndentNotParentAlignment(true);
_format.setAlignment(align); _format.setAlignment(align);
} }
/**
* set the type of horizontal alignment for the cell
* @param align - the type of alignment
*/
@Override
public void setAlignment(HorizontalAlignment align)
{
_format.setIndentNotParentAlignment(true);
_format.setAlignment(align.getCode());
}
/** /**
* get the type of horizontal alignment for the cell * get the type of horizontal alignment for the cell
@ -268,12 +281,22 @@ public final class HSSFCellStyle implements CellStyle {
* @see #ALIGN_FILL * @see #ALIGN_FILL
* @see #ALIGN_JUSTIFY * @see #ALIGN_JUSTIFY
* @see #ALIGN_CENTER_SELECTION * @see #ALIGN_CENTER_SELECTION
* @deprecated POI 3.15 beta 3. Use {@link #getAlignmentEnum()} instead.
*/ */
@Override @Override
public short getAlignment() public short getAlignment()
{ {
return _format.getAlignment(); return _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());
}
/** /**
* set whether the text should be wrapped * set whether the text should be wrapped
@ -303,12 +326,23 @@ public final class HSSFCellStyle implements CellStyle {
* @see #VERTICAL_CENTER * @see #VERTICAL_CENTER
* @see #VERTICAL_BOTTOM * @see #VERTICAL_BOTTOM
* @see #VERTICAL_JUSTIFY * @see #VERTICAL_JUSTIFY
* @see VerticalAlignment
* @deprecated POI 3.15 beta 3. Use {@link #setVerticalAlignment(VerticalAlignment)} instead.
*/ */
@Override @Override
public void setVerticalAlignment(short align) public void setVerticalAlignment(short align)
{ {
_format.setVerticalAlignment(align); _format.setVerticalAlignment(align);
} }
/**
* set the type of vertical alignment for the cell
* @param align the type of alignment
*/
@Override
public void setVerticalAlignment(VerticalAlignment align)
{
_format.setVerticalAlignment(align.getCode());
}
/** /**
* get the type of vertical alignment for the cell * get the type of vertical alignment for the cell
@ -317,12 +351,23 @@ public final class HSSFCellStyle implements CellStyle {
* @see #VERTICAL_CENTER * @see #VERTICAL_CENTER
* @see #VERTICAL_BOTTOM * @see #VERTICAL_BOTTOM
* @see #VERTICAL_JUSTIFY * @see #VERTICAL_JUSTIFY
* @see VerticalAlignment
* @deprecated POI 3.15 beta 3. Use {@link #getVerticalAlignmentEnum()} instead.
*/ */
@Override @Override
public short getVerticalAlignment() public short getVerticalAlignment()
{ {
return _format.getVerticalAlignment(); return _format.getVerticalAlignment();
} }
/**
* get the type of vertical alignment for the cell
* @return align the type of alignment
*/
@Override
public VerticalAlignment getVerticalAlignmentEnum()
{
return VerticalAlignment.forInt(_format.getVerticalAlignment());
}
/** /**
* set the degree of rotation for the text in the cell * set the degree of rotation for the text in the cell

View File

@ -18,6 +18,7 @@
*/ */
package org.apache.poi.sl.usermodel; package org.apache.poi.sl.usermodel;
// FIXME: Identical to {@link org.apache.poi.ss.usermodel.VerticalAlignment}. Should merge these.
/** /**
* Specifies a list of available anchoring types for text * Specifies a list of available anchoring types for text
* *

View File

@ -21,267 +21,267 @@ public interface CellStyle {
/** /**
* general (normal) horizontal alignment * general (normal) horizontal alignment
* @deprecated POI 3.15 beta 3. Use {@link HorizontalAlignment#GENERAL} instead.
*/ */
static final short ALIGN_GENERAL = 0x0; //HorizontalAlignment.GENERAL.getCode();
short ALIGN_GENERAL = 0x0;
/** /**
* left-justified horizontal alignment * left-justified horizontal alignment
* @deprecated POI 3.15 beta 3. Use {@link HorizontalAlignment#LEFT} instead.
*/ */
static final short ALIGN_LEFT = 0x1; //HorizontalAlignment.LEFT.getCode();
short ALIGN_LEFT = 0x1;
/** /**
* center horizontal alignment * center horizontal alignment
* @deprecated POI 3.15 beta 3. Use {@link HorizontalAlignment#CENTER} instead.
*/ */
static final short ALIGN_CENTER = 0x2; //HorizontalAlignment.CENTER.getCode();
short ALIGN_CENTER = 0x2;
/** /**
* right-justified horizontal alignment * right-justified horizontal alignment
* @deprecated POI 3.15 beta 3. Use {@link HorizontalAlignment#RIGHT} instead.
*/ */
static final short ALIGN_RIGHT = 0x3; //HorizontalAlignment.RIGHT.getCode();
short ALIGN_RIGHT = 0x3;
/** /**
* fill? horizontal alignment * fill? horizontal alignment
* @deprecated POI 3.15 beta 3. Use {@link HorizontalAlignment#FILL} instead.
*/ */
static final short ALIGN_FILL = 0x4; //HorizontalAlignment.FILL.getCode();
short ALIGN_FILL = 0x4;
/** /**
* justified horizontal alignment * justified horizontal alignment
* @deprecated POI 3.15 beta 3. Use {@link HorizontalAlignment#JUSTIFY} instead.
*/ */
static final short ALIGN_JUSTIFY = 0x5; //HorizontalAlignment.JUSTIFY.getCode();
short ALIGN_JUSTIFY = 0x5;
/** /**
* center-selection? horizontal alignment * center-selection? horizontal alignment
* @deprecated POI 3.15 beta 3. Use {@link HorizontalAlignment#CENTER_SELECTION} instead.
*/ */
static final short ALIGN_CENTER_SELECTION = 0x6; //HorizontalAlignment.CENTER_SELECTION.getCode();
short ALIGN_CENTER_SELECTION = 0x6;
/** /**
* top-aligned vertical alignment * top-aligned vertical alignment
* @deprecated POI 3.15 beta 3. Use {@link VerticalAlignment#TOP} instead.
*/ */
static final short VERTICAL_TOP = 0x0; //VerticalAlignment.TOP.getCode();
short VERTICAL_TOP = 0x0;
/** /**
* center-aligned vertical alignment * center-aligned vertical alignment
* @deprecated POI 3.15 beta 3. Use {@link VerticalAlignment#CENTER} instead.
*/ */
static final short VERTICAL_CENTER = 0x1; //VerticalAlignment.CENTER.getCode();
short VERTICAL_CENTER = 0x1;
/** /**
* bottom-aligned vertical alignment * bottom-aligned vertical alignment
* @deprecated POI 3.15 beta 3. Use {@link VerticalAlignment#BOTTOM} instead.
*/ */
static final short VERTICAL_BOTTOM = 0x2; //VerticalAlignment.BOTTOM.getCode();
short VERTICAL_BOTTOM = 0x2;
/** /**
* vertically justified vertical alignment * vertically justified vertical alignment
* @deprecated POI 3.15 beta 3. Use {@link VerticalAlignment#TOP} instead.
*/ */
static final short VERTICAL_JUSTIFY = 0x3; //VerticalAlignment.JUSTIFY.getCode();
short VERTICAL_JUSTIFY = 0x3;
/** /**
* No border * No border
* @deprecated 3.15 beta 2. Use {@link BorderStyle#NONE} instead. * @deprecated 3.15 beta 2. Use {@link BorderStyle#NONE} instead.
*/ */
short BORDER_NONE = BorderStyle.NONE.getCode(); static final short BORDER_NONE = 0x0; //BorderStyle.NONE.getCode();
/** /**
* Thin border * Thin border
* @deprecated 3.15 beta 2. Use {@link BorderStyle#THIN} instead. * @deprecated 3.15 beta 2. Use {@link BorderStyle#THIN} instead.
*/ */
short BORDER_THIN = BorderStyle.THIN.getCode(); static final short BORDER_THIN = 0x1; //BorderStyle.THIN.getCode();
/** /**
* Medium border * Medium border
* @deprecated 3.15 beta 2. Use {@link BorderStyle#MEDIUM} instead. * @deprecated 3.15 beta 2. Use {@link BorderStyle#MEDIUM} instead.
*/ */
short BORDER_MEDIUM = BorderStyle.MEDIUM.getCode(); static final short BORDER_MEDIUM = 0x2; //BorderStyle.MEDIUM.getCode();
/** /**
* dash border * dash border
* @deprecated 3.15 beta 2. Use {@link BorderStyle#DASHED} instead. * @deprecated 3.15 beta 2. Use {@link BorderStyle#DASHED} instead.
*/ */
short BORDER_DASHED = BorderStyle.DASHED.getCode(); static final short BORDER_DASHED = 0x3; //BorderStyle.DASHED.getCode();
/** /**
* dot border * dot border
* @deprecated 3.15 beta 2. Use {@link BorderStyle#DOTTED} instead. * @deprecated 3.15 beta 2. Use {@link BorderStyle#DOTTED} instead.
*/ */
short BORDER_DOTTED = BorderStyle.DOTTED.getCode(); static final short BORDER_DOTTED = 0x4; //BorderStyle.DOTTED.getCode();
/** /**
* Thick border * Thick border
* @deprecated 3.15 beta 2. Use {@link BorderStyle#THICK} instead. * @deprecated 3.15 beta 2. Use {@link BorderStyle#THICK} instead.
*/ */
short BORDER_THICK = BorderStyle.THICK.getCode(); static final short BORDER_THICK = 0x5; //BorderStyle.THICK.getCode();
/** /**
* double-line border * double-line border
* @deprecated 3.15 beta 2. Use {@link BorderStyle#DOUBLE} instead. * @deprecated 3.15 beta 2. Use {@link BorderStyle#DOUBLE} instead.
*/ */
short BORDER_DOUBLE = BorderStyle.DOUBLE.getCode(); static final short BORDER_DOUBLE = 0x6; //BorderStyle.DOUBLE.getCode();
/** /**
* hair-line border * hair-line border
* @deprecated 3.15 beta 2. Use {@link BorderStyle#HAIR} instead. * @deprecated 3.15 beta 2. Use {@link BorderStyle#HAIR} instead.
*/ */
short BORDER_HAIR = BorderStyle.HAIR.getCode(); static final short BORDER_HAIR = 0x7; //BorderStyle.HAIR.getCode();
/** /**
* Medium dashed border * Medium dashed border
* @deprecated 3.15 beta 2. Use {@link BorderStyle#MEDIUM_DASHED} instead. * @deprecated 3.15 beta 2. Use {@link BorderStyle#MEDIUM_DASHED} instead.
*/ */
short BORDER_MEDIUM_DASHED = BorderStyle.MEDIUM_DASHED.getCode(); static final short BORDER_MEDIUM_DASHED = 0x8; //BorderStyle.MEDIUM_DASHED.getCode();
/** /**
* dash-dot border * dash-dot border
* @deprecated 3.15 beta 2. Use {@link BorderStyle#DASH_DOT} instead. * @deprecated 3.15 beta 2. Use {@link BorderStyle#DASH_DOT} instead.
*/ */
short BORDER_DASH_DOT = BorderStyle.DASH_DOT.getCode(); static final short BORDER_DASH_DOT = 0x9; //BorderStyle.DASH_DOT.getCode();
/** /**
* medium dash-dot border * medium dash-dot border
* @deprecated 3.15 beta 2. Use {@link BorderStyle#MEDIUM_DASH_DOT} instead. * @deprecated 3.15 beta 2. Use {@link BorderStyle#MEDIUM_DASH_DOT} instead.
*/ */
short BORDER_MEDIUM_DASH_DOT = BorderStyle.MEDIUM_DASH_DOT.getCode(); static final short BORDER_MEDIUM_DASH_DOT = 0xA; //BorderStyle.MEDIUM_DASH_DOT.getCode();
/** /**
* dash-dot-dot border * dash-dot-dot border
* @deprecated 3.15 beta 2. Use {@link BorderStyle#DASH_DOT_DOT} instead. * @deprecated 3.15 beta 2. Use {@link BorderStyle#DASH_DOT_DOT} instead.
*/ */
short BORDER_DASH_DOT_DOT = BorderStyle.DASH_DOT_DOT.getCode(); static final short BORDER_DASH_DOT_DOT = 0xB; //BorderStyle.DASH_DOT_DOT.getCode();
/** /**
* medium dash-dot-dot border * medium dash-dot-dot border
* @deprecated 3.15 beta 2. Use {@link BorderStyle#MEDIUM_DASH_DOT_DOT} instead. * @deprecated 3.15 beta 2. Use {@link BorderStyle#MEDIUM_DASH_DOT_DOT} instead.
*/ */
short BORDER_MEDIUM_DASH_DOT_DOT = BorderStyle.MEDIUM_DASH_DOT_DOT.getCode(); static final short BORDER_MEDIUM_DASH_DOT_DOT = 0xC; //BorderStyle.MEDIUM_DASH_DOT_DOT.getCode();
/** /**
* slanted dash-dot border * slanted dash-dot border
* @deprecated 3.15 beta 2. Use {@link BorderStyle#SLANTED_DASH_DOT} instead. * @deprecated 3.15 beta 2. Use {@link BorderStyle#SLANTED_DASH_DOT} instead.
*/ */
short BORDER_SLANTED_DASH_DOT = BorderStyle.SLANTED_DASH_DOT.getCode(); static final short BORDER_SLANTED_DASH_DOT = 0xD; //BorderStyle.SLANTED_DASH_DOT.getCode();
/** /**
* Fill Pattern: No background * Fill Pattern: No background
* @deprecated 3.15 beta 3. Use {@link FillPatternType#NO_FILL} instead. * @deprecated 3.15 beta 3. Use {@link FillPatternType#NO_FILL} instead.
*/ */
short NO_FILL = FillPatternType.NO_FILL.getCode(); static final short NO_FILL = 0; //FillPatternType.NO_FILL.getCode();
/** /**
* Fill Pattern: Solidly filled * Fill Pattern: Solidly filled
* @deprecated 3.15 beta 3. Use {@link FillPatternType#SOLID_FOREGROUND} instead. * @deprecated 3.15 beta 3. Use {@link FillPatternType#SOLID_FOREGROUND} instead.
*/ */
short SOLID_FOREGROUND = FillPatternType.SOLID_FOREGROUND.getCode(); static final short SOLID_FOREGROUND = 1; //FillPatternType.SOLID_FOREGROUND.getCode();
/** /**
* Fill Pattern: Small fine dots * Fill Pattern: Small fine dots
* @deprecated 3.15 beta 3. Use {@link FillPatternType#FINE_DOTS} instead. * @deprecated 3.15 beta 3. Use {@link FillPatternType#FINE_DOTS} instead.
*/ */
short FINE_DOTS = FillPatternType.FINE_DOTS.getCode(); static final short FINE_DOTS = 2; //FillPatternType.FINE_DOTS.getCode();
/** /**
* Fill Pattern: Wide dots * Fill Pattern: Wide dots
* @deprecated 3.15 beta 3. Use {@link FillPatternType#ALT_BARS} instead. * @deprecated 3.15 beta 3. Use {@link FillPatternType#ALT_BARS} instead.
*/ */
short ALT_BARS = FillPatternType.ALT_BARS.getCode(); static final short ALT_BARS = 3; //FillPatternType.ALT_BARS.getCode();
/** /**
* Fill Pattern: Sparse dots * Fill Pattern: Sparse dots
* @deprecated 3.15 beta 3. Use {@link FillPatternType#SPARSE_DOTS} instead. * @deprecated 3.15 beta 3. Use {@link FillPatternType#SPARSE_DOTS} instead.
*/ */
short SPARSE_DOTS = FillPatternType.SPARSE_DOTS.getCode(); static final short SPARSE_DOTS = 4; //FillPatternType.SPARSE_DOTS.getCode();
/** /**
* Fill Pattern: Thick horizontal bands * Fill Pattern: Thick horizontal bands
* @deprecated 3.15 beta 3. Use {@link FillPatternType#THICK_HORZ_BANDS} instead. * @deprecated 3.15 beta 3. Use {@link FillPatternType#THICK_HORZ_BANDS} instead.
*/ */
short THICK_HORZ_BANDS = FillPatternType.THICK_HORZ_BANDS.getCode(); static final short THICK_HORZ_BANDS = 5; //FillPatternType.THICK_HORZ_BANDS.getCode();
/** /**
* Fill Pattern: Thick vertical bands * Fill Pattern: Thick vertical bands
* @deprecated 3.15 beta 3. Use {@link FillPatternType#THICK_VERT_BANDS} instead. * @deprecated 3.15 beta 3. Use {@link FillPatternType#THICK_VERT_BANDS} instead.
*/ */
short THICK_VERT_BANDS = FillPatternType.THICK_VERT_BANDS.getCode(); static final short THICK_VERT_BANDS = 6; //FillPatternType.THICK_VERT_BANDS.getCode();
/** /**
* Fill Pattern: Thick backward facing diagonals * Fill Pattern: Thick backward facing diagonals
* @deprecated 3.15 beta 3. Use {@link FillPatternType#NO_FILL} instead. * @deprecated 3.15 beta 3. Use {@link FillPatternType#THICK_BACKWARD_DIAG} instead.
*/ */
short THICK_BACKWARD_DIAG = 7; static final short THICK_BACKWARD_DIAG = 7; //FillPatternType.THICK_BACKWARD_DIAG.getCode();
/** /**
* Fill Pattern: Thick forward facing diagonals * Fill Pattern: Thick forward facing diagonals
* @deprecated 3.15 beta 3. Use {@link FillPatternType#NO_FILL} instead. * @deprecated 3.15 beta 3. Use {@link FillPatternType#THICK_FORWARD_DIAG} instead.
*/ */
short THICK_FORWARD_DIAG = FillPatternType.THICK_FORWARD_DIAG.getCode(); static final short THICK_FORWARD_DIAG = 8; //FillPatternType.THICK_FORWARD_DIAG.getCode();
/** /**
* Fill Pattern: Large spots * Fill Pattern: Large spots
* @deprecated 3.15 beta 3. Use {@link FillPatternType#BIG_SPOTS} instead. * @deprecated 3.15 beta 3. Use {@link FillPatternType#BIG_SPOTS} instead.
*/ */
short BIG_SPOTS = FillPatternType.BIG_SPOTS.getCode(); static final short BIG_SPOTS = 9; //FillPatternType.BIG_SPOTS.getCode();
/** /**
* Fill Pattern: Brick-like layout * Fill Pattern: Brick-like layout
* @deprecated 3.15 beta 3. Use {@link FillPatternType#BRICKS} instead. * @deprecated 3.15 beta 3. Use {@link FillPatternType#BRICKS} instead.
*/ */
short BRICKS = FillPatternType.BRICKS.getCode(); static final short BRICKS = 10; //FillPatternType.BRICKS.getCode();
/** /**
* Fill Pattern: Thin horizontal bands * Fill Pattern: Thin horizontal bands
* @deprecated 3.15 beta 3. Use {@link FillPatternType#THIN_HORZ_BANDS} instead. * @deprecated 3.15 beta 3. Use {@link FillPatternType#THIN_HORZ_BANDS} instead.
*/ */
short THIN_HORZ_BANDS = FillPatternType.THIN_HORZ_BANDS.getCode(); static final short THIN_HORZ_BANDS = 11; //FillPatternType.THIN_HORZ_BANDS.getCode();
/** /**
* Fill Pattern: Thin vertical bands * Fill Pattern: Thin vertical bands
* @deprecated 3.15 beta 3. Use {@link FillPatternType#THIN_VERT_BANDS} instead. * @deprecated 3.15 beta 3. Use {@link FillPatternType#THIN_VERT_BANDS} instead.
*/ */
short THIN_VERT_BANDS = FillPatternType.THIN_VERT_BANDS.getCode(); static final short THIN_VERT_BANDS = 12; //FillPatternType.THIN_VERT_BANDS.getCode();
/** /**
* Fill Pattern: Thin backward diagonal * Fill Pattern: Thin backward diagonal
* @deprecated 3.15 beta 3. Use {@link FillPatternType#THIN_BACKWARD_DIAG} instead. * @deprecated 3.15 beta 3. Use {@link FillPatternType#THIN_BACKWARD_DIAG} instead.
*/ */
short THIN_BACKWARD_DIAG = FillPatternType.THIN_BACKWARD_DIAG.getCode(); static final short THIN_BACKWARD_DIAG = 13; //FillPatternType.THIN_BACKWARD_DIAG.getCode();
/** /**
* Fill Pattern: Thin forward diagonal * Fill Pattern: Thin forward diagonal
* @deprecated 3.15 beta 3. Use {@link FillPatternType#THIN_FORWARD_DIAG} instead. * @deprecated 3.15 beta 3. Use {@link FillPatternType#THIN_FORWARD_DIAG} instead.
*/ */
short THIN_FORWARD_DIAG = FillPatternType.THIN_FORWARD_DIAG.getCode(); static final short THIN_FORWARD_DIAG = 14; //FillPatternType.THIN_FORWARD_DIAG.getCode();
/** /**
* Fill Pattern: Squares * Fill Pattern: Squares
* @deprecated 3.15 beta 3. Use {@link FillPatternType#SQUARES} instead. * @deprecated 3.15 beta 3. Use {@link FillPatternType#SQUARES} instead.
*/ */
short SQUARES = FillPatternType.SQUARES.getCode(); static final short SQUARES = 15; //FillPatternType.SQUARES.getCode();
/** /**
* Fill Pattern: Diamonds * Fill Pattern: Diamonds
* @deprecated 3.15 beta 3. Use {@link FillPatternType#DIAMONDS} instead. * @deprecated 3.15 beta 3. Use {@link FillPatternType#DIAMONDS} instead.
*/ */
short DIAMONDS = FillPatternType.DIAMONDS.getCode(); static final short DIAMONDS = 16; //FillPatternType.DIAMONDS.getCode();
/** /**
* Fill Pattern: Less Dots * Fill Pattern: Less Dots
* @deprecated 3.15 beta 3. Use {@link FillPatternType#LESS_DOTS} instead. * @deprecated 3.15 beta 3. Use {@link FillPatternType#LESS_DOTS} instead.
*/ */
short LESS_DOTS = FillPatternType.LESS_DOTS.getCode(); static final short LESS_DOTS = 17; //FillPatternType.LESS_DOTS.getCode();
/** /**
* Fill Pattern: Least Dots * Fill Pattern: Least Dots
* @deprecated 3.15 beta 3. Use {@link FillPatternType#LEAST_DOTS} instead. * @deprecated 3.15 beta 3. Use {@link FillPatternType#LEAST_DOTS} instead.
*/ */
short LEAST_DOTS = FillPatternType.LEAST_DOTS.getCode(); static final short LEAST_DOTS = 18; //FillPatternType.LEAST_DOTS.getCode();
/** /**
* get the index within the Workbook (sequence within the collection of ExtnededFormat objects) * get the index within the Workbook (sequence within the collection of ExtnededFormat objects)
@ -362,9 +362,14 @@ public interface CellStyle {
* @see #ALIGN_FILL * @see #ALIGN_FILL
* @see #ALIGN_JUSTIFY * @see #ALIGN_JUSTIFY
* @see #ALIGN_CENTER_SELECTION * @see #ALIGN_CENTER_SELECTION
* @deprecated POI 3.15 beta 3. Use {@link #setAlignment(HorizontalAlignment)} instead.
*/ */
void setAlignment(short align); void setAlignment(short align);
/**
* set the type of horizontal alignment for the cell
* @param align - the type of alignment
*/
void setAlignment(HorizontalAlignment align);
/** /**
* get the type of horizontal alignment for the cell * get the type of horizontal alignment for the cell
@ -376,14 +381,19 @@ public interface CellStyle {
* @see #ALIGN_FILL * @see #ALIGN_FILL
* @see #ALIGN_JUSTIFY * @see #ALIGN_JUSTIFY
* @see #ALIGN_CENTER_SELECTION * @see #ALIGN_CENTER_SELECTION
* @deprecated POI 3.15 beta 3. Use {@link #getAlignmentEnum()} instead.
*/ */
short getAlignment(); short getAlignment();
/**
* get the type of horizontal alignment for the cell
* @return align - the type of alignment
*/
HorizontalAlignment getAlignmentEnum();
/** /**
* Set whether the text should be wrapped. * Set whether the text should be wrapped.
* Setting this flag to <code>true</code> make all content visible * Setting this flag to <code>true</code> make all content visible
* whithin a cell by displaying it on multiple lines * within a cell by displaying it on multiple lines
* *
* @param wrapped wrap text or not * @param wrapped wrap text or not
*/ */
@ -404,9 +414,14 @@ public interface CellStyle {
* @see #VERTICAL_CENTER * @see #VERTICAL_CENTER
* @see #VERTICAL_BOTTOM * @see #VERTICAL_BOTTOM
* @see #VERTICAL_JUSTIFY * @see #VERTICAL_JUSTIFY
* @deprecated POI 3.15 beta 3. Use {@link #setVerticalAlignment(VerticalAlignment)} instead.
*/ */
void setVerticalAlignment(short align); void setVerticalAlignment(short align);
/**
* set the type of vertical alignment for the cell
* @param align the type of alignment
*/
void setVerticalAlignment(VerticalAlignment align);
/** /**
* get the type of vertical alignment for the cell * get the type of vertical alignment for the cell
@ -415,9 +430,14 @@ public interface CellStyle {
* @see #VERTICAL_CENTER * @see #VERTICAL_CENTER
* @see #VERTICAL_BOTTOM * @see #VERTICAL_BOTTOM
* @see #VERTICAL_JUSTIFY * @see #VERTICAL_JUSTIFY
* @deprecated POI 3.15 beta 3. Use {@link #getVerticalAlignmentEnum()} instead.
*/ */
short getVerticalAlignment(); short getVerticalAlignment();
/**
* get the type of vertical alignment for the cell
* @return align the type of alignment
*/
VerticalAlignment getVerticalAlignmentEnum();
/** /**
* set the degree of rotation for the text in the cell. * set the degree of rotation for the text in the cell.

View File

@ -91,5 +91,15 @@ public enum HorizontalAlignment {
* <p> A 'word' is a set of characters with no space character in them. </p> * <p> A 'word' is a set of characters with no space character in them. </p>
* <p> Two lines inside a cell are separated by a carriage return. </p> * <p> Two lines inside a cell are separated by a carriage return. </p>
*/ */
DISTRIBUTED DISTRIBUTED;
public short getCode() {
return (short) ordinal();
}
public static HorizontalAlignment forInt(int code) {
if (code < 0 || code >= values().length) {
throw new IllegalArgumentException("Invalid HorizontalAlignment code: " + code);
}
return values()[code];
}
} }

View File

@ -17,9 +17,11 @@
package org.apache.poi.ss.usermodel; package org.apache.poi.ss.usermodel;
//FIXME: Identical to {@link org.apache.poi.ss.usermodel.VerticalAlignment}. Should merge these.
/** /**
* This enumeration value indicates the type of vertical alignment for a cell, i.e., * This enumeration value indicates the type of vertical alignment for a cell, i.e.,
* whether it is aligned top, bottom, vertically centered, justified or distributed. * whether it is aligned top, bottom, vertically centered, justified or distributed.
* FIXME: Identical to {@link org.apache.poi.ss.usermodel.VerticalAlignment}. Should merge these.
*/ */
public enum VerticalAlignment { public enum VerticalAlignment {
/** /**
@ -65,5 +67,15 @@ public enum VerticalAlignment {
* and the line of text is distributed evenly from top to bottom. * and the line of text is distributed evenly from top to bottom.
* </p> * </p>
*/ */
DISTRIBUTED DISTRIBUTED;
public short getCode() {
return (short) ordinal();
}
public static VerticalAlignment forInt(int code) {
if (code < 0 || code >= values().length) {
throw new IllegalArgumentException("Invalid VerticalAlignment code: " + code);
}
return values()[code];
}
} }

View File

@ -228,22 +228,23 @@ public class XSSFCellStyle implements CellStyle {
* @see org.apache.poi.ss.usermodel.CellStyle#ALIGN_FILL * @see org.apache.poi.ss.usermodel.CellStyle#ALIGN_FILL
* @see org.apache.poi.ss.usermodel.CellStyle#ALIGN_JUSTIFY * @see org.apache.poi.ss.usermodel.CellStyle#ALIGN_JUSTIFY
* @see org.apache.poi.ss.usermodel.CellStyle#ALIGN_CENTER_SELECTION * @see org.apache.poi.ss.usermodel.CellStyle#ALIGN_CENTER_SELECTION
* @deprecated POI 3.15 beta 3. Use {@link #getAlignmentEnum()} instead.
*/ */
@Override @Override
public short getAlignment() { public short getAlignment() {
return (short)(getAlignmentEnum().ordinal()); return getAlignmentEnum().getCode();
} }
/** /**
* Get the type of horizontal alignment for the cell * Get the type of horizontal alignment for the cell
* *
* @return HorizontalAlignment - the type of alignment * @return HorizontalAlignment - the type of alignment
* @see org.apache.poi.ss.usermodel.HorizontalAlignment
*/ */
@Override
public HorizontalAlignment getAlignmentEnum() { public HorizontalAlignment getAlignmentEnum() {
CTCellAlignment align = _cellXf.getAlignment(); CTCellAlignment align = _cellXf.getAlignment();
if(align != null && align.isSetHorizontal()) { if(align != null && align.isSetHorizontal()) {
return HorizontalAlignment.values()[align.getHorizontal().intValue()-1]; return HorizontalAlignment.forInt(align.getHorizontal().intValue()-1);
} }
return HorizontalAlignment.GENERAL; return HorizontalAlignment.GENERAL;
} }
@ -729,22 +730,23 @@ public class XSSFCellStyle implements CellStyle {
* @see org.apache.poi.ss.usermodel.CellStyle#VERTICAL_CENTER * @see org.apache.poi.ss.usermodel.CellStyle#VERTICAL_CENTER
* @see org.apache.poi.ss.usermodel.CellStyle#VERTICAL_BOTTOM * @see org.apache.poi.ss.usermodel.CellStyle#VERTICAL_BOTTOM
* @see org.apache.poi.ss.usermodel.CellStyle#VERTICAL_JUSTIFY * @see org.apache.poi.ss.usermodel.CellStyle#VERTICAL_JUSTIFY
* @deprecated POI 3.15 beta 3. Use {@link #getVerticalAlignmentEnum()} instead.
*/ */
@Override @Override
public short getVerticalAlignment() { public short getVerticalAlignment() {
return (short) (getVerticalAlignmentEnum().ordinal()); return getVerticalAlignmentEnum().getCode();
} }
/** /**
* Get the type of vertical alignment for the cell * Get the type of vertical alignment for the cell
* *
* @return the type of alignment, default value is {@link org.apache.poi.ss.usermodel.VerticalAlignment#BOTTOM} * @return the type of alignment, default value is {@link VerticalAlignment#BOTTOM}
* @see org.apache.poi.ss.usermodel.VerticalAlignment
*/ */
@Override
public VerticalAlignment getVerticalAlignmentEnum() { public VerticalAlignment getVerticalAlignmentEnum() {
CTCellAlignment align = _cellXf.getAlignment(); CTCellAlignment align = _cellXf.getAlignment();
if(align != null && align.isSetVertical()) { if(align != null && align.isSetVertical()) {
return VerticalAlignment.values()[align.getVertical().intValue()-1]; return VerticalAlignment.forInt(align.getVertical().intValue()-1);
} }
return VerticalAlignment.BOTTOM; return VerticalAlignment.BOTTOM;
} }
@ -771,20 +773,21 @@ public class XSSFCellStyle implements CellStyle {
* @see org.apache.poi.ss.usermodel.CellStyle#ALIGN_FILL * @see org.apache.poi.ss.usermodel.CellStyle#ALIGN_FILL
* @see org.apache.poi.ss.usermodel.CellStyle#ALIGN_JUSTIFY * @see org.apache.poi.ss.usermodel.CellStyle#ALIGN_JUSTIFY
* @see org.apache.poi.ss.usermodel.CellStyle#ALIGN_CENTER_SELECTION * @see org.apache.poi.ss.usermodel.CellStyle#ALIGN_CENTER_SELECTION
* @deprecated POI 3.15 beta 3. Use {@link #setAlignment(HorizontalAlignment)} instead.
*/ */
@Override @Override
public void setAlignment(short align) { public void setAlignment(short align) {
getCellAlignment().setHorizontal(HorizontalAlignment.values()[align]); setAlignment(HorizontalAlignment.forInt(align));
} }
/** /**
* Set the type of horizontal alignment for the cell * Set the type of horizontal alignment for the cell
* *
* @param align - the type of alignment * @param align - the type of alignment
* @see org.apache.poi.ss.usermodel.HorizontalAlignment
*/ */
@Override
public void setAlignment(HorizontalAlignment align) { public void setAlignment(HorizontalAlignment align) {
setAlignment((short)align.ordinal()); getCellAlignment().setHorizontal(align);
} }
/** /**
@ -1330,10 +1333,11 @@ public class XSSFCellStyle implements CellStyle {
* @see org.apache.poi.ss.usermodel.CellStyle#VERTICAL_BOTTOM * @see org.apache.poi.ss.usermodel.CellStyle#VERTICAL_BOTTOM
* @see org.apache.poi.ss.usermodel.CellStyle#VERTICAL_JUSTIFY * @see org.apache.poi.ss.usermodel.CellStyle#VERTICAL_JUSTIFY
* @see org.apache.poi.ss.usermodel.VerticalAlignment * @see org.apache.poi.ss.usermodel.VerticalAlignment
* @deprecated POI 3.15 beta 3. Use {@link #setVerticalAlignment(VerticalAlignment)} instead.
*/ */
@Override @Override
public void setVerticalAlignment(short align) { public void setVerticalAlignment(short align) {
getCellAlignment().setVertical(VerticalAlignment.values()[align]); setVerticalAlignment(VerticalAlignment.forInt(align));
} }
/** /**