Search in sources :

Example 1 with CTVerticalAlignFontProperty

use of org.openxmlformats.schemas.spreadsheetml.x2006.main.CTVerticalAlignFontProperty in project poi by apache.

the class TestXSSFFont method testTypeOffset.

@Test
public void testTypeOffset() {
    CTFont ctFont = CTFont.Factory.newInstance();
    CTVerticalAlignFontProperty valign = ctFont.addNewVertAlign();
    valign.setVal(STVerticalAlignRun.BASELINE);
    ctFont.setVertAlignArray(0, valign);
    XSSFFont font = new XSSFFont(ctFont);
    assertEquals(Font.SS_NONE, font.getTypeOffset());
    font.setTypeOffset(XSSFFont.SS_SUPER);
    assertEquals(STVerticalAlignRun.SUPERSCRIPT, ctFont.getVertAlignArray(0).getVal());
}
Also used : CTVerticalAlignFontProperty(org.openxmlformats.schemas.spreadsheetml.x2006.main.CTVerticalAlignFontProperty) CTFont(org.openxmlformats.schemas.spreadsheetml.x2006.main.CTFont) Test(org.junit.Test)

Example 2 with CTVerticalAlignFontProperty

use of org.openxmlformats.schemas.spreadsheetml.x2006.main.CTVerticalAlignFontProperty in project poi by apache.

the class XSSFFont method getTypeOffset.

/**
     * get normal,super or subscript.
     *
     * @return short - offset type to use (none,super,sub)
     * @see Font#SS_NONE
     * @see Font#SS_SUPER
     * @see Font#SS_SUB
     */
public short getTypeOffset() {
    CTVerticalAlignFontProperty vAlign = _ctFont.sizeOfVertAlignArray() == 0 ? null : _ctFont.getVertAlignArray(0);
    if (vAlign == null) {
        return Font.SS_NONE;
    }
    int val = vAlign.getVal().intValue();
    switch(val) {
        case STVerticalAlignRun.INT_BASELINE:
            return Font.SS_NONE;
        case STVerticalAlignRun.INT_SUBSCRIPT:
            return Font.SS_SUB;
        case STVerticalAlignRun.INT_SUPERSCRIPT:
            return Font.SS_SUPER;
        default:
            throw new POIXMLException("Wrong offset value " + val);
    }
}
Also used : CTVerticalAlignFontProperty(org.openxmlformats.schemas.spreadsheetml.x2006.main.CTVerticalAlignFontProperty) POIXMLException(org.apache.poi.POIXMLException)

Aggregations

CTVerticalAlignFontProperty (org.openxmlformats.schemas.spreadsheetml.x2006.main.CTVerticalAlignFontProperty)2 POIXMLException (org.apache.poi.POIXMLException)1 Test (org.junit.Test)1 CTFont (org.openxmlformats.schemas.spreadsheetml.x2006.main.CTFont)1