类org.w3c.dom.css.CSSStyleDeclaration源码实例Demo

下面列出了怎么用org.w3c.dom.css.CSSStyleDeclaration的API类实例代码及写法,或者点击链接到github查看源代码。

源代码1 项目: birt   文件: CSSEngine.java
/**
 * Parses and creates a style declaration.
 * 
 * @param value
 *            The style declaration text.
 */
public CSSStyleDeclaration parseStyleDeclaration( String value )
{
	styleDeclarationBuilder.styleDeclaration = new StyleDeclaration( this );
	try
	{
		parser.setDocumentHandler( styleDeclarationBuilder );
		parser.parseStyleDeclaration( new InputSource( new StringReader(
				value ) ) );
	}
	catch ( Exception e )
	{
		/** @todo: logout the error message */
	}
	return styleDeclarationBuilder.styleDeclaration;
}
 
源代码2 项目: birt   文件: StyleSheetLoader.java
/**
 * Gets all the name/value pairs from a CSS declaration and puts them into a
 * <code>LinkedHashMap</code>. All the name and value is of string type.
 * 
 * @param declaration
 *            the declaration of the style rule
 * @param errors
 *            the error list of the declaration
 * @return all the supported name/value pairs
 */

LinkedHashMap<String, ? extends Object> buildProperties(
		CSSStyleDeclaration declaration,
		List<StyleSheetParserException> errors )
{
	LinkedHashMap<String, String> properties = new LinkedHashMap<String, String>( );
	for ( int i = 0; i < declaration.getLength( ); i++ )
	{
		String cssName = declaration.item( i );
		String cssValue = declaration.getPropertyValue( cssName );
		if ( StringUtil.isBlank( cssName ) || StringUtil.isBlank( cssValue ) )
			continue;

		properties.put( cssName, cssValue );
	}

	return buildProperties( properties, errors );
}
 
源代码3 项目: commafeed   文件: FeedUtils.java
public static String escapeIFrameCss(String orig) {
	String rule = "";
	CSSOMParser parser = new CSSOMParser();
	try {
		List<String> rules = new ArrayList<>();
		CSSStyleDeclaration decl = parser.parseStyleDeclaration(new InputSource(new StringReader(orig)));

		for (int i = 0; i < decl.getLength(); i++) {
			String property = decl.item(i);
			String value = decl.getPropertyValue(property);
			if (StringUtils.isBlank(property) || StringUtils.isBlank(value)) {
				continue;
			}

			if (ALLOWED_IFRAME_CSS_RULES.contains(property) && StringUtils.containsNone(value, FORBIDDEN_CSS_RULE_CHARACTERS)) {
				rules.add(property + ":" + decl.getPropertyValue(property) + ";");
			}
		}
		rule = StringUtils.join(rules, "");
	} catch (Exception e) {
		log.error(e.getMessage(), e);
	}
	return rule;
}
 
源代码4 项目: commafeed   文件: FeedUtils.java
public static String escapeImgCss(String orig) {
	String rule = "";
	CSSOMParser parser = new CSSOMParser();
	try {
		List<String> rules = new ArrayList<>();
		CSSStyleDeclaration decl = parser.parseStyleDeclaration(new InputSource(new StringReader(orig)));

		for (int i = 0; i < decl.getLength(); i++) {
			String property = decl.item(i);
			String value = decl.getPropertyValue(property);
			if (StringUtils.isBlank(property) || StringUtils.isBlank(value)) {
				continue;
			}

			if (ALLOWED_IMG_CSS_RULES.contains(property) && StringUtils.containsNone(value, FORBIDDEN_CSS_RULE_CHARACTERS)) {
				rules.add(property + ":" + decl.getPropertyValue(property) + ";");
			}
		}
		rule = StringUtils.join(rules, "");
	} catch (Exception e) {
		log.error(e.getMessage(), e);
	}
	return rule;
}
 
源代码5 项目: birt   文件: Report.java
/**
 * add a style definition into the report.
 * 
 * @param style
 *            style definition.
 */
public void addStyle( String name, CSSStyleDeclaration style )
{
	assert ( style != null );
	this.styles.add( style );
	this.styleTable.put( name, style );
}
 
源代码6 项目: birt   文件: CSSPaserTest.java
private String parseStyle( String cssText )
{
	try
	{
		CSSStyleDeclaration style = engine.parseStyleDeclaration( cssText );
		return style.getCssText( );
	}
	catch ( Exception ex )
	{
	}
	return "";
}
 
源代码7 项目: bonita-studio   文件: SVGUtils.java
public static Color toSWTColor(Element element, String attributeName) {
	Document document = element.getOwnerDocument();
	ViewCSS viewCSS = (ViewCSS) document.getDocumentElement();
	CSSStyleDeclaration computedStyle = viewCSS.getComputedStyle(element, null);
	SVGPaint svgPaint = (SVGPaint) computedStyle.getPropertyCSSValue(attributeName);
	if (svgPaint.getPaintType() == SVGPaint.SVG_PAINTTYPE_RGBCOLOR) {
		RGBColor rgb = svgPaint.getRGBColor();
		float red = rgb.getRed().getFloatValue(CSSValue.CSS_PRIMITIVE_VALUE);
		float green = rgb.getGreen().getFloatValue(CSSValue.CSS_PRIMITIVE_VALUE);
		float blue = rgb.getBlue().getFloatValue(CSSValue.CSS_PRIMITIVE_VALUE);
		return new Color(Display.getCurrent(), (int) red, (int) green, (int) blue);
	}
	return null;
}
 
源代码8 项目: birt   文件: StyleRule.java
public CSSStyleDeclaration getStyle( )
{
	return this.style;
}
 
 类所在包
 类方法
 同包方法