public PropertyValue parsePropertyValue(CSSName cssName, int origin, String expr) { _URI = cssName + " property value"; try { reset(new StringReader(expr)); List values = expr( cssName == CSSName.FONT_FAMILY || cssName == CSSName.FONT_SHORTHAND || cssName == CSSName.FS_PDF_FONT_ENCODING); PropertyBuilder builder = CSSName.getPropertyBuilder(cssName); List props; try { props = builder.buildDeclarations(cssName, values, origin, false); } catch (CSSParseException e) { e.setLine(getCurrentLine()); throw e; } if (props.size() != 1) { throw new CSSParseException( "Builder created " + props.size() + "properties, expected 1", getCurrentLine()); } PropertyDeclaration decl = (PropertyDeclaration)props.get(0); return (PropertyValue)decl.getValue(); } catch (IOException e) { // "Shouldn't" happen throw new RuntimeException(e.getMessage(), e); } catch (CSSParseException e) { error(e, "property value", false); return null; } }
private void margin(Stylesheet stylesheet, PageRule pageRule) throws IOException { Token t = next(); if (t != Token.TK_AT_RULE) { error(new CSSParseException(t, Token.TK_AT_RULE, getCurrentLine()), "at rule", true); recover(true, false); return; MarginBoxName marginBoxName = MarginBoxName.valueOf(name); if (marginBoxName == null) { error(new CSSParseException(name + " is not a valid margin box name", getCurrentLine()), "at rule", true); recover(true, false); return; error(e, "margin box", true); recover(false, false);
error(e, "@charset rule", true); recover(false, false); case Token.IMPORT_SYM: next(); error(new CSSParseException("@import not allowed here", getCurrentLine()), "@import rule", true); recover(false, false); case Token.NAMESPACE_SYM: next(); error(new CSSParseException("@namespace not allowed here", getCurrentLine()), "@namespace rule", true); recover(false, false); case Token.AT_RULE: next(); error(new CSSParseException( "Invalid at-rule", getCurrentLine()), "at-rule", true); recover(false, false); error(e, "stylesheet", false);
error(e, "@namespace rule", true); recover(false, false);
error(e, "ruleset", true); recover(true, false);
error(e, "@page rule", true); recover(false, false);
error(e, "@font-face rule", true); recover(false, false);
error(e, "@import rule", true); recover(false, false);
error(e, "@media rule", true); recover(false, false);