Bug 64119 - FILESAVE: Buggy CSS stylesheet in exported XHTML
Summary: FILESAVE: Buggy CSS stylesheet in exported XHTML
Status: RESOLVED FIXED
Alias: None
Product: LibreOffice
Classification: Unclassified
Component: Calc (show other bugs)
Version:
(earliest affected)
4.0.2.1 rc
Hardware: Other Linux (All)
: medium normal
Assignee: Gian Domenico Ceccarini
URL:
Whiteboard:
Keywords: difficultyBeginner, easyHack
Depends on:
Blocks:
 
Reported: 2013-05-01 15:49 UTC by Rainer Klute
Modified: 2017-03-13 14:24 UTC (History)
3 users (show)

See Also:
Crash report or crash signature:


Attachments
ZIP file containing a sample ODS document and the corresponding XHTML export. (9.38 KB, application/x-zip)
2013-05-01 15:49 UTC, Rainer Klute
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Rainer Klute 2013-05-01 15:49:30 UTC
Created attachment 78726 [details]
ZIP file containing a sample ODS document and the corresponding XHTML export.

When exporting an ODS document as XHTML, the CSS stylesheet contained in the <style> element is buggy in several respects:

1. The border-width attribute is exported has a comma instead of a point as decimal separator, e.g. border-width:0,021cm instead of border-width:0.021cm. Other width attributes seem to be okay.

2. The stylesheet contains XML-like comments, e.g. <!-- ODF styles with no properties representable as CSS -->. However, CSS comments must be Java style, e.g. /* ODF styles with no properties representable as CSS */

3. The stylesheet contains empty blocks, e.g. { }. This is invalid.
Operating System: Linux (Other)
Version: 4.0.2.1 rc
Comment 1 David Tardon 2013-05-02 07:07:21 UTC
Well, these are three different bugs, so there should be three reports. But let's ignore the technicalities... IMHO at least the first two bugs should be very easily fixable by anyone who knows XSLT, so I am marking this as EasyHack. 

The code in question is filter/source/xslt/odf2xhtml with some parts in filter/source/xslt/common . Some pointers to the individual problems:

1. I would start looking at template round-up-border-width in filter/source/xslt/odf2xhtml/export/common/styles/style_mapping_css.xsl .

2. This is because of the use of xsl:comment in the CSS export code, e.g., template create-page-layout in filter/source/xslt/odf2xhtml/export/xhtml/header.xsl . Obviously these must be changed to plain /* */.

3. I have not been able to spot a likely problematic place in a quick look, so I leave this as excercise to the reader :-)
Comment 2 Marco Biscaro 2013-05-11 02:51:17 UTC
#2 and #3 fixed in https://gerrit.libreoffice.org/#/c/3851

But #1 is a locale problem. In locales where the decimal separator is a comma (like de_DE or pt_BR), the output CSS is wrong. What should be done in this case?
Comment 3 Rainer Klute 2013-05-11 05:46:26 UTC
CSS output should never be localized, but the decimal point must always be a dot ('.'). See the specification here: <http://www.w3.org/TR/CSS2/syndata.html#numbers>.
Comment 4 Marco Biscaro 2013-05-11 19:41:17 UTC
Yes, I know the decimal separator cannot be localized in CSS. What I meant is how can we prevent it to be localized (since it does the localization automatically when doing any calculation)?
Comment 5 Björn Michaelsen 2013-10-04 18:46:55 UTC
adding LibreOffice developer list as CC to unresolved EasyHacks for better visibility.

see e.g. http://nabble.documentfoundation.org/minutes-of-ESC-call-td4076214.html for details
Comment 6 David Tardon 2015-02-10 09:30:51 UTC
(In reply to Marco Biscaro from comment #2)
> #2 and #3 fixed in https://gerrit.libreoffice.org/#/c/3851

I am sorry... I missed this somehow and now the review is lost. Could you push it again?

> 
> But #1 is a locale problem. In locales where the decimal separator is a
> comma (like de_DE or pt_BR), the output CSS is wrong. What should be done in
> this case?

That suggests that the code uses xsl:number to convert the value to string. In that case, adding lang="en-US" attribute should fix the problem.
Comment 7 Robinson Tryon (qubit) 2015-12-14 06:22:02 UTC Comment hidden (obsolete)
Comment 8 Robinson Tryon (qubit) 2016-02-18 14:52:18 UTC Comment hidden (obsolete)
Comment 9 Gian Domenico Ceccarini 2016-12-07 13:24:44 UTC
https://gerrit.libreoffice.org/#/c/31683/

Resolved easy hack!
1) fixed border-width:0.021cm
2) changed stylesheet comment in /*comment*/
3) removed empty blocks
Comment 10 David Tardon 2016-12-08 09:18:13 UTC
Please don't mark as resolved until the fix is merged.
Comment 11 jani 2017-01-09 08:24:18 UTC
A polite ping, still working on this issue ?
Comment 12 Gian Domenico Ceccarini 2017-01-10 14:25:08 UTC
(In reply to jan iversen from comment #11)
> A polite ping, still working on this issue ?

Yes, I'm solving this bug.
Comment 13 jani 2017-02-10 06:49:31 UTC
Unassigning, due to lack of work (old patch is abandoned). If you want to continue working on this please reassign yourself.