Переглянути джерело

bug 59264: revert CellStyle#getBorder[Top|Bottom|Left|Right]() to return short and add getBorder[Top|Bottom|Left|Right]Enum() returns BorderStyle enum for backwards compatibility with POI 3.14 and earlier

git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1760630 13f79535-47bb-0310-9956-ffa450edef68
tags/REL_3_15_FINAL^2
Javen O'Neal 7 роки тому
джерело
коміт
64f1a5b33f

+ 2
- 2
src/examples/src/org/apache/poi/hssf/view/SVTableCellRenderer.java Переглянути файл

@@ -160,8 +160,8 @@ public class SVTableCellRenderer extends JLabel
SVTableUtils.getAWTColor(s.getRightBorderColor(), SVTableUtils.black),
SVTableUtils.getAWTColor(s.getBottomBorderColor(), SVTableUtils.black),
SVTableUtils.getAWTColor(s.getLeftBorderColor(), SVTableUtils.black),
s.getBorderTop(), s.getBorderRight(),
s.getBorderBottom(), s.getBorderLeft(),
s.getBorderTopEnum(), s.getBorderRightEnum(),
s.getBorderBottomEnum(), s.getBorderLeftEnum(),
hasFocus);
setBorder(cellBorder);
isBorderSet=true;

+ 8
- 8
src/examples/src/org/apache/poi/ss/examples/ExcelComparator.java Переглянути файл

@@ -367,23 +367,23 @@ public class ExcelComparator {
String borderName;
switch (borderSide) {
case 't': default:
b1 = style1.getBorderTop() == BorderStyle.THIN;
b2 = style2.getBorderTop() == BorderStyle.THIN;
b1 = style1.getBorderTopEnum() == BorderStyle.THIN;
b2 = style2.getBorderTopEnum() == BorderStyle.THIN;
borderName = "TOP";
break;
case 'b':
b1 = style1.getBorderBottom() == BorderStyle.THIN;
b2 = style2.getBorderBottom() == BorderStyle.THIN;
b1 = style1.getBorderBottomEnum() == BorderStyle.THIN;
b2 = style2.getBorderBottomEnum() == BorderStyle.THIN;
borderName = "BOTTOM";
break;
case 'l':
b1 = style1.getBorderLeft() == BorderStyle.THIN;
b2 = style2.getBorderLeft() == BorderStyle.THIN;
b1 = style1.getBorderLeftEnum() == BorderStyle.THIN;
b2 = style2.getBorderLeftEnum() == BorderStyle.THIN;
borderName = "LEFT";
break;
case 'r':
b1 = style1.getBorderRight() == BorderStyle.THIN;
b2 = style2.getBorderRight() == BorderStyle.THIN;
b1 = style1.getBorderRightEnum() == BorderStyle.THIN;
b2 = style2.getBorderRightEnum() == BorderStyle.THIN;
borderName = "RIGHT";
break;
}

+ 4
- 4
src/examples/src/org/apache/poi/ss/examples/html/ToHtml.java Переглянути файл

@@ -298,10 +298,10 @@ public class ToHtml {
}

private void borderStyles(CellStyle style) {
styleOut("border-left", style.getBorderLeft(), BORDER);
styleOut("border-right", style.getBorderRight(), BORDER);
styleOut("border-top", style.getBorderTop(), BORDER);
styleOut("border-bottom", style.getBorderBottom(), BORDER);
styleOut("border-left", style.getBorderLeftEnum(), BORDER);
styleOut("border-right", style.getBorderRightEnum(), BORDER);
styleOut("border-top", style.getBorderTopEnum(), BORDER);
styleOut("border-bottom", style.getBorderBottomEnum(), BORDER);
}

private void fontStyle(CellStyle style) {

+ 58
- 4
src/java/org/apache/poi/hssf/usermodel/HSSFCellStyle.java Переглянути файл

@@ -331,6 +331,7 @@ public final class HSSFCellStyle implements CellStyle {
* @see VerticalAlignment
* @deprecated POI 3.15 beta 3. Use {@link #setVerticalAlignment(VerticalAlignment)} instead.
*/
@Removal(version="3.17")
@Override
public void setVerticalAlignment(short align)
{
@@ -461,6 +462,7 @@ public final class HSSFCellStyle implements CellStyle {
* @see #BORDER_SLANTED_DASH_DOT
* @deprecated 3.15 beta 2. Use {@link HSSFCellStyle#setBorderLeft(BorderStyle)} instead.
*/
@Removal(version="3.17")
@Override
public void setBorderLeft(short border)
{
@@ -471,6 +473,7 @@ public final class HSSFCellStyle implements CellStyle {
/**
* set the type of border to use for the left border of the cell
* @param border type
* @since POI 3.15
*/
@Override
public void setBorderLeft(BorderStyle border)
@@ -481,9 +484,20 @@ public final class HSSFCellStyle implements CellStyle {
/**
* get the type of border to use for the left border of the cell
* @return border type
* @deprecated POI 3.15. Will return a BorderStyle enum in the future. Use {@link #getBorderLeftEnum()}.
*/
@Override
public short getBorderLeft()
{
return _format.getBorderLeft();
}
/**
* get the type of border to use for the left border of the cell
* @return border type
* @since POI 3.15
*/
@Override
public BorderStyle getBorderLeft()
public BorderStyle getBorderLeftEnum()
{
return BorderStyle.valueOf(_format.getBorderLeft());
}
@@ -507,6 +521,7 @@ public final class HSSFCellStyle implements CellStyle {
* @see #BORDER_SLANTED_DASH_DOT
* @deprecated 3.15 beta 2. Use {@link HSSFCellStyle#setBorderRight(BorderStyle)} instead.
*/
@Removal(version="3.17")
@Override
public void setBorderRight(short border)
{
@@ -517,6 +532,7 @@ public final class HSSFCellStyle implements CellStyle {
/**
* set the type of border to use for the right border of the cell
* @param border type
* @since POI 3.15
*/
@Override
public void setBorderRight(BorderStyle border)
@@ -527,9 +543,20 @@ public final class HSSFCellStyle implements CellStyle {
/**
* get the type of border to use for the right border of the cell
* @return border type
* @deprecated POI 3.15. Will return a BorderStyle enum in the future. Use {@link #getBorderRightEnum()}.
*/
@Override
public short getBorderRight()
{
return _format.getBorderRight();
}
/**
* get the type of border to use for the right border of the cell
* @return border type
* @since POI 3.15
*/
@Override
public BorderStyle getBorderRight()
public BorderStyle getBorderRightEnum()
{
return BorderStyle.valueOf(_format.getBorderRight());
}
@@ -553,6 +580,7 @@ public final class HSSFCellStyle implements CellStyle {
* @see #BORDER_SLANTED_DASH_DOT
* @deprecated 3.15 beta 2. Use {@link HSSFCellStyle#setBorderTop(BorderStyle)} instead.
*/
@Removal(version="3.17")
@Override
public void setBorderTop(short border)
{
@@ -563,6 +591,7 @@ public final class HSSFCellStyle implements CellStyle {
/**
* set the type of border to use for the top border of the cell
* @param border type
* @since POI 3.15
*/
@Override
public void setBorderTop(BorderStyle border)
@@ -573,9 +602,20 @@ public final class HSSFCellStyle implements CellStyle {
/**
* get the type of border to use for the top border of the cell
* @return border type
* @deprecated POI 3.15. Will return a BorderStyle enum in the future. Use {@link #getBorderTopEnum()}.
*/
@Override
public BorderStyle getBorderTop()
public short getBorderTop()
{
return _format.getBorderTop();
}
/**
* get the type of border to use for the top border of the cell
* @return border type
* @since 3.15
*/
@Override
public BorderStyle getBorderTopEnum()
{
return BorderStyle.valueOf(_format.getBorderTop());
}
@@ -599,6 +639,7 @@ public final class HSSFCellStyle implements CellStyle {
* @see #BORDER_SLANTED_DASH_DOT
* @deprecated 3.15 beta 2. Use {@link HSSFCellStyle#setBorderBottom(BorderStyle)} instead.
*/
@Removal(version="3.17")
@Override
public void setBorderBottom(short border)
{
@@ -609,6 +650,7 @@ public final class HSSFCellStyle implements CellStyle {
/**
* set the type of border to use for the bottom border of the cell
* @param border type
* @since 3.15 beta 2
*/
@Override
public void setBorderBottom(BorderStyle border)
@@ -619,9 +661,20 @@ public final class HSSFCellStyle implements CellStyle {
/**
* get the type of border to use for the bottom border of the cell
* @return border type
* @deprecated POI 3.15. Will return a BorderStyle enum in the future. Use {@link #getBorderBottomEnum()}.
*/
@Override
public BorderStyle getBorderBottom()
public short getBorderBottom()
{
return _format.getBorderBottom();
}
/**
* get the type of border to use for the bottom border of the cell
* @return border type
* @since 3.15
*/
@Override
public BorderStyle getBorderBottomEnum()
{
return BorderStyle.valueOf(_format.getBorderBottom());
}
@@ -735,6 +788,7 @@ public final class HSSFCellStyle implements CellStyle {
* @param fp fill pattern (set to 1 to fill w/foreground color)
* @deprecated POI 3.15 beta 3. Use {@link #setFillPattern(FillPatternType)} instead.
*/
@Removal(version="3.17")
@Override
public void setFillPattern(short fp)
{

+ 44
- 4
src/java/org/apache/poi/ss/usermodel/CellStyle.java Переглянути файл

@@ -541,19 +541,29 @@ public interface CellStyle {
* @see #BORDER_SLANTED_DASH_DOT
* @deprecated 3.15 beta 2. Use {@link #setBorderLeft(BorderStyle)} instead
*/
@Removal(version="3.17")
void setBorderLeft(short border);
/**
* set the type of border to use for the left border of the cell
* @param border type
* @since POI 3.15
*/
void setBorderLeft(BorderStyle border);

/**
* get the type of border to use for the left border of the cell
* @return border type
* @deprecated POI 3.15. Use {@link #getBorderLeftEnum()} instead.
* This will return a BorderStyle enum in the future.
*/
short getBorderLeft();
/**
* get the type of border to use for the left border of the cell
* @return border type
* @since POI 3.15
*/
BorderStyle getBorderLeft();
BorderStyle getBorderLeftEnum();

/**
* set the type of border to use for the right border of the cell
@@ -574,19 +584,29 @@ public interface CellStyle {
* @see #BORDER_SLANTED_DASH_DOT
* @deprecated 3.15 beta 2. Use {@link #setBorderRight(BorderStyle)} instead
*/
@Removal(version="3.17")
void setBorderRight(short border);
/**
* set the type of border to use for the right border of the cell
* @param border type
* @since POI 3.15
*/
void setBorderRight(BorderStyle border);

/**
* get the type of border to use for the right border of the cell
* @return border type
* @deprecated POI 3.15. Use {@link #getBorderRightEnum()} instead.
* This will return a BorderStyle enum in the future.
*/
short getBorderRight();
/**
* get the type of border to use for the right border of the cell
* @return border type
* @since POI 3.15
*/
BorderStyle getBorderRight();
BorderStyle getBorderRightEnum();

/**
* set the type of border to use for the top border of the cell
@@ -607,19 +627,29 @@ public interface CellStyle {
* @see #BORDER_SLANTED_DASH_DOT
* @deprecated 3.15 beta 2. Use {@link #setBorderTop(BorderStyle)} instead
*/
@Removal(version="3.17")
void setBorderTop(short border);
/**
* set the type of border to use for the top border of the cell
* @param border type
* @since POI 3.15
*/
void setBorderTop(BorderStyle border);

/**
* get the type of border to use for the top border of the cell
* @return border type
* @deprecated POI 3.15. Use {@link #getBorderTopEnum()} instead.
* This will return a BorderStyle enum in the future.
*/
short getBorderTop();
/**
* get the type of border to use for the top border of the cell
* @return border type
* @since POI 3.15
*/
BorderStyle getBorderTop();
BorderStyle getBorderTopEnum();

/**
* set the type of border to use for the bottom border of the cell
@@ -640,19 +670,29 @@ public interface CellStyle {
* @see #BORDER_SLANTED_DASH_DOT
* @deprecated 3.15 beta 2. Use {@link #setBorderBottom(BorderStyle)} instead.
*/
@Removal(version="3.17")
void setBorderBottom(short border);
/**
* set the type of border to use for the bottom border of the cell
* @param border type
* @since POI 3.15
*/
void setBorderBottom(BorderStyle border);

/**
* get the type of border to use for the bottom border of the cell
* @return border type
* @deprecated POI 3.15. Use {@link #getBorderBottomEnum()} instead.
* This will return a BorderStyle enum in the future.
*/
short getBorderBottom();
/**
* get the type of border to use for the bottom border of the cell
* @return border type
* @since POI 3.15
*/
BorderStyle getBorderBottom();
BorderStyle getBorderBottomEnum();

/**
* set the color to use for the left border

+ 4
- 4
src/java/org/apache/poi/ss/util/CellUtil.java Переглянути файл

@@ -405,10 +405,10 @@ public final class CellUtil {
Map<String, Object> properties = new HashMap<String, Object>();
put(properties, ALIGNMENT, style.getAlignmentEnum());
put(properties, VERTICAL_ALIGNMENT, style.getVerticalAlignmentEnum());
put(properties, BORDER_BOTTOM, style.getBorderBottom());
put(properties, BORDER_LEFT, style.getBorderLeft());
put(properties, BORDER_RIGHT, style.getBorderRight());
put(properties, BORDER_TOP, style.getBorderTop());
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());

+ 40
- 21
src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFCellStyle.java Переглянути файл

@@ -252,11 +252,13 @@ public class XSSFCellStyle implements CellStyle {

/**
* Get the type of border to use for the bottom border of the cell
* Will be removed when {@link #getBorderBottom()} returns a BorderStyle enum
*
* @return border type, default value is {@link org.apache.poi.ss.usermodel.BorderStyle#NONE}
* @since POI 3.15
*/
@Override
public BorderStyle getBorderBottom() {
public BorderStyle getBorderBottomEnum() {
if(!_cellXf.getApplyBorder()) return BorderStyle.NONE;

int idx = (int)_cellXf.getBorderId();
@@ -267,24 +269,26 @@ public class XSSFCellStyle implements CellStyle {
}
return BorderStyle.valueOf((short)(ptrn.intValue() - 1));
}

/**
* Get the type of border to use for the bottom border of the cell
* This will return a BorderStyle enum in the future.
*
* @return border type as Java enum
* @deprecated 3.15 beta 2. Use {@link #getBorderBottom}
* @return border type code
* @deprecated 3.15 beta 2. Use {@link #getBorderBottomEnum()}
*/
public BorderStyle getBorderBottomEnum() {
return getBorderBottom();
public short getBorderBottom() {
return getBorderBottomEnum().getCode();
}

/**
* Get the type of border to use for the left border of the cell
* Will be removed when {@link #getBorderLeft()} returns a BorderStyle enum
*
* @return border type, default value is {@link org.apache.poi.ss.usermodel.BorderStyle#NONE}
* @since POI 3.15
*/
@Override
public BorderStyle getBorderLeft() {
public BorderStyle getBorderLeftEnum() {
if(!_cellXf.getApplyBorder()) return BorderStyle.NONE;

int idx = (int)_cellXf.getBorderId();
@@ -298,21 +302,24 @@ public class XSSFCellStyle implements CellStyle {

/**
* Get the type of border to use for the left border of the cell
* This will return a BorderStyle enum in the future.
*
* @return border type, default value is {@link org.apache.poi.ss.usermodel.BorderStyle#NONE}
* @deprecated 3.15 beta 2. Use {@link #getBorderLeft}
* @return border type code
* @deprecated 3.15 beta 2. Use {@link #getBorderLeftEnum()}
*/
public BorderStyle getBorderLeftEnum() {
return getBorderLeft();
public short getBorderLeft() {
return getBorderLeftEnum().getCode();
}

/**
* Get the type of border to use for the right border of the cell
* Will be removed when {@link #getBorderRight()} returns a BorderStyle enum
*
* @return border type, default value is {@link org.apache.poi.ss.usermodel.BorderStyle#NONE}
* @since POI 3.15
*/
@Override
public BorderStyle getBorderRight() {
public BorderStyle getBorderRightEnum() {
if(!_cellXf.getApplyBorder()) return BorderStyle.NONE;

int idx = (int)_cellXf.getBorderId();
@@ -323,24 +330,26 @@ public class XSSFCellStyle implements CellStyle {
}
return BorderStyle.valueOf((short)(ptrn.intValue() - 1));
}

/**
* Get the type of border to use for the right border of the cell
* This will return a BorderStyle enum in the future.
*
* @return border type, default value is {@link org.apache.poi.ss.usermodel.BorderStyle#NONE}
* @deprecated 3.15 beta 2. Use {@link #getBorderRight}
* @deprecated 3.15 beta 2. Use {@link #getBorderRightEnum()} instead
*/
public BorderStyle getBorderRightEnum() {
return getBorderRight();
public short getBorderRight() {
return getBorderRightEnum().getCode();
}

/**
* Get the type of border to use for the top border of the cell
* Will be removed when {@link #getBorderTop()} returns a BorderStyle enum
*
* @return border type, default value is {@link org.apache.poi.ss.usermodel.BorderStyle#NONE}
* @since POI 3.15
*/
@Override
public BorderStyle getBorderTop() {
public BorderStyle getBorderTopEnum() {
if(!_cellXf.getApplyBorder()) return BorderStyle.NONE;

int idx = (int)_cellXf.getBorderId();
@@ -351,15 +360,15 @@ public class XSSFCellStyle implements CellStyle {
}
return BorderStyle.valueOf((short) (ptrn.intValue() - 1));
}

/**
* Get the type of border to use for the top border of the cell
* This will return a BorderStyle enum in the future.
*
* @return border type, default value is {@link org.apache.poi.ss.usermodel.BorderStyle#NONE}
* @deprecated 3.15 beta 2. Use {@link #getBorderTop}
* @deprecated 3.15 beta 2. Use {@link #getBorderTopEnum()} instead.
*/
public BorderStyle getBorderTopEnum() {
return getBorderTop();
public short getBorderTop() {
return getBorderTopEnum().getCode();
}

/**
@@ -776,6 +785,7 @@ public class XSSFCellStyle implements CellStyle {
* @see org.apache.poi.ss.usermodel.CellStyle#ALIGN_CENTER_SELECTION
* @deprecated POI 3.15 beta 3. Use {@link #setAlignment(HorizontalAlignment)} instead.
*/
@Removal(version="3.17")
@Override
public void setAlignment(short align) {
setAlignment(HorizontalAlignment.forInt(align));
@@ -797,6 +807,7 @@ public class XSSFCellStyle implements CellStyle {
* @param border the type of border to use
* @deprecated 3.15 beta 2. Use {@link #setBorderBottom(BorderStyle)}
*/
@Removal(version="3.17")
@Override
public void setBorderBottom(short border) {
setBorderBottom(BorderStyle.valueOf(border));
@@ -807,6 +818,7 @@ public class XSSFCellStyle implements CellStyle {
*
* @param border - type of border to use
* @see org.apache.poi.ss.usermodel.BorderStyle
* @since POI 3.15
*/
@Override
public void setBorderBottom(BorderStyle border) {
@@ -826,6 +838,7 @@ public class XSSFCellStyle implements CellStyle {
* @param border the type of border to use
* @deprecated 3.15 beta 2. Use {@link #setBorderLeft(BorderStyle)}
*/
@Removal(version="3.17")
@Override
public void setBorderLeft(short border) {
setBorderLeft(BorderStyle.valueOf(border));
@@ -835,6 +848,7 @@ public class XSSFCellStyle implements CellStyle {
* Set the type of border to use for the left border of the cell
*
* @param border the type of border to use
* @since POI 3.15
*/
@Override
public void setBorderLeft(BorderStyle border) {
@@ -855,6 +869,7 @@ public class XSSFCellStyle implements CellStyle {
* @param border the type of border to use
* @deprecated 3.15 beta 2. Use {@link #setBorderRight(BorderStyle)}
*/
@Removal(version="3.17")
@Override
public void setBorderRight(short border) {
setBorderRight(BorderStyle.valueOf(border));
@@ -864,6 +879,7 @@ public class XSSFCellStyle implements CellStyle {
* Set the type of border to use for the right border of the cell
*
* @param border the type of border to use
* @since POI 3.15
*/
@Override
public void setBorderRight(BorderStyle border) {
@@ -884,6 +900,7 @@ public class XSSFCellStyle implements CellStyle {
* @param border the type of border to use
* @deprecated 3.15 beta 2. Use {@link #setBorderTop(BorderStyle)}
*/
@Removal(version="3.17")
@Override
public void setBorderTop(short border) {
setBorderTop(BorderStyle.valueOf(border));
@@ -893,6 +910,7 @@ public class XSSFCellStyle implements CellStyle {
* Set the type of border to use for the top border of the cell
*
* @param border the type of border to use
* @since POI 3.15
*/
@Override
public void setBorderTop(BorderStyle border) {
@@ -1338,6 +1356,7 @@ public class XSSFCellStyle implements CellStyle {
* @see org.apache.poi.ss.usermodel.VerticalAlignment
* @deprecated POI 3.15 beta 3. Use {@link #setVerticalAlignment(VerticalAlignment)} instead.
*/
@Removal(version="3.17")
@Override
public void setVerticalAlignment(short align) {
setVerticalAlignment(VerticalAlignment.forInt(align));

+ 19
- 19
src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFCellStyle.java Переглянути файл

@@ -104,11 +104,11 @@ public class TestXSSFCellStyle {
@Test
public void testGetSetBorderBottom() {
//default values
assertEquals(BorderStyle.NONE, cellStyle.getBorderBottom());
assertEquals(BorderStyle.NONE, cellStyle.getBorderBottomEnum());

int num = stylesTable.getBorders().size();
cellStyle.setBorderBottom(BorderStyle.MEDIUM);
assertEquals(BorderStyle.MEDIUM, cellStyle.getBorderBottom());
assertEquals(BorderStyle.MEDIUM, cellStyle.getBorderBottomEnum());
//a new border has been added
assertEquals(num + 1, stylesTable.getBorders().size());
//id of the created border
@@ -122,7 +122,7 @@ public class TestXSSFCellStyle {
//setting the same border multiple times should not change borderId
for (int i = 0; i < 3; i++) {
cellStyle.setBorderBottom(BorderStyle.MEDIUM);
assertEquals(BorderStyle.MEDIUM, cellStyle.getBorderBottom());
assertEquals(BorderStyle.MEDIUM, cellStyle.getBorderBottomEnum());
}
assertEquals(borderId, cellStyle.getCoreXf().getBorderId());
assertEquals(num, stylesTable.getBorders().size());
@@ -139,11 +139,11 @@ public class TestXSSFCellStyle {
@Test
public void testGetSetBorderRight() {
//default values
assertEquals(BorderStyle.NONE, cellStyle.getBorderRight());
assertEquals(BorderStyle.NONE, cellStyle.getBorderRightEnum());

int num = stylesTable.getBorders().size();
cellStyle.setBorderRight(BorderStyle.MEDIUM);
assertEquals(BorderStyle.MEDIUM, cellStyle.getBorderRight());
assertEquals(BorderStyle.MEDIUM, cellStyle.getBorderRightEnum());
//a new border has been added
assertEquals(num + 1, stylesTable.getBorders().size());
//id of the created border
@@ -157,7 +157,7 @@ public class TestXSSFCellStyle {
//setting the same border multiple times should not change borderId
for (int i = 0; i < 3; i++) {
cellStyle.setBorderRight(BorderStyle.MEDIUM);
assertEquals(BorderStyle.MEDIUM, cellStyle.getBorderRight());
assertEquals(BorderStyle.MEDIUM, cellStyle.getBorderRightEnum());
}
assertEquals(borderId, cellStyle.getCoreXf().getBorderId());
assertEquals(num, stylesTable.getBorders().size());
@@ -174,11 +174,11 @@ public class TestXSSFCellStyle {
@Test
public void testGetSetBorderLeft() {
//default values
assertEquals(BorderStyle.NONE, cellStyle.getBorderLeft());
assertEquals(BorderStyle.NONE, cellStyle.getBorderLeftEnum());

int num = stylesTable.getBorders().size();
cellStyle.setBorderLeft(BorderStyle.MEDIUM);
assertEquals(BorderStyle.MEDIUM, cellStyle.getBorderLeft());
assertEquals(BorderStyle.MEDIUM, cellStyle.getBorderLeftEnum());
//a new border has been added
assertEquals(num + 1, stylesTable.getBorders().size());
//id of the created border
@@ -192,7 +192,7 @@ public class TestXSSFCellStyle {
//setting the same border multiple times should not change borderId
for (int i = 0; i < 3; i++) {
cellStyle.setBorderLeft(BorderStyle.MEDIUM);
assertEquals(BorderStyle.MEDIUM, cellStyle.getBorderLeft());
assertEquals(BorderStyle.MEDIUM, cellStyle.getBorderLeftEnum());
}
assertEquals(borderId, cellStyle.getCoreXf().getBorderId());
assertEquals(num, stylesTable.getBorders().size());
@@ -209,11 +209,11 @@ public class TestXSSFCellStyle {
@Test
public void testGetSetBorderTop() {
//default values
assertEquals(BorderStyle.NONE, cellStyle.getBorderTop());
assertEquals(BorderStyle.NONE, cellStyle.getBorderTopEnum());

int num = stylesTable.getBorders().size();
cellStyle.setBorderTop(BorderStyle.MEDIUM);
assertEquals(BorderStyle.MEDIUM, cellStyle.getBorderTop());
assertEquals(BorderStyle.MEDIUM, cellStyle.getBorderTopEnum());
//a new border has been added
assertEquals(num + 1, stylesTable.getBorders().size());
//id of the created border
@@ -227,7 +227,7 @@ public class TestXSSFCellStyle {
//setting the same border multiple times should not change borderId
for (int i = 0; i < 3; i++) {
cellStyle.setBorderTop(BorderStyle.MEDIUM);
assertEquals(BorderStyle.MEDIUM, cellStyle.getBorderTop());
assertEquals(BorderStyle.MEDIUM, cellStyle.getBorderTopEnum());
}
assertEquals(borderId, cellStyle.getCoreXf().getBorderId());
assertEquals(num, stylesTable.getBorders().size());
@@ -243,7 +243,7 @@ public class TestXSSFCellStyle {
private void testGetSetBorderXMLBean(BorderStyle border, STBorderStyle.Enum expected) {
cellStyle.setBorderTop(border);
assertEquals(border, cellStyle.getBorderTop());
assertEquals(border, cellStyle.getBorderTopEnum());
int borderId = (int)cellStyle.getCoreXf().getBorderId();
assertTrue(borderId > 0);
//check changes in the underlying xml bean
@@ -256,7 +256,7 @@ public class TestXSSFCellStyle {
@Test
public void testGetSetBorderNone() {
cellStyle.setBorderTop(BorderStyle.NONE);
assertEquals(BorderStyle.NONE, cellStyle.getBorderTop());
assertEquals(BorderStyle.NONE, cellStyle.getBorderTopEnum());
int borderId = (int)cellStyle.getCoreXf().getBorderId();
assertTrue(borderId > 0);
//check changes in the underlying xml bean
@@ -562,10 +562,10 @@ public class TestXSSFCellStyle {
assertEquals(style2.getRightBorderColor(), style1.getRightBorderColor());
assertEquals(style2.getBottomBorderColor(), style1.getBottomBorderColor());

assertEquals(style2.getBorderBottom(), style1.getBorderBottom());
assertEquals(style2.getBorderLeft(), style1.getBorderLeft());
assertEquals(style2.getBorderRight(), style1.getBorderRight());
assertEquals(style2.getBorderTop(), style1.getBorderTop());
assertEquals(style2.getBorderBottomEnum(), style1.getBorderBottomEnum());
assertEquals(style2.getBorderLeftEnum(), style1.getBorderLeftEnum());
assertEquals(style2.getBorderRightEnum(), style1.getBorderRightEnum());
assertEquals(style2.getBorderTopEnum(), style1.getBorderTopEnum());
wb2.close();
}

@@ -999,7 +999,7 @@ public class TestXSSFCellStyle {
Workbook copy = XSSFTestDataSamples.writeOutAndReadBack(target);

// previously this failed because the border-element was not copied over
copy.getCellStyleAt((short)1).getBorderBottom();
copy.getCellStyleAt((short)1).getBorderBottomEnum();
copy.close();

+ 8
- 8
src/scratchpad/src/org/apache/poi/hssf/converter/ExcelToFoConverter.java Переглянути файл

@@ -193,10 +193,10 @@ public class ExcelToFoConverter extends AbstractExcelConverter
protected boolean isEmptyStyle( CellStyle cellStyle ) {
return cellStyle == null || (
cellStyle.getFillPattern() == 0
&& cellStyle.getBorderTop() == BorderStyle.NONE
&& cellStyle.getBorderRight() == BorderStyle.NONE
&& cellStyle.getBorderBottom() == BorderStyle.NONE
&& cellStyle.getBorderLeft() == BorderStyle.NONE
&& cellStyle.getBorderTopEnum() == BorderStyle.NONE
&& cellStyle.getBorderRightEnum() == BorderStyle.NONE
&& cellStyle.getBorderBottomEnum() == BorderStyle.NONE
&& cellStyle.getBorderLeftEnum() == BorderStyle.NONE
);
}

@@ -361,13 +361,13 @@ public class ExcelToFoConverter extends AbstractExcelConverter
}

processCellStyleBorder( workbook, cellTarget, "top",
cellStyle.getBorderTop(), cellStyle.getTopBorderColor() );
cellStyle.getBorderTopEnum(), cellStyle.getTopBorderColor() );
processCellStyleBorder( workbook, cellTarget, "right",
cellStyle.getBorderRight(), cellStyle.getRightBorderColor() );
cellStyle.getBorderRightEnum(), cellStyle.getRightBorderColor() );
processCellStyleBorder( workbook, cellTarget, "bottom",
cellStyle.getBorderBottom(), cellStyle.getBottomBorderColor() );
cellStyle.getBorderBottomEnum(), cellStyle.getBottomBorderColor() );
processCellStyleBorder( workbook, cellTarget, "left",
cellStyle.getBorderLeft(), cellStyle.getLeftBorderColor() );
cellStyle.getBorderLeftEnum(), cellStyle.getLeftBorderColor() );

HSSFFont font = cellStyle.getFont( workbook );
processCellStyleFont( workbook, blockTarget, font );

+ 4
- 4
src/scratchpad/src/org/apache/poi/hssf/converter/ExcelToHtmlConverter.java Переглянути файл

@@ -175,13 +175,13 @@ public class ExcelToHtmlConverter extends AbstractExcelConverter
break;
}

buildStyle_border( workbook, style, "top", cellStyle.getBorderTop(),
buildStyle_border( workbook, style, "top", cellStyle.getBorderTopEnum(),
cellStyle.getTopBorderColor() );
buildStyle_border( workbook, style, "right",
cellStyle.getBorderRight(), cellStyle.getRightBorderColor() );
cellStyle.getBorderRightEnum(), cellStyle.getRightBorderColor() );
buildStyle_border( workbook, style, "bottom",
cellStyle.getBorderBottom(), cellStyle.getBottomBorderColor() );
buildStyle_border( workbook, style, "left", cellStyle.getBorderLeft(),
cellStyle.getBorderBottomEnum(), cellStyle.getBottomBorderColor() );
buildStyle_border( workbook, style, "left", cellStyle.getBorderLeftEnum(),
cellStyle.getLeftBorderColor() );

HSSFFont font = cellStyle.getFont( workbook );

+ 1
- 1
src/testcases/org/apache/poi/hssf/usermodel/TestBugs.java Переглянути файл

@@ -2567,7 +2567,7 @@ public final class TestBugs extends BaseTestBugzillaIssues {
HSSFSheet sheet = wb.getSheetAt(0);
HSSFRow row = sheet.getRow(0);
HSSFCellStyle rstyle = row.getRowStyle();
assertEquals(BorderStyle.DOUBLE, rstyle.getBorderBottom());
assertEquals(BorderStyle.DOUBLE, rstyle.getBorderBottomEnum());
wb.close();
}


+ 13
- 13
src/testcases/org/apache/poi/hssf/usermodel/TestCellStyle.java Переглянути файл

@@ -348,40 +348,40 @@ public final class TestCellStyle extends TestCase {
HSSFCellStyle cs;

cs = s.getRow(0).getCell(0).getCellStyle();
assertEquals(BorderStyle.HAIR, cs.getBorderRight());
assertEquals(BorderStyle.HAIR, cs.getBorderRightEnum());

cs = s.getRow(1).getCell(1).getCellStyle();
assertEquals(BorderStyle.DOTTED, cs.getBorderRight());
assertEquals(BorderStyle.DOTTED, cs.getBorderRightEnum());

cs = s.getRow(2).getCell(2).getCellStyle();
assertEquals(BorderStyle.DASH_DOT_DOT, cs.getBorderRight());
assertEquals(BorderStyle.DASH_DOT_DOT, cs.getBorderRightEnum());

cs = s.getRow(3).getCell(3).getCellStyle();
assertEquals(BorderStyle.DASHED, cs.getBorderRight());
assertEquals(BorderStyle.DASHED, cs.getBorderRightEnum());

cs = s.getRow(4).getCell(4).getCellStyle();
assertEquals(BorderStyle.THIN, cs.getBorderRight());
assertEquals(BorderStyle.THIN, cs.getBorderRightEnum());

cs = s.getRow(5).getCell(5).getCellStyle();
assertEquals(BorderStyle.MEDIUM_DASH_DOT_DOT, cs.getBorderRight());
assertEquals(BorderStyle.MEDIUM_DASH_DOT_DOT, cs.getBorderRightEnum());

cs = s.getRow(6).getCell(6).getCellStyle();
assertEquals(BorderStyle.SLANTED_DASH_DOT, cs.getBorderRight());
assertEquals(BorderStyle.SLANTED_DASH_DOT, cs.getBorderRightEnum());

cs = s.getRow(7).getCell(7).getCellStyle();
assertEquals(BorderStyle.MEDIUM_DASH_DOT, cs.getBorderRight());
assertEquals(BorderStyle.MEDIUM_DASH_DOT, cs.getBorderRightEnum());

cs = s.getRow(8).getCell(8).getCellStyle();
assertEquals(BorderStyle.MEDIUM_DASHED, cs.getBorderRight());
assertEquals(BorderStyle.MEDIUM_DASHED, cs.getBorderRightEnum());

cs = s.getRow(9).getCell(9).getCellStyle();
assertEquals(BorderStyle.MEDIUM, cs.getBorderRight());
assertEquals(BorderStyle.MEDIUM, cs.getBorderRightEnum());

cs = s.getRow(10).getCell(10).getCellStyle();
assertEquals(BorderStyle.THICK, cs.getBorderRight());
assertEquals(BorderStyle.THICK, cs.getBorderRightEnum());

cs = s.getRow(11).getCell(11).getCellStyle();
assertEquals(BorderStyle.DOUBLE, cs.getBorderRight());
assertEquals(BorderStyle.DOUBLE, cs.getBorderRightEnum());
}

public void testShrinkToFit() {
@@ -500,7 +500,7 @@ public final class TestCellStyle extends TestCase {
newCell.setCellValue("2testtext2");

CellStyle newStyle = newCell.getCellStyle();
assertEquals(BorderStyle.DOTTED, newStyle.getBorderBottom());
assertEquals(BorderStyle.DOTTED, newStyle.getBorderBottomEnum());
assertEquals(Font.COLOR_RED, ((HSSFCellStyle)newStyle).getFont(wb).getColor());
// OutputStream out = new FileOutputStream("/tmp/56959.xls");

+ 3
- 3
src/testcases/org/apache/poi/hssf/usermodel/TestHSSFOptimiser.java Переглянути файл

@@ -308,8 +308,8 @@ public final class TestHSSFOptimiser extends TestCase {
// Check
assertEquals(23, wb.getNumCellStyles());
assertEquals(BorderStyle.THICK, r.getCell(0).getCellStyle().getBorderBottom());
assertEquals(BorderStyle.DASH_DOT, r.getCell(1).getCellStyle().getBorderBottom());
assertEquals(BorderStyle.THICK, r.getCell(2).getCellStyle().getBorderBottom());
assertEquals(BorderStyle.THICK, r.getCell(0).getCellStyle().getBorderBottomEnum());
assertEquals(BorderStyle.DASH_DOT, r.getCell(1).getCellStyle().getBorderBottomEnum());
assertEquals(BorderStyle.THICK, r.getCell(2).getCellStyle().getBorderBottomEnum());
}
}

+ 4
- 4
src/testcases/org/apache/poi/hssf/usermodel/TestRowStyle.java Переглянути файл

@@ -151,10 +151,10 @@ public final class TestRowStyle extends TestCase {
assertNotNull("Row is not null", r);
cs = r.getRowStyle();
assertEquals("Bottom Border Style for row:", BorderStyle.THIN, cs.getBorderBottom());
assertEquals("Left Border Style for row:", BorderStyle.THIN, cs.getBorderLeft());
assertEquals("Right Border Style for row:", BorderStyle.THIN, cs.getBorderRight());
assertEquals("Top Border Style for row:", BorderStyle.THIN, cs.getBorderTop());
assertEquals("Bottom Border Style for row:", BorderStyle.THIN, cs.getBorderBottomEnum());
assertEquals("Left Border Style for row:", BorderStyle.THIN, cs.getBorderLeftEnum());
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:", 0x1, cs.getFillPattern());

+ 4
- 4
src/testcases/org/apache/poi/ss/usermodel/BaseTestBorderStyle.java Переглянути файл

@@ -73,10 +73,10 @@ public class BaseTestBorderStyle {
protected void assertBorderStyleEquals(BorderStyle expected, Cell cell) {
CellStyle style = cell.getCellStyle();
assertEquals(expected, style.getBorderTop());
assertEquals(expected, style.getBorderBottom());
assertEquals(expected, style.getBorderLeft());
assertEquals(expected, style.getBorderRight());
assertEquals(expected, style.getBorderTopEnum());
assertEquals(expected, style.getBorderBottomEnum());
assertEquals(expected, style.getBorderLeftEnum());
assertEquals(expected, style.getBorderRightEnum());
}

}

+ 4
- 4
src/testcases/org/apache/poi/ss/usermodel/BaseTestCell.java Переглянути файл

@@ -278,10 +278,10 @@ public abstract class BaseTestCell {

assertNotNull("Formula Cell Style", cs);
assertEquals("Font Index Matches", f.getIndex(), cs.getFontIndex());
assertEquals("Top Border", BorderStyle.THIN, cs.getBorderTop());
assertEquals("Left Border", BorderStyle.THIN, cs.getBorderLeft());
assertEquals("Right Border", BorderStyle.THIN, cs.getBorderRight());
assertEquals("Bottom Border", BorderStyle.THIN, cs.getBorderBottom());
assertEquals("Top Border", BorderStyle.THIN, cs.getBorderTopEnum());
assertEquals("Left Border", BorderStyle.THIN, cs.getBorderLeftEnum());
assertEquals("Right Border", BorderStyle.THIN, cs.getBorderRightEnum());
assertEquals("Bottom Border", BorderStyle.THIN, cs.getBorderBottomEnum());
wb2.close();
}


+ 2
- 2
src/testcases/org/apache/poi/ss/util/BaseTestCellUtil.java Переглянути файл

@@ -99,11 +99,11 @@ public class BaseTestCellUtil {
// A valid BorderStyle constant, as a Short
CellUtil.setCellStyleProperty(c, CellUtil.BORDER_BOTTOM, BorderStyle.DASH_DOT.getCode());
assertEquals(BorderStyle.DASH_DOT, c.getCellStyle().getBorderBottom());
assertEquals(BorderStyle.DASH_DOT, c.getCellStyle().getBorderBottomEnum());
// A valid BorderStyle constant, as an Enum
CellUtil.setCellStyleProperty(c, CellUtil.BORDER_TOP, BorderStyle.MEDIUM_DASH_DOT);
assertEquals(BorderStyle.MEDIUM_DASH_DOT, c.getCellStyle().getBorderTop());
assertEquals(BorderStyle.MEDIUM_DASH_DOT, c.getCellStyle().getBorderTopEnum());
wb.close();
}

Завантаження…
Відмінити
Зберегти