Bug 108064 - [FILESAVE DOCX] Border Line Style property of the data series not preserved when saved as DOCX
Summary: [FILESAVE DOCX] Border Line Style property of the data series not preserved w...
Status: RESOLVED FIXED
Alias: None
Product: LibreOffice
Classification: Unclassified
Component: Chart (show other bugs)
Version:
(earliest affected)
4.2.0.4 release
Hardware: All All
: medium normal
Assignee: Adam Kovacs
URL:
Whiteboard: target:6.2.0
Keywords:
: 94336 (view as bug list)
Depends on:
Blocks: DOCX
  Show dependency treegraph
 
Reported: 2017-05-24 15:23 UTC by Gabor Kelemen (allotropia)
Modified: 2019-09-24 13:38 UTC (History)
6 users (show)

See Also:
Crash report or crash signature:


Attachments
Example file from LO 5.3 (14.43 KB, application/vnd.oasis.opendocument.text)
2017-05-24 15:23 UTC, Gabor Kelemen (allotropia)
Details
Example file saved from LO 5.3 (15.03 KB, application/vnd.openxmlformats-officedocument.wordprocessingml.document)
2017-05-24 15:24 UTC, Gabor Kelemen (allotropia)
Details
Docx in Word 2013 and odt in LO 5.3 side by side (164.09 KB, image/png)
2017-05-24 15:24 UTC, Gabor Kelemen (allotropia)
Details
test file converted from ODT to DOCX by Word 2016 (14.88 KB, application/vnd.openxmlformats-officedocument.wordprocessingml.document)
2018-10-10 01:04 UTC, Luke
Details
In my latest commit there is a conversion in the case of LO preset dashes, which has equivalent MSO preset dashes (110.39 KB, image/png)
2018-10-10 10:14 UTC, Adam Kovacs
Details
mso vs lo preset dashes (107.07 KB, image/png)
2018-10-10 10:17 UTC, Adam Kovacs
Details
MSO preset dashes with names (107.78 KB, image/png)
2018-10-10 10:17 UTC, Adam Kovacs
Details
MSO preset dashes example (338.83 KB, image/png)
2018-10-10 10:18 UTC, Adam Kovacs
Details
Lineproperties of LO preset dashes (1.72 KB, text/plain)
2018-10-10 10:35 UTC, Adam Kovacs
Details
ultrafine dash odt to docx converted by msword (114.70 KB, image/png)
2018-10-11 15:26 UTC, Adam Kovacs
Details
Word 2016 converted Ultra Dash, opened correctly in Writer (132.79 KB, image/png)
2018-10-11 20:54 UTC, Luke
Details
LO Ultrafine Dashed converted by Word 2016 (15.01 KB, application/vnd.openxmlformats-officedocument.wordprocessingml.document)
2018-10-11 20:55 UTC, Luke
Details
MSO preset dash names (3.38 KB, image/png)
2019-01-22 11:53 UTC, Adam Kovacs
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Gabor Kelemen (allotropia) 2017-05-24 15:23:52 UTC
Created attachment 133528 [details]
Example file from LO 5.3

The Border Line Style property of the data series is not preserved when the file saved as DOCX in LibrOffice Writer.

Steps to reproduce:
1. Create an empty text document in LibreOffice Writer
2. Insert a Chart
3. Change the Data Series Border Line Style property to something other than none or Continuous (such as Ultrafine Dashed).
4. Save the file as DOCX
5. Reopen the file either in LibreOffice Writer or Microsoft Word 2013

Actual results:
The border around the data series appears as a continuous line.

Expected results:
The border should appear as intended (e.g. Ultrafine Dashed).
Comment 1 Gabor Kelemen (allotropia) 2017-05-24 15:24:19 UTC
Created attachment 133529 [details]
Example file saved from LO 5.3
Comment 2 Gabor Kelemen (allotropia) 2017-05-24 15:24:57 UTC
Created attachment 133530 [details]
Docx in Word 2013 and odt in LO 5.3 side by side
Comment 3 Jacques Guilleron 2017-05-25 07:54:04 UTC
Hello Gabor,

I reproduce with
LO 5.5.0.0.alpha0+ Build ID: 0e6297932252403883a6057feee488e4ee2bc360
CPU threads: 2; OS: Windows 6.1; UI render: default; 
TinderBox: Win-x86@39, Branch:master, Time: 2017-05-23_00:14:17
Locale: fr-FR (fr_FR); Calc: CL
and
LO 4.2.0.0.beta1 Build ID: f4ca7b35f580827ad2c69ea6d29f7c9b48ebbac7
& Windows 7 Home
Comment 4 QA Administrators 2018-05-26 02:41:36 UTC Comment hidden (obsolete)
Comment 5 Jacques Guilleron 2018-05-27 11:52:09 UTC
Reproduced also with
LO 6.1.0.0.alpha1+
Build ID: 23c5125148a8110d88385b29570bf0b7d4400458
CPU threads: 2; OS: Windows 6.1; UI render: default; 
TinderBox: Win-x86@42, Branch:master, Time: 2018-05-12_00:15:25
Locale: fr-FR (fr_FR); Calc: CL
Comment 6 Adam Kovacs 2018-07-26 06:41:16 UTC
Hello!
I've noticed that if you make the docx file with MS Word, inside the unzipped docx folder in the chart1.xml file there are a tag something like: <a:prstDash val="dash"/> or <a:prstDash val="sysDot"/> or <a:prstDash val="lgDashDotDot"/>. The value of val="something" certainly depends on the custom line style you chose (for example sysdot is also like normal dashes, and lgDashDotDot contains more than one dashes and dots).
When you save the docx file with LibreOffice Writer, this a:prstdash tag will be removed and there will be an <a:custDash/> tag instead of it/them (without val="something").
If you save the file with LibreOffice Writer (...then it loses the custom line style of course...) and manually edit the chart1.xml file, and delete the <a:custDash/> tag, and instert an appropriate tag (for example a <a:prstDash val="dash"/>) instead of it, rezip the contents of the folder and rename it to docx, the custom line style will work again, and it will have the same look (I havent tried all of the custom styles, just a few one).

(You can check out and edit the xml files with xml copy or open xml sdk. Open xml sdk can also compare two xml files).

I guess the responsible code for this, is in the WriteOutLine function in the https://opengrok.libreoffice.org/xref/core/oox/source/export/drawingml.cxx#573 file, starting at the line 700, with this: if( bDashSet && aStyleLineStyle != drawing::LineStyle_DASH ). Currently I have no idea how to solve it. I tried to rename XML_custdash macros to XML_prstDash, but thats not working. I also tried to delete the else block and the if header, and the result was losing the custom dash property, but the line style wont be continous, instead of it it will be dashed with long dashes and long spacing. Can somebody help? :)
Comment 7 Adam Kovacs 2018-07-26 12:10:39 UTC
This could be useful about the prst (preset) dashes: http://officeopenxml.com/drwSp-outline.php
Comment 8 Adam Kovacs 2018-07-26 14:15:08 UTC
About the custom line styles:
https://msdn.microsoft.com/en-us/library/dd947967(v=office.12).aspx
Comment 9 Rizal Muttaqin 2018-07-27 04:25:10 UTC
Reproducible also

Version: 6.0.5.2
Build ID: 1:6.0.5~rc2-0ubuntu0.16.04.1~lo1
CPU threads: 2; OS: Linux 4.10; UI render: default; VCL: gtk2; 
Locale: id-ID (id_ID.UTF-8); Calc: group

Ubuntu 16.04.5
Comment 12 Adam Kovacs 2018-07-30 08:31:13 UTC
So in the file: https://opengrok.libreoffice.org/xref/core/oox/source/drawingml/lineproperties.cxx

There are some settings for the preset line styles in this function:
https://opengrok.libreoffice.org/xref/core/oox/source/drawingml/lineproperties.cxx#62

And the meanings of the numbers can be seen in this function:
https://opengrok.libreoffice.org/xref/core/oox/source/drawingml/lineproperties.cxx#lclSetDashData

For example XML_dot: 1, 1, 0, 0, 3, and the meanings: Dots, DotLe, Dashes, DashLen, Distance.

I guess some if-else-if should be written in this function:
https://opengrok.libreoffice.org/xref/core/oox/source/export/drawingml.cxx#573
around line 704.
Comment 13 Adam Kovacs 2018-08-06 07:37:57 UTC
One question. Why are these properties in if-else relation? If something has a color property it cant have a linestyle property?

if (aStyleProperties.hasElements())
619          {
620              for (sal_Int32 i=0; i < aStyleProperties.getLength(); ++i)
621              {
622                  if( aStyleProperties[i].Name == "Color" )
623                      aStyleProperties[i].Value >>= nStyleColor;
624                  else if( aStyleProperties[i].Name == "LineStyle" )
625                      aStyleProperties[i].Value >>= aStyleLineStyle;
626                  else if( aStyleProperties[i].Name == "LineJoint" )
627                      aStyleProperties[i].Value >>= aStyleLineJoint;
628                  else if( aStyleProperties[i].Name == "LineWidth" )
629                      aStyleProperties[i].Value >>= nStyleLineWidth;
630              }
631          }
Comment 14 Adam Kovacs 2018-08-06 13:30:04 UTC
(In reply to Adam Kovacs from comment #13)
Ok, I understand it. This is in a loop, and in one step there can be only one property validated.
Comment 15 Adam Kovacs 2018-08-07 08:57:52 UTC
Unfortunately this code is not working. The control only gets to the else branch. Such like if aLineDash doesn't even initialized.

//XML_dot
if (aLineDash.Dots == 1 && aLineDash.DotLen == 1 && aLineDash.Dashes == 0 && aLineDash.DashLen == 0 && aLineDash.Distance == 3) {
	mpFS->singleElementNS(XML_a, XML_prstDash, XML_val, "dot", FSEND);
//XML_dash
} else if (aLineDash.Dots == 0 && aLineDash.DotLen == 0 && aLineDash.Dashes == 1 && aLineDash.DashLen == 4 && aLineDash.Distance == 3) {
	mpFS->singleElementNS(XML_a, XML_prstDash, XML_val, "dash", FSEND);
//XML_dashDot
} else if (aLineDash.Dots == 1 && aLineDash.DotLen == 1 && aLineDash.Dashes == 1 && aLineDash.DashLen == 4 && aLineDash.Distance == 3) {
	mpFS->singleElementNS(XML_a, XML_prstDash, XML_val, "dashDot", FSEND);
}
//...and so on
Comment 16 Buovjaga 2018-08-20 14:28:51 UTC
There was a commit for this, but the message accidentally omitted the # from tdf#, so there was no automated comment & whiteboard: https://cgit.freedesktop.org/libreoffice/core/commit/?id=f5f235051055d24c8aced602078c54261603efea

Are further commits coming or is this done?
Comment 17 Adam Kovacs 2018-08-22 10:51:08 UTC
It is planned :)
Comment 18 Commit Notification 2018-09-10 06:51:39 UTC
Adam Kovacs committed a patch related to this issue.
It has been pushed to "master":

http://cgit.freedesktop.org/libreoffice/core/commit/?id=f3d6c44c9cb533fe4f1cd28fc95adc36cac4bfd5

tdf#108064 OOXML export: keep preset dashes with any line width

It will be available in 6.2.0.

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

Affected users are encouraged to test the fix and report feedback.
Comment 19 Commit Notification 2018-09-14 06:07:36 UTC
Adam Kovacs committed a patch related to this issue.
It has been pushed to "master":

http://cgit.freedesktop.org/libreoffice/core/commit/?id=761308edb65a6cf44ef84cebc387e77af8b70f83

tdf#108064 OOXML export: fixing linestyle export in charts

It will be available in 6.2.0.

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

Affected users are encouraged to test the fix and report feedback.
Comment 20 Commit Notification 2018-10-03 09:27:20 UTC
Adam Kovacs committed a patch related to this issue.
It has been pushed to "master":

http://cgit.freedesktop.org/libreoffice/core/commit/?id=d5cc52fec12e3c8d1c3561f172d3e1c5434290b3

tdf#108064 OOXML export: keep preset dashes with mso preset linewidths

It will be available in 6.2.0.

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

Affected users are encouraged to test the fix and report feedback.
Comment 21 Timur 2018-10-03 09:51:45 UTC
Started in 4.2. Previously, chart couldn't be open with MSO.
Comment 22 Commit Notification 2018-10-08 14:34:52 UTC
Adam Kovacs committed a patch related to this issue.
It has been pushed to "master":

http://cgit.freedesktop.org/libreoffice/core/commit/?id=47c3b0390e5ad5a894488c47f014cdd7ecba7d2e

tdf#108064 OOXML export: convert LO preset dashes to equivalent MSO presets

It will be available in 6.2.0.

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

Affected users are encouraged to test the fix and report feedback.
Comment 23 Luke 2018-10-10 01:04:02 UTC
Created attachment 145545 [details]
test file converted from ODT to DOCX by Word 2016

This was marked fixed, but we could do a better job matching LO's fine dash to MSO's "round dot" dash type. It's not perfect, but it's a much closer match.

Attached an example to show how the OOXML looks like.
Comment 24 Adam Kovacs 2018-10-10 10:14:59 UTC
Created attachment 145557 [details]
In my latest commit there is a conversion in the case of LO preset dashes, which has equivalent MSO preset dashes

Related to this commit: https://gerrit.libreoffice.org/#/c/61417/
Comment 25 Adam Kovacs 2018-10-10 10:17:01 UTC
Created attachment 145558 [details]
mso vs lo preset dashes
Comment 26 Adam Kovacs 2018-10-10 10:17:59 UTC
Created attachment 145559 [details]
MSO preset dashes with names
Comment 27 Adam Kovacs 2018-10-10 10:18:47 UTC
Created attachment 145560 [details]
MSO preset dashes example
Comment 28 Adam Kovacs 2018-10-10 10:35:26 UTC
Created attachment 145562 [details]
Lineproperties of LO preset dashes
Comment 29 Adam Kovacs 2018-10-10 10:36:50 UTC
(In reply to Luke from comment #23)
> Created attachment 145545 [details]
> test file converted from ODT to DOCX by Word 2016
> 
> This was marked fixed, but we could do a better job matching LO's fine dash
> to MSO's "round dot" dash type. It's not perfect, but it's a much closer
> match.
> 
> Attached an example to show how the OOXML looks like.

Now you can try with my new fix. 7 of the 10 LO preset dashes should be working (which have MSO preset dash equivalents).
Comment 30 Buovjaga 2018-10-10 11:23:50 UTC
(In reply to Adam Kovacs from comment #29)
> (In reply to Luke from comment #23)
> > Created attachment 145545 [details]
> > test file converted from ODT to DOCX by Word 2016
> > 
> > This was marked fixed, but we could do a better job matching LO's fine dash
> > to MSO's "round dot" dash type. It's not perfect, but it's a much closer
> > match.
> > 
> > Attached an example to show how the OOXML looks like.
> 
> Now you can try with my new fix. 7 of the 10 LO preset dashes should be
> working (which have MSO preset dash equivalents).

Adding Luke to CC to notify
Comment 31 Luke 2018-10-11 03:20:20 UTC
Adam,

In Word, if you open your 'lo_preset_all.odt' and save as .docx, and edit the xml, you will see that the LO preset "Ultra fine dash" used in this bug report is not converted to one of MSO's presets. Rather they use a custom dash, producing better results. 

Here is the OOXML generated by Word:
<a:custDash>
<a:ds sp="33611" d="33611"/>
<a:ds sp="33611" d="33611"/>
</a:custDash>

Here is the OOXML generated by Writer
<a:prstDash val="sysDot"/>
<a:round/>
</a:ln>

I thought you might be interested to see how Word handled it with a custom dash. I did not mean to nitpick. You've done a great job here. Thank you!
Comment 32 Adam Kovacs 2018-10-11 07:53:43 UTC
(In reply to Luke from comment #31)
> Adam,
> 
> In Word, if you open your 'lo_preset_all.odt' and save as .docx, and edit
> the xml, you will see that the LO preset "Ultra fine dash" used in this bug
> report is not converted to one of MSO's presets. Rather they use a custom
> dash, producing better results. 
> 
> Here is the OOXML generated by Word:
> <a:custDash>
> <a:ds sp="33611" d="33611"/>
> <a:ds sp="33611" d="33611"/>
> </a:custDash>
> 
> Here is the OOXML generated by Writer
> <a:prstDash val="sysDot"/>
> <a:round/>
> </a:ln>
> 
> I thought you might be interested to see how Word handled it with a custom
> dash. I did not mean to nitpick. You've done a great job here. Thank you!

So you make an ultrafine LO preset dash into an odt file, open it with World, and save it to docx? I guess that's good as long as you don't open it with Writer :)
Comment 33 Gabor Kelemen (allotropia) 2018-10-11 09:14:45 UTC
*** Bug 94336 has been marked as a duplicate of this bug. ***
Comment 34 Luke 2018-10-11 14:43:45 UTC
(In reply to Adam Kovacs from comment #32)
> (In reply to Luke from comment #31)
 I guess that's good as long as you don't open it
> with Writer :)

Why? Writer has no issue opening attachment 145545 [details]. The custom dash that Word uses to convert 'Ultrafine Dashed', is a close approximation to our preset. It can be opened by both Writer and Word.
Comment 35 Adam Kovacs 2018-10-11 15:26:21 UTC
Created attachment 145618 [details]
ultrafine dash odt to docx converted by msword
Comment 36 Luke 2018-10-11 20:54:45 UTC
Created attachment 145627 [details]
Word 2016 converted Ultra Dash, opened correctly in Writer

Adam,
This is strange. I get different results than you. Are you running an updated version of word 2016?
Comment 37 Luke 2018-10-11 20:55:34 UTC
Created attachment 145628 [details]
LO Ultrafine Dashed converted by Word 2016
Comment 38 Adam Kovacs 2018-10-15 14:33:27 UTC
Version 1708 (build: 8431.2236)
Comment 39 Commit Notification 2018-10-25 07:00:50 UTC
Adam Kovacs committed a patch related to this issue.
It has been pushed to "master":

http://cgit.freedesktop.org/libreoffice/core/commit/?id=ba60a132e788201d4074c576352b4f462c16a9c6

tdf#108064 OOXML export: keep preset dashes with linewidth < 1pt

It will be available in 6.2.0.

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

Affected users are encouraged to test the fix and report feedback.
Comment 40 Adam Kovacs 2019-01-22 11:53:37 UTC
Created attachment 148509 [details]
MSO preset dash names

MSO preset dash names:

1: sysDot
2: sysDash
3: dash
4: dashDot
5: lgDash
6: lgDashDot
7: lgDashDotDot

There are 3 more in OOXML standard:
dot, sysDashDot, sysDashDotDot

You can put these 3 into OOXML, but in MSO, they are not changable from the list.

Some LibreOffice preset dashes converted to these:
"Fine Dotted" -> dot
"2 Dots 1 Dash" -> sysDashDotDot