https://bugs.documentfoundation.org/show_bug.cgi?id=173931

            Bug ID: 173931
           Summary: FILESAVE ODT: identical table rows/cells each get
                    their own automatic style, e.g. when only the header
                    row and its cells have a background
           Product: LibreOffice
           Version: 26.8.0.3 release
          Hardware: All
                OS: All
            Status: UNCONFIRMED
          Severity: normal
          Priority: medium
         Component: Writer
          Assignee: [email protected]
          Reporter: [email protected]

Created attachment 209031
  --> https://bugs.documentfoundation.org/attachment.cgi?id=209031&action=edit
Test document: 4x4 table with a shaded header row

Steps to reproduce:

1. Open the attached `table-auto-styles-header-background.fodt`: one 4x4 table;
the header row and its cells have a background colour; the other three rows
share one row style and the other twelve cells share one cell style.
2. Save as ODT.
3. Unzip and look at `office:automatic-styles` in `content.xml`.

Actual result: 13 `table-cell` automatic styles (`Table1.A1`, `Table1.A2`,
`Table1.B2`, … `Table1.D4`) and 4 `table-row` automatic styles, although there
are only 2 distinct cell styles and 2 distinct row styles. Several of the cell
styles are not referenced by any cell. Saving again gives the same result.

Expected result: 2 `table-cell` and 2 `table-row` automatic styles.

The order matters: with the cell background on the body cells instead of the
header cells, the export has the expected 2 cell styles; with the row
background on the last row instead of the first, it has the expected 2 row
styles.

Cause: `SwXMLTableFrameFormatsSort_Impl::AddRow()` and `AddCell()` in
`sw/source/filter/xml/xmltble.cxx` keep a list sorted by which attributes are
set. The scan stops at the first entry that sorts after the new format, but the
code does `++i` before `insert()`, so the new format lands after that entry.
The list is then out of order and later lookups stop before reaching the
matching format. The two lines date from commit 0e5e5f7f8bcc (2010).

On 533 real-world documents, saving with the fix reduced the table-cell
automatic styles from 49,244 to 10,354.

I will submit a patch with a unit test to Gerrit and link it here.

-- 
You are receiving this mail because:
You are the assignee for the bug.

Reply via email to