Bug 155244 - Blue background when exporting spreadsheet as XHTML
Summary: Blue background when exporting spreadsheet as XHTML
Status: VERIFIED FIXED
Alias: None
Product: LibreOffice
Classification: Unclassified
Component: filters and storage (show other bugs)
Version:
(earliest affected)
7.6.0.0 alpha0+
Hardware: x86-64 (AMD64) Linux (All)
: medium normal
Assignee: Svante Schubert
URL:
Whiteboard: target:24.2.0 target:7.6.0.0.beta2 ta...
Keywords: bibisected, bisected, filter:html, regression
Depends on:
Blocks: (X)HTML-Export
  Show dependency treegraph
 
Reported: 2023-05-11 14:54 UTC by Stéphane Guillou (stragu)
Modified: 2023-07-11 15:09 UTC (History)
2 users (show)

See Also:
Crash report or crash signature:


Attachments
simple test ODS with text entered in one cell (8.67 KB, application/vnd.oasis.opendocument.spreadsheet)
2023-05-11 15:18 UTC, Stéphane Guillou (stragu)
Details
buggy XHTML export (2.40 KB, text/html)
2023-05-11 15:45 UTC, Stéphane Guillou (stragu)
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Stéphane Guillou (stragu) 2023-05-11 14:54:01 UTC
Exporting a sheet to XHTML uses a non-existant #729fcf cell background as a .Default style.

Steps:
1. Open LO Calc
2. Enter some data in a cell
3. File > Export > XHTML

Alternatively, a command like:

instdir/program/soffice --headless --convert-to "html:XHTML Calc File:UTF8" ./bluetest.ods

Result: blue background in cells that contain data.

Version: 7.6.0.0.alpha0+ (X86_64) / LibreOffice Community
Build ID: 88bd66d258de5fee3d35aba80c61fec49eb2a969
CPU threads: 8; OS: Linux 5.15; UI render: default; VCL: gtk3
Locale: en-AU (en_AU.UTF-8); UI: en-US
Calc: threaded

Bibisected with linux-64-7.6 repo to first bad commit d112c01284868f60d14a5b1a8be5ba71cb0427d0 which points to core commit:

commit e857b12dada1468cb3bdb49ed5ea636df0b6d153
author	Svante Schubert <svante.schubert@gmail.com>	Fri May 05 12:26:53 2023 +0200
committer	Michael Stahl <michael.stahl@allotropia.de>	Mon May 08 09:42:22 2023 +0200
tdf#154989 filter: XHTML export: avoid duplicated frames
Various updates on XSLT ODF2HTML triggered by TDF issue 154989 - esp. image/frame positioning by CSS position
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/151094

Svante, a regression from your recent work associated to tdf#154989. Can you please have a look?

Before the commit:
    .Default { background-color:#729fcf; font-size:12pt; writing-mode:horizontal-tb; direction:ltr;}
After the commit:
    .Default { font-size:12pt; writing-mode:horizontal-tb; direction:ltr;}
Comment 1 Svante Schubert 2023-05-11 14:59:22 UTC
Hi Stéphane, could you please attach the test input document as I am on the road.
I will than have a look into it.
My guess is that the color is in the ODF XML but is not shown by LO.
Comment 2 Stéphane Guillou (stragu) 2023-05-11 15:18:26 UTC
Created attachment 187202 [details]
simple test ODS with text entered in one cell

Can be seen by exporting this example ODS.

But can also be tested with an older file, like attachment 155587 [details].
Comment 3 Svante Schubert 2023-05-11 15:34:16 UTC
The input is correct,
it is only the default for graphics

<style:default-style style:family="graphic">
<style:graphic-properties svg:stroke-color="#3465a4" draw:fill-color="#729fcf" 

can you therefore please attach the HTML output to the issue :-)
Thanks in advance,
Svante
Comment 4 Stéphane Guillou (stragu) 2023-05-11 15:45:02 UTC
Created attachment 187204 [details]
buggy XHTML export

Exported with:

instdir/program/soffice --headless --convert-to "html:XHTML Calc File:UTF8" /home/stragu/Downloads/bluetest.ods

Console output:

convert /home/stragu/Downloads/bluetest.ods as a Calc document -> /home/stragu/LO-bibisect/linux-64-7.6/bluetest.html using filter : XHTML Calc File:UTF8
XSL Vendor: 'libxslt'
Using default element rule for ODF element 'table:calculation-settings'.
Using default element rule for ODF element 'table:named-expressions'.

Cell is blue in both Firefox and Chromium, and even when imported in Writer.
Comment 5 Svante Schubert 2023-05-11 15:53:55 UTC
Thanks, the issue is that we have only "default" styles without the context of the style family, like:

<style:default-style style:family="graphic">
should become

"default_graphic" and the using element have to have sequence of all style classes it may have properties, like cell may have default_cell, default_paragraph, default_text.
Comment 6 Svante Schubert 2023-05-25 07:04:34 UTC
It is a bit more complex it was not the <style:default-style>
but two styles both named "default" but from different style:families.

Earlier - to keep the naming short and complexity low - we assumed that there will no two styles with the same name, now we realized that we have add this complexity and add to the style name its style family (likely as an abbreviated prefix), see

https://docs.oasis-open.org/office/OpenDocument/v1.3/os/part3-schema/OpenDocument-v1.3-os-part3-schema.html#attribute-style_family
Comment 7 Svante Schubert 2023-06-08 07:22:16 UTC
Problem
========
The problem here was that two styles had similar names but different style:family, which lead to unintended formatting.

Solution
========
Making ODF style IDs unique for HTML/CSS by adding a prefix (the @style:family with '-' as glue character) to their style name.

Solution Details
================
* Adding a prefix (the @Style:family with '-' as glue character) to each style name twice:
   1.1.  in the CSS header for each style name
   1.2.  in the HTML body for each style name

* Added a function (XSLT named template) to map an element name to a style:family to get the the @style:family in the body

* Enhanced the mapping of all style attributes to create a single CSS class attribute with all style names a space separated list of this class attribute (trimming the value later). Wasting just a bit of performance as in case of multiple style names each will create an class attribute and overwrite the prior (but XSLT is not C++) ;-)

Tested it for now locally at our ODF-TC repo https://github.com/oasis-tcs/odf-tc/pull/48 and will ask Michael Stahl for review, merging in LO and adoption of regression tests (thanks in advance, Michael) :-)
Comment 8 Commit Notification 2023-06-09 13:13:11 UTC
Svante Schubert committed a patch related to this issue.
It has been pushed to "master":

https://git.libreoffice.org/core/commit/2d9f739ccfead38cdaa13780f7bb5172553dbd77

tdf#155244 filter: XHTML export: Making ODF style IDs unique for ...

It will be available in 24.2.0.

The patch should be included in the daily builds available at
https://dev-builds.libreoffice.org/daily/ in the next 24-48 hours. More
information about daily builds can be found at:
https://wiki.documentfoundation.org/Testing_Daily_Builds

Affected users are encouraged to test the fix and report feedback.
Comment 9 Svante Schubert 2023-06-09 13:32:20 UTC
Michael was so kind to do the merge! Thx Michael: https://gerrit.libreoffice.org/c/core/+/152749
Comment 10 Commit Notification 2023-06-09 14:54:27 UTC
Svante Schubert committed a patch related to this issue.
It has been pushed to "libreoffice-7-6":

https://git.libreoffice.org/core/commit/ea5a96e10f93a285279da4ade8104f85c1a95dfc

tdf#155244 filter: XHTML export: Making ODF style IDs unique for ...

It will be available in 7.6.0.0.beta2.

The patch should be included in the daily builds available at
https://dev-builds.libreoffice.org/daily/ in the next 24-48 hours. More
information about daily builds can be found at:
https://wiki.documentfoundation.org/Testing_Daily_Builds

Affected users are encouraged to test the fix and report feedback.
Comment 11 Commit Notification 2023-06-12 08:43:46 UTC
Svante Schubert committed a patch related to this issue.
It has been pushed to "libreoffice-7-5":

https://git.libreoffice.org/core/commit/62fb87155c6edad3bb4e2d69b46ba4d2ef45f762

tdf#155244 filter: XHTML export: Making ODF style IDs unique for ...

It will be available in 7.5.5.

The patch should be included in the daily builds available at
https://dev-builds.libreoffice.org/daily/ in the next 24-48 hours. More
information about daily builds can be found at:
https://wiki.documentfoundation.org/Testing_Daily_Builds

Affected users are encouraged to test the fix and report feedback.
Comment 12 Stéphane Guillou (stragu) 2023-06-14 16:54:57 UTC
Verified as fixed in:

Version: 24.2.0.0.alpha0+ (X86_64) / LibreOffice Community
Build ID: ec60d354359067f8c5c686ef2239ee705916de43
CPU threads: 8; OS: Linux 5.15; UI render: default; VCL: gtk3
Locale: en-AU (en_AU.UTF-8); UI: en-US
Calc: threaded

Thanks Michael and Svante!