Skip to content

Commit

Permalink
Fix Bugzilla � Bug 287280 Background image does not work in inline st…
Browse files Browse the repository at this point in the history
…yle in html text.
  • Loading branch information
Gang Liu committed Sep 3, 2009
1 parent 128f2b2 commit 139e682
Show file tree
Hide file tree
Showing 5 changed files with 221 additions and 194 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -71,16 +71,15 @@
import org.eclipse.birt.report.engine.emitter.html.util.DiagonalLineImage;
import org.eclipse.birt.report.engine.emitter.html.util.HTMLEmitterUtil;
import org.eclipse.birt.report.engine.executor.ExecutionContext.ElementExceptionInfo;
import org.eclipse.birt.report.engine.executor.css.HTMLProcessor;
import org.eclipse.birt.report.engine.i18n.EngineResourceHandle;
import org.eclipse.birt.report.engine.i18n.MessageConstants;
import org.eclipse.birt.report.engine.ir.DimensionType;
import org.eclipse.birt.report.engine.ir.Report;
import org.eclipse.birt.report.engine.ir.SimpleMasterPageDesign;
import org.eclipse.birt.report.engine.ir.StyledElementDesign;
import org.eclipse.birt.report.engine.ir.TemplateDesign;
import org.eclipse.birt.report.engine.layout.pdf.util.HTMLStyleProcessor;
import org.eclipse.birt.report.engine.layout.pdf.util.PropertyUtil;
import org.eclipse.birt.report.engine.layout.pdf.util.StyleProperties;
import org.eclipse.birt.report.engine.parser.TextParser;
import org.eclipse.birt.report.engine.presentation.ContentEmitterVisitor;
import org.eclipse.birt.report.engine.util.SvgFile;
Expand Down Expand Up @@ -2566,9 +2565,10 @@ private void outputHtmlText(IForeignContent foreign)
TextParser.TEXT_TYPE_HTML );
ReportDesignHandle design = (ReportDesignHandle) runnable
.getDesignHandle( );
HTMLStyleProcessor htmlProcessor = new HTMLStyleProcessor( design );
HTMLProcessor htmlProcessor = new HTMLProcessor( design, reportContext
.getAppContext( ) );

HashMap<Element, StyleProperties> styleMap = new HashMap<Element, StyleProperties>( );
HashMap styleMap = new HashMap( );

Element body = null;
if ( doc != null )
Expand All @@ -2581,7 +2581,7 @@ private void outputHtmlText(IForeignContent foreign)
}
if ( body != null )
{
htmlProcessor.execute( body, styleMap, reportContext.getAppContext( ) );
htmlProcessor.execute( body, styleMap );
processNodes( body, styleMap );
}
writer.setIndent( bIndent );
Expand All @@ -2595,7 +2595,7 @@ private void outputHtmlText(IForeignContent foreign)
* @param ele
* the specific node
*/
private void processNodes( Element ele, HashMap<Element, StyleProperties> cssStyles )
private void processNodes( Element ele, HashMap cssStyles )
{
for ( Node node = ele.getFirstChild( ); node != null; node = node
.getNextSibling( ) )
Expand Down Expand Up @@ -2665,11 +2665,10 @@ private boolean isScriptText( Node node )
return false;
}

public void startNode( Node node,
HashMap<Element, StyleProperties> cssStyles )
public void startNode( Node node, HashMap cssStyles )
{
String nodeName = node.getNodeName( );
StyleProperties cssStyle = cssStyles.get( node );
HashMap cssStyle = (HashMap) cssStyles.get( node );
writer.openTag( nodeName );
NamedNodeMap attributes = node.getAttributes( );
if ( attributes != null )
Expand Down Expand Up @@ -2698,7 +2697,37 @@ public void startNode( Node node,
if ( cssStyle != null )
{
StringBuffer buffer = new StringBuffer( );
cssStyle.toString( buffer );
Iterator ite = cssStyle.entrySet( ).iterator( );
while ( ite.hasNext( ) )
{
Map.Entry entry = (Map.Entry) ite.next( );
Object keyObj = entry.getKey( );
Object valueObj = entry.getValue( );
if ( keyObj == null || valueObj == null )
{
continue;
}
String key = keyObj.toString( );
String value = valueObj.toString( );
buffer.append( key );
buffer.append( ":" );
if ( "background-image".equalsIgnoreCase( key ) )
{
String valueTrue = handleStyleImage( value, true );
if ( valueTrue != null )
{
value = valueTrue;
}
buffer.append( "url(" );
buffer.append( value );
buffer.append( ")" );
}
else
{
buffer.append( value );
}
buffer.append( ";" );
}
if ( buffer.length( ) != 0 )
{
writer.attribute( "style", buffer.toString( ) );
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -114,21 +114,6 @@ public boolean equals( Object aStyle )
return false;
}

public void toString(StringBuffer buffer)
{
for ( int i = 0; i < values.length; i++ )
{
CSSValue value = values[i];
if ( null != value )
{
String propertyName = engine.getPropertyName( i );
buffer.append( propertyName );
buffer.append( ":" );
buffer.append( value.getCssText( ) );
buffer.append( ";" );
}
}
}

public void write( DataOutputStream out ) throws IOException
{
Expand Down
Loading

0 comments on commit 139e682

Please sign in to comment.