Author: centic
Date: Sun Sep 29 20:23:20 2013
New Revision: 1527397
URL: http://svn.apache.org/r1527397
Log:
Apply patch from bug 55341
Added:
poi/trunk/test-data/spreadsheet/55341_CellStyleBorder.xls
Modified:
poi/trunk/src/java/org/apache/poi/ss/usermodel/CellStyle.java
poi/trunk/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFCellStyle.java
poi/trunk/src/testcases/org/apache/poi/hssf/usermodel/TestCellStyle.java
Modified: poi/trunk/src/java/org/apache/poi/ss/usermodel/CellStyle.java
URL:
http://svn.apache.org/viewvc/poi/trunk/src/java/org/apache/poi/ss/usermodel/CellStyle.java?rev=1527397&r1=1527396&r2=1527397&view=diff
==============================================================================
--- poi/trunk/src/java/org/apache/poi/ss/usermodel/CellStyle.java (original)
+++ poi/trunk/src/java/org/apache/poi/ss/usermodel/CellStyle.java Sun Sep 29
20:23:20 2013
@@ -113,7 +113,7 @@ public interface CellStyle {
* dot border
*/
- public final static short BORDER_HAIR = 0x4;
+ public final static short BORDER_HAIR = 0x7;
/**
* Thick border
@@ -131,7 +131,7 @@ public interface CellStyle {
* hair-line border
*/
- public final static short BORDER_DOTTED = 0x7;
+ public final static short BORDER_DOTTED = 0x4;
/**
* Medium dashed border
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=1527397&r1=1527396&r2=1527397&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
Sun Sep 29 20:23:20 2013
@@ -229,6 +229,136 @@ public class TestXSSFCellStyle extends T
assertFalse(ctBorder.isSetTop());
}
+ public void testGetSetBorderThin() {
+ cellStyle.setBorderTop(CellStyle.BORDER_THIN);
+ assertEquals(CellStyle.BORDER_THIN, 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());
+ }
+
+ public void testGetSetBorderMedium() {
+ cellStyle.setBorderTop(CellStyle.BORDER_MEDIUM);
+ assertEquals(CellStyle.BORDER_MEDIUM, 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());
+ }
+
+ 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());
+ }
+
+ 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());
+ }
+
+ 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());
+ }
+
+ 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());
+ }
+
+ 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());
+ }
+
+ 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());
+ }
+
+ 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());
+ }
+
+ 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());
+ }
+
+ 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());
+ }
+
+ 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());
+ }
+
+ 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());
+ }
+
public void testGetSetBottomBorderColor() {
//defaults
assertEquals(IndexedColors.BLACK.getIndex(),
cellStyle.getBottomBorderColor());
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=1527397&r1=1527396&r2=1527397&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
Sun Sep 29 20:23:20 2013
@@ -17,16 +17,18 @@
package org.apache.poi.hssf.usermodel;
-import junit.framework.TestCase;
-import org.apache.poi.hssf.HSSFTestDataSamples;
-import org.apache.poi.util.TempFile;
-
import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.util.Calendar;
import java.util.Date;
+import junit.framework.TestCase;
+
+import org.apache.poi.hssf.HSSFTestDataSamples;
+import org.apache.poi.ss.usermodel.CellStyle;
+import org.apache.poi.util.TempFile;
+
/**
* Class to test cell styling functionality
*
@@ -331,5 +333,47 @@ public final class TestCellStyle extends
c4.setCellStyle(cs2);
assertEquals("style1",
c4.getCellStyle().getParentStyle().getUserStyleName());
}
+
+ public void testGetSetBorderHair() {
+ HSSFWorkbook wb = openSample("55341_CellStyleBorder.xls");
+ HSSFSheet s = wb.getSheetAt(0);
+ HSSFCellStyle cs;
+
+ cs = s.getRow(0).getCell(0).getCellStyle();
+ assertEquals(CellStyle.BORDER_HAIR, cs.getBorderRight());
+
+ cs = s.getRow(1).getCell(1).getCellStyle();
+ assertEquals(CellStyle.BORDER_DOTTED, cs.getBorderRight());
+
+ cs = s.getRow(2).getCell(2).getCellStyle();
+ assertEquals(CellStyle.BORDER_DASH_DOT_DOT, cs.getBorderRight());
+
+ cs = s.getRow(3).getCell(3).getCellStyle();
+ assertEquals(CellStyle.BORDER_DASHED, cs.getBorderRight());
+
+ cs = s.getRow(4).getCell(4).getCellStyle();
+ assertEquals(CellStyle.BORDER_THIN, cs.getBorderRight());
+
+ cs = s.getRow(5).getCell(5).getCellStyle();
+ assertEquals(CellStyle.BORDER_MEDIUM_DASH_DOT_DOT,
cs.getBorderRight());
+
+ cs = s.getRow(6).getCell(6).getCellStyle();
+ assertEquals(CellStyle.BORDER_SLANTED_DASH_DOT, cs.getBorderRight());
+
+ cs = s.getRow(7).getCell(7).getCellStyle();
+ assertEquals(CellStyle.BORDER_MEDIUM_DASH_DOT, cs.getBorderRight());
+
+ cs = s.getRow(8).getCell(8).getCellStyle();
+ assertEquals(CellStyle.BORDER_MEDIUM_DASHED, cs.getBorderRight());
+
+ cs = s.getRow(9).getCell(9).getCellStyle();
+ assertEquals(CellStyle.BORDER_MEDIUM, cs.getBorderRight());
+
+ cs = s.getRow(10).getCell(10).getCellStyle();
+ assertEquals(CellStyle.BORDER_THICK, cs.getBorderRight());
+
+ cs = s.getRow(11).getCell(11).getCellStyle();
+ assertEquals(CellStyle.BORDER_DOUBLE, cs.getBorderRight());
+ }
}
Added: poi/trunk/test-data/spreadsheet/55341_CellStyleBorder.xls
URL:
http://svn.apache.org/viewvc/poi/trunk/test-data/spreadsheet/55341_CellStyleBorder.xls?rev=1527397&view=auto
==============================================================================
Files poi/trunk/test-data/spreadsheet/55341_CellStyleBorder.xls (added) and
poi/trunk/test-data/spreadsheet/55341_CellStyleBorder.xls Sun Sep 29 20:23:20
2013 differ
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]