Skip to content

Commit

Permalink
Fix Bugzilla � Bug 287386 'cellpadding' on table does not work in pdf.
Browse files Browse the repository at this point in the history
  • Loading branch information
Gang Liu committed Sep 3, 2009
1 parent a4ac0e2 commit 815f727
Showing 1 changed file with 143 additions and 26 deletions.
Expand Up @@ -66,23 +66,77 @@ public static void process( String property, String value,
}
}

protected boolean hasProperty( IStyle style, int index )
{
return style.getProperty( index ) != null;
}

static
{
properties2Style.put( "cellpadding", //$NON-NLS-1$
new PropertiesProcessor( ) {

public void process( String value, StyleProperties sp )
{
try
{
int size = Integer.parseInt( value ); //$NON-NLS-1$
String padding = size + "px";
IStyle style = sp.getStyle( );
style.setPadding( padding );
}
catch ( Exception e )
if ( value != null && value.length( ) > 0 )
{

if ( value.endsWith( "%" ) )
{
IStyle style = sp.getStyle( );
if ( !hasProperty( style,
IStyle.STYLE_PADDING_LEFT ) )
{
style.setPaddingLeft( value );
}
if ( !hasProperty( style,
IStyle.STYLE_PADDING_RIGHT ) )
{
style.setPaddingRight( value );
}
if ( !hasProperty( style,
IStyle.STYLE_PADDING_TOP ) )
{
style.setPaddingTop( value );
}
if ( !hasProperty( style,
IStyle.STYLE_PADDING_BOTTOM ) )
{
style.setPaddingBottom( value );
}
}
else
{
try
{
int size = Integer.parseInt( value ); //$NON-NLS-1$
String padding = size + "px";
IStyle style = sp.getStyle( );
if ( !hasProperty( style,
IStyle.STYLE_PADDING_LEFT ) )
{
style.setPaddingLeft( padding );
}
if ( !hasProperty( style,
IStyle.STYLE_PADDING_RIGHT ) )
{
style.setPaddingRight( padding );
}
if ( !hasProperty( style,
IStyle.STYLE_PADDING_TOP ) )
{
style.setPaddingTop( padding );
}
if ( !hasProperty( style,
IStyle.STYLE_PADDING_BOTTOM ) )
{
style.setPaddingBottom( padding );
}
}
catch ( Exception e )
{

}
}
}
}
} );
Expand All @@ -91,7 +145,11 @@ public void process( String value, StyleProperties sp )

public void process( String value, StyleProperties sp )
{
sp.getStyle( ).setBackground( value );
IStyle style = sp.getStyle( );
if ( !hasProperty( style, IStyle.STYLE_BACKGROUND_COLOR ) )
{
style.setBackgroundColor( value );
}
}
} );
properties2Style.put( "size", //$NON-NLS-1$
Expand All @@ -102,8 +160,11 @@ public void process( String value, StyleProperties sp )
try
{
int size = Integer.parseInt( value ); //$NON-NLS-1$
sp.getStyle( ).setFontSize(
FONT_SIZE[size + 7] + "pt" );
IStyle style = sp.getStyle( );
if ( !hasProperty( style, IStyle.STYLE_FONT_SIZE ) )
{
style.setFontSize( FONT_SIZE[size + 7] + "pt" );
}
}
catch ( Exception e )
{
Expand All @@ -117,7 +178,11 @@ public void process( String value, StyleProperties sp )

public void process( String value, StyleProperties sp )
{
sp.getStyle( ).setColor( value );
IStyle style = sp.getStyle( );
if ( !hasProperty( style, IStyle.STYLE_COLOR ) )
{
style.setColor( value );
}
}
} );

Expand All @@ -126,7 +191,11 @@ public void process( String value, StyleProperties sp )

public void process( String value, StyleProperties sp )
{
sp.getStyle( ).setColor( value );
IStyle style = sp.getStyle( );
if ( !hasProperty( style, IStyle.STYLE_COLOR ) )
{
style.setColor( value );
}
}
} );

Expand All @@ -135,7 +204,11 @@ public void process( String value, StyleProperties sp )

public void process( String value, StyleProperties sp )
{
sp.getStyle( ).setBackgroundColor( value );
IStyle style = sp.getStyle( );
if ( !hasProperty( style, IStyle.STYLE_BACKGROUND_COLOR ) )
{
style.setBackgroundColor( value );
}
}
} );
properties2Style.put( "border", //$NON-NLS-1$
Expand All @@ -149,14 +222,46 @@ public void process( String value, StyleProperties sp )
int size = Integer.parseInt( value ); //$NON-NLS-1$
String width = size + "px";
IStyle style = sp.getStyle( );
style.setBorderTopWidth( width );
style.setBorderBottomWidth( width );
style.setBorderLeftWidth( width );
style.setBorderRightWidth( width );
style.setBorderTopStyle( "solid" );
style.setBorderBottomStyle( "solid" );
style.setBorderLeftStyle( "solid" );
style.setBorderRightStyle( "solid" );
if ( !hasProperty( style,
IStyle.STYLE_BORDER_TOP_WIDTH ) )
{
style.setBorderTopWidth( width );
}
if ( !hasProperty( style,
IStyle.STYLE_BORDER_BOTTOM_WIDTH ) )
{
style.setBorderBottomWidth( width );
}
if ( !hasProperty( style,
IStyle.STYLE_BORDER_LEFT_WIDTH ) )
{
style.setBorderLeftWidth( width );
}
if ( !hasProperty( style,
IStyle.STYLE_BORDER_RIGHT_WIDTH ) )
{
style.setBorderRightWidth( width );
}
if ( !hasProperty( style,
IStyle.STYLE_BORDER_TOP_STYLE ) )
{
style.setBorderTopStyle( "solid" );
}
if ( !hasProperty( style,
IStyle.STYLE_BORDER_BOTTOM_STYLE ) )
{
style.setBorderBottomStyle( "solid" );
}
if ( !hasProperty( style,
IStyle.STYLE_BORDER_LEFT_STYLE ) )
{
style.setBorderLeftStyle( "solid" );
}
if ( !hasProperty( style,
IStyle.STYLE_BORDER_RIGHT_STYLE ) )
{
style.setBorderRightStyle( "solid" );
}
}
catch ( Exception e )
{
Expand All @@ -169,15 +274,23 @@ public void process( String value, StyleProperties sp )

public void process( String value, StyleProperties sp )
{
sp.getStyle( ).setFontFamily( value );
IStyle style = sp.getStyle( );
if ( !hasProperty( style, IStyle.STYLE_FONT_FAMILY ) )
{
style.setFontFamily( value );
}
}
} );
properties2Style.put( "align", //$NON-NLS-1$
new PropertiesProcessor( ) {

public void process( String value, StyleProperties sp )
{
sp.getStyle( ).setTextAlign( value );
IStyle style = sp.getStyle( );
if ( !hasProperty( style, IStyle.STYLE_TEXT_ALIGN ) )
{
style.setTextAlign( value );
}
}
} );

Expand All @@ -186,7 +299,11 @@ public void process( String value, StyleProperties sp )

public void process( String value, StyleProperties sp )
{
sp.getStyle( ).setVerticalAlign( value );
IStyle style = sp.getStyle( );
if ( !hasProperty( style, IStyle.STYLE_VERTICAL_ALIGN ) )
{
style.setVerticalAlign( value );
}
}
} );

Expand Down

0 comments on commit 815f727

Please sign in to comment.