]> source.dussan.org Git - poi.git/commitdiff
Apply patch from bug 55341
authorDominik Stadler <centic@apache.org>
Sun, 29 Sep 2013 20:23:20 +0000 (20:23 +0000)
committerDominik Stadler <centic@apache.org>
Sun, 29 Sep 2013 20:23:20 +0000 (20:23 +0000)
git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1527397 13f79535-47bb-0310-9956-ffa450edef68

src/java/org/apache/poi/ss/usermodel/CellStyle.java
src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFCellStyle.java
src/testcases/org/apache/poi/hssf/usermodel/TestCellStyle.java
test-data/spreadsheet/55341_CellStyleBorder.xls [new file with mode: 0644]

index 7b62c1ee8005f4a0d05e5c14c7889aeb30e269d2..3eed0604bd4b0e50fa0f9d65439f17b5a0277b3f 100644 (file)
@@ -113,7 +113,7 @@ public interface CellStyle {
      * dot border
      */
 
-    public final static short BORDER_HAIR = 0x4;
+    public final static short BORDER_HAIR = 0x7;\r
 
     /**
      * 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;\r
 
     /**
      * Medium dashed border
index 11b724f4abe036dac045e49d29796bf50f606d2a..303cba95eee693cd1fc8aa107ff2e906fe5d0993 100644 (file)
@@ -229,6 +229,136 @@ public class TestXSSFCellStyle extends TestCase {
         assertFalse(ctBorder.isSetTop());
        }
 
+       public void testGetSetBorderThin() {\r
+        cellStyle.setBorderTop(CellStyle.BORDER_THIN);\r
+        assertEquals(CellStyle.BORDER_THIN, cellStyle.getBorderTop());\r
+        int borderId = (int)cellStyle.getCoreXf().getBorderId();\r
+        assertTrue(borderId > 0);\r
+        //check changes in the underlying xml bean\r
+        CTBorder ctBorder = stylesTable.getBorderAt(borderId).getCTBorder();\r
+        assertEquals(STBorderStyle.THIN, ctBorder.getTop().getStyle());\r
+       }\r
+       \r
+       public void testGetSetBorderMedium() {\r
+        cellStyle.setBorderTop(CellStyle.BORDER_MEDIUM);\r
+        assertEquals(CellStyle.BORDER_MEDIUM, cellStyle.getBorderTop());\r
+        int borderId = (int)cellStyle.getCoreXf().getBorderId();\r
+        assertTrue(borderId > 0);\r
+        //check changes in the underlying xml bean\r
+        CTBorder ctBorder = stylesTable.getBorderAt(borderId).getCTBorder();\r
+        assertEquals(STBorderStyle.MEDIUM, ctBorder.getTop().getStyle());\r
+       }\r
+       \r
+       public void testGetSetBorderThick() {\r
+        cellStyle.setBorderTop(CellStyle.BORDER_THICK);\r
+        assertEquals(CellStyle.BORDER_THICK, cellStyle.getBorderTop());\r
+        int borderId = (int)cellStyle.getCoreXf().getBorderId();\r
+        assertTrue(borderId > 0);\r
+        //check changes in the underlying xml bean\r
+        CTBorder ctBorder = stylesTable.getBorderAt(borderId).getCTBorder();\r
+        assertEquals(STBorderStyle.THICK, ctBorder.getTop().getStyle());\r
+       }\r
+       \r
+       public void testGetSetBorderHair() {\r
+        cellStyle.setBorderTop(CellStyle.BORDER_HAIR);\r
+        assertEquals(CellStyle.BORDER_HAIR, cellStyle.getBorderTop());\r
+        int borderId = (int)cellStyle.getCoreXf().getBorderId();\r
+        assertTrue(borderId > 0);\r
+        //check changes in the underlying xml bean\r
+        CTBorder ctBorder = stylesTable.getBorderAt(borderId).getCTBorder();\r
+        assertEquals(STBorderStyle.HAIR, ctBorder.getTop().getStyle());\r
+       }\r
+       \r
+       public void testGetSetBorderDotted() {\r
+        cellStyle.setBorderTop(CellStyle.BORDER_DOTTED);\r
+        assertEquals(CellStyle.BORDER_DOTTED, cellStyle.getBorderTop());\r
+        int borderId = (int)cellStyle.getCoreXf().getBorderId();\r
+        assertTrue(borderId > 0);\r
+        //check changes in the underlying xml bean\r
+        CTBorder ctBorder = stylesTable.getBorderAt(borderId).getCTBorder();\r
+        assertEquals(STBorderStyle.DOTTED, ctBorder.getTop().getStyle());\r
+       }\r
+       \r
+       public void testGetSetBorderDashed() {\r
+        cellStyle.setBorderTop(CellStyle.BORDER_DASHED);\r
+        assertEquals(CellStyle.BORDER_DASHED, cellStyle.getBorderTop());\r
+        int borderId = (int)cellStyle.getCoreXf().getBorderId();\r
+        assertTrue(borderId > 0);\r
+        //check changes in the underlying xml bean\r
+        CTBorder ctBorder = stylesTable.getBorderAt(borderId).getCTBorder();\r
+        assertEquals(STBorderStyle.DASHED, ctBorder.getTop().getStyle());\r
+       }\r
+       \r
+       public void testGetSetBorderDashDot() {\r
+        cellStyle.setBorderTop(CellStyle.BORDER_DASH_DOT);\r
+        assertEquals(CellStyle.BORDER_DASH_DOT, cellStyle.getBorderTop());\r
+        int borderId = (int)cellStyle.getCoreXf().getBorderId();\r
+        assertTrue(borderId > 0);\r
+        //check changes in the underlying xml bean\r
+        CTBorder ctBorder = stylesTable.getBorderAt(borderId).getCTBorder();\r
+        assertEquals(STBorderStyle.DASH_DOT, ctBorder.getTop().getStyle());\r
+       }\r
+       \r
+       public void testGetSetBorderDashDotDot() {\r
+        cellStyle.setBorderTop(CellStyle.BORDER_DASH_DOT_DOT);\r
+        assertEquals(CellStyle.BORDER_DASH_DOT_DOT, cellStyle.getBorderTop());\r
+        int borderId = (int)cellStyle.getCoreXf().getBorderId();\r
+        assertTrue(borderId > 0);\r
+        //check changes in the underlying xml bean\r
+        CTBorder ctBorder = stylesTable.getBorderAt(borderId).getCTBorder();\r
+        assertEquals(STBorderStyle.DASH_DOT_DOT, ctBorder.getTop().getStyle());\r
+       }\r
+       \r
+       public void testGetSetBorderMediumDashDot() {\r
+        cellStyle.setBorderTop(CellStyle.BORDER_MEDIUM_DASH_DOT);\r
+        assertEquals(CellStyle.BORDER_MEDIUM_DASH_DOT, cellStyle.getBorderTop());\r
+        int borderId = (int)cellStyle.getCoreXf().getBorderId();\r
+        assertTrue(borderId > 0);\r
+        //check changes in the underlying xml bean\r
+        CTBorder ctBorder = stylesTable.getBorderAt(borderId).getCTBorder();\r
+        assertEquals(STBorderStyle.MEDIUM_DASH_DOT, ctBorder.getTop().getStyle());\r
+       }\r
+       \r
+       public void testGetSetBorderMediumDashDotDot() {\r
+        cellStyle.setBorderTop(CellStyle.BORDER_MEDIUM_DASH_DOT_DOT);\r
+        assertEquals(CellStyle.BORDER_MEDIUM_DASH_DOT_DOT, cellStyle.getBorderTop());\r
+        int borderId = (int)cellStyle.getCoreXf().getBorderId();\r
+        assertTrue(borderId > 0);\r
+        //check changes in the underlying xml bean\r
+        CTBorder ctBorder = stylesTable.getBorderAt(borderId).getCTBorder();\r
+        assertEquals(STBorderStyle.MEDIUM_DASH_DOT_DOT, ctBorder.getTop().getStyle());\r
+       }\r
+       \r
+       public void testGetSetBorderMediumDashed() {\r
+        cellStyle.setBorderTop(CellStyle.BORDER_MEDIUM_DASHED);\r
+        assertEquals(CellStyle.BORDER_MEDIUM_DASHED, cellStyle.getBorderTop());\r
+        int borderId = (int)cellStyle.getCoreXf().getBorderId();\r
+        assertTrue(borderId > 0);\r
+        //check changes in the underlying xml bean\r
+        CTBorder ctBorder = stylesTable.getBorderAt(borderId).getCTBorder();\r
+        assertEquals(STBorderStyle.MEDIUM_DASHED, ctBorder.getTop().getStyle());\r
+       }\r
+       \r
+       public void testGetSetBorderSlantDashDot() {\r
+        cellStyle.setBorderTop(CellStyle.BORDER_SLANTED_DASH_DOT);\r
+        assertEquals(CellStyle.BORDER_SLANTED_DASH_DOT, cellStyle.getBorderTop());\r
+        int borderId = (int)cellStyle.getCoreXf().getBorderId();\r
+        assertTrue(borderId > 0);\r
+        //check changes in the underlying xml bean\r
+        CTBorder ctBorder = stylesTable.getBorderAt(borderId).getCTBorder();\r
+        assertEquals(STBorderStyle.SLANT_DASH_DOT, ctBorder.getTop().getStyle());\r
+       }\r
+       \r
+       public void testGetSetBorderDouble() {\r
+        cellStyle.setBorderTop(CellStyle.BORDER_DOUBLE);\r
+        assertEquals(CellStyle.BORDER_DOUBLE, cellStyle.getBorderTop());\r
+        int borderId = (int)cellStyle.getCoreXf().getBorderId();\r
+        assertTrue(borderId > 0);\r
+        //check changes in the underlying xml bean\r
+        CTBorder ctBorder = stylesTable.getBorderAt(borderId).getCTBorder();\r
+        assertEquals(STBorderStyle.DOUBLE, ctBorder.getTop().getStyle());\r
+       }\r
+       \r
        public void testGetSetBottomBorderColor() {
         //defaults
         assertEquals(IndexedColors.BLACK.getIndex(), cellStyle.getBottomBorderColor());
index baaad8c425f5314dc28c795521ede16d0b59a3af..2457032a6651d685aa11a92ec6776b8390016322 100644 (file)
 
 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 TestCase {
         c4.setCellStyle(cs2);
         assertEquals("style1", c4.getCellStyle().getParentStyle().getUserStyleName());
     }
+    \r
+       public void testGetSetBorderHair() {\r
+        HSSFWorkbook wb = openSample("55341_CellStyleBorder.xls");\r
+        HSSFSheet s = wb.getSheetAt(0);\r
+        HSSFCellStyle cs;\r
+        \r
+        cs = s.getRow(0).getCell(0).getCellStyle();\r
+        assertEquals(CellStyle.BORDER_HAIR, cs.getBorderRight());\r
+        \r
+        cs = s.getRow(1).getCell(1).getCellStyle();\r
+        assertEquals(CellStyle.BORDER_DOTTED, cs.getBorderRight());\r
+\r
+        cs = s.getRow(2).getCell(2).getCellStyle();\r
+        assertEquals(CellStyle.BORDER_DASH_DOT_DOT, cs.getBorderRight());\r
+\r
+        cs = s.getRow(3).getCell(3).getCellStyle();\r
+        assertEquals(CellStyle.BORDER_DASHED, cs.getBorderRight());\r
+\r
+        cs = s.getRow(4).getCell(4).getCellStyle();\r
+        assertEquals(CellStyle.BORDER_THIN, cs.getBorderRight());\r
+\r
+        cs = s.getRow(5).getCell(5).getCellStyle();\r
+        assertEquals(CellStyle.BORDER_MEDIUM_DASH_DOT_DOT, cs.getBorderRight());\r
+\r
+        cs = s.getRow(6).getCell(6).getCellStyle();\r
+        assertEquals(CellStyle.BORDER_SLANTED_DASH_DOT, cs.getBorderRight());\r
+\r
+        cs = s.getRow(7).getCell(7).getCellStyle();\r
+        assertEquals(CellStyle.BORDER_MEDIUM_DASH_DOT, cs.getBorderRight());\r
+\r
+        cs = s.getRow(8).getCell(8).getCellStyle();\r
+        assertEquals(CellStyle.BORDER_MEDIUM_DASHED, cs.getBorderRight());\r
+\r
+        cs = s.getRow(9).getCell(9).getCellStyle();\r
+        assertEquals(CellStyle.BORDER_MEDIUM, cs.getBorderRight());\r
+\r
+        cs = s.getRow(10).getCell(10).getCellStyle();\r
+        assertEquals(CellStyle.BORDER_THICK, cs.getBorderRight());\r
+\r
+        cs = s.getRow(11).getCell(11).getCellStyle();\r
+        assertEquals(CellStyle.BORDER_DOUBLE, cs.getBorderRight());\r
+       }\r
 
 }
diff --git a/test-data/spreadsheet/55341_CellStyleBorder.xls b/test-data/spreadsheet/55341_CellStyleBorder.xls
new file mode 100644 (file)
index 0000000..6de09bc
Binary files /dev/null and b/test-data/spreadsheet/55341_CellStyleBorder.xls differ