https://issues.apache.org/bugzilla/show_bug.cgi?id=47811

           Summary: (CSSToXLSFO, html tables) Rendering table columns
                    without fo:table-column specified
           Product: Fop
           Version: all
          Platform: PC
        OS/Version: All
            Status: NEW
          Severity: major
          Priority: P2
         Component: rtf
        AssignedTo: fop-dev@xmlgraphics.apache.org
        ReportedBy: pmolcha...@idsk.com


--- Comment #0 from Pavel Molchanov <pmolcha...@idsk.com> 2009-09-09 11:56:17 
PDT ---
Created an attachment (id=24240)
FO test case

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()) {
            tableUnitMap.put(tc, tableUnitAsInt);
        }
    }

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.

-- 
Configure bugmail: https://issues.apache.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug.

Reply via email to