https://bz.apache.org/ooo/show_bug.cgi?id=123330

--- Comment #4 from [email protected] ---
What we expect to see is:
+------------------+
|(Table 0, A1)     |
| Hotkeys          |
+------------------+
|(Table 0, A2)     |
|+-------------+   |
||(Table 1, A1)|   |
|| File        |   |
|+-------------+   |
|                  |
+------------------+

But instead we see:
+------------------+
|(Table 0, A1)     |
| Hotkeys          |
|+-------------+   |
||(Table 1, A1)|   |
|| File        |   |
|+-------------+   |
+------------------+
|(Table 0, A2)     |
|                  |
+------------------+

We don't know where the problem occurs, but today it dawned on me that we could
discover that in several ways.

Logically, the process of loading and displaying the HTML file must look
something like this:

+----+          +----------+          +----+
|HTML| Loading  | In-memory|  Saving  |HTML|
|file|--------->|  state   |--------->|file|
| A  |          +----------+          | B  |
+----+               |                +----+
                     | Rendering
                     v
                +----------+
                |  Screen  |
                +----------+

Now what we see on the screen is wrong, but what is broken, loading or
rendering?

If, once loaded, we save the file to another HTML file, and examine the
contents of that one:

<TABLE CELLPADDING=2 CELLSPACING=2 STYLE="page-break-before: always">
    <TR>
        <TD BGCOLOR="#f6b64c">
            <P STYLE="margin-bottom: 0in">Hotkeys</P>
            <TABLE CELLPADDING=2 CELLSPACING=2>
                <TR>
                    <TD>
                        <P>File</P>
                    </TD>
                </TR>
            </TABLE>
            <P><BR><BR>
            </P>
        </TD>
    </TR>
    <TR>
        <TD></TD>
    </TR>
</TABLE>

which is the same as what we see on the screen: the nested table is in the
outer table's cell A1, not A2.

So saving and rendering agree with each other.

But we can go even further and examine the in-memory state using a macro I
stitched together:

Sub Main
    doc = ThisComponent
    textTables = doc.getTextTables()
    text = "Have " & textTables.count & " tables." & Chr(13)
    text = text & "----------" & Chr(13)
    For i = 0 to textTables.count - 1
        table = textTables(i)
        rows = table.getRows()
        text = text & "Table " & i & " has " & rows.GetCount() & " rows" & "."
& chr(13)
        columns = table.getColumns()
        For rowIndex = 1 To rows.getCount()
            For columnIndex = 1 To columns.getCount()
                cellName = Chr(Asc("A") - 1 + columnIndex) & rowIndex
                cell = table.getCellByName(cellName)
                innerTable = GetTableFromCell(cell)
                If IsNull(innerTable) Then
                    text = text & "Cell " & cellName & " has text: "  &
cell.String & Chr(13)
                Else
                    text = text & "Cell " & cellName & " has a nested table"  &
Chr(13)
                End If
            Next
        Next
        text = text & "----------" & Chr(13)
    Next
    MsgBox text
End Sub

Function GetTableFromCell(cell)
    e = cell.createEnumeration()
    While e.hasMoreElements()
        paragraph = e.nextElement()
        If paragraph.supportsService("com.sun.star.text.TextTable") Then
            GetTableFromCell = paragraph
            Exit Function
        End If
    Wend
End Function


which gives the output:

Have 2 tables.
----------
Table 0 has 2 rows.
Cell A1 has a nested table.
Cell A2 has text:
----------
Table 1 has 1 rows.
Cell A1 has text: File


This conclusively proves the in-memory state is wrong, and since it was created
by loading the file, the process of loading the file must be buggy.

-- 
You are receiving this mail because:
You are the assignee for the issue.
You are on the CC list for the issue.

Reply via email to