You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@poi.apache.org by on...@apache.org on 2016/04/05 22:28:47 UTC
svn commit: r1737879 [2/2] - in /poi/trunk:
src/examples/src/org/apache/poi/hssf/view/
src/examples/src/org/apache/poi/ss/examples/
src/examples/src/org/apache/poi/ss/examples/html/
src/java/org/apache/poi/hssf/usermodel/ src/java/org/apache/poi/ss/use...
Modified: poi/trunk/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFCellStyle.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFCellStyle.java?rev=1737879&r1=1737878&r2=1737879&view=diff
==============================================================================
--- poi/trunk/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFCellStyle.java (original)
+++ poi/trunk/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFCellStyle.java Tue Apr 5 20:28:46 2016
@@ -104,11 +104,11 @@ public class TestXSSFCellStyle {
@Test
public void testGetSetBorderBottom() {
//default values
- assertEquals(CellStyle.BORDER_NONE, cellStyle.getBorderBottom());
+ assertEquals(BorderStyle.NONE, cellStyle.getBorderBottom());
int num = stylesTable.getBorders().size();
- cellStyle.setBorderBottom(CellStyle.BORDER_MEDIUM);
- assertEquals(CellStyle.BORDER_MEDIUM, cellStyle.getBorderBottom());
+ cellStyle.setBorderBottom(BorderStyle.MEDIUM);
+ assertEquals(BorderStyle.MEDIUM, cellStyle.getBorderBottom());
//a new border has been added
assertEquals(num + 1, stylesTable.getBorders().size());
//id of the created border
@@ -121,15 +121,15 @@ public class TestXSSFCellStyle {
num = stylesTable.getBorders().size();
//setting the same border multiple times should not change borderId
for (int i = 0; i < 3; i++) {
- cellStyle.setBorderBottom(CellStyle.BORDER_MEDIUM);
- assertEquals(CellStyle.BORDER_MEDIUM, cellStyle.getBorderBottom());
+ cellStyle.setBorderBottom(BorderStyle.MEDIUM);
+ assertEquals(BorderStyle.MEDIUM, cellStyle.getBorderBottom());
}
assertEquals(borderId, cellStyle.getCoreXf().getBorderId());
assertEquals(num, stylesTable.getBorders().size());
assertSame(ctBorder, stylesTable.getBorderAt(borderId).getCTBorder());
//setting border to none removes the <bottom> element
- cellStyle.setBorderBottom(CellStyle.BORDER_NONE);
+ cellStyle.setBorderBottom(BorderStyle.NONE);
assertEquals(num, stylesTable.getBorders().size());
borderId = (int)cellStyle.getCoreXf().getBorderId();
ctBorder = stylesTable.getBorderAt(borderId).getCTBorder();
@@ -139,11 +139,11 @@ public class TestXSSFCellStyle {
@Test
public void testGetSetBorderRight() {
//default values
- assertEquals(CellStyle.BORDER_NONE, cellStyle.getBorderRight());
+ assertEquals(BorderStyle.NONE, cellStyle.getBorderRight());
int num = stylesTable.getBorders().size();
- cellStyle.setBorderRight(CellStyle.BORDER_MEDIUM);
- assertEquals(CellStyle.BORDER_MEDIUM, cellStyle.getBorderRight());
+ cellStyle.setBorderRight(BorderStyle.MEDIUM);
+ assertEquals(BorderStyle.MEDIUM, cellStyle.getBorderRight());
//a new border has been added
assertEquals(num + 1, stylesTable.getBorders().size());
//id of the created border
@@ -156,15 +156,15 @@ public class TestXSSFCellStyle {
num = stylesTable.getBorders().size();
//setting the same border multiple times should not change borderId
for (int i = 0; i < 3; i++) {
- cellStyle.setBorderRight(CellStyle.BORDER_MEDIUM);
- assertEquals(CellStyle.BORDER_MEDIUM, cellStyle.getBorderRight());
+ cellStyle.setBorderRight(BorderStyle.MEDIUM);
+ assertEquals(BorderStyle.MEDIUM, cellStyle.getBorderRight());
}
assertEquals(borderId, cellStyle.getCoreXf().getBorderId());
assertEquals(num, stylesTable.getBorders().size());
assertSame(ctBorder, stylesTable.getBorderAt(borderId).getCTBorder());
//setting border to none removes the <right> element
- cellStyle.setBorderRight(CellStyle.BORDER_NONE);
+ cellStyle.setBorderRight(BorderStyle.NONE);
assertEquals(num, stylesTable.getBorders().size());
borderId = (int)cellStyle.getCoreXf().getBorderId();
ctBorder = stylesTable.getBorderAt(borderId).getCTBorder();
@@ -174,11 +174,11 @@ public class TestXSSFCellStyle {
@Test
public void testGetSetBorderLeft() {
//default values
- assertEquals(CellStyle.BORDER_NONE, cellStyle.getBorderLeft());
+ assertEquals(BorderStyle.NONE, cellStyle.getBorderLeft());
int num = stylesTable.getBorders().size();
- cellStyle.setBorderLeft(CellStyle.BORDER_MEDIUM);
- assertEquals(CellStyle.BORDER_MEDIUM, cellStyle.getBorderLeft());
+ cellStyle.setBorderLeft(BorderStyle.MEDIUM);
+ assertEquals(BorderStyle.MEDIUM, cellStyle.getBorderLeft());
//a new border has been added
assertEquals(num + 1, stylesTable.getBorders().size());
//id of the created border
@@ -191,15 +191,15 @@ public class TestXSSFCellStyle {
num = stylesTable.getBorders().size();
//setting the same border multiple times should not change borderId
for (int i = 0; i < 3; i++) {
- cellStyle.setBorderLeft(CellStyle.BORDER_MEDIUM);
- assertEquals(CellStyle.BORDER_MEDIUM, cellStyle.getBorderLeft());
+ cellStyle.setBorderLeft(BorderStyle.MEDIUM);
+ assertEquals(BorderStyle.MEDIUM, cellStyle.getBorderLeft());
}
assertEquals(borderId, cellStyle.getCoreXf().getBorderId());
assertEquals(num, stylesTable.getBorders().size());
assertSame(ctBorder, stylesTable.getBorderAt(borderId).getCTBorder());
//setting border to none removes the <left> element
- cellStyle.setBorderLeft(CellStyle.BORDER_NONE);
+ cellStyle.setBorderLeft(BorderStyle.NONE);
assertEquals(num, stylesTable.getBorders().size());
borderId = (int)cellStyle.getCoreXf().getBorderId();
ctBorder = stylesTable.getBorderAt(borderId).getCTBorder();
@@ -209,11 +209,11 @@ public class TestXSSFCellStyle {
@Test
public void testGetSetBorderTop() {
//default values
- assertEquals(CellStyle.BORDER_NONE, cellStyle.getBorderTop());
+ assertEquals(BorderStyle.NONE, cellStyle.getBorderTop());
int num = stylesTable.getBorders().size();
- cellStyle.setBorderTop(CellStyle.BORDER_MEDIUM);
- assertEquals(CellStyle.BORDER_MEDIUM, cellStyle.getBorderTop());
+ cellStyle.setBorderTop(BorderStyle.MEDIUM);
+ assertEquals(BorderStyle.MEDIUM, cellStyle.getBorderTop());
//a new border has been added
assertEquals(num + 1, stylesTable.getBorders().size());
//id of the created border
@@ -226,165 +226,112 @@ public class TestXSSFCellStyle {
num = stylesTable.getBorders().size();
//setting the same border multiple times should not change borderId
for (int i = 0; i < 3; i++) {
- cellStyle.setBorderTop(CellStyle.BORDER_MEDIUM);
- assertEquals(CellStyle.BORDER_MEDIUM, cellStyle.getBorderTop());
+ cellStyle.setBorderTop(BorderStyle.MEDIUM);
+ assertEquals(BorderStyle.MEDIUM, cellStyle.getBorderTop());
}
assertEquals(borderId, cellStyle.getCoreXf().getBorderId());
assertEquals(num, stylesTable.getBorders().size());
assertSame(ctBorder, stylesTable.getBorderAt(borderId).getCTBorder());
//setting border to none removes the <top> element
- cellStyle.setBorderTop(CellStyle.BORDER_NONE);
+ cellStyle.setBorderTop(BorderStyle.NONE);
assertEquals(num, stylesTable.getBorders().size());
borderId = (int)cellStyle.getCoreXf().getBorderId();
ctBorder = stylesTable.getBorderAt(borderId).getCTBorder();
assertFalse(ctBorder.isSetTop());
- }
-
- @Test
- public void testGetSetBorderThin() {
- cellStyle.setBorderTop(CellStyle.BORDER_THIN);
- assertEquals(CellStyle.BORDER_THIN, cellStyle.getBorderTop());
+ }
+
+ private void testGetSetBorderXMLBean(BorderStyle border, STBorderStyle.Enum expected) {
+ cellStyle.setBorderTop(border);
+ assertEquals(border, cellStyle.getBorderTop());
int borderId = (int)cellStyle.getCoreXf().getBorderId();
assertTrue(borderId > 0);
//check changes in the underlying xml bean
CTBorder ctBorder = stylesTable.getBorderAt(borderId).getCTBorder();
- assertEquals(STBorderStyle.THIN, ctBorder.getTop().getStyle());
- }
-
- @Test
- public void testGetSetBorderMedium() {
- cellStyle.setBorderTop(CellStyle.BORDER_MEDIUM);
- assertEquals(CellStyle.BORDER_MEDIUM, cellStyle.getBorderTop());
+ assertEquals(expected, ctBorder.getTop().getStyle());
+ }
+
+
+ // Border Styles, in BorderStyle/STBorderStyle enum order
+ @Test
+ public void testGetSetBorderNone() {
+ cellStyle.setBorderTop(BorderStyle.NONE);
+ assertEquals(BorderStyle.NONE, cellStyle.getBorderTop());
int borderId = (int)cellStyle.getCoreXf().getBorderId();
assertTrue(borderId > 0);
//check changes in the underlying xml bean
CTBorder ctBorder = stylesTable.getBorderAt(borderId).getCTBorder();
- assertEquals(STBorderStyle.MEDIUM, ctBorder.getTop().getStyle());
- }
-
- @Test
+ assertNull(ctBorder.getTop());
+ // no border style and STBorderStyle.NONE are equivalent
+ // POI prefers to unset the border style than explicitly set it STBorderStyle.NONE
+ }
+
+ @Test
+ public void testGetSetBorderThin() {
+ testGetSetBorderXMLBean(BorderStyle.THIN, STBorderStyle.THIN);
+ }
+
+ @Test
+ public void testGetSetBorderMedium() {
+ testGetSetBorderXMLBean(BorderStyle.MEDIUM, STBorderStyle.MEDIUM);
+ }
+
+ @Test
+ public void testGetSetBorderDashed() {
+ testGetSetBorderXMLBean(BorderStyle.DASHED, STBorderStyle.DASHED);
+ }
+
+ @Test
+ public void testGetSetBorderDotted() {
+ testGetSetBorderXMLBean(BorderStyle.DOTTED, STBorderStyle.DOTTED);
+ }
+
+ @Test
public void testGetSetBorderThick() {
- cellStyle.setBorderTop(CellStyle.BORDER_THICK);
- assertEquals(CellStyle.BORDER_THICK, cellStyle.getBorderTop());
- int borderId = (int)cellStyle.getCoreXf().getBorderId();
- assertTrue(borderId > 0);
- //check changes in the underlying xml bean
- CTBorder ctBorder = stylesTable.getBorderAt(borderId).getCTBorder();
- assertEquals(STBorderStyle.THICK, ctBorder.getTop().getStyle());
- }
-
- @Test
+ testGetSetBorderXMLBean(BorderStyle.THICK, STBorderStyle.THICK);
+ }
+
+ @Test
+ public void testGetSetBorderDouble() {
+ testGetSetBorderXMLBean(BorderStyle.DOUBLE, STBorderStyle.DOUBLE);
+ }
+
+ @Test
public void testGetSetBorderHair() {
- cellStyle.setBorderTop(CellStyle.BORDER_HAIR);
- assertEquals(CellStyle.BORDER_HAIR, cellStyle.getBorderTop());
- int borderId = (int)cellStyle.getCoreXf().getBorderId();
- assertTrue(borderId > 0);
- //check changes in the underlying xml bean
- CTBorder ctBorder = stylesTable.getBorderAt(borderId).getCTBorder();
- assertEquals(STBorderStyle.HAIR, ctBorder.getTop().getStyle());
- }
-
- @Test
- public void testGetSetBorderDotted() {
- cellStyle.setBorderTop(CellStyle.BORDER_DOTTED);
- assertEquals(CellStyle.BORDER_DOTTED, cellStyle.getBorderTop());
- int borderId = (int)cellStyle.getCoreXf().getBorderId();
- assertTrue(borderId > 0);
- //check changes in the underlying xml bean
- CTBorder ctBorder = stylesTable.getBorderAt(borderId).getCTBorder();
- assertEquals(STBorderStyle.DOTTED, ctBorder.getTop().getStyle());
- }
-
- @Test
- public void testGetSetBorderDashed() {
- cellStyle.setBorderTop(CellStyle.BORDER_DASHED);
- assertEquals(CellStyle.BORDER_DASHED, cellStyle.getBorderTop());
- int borderId = (int)cellStyle.getCoreXf().getBorderId();
- assertTrue(borderId > 0);
- //check changes in the underlying xml bean
- CTBorder ctBorder = stylesTable.getBorderAt(borderId).getCTBorder();
- assertEquals(STBorderStyle.DASHED, ctBorder.getTop().getStyle());
- }
-
- @Test
+ testGetSetBorderXMLBean(BorderStyle.HAIR, STBorderStyle.HAIR);
+ }
+
+ @Test
+ public void testGetSetBorderMediumDashed() {
+ testGetSetBorderXMLBean(BorderStyle.MEDIUM_DASHED, STBorderStyle.MEDIUM_DASHED);
+ }
+
+ @Test
public void testGetSetBorderDashDot() {
- cellStyle.setBorderTop(CellStyle.BORDER_DASH_DOT);
- assertEquals(CellStyle.BORDER_DASH_DOT, cellStyle.getBorderTop());
- int borderId = (int)cellStyle.getCoreXf().getBorderId();
- assertTrue(borderId > 0);
- //check changes in the underlying xml bean
- CTBorder ctBorder = stylesTable.getBorderAt(borderId).getCTBorder();
- assertEquals(STBorderStyle.DASH_DOT, ctBorder.getTop().getStyle());
- }
-
- @Test
- public void testGetSetBorderDashDotDot() {
- cellStyle.setBorderTop(CellStyle.BORDER_DASH_DOT_DOT);
- assertEquals(CellStyle.BORDER_DASH_DOT_DOT, cellStyle.getBorderTop());
- int borderId = (int)cellStyle.getCoreXf().getBorderId();
- assertTrue(borderId > 0);
- //check changes in the underlying xml bean
- CTBorder ctBorder = stylesTable.getBorderAt(borderId).getCTBorder();
- assertEquals(STBorderStyle.DASH_DOT_DOT, ctBorder.getTop().getStyle());
- }
-
- @Test
+ testGetSetBorderXMLBean(BorderStyle.DASH_DOT, STBorderStyle.DASH_DOT);
+ }
+
+ @Test
public void testGetSetBorderMediumDashDot() {
- cellStyle.setBorderTop(CellStyle.BORDER_MEDIUM_DASH_DOT);
- assertEquals(CellStyle.BORDER_MEDIUM_DASH_DOT, cellStyle.getBorderTop());
- int borderId = (int)cellStyle.getCoreXf().getBorderId();
- assertTrue(borderId > 0);
- //check changes in the underlying xml bean
- CTBorder ctBorder = stylesTable.getBorderAt(borderId).getCTBorder();
- assertEquals(STBorderStyle.MEDIUM_DASH_DOT, ctBorder.getTop().getStyle());
- }
-
- @Test
+ testGetSetBorderXMLBean(BorderStyle.MEDIUM_DASH_DOT, STBorderStyle.MEDIUM_DASH_DOT);
+ }
+
+ @Test
+ public void testGetSetBorderDashDotDot() {
+ testGetSetBorderXMLBean(BorderStyle.DASH_DOT_DOT, STBorderStyle.DASH_DOT_DOT);
+ }
+
+ @Test
public void testGetSetBorderMediumDashDotDot() {
- cellStyle.setBorderTop(CellStyle.BORDER_MEDIUM_DASH_DOT_DOT);
- assertEquals(CellStyle.BORDER_MEDIUM_DASH_DOT_DOT, cellStyle.getBorderTop());
- int borderId = (int)cellStyle.getCoreXf().getBorderId();
- assertTrue(borderId > 0);
- //check changes in the underlying xml bean
- CTBorder ctBorder = stylesTable.getBorderAt(borderId).getCTBorder();
- assertEquals(STBorderStyle.MEDIUM_DASH_DOT_DOT, ctBorder.getTop().getStyle());
- }
-
- @Test
- public void testGetSetBorderMediumDashed() {
- cellStyle.setBorderTop(CellStyle.BORDER_MEDIUM_DASHED);
- assertEquals(CellStyle.BORDER_MEDIUM_DASHED, cellStyle.getBorderTop());
- int borderId = (int)cellStyle.getCoreXf().getBorderId();
- assertTrue(borderId > 0);
- //check changes in the underlying xml bean
- CTBorder ctBorder = stylesTable.getBorderAt(borderId).getCTBorder();
- assertEquals(STBorderStyle.MEDIUM_DASHED, ctBorder.getTop().getStyle());
- }
-
- @Test
+ testGetSetBorderXMLBean(BorderStyle.MEDIUM_DASH_DOT_DOT, STBorderStyle.MEDIUM_DASH_DOT_DOT);
+ }
+
+ @Test
public void testGetSetBorderSlantDashDot() {
- cellStyle.setBorderTop(CellStyle.BORDER_SLANTED_DASH_DOT);
- assertEquals(CellStyle.BORDER_SLANTED_DASH_DOT, cellStyle.getBorderTop());
- int borderId = (int)cellStyle.getCoreXf().getBorderId();
- assertTrue(borderId > 0);
- //check changes in the underlying xml bean
- CTBorder ctBorder = stylesTable.getBorderAt(borderId).getCTBorder();
- assertEquals(STBorderStyle.SLANT_DASH_DOT, ctBorder.getTop().getStyle());
- }
-
- @Test
- public void testGetSetBorderDouble() {
- cellStyle.setBorderTop(CellStyle.BORDER_DOUBLE);
- assertEquals(CellStyle.BORDER_DOUBLE, cellStyle.getBorderTop());
- int borderId = (int)cellStyle.getCoreXf().getBorderId();
- assertTrue(borderId > 0);
- //check changes in the underlying xml bean
- CTBorder ctBorder = stylesTable.getBorderAt(borderId).getCTBorder();
- assertEquals(STBorderStyle.DOUBLE, ctBorder.getTop().getStyle());
- }
-
- @Test
+ testGetSetBorderXMLBean(BorderStyle.SLANTED_DASH_DOT, STBorderStyle.SLANT_DASH_DOT);
+ }
+
+ @Test
public void testGetSetBottomBorderColor() {
//defaults
assertEquals(IndexedColors.BLACK.getIndex(), cellStyle.getBottomBorderColor());
@@ -780,21 +727,21 @@ public class TestXSSFCellStyle {
assertEquals(2, wb.getNumberOfFonts());
XSSFCellStyle orig = wb.createCellStyle();
- orig.setAlignment(HSSFCellStyle.ALIGN_RIGHT);
+ orig.setAlignment(CellStyle.ALIGN_RIGHT);
orig.setFont(fnt);
orig.setDataFormat((short)18);
- assertTrue(HSSFCellStyle.ALIGN_RIGHT == orig.getAlignment());
+ assertTrue(CellStyle.ALIGN_RIGHT == orig.getAlignment());
assertTrue(fnt == orig.getFont());
assertTrue(18 == orig.getDataFormat());
XSSFCellStyle clone = wb.createCellStyle();
- assertFalse(HSSFCellStyle.ALIGN_RIGHT == clone.getAlignment());
+ assertFalse(CellStyle.ALIGN_RIGHT == clone.getAlignment());
assertFalse(fnt == clone.getFont());
assertFalse(18 == clone.getDataFormat());
clone.cloneStyleFrom(orig);
- assertTrue(HSSFCellStyle.ALIGN_RIGHT == clone.getAlignment());
+ assertTrue(CellStyle.ALIGN_RIGHT == clone.getAlignment());
assertTrue(fnt == clone.getFont());
assertTrue(18 == clone.getDataFormat());
assertEquals(2, wb.getNumberOfFonts());
@@ -1104,5 +1051,7 @@ public class TestXSSFCellStyle {
cellStyle.setRightBorderColor(null);
assertNull(cellStyle.getRightBorderXSSFColor());
+
+ workbook.close();
}
}
Modified: poi/trunk/src/scratchpad/src/org/apache/poi/hssf/converter/AbstractExcelUtils.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/scratchpad/src/org/apache/poi/hssf/converter/AbstractExcelUtils.java?rev=1737879&r1=1737878&r2=1737879&view=diff
==============================================================================
--- poi/trunk/src/scratchpad/src/org/apache/poi/hssf/converter/AbstractExcelUtils.java (original)
+++ poi/trunk/src/scratchpad/src/org/apache/poi/hssf/converter/AbstractExcelUtils.java Tue Apr 5 20:28:46 2016
@@ -25,6 +25,7 @@ import org.apache.poi.hssf.usermodel.HSS
import org.apache.poi.hssf.usermodel.HSSFWorkbook;
import org.apache.poi.hssf.util.HSSFColor;
import org.apache.poi.hwpf.converter.AbstractWordUtils;
+import org.apache.poi.ss.usermodel.BorderStyle;
import org.apache.poi.ss.util.CellRangeAddress;
import org.apache.poi.util.Beta;
import org.apache.poi.util.IOUtils;
@@ -66,28 +67,28 @@ public class AbstractExcelUtils
}
}
- public static String getBorderStyle( short xlsBorder )
+ public static String getBorderStyle( BorderStyle xlsBorder )
{
final String borderStyle;
switch ( xlsBorder )
{
- case HSSFCellStyle.BORDER_NONE:
+ case NONE:
borderStyle = "none";
break;
- case HSSFCellStyle.BORDER_DASH_DOT:
- case HSSFCellStyle.BORDER_DASH_DOT_DOT:
- case HSSFCellStyle.BORDER_DOTTED:
- case HSSFCellStyle.BORDER_HAIR:
- case HSSFCellStyle.BORDER_MEDIUM_DASH_DOT:
- case HSSFCellStyle.BORDER_MEDIUM_DASH_DOT_DOT:
- case HSSFCellStyle.BORDER_SLANTED_DASH_DOT:
+ case DASH_DOT:
+ case DASH_DOT_DOT:
+ case DOTTED:
+ case HAIR:
+ case MEDIUM_DASH_DOT:
+ case MEDIUM_DASH_DOT_DOT:
+ case SLANTED_DASH_DOT:
borderStyle = "dotted";
break;
- case HSSFCellStyle.BORDER_DASHED:
- case HSSFCellStyle.BORDER_MEDIUM_DASHED:
+ case DASHED:
+ case MEDIUM_DASHED:
borderStyle = "dashed";
break;
- case HSSFCellStyle.BORDER_DOUBLE:
+ case DOUBLE:
borderStyle = "double";
break;
default:
@@ -97,17 +98,17 @@ public class AbstractExcelUtils
return borderStyle;
}
- public static String getBorderWidth( short xlsBorder )
+ public static String getBorderWidth( BorderStyle xlsBorder )
{
final String borderWidth;
switch ( xlsBorder )
{
- case HSSFCellStyle.BORDER_MEDIUM_DASH_DOT:
- case HSSFCellStyle.BORDER_MEDIUM_DASH_DOT_DOT:
- case HSSFCellStyle.BORDER_MEDIUM_DASHED:
+ case MEDIUM_DASH_DOT:
+ case MEDIUM_DASH_DOT_DOT:
+ case MEDIUM_DASHED:
borderWidth = "2pt";
break;
- case HSSFCellStyle.BORDER_THICK:
+ case THICK:
borderWidth = "thick";
break;
default:
Modified: poi/trunk/src/scratchpad/src/org/apache/poi/hssf/converter/ExcelToFoConverter.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/scratchpad/src/org/apache/poi/hssf/converter/ExcelToFoConverter.java?rev=1737879&r1=1737878&r2=1737879&view=diff
==============================================================================
--- poi/trunk/src/scratchpad/src/org/apache/poi/hssf/converter/ExcelToFoConverter.java (original)
+++ poi/trunk/src/scratchpad/src/org/apache/poi/hssf/converter/ExcelToFoConverter.java Tue Apr 5 20:28:46 2016
@@ -38,6 +38,7 @@ import org.apache.poi.hssf.util.HSSFColo
import org.apache.poi.hwpf.converter.FoDocumentFacade;
import org.apache.poi.hwpf.converter.FontReplacer.Triplet;
import org.apache.poi.ss.formula.eval.ErrorEval;
+import org.apache.poi.ss.usermodel.BorderStyle;
import org.apache.poi.ss.usermodel.CellStyle;
import org.apache.poi.ss.util.CellRangeAddress;
import org.apache.poi.util.Beta;
@@ -192,10 +193,10 @@ public class ExcelToFoConverter extends
protected boolean isEmptyStyle( CellStyle cellStyle ) {
return cellStyle == null || (
cellStyle.getFillPattern() == 0
- && cellStyle.getBorderTop() == HSSFCellStyle.BORDER_NONE
- && cellStyle.getBorderRight() == HSSFCellStyle.BORDER_NONE
- && cellStyle.getBorderBottom() == HSSFCellStyle.BORDER_NONE
- && cellStyle.getBorderLeft() == HSSFCellStyle.BORDER_NONE
+ && cellStyle.getBorderTop() == BorderStyle.NONE
+ && cellStyle.getBorderRight() == BorderStyle.NONE
+ && cellStyle.getBorderBottom() == BorderStyle.NONE
+ && cellStyle.getBorderLeft() == BorderStyle.NONE
);
}
@@ -374,9 +375,9 @@ public class ExcelToFoConverter extends
}
protected void processCellStyleBorder( HSSFWorkbook workbook,
- Element cellTarget, String type, short xlsBorder, short borderColor )
+ Element cellTarget, String type, BorderStyle xlsBorder, short borderColor )
{
- if ( xlsBorder == HSSFCellStyle.BORDER_NONE )
+ if ( xlsBorder == BorderStyle.NONE )
return;
StringBuilder borderStyle = new StringBuilder();
Modified: poi/trunk/src/scratchpad/src/org/apache/poi/hssf/converter/ExcelToHtmlConverter.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/scratchpad/src/org/apache/poi/hssf/converter/ExcelToHtmlConverter.java?rev=1737879&r1=1737878&r2=1737879&view=diff
==============================================================================
--- poi/trunk/src/scratchpad/src/org/apache/poi/hssf/converter/ExcelToHtmlConverter.java (original)
+++ poi/trunk/src/scratchpad/src/org/apache/poi/hssf/converter/ExcelToHtmlConverter.java Tue Apr 5 20:28:46 2016
@@ -42,6 +42,7 @@ import org.apache.poi.hssf.usermodel.HSS
import org.apache.poi.hssf.util.HSSFColor;
import org.apache.poi.hwpf.converter.HtmlDocumentFacade;
import org.apache.poi.ss.formula.eval.ErrorEval;
+import org.apache.poi.ss.usermodel.BorderStyle;
import org.apache.poi.ss.util.CellRangeAddress;
import org.apache.poi.util.Beta;
import org.apache.poi.util.POILogFactory;
@@ -190,9 +191,9 @@ public class ExcelToHtmlConverter extend
}
private void buildStyle_border( HSSFWorkbook workbook, StringBuilder style,
- String type, short xlsBorder, short borderColor )
+ String type, BorderStyle xlsBorder, short borderColor )
{
- if ( xlsBorder == HSSFCellStyle.BORDER_NONE ) {
+ if ( xlsBorder == BorderStyle.NONE ) {
return;
}
Modified: poi/trunk/src/testcases/org/apache/poi/hssf/usermodel/TestBugs.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/testcases/org/apache/poi/hssf/usermodel/TestBugs.java?rev=1737879&r1=1737878&r2=1737879&view=diff
==============================================================================
--- poi/trunk/src/testcases/org/apache/poi/hssf/usermodel/TestBugs.java (original)
+++ poi/trunk/src/testcases/org/apache/poi/hssf/usermodel/TestBugs.java Tue Apr 5 20:28:46 2016
@@ -68,6 +68,7 @@ import org.apache.poi.ss.formula.ptg.Are
import org.apache.poi.ss.formula.ptg.DeletedArea3DPtg;
import org.apache.poi.ss.formula.ptg.Ptg;
import org.apache.poi.ss.usermodel.BaseTestBugzillaIssues;
+import org.apache.poi.ss.usermodel.BorderStyle;
import org.apache.poi.ss.usermodel.Cell;
import org.apache.poi.ss.usermodel.CellStyle;
import org.apache.poi.ss.usermodel.ClientAnchor.AnchorType;
@@ -2564,7 +2565,7 @@ public final class TestBugs extends Base
HSSFSheet sheet = wb.getSheetAt(0);
HSSFRow row = sheet.getRow(0);
HSSFCellStyle rstyle = row.getRowStyle();
- assertEquals(rstyle.getBorderBottom(), CellStyle.BORDER_DOUBLE);
+ assertEquals(BorderStyle.DOUBLE, rstyle.getBorderBottom());
wb.close();
}
Modified: poi/trunk/src/testcases/org/apache/poi/hssf/usermodel/TestCellStyle.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/testcases/org/apache/poi/hssf/usermodel/TestCellStyle.java?rev=1737879&r1=1737878&r2=1737879&view=diff
==============================================================================
--- poi/trunk/src/testcases/org/apache/poi/hssf/usermodel/TestCellStyle.java (original)
+++ poi/trunk/src/testcases/org/apache/poi/hssf/usermodel/TestCellStyle.java Tue Apr 5 20:28:46 2016
@@ -24,6 +24,7 @@ import java.util.Calendar;
import java.util.Date;
import org.apache.poi.hssf.HSSFTestDataSamples;
+import org.apache.poi.ss.usermodel.BorderStyle;
import org.apache.poi.ss.usermodel.Cell;
import org.apache.poi.ss.usermodel.CellStyle;
import org.apache.poi.ss.usermodel.Font;
@@ -180,10 +181,10 @@ public final class TestCellStyle extends
HSSFCellStyle cs = wb.createCellStyle();
HSSFCellStyle cs2 = wb.createCellStyle();
- cs.setBorderBottom(HSSFCellStyle.BORDER_THIN);
- cs.setBorderLeft(HSSFCellStyle.BORDER_THIN);
- cs.setBorderRight(HSSFCellStyle.BORDER_THIN);
- cs.setBorderTop(HSSFCellStyle.BORDER_THIN);
+ cs.setBorderBottom(BorderStyle.THIN);
+ cs.setBorderLeft(BorderStyle.THIN);
+ cs.setBorderRight(BorderStyle.THIN);
+ cs.setBorderTop(BorderStyle.THIN);
cs.setFillForegroundColor(( short ) 0xA);
cs.setFillPattern(( short ) 1);
fnt.setColor(( short ) 0xf);
@@ -346,40 +347,40 @@ public final class TestCellStyle extends
HSSFCellStyle cs;
cs = s.getRow(0).getCell(0).getCellStyle();
- assertEquals(CellStyle.BORDER_HAIR, cs.getBorderRight());
+ assertEquals(BorderStyle.HAIR, cs.getBorderRight());
cs = s.getRow(1).getCell(1).getCellStyle();
- assertEquals(CellStyle.BORDER_DOTTED, cs.getBorderRight());
+ assertEquals(BorderStyle.DOTTED, cs.getBorderRight());
cs = s.getRow(2).getCell(2).getCellStyle();
- assertEquals(CellStyle.BORDER_DASH_DOT_DOT, cs.getBorderRight());
+ assertEquals(BorderStyle.DASH_DOT_DOT, cs.getBorderRight());
cs = s.getRow(3).getCell(3).getCellStyle();
- assertEquals(CellStyle.BORDER_DASHED, cs.getBorderRight());
+ assertEquals(BorderStyle.DASHED, cs.getBorderRight());
cs = s.getRow(4).getCell(4).getCellStyle();
- assertEquals(CellStyle.BORDER_THIN, cs.getBorderRight());
+ assertEquals(BorderStyle.THIN, cs.getBorderRight());
cs = s.getRow(5).getCell(5).getCellStyle();
- assertEquals(CellStyle.BORDER_MEDIUM_DASH_DOT_DOT, cs.getBorderRight());
+ assertEquals(BorderStyle.MEDIUM_DASH_DOT_DOT, cs.getBorderRight());
cs = s.getRow(6).getCell(6).getCellStyle();
- assertEquals(CellStyle.BORDER_SLANTED_DASH_DOT, cs.getBorderRight());
+ assertEquals(BorderStyle.SLANTED_DASH_DOT, cs.getBorderRight());
cs = s.getRow(7).getCell(7).getCellStyle();
- assertEquals(CellStyle.BORDER_MEDIUM_DASH_DOT, cs.getBorderRight());
+ assertEquals(BorderStyle.MEDIUM_DASH_DOT, cs.getBorderRight());
cs = s.getRow(8).getCell(8).getCellStyle();
- assertEquals(CellStyle.BORDER_MEDIUM_DASHED, cs.getBorderRight());
+ assertEquals(BorderStyle.MEDIUM_DASHED, cs.getBorderRight());
cs = s.getRow(9).getCell(9).getCellStyle();
- assertEquals(CellStyle.BORDER_MEDIUM, cs.getBorderRight());
+ assertEquals(BorderStyle.MEDIUM, cs.getBorderRight());
cs = s.getRow(10).getCell(10).getCellStyle();
- assertEquals(CellStyle.BORDER_THICK, cs.getBorderRight());
+ assertEquals(BorderStyle.THICK, cs.getBorderRight());
cs = s.getRow(11).getCell(11).getCellStyle();
- assertEquals(CellStyle.BORDER_DOUBLE, cs.getBorderRight());
+ assertEquals(BorderStyle.DOUBLE, cs.getBorderRight());
}
public void testShrinkToFit() {
@@ -485,7 +486,7 @@ public final class TestCellStyle extends
font.setColor(Font.COLOR_RED);
CellStyle style = wb.createCellStyle();
- style.setBorderBottom(CellStyle.BORDER_DOTTED);
+ style.setBorderBottom(BorderStyle.DOTTED);
style.setFont(font);
Cell cell = row.createCell(0);
@@ -498,7 +499,7 @@ public final class TestCellStyle extends
newCell.setCellValue("2testtext2");
CellStyle newStyle = newCell.getCellStyle();
- assertEquals(CellStyle.BORDER_DOTTED, newStyle.getBorderBottom());
+ assertEquals(BorderStyle.DOTTED, newStyle.getBorderBottom());
assertEquals(Font.COLOR_RED, ((HSSFCellStyle)newStyle).getFont(wb).getColor());
// OutputStream out = new FileOutputStream("/tmp/56959.xls");
Modified: poi/trunk/src/testcases/org/apache/poi/hssf/usermodel/TestHSSFOptimiser.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/testcases/org/apache/poi/hssf/usermodel/TestHSSFOptimiser.java?rev=1737879&r1=1737878&r2=1737879&view=diff
==============================================================================
--- poi/trunk/src/testcases/org/apache/poi/hssf/usermodel/TestHSSFOptimiser.java (original)
+++ poi/trunk/src/testcases/org/apache/poi/hssf/usermodel/TestHSSFOptimiser.java Tue Apr 5 20:28:46 2016
@@ -16,6 +16,8 @@
==================================================================== */
package org.apache.poi.hssf.usermodel;
+import org.apache.poi.ss.usermodel.BorderStyle;
+
import junit.framework.TestCase;
public final class TestHSSFOptimiser extends TestCase {
@@ -278,13 +280,13 @@ public final class TestHSSFOptimiser ext
assertEquals(21, wb.getNumCellStyles());
HSSFCellStyle cs1 = wb.createCellStyle();
- cs1.setBorderBottom(HSSFCellStyle.BORDER_THICK);
+ cs1.setBorderBottom(BorderStyle.THICK);
HSSFCellStyle cs2 = wb.createCellStyle();
- cs2.setBorderBottom(HSSFCellStyle.BORDER_DASH_DOT);
+ cs2.setBorderBottom(BorderStyle.DASH_DOT);
HSSFCellStyle cs3 = wb.createCellStyle(); // = cs1
- cs3.setBorderBottom(HSSFCellStyle.BORDER_THICK);
+ cs3.setBorderBottom(BorderStyle.THICK);
assertEquals(24, wb.getNumCellStyles());
@@ -306,8 +308,8 @@ public final class TestHSSFOptimiser ext
// Check
assertEquals(23, wb.getNumCellStyles());
- assertEquals(HSSFCellStyle.BORDER_THICK, r.getCell(0).getCellStyle().getBorderBottom());
- assertEquals(HSSFCellStyle.BORDER_DASH_DOT, r.getCell(1).getCellStyle().getBorderBottom());
- assertEquals(HSSFCellStyle.BORDER_THICK, r.getCell(2).getCellStyle().getBorderBottom());
+ 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());
}
}
Modified: poi/trunk/src/testcases/org/apache/poi/hssf/usermodel/TestRowStyle.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/testcases/org/apache/poi/hssf/usermodel/TestRowStyle.java?rev=1737879&r1=1737878&r2=1737879&view=diff
==============================================================================
--- poi/trunk/src/testcases/org/apache/poi/hssf/usermodel/TestRowStyle.java (original)
+++ poi/trunk/src/testcases/org/apache/poi/hssf/usermodel/TestRowStyle.java Tue Apr 5 20:28:46 2016
@@ -20,6 +20,7 @@ package org.apache.poi.hssf.usermodel;
import junit.framework.TestCase;
import org.apache.poi.hssf.HSSFTestDataSamples;
+import org.apache.poi.ss.usermodel.BorderStyle;
/**
* Class to test row styling functionality
@@ -110,10 +111,10 @@ public final class TestRowStyle extends
HSSFCellStyle cs = wb.createCellStyle();
HSSFCellStyle cs2 = wb.createCellStyle();
- cs.setBorderBottom(HSSFCellStyle.BORDER_THIN);
- cs.setBorderLeft(HSSFCellStyle.BORDER_THIN);
- cs.setBorderRight(HSSFCellStyle.BORDER_THIN);
- cs.setBorderTop(HSSFCellStyle.BORDER_THIN);
+ cs.setBorderBottom(BorderStyle.THIN);
+ cs.setBorderLeft(BorderStyle.THIN);
+ cs.setBorderRight(BorderStyle.THIN);
+ cs.setBorderTop(BorderStyle.THIN);
cs.setFillForegroundColor(( short ) 0xA);
cs.setFillPattern(( short ) 1);
fnt.setColor(( short ) 0xf);
@@ -150,12 +151,12 @@ public final class TestRowStyle extends
assertNotNull("Row is not null", r);
cs = r.getRowStyle();
- assertEquals("FillForegroundColor for row: ", cs.getBorderBottom(), HSSFCellStyle.BORDER_THIN);
- assertEquals("FillPattern for row: ", cs.getBorderLeft(), HSSFCellStyle.BORDER_THIN);
- assertEquals("FillForegroundColor for row: ", cs.getBorderRight(), HSSFCellStyle.BORDER_THIN);
- assertEquals("FillPattern for row: ", cs.getBorderTop(), HSSFCellStyle.BORDER_THIN);
- assertEquals("FillForegroundColor for row: ", cs.getFillForegroundColor(), 0xA);
- assertEquals("FillPattern for row: ", cs.getFillPattern(), (short) 0x1);
+ 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("FillForegroundColor for row:", 0xA, cs.getFillForegroundColor());
+ assertEquals("FillPattern for row:", 0x1, cs.getFillPattern());
rownum++;
if (rownum >= 100) break; // I feel too lazy to check if this isreqd :-/
Added: poi/trunk/src/testcases/org/apache/poi/ss/usermodel/BaseTestBorderStyle.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/testcases/org/apache/poi/ss/usermodel/BaseTestBorderStyle.java?rev=1737879&view=auto
==============================================================================
--- poi/trunk/src/testcases/org/apache/poi/ss/usermodel/BaseTestBorderStyle.java (added)
+++ poi/trunk/src/testcases/org/apache/poi/ss/usermodel/BaseTestBorderStyle.java Tue Apr 5 20:28:46 2016
@@ -0,0 +1,82 @@
+/* ====================================================================
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with
+ the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+
+ 2012 - Alfresco Software, Ltd.
+ Alfresco Software has modified source of this file
+ The details of changes as svn diff can be found in svn at location root/projects/3rd-party/src
+==================================================================== */
+
+package org.apache.poi.ss.usermodel;
+
+import static org.junit.Assert.assertEquals;
+
+import java.io.IOException;
+
+import org.apache.poi.ss.ITestDataProvider;
+import org.junit.Test;
+
+/**
+ * Tests of {@link BorderStyle}
+ */
+public class BaseTestBorderStyle {
+
+ private final ITestDataProvider _testDataProvider;
+
+ protected BaseTestBorderStyle(ITestDataProvider testDataProvider) {
+ _testDataProvider = testDataProvider;
+ }
+
+ /**
+ * Test that we use the specified locale when deciding
+ * how to format normal numbers
+ */
+ @Test
+ public void testBorderStyle() throws IOException {
+ String ext = _testDataProvider.getStandardFileNameExtension();
+ Workbook wb = _testDataProvider.openSampleWorkbook("59264."+ext);
+ Sheet sh = wb.getSheetAt(0);
+
+ assertBorderStyleEquals(BorderStyle.NONE, getDiagonalCell(sh, 0));
+ assertBorderStyleEquals(BorderStyle.THIN, getDiagonalCell(sh, 1));
+ assertBorderStyleEquals(BorderStyle.MEDIUM, getDiagonalCell(sh, 2));
+ assertBorderStyleEquals(BorderStyle.DASHED, getDiagonalCell(sh, 3));
+ assertBorderStyleEquals(BorderStyle.DOTTED, getDiagonalCell(sh, 4));
+ assertBorderStyleEquals(BorderStyle.THICK, getDiagonalCell(sh, 5));
+ assertBorderStyleEquals(BorderStyle.DOUBLE, getDiagonalCell(sh, 6));
+ assertBorderStyleEquals(BorderStyle.HAIR, getDiagonalCell(sh, 7));
+ assertBorderStyleEquals(BorderStyle.MEDIUM_DASHED, getDiagonalCell(sh, 8));
+ assertBorderStyleEquals(BorderStyle.DASH_DOT, getDiagonalCell(sh, 9));
+ assertBorderStyleEquals(BorderStyle.MEDIUM_DASH_DOT, getDiagonalCell(sh, 10));
+ assertBorderStyleEquals(BorderStyle.DASH_DOT_DOT, getDiagonalCell(sh, 11));
+ assertBorderStyleEquals(BorderStyle.MEDIUM_DASH_DOT_DOT, getDiagonalCell(sh, 12));
+ assertBorderStyleEquals(BorderStyle.SLANTED_DASH_DOT, getDiagonalCell(sh, 13));
+
+ wb.close();
+ }
+
+ private Cell getDiagonalCell(Sheet sheet, int n) {
+ return sheet.getRow(n).getCell(n);
+ }
+
+ 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());
+ }
+
+}
Propchange: poi/trunk/src/testcases/org/apache/poi/ss/usermodel/BaseTestBorderStyle.java
------------------------------------------------------------------------------
svn:eol-style = native
Modified: poi/trunk/src/testcases/org/apache/poi/ss/usermodel/BaseTestCell.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/testcases/org/apache/poi/ss/usermodel/BaseTestCell.java?rev=1737879&r1=1737878&r2=1737879&view=diff
==============================================================================
--- poi/trunk/src/testcases/org/apache/poi/ss/usermodel/BaseTestCell.java (original)
+++ poi/trunk/src/testcases/org/apache/poi/ss/usermodel/BaseTestCell.java Tue Apr 5 20:28:46 2016
@@ -254,10 +254,10 @@ public abstract class BaseTestCell {
f.setFontName("Arial Unicode MS");
cs.setFillBackgroundColor((short)3);
cs.setFont(f);
- cs.setBorderTop((short)1);
- cs.setBorderRight((short)1);
- cs.setBorderLeft((short)1);
- cs.setBorderBottom((short)1);
+ cs.setBorderTop(BorderStyle.THIN);
+ cs.setBorderRight(BorderStyle.THIN);
+ cs.setBorderLeft(BorderStyle.THIN);
+ cs.setBorderBottom(BorderStyle.THIN);
r = s.createRow(0);
c=r.createCell(0);
@@ -270,15 +270,15 @@ public abstract class BaseTestCell {
r = s.getRow(0);
c = r.getCell(0);
- assertTrue("Formula Cell at 0,0", (c.getCellType()==Cell.CELL_TYPE_FORMULA));
+ assertEquals("Formula Cell at 0,0", Cell.CELL_TYPE_FORMULA, c.getCellType());
cs = c.getCellStyle();
assertNotNull("Formula Cell Style", cs);
- assertTrue("Font Index Matches", (cs.getFontIndex() == f.getIndex()));
- assertTrue("Top Border", (cs.getBorderTop() == (short)1));
- assertTrue("Left Border", (cs.getBorderLeft() == (short)1));
- assertTrue("Right Border", (cs.getBorderRight() == (short)1));
- assertTrue("Bottom Border", (cs.getBorderBottom() == (short)1));
+ 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());
wb2.close();
}
Modified: poi/trunk/src/testcases/org/apache/poi/ss/usermodel/BaseTestConditionalFormatting.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/testcases/org/apache/poi/ss/usermodel/BaseTestConditionalFormatting.java?rev=1737879&r1=1737878&r2=1737879&view=diff
==============================================================================
--- poi/trunk/src/testcases/org/apache/poi/ss/usermodel/BaseTestConditionalFormatting.java (original)
+++ poi/trunk/src/testcases/org/apache/poi/ss/usermodel/BaseTestConditionalFormatting.java Tue Apr 5 20:28:46 2016
@@ -323,10 +323,10 @@ public abstract class BaseTestConditiona
fontFmt.setFontStyle(true, false);
BorderFormatting bordFmt = rule1.createBorderFormatting();
- bordFmt.setBorderBottom(BorderFormatting.BORDER_THIN);
- bordFmt.setBorderTop(BorderFormatting.BORDER_THICK);
- bordFmt.setBorderLeft(BorderFormatting.BORDER_DASHED);
- bordFmt.setBorderRight(BorderFormatting.BORDER_DOTTED);
+ bordFmt.setBorderBottom(BorderStyle.THIN);
+ bordFmt.setBorderTop(BorderStyle.THICK);
+ bordFmt.setBorderLeft(BorderStyle.DASHED);
+ bordFmt.setBorderRight(BorderStyle.DOTTED);
PatternFormatting patternFmt = rule1.createPatternFormatting();
patternFmt.setFillBackgroundColor(IndexedColors.YELLOW.index);
@@ -376,10 +376,10 @@ public abstract class BaseTestConditiona
BorderFormatting r1bf = rule1.getBorderFormatting();
assertNotNull(r1bf);
- assertEquals(BorderFormatting.BORDER_THIN, r1bf.getBorderBottom());
- assertEquals(BorderFormatting.BORDER_THICK,r1bf.getBorderTop());
- assertEquals(BorderFormatting.BORDER_DASHED,r1bf.getBorderLeft());
- assertEquals(BorderFormatting.BORDER_DOTTED,r1bf.getBorderRight());
+ assertEquals(BorderStyle.THIN, r1bf.getBorderBottom());
+ assertEquals(BorderStyle.THICK,r1bf.getBorderTop());
+ assertEquals(BorderStyle.DASHED,r1bf.getBorderLeft());
+ assertEquals(BorderStyle.DOTTED,r1bf.getBorderRight());
PatternFormatting r1pf = rule1.getPatternFormatting();
assertNotNull(r1pf);
@@ -453,7 +453,7 @@ public abstract class BaseTestConditiona
ConditionalFormattingRule rule2 = sheetCF.createConditionalFormattingRule(
ComparisonOperator.BETWEEN, "SUM(A10:A15)", "1+SUM(B16:B30)");
BorderFormatting borderFmt = rule2.createBorderFormatting();
- borderFmt.setBorderDiagonal((short) 2);
+ borderFmt.setBorderDiagonal(BorderStyle.MEDIUM);
CellRangeAddress [] regions = {
new CellRangeAddress(2, 4, 0, 0), // A3:A5
@@ -1019,6 +1019,38 @@ public abstract class BaseTestConditiona
workbook.close();
}
+
+ @Test
+ public void testAllCreateBorderFormatting() throws IOException {
+ // Make sure it is possible to create a conditional formatting rule
+ // with every type of Border Style
+ Workbook workbook = _testDataProvider.createWorkbook();
+ Sheet sheet = workbook.createSheet();
+
+ SheetConditionalFormatting sheetCF = sheet.getSheetConditionalFormatting();
+
+ ConditionalFormattingRule rule1 = sheetCF.createConditionalFormattingRule(ComparisonOperator.EQUAL, "7");
+ BorderFormatting borderFmt = rule1.createBorderFormatting();
+
+ for (BorderStyle border : BorderStyle.values()) {
+ borderFmt.setBorderTop(border);
+ assertEquals(border, borderFmt.getBorderTop());
+
+ borderFmt.setBorderBottom(border);
+ assertEquals(border, borderFmt.getBorderBottom());
+
+ borderFmt.setBorderLeft(border);
+ assertEquals(border, borderFmt.getBorderLeft());
+
+ borderFmt.setBorderRight(border);
+ assertEquals(border, borderFmt.getBorderRight());
+
+ borderFmt.setBorderDiagonal(border);
+ assertEquals(border, borderFmt.getBorderDiagonal());
+ }
+
+ workbook.close();
+ }
@Test
public void testCreateBorderFormatting() throws IOException {
@@ -1030,37 +1062,37 @@ public abstract class BaseTestConditiona
ConditionalFormattingRule rule1 = sheetCF.createConditionalFormattingRule(ComparisonOperator.EQUAL, "7");
BorderFormatting borderFmt = rule1.createBorderFormatting();
- assertEquals(BorderFormatting.BORDER_NONE, borderFmt.getBorderBottom());
- borderFmt.setBorderBottom(BorderFormatting.BORDER_DOTTED);
- assertEquals(BorderFormatting.BORDER_DOTTED, borderFmt.getBorderBottom());
- borderFmt.setBorderBottom(BorderFormatting.BORDER_NONE);
- assertEquals(BorderFormatting.BORDER_NONE, borderFmt.getBorderBottom());
- borderFmt.setBorderBottom(BorderFormatting.BORDER_THICK);
- assertEquals(BorderFormatting.BORDER_THICK, borderFmt.getBorderBottom());
-
- assertEquals(BorderFormatting.BORDER_NONE, borderFmt.getBorderTop());
- borderFmt.setBorderTop(BorderFormatting.BORDER_DOTTED);
- assertEquals(BorderFormatting.BORDER_DOTTED, borderFmt.getBorderTop());
- borderFmt.setBorderTop(BorderFormatting.BORDER_NONE);
- assertEquals(BorderFormatting.BORDER_NONE, borderFmt.getBorderTop());
- borderFmt.setBorderTop(BorderFormatting.BORDER_THICK);
- assertEquals(BorderFormatting.BORDER_THICK, borderFmt.getBorderTop());
-
- assertEquals(BorderFormatting.BORDER_NONE, borderFmt.getBorderLeft());
- borderFmt.setBorderLeft(BorderFormatting.BORDER_DOTTED);
- assertEquals(BorderFormatting.BORDER_DOTTED, borderFmt.getBorderLeft());
- borderFmt.setBorderLeft(BorderFormatting.BORDER_NONE);
- assertEquals(BorderFormatting.BORDER_NONE, borderFmt.getBorderLeft());
- borderFmt.setBorderLeft(BorderFormatting.BORDER_THIN);
- assertEquals(BorderFormatting.BORDER_THIN, borderFmt.getBorderLeft());
-
- assertEquals(BorderFormatting.BORDER_NONE, borderFmt.getBorderRight());
- borderFmt.setBorderRight(BorderFormatting.BORDER_DOTTED);
- assertEquals(BorderFormatting.BORDER_DOTTED, borderFmt.getBorderRight());
- borderFmt.setBorderRight(BorderFormatting.BORDER_NONE);
- assertEquals(BorderFormatting.BORDER_NONE, borderFmt.getBorderRight());
- borderFmt.setBorderRight(BorderFormatting.BORDER_HAIR);
- assertEquals(BorderFormatting.BORDER_HAIR, borderFmt.getBorderRight());
+ assertEquals(BorderStyle.NONE, borderFmt.getBorderBottom());
+ borderFmt.setBorderBottom(BorderStyle.DOTTED);
+ assertEquals(BorderStyle.DOTTED, borderFmt.getBorderBottom());
+ borderFmt.setBorderBottom(BorderStyle.NONE);
+ assertEquals(BorderStyle.NONE, borderFmt.getBorderBottom());
+ borderFmt.setBorderBottom(BorderStyle.THICK);
+ assertEquals(BorderStyle.THICK, borderFmt.getBorderBottom());
+
+ assertEquals(BorderStyle.NONE, borderFmt.getBorderTop());
+ borderFmt.setBorderTop(BorderStyle.DOTTED);
+ assertEquals(BorderStyle.DOTTED, borderFmt.getBorderTop());
+ borderFmt.setBorderTop(BorderStyle.NONE);
+ assertEquals(BorderStyle.NONE, borderFmt.getBorderTop());
+ borderFmt.setBorderTop(BorderStyle.THICK);
+ assertEquals(BorderStyle.THICK, borderFmt.getBorderTop());
+
+ assertEquals(BorderStyle.NONE, borderFmt.getBorderLeft());
+ borderFmt.setBorderLeft(BorderStyle.DOTTED);
+ assertEquals(BorderStyle.DOTTED, borderFmt.getBorderLeft());
+ borderFmt.setBorderLeft(BorderStyle.NONE);
+ assertEquals(BorderStyle.NONE, borderFmt.getBorderLeft());
+ borderFmt.setBorderLeft(BorderStyle.THIN);
+ assertEquals(BorderStyle.THIN, borderFmt.getBorderLeft());
+
+ assertEquals(BorderStyle.NONE, borderFmt.getBorderRight());
+ borderFmt.setBorderRight(BorderStyle.DOTTED);
+ assertEquals(BorderStyle.DOTTED, borderFmt.getBorderRight());
+ borderFmt.setBorderRight(BorderStyle.NONE);
+ assertEquals(BorderStyle.NONE, borderFmt.getBorderRight());
+ borderFmt.setBorderRight(BorderStyle.HAIR);
+ assertEquals(BorderStyle.HAIR, borderFmt.getBorderRight());
ConditionalFormattingRule [] cfRules = { rule1 };
@@ -1076,10 +1108,10 @@ public abstract class BaseTestConditiona
BorderFormatting r1fp = cf.getRule(0).getBorderFormatting();
assertNotNull(r1fp);
- assertEquals(BorderFormatting.BORDER_THICK, r1fp.getBorderBottom());
- assertEquals(BorderFormatting.BORDER_THICK, r1fp.getBorderTop());
- assertEquals(BorderFormatting.BORDER_THIN, r1fp.getBorderLeft());
- assertEquals(BorderFormatting.BORDER_HAIR, r1fp.getBorderRight());
+ assertEquals(BorderStyle.THICK, r1fp.getBorderBottom());
+ assertEquals(BorderStyle.THICK, r1fp.getBorderTop());
+ assertEquals(BorderStyle.THIN, r1fp.getBorderLeft());
+ assertEquals(BorderStyle.HAIR, r1fp.getBorderRight());
workbook.close();
}
Added: poi/trunk/src/testcases/org/apache/poi/ss/usermodel/TestHSSFBorderStyle.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/testcases/org/apache/poi/ss/usermodel/TestHSSFBorderStyle.java?rev=1737879&view=auto
==============================================================================
--- poi/trunk/src/testcases/org/apache/poi/ss/usermodel/TestHSSFBorderStyle.java (added)
+++ poi/trunk/src/testcases/org/apache/poi/ss/usermodel/TestHSSFBorderStyle.java Tue Apr 5 20:28:46 2016
@@ -0,0 +1,30 @@
+/* ====================================================================
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with
+ the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+==================================================================== */
+
+package org.apache.poi.ss.usermodel;
+
+import org.apache.poi.hssf.HSSFITestDataProvider;
+
+/**
+ * @author Yegor Kozlov
+ */
+public final class TestHSSFBorderStyle extends BaseTestBorderStyle {
+
+ public TestHSSFBorderStyle() {
+ super(HSSFITestDataProvider.instance);
+ }
+}
\ No newline at end of file
Propchange: poi/trunk/src/testcases/org/apache/poi/ss/usermodel/TestHSSFBorderStyle.java
------------------------------------------------------------------------------
svn:eol-style = native
Modified: poi/trunk/src/testcases/org/apache/poi/ss/util/TestCellUtil.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/testcases/org/apache/poi/ss/util/TestCellUtil.java?rev=1737879&r1=1737878&r2=1737879&view=diff
==============================================================================
--- poi/trunk/src/testcases/org/apache/poi/ss/util/TestCellUtil.java (original)
+++ poi/trunk/src/testcases/org/apache/poi/ss/util/TestCellUtil.java Tue Apr 5 20:28:46 2016
@@ -29,13 +29,13 @@ import java.util.HashMap;
import java.util.Map;
import org.apache.poi.hssf.usermodel.HSSFWorkbook;
+import org.apache.poi.ss.usermodel.BorderStyle;
import org.apache.poi.ss.usermodel.Cell;
import org.apache.poi.ss.usermodel.CellStyle;
import org.apache.poi.ss.usermodel.Font;
import org.apache.poi.ss.usermodel.Row;
import org.apache.poi.ss.usermodel.Sheet;
import org.apache.poi.ss.usermodel.Workbook;
-
import org.junit.Test;
/**
@@ -53,13 +53,13 @@ public final class TestCellUtil {
// Add a border should create a new style
int styCnt1 = wb.getNumCellStyles();
- CellUtil.setCellStyleProperty(c, wb, CellUtil.BORDER_BOTTOM, CellStyle.BORDER_THIN);
+ CellUtil.setCellStyleProperty(c, wb, CellUtil.BORDER_BOTTOM, BorderStyle.THIN);
int styCnt2 = wb.getNumCellStyles();
assertEquals(styCnt2, styCnt1+1);
// Add same border to another cell, should not create another style
c = r.createCell(1);
- CellUtil.setCellStyleProperty(c, wb, CellUtil.BORDER_BOTTOM, CellStyle.BORDER_THIN);
+ CellUtil.setCellStyleProperty(c, wb, CellUtil.BORDER_BOTTOM, BorderStyle.THIN);
int styCnt3 = wb.getNumCellStyles();
assertEquals(styCnt3, styCnt2);
@@ -76,19 +76,19 @@ public final class TestCellUtil {
// Add multiple border properties to cell should create a single new style
int styCnt1 = wb.getNumCellStyles();
Map<String, Object> props = new HashMap<String, Object>();
- props.put(CellUtil.BORDER_TOP, CellStyle.BORDER_THIN);
- props.put(CellUtil.BORDER_BOTTOM, CellStyle.BORDER_THIN);
- props.put(CellUtil.BORDER_LEFT, CellStyle.BORDER_THIN);
- props.put(CellUtil.BORDER_RIGHT, CellStyle.BORDER_THIN);
+ props.put(CellUtil.BORDER_TOP, BorderStyle.THIN);
+ props.put(CellUtil.BORDER_BOTTOM, BorderStyle.THIN);
+ props.put(CellUtil.BORDER_LEFT, BorderStyle.THIN);
+ props.put(CellUtil.BORDER_RIGHT, BorderStyle.THIN);
CellUtil.setCellStyleProperties(c, props);
int styCnt2 = wb.getNumCellStyles();
- assertEquals(styCnt2, styCnt1+1);
+ assertEquals(styCnt1+1, styCnt2);
// Add same border another to same cell, should not create another style
c = r.createCell(1);
CellUtil.setCellStyleProperties(c, props);
int styCnt3 = wb.getNumCellStyles();
- assertEquals(styCnt3, styCnt2);
+ assertEquals(styCnt2, styCnt3);
wb.close();
}
Added: poi/trunk/test-data/spreadsheet/59264.xls
URL: http://svn.apache.org/viewvc/poi/trunk/test-data/spreadsheet/59264.xls?rev=1737879&view=auto
==============================================================================
Binary file - no diff available.
Propchange: poi/trunk/test-data/spreadsheet/59264.xls
------------------------------------------------------------------------------
svn:mime-type = application/vnd.ms-excel
Added: poi/trunk/test-data/spreadsheet/59264.xlsx
URL: http://svn.apache.org/viewvc/poi/trunk/test-data/spreadsheet/59264.xlsx?rev=1737879&view=auto
==============================================================================
Binary file - no diff available.
Propchange: poi/trunk/test-data/spreadsheet/59264.xlsx
------------------------------------------------------------------------------
--- svn:mime-type (added)
+++ svn:mime-type Tue Apr 5 20:28:46 2016
@@ -0,0 +1 @@
+application/vnd.openxmlformats-officedocument.spreadsheetml.sheet
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@poi.apache.org
For additional commands, e-mail: commits-help@poi.apache.org