Skip to content

Commit

Permalink
Fix bugzilla 236380 In the HTML content, we have table,tr,td tags.BIR…
Browse files Browse the repository at this point in the history
…T doesn?? support the attributes of the below mentioned tags.

bugzilla bug 256746 -- PDF emitter doesn't show <div/> the same way HTML editor does
  • Loading branch information
Gang Liu committed Aug 20, 2009
1 parent 243b774 commit 8f82d65
Show file tree
Hide file tree
Showing 12 changed files with 2,030 additions and 314 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -71,15 +71,16 @@
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 @@ -2565,10 +2566,9 @@ private void outputHtmlText(IForeignContent foreign)
TextParser.TEXT_TYPE_HTML );
ReportDesignHandle design = (ReportDesignHandle) runnable
.getDesignHandle( );
HTMLProcessor htmlProcessor = new HTMLProcessor( design, reportContext
.getAppContext( ) );
HTMLStyleProcessor htmlProcessor = new HTMLStyleProcessor( design );

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

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

public void startNode( Node node, HashMap cssStyles )
public void startNode( Node node,
HashMap<Element, StyleProperties> cssStyles )
{
String nodeName = node.getNodeName( );
HashMap cssStyle = (HashMap) cssStyles.get( node );
StyleProperties cssStyle = cssStyles.get( node );
writer.openTag( nodeName );
NamedNodeMap attributes = node.getAttributes( );
if ( attributes != null )
Expand Down Expand Up @@ -2697,37 +2698,7 @@ public void startNode( Node node, HashMap cssStyles )
if ( cssStyle != null )
{
StringBuffer buffer = new StringBuffer( );
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( ";" );
}
cssStyle.toString( buffer );
if ( buffer.length( ) != 0 )
{
writer.attribute( "style", buffer.toString( ) );
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,22 @@ 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
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,16 @@ public CSSValue parsePropertyValue(int idx, String value)
return vm.getDefaultValue();
}

public Parser getParser()
{
return parser;
}

public PropertyManagerFactory getPropertyManagerFactory()
{
return pm;
}

/**
* Parses and creates a style declaration.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@ public interface CSSConstants {
String CSS_BACKGROUND_COLOR_PROPERTY = "background-color";
String CSS_BACKGROUND_IMAGE_PROPERTY = "background-image";
String CSS_BACKGROUND_REPEAT_PROPERTY = "background-repeat";
String CSS_BACKGROUND_REPEAT_X_PROPERTY = "background-repeat-x";
String CSS_BACKGROUND_REPEAT_Y_PROPERTY = "background-repeat-y";
String CSS_BACKGROUND_HEIGHT_PROPERTY = "background-height";
String CSS_BACKGROUND_WIDTH_PROPERTY = "background-width";

Expand Down
Loading

0 comments on commit 8f82d65

Please sign in to comment.