ASF Bugzilla – Attachment 30659 Details for
Bug 55341
[PATCH] constants for HAIR and DOTTED border styles are swapped
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
Remember
[x]
|
Forgot Password
Login:
[x]
[patch]
Patch and unit tests
poi-border-style.patch (text/plain), 10.06 KB, created by
vladk
on 2013-08-01 21:52:11 UTC
(
hide
)
Description:
Patch and unit tests
Filename:
MIME Type:
Creator:
vladk
Created:
2013-08-01 21:52:11 UTC
Size:
10.06 KB
patch
obsolete
>Index: src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFCellStyle.java >=================================================================== >--- src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFCellStyle.java (revision 1509427) >+++ src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFCellStyle.java (working copy) >@@ -229,6 +229,136 @@ > 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()); >Index: src/java/org/apache/poi/ss/usermodel/CellStyle.java >=================================================================== >--- src/java/org/apache/poi/ss/usermodel/CellStyle.java (revision 1509427) >+++ src/java/org/apache/poi/ss/usermodel/CellStyle.java (working copy) >@@ -113,7 +113,7 @@ > * dot border > */ > >- public final static short BORDER_HAIR = 0x4; >+ public final static short BORDER_HAIR = 0x7; > > /** > * Thick border >@@ -131,7 +131,7 @@ > * hair-line border > */ > >- public final static short BORDER_DOTTED = 0x7; >+ public final static short BORDER_DOTTED = 0x4; > > /** > * Medium dashed border >Index: src/testcases/org/apache/poi/hssf/usermodel/TestCellStyle.java >=================================================================== >--- src/testcases/org/apache/poi/hssf/usermodel/TestCellStyle.java (revision 1509427) >+++ src/testcases/org/apache/poi/hssf/usermodel/TestCellStyle.java (working copy) >@@ -18,7 +18,9 @@ > package org.apache.poi.hssf.usermodel; > > import junit.framework.TestCase; >+ > import org.apache.poi.hssf.HSSFTestDataSamples; >+import org.apache.poi.ss.usermodel.CellStyle; > import org.apache.poi.util.TempFile; > > import java.io.File; >@@ -331,5 +333,47 @@ > c4.setCellStyle(cs2); > assertEquals("style1", c4.getCellStyle().getParentStyle().getUserStyleName()); > } >+ >+ public void testGetSetBorderHair() { >+ HSSFWorkbook wb = openSample("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()); >+ } > > }
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
Attachments on
bug 55341
: 30659 |
30660