Search in sources :

Example 26 with CTBorder

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));
}
Also used : CTBorder(org.openxmlformats.schemas.spreadsheetml.x2006.main.CTBorder) STBorderStyle(org.openxmlformats.schemas.spreadsheetml.x2006.main.STBorderStyle)

Example 27 with CTBorder

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());
}
Also used : CTBorder(org.openxmlformats.schemas.spreadsheetml.x2006.main.CTBorder) CTStylesheet(org.openxmlformats.schemas.spreadsheetml.x2006.main.CTStylesheet) CTBorderPr(org.openxmlformats.schemas.spreadsheetml.x2006.main.CTBorderPr)

Example 28 with CTBorder

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();
}
Also used : CTPPr(org.openxmlformats.schemas.wordprocessingml.x2006.main.CTPPr) CTBorder(org.openxmlformats.schemas.wordprocessingml.x2006.main.CTBorder) CTPBdr(org.openxmlformats.schemas.wordprocessingml.x2006.main.CTPBdr) CTP(org.openxmlformats.schemas.wordprocessingml.x2006.main.CTP) Test(org.junit.Test)

Example 29 with CTBorder

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);
}
Also used : CTTblBorders(org.openxmlformats.schemas.wordprocessingml.x2006.main.CTTblBorders) CTBorder(org.openxmlformats.schemas.wordprocessingml.x2006.main.CTBorder) CTTblPr(org.openxmlformats.schemas.wordprocessingml.x2006.main.CTTblPr)

Example 30 with CTBorder

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;
}
Also used : CTTblBorders(org.openxmlformats.schemas.wordprocessingml.x2006.main.CTTblBorders) CTBorder(org.openxmlformats.schemas.wordprocessingml.x2006.main.CTBorder) CTTblPr(org.openxmlformats.schemas.wordprocessingml.x2006.main.CTTblPr)

Aggregations

CTBorder (org.openxmlformats.schemas.spreadsheetml.x2006.main.CTBorder)25 CTBorder (org.openxmlformats.schemas.wordprocessingml.x2006.main.CTBorder)11 Test (org.junit.Test)10 CTTblBorders (org.openxmlformats.schemas.wordprocessingml.x2006.main.CTTblBorders)10 CTTblPr (org.openxmlformats.schemas.wordprocessingml.x2006.main.CTTblPr)10 XSSFCellBorder (org.apache.poi.xssf.usermodel.extensions.XSSFCellBorder)9 CTBorderPr (org.openxmlformats.schemas.spreadsheetml.x2006.main.CTBorderPr)9 STBorderStyle (org.openxmlformats.schemas.spreadsheetml.x2006.main.STBorderStyle)4 CTString (org.openxmlformats.schemas.wordprocessingml.x2006.main.CTString)2 POIXMLException (org.apache.poi.POIXMLException)1 XmlException (org.apache.xmlbeans.XmlException)1 CTFill (org.openxmlformats.schemas.spreadsheetml.x2006.main.CTFill)1 CTFont (org.openxmlformats.schemas.spreadsheetml.x2006.main.CTFont)1 CTStylesheet (org.openxmlformats.schemas.spreadsheetml.x2006.main.CTStylesheet)1 CTP (org.openxmlformats.schemas.wordprocessingml.x2006.main.CTP)1 CTPBdr (org.openxmlformats.schemas.wordprocessingml.x2006.main.CTPBdr)1 CTPPr (org.openxmlformats.schemas.wordprocessingml.x2006.main.CTPPr)1