org.w3c.dom.css.CSSValue Java Examples

The following examples show how to use org.w3c.dom.css.CSSValue. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: BirtStyle.java    From birt with Eclipse Public License 1.0 6 votes vote down vote up
@Override
protected BirtStyle clone() {
	BirtStyle result = new BirtStyle(this.cssEngine);

	result.propertyOverride = new CSSValue[ BirtStyle.NUMBER_OF_STYLES ];
			
	for(int i = 0; i < NUMBER_OF_STYLES; ++i ) {
		CSSValue value = getProperty( i );
		if( value != null ) {
			if( value instanceof DataFormatValue ) {
				value = StyleManagerUtils.cloneDataFormatValue((DataFormatValue)value);
			}
			
				result.propertyOverride[ i ] = value;
			}
	}
	
	return result;
}
 
Example #2
Source File: TableComboPropertyHandler.java    From nebula with Eclipse Public License 2.0 6 votes vote down vote up
private boolean applyCSSPropertyStyle(final Object element, final Control widget, final CSSValue value) throws Exception {
	if (value.getCssValueType() == CSSValue.CSS_PRIMITIVE_VALUE) {
		final FontData fd = CSSEngineHelper.getFontData(widget);
		boolean modified = false;
		if ("italic".equals(value.getCssText()) || "oblique".equals(value.getCssText())) {
			modified = (fd.getStyle() & SWT.ITALIC) != SWT.ITALIC;
			if (modified) {
				fd.setStyle(fd.getStyle() | SWT.ITALIC);
			}
		} else {
			modified = (fd.getStyle() & SWT.ITALIC) == SWT.ITALIC;
			if (modified) {
				fd.setStyle(fd.getStyle() | ~SWT.ITALIC);
			}
		}
		if (modified) {
			applyFont(widget, fd);
		}

	}
	return true;
}
 
Example #3
Source File: GridPropertyHandler.java    From nebula with Eclipse Public License 2.0 6 votes vote down vote up
private boolean applyCSSPropertyWeight(final Object element, final Grid grid, final CSSValue value, String target) throws Exception {
	if (value.getCssValueType() == CSSValue.CSS_PRIMITIVE_VALUE) {
		final FontData fd = CSSEngineHelper.getFontData(grid);
		boolean modified = false;
		if ("bold".equals(value.getCssText()) || "bolder".equals(value.getCssText())) {
			modified = (fd.getStyle() & SWT.BOLD) != SWT.BOLD;
			if (modified) {
				fd.setStyle(fd.getStyle() | SWT.BOLD);
			}
		} else {
			modified = (fd.getStyle() & SWT.BOLD) == SWT.BOLD;
			if (modified) {
				fd.setStyle(fd.getStyle() | ~SWT.BOLD);
			}
		}
		if (modified) {
			applyFont(grid, fd, target);
		}

	}
	return true;
}
 
Example #4
Source File: CDateTimePropertyHandler.java    From nebula with Eclipse Public License 2.0 6 votes vote down vote up
private void applyCSSPropertyFont(final Control widget, final CSSValue value, final boolean picker) throws Exception {
	if (value.getCssValueType() == CSSValue.CSS_VALUE_LIST) {
		final CSSValueList valueList = (CSSValueList) value;
		final int length = valueList.getLength();
		for (int i = 0; i < length; i++) {
			final CSSValue value2 = valueList.item(i);
			if (value2.getCssValueType() == CSSValue.CSS_PRIMITIVE_VALUE) {
				final String cssProp = CSS2FontHelper.getCSSFontPropertyName((CSSPrimitiveValue) value2);
				if (cssProp.equals("font-family")) {
					applyCSSPropertyFamily(widget, value2, picker);
				} else if (cssProp.equals("font-size")) {
					applyCSSPropertySize(widget, value2, picker);
				} else if (cssProp.equals("font-weight") && ("bold".equals(value2.getCssText()) || "bolder".equals(value2.getCssText()))) {
					applyCSSPropertyWeight(widget, value2, picker);
				} else if (cssProp.equals("font-style") && ("italic".equals(value2.getCssText()) || "oblique".equals(value2.getCssText()))) {
					applyCSSPropertyStyle(widget, value2, picker);
				}
			}
		}
	}
}
 
Example #5
Source File: ContentUtil.java    From birt with Eclipse Public License 1.0 6 votes vote down vote up
/**
 * to check whether there are horizontal page breaks in the table.
 * 
 * @param table
 * @return
 */
public static boolean hasHorzPageBreak( ITableContent table )
{
	int count = table.getColumnCount( );
	for ( int i = 0; i < count; i++ )
	{
		IColumn column = table.getColumn( i );
		IStyle style = column.getStyle( );
		CSSValue pageBreak = style.getProperty( IStyle.STYLE_PAGE_BREAK_BEFORE );
		if ( i > 0 && IStyle.ALWAYS_VALUE == pageBreak )
		{
			return true;
		}
		pageBreak = style.getProperty( IStyle.STYLE_PAGE_BREAK_AFTER );
		if ( i < count - 1 && IStyle.ALWAYS_VALUE == pageBreak )
		{
			return true;
		}
	}
	return false;
}
 
Example #6
Source File: AbstractEmitterImpl.java    From birt with Eclipse Public License 1.0 6 votes vote down vote up
protected boolean isNullValue( CSSValue value )
{
	if ( value == null )
	{
		return true;
	}

	if ( value instanceof DataFormatValue )
	{
		return true;
	}

	if ( value instanceof FloatValue )
	{
		return false;
	}
	String cssText = value.getCssText( );
	return "none".equalsIgnoreCase( cssText )
			|| "transparent".equalsIgnoreCase( cssText );
}
 
Example #7
Source File: PShelfPropertyHandler.java    From nebula with Eclipse Public License 2.0 6 votes vote down vote up
@Override
public boolean applyCSSProperty(Object element, String property,
		CSSValue value, String pseudo, CSSEngine engine) throws Exception {
	final PShelf s = (PShelf)((PShelfElement)element).getNativeWidget();
	final AbstractRenderer r = s.getRenderer();

	if( r instanceof CSSShelfRenderer ) {
		if( ! scheduled.containsKey(s) ) {
			scheduled.put(s, Boolean.TRUE);
			// Queue the changes
			s.getDisplay().asyncExec(() -> {
				if (!s.isDisposed() && !r.isDisposed()) {
					scheduled.remove(s);
					((CSSShelfRenderer) r).reinitialize();
				}
			});
		}
	}
	return true;
}
 
Example #8
Source File: ReportletBodyExecutor.java    From birt with Eclipse Public License 1.0 6 votes vote down vote up
private boolean isNullValue( CSSValue value )
{
	if ( value == null )
	{
		return true;
	}

	if ( value instanceof DataFormatValue )
	{
		return true;
	}

	String cssText = value.getCssText( );
	return "none".equalsIgnoreCase( cssText )
			|| "transparent".equalsIgnoreCase( cssText );
}
 
Example #9
Source File: ChartReportStyleProcessor.java    From birt with Eclipse Public License 1.0 6 votes vote down vote up
private ColorDefinition getColor( CSSValue value )
{
	if ( value != null && value instanceof RGBColorValue )
	{
		RGBColorValue color = (RGBColorValue) value;
		try
		{
			return goFactory.createColorDefinition( Math.round( color.getRed( )
					.getFloatValue( CSSPrimitiveValue.CSS_NUMBER ) ),
					Math.round( color.getGreen( )
							.getFloatValue( CSSPrimitiveValue.CSS_NUMBER ) ),
					Math.round( color.getBlue( )
							.getFloatValue( CSSPrimitiveValue.CSS_NUMBER ) ) );
		}
		catch ( RuntimeException ex )
		{
			logger.log( Level.WARNING.intValue( ),
					"invalid color: {0}" + value.toString( ) ); //$NON-NLS-1$
		}
	}
	return null;
}
 
Example #10
Source File: AttributeBuilder.java    From birt with Eclipse Public License 1.0 6 votes vote down vote up
/**
 * Build the Text-Decoration style string.
 * 
 * @param styleBuffer
 *            The <code>StringBuffer</code> to which the result is output.
 * @param linethrough
 *            The line-through value.
 * @param underline
 *            The underline value.
 * @param overline
 *            The overline value.
 */
public static void buildTextDecoration( StringBuffer styleBuffer,
		IStyle style )
{
	CSSValue linethrough = style.getProperty(IStyle.STYLE_TEXT_LINETHROUGH);
	CSSValue underline = style.getProperty(IStyle.STYLE_TEXT_UNDERLINE);
	CSSValue overline = style.getProperty(IStyle.STYLE_TEXT_OVERLINE);

	if (linethrough == IStyle.LINE_THROUGH_VALUE || underline == IStyle.UNDERLINE_VALUE || overline == IStyle.OVERLINE_VALUE)
	{
		styleBuffer.append( " text-decoration:" ); //$NON-NLS-1$
		if (IStyle.LINE_THROUGH_VALUE == linethrough )
		{
			addPropValue( styleBuffer, "line-through" );
		}
		if ( IStyle.UNDERLINE_VALUE == underline)
		{
			addPropValue( styleBuffer, "underline" );
		}
		if ( IStyle.OVERLINE_VALUE == overline)
		{
			addPropValue( styleBuffer, "overline" );
		}
		styleBuffer.append( ';' );
	}
}
 
Example #11
Source File: HTMLEmitter.java    From birt with Eclipse Public License 1.0 6 votes vote down vote up
/**
 * Close the vertical-align box tag if the element needs implementing the
 * vertical-align.
 */
public void handleVerticalAlignEnd( IContent element )
{
	IStyle style = element.getStyle( );
	CSSValue vAlign = style.getProperty( IStyle.STYLE_VERTICAL_ALIGN );
	CSSValue canShrink = style.getProperty( IStyle.STYLE_CAN_SHRINK );
	DimensionType height = element.getHeight( );
	if ( vAlign != null
			&& vAlign != IStyle.BASELINE_VALUE && height != null
			&& canShrink != IStyle.TRUE_VALUE )
	{
		writer.closeTag( HTMLTags.TAG_TD );
		writer.closeTag( HTMLTags.TAG_TR );
		writer.closeTag( HTMLTags.TAG_TABLE );
	}
}
 
Example #12
Source File: HTMLPerformanceOptimize.java    From birt with Eclipse Public License 1.0 6 votes vote down vote up
/**
 * Handles the Text-Align property of the row content.
 */
public void handleRowAlign( IRowContent row )
{
	// The method getStyle( ) will nevel return a null value;
	IStyle style = row.getStyle( );

	// Build the Vertical-Align property of the row content
	CSSValue vAlign = style.getProperty( IStyle.STYLE_VERTICAL_ALIGN );
	if ( null == vAlign || IStyle.BASELINE_VALUE == vAlign )
	{
		// The default vertical-align value of cell is top. And the cell can
		// inherit the valign from parent row.
		vAlign = IStyle.TOP_VALUE;
	}
	writer.attribute( HTMLTags.ATTR_VALIGN, vAlign.getCssText( ) );
	
	// Build the Text-Align property.
	CSSValue hAlign = style.getProperty( IStyle.STYLE_TEXT_ALIGN );
	if ( null != hAlign )
	{
		writer.attribute( HTMLTags.ATTR_ALIGN, hAlign.getCssText( ) );
	}
}
 
Example #13
Source File: GridPropertyHandler.java    From nebula with Eclipse Public License 2.0 6 votes vote down vote up
private void applyCSSPropertyFont(final Object element, final Grid grid, final CSSValue value, String target) throws Exception {
	if (value.getCssValueType() == CSSValue.CSS_VALUE_LIST) {
		final CSSValueList valueList = (CSSValueList) value;
		final int length = valueList.getLength();
		for (int i = 0; i < length; i++) {
			final CSSValue value2 = valueList.item(i);
			if (value2.getCssValueType() == CSSValue.CSS_PRIMITIVE_VALUE) {
				final String cssProp = CSS2FontHelper.getCSSFontPropertyName((CSSPrimitiveValue) value2);
				if (cssProp.equals("font-family")) {
					applyCSSPropertyFamily(element, grid, value2, target);
				} else if (cssProp.equals("font-size")) {
					applyCSSPropertySize(element, grid, value2, target);
				} else if (cssProp.equals("font-weight") && ("bold".equals(value2.getCssText()) || "bolder".equals(value2.getCssText()))) {
					applyCSSPropertyWeight(element, grid, value2, target);
				} else if (cssProp.equals("font-style") && ("italic".equals(value2.getCssText()) || "oblique".equals(value2.getCssText()))) {
					applyCSSPropertyStyle(element, grid, value2, target);
				}
			}
		}
	}
}
 
Example #14
Source File: HTMLVisionOptimize.java    From birt with Eclipse Public License 1.0 6 votes vote down vote up
/**
 * Build the style of row content.
 */
public void buildRowStyle( IRowContent row, StringBuffer styleBuffer )
{
	buildSize( styleBuffer, HTMLTags.ATTR_HEIGHT, row.getHeight( ) ); //$NON-NLS-1$
	
	// The method getStyle( ) will nevel return a null value;
	IStyle style = row.getStyle( );
	
	// output the none value of the display
	CSSValue display = style.getProperty( IStyle.STYLE_DISPLAY );
	if ( IStyle.NONE_VALUE == display )
	{
		styleBuffer.append( " display: none;" );
	}
	
	style = getElementStyle( row );
	if ( style == null )
	{
		return;
	}
	
	AttributeBuilder.buildFont( styleBuffer, style );
	AttributeBuilder.buildBackground( styleBuffer, style, reportEmitter );
	AttributeBuilder.buildText( styleBuffer, style );
	AttributeBuilder.buildVisual( styleBuffer, style );
}
 
Example #15
Source File: HTMLVisionOptimize.java    From birt with Eclipse Public License 1.0 6 votes vote down vote up
/**
 * Handles the vertical align property of the element content.
 */
public void handleCellVAlign( ICellContent cell )
{
	// The method getStyle( ) will nevel return a null value;
	IStyle style = cell.getStyle( );
	
	// Build the Vertical-Align property.
	CSSValue vAlign = style.getProperty( IStyle.STYLE_VERTICAL_ALIGN );
	if( null == vAlign )
	{
		IStyle cellMergedStyle = new CellMergedStyle( cell );
		vAlign = cellMergedStyle.getProperty( IStyle.STYLE_VERTICAL_ALIGN );
	}
	if ( IStyle.BASELINE_VALUE == vAlign )
	{
		vAlign = IStyle.TOP_VALUE;
	}
	if ( null != vAlign )
	{
		// The default vertical-align value has already been outputted on
		// the parent row.
		writer.attribute( HTMLTags.ATTR_VALIGN, vAlign.getCssText( ) );
	}
}
 
Example #16
Source File: BasicComponent.java    From birt with Eclipse Public License 1.0 5 votes vote down vote up
protected void writeFontSize( IStyle style )
{
	CSSValue fontSize = style
			.getProperty( StyleConstants.STYLE_FONT_SIZE );
	int size = WordUtil.parseFontSize( PropertyUtil
			.getDimensionValue( fontSize ) );
	writeAttrTag( "w:sz", size );
	writeAttrTag( "w:szCs", size );
}
 
Example #17
Source File: BasicComponent.java    From birt with Eclipse Public License 1.0 5 votes vote down vote up
private void buildTextDecoration( StringBuffer styleBuffer, IStyle style )
{
	CSSValue linethrough = style
			.getProperty( IStyle.STYLE_TEXT_LINETHROUGH );
	CSSValue underline = style.getProperty( IStyle.STYLE_TEXT_UNDERLINE );
	CSSValue overline = style.getProperty( IStyle.STYLE_TEXT_OVERLINE );

	if ( linethrough == IStyle.LINE_THROUGH_VALUE
			|| underline == IStyle.UNDERLINE_VALUE
			|| overline == IStyle.OVERLINE_VALUE )
	{
		styleBuffer.append( " text-decoration:" ); //$NON-NLS-1$
		if ( IStyle.LINE_THROUGH_VALUE == linethrough )
		{
			addPropValue( styleBuffer, "line-through" );
		}
		if ( IStyle.UNDERLINE_VALUE == underline )
		{
			addPropValue( styleBuffer, "underline" );
		}
		if ( IStyle.OVERLINE_VALUE == overline )
		{
			addPropValue( styleBuffer, "overline" );
		}
		styleBuffer.append( ';' );
	}
}
 
Example #18
Source File: DocWriter.java    From birt with Eclipse Public License 1.0 5 votes vote down vote up
protected void writeFontSize( IStyle style )
{
	CSSValue fontSize = style.getProperty( StyleConstants.STYLE_FONT_SIZE );
	int size = WordUtil.parseFontSize( PropertyUtil
			.getDimensionValue( fontSize ) );
	writeAttrTag( "w:sz", size );
	writeAttrTag( "w:sz-cs", size );
}
 
Example #19
Source File: HTMLAbstractLM.java    From birt with Eclipse Public License 1.0 5 votes vote down vote up
protected boolean needPageBreakBefore( )
{
	if ( content == null
			|| content.getContentType( ) == IContent.CELL_CONTENT )
	{
		return false;
	}
	if ( hasMasterPageChanged( ) )
	{
		return true;
	}
	IStyle style = content.getStyle( );
	CSSValue pageBreak = style.getProperty( IStyle.STYLE_PAGE_BREAK_BEFORE );
	if ( IStyle.ALWAYS_VALUE == pageBreak ||
			IStyle.RIGHT_VALUE == pageBreak ||
			IStyle.LEFT_VALUE == pageBreak ||
			IStyle.SOFT_VALUE == pageBreak )
	{
		// style.setProperty( IStyle.STYLE_PAGE_BREAK_BEFORE,
		// IStyle.AUTO_VALUE );
		return true;
	}
	
	if ( parent != null && parent instanceof HTMLListingBandLM )
	{
		HTMLListingBandLM bandLayout = (HTMLListingBandLM) parent;
		if ( isVisible && bandLayout.needSoftPageBreak )
		{
			if ( pageBreak == null || IStyle.AUTO_VALUE.equals( pageBreak ) )
			{
				bandLayout.needSoftPageBreak = false; // reset page break
				return true;
			}
		}
	}
	return false;
}
 
Example #20
Source File: HTMLEmitter.java    From birt with Eclipse Public License 1.0 5 votes vote down vote up
/**
 * Checks whether the element is block, inline or inline-block level. In
 * BIRT, the absolute positioning model is used and a box is explicitly
 * offset with respect to its containing block. When an element's x or y is
 * set, it will be treated as a block level element regardless of the
 * 'Display' property set in style. When designating width or height value
 * to an inline element, or when the element has right-to-left base
 * direction, it it will be treated as inline-block.
 * 
 * @param x
 *            Specifies how far a box's left margin edge is offset to the
 *            right of the left edge of the box's containing block.
 * @param y
 *            Specifies how far an absolutely positioned box's top margin
 *            edge is offset below the top edge of the box's containing
 *            block.
 * @param width
 *            The width of the element.
 * @param height
 *            The height of the element.
 * @param style
 *            The <code>IStyle</code> object.
 * @return The display type of the element.
 */
public CSSValue getElementDisplay( DimensionType x, DimensionType y,
		DimensionType width, DimensionType height, IStyle style )
{
	CSSValue display = null;
	if ( style != null )
	{
		display = style.getProperty( IStyle.STYLE_DISPLAY );
	}
	
	if ( IStyle.NONE_VALUE == display )
	{
		return IStyle.NONE_VALUE;
	}
	
	if ( x != null || y != null )
	{
		return IStyle.BLOCK_VALUE;
	}
	else if( IStyle.INLINE_VALUE == display )
	{
		if ( width != null || height != null )
		{
			return IStyle.INLINE_BLOCK_VALUE;
		}
		// RTL text is also treated as inline-block
		else if ( IStyle.CSS_RTL_VALUE.equals( style.getDirection( ) ) )
		{
			return IStyle.INLINE_BLOCK_VALUE;
		}
		else
		{
			return IStyle.INLINE_VALUE;
		}

	}
	return IStyle.BLOCK_VALUE;
}
 
Example #21
Source File: LocalizedContentVisitor.java    From birt with Eclipse Public License 1.0 5 votes vote down vote up
/**
 * process the data content
 * 
 * <li> localize the help text
 * <li> format the value
 * <li> handle it as it is an text.
 * 
 * @param data
 *            data object
 */
protected void processData( IDataContent data )
{
	String altText = localize( data, data.getAltTextKey( ), data.getAltText( ) );
	data.setAltText( altText );
	String helpText = localize( data, data.getHelpKey( ), data.getHelpText( ) );
	data.setHelpText( helpText );
	String text = ""; //$NON-NLS-1$
	if ( data.getLabelKey( ) != null || data.getLabelText( ) != null )
	{
		text = localize( data, data.getLabelKey( ), data.getLabelText( ) );
	}
	else
	{
		Object value = data.getValue( );
		IStyle style = data.getComputedStyle( );
		text = format( value, style );
		if ( value instanceof Number )
		{
			CSSValue align = style.getProperty( IStyle.STYLE_NUMBER_ALIGN );
			if ( align != null && align != CSSValueConstants.NONE_VALUE )
			{
				data.getStyle( ).setProperty( IStyle.STYLE_TEXT_ALIGN,
						align );
			}
		}
	}

	// text can be null value after applying format
	data.setText( text == null ? "" : text );
}
 
Example #22
Source File: PropertyUtil.java    From birt with Eclipse Public License 1.0 5 votes vote down vote up
public static int getIntValue( CSSValue value )
{
	if ( value != null && ( value instanceof FloatValue ) )
	{
		FloatValue fv = (FloatValue) value;
		return (int) fv.getFloatValue( );
	}
	return 0;
}
 
Example #23
Source File: StyleManagerUtils.java    From birt with Eclipse Public License 1.0 5 votes vote down vote up
/**
 * Place a border around a region on the current sheet.
 * This is used to apply borders to entire rows or entire tables.
 * @param colStart
 * The column marking the left-side boundary of the region.
 * @param colEnd
 * The column marking the right-side boundary of the region.
 * @param row
 * The row to get a bottom border.
 * @param borderStyle
 * The BIRT border style to apply to the region.
 */
public void applyBottomBorderToRow( StyleManager sm, Sheet sheet, int colStart, int colEnd, int row, BirtStyle borderStyle ) {	
	CSSValue borderStyleBottom = borderStyle.getProperty( StyleConstants.STYLE_BORDER_BOTTOM_STYLE );
	CSSValue borderWidthBottom = borderStyle.getProperty( StyleConstants.STYLE_BORDER_BOTTOM_WIDTH );
	CSSValue borderColourBottom = borderStyle.getProperty( StyleConstants.STYLE_BORDER_BOTTOM_COLOR );
	
	if( ( borderStyleBottom == null ) || ( CSSConstants.CSS_NONE_VALUE.equals( borderStyleBottom.getCssText() ) )
			|| ( borderWidthBottom == null ) || ( "0".equals(borderWidthBottom) )
			|| ( borderColourBottom == null ) || ( CSSConstants.CSS_TRANSPARENT_VALUE.equals(borderColourBottom.getCssText() ) ) ) {
			borderStyleBottom = null;
			borderWidthBottom = null;
			borderColourBottom = null;
	}

	if( ( borderStyleBottom != null ) || ( borderWidthBottom != null ) || ( borderColourBottom != null ) ) {
		Row styleRow = sheet.getRow(row);
		if( styleRow != null ) {
			for( int col = colStart; col <= colEnd; ++col ) {
				Cell styleCell = styleRow.getCell(col);
				if( styleCell == null ) {
					styleCell = styleRow.createCell(col);
				}
				if( styleCell != null ) {
					// log.debug( "Applying border to cell [R" + styleCell.getRowIndex() + "C" + styleCell.getColumnIndex() + "]");
					CellStyle newStyle = sm.getStyleWithBorders( styleCell.getCellStyle()
							, borderStyleBottom, borderWidthBottom, borderColourBottom 
							, null, null, null
							, null, null, null
							, null, null, null
							);
					styleCell.setCellStyle(newStyle);
				}
			}
		}
	}
}
 
Example #24
Source File: AbstractWordXmlWriter.java    From birt with Eclipse Public License 1.0 5 votes vote down vote up
private void writeSingleBorder( String type, String borderStyle,
		String color, CSSValue width, int margin )
{
	writer.openTag( "w:" + type );
	writeBorderProperty( borderStyle, color, width, margin );
	writer.closeTag( "w:" + type );
}
 
Example #25
Source File: ListValue.java    From birt with Eclipse Public License 1.0 5 votes vote down vote up
/**
 * A string representation of the current value.
 */
public String getCssText( )
{
	StringBuffer sb = new StringBuffer();
	for ( int i = 0; i < length; i++)
	{
		Value value = (Value)items[i];
		if (value == null)
		{
			continue;
		}
		short valueType = value.getCssValueType( );
		if ( valueType == CSSValue.CSS_PRIMITIVE_VALUE )
		{
			switch ( value.getPrimitiveType( ) )
			{
				case CSSPrimitiveValue.CSS_STRING :
					sb.append( encodeString( value.getStringValue( ) ) );
					break;
				case CSSPrimitiveValue.CSS_URI :
					sb.append( "url('" );
					sb.append( value.getStringValue( ) );
					sb.append( "')" );
					break;
				default :
					sb.append( value.getCssText( ) );
			}
		}
		else
		{
			sb.append(value.getCssText( ));
		}
		sb.append( separator );
	}
	if (sb.length( ) != 0)
	{
		sb.setLength( sb.length() - 1 );
	}
	return sb.toString();
}
 
Example #26
Source File: HTMLEmitter.java    From birt with Eclipse Public License 1.0 5 votes vote down vote up
/**
 * Handles the text align property of the element content.
 */
public void handleCellAlign( ICellContent cell )
{
	// The method getStyle( ) will nevel return a null value;
	IStyle style = cell.getStyle( );

	// Build the Text-Align property.
	CSSValue hAlign = style.getProperty( IStyle.STYLE_TEXT_ALIGN );
	if ( null != hAlign )
	{
		writer.attribute( HTMLTags.ATTR_ALIGN, hAlign.getCssText( ) );
	}
}
 
Example #27
Source File: HTMLVisionOptimize.java    From birt with Eclipse Public License 1.0 5 votes vote down vote up
/**
 * Get the border width from a style. It don't support '%'.
 * 
 * @param style
 * @param borderNum
 * @return
 */
private int getBorderWidthValue( IStyle style, int borderNum )
{
	if ( null == style )
	{
		return 0;
	}
	if ( IStyle.STYLE_BORDER_TOP_WIDTH != borderNum
			&& IStyle.STYLE_BORDER_RIGHT_WIDTH != borderNum
			&& IStyle.STYLE_BORDER_BOTTOM_WIDTH != borderNum
			&& IStyle.STYLE_BORDER_LEFT_WIDTH != borderNum )
	{
		return 0;
	}
	CSSValue value = style.getProperty( borderNum );
	if ( value != null && ( value instanceof FloatValue ) )
	{
		FloatValue fv = (FloatValue) value;
		float v = fv.getFloatValue( );
		switch ( fv.getPrimitiveType( ) )
		{
			case CSSPrimitiveValue.CSS_CM :
				return (int) ( v * 72000 / 2.54 );

			case CSSPrimitiveValue.CSS_IN :
				return (int) ( v * 72000 );

			case CSSPrimitiveValue.CSS_MM :
				return (int) ( v * 7200 / 2.54 );

			case CSSPrimitiveValue.CSS_PT :
				return (int) ( v * 1000 );
			case CSSPrimitiveValue.CSS_NUMBER :
				return (int) v;
		}
	}
	return 0;
}
 
Example #28
Source File: TableBreakBuffer.java    From birt with Eclipse Public License 1.0 5 votes vote down vote up
protected int[] getPageBreakIndex( ITableContent table )
{
	List<Integer> indexs = new ArrayList<Integer>( );
	int count = table.getColumnCount( );
	for ( int i = 0; i < count; i++ )
	{
		IColumn column = table.getColumn( i );
		IStyle style = column.getStyle( );
		CSSValue pageBreak = style
				.getProperty( IStyle.STYLE_PAGE_BREAK_BEFORE );
		if ( i > 0 && IStyle.ALWAYS_VALUE == pageBreak )
		{
			if ( !indexs.contains( i - 1 ) )
			{
				indexs.add( i - 1 );
			}
		}
		pageBreak = style.getProperty( IStyle.STYLE_PAGE_BREAK_AFTER );
		if ( i < count - 1 && IStyle.ALWAYS_VALUE == pageBreak )
		{
			if ( !indexs.contains( i ) )
			{
				indexs.add( i );
			}
		}
	}
	if ( !indexs.contains( count - 1 ) )
	{
		indexs.add( count - 1 );
	}
	int[] values = new int[indexs.size( )];
	for ( int i = 0; i < indexs.size( ); i++ )
	{
		values[i] = indexs.get( i ).intValue( );
	}
	return values;
}
 
Example #29
Source File: StyleManagerUtils.java    From birt with Eclipse Public License 1.0 5 votes vote down vote up
public static String getDateFormat( BirtStyle style ) {
	CSSValue dataFormat = style.getProperty( StyleConstants.STYLE_DATA_FORMAT );
	if( dataFormat instanceof DataFormatValue ) {
		DataFormatValue dataFormatValue = (DataFormatValue)dataFormat;
		return dataFormatValue.getDatePattern();			
	}
	return null;
}
 
Example #30
Source File: StyleEntryWriter.java    From birt with Eclipse Public License 1.0 5 votes vote down vote up
private void writeIndent( StyleEntry style )
{
	CSSValue value = (CSSValue)style.getProperty( StyleConstant.TEXT_INDENT );
	if ( value != null )
	{
		writer.attribute( "fo:text-indent", getDimension( value ) );
	}
}