Bug 126708

Summary: EMF image lost in command-line conversion from .odt to .doc
Product: LibreOffice Reporter: Luke Deller <luke>
Component: filters and storageAssignee: Luke Deller <luke>
Status: VERIFIED FIXED    
Severity: normal CC: quikee, telesto, vmiklos, xiscofauli
Priority: medium Keywords: bibisected, bisected, regression
Version: 6.1.0.0.alpha0+   
Hardware: All   
OS: All   
See Also: https://bugs.documentfoundation.org/show_bug.cgi?id=118140
https://bugs.documentfoundation.org/show_bug.cgi?id=138515
Whiteboard: target:6.4.0 target:6.3.1
Crash report or crash signature: Regression By:
Bug Depends on:    
Bug Blocks: 103859    
Attachments: containsemf.odt

Description Luke Deller 2019-08-05 13:19:29 UTC
Description:
If an .odt file containing an .emf image is converted to .doc format from the command line, then the image is not visible in the output document.

Steps to Reproduce:
1. Download the attached containsemf.odt file, which was created by inserting an EMF image into a blank document
2. Open containsemf.odt, observe the image, then close LibreOffice
3. Run the following command from the directory where containsemf.odt was saved:
soffice --convert-to doc containsemf.odt
4. Open containsemf.doc

Actual Results:
The image cannot be seen in containsemf.doc

Expected Results:
The image from containsemf.odt should be shown in containsemf.doc


Reproducible: Always


User Profile Reset: Yes



Additional Info:
If the same conversion is performed via the GUI, by opening containsemf.odt and then saving as a doc file, then there is no problem.

Tested in:
LibreOffice 6.0.7.3 - no problem
LibreOffice 6.1.5.2 - problem exists
LibreOffice 6.4.0.0+ (recent master build) - problem exists
Comment 1 Luke Deller 2019-08-05 13:22:18 UTC
Created attachment 153140 [details]
containsemf.odt
Comment 2 Xisco Faulí 2019-08-05 15:35:15 UTC
Regression introduced by:

https://cgit.freedesktop.org/libreoffice/core/commit/?id=7b355669c6ddeab2e6cec692d6afdff41c61d0fb

author	Tomaž Vajngerl <tomaz.vajngerl@collabora.co.uk>	2018-04-14 15:13:05 +0900
committer	Tomaž Vajngerl <quikee@gmail.com>	2018-04-20 09:15:22 +0200
commit 7b355669c6ddeab2e6cec692d6afdff41c61d0fb (patch)
tree 46c55326bccfa68a2bb5fad6d637e0f4576c8d68
parent 663fd3d6e1f93ec989dc289e688d5dbfe434cbca (diff)
Function to load graphic swapped out (loaded on demand)

Bisected with: bibisect-linux64-6.1
 
Adding Cc: to Tomaž Vajngerl
Comment 3 Luke Deller 2019-08-06 13:21:03 UTC
Thanks Xisco, that is really helpful!

I think the trouble is that we cannot get the size of the EMF when it is not properly loaded yet ("swapped in").  Tomaž' change means that the image will be swapped out until we scroll to the page, which doesn't happen when not using the GUI!

Other image formats work because we have some code to sniff the image size from the first few bytes of the file without fully loading it.
(in vcl/source/filter/graphicfilter2.cxx in GraphicDescriptor::Detect)

Adding a proper implementation of GraphicDescriptor::ImpDetectEMF in vcl/source/filter/graphicfilter2.cxx seems to fix the problem for me.  I'll try to get a cppunit test case working and then submit a patch.
Comment 4 Commit Notification 2019-08-07 14:44:33 UTC
Luke Deller committed a patch related to this issue.
It has been pushed to "master":

https://git.libreoffice.org/core/+/6369cab9b1e16275c8700692bb717aec3c42d346%5E%21

tdf#126708 Fix EMF image size in CLI .doc export

It will be available in 6.4.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 5 Xisco Faulí 2019-08-08 09:05:13 UTC
Verified in

Version: 6.4.0.0.alpha0+
Build ID: 6d024a69164716f7856ec936a72d01a6630d2a7c
CPU threads: 4; OS: Linux 4.15; UI render: default; VCL: gtk3; 
Locale: ca-ES (ca_ES.UTF-8); UI-Language: en-US
Calc: threaded

@Luke, thanks for fixing this issue!!
Comment 6 Commit Notification 2019-08-08 10:54:15 UTC
Luke Deller committed a patch related to this issue.
It has been pushed to "libreoffice-6-3":

https://git.libreoffice.org/core/+/bea53649cb9716c48ab2a5518ef2cea76a2cbe3b%5E%21

tdf#126708 Fix EMF image size in CLI .doc export

It will be available in 6.3.1.

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 7 Xisco Faulí 2019-10-22 10:21:12 UTC
I guess we can close it as VERIFIED FIXED, specially after finding bug 118140 was fixed by this issue.
@Luke, revert my change if you disagree...