private static void insertPageStyle(StringBuilder builder, RulePage pageRule, boolean topLevel) { builder.append("@page"); String pseudo = pageRule.getPseudo(); if (pseudo != null && !"".equals(pseudo)) builder.append(":").append(pseudo); builder.append(" { "); for (Declaration decl : filter(pageRule, Declaration.class)) insertDeclaration(builder, decl); for (RuleMargin margin : filter(pageRule, RuleMargin.class)) insertMarginStyle(builder, margin); builder.append("} "); }
for (RulePage r : filter(stylesheet, RulePage.class)) { String name = firstNonNull(r.getName(), "auto"); String pseudo = firstNonNull(r.getPseudo(), ""); Map<String,RulePage> pageRule = style.pageRules.get(name); if (pageRule == null) {
static Style of(RulePage page) { // assumed to be anonymous page Style style = new Style(); for (Rule<?> r : page) if (r instanceof Declaration) style.add((Declaration)r); else if (r instanceof RuleMargin) style.add("@" + ((RuleMargin)r).getMarginArea(), new Style().add((List<Declaration>)r)); else throw new RuntimeException("coding error"); String pseudo = page.getPseudo(); return pseudo == null ? style : new Style().add("&:" + pseudo, style); }