use of org.openxmlformats.schemas.wordprocessingml.x2006.main.CTBorder in project poi by apache.
the class XSSFCellStyle method getBorderTopEnum.
/**
* Get the type of border to use for the top border of the cell
* Will be removed when {@link #getBorderTop()} returns a BorderStyle enum
*
* @return border type, default value is {@link org.apache.poi.ss.usermodel.BorderStyle#NONE}
* @since POI 3.15
*/
@Override
public BorderStyle getBorderTopEnum() {
if (!_cellXf.getApplyBorder())
return BorderStyle.NONE;
int idx = (int) _cellXf.getBorderId();
CTBorder ct = _stylesSource.getBorderAt(idx).getCTBorder();
STBorderStyle.Enum ptrn = ct.isSetTop() ? ct.getTop().getStyle() : null;
if (ptrn == null) {
return BorderStyle.NONE;
}
return BorderStyle.valueOf((short) (ptrn.intValue() - 1));
}
use of org.openxmlformats.schemas.wordprocessingml.x2006.main.CTBorder in project poi by apache.
the class TestXSSFBorder method testGetBorderStyle.
public void testGetBorderStyle() {
CTStylesheet stylesheet = CTStylesheet.Factory.newInstance();
CTBorder border = stylesheet.addNewBorders().addNewBorder();
CTBorderPr top = border.addNewTop();
CTBorderPr right = border.addNewRight();
CTBorderPr bottom = border.addNewBottom();
top.setStyle(STBorderStyle.DASH_DOT);
right.setStyle(STBorderStyle.NONE);
bottom.setStyle(STBorderStyle.THIN);
XSSFCellBorder cellBorderStyle = new XSSFCellBorder(border);
assertEquals("DASH_DOT", cellBorderStyle.getBorderStyle(BorderSide.TOP).toString());
assertEquals("NONE", cellBorderStyle.getBorderStyle(BorderSide.RIGHT).toString());
assertEquals(BorderStyle.NONE.ordinal(), cellBorderStyle.getBorderStyle(BorderSide.RIGHT).ordinal());
assertEquals("THIN", cellBorderStyle.getBorderStyle(BorderSide.BOTTOM).toString());
assertEquals(BorderStyle.THIN.ordinal(), cellBorderStyle.getBorderStyle(BorderSide.BOTTOM).ordinal());
}
use of org.openxmlformats.schemas.wordprocessingml.x2006.main.CTBorder in project poi by apache.
the class TestXWPFParagraph method testSetGetBorderTop.
@Test
public void testSetGetBorderTop() throws IOException {
//new clean instance of paragraph
XWPFDocument doc = new XWPFDocument();
XWPFParagraph p = doc.createParagraph();
assertEquals(STBorder.NONE.intValue(), p.getBorderTop().getValue());
CTP ctp = p.getCTP();
CTPPr ppr = ctp.getPPr() == null ? ctp.addNewPPr() : ctp.getPPr();
//bordi
CTPBdr bdr = ppr.addNewPBdr();
CTBorder borderTop = bdr.addNewTop();
borderTop.setVal(STBorder.DOUBLE);
bdr.setTop(borderTop);
assertEquals(Borders.DOUBLE, p.getBorderTop());
p.setBorderTop(Borders.SINGLE);
assertEquals(STBorder.SINGLE, borderTop.getVal());
doc.close();
}
use of org.openxmlformats.schemas.wordprocessingml.x2006.main.CTBorder in project poi by apache.
the class XWPFTable method setInsideHBorder.
public void setInsideHBorder(XWPFBorderType type, int size, int space, String rgbColor) {
CTTblPr tblPr = getTrPr();
CTTblBorders ctb = tblPr.isSetTblBorders() ? tblPr.getTblBorders() : tblPr.addNewTblBorders();
CTBorder b = ctb.isSetInsideH() ? ctb.getInsideH() : ctb.addNewInsideH();
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 getInsideVBorderType.
public XWPFBorderType getInsideVBorderType() {
XWPFBorderType bt = null;
CTTblPr tblPr = getTrPr();
if (tblPr.isSetTblBorders()) {
CTTblBorders ctb = tblPr.getTblBorders();
if (ctb.isSetInsideV()) {
CTBorder border = ctb.getInsideV();
bt = stBorderTypeMap.get(border.getVal().intValue());
}
}
return bt;
}
Aggregations