Skip to content

Commit

Permalink
Margins are not being set in the doc/docx format of BIRT reports
Browse files Browse the repository at this point in the history
  Fixed this issue by fetching the user values and settting the table
width and margins based on those values.
  For background volor, color code was missed for orange color. Added
that also.
  • Loading branch information
aswanib authored and aswanib committed Mar 17, 2017
1 parent 60b6d23 commit 0e6a054
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -226,11 +226,11 @@ public void startTable( IStyle style, int tablewidth, boolean inForeign )
{
writer.openTag( "w:tbl" );
writer.openTag( "w:tblPr" );
writeTableIndent( );
writeTableIndent( style );
writeAttrTag( "w:tblStyle", "TableGrid" );
writeAttrTag( "w:tblOverlap", "Never" );
writeBidiTable( );
writeTableWidth( tablewidth );
writeTableWidth( style, tablewidth );
writeAttrTag( "w:tblLook", "01E0" );
writeTableLayout( );
writeTableBorders( style );
Expand Down Expand Up @@ -289,14 +289,25 @@ private void writeTableWidth( int tablewidth )
writer.closeTag( "w:tblW" );
}

private void writeTableIndent( )
private void writeTableIndent( IStyle style )
{
writer.openTag( "w:tblInd" );
writer.attribute( "w:w", 0 );
writer.attribute( "w:w",
WordUtil.milliPt2Twips( PropertyUtil.getDimensionValue( style
.getProperty( StyleConstants.STYLE_MARGIN_LEFT ) ) ) );
writer.attribute( "w:type", "dxa" );
writer.closeTag( "w:tblInd" );
}

private void writeTableWidth( IStyle style, int tablewidth )
{
int leftSpace = WordUtil.milliPt2Twips( PropertyUtil.getDimensionValue(
style.getProperty( StyleConstants.STYLE_MARGIN_LEFT ) ) );
int rightSpace = WordUtil.milliPt2Twips( PropertyUtil.getDimensionValue(
style.getProperty( StyleConstants.STYLE_MARGIN_RIGHT ) ) );
writeTableWidth( tablewidth - leftSpace - rightSpace );
}

protected void writeBorders( IStyle style, int bottomMargin, int topMargin,
int leftMargin, int rightMargin )
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -582,6 +582,8 @@ else if ( color.equalsIgnoreCase( "Fuchsia" ) )
return "FF00FF";
else if ( color.equalsIgnoreCase( "Maroon" ) )
return "800000";
else if ( color.equalsIgnoreCase( "Orange" ) )
return "#FFA500";
String[] values = color.substring( color.indexOf( "(" ) + 1,
color.length( ) - 1 ).split( "," );
String value = "";
Expand Down

0 comments on commit 0e6a054

Please sign in to comment.