Search in sources :

Example 1 with CTTablePartStyle

use of org.openxmlformats.schemas.drawingml.x2006.main.CTTablePartStyle in project poi by apache.

the class XSLFTableCell method getFillPaint.

@SuppressWarnings("resource")
@Override
public PaintStyle getFillPaint() {
    XSLFSheet sheet = getSheet();
    XSLFTheme theme = sheet.getTheme();
    final boolean hasPlaceholder = getPlaceholder() != null;
    XmlObject props = getCellProperties(false);
    XSLFFillProperties fp = XSLFPropertiesDelegate.getFillDelegate(props);
    if (fp != null) {
        PaintStyle paint = selectPaint(fp, null, sheet.getPackagePart(), theme, hasPlaceholder);
        if (paint != null) {
            return paint;
        }
    }
    CTTablePartStyle tps = getTablePartStyle(null);
    if (tps == null || !tps.isSetTcStyle()) {
        tps = getTablePartStyle(TablePartStyle.wholeTbl);
        if (tps == null || !tps.isSetTcStyle()) {
            return null;
        }
    }
    XMLSlideShow slideShow = sheet.getSlideShow();
    CTTableStyleCellStyle tcStyle = tps.getTcStyle();
    if (tcStyle.isSetFill()) {
        props = tcStyle.getFill();
    } else if (tcStyle.isSetFillRef()) {
        props = tcStyle.getFillRef();
    } else {
        return null;
    }
    fp = XSLFPropertiesDelegate.getFillDelegate(props);
    if (fp != null) {
        PaintStyle paint = XSLFShape.selectPaint(fp, null, slideShow.getPackagePart(), theme, hasPlaceholder);
        if (paint != null) {
            return paint;
        }
    }
    return null;
}
Also used : CTTableStyleCellStyle(org.openxmlformats.schemas.drawingml.x2006.main.CTTableStyleCellStyle) CTTablePartStyle(org.openxmlformats.schemas.drawingml.x2006.main.CTTablePartStyle) PaintStyle(org.apache.poi.sl.usermodel.PaintStyle) XmlObject(org.apache.xmlbeans.XmlObject) XSLFFillProperties(org.apache.poi.xslf.usermodel.XSLFPropertiesDelegate.XSLFFillProperties)

Example 2 with CTTablePartStyle

use of org.openxmlformats.schemas.drawingml.x2006.main.CTTablePartStyle in project poi by apache.

the class XSLFTableCell method getTablePartStyle.

/**
     * Retrieves the part style depending on the location of this cell
     *
     * @param tablePartStyle the part to be returned, usually this is null
     *  and only set when used as a helper method
     * @return the table part style
     */
private CTTablePartStyle getTablePartStyle(TablePartStyle tablePartStyle) {
    CTTable ct = table.getCTTable();
    if (!ct.isSetTblPr()) {
        return null;
    }
    CTTableProperties pr = ct.getTblPr();
    boolean bandRow = (pr.isSetBandRow() && pr.getBandRow());
    boolean firstRow = (pr.isSetFirstRow() && pr.getFirstRow());
    boolean lastRow = (pr.isSetLastRow() && pr.getLastRow());
    boolean bandCol = (pr.isSetBandCol() && pr.getBandCol());
    boolean firstCol = (pr.isSetFirstCol() && pr.getFirstCol());
    boolean lastCol = (pr.isSetLastCol() && pr.getLastCol());
    TablePartStyle tps;
    if (tablePartStyle != null) {
        tps = tablePartStyle;
    } else if (row == 0 && firstRow) {
        tps = TablePartStyle.firstRow;
    } else if (row == table.getNumberOfRows() - 1 && lastRow) {
        tps = TablePartStyle.lastRow;
    } else if (col == 0 && firstCol) {
        tps = TablePartStyle.firstCol;
    } else if (col == table.getNumberOfColumns() - 1 && lastCol) {
        tps = TablePartStyle.lastCol;
    } else {
        tps = TablePartStyle.wholeTbl;
        int br = row + (firstRow ? 1 : 0);
        int bc = col + (firstCol ? 1 : 0);
        if (bandRow && (br & 1) == 0) {
            tps = TablePartStyle.band1H;
        } else if (bandCol && (bc & 1) == 0) {
            tps = TablePartStyle.band1V;
        }
    }
    XSLFTableStyle tabStyle = table.getTableStyle();
    if (tabStyle == null) {
        return null;
    }
    CTTablePartStyle part = tabStyle.getTablePartStyle(tps);
    return (part == null) ? tabStyle.getTablePartStyle(TablePartStyle.wholeTbl) : part;
}
Also used : CTTablePartStyle(org.openxmlformats.schemas.drawingml.x2006.main.CTTablePartStyle) TablePartStyle(org.apache.poi.xslf.usermodel.XSLFTableStyle.TablePartStyle) CTTablePartStyle(org.openxmlformats.schemas.drawingml.x2006.main.CTTablePartStyle) CTTable(org.openxmlformats.schemas.drawingml.x2006.main.CTTable) CTTableProperties(org.openxmlformats.schemas.drawingml.x2006.main.CTTableProperties) DrawPaint(org.apache.poi.sl.draw.DrawPaint) SolidPaint(org.apache.poi.sl.usermodel.PaintStyle.SolidPaint)

Aggregations

CTTablePartStyle (org.openxmlformats.schemas.drawingml.x2006.main.CTTablePartStyle)2 DrawPaint (org.apache.poi.sl.draw.DrawPaint)1 PaintStyle (org.apache.poi.sl.usermodel.PaintStyle)1 SolidPaint (org.apache.poi.sl.usermodel.PaintStyle.SolidPaint)1 XSLFFillProperties (org.apache.poi.xslf.usermodel.XSLFPropertiesDelegate.XSLFFillProperties)1 TablePartStyle (org.apache.poi.xslf.usermodel.XSLFTableStyle.TablePartStyle)1 XmlObject (org.apache.xmlbeans.XmlObject)1 CTTable (org.openxmlformats.schemas.drawingml.x2006.main.CTTable)1 CTTableProperties (org.openxmlformats.schemas.drawingml.x2006.main.CTTableProperties)1 CTTableStyleCellStyle (org.openxmlformats.schemas.drawingml.x2006.main.CTTableStyleCellStyle)1