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; } }
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; } }
PropertyBuilder fontSizeBuilder = CSSName.getPropertyBuilder(CSSName.FONT_SIZE); List l = fontSizeBuilder.buildDeclarations( CSSName.FONT_SIZE, Collections.singletonList(value), origin, important); value = (PropertyValue)i.next(); if (value.getOperator() == Token.TK_VIRGULE) { PropertyBuilder lineHeightBuilder = CSSName.getPropertyBuilder(CSSName.LINE_HEIGHT); l = lineHeightBuilder.buildDeclarations( CSSName.LINE_HEIGHT, Collections.singletonList(value), origin, important); families.add(i.next()); PropertyBuilder fontFamilyBuilder = CSSName.getPropertyBuilder(CSSName.FONT_FAMILY); l = fontFamilyBuilder.buildDeclarations( CSSName.FONT_FAMILY, families, origin, important);
PropertyBuilder fontSizeBuilder = CSSName.getPropertyBuilder(CSSName.FONT_SIZE); List l = fontSizeBuilder.buildDeclarations( CSSName.FONT_SIZE, Collections.singletonList(value), origin, important); value = (PropertyValue)i.next(); if (value.getOperator() == Token.TK_VIRGULE) { PropertyBuilder lineHeightBuilder = CSSName.getPropertyBuilder(CSSName.LINE_HEIGHT); l = lineHeightBuilder.buildDeclarations( CSSName.LINE_HEIGHT, Collections.singletonList(value), origin, important); families.add(i.next()); PropertyBuilder fontFamilyBuilder = CSSName.getPropertyBuilder(CSSName.FONT_FAMILY); l = fontFamilyBuilder.buildDeclarations( CSSName.FONT_FAMILY, families, origin, important);
private boolean checkCSSName(CSSName cssName, String propertyName) { if (cssName == null) { _errorHandler.error( _URI, propertyName + " is an unrecognized CSS property at line " + getCurrentLine() + ". Ignoring declaration."); return false; } if (! CSSName.isImplemented(cssName)) { _errorHandler.error( _URI, propertyName + " is not implemented at line " + getCurrentLine() + ". Ignoring declaration."); return false; } PropertyBuilder builder = CSSName.getPropertyBuilder(cssName); if (builder == null) { _errorHandler.error( _URI, "(bug) No property builder defined for " + propertyName + " at line " + getCurrentLine() + ". Ignoring declaration."); return false; } return true; }
private boolean checkCSSName(CSSName cssName, String propertyName) { if (cssName == null) { _errorHandler.error( _URI, propertyName + " is an unrecognized CSS property at line " + getCurrentLine() + ". Ignoring declaration."); return false; } if (! CSSName.isImplemented(cssName)) { _errorHandler.error( _URI, propertyName + " is not implemented at line " + getCurrentLine() + ". Ignoring declaration."); return false; } PropertyBuilder builder = CSSName.getPropertyBuilder(cssName); if (builder == null) { _errorHandler.error( _URI, "(bug) No property builder defined for " + propertyName + " at line " + getCurrentLine() + ". Ignoring declaration."); return false; } return true; }
PropertyBuilder builder = CSSName.getPropertyBuilder(CSSName.BACKGROUND_POSITION); backgroundPosition = (PropertyDeclaration)builder.buildDeclarations( CSSName.BACKGROUND_POSITION, v, origin, important).get(0);
PropertyBuilder builder = CSSName.getPropertyBuilder(CSSName.BACKGROUND_POSITION); backgroundPosition = (PropertyDeclaration)builder.buildDeclarations( CSSName.BACKGROUND_POSITION, v, origin, important).get(0);
PropertyBuilder builder = CSSName.getPropertyBuilder(cssName); ruleset.addAllProperties(builder.buildDeclarations( cssName, values, ruleset.getOrigin(), important, !inFontFace));
PropertyBuilder builder = CSSName.getPropertyBuilder(cssName); ruleset.addAllProperties(builder.buildDeclarations( cssName, values, ruleset.getOrigin(), important, !inFontFace));