TableCellStyle implements FontFaceContainerStyle { public static TableCellStyleBuilder builder(final String name) { return new TableCellStyleBuilder(name); } TableCellStyle(final String name, final boolean hidden, final DataStyle dataStyle,
                   final Color backgroundColor, final TextProperties textProperties,
                   final CellAlign textAlign, final VerticalAlign verticalAlign, final boolean wrap,
                   final TableCellStyle parentCellStyle, final Borders borders,
                   final Margins margins, final Angle textRotating); static TableCellStyleBuilder builder(final String name); @Override void addToElements(final OdsElements odsElements); @Override void appendXMLContent(final XMLUtil util, final Appendable appendable); DataStyle getDataStyle(); @Override ObjectStyleFamily getFamily(); @Override String getKey(); @Override String getName(); String getRealName(); boolean hasParent(); @Override boolean isHidden(); TableCellStyle getParentCellStyle(); @Override FontFace getFontFace(); boolean hasTextAlign(); TableCellStyleBuilder toBuilder(final String newName); static final TableCellStyle DEFAULT_CELL_STYLE; }
@Test public final void testAllBorders() throws IOException { final TableCellStyle tcs = TableCellStyle.builder("test") .borderAll(SimpleLength.pt(1.0), SimpleColor.AQUA, BorderStyle.DOUBLE).build(); TestHelper.assertXMLEquals("<style:style style:name=\"test\" style:family=\"table-cell\" " + "style:parent-style-name=\"Default\">" + "<style:table-cell-properties fo:border=\"1pt double #00ffff\"/>" + "</style:style>", tcs); }
@Test public final void testAllMargins() throws IOException { final TableCellStyle tcs = TableCellStyle.builder("tcs").allMargins(SimpleLength.pt(10.0)).build(); TestHelper.assertXMLEquals("<style:style style:name=\"tcs\" style:family=\"table-cell\" " + "style:parent-style-name=\"Default\">" + "<style:paragraph-properties fo:margin=\"10pt\"/>" + "</style:style>", tcs); }
@Test public final void testBorders() throws IOException { final TableCellStyle tcs = TableCellStyle.builder("test") .borderTop(SimpleLength.pt(1.0), SimpleColor.AQUA, BorderStyle.DOUBLE) .borderRight(SimpleLength.pt(2.0), SimpleColor.BEIGE, BorderStyle.SOLID) .borderBottom(SimpleLength.pt(3.0), SimpleColor.CADETBLUE, BorderStyle.DOUBLE) .borderLeft(SimpleLength.pt(4.0), SimpleColor.DARKBLUE, BorderStyle.DOUBLE).build(); TestHelper.assertXMLEquals("<style:style style:name=\"test\" style:family=\"table-cell\" " + "style:parent-style-name=\"Default\">" + "<style:table-cell-properties fo:border-bottom=\"3pt double #5f9ea0\" " + "fo:border-left=\"4pt " + "double #00008b\" fo:border-right=\"2pt solid #f5f5dc\" " + "fo:border-top=\"1pt double " + "#00ffff\"/>" + "</style:style>", tcs); }
@Test public final void testSimpleBorders() throws IOException { final BorderAttribute borderAttribute = new BorderAttribute(SimpleLength.pt(1.0), SimpleColor.AQUA, BorderStyle.DOUBLE); final TableCellStyle tcs = TableCellStyle.builder("test").borderTop(borderAttribute) .borderBottom(borderAttribute).borderLeft(borderAttribute) .borderRight(borderAttribute).build(); TestHelper.assertXMLEquals("<style:style style:name=\"test\" style:family=\"table-cell\" " + "style:parent-style-name=\"Default\"><style:table-cell-properties fo:border=\"1pt" + " double #00ffff\"/></style:style>", tcs); }
@Test public final void testSimpleBordersAll() throws IOException { final BorderAttribute borderAttributeTop = new BorderAttribute(SimpleLength.pt(1.0), SimpleColor.AQUA, BorderStyle.DOUBLE); final BorderAttribute borderAttribute = new BorderAttribute(SimpleLength.pt(2.0), SimpleColor.BLACK, BorderStyle.DOUBLE); final TableCellStyle tcs = TableCellStyle.builder("test").borderTop(borderAttributeTop) .borderAll(borderAttribute).build(); TestHelper.assertXMLEquals("<style:style style:name=\"test\" style:family=\"table-cell\" " + "style:parent-style-name=\"Default\"><style:table-cell-properties fo:border=\"2pt" + " double #000000\" fo:border-top=\"1pt double #00ffff\"/></style:style>", tcs); }
@Test public final void testMargins() throws IOException { final TableCellStyle tcs = TableCellStyle.builder("tcs").marginTop(SimpleLength.pt(10.0)) .marginRight(SimpleLength.pt(11.0)).marginBottom(SimpleLength.pt(12.0)) .marginLeft(SimpleLength.pt(13.0)).build(); TestHelper.assertXMLEquals("<style:style style:name=\"tcs\" style:family=\"table-cell\" " + "style:parent-style-name=\"Default\">" + "<style:paragraph-properties fo:margin-bottom=\"12pt\" " + "fo:margin-left=\"13pt\" " + "fo:margin-right=\"11pt\" fo:margin-top=\"10pt\"/>" + "</style:style>", tcs); }
@Test(expected = IllegalArgumentException.class) public final void testNullName() { TableCellStyle.builder(null); }
@Test public final void testGetters() { StyleTestHelper.testGetters(TableCellStyle.builder("test")); }
@Test public final void testFontName() throws IOException { final TableCellStyle symbolStyle = TableCellStyle.builder("symbol-cell").fontName(LOFonts.OPENSYMBOL).build(); TestHelper.assertXMLEquals("<style:style style:name=\"symbol-cell\" " + "style:family=\"table-cell\" style:parent-style-name=\"Default\"><style:text" + "-properties style:font-name=\"OpenSymbol\"/></style:style>", symbolStyle); }
@Test public final void testFontNormal() throws IOException { final TableCellStyle s = TableCellStyle.builder("test").fontStyleNormal().fontWeightNormal().build(); TestHelper.assertXMLEquals("<style:style style:name=\"test\" style:family=\"table-cell\" " + "style:parent-style-name=\"Default\"><style:text-properties " + "fo:font-weight=\"normal\" style:font-weight-asian=\"normal\" " + "style:font-weight-complex=\"normal\" fo:font-style=\"normal\" " + "style:font-style-asian=\"normal\" " + "style:font-style-complex=\"normal\"/></style:style>", s); }
@Test public final void testFontUnderline() throws IOException { final TableCellStyle s = TableCellStyle.builder("test").fontUnderlineStyle(TextProperties.Underline.DASH) .fontUnderlineColor(SimpleColor.RED).build(); TestHelper.assertXMLEquals("<style:style style:name=\"test\" style:family=\"table-cell\" " + "style:parent-style-name=\"Default\"><style:text-properties " + "style:text-underline-style=\"dash\" style:text-underline-width=\"auto\" " + "style:text-underline-color=\"#ff0000\"/></style:style>", s); }
@Test public final void testFontSizePercentage() throws IOException { final TableCellStyle s = TableCellStyle.builder("test").fontSizePercentage(125.9).build(); TestHelper.assertXMLEquals("<style:style style:name=\"test\" style:family=\"table-cell\" " + "style:parent-style-name=\"Default\"><style:text-properties " + "fo:font-size=\"125.9%\" style:font-size-asian=\"125.9%\" " + "style:font-size-complex=\"125.9%\"/></style:style>", s); }
@Test public final void testFontColor() throws IOException { final TableCellStyle s = TableCellStyle.builder("test").fontColor(SimpleColor.GRAY).build(); TestHelper.assertXMLEquals("<style:style style:name=\"test\" style:family=\"table-cell\" " + "style:parent-style-name=\"Default\"><style:text-properties " + "fo:color=\"#808080\"/></style:style>", s); }
@Test public final void testFontSize() throws IOException { final TableCellStyle s = TableCellStyle.builder("test").fontSize(SimpleLength.pt(12.5)).build(); TestHelper.assertXMLEquals("<style:style style:name=\"test\" style:family=\"table-cell\" " + "style:parent-style-name=\"Default\"><style:text-properties " + "fo:font-size=\"12.5pt\" style:font-size-asian=\"12.5pt\" " + "style:font-size-complex=\"12.5pt\"/></style:style>", s); }