TextStyle implements FontFaceContainerStyle { public static TextStyleBuilder builder(final String styleName) { return new TextStyleBuilder(styleName); } TextStyle(final String name, final boolean hidden, final TextProperties textProperties); static TextStyleBuilder builder(final String styleName); @Override void appendXMLContent(final XMLUtil util, final Appendable appendable); @Override FontFace getFontFace(); @Override ObjectStyleFamily getFamily(); @Override String getName(); boolean isNotEmpty(); @Override String getKey(); @Override boolean isHidden(); @Override void addToElements(final OdsElements odsElements); static final TextStyle DEFAULT_TEXT_STYLE; }
@Test public void testDefaultXML() throws IOException { final TextStyle style = TextStyle.builder("ts").build(); TestHelper.assertXMLEquals("<style:style style:name=\"ts\" " + "style:family=\"text\"><style:text-properties/></style:style>", style); }
@Test public final void testBadSize() throws IOException { final TextStyle style = TextStyle.builder("ts").fontSize(SimpleLength.cm(10)).build(); TestHelper.assertXMLEquals( "<style:style style:name=\"ts\" style:family=\"text\">" + "<style:text-properties fo:font-size=\"10cm\" style:font-size-asian=\"10cm\" style:font-size-complex=\"10cm\"/>" + "</style:style>", style); }
@Test(expected = IllegalArgumentException.class) public final void testVisibleOnly() { TextStyle.builder("ts").fontSizePercentage(110).build(); }
@Test public final void testColorNameSize() throws IOException { final TextStyle style = TextStyle.builder("ts").fontColor(SimpleColor.ALICEBLUE) .fontName(LOFonts.LIBERATION_SERIF).fontSizePercentage(10.8).visible().build(); TestHelper.assertXMLEquals( "<style:style style:name=\"ts\" style:family=\"text\">" + "<style:text-properties fo:color=\"#f0f8ff\" " + "style:font-name=\"Liberation Serif\" fo:font-size=\"10.8%\" " + "style:font-size-asian=\"10.8%\" style:font-size-complex=\"10.8%\"/>" + "</style:style>", style); }
@Test public final void testItalicBold() throws IOException { final TextStyle prop = TextStyle.builder("ts").fontStyleItalic().fontWeightBold().build(); TestHelper.assertXMLEquals( "<style:style style:name=\"ts\" style:family=\"text\">" + "<style:text-properties fo:font-weight=\"bold\" " + "style:font-weight-asian=\"bold\" style:font-weight-complex=\"bold\" " + "fo:font-style=\"italic\" style:font-style-asian=\"italic\" " + "style:font-style-complex=\"italic\"/>" + "</style:style>", prop); }