use of org.openxmlformats.schemas.wordprocessingml.x2006.main.CTBorder in project poi by apache.
the class XWPFTable method setInsideVBorder.
public void setInsideVBorder(XWPFBorderType type, int size, int space, String rgbColor) {
CTTblPr tblPr = getTrPr();
CTTblBorders ctb = tblPr.isSetTblBorders() ? tblPr.getTblBorders() : tblPr.addNewTblBorders();
CTBorder b = ctb.isSetInsideV() ? ctb.getInsideV() : ctb.addNewInsideV();
b.setVal(xwpfBorderTypeMap.get(type));
b.setSz(BigInteger.valueOf(size));
b.setSpace(BigInteger.valueOf(space));
b.setColor(rgbColor);
}
use of org.openxmlformats.schemas.wordprocessingml.x2006.main.CTBorder in project poi by apache.
the class XWPFTable method getInsideHBorderType.
public XWPFBorderType getInsideHBorderType() {
XWPFBorderType bt = null;
CTTblPr tblPr = getTrPr();
if (tblPr.isSetTblBorders()) {
CTTblBorders ctb = tblPr.getTblBorders();
if (ctb.isSetInsideH()) {
CTBorder border = ctb.getInsideH();
bt = stBorderTypeMap.get(border.getVal().intValue());
}
}
return bt;
}
use of org.openxmlformats.schemas.wordprocessingml.x2006.main.CTBorder in project poi by apache.
the class TestXSSFCellStyle method testGetSetBorderBottom.
@Test
public void testGetSetBorderBottom() {
//default values
assertEquals(BorderStyle.NONE, cellStyle.getBorderBottomEnum());
int num = stylesTable.getBorders().size();
cellStyle.setBorderBottom(BorderStyle.MEDIUM);
assertEquals(BorderStyle.MEDIUM, cellStyle.getBorderBottomEnum());
//a new border has been added
assertEquals(num + 1, stylesTable.getBorders().size());
//id of the created border
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.getBottom().getStyle());
num = stylesTable.getBorders().size();
//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.getBorderBottomEnum());
}
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(BorderStyle.NONE);
assertEquals(num, stylesTable.getBorders().size());
borderId = (int) cellStyle.getCoreXf().getBorderId();
ctBorder = stylesTable.getBorderAt(borderId).getCTBorder();
assertFalse(ctBorder.isSetBottom());
}
use of org.openxmlformats.schemas.wordprocessingml.x2006.main.CTBorder in project poi by apache.
the class TestXSSFCellStyle method testGetSetRightBorderColor.
@Test
public void testGetSetRightBorderColor() {
//defaults
assertEquals(IndexedColors.BLACK.getIndex(), cellStyle.getRightBorderColor());
assertNull(cellStyle.getRightBorderXSSFColor());
int num = stylesTable.getBorders().size();
XSSFColor clr;
//setting indexed color
cellStyle.setRightBorderColor(IndexedColors.BLUE_GREY.getIndex());
assertEquals(IndexedColors.BLUE_GREY.getIndex(), cellStyle.getRightBorderColor());
clr = cellStyle.getRightBorderXSSFColor();
assertTrue(clr.getCTColor().isSetIndexed());
assertEquals(IndexedColors.BLUE_GREY.getIndex(), clr.getIndexed());
//a new border was added to the styles table
assertEquals(num + 1, stylesTable.getBorders().size());
//id of the created border
int borderId = (int) cellStyle.getCoreXf().getBorderId();
assertTrue(borderId > 0);
//check changes in the underlying xml bean
CTBorder ctBorder = stylesTable.getBorderAt(borderId).getCTBorder();
assertEquals(IndexedColors.BLUE_GREY.getIndex(), ctBorder.getRight().getColor().getIndexed());
//setting XSSFColor
num = stylesTable.getBorders().size();
clr = new XSSFColor(java.awt.Color.CYAN);
cellStyle.setRightBorderColor(clr);
assertEquals(clr.getCTColor().toString(), cellStyle.getRightBorderXSSFColor().getCTColor().toString());
byte[] rgb = cellStyle.getRightBorderXSSFColor().getRGB();
assertEquals(java.awt.Color.CYAN, new java.awt.Color(rgb[0] & 0xFF, rgb[1] & 0xFF, rgb[2] & 0xFF));
//another border was added to the styles table
assertEquals(num + 1, stylesTable.getBorders().size());
//passing null unsets the color
cellStyle.setRightBorderColor(null);
assertNull(cellStyle.getRightBorderXSSFColor());
}
use of org.openxmlformats.schemas.wordprocessingml.x2006.main.CTBorder in project poi by apache.
the class TestXSSFCellStyle method testGetSetTopBorderColor.
@Test
public void testGetSetTopBorderColor() {
//defaults
assertEquals(IndexedColors.BLACK.getIndex(), cellStyle.getTopBorderColor());
assertNull(cellStyle.getTopBorderXSSFColor());
int num = stylesTable.getBorders().size();
XSSFColor clr;
//setting indexed color
cellStyle.setTopBorderColor(IndexedColors.BLUE_GREY.getIndex());
assertEquals(IndexedColors.BLUE_GREY.getIndex(), cellStyle.getTopBorderColor());
clr = cellStyle.getTopBorderXSSFColor();
assertTrue(clr.getCTColor().isSetIndexed());
assertEquals(IndexedColors.BLUE_GREY.getIndex(), clr.getIndexed());
//a new border was added to the styles table
assertEquals(num + 1, stylesTable.getBorders().size());
//id of the created border
int borderId = (int) cellStyle.getCoreXf().getBorderId();
assertTrue(borderId > 0);
//check changes in the underlying xml bean
CTBorder ctBorder = stylesTable.getBorderAt(borderId).getCTBorder();
assertEquals(IndexedColors.BLUE_GREY.getIndex(), ctBorder.getTop().getColor().getIndexed());
//setting XSSFColor
num = stylesTable.getBorders().size();
clr = new XSSFColor(java.awt.Color.CYAN);
cellStyle.setTopBorderColor(clr);
assertEquals(clr.getCTColor().toString(), cellStyle.getTopBorderXSSFColor().getCTColor().toString());
byte[] rgb = cellStyle.getTopBorderXSSFColor().getRGB();
assertEquals(java.awt.Color.CYAN, new java.awt.Color(rgb[0] & 0xFF, rgb[1] & 0xFF, rgb[2] & 0xFF));
//another border was added to the styles table
assertEquals(num + 1, stylesTable.getBorders().size());
//passing null unsets the color
cellStyle.setTopBorderColor(null);
assertNull(cellStyle.getTopBorderXSSFColor());
}
Aggregations