Details
-
Bug
-
Status: Open
-
Resolution: Unresolved
-
2.5
-
None
-
None
-
Operating System: All
Platform: PC
-
47811
Description
I faced this bug when I tried to render table with no exact widths for the
table cells.
FO was generated by CSSToXSLFO converter from very simple html code and it was
generated correctly.
Original html:
<?xml version="1.0" encoding="UTF-8"?>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
</head>
<body>
<table><tr><td>cell 1</td><td>cell 2</td></tr></table>
</body>
</html>
CSSToXSLFO produced FO stylesheet that I attached to the bug as a test case.
It's perfectly correct and works fine with FO->PDF conversion. RTF however
produced ugly table with huge unreadable columns.
Quick fix:
Modify org.apache.fop.render.rtf.rtflib.tools.PercentContext. Replace:
public void setTableUnit(Table table, int tableUnit)
{ tableUnitMap.put(table, new Integer(tableUnit)); }with:
public void setTableUnit(Table table, int tableUnit) {
Integer tableUnitAsInt = new Integer(tableUnit);
tableUnitMap.put(table, tableUnitAsInt);
// put table units for all columns
for (Object tc : table.getColumns())
}
Explanation:
Checking the source code I found that RTF render can't resolve columns widths
correctly in the startColumn(TableColumn tc) method of RTFHandler. The column
width always come out as 0 for proportional width columns.
Actual call is:
int iWidth = tc.getColumnWidth().getValue(percentManager);
Which finally comes to int getBaseLength(int lengthBase, FObj fobj) in
PercentContext class
First argument comes as LengthBase.TABLE_UNITS, second - TableColumn object to
resolve width. Length is extracted from the Map:
Object unit = tableUnitMap.get(fobj);
However this Map is never initialized correctly for TableColumn objects.
Initialization is done only for the Table object but not for columns. All
requests for width calculation could not find width for columns specified in
TABLE_UNITS, returned 0.0.
As a result 0.0 width passed to RTF call tag and produce ugly output for
columns.
Simple fix was straight-forward. Fill tableUnitMap with correct widths for
TableColumn objects too. That fixed the problem and produce nice table output
in RTF.