PageStyle implements AddableToOdsElements, ElementWithEmbeddedStyles, Hidable { public static PageStyleBuilder builder(final String name) { return new PageStyleBuilder(name); } PageStyle(final boolean hidden, final MasterPageStyle masterPageStyle,
              final PageLayoutStyle pageLayoutStyle); static PageStyleBuilder builder(final String name); @Override boolean isHidden(); MasterPageStyle getMasterPageStyle(); PageLayoutStyle getPageLayoutStyle(); String getMasterName(); @Override void addEmbeddedStyles(final StylesContainer stylesContainer); @Override void addToElements(final OdsElements odsElements); void appendXMLToAutomaticStyle(final XMLUtil util, final Appendable appendable); void appendXMLToMasterStyle(final XMLUtil util, final Appendable appendable); static final String DEFAULT_MASTER_PAGE_NAME; static final PaperFormat DEFAULT_FORMAT; static final PagePrintOrientation DEFAULT_PRINT_ORIENTATION; static final PageWritingMode DEFAULT_WRITING_MODE; static final PageStyle DEFAULT_MASTER_PAGE_STYLE; static final PageStyle DEFAULT_PAGE_STYLE; }
@Test public final void testAlmostEmptyToAutomaticStyle() throws IOException { final PageStyle pageStyle = PageStyle.builder("test").build(); this.assertLayoutXMLEquals("<style:page-layout style:name=\"test\">" + "<style:page-layout-properties fo:page-width=\"21cm\" " + "fo:page-height=\"29.7cm\" style:num-format=\"1\" " + "style:writing-mode=\"lr-tb\" " + "style:print-orientation=\"portrait\" fo:margin=\"1.5cm\"/>" + "<style:header-style>" + "<style:header-footer-properties " + "fo:min-height=\"0cm\" " + "fo:margin=\"0cm\"/>" + "</style:header-style>" + "<style:footer-style>" + "<style:header-footer-properties " + "fo:min-height=\"0cm\" " + "fo:margin=\"0cm\"/>" + "</style:footer-style>" + "</style:page-layout>", pageStyle); }
@Test public final void testAlmostEmptyToMasterStyle() throws IOException { final PageStyle pageStyle = PageStyle.builder("test").build(); this.assertMasterXMLEquals(PageStyleTest.MASTER, pageStyle); }
@Test public final void testBackground() throws IOException { final PageStyle pageStyle = PageStyle.builder("test").backgroundColor(SimpleColor.BLANCHEDALMOND).build(); this.assertMasterXMLEquals(PageStyleTest.MASTER, pageStyle); this.assertLayoutXMLEquals("<style:page-layout style:name=\"test\">" + "<style:page-layout-properties fo:page-width=\"21cm\" " + "fo:page-height=\"29.7cm\" style:num-format=\"1\" style:writing-mode=\"lr-tb\" " + "style:print-orientation=\"portrait\" fo:background-color=\"#ffebcd\" " + "fo:margin=\"1.5cm\"/>" + "<style:header-style>" + "<style:header-footer-properties fo:min-height=\"0cm\" " + "fo:margin=\"0cm\"/></style:header-style><style:footer-style><style:header-footer" + "-properties " + "" + "" + "" + "" + "" + "" + "" + "" + "" + "fo:min-height=\"0cm\" fo:margin=\"0cm\"/>" + "</style:footer-style>" + "</style:page-layout>", pageStyle); }
@Test(expected = IllegalStateException.class) public final void testEmpty() { PageStyle.builder(null).build(); }
@Test public final void testHeightAndWidth() throws IOException { final PageStyle pageStyle = PageStyle.builder("test").pageHeight(SimpleLength.cm(20.0)) .pageWidth(SimpleLength.cm(10.0)).build(); this.assertLayoutXMLEquals("<style:page-layout style:name=\"test\">" + "<style:page-layout-properties fo:page-width=\"10cm\" " + "fo:page-height=\"20cm\" style:num-format=\"1\" style:writing-mode=\"lr-tb\" " + "style:print-orientation=\"portrait\" fo:margin=\"1.5cm\"/>" + "<style:header-style>" + "<style:header-footer-properties fo:min-height=\"0cm\" fo:margin=\"0cm\"/>" + "</style:header-style>" + "<style:footer-style>" + "<style:header-footer-properties " + "fo:min-height=\"0cm\" fo:margin=\"0cm\"/>" + "</style:footer-style>" + "</style:page-layout>", pageStyle); }
@Test public final void testNullFooterHeader() throws IOException { final PageStyle pageStyle = PageStyle.builder("test").header(null).footer(null).build(); this.assertLayoutXMLEquals("<style:page-layout style:name=\"test\">" + "<style:page-layout-properties fo:page-width=\"21cm\" " + "fo:page-height=\"29.7cm\" style:num-format=\"1\" " + "style:writing-mode=\"lr-tb\" " + "style:print-orientation=\"portrait\" fo:margin=\"1.5cm\"/>" + "<style:header-style/>" + "<style:footer-style/>" + "</style:page-layout>", pageStyle); }
@Test public final void testPaperFormat() throws IOException { final PageStyle pageStyle = PageStyle.builder("test").paperFormat(PaperFormat.A3).build(); this.assertMasterXMLEquals(PageStyleTest.MASTER, pageStyle); this.assertLayoutXMLEquals("<style:page-layout style:name=\"test\">" + "<style:page-layout-properties fo:page-width=\"29.7cm\" " + "fo:page-height=\"42cm\" style:num-format=\"1\" style:writing-mode=\"lr-tb\" " + "style:print-orientation=\"portrait\" fo:margin=\"1.5cm\"/>" + "<style:header-style>" + "<style:header-footer-properties fo:min-height=\"0cm\" fo:margin=\"0cm\"/>" + "</style:header-style>" + "<style:footer-style>" + "<style:header-footer-properties " + "fo:min-height=\"0cm\" fo:margin=\"0cm\"/>" + "</style:footer-style>" + "</style:page-layout>", pageStyle); }
@Test public final void testPrintOrientationH() throws IOException { final PageStyle pageStyle = PageStyle.builder("test").printOrientationHorizontal() .writingMode(PageWritingMode.PAGE).build(); this.assertMasterXMLEquals(PageStyleTest.MASTER, pageStyle); this.assertLayoutXMLEquals("<style:page-layout style:name=\"test\">" + "<style:page-layout-properties fo:page-width=\"29.7cm\" " + "fo:page-height=\"21cm\" style:num-format=\"1\" style:writing-mode=\"page\" " + "style:print-orientation=\"landscape\" fo:margin=\"1.5cm\"/>" + "<style:header-style>" + "<style:header-footer-properties fo:min-height=\"0cm\" fo:margin=\"0cm\"/>" + "</style:header-style>" + "<style:footer-style>" + "<style:header-footer-properties " + "fo:min-height=\"0cm\" fo:margin=\"0cm\"/>" + "</style:footer-style>" + "</style:page-layout>", pageStyle); }
@Test public final void testPrintOrientationV() throws IOException { final PageStyle pageStyle = PageStyle.builder("test").printOrientationVertical() .writingMode(PageWritingMode.PAGE).build(); this.assertMasterXMLEquals(PageStyleTest.MASTER, pageStyle); this.assertLayoutXMLEquals("<style:page-layout style:name=\"test\">" + "<style:page-layout-properties fo:page-width=\"21cm\" " + "fo:page-height=\"29.7cm\" style:num-format=\"1\" style:writing-mode=\"page\" " + "style:print-orientation=\"portrait\" fo:margin=\"1.5cm\"/>" + "<style:header-style>" + "<style:header-footer-properties fo:min-height=\"0cm\" fo:margin=\"0cm\"/>" + "</style:header-style>" + "<style:footer-style>" + "<style:header-footer-properties " + "fo:min-height=\"0cm\" fo:margin=\"0cm\"/>" + "</style:footer-style>" + "</style:page-layout>", pageStyle); }
@Test public final void testPrintMargins() throws IOException { final PageStyle pageStyle = PageStyle.builder("test").marginBottom(SimpleLength.pt(1)) .marginLeft(SimpleLength.pt(2)).marginRight(SimpleLength.pt(3)) .marginTop(SimpleLength.pt(4)).build(); this.assertMasterXMLEquals(PageStyleTest.MASTER, pageStyle); this.assertLayoutXMLEquals("<style:page-layout style:name=\"test\"><style:page-layout" + "-properties fo:page-width=\"21cm\" fo:page-height=\"29.7cm\" " + "style:num-format=\"1\" style:writing-mode=\"lr-tb\" " + "style:print-orientation=\"portrait\" fo:margin=\"1.5cm\" fo:margin-top=\"4pt\" " + "fo:margin-right=\"3pt\" fo:margin-bottom=\"1pt\" " + "fo:margin-left=\"2pt\"/><style:header-style><style:header-footer-properties " + "fo:min-height=\"0cm\" fo:margin=\"0cm\"/></style:header-style><style:footer" + "-style><style:header-footer-properties fo:min-height=\"0cm\" " + "fo:margin=\"0cm\"/></style:footer-style></style:page-layout>", pageStyle); }
@Test(expected = IllegalArgumentException.class) public final void testWritingException() { PageStyle.builder("test").writingMode(null); }
@Test public final void testWritingMode() throws IOException { final PageStyle pageStyle = PageStyle.builder("test").writingMode(PageWritingMode.PAGE).build(); this.assertLayoutXMLEquals("<style:page-layout style:name=\"test\">" + "<style:page-layout-properties fo:page-width=\"21cm\" " + "fo:page-height=\"29.7cm\" style:num-format=\"1\" style:writing-mode=\"page\" " + "style:print-orientation=\"portrait\" fo:margin=\"1.5cm\"/>" + "<style:header-style>" + "<style:header-footer-properties fo:min-height=\"0cm\" fo:margin=\"0cm\"/>" + "</style:header-style>" + "<style:footer-style>" + "<style:header-footer-properties " + "fo:min-height=\"0cm\" fo:margin=\"0cm\"/>" + "</style:footer-style>" + "</style:page-layout>", pageStyle); }