Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

column's width is not kept when exporting to PDF/Word using plain HTML #349

Merged
merged 1 commit into from
Oct 7, 2016
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@

import java.awt.Color;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;

import org.eclipse.birt.core.exception.BirtException;
Expand All @@ -28,7 +29,10 @@
import org.eclipse.birt.report.engine.content.IRowContent;
import org.eclipse.birt.report.engine.content.IStyle;
import org.eclipse.birt.report.engine.content.ITableContent;
import org.eclipse.birt.report.engine.content.impl.CellContent;
import org.eclipse.birt.report.engine.content.impl.ReportContent;
import org.eclipse.birt.report.engine.content.impl.RowContent;
import org.eclipse.birt.report.engine.content.impl.TableBandContent;
import org.eclipse.birt.report.engine.css.dom.StyleDeclaration;
import org.eclipse.birt.report.engine.css.engine.StyleConstants;
import org.eclipse.birt.report.engine.executor.ExecutionContext;
Expand Down Expand Up @@ -930,6 +934,47 @@ else if ( EngineIRConstants.UNITS_EM.equals( columns[i]
return resolvedColumnWidth;
}

private DimensionType getColWidthFromCellInFirstRow( int colIndex )
{
if ( table.getChildren( ) != null )
{
Iterator<Object> rowIterator = table.getChildren( ).iterator( );
if ( rowIterator.hasNext( ) )
{
Object content = rowIterator.next( );
RowContent rowContent = null;
// handle tables generated by report designer
if ( content instanceof TableBandContent )
{
rowContent = (RowContent) ( (TableBandContent) content )
.getChildren( ).iterator( ).next( );
}
// handle tables directly generated by native html tags
else if ( content instanceof RowContent )
{
rowContent = (RowContent) content;
}

// find i-th Cell width
if ( rowContent != null && rowContent.hasChildren( ) )
{
Iterator<CellContent> cellIterator = rowContent
.getChildren( ).iterator( );
for ( int i = 0; i <= colIndex
&& cellIterator.hasNext( ); i++ )
{
CellContent cell = cellIterator.next( );
if ( i == colIndex )
{
return cell.getWidth( );
}
}
}
}
}
return null;
}

public int[] resolveFixedLayout( int maxWidth )
{

Expand All @@ -948,7 +993,7 @@ public int[] resolveFixedLayout( int maxWidth )
endCol = i;
if ( w == null )
{
columns[i] = null;
columns[i] = getColWidthFromCellInFirstRow( i );
}
else
{
Expand Down