use of org.openxmlformats.schemas.spreadsheetml.x2006.main.CTFont 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());
}
use of org.openxmlformats.schemas.spreadsheetml.x2006.main.CTFont in project poi by apache.
the class TestXSSFFont method testColor.
@Test
public void testColor() {
CTFont ctFont = CTFont.Factory.newInstance();
CTColor color = ctFont.addNewColor();
color.setIndexed(XSSFFont.DEFAULT_FONT_COLOR);
ctFont.setColorArray(0, color);
XSSFFont xssfFont = new XSSFFont(ctFont);
assertEquals(IndexedColors.BLACK.getIndex(), xssfFont.getColor());
xssfFont.setColor(IndexedColors.RED.getIndex());
assertEquals(IndexedColors.RED.getIndex(), ctFont.getColorArray(0).getIndexed());
}
use of org.openxmlformats.schemas.spreadsheetml.x2006.main.CTFont in project poi by apache.
the class TestXSSFFont method testRgbColor.
@Test
public void testRgbColor() {
CTFont ctFont = CTFont.Factory.newInstance();
CTColor color = ctFont.addNewColor();
color.setRgb(Integer.toHexString(0xFFFFFF).getBytes(LocaleUtil.CHARSET_1252));
ctFont.setColorArray(0, color);
XSSFFont xssfFont = new XSSFFont(ctFont);
assertEquals(ctFont.getColorArray(0).getRgb()[0], xssfFont.getXSSFColor().getRGB()[0]);
assertEquals(ctFont.getColorArray(0).getRgb()[1], xssfFont.getXSSFColor().getRGB()[1]);
assertEquals(ctFont.getColorArray(0).getRgb()[2], xssfFont.getXSSFColor().getRGB()[2]);
assertEquals(ctFont.getColorArray(0).getRgb()[3], xssfFont.getXSSFColor().getRGB()[3]);
xssfFont.setColor((short) 23);
byte[] bytes = Integer.toHexString(0xF1F1F1).getBytes(LocaleUtil.CHARSET_1252);
color.setRgb(bytes);
XSSFColor newColor = new XSSFColor(color, null);
xssfFont.setColor(newColor);
assertEquals(ctFont.getColorArray(0).getRgb()[2], newColor.getRGB()[2]);
assertArrayEquals(bytes, xssfFont.getXSSFColor().getRGB());
assertEquals(0, xssfFont.getColor());
}
use of org.openxmlformats.schemas.spreadsheetml.x2006.main.CTFont in project poi by apache.
the class TestXSSFFont method testFontHeightInPoint.
@Test
public void testFontHeightInPoint() {
CTFont ctFont = CTFont.Factory.newInstance();
CTFontSize size = ctFont.addNewSz();
size.setVal(14);
ctFont.setSzArray(0, size);
XSSFFont xssfFont = new XSSFFont(ctFont);
assertEquals(14, xssfFont.getFontHeightInPoints());
xssfFont.setFontHeightInPoints((short) 20);
assertEquals(20.0, ctFont.getSzArray(0).getVal(), 0.0);
}
use of org.openxmlformats.schemas.spreadsheetml.x2006.main.CTFont in project poi by apache.
the class TestXSSFFont method testStrikeout.
@Test
public void testStrikeout() {
CTFont ctFont = CTFont.Factory.newInstance();
CTBooleanProperty bool = ctFont.addNewStrike();
bool.setVal(false);
ctFont.setStrikeArray(0, bool);
XSSFFont xssfFont = new XSSFFont(ctFont);
assertEquals(false, xssfFont.getStrikeout());
xssfFont.setStrikeout(true);
assertEquals(ctFont.sizeOfStrikeArray(), 1);
assertEquals(true, ctFont.getStrikeArray(0).getVal());
assertEquals(true, ctFont.getStrikeArray(0).getVal());
}
Aggregations