Bug 106084 - EMF+ images from OOXML document are not rendered correctly LibreOffice
Summary: EMF+ images from OOXML document are not rendered correctly LibreOffice
Status: RESOLVED FIXED
Alias: None
Product: LibreOffice
Classification: Unclassified
Component: filters and storage (show other bugs)
Version:
(earliest affected)
5.2.5.1 release
Hardware: All All
: medium normal
Assignee: Bartosz
URL:
Whiteboard: target:5.4.0 target:5.3.4 target:6.0....
Keywords: filter:emf
Depends on:
Blocks: EMF-WMF
  Show dependency treegraph
 
Reported: 2017-02-19 04:45 UTC by MALLESH SUBRAMANI M
Modified: 2019-01-04 21:46 UTC (History)
5 users (show)

See Also:
Crash report or crash signature:


Attachments
this is a lab manual from my college (798.83 KB, application/wps-office.docx)
2017-02-19 04:47 UTC, MALLESH SUBRAMANI M
Details
this the screen shot of first page when opened using wps office on ubuntu libre office writer (69.59 KB, image/png)
2017-02-19 04:50 UTC, MALLESH SUBRAMANI M
Details
Extracted emf imaged which illustrate the issue. (328.15 KB, application/x-zip-compressed)
2017-03-28 14:21 UTC, Bartosz
Details
Image which shows lack of drawing Bezier lines and transformations (14.07 KB, image/x-emf)
2017-04-19 13:48 UTC, Bartosz
Details
Interested image extracted from document, which could be used for testing purposes (22.66 KB, image/x-emf)
2017-04-27 14:47 UTC, Bartosz
Details
image1 emf inserted into LO 550alpha0 master (238.72 KB, image/png)
2017-06-09 12:07 UTC, V Stuart Foote
Details
Comparison of reference document with patch and without (129.33 KB, image/png)
2018-04-10 23:03 UTC, Bartosz
Details
Comparison of the EMF+ image under LO master and Xnview (Wine) on Ubuntu 18.04 (165.07 KB, image/png)
2019-01-04 15:26 UTC, Bartosz
Details
Visualisation of issue with missing Circles - arrow intersecting the the line (157.84 KB, image/png)
2019-01-04 20:26 UTC, Bartosz
Details

Note You need to log in before you can comment on or make changes to this bug.
Description MALLESH SUBRAMANI M 2017-02-19 04:45:28 UTC
Description:
the images like electric circuit diagrams which were saved using ms office does not show up in libre office even when openGL or CL is enabled or disabled but the same file is opening prpoerly in wps office or ms office and even the print preview screen doesnt show up the image

Actual Results:  
i tried to enable and disable the openGL and CL but the output is same and unaffected

Expected Results:
the image should have shown up


Reproducible: Always

User Profile Reset: Yes

Additional Info:


User-Agent: Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:51.0) Gecko/20100101 Firefox/51.0
Comment 1 MALLESH SUBRAMANI M 2017-02-19 04:47:46 UTC
Created attachment 131334 [details]
this is a lab manual from my college
Comment 2 MALLESH SUBRAMANI M 2017-02-19 04:50:58 UTC
Created attachment 131335 [details]
this the screen shot of first page when opened using wps office on ubuntu libre office writer
Comment 3 MALLESH SUBRAMANI M 2017-02-19 04:55:10 UTC
the same problem happens in libre office installed on windows 10 too
Comment 4 Julien Nabet 2017-02-19 13:39:49 UTC
On pc Debian x86-64 with master sources updated yesterday, I could reproduce this.

There are lots of logs but I noticed this one repeated several times:
warn:writerfilter:7184:1:writerfilter/source/dmapper/OLEHandler.cxx:242: OLEHandler::getCLSID: unhandled m_sProgId: RFFlow4
Comment 5 V Stuart Foote 2017-02-19 16:37:02 UTC
Confirmed, but issue is *not* with the OOXML document--it is with our handling of the EMF images in the archive.  

Export from MS Word 2007 to an ODF document also corrupts images on opening in LO Writer.

Extracted the media folder from the document, and there are 40 images--39 are .emf

Of the half dozen .emf I tested, none are rendered correctly on insert or open with LO Draw.

=-testing-=
Windows 10 Pro 64-bit en-US with
Version: 5.3.0.3 (x64)
Build ID: 7074905676c47b82bbcfbea1aeefc84afe1c50e1

Version: 5.4.0.0.alpha0+
Build ID: 6de3688cc6bd52ce08ff8a4327e59dbbc8a5c7d4

Version: 4.4.6.3
Build ID: e8938fd3328e95dcf59dd64e7facd2c7d67c704d

Version 3.6.7.1 (Build ID: 9418c72)
Comment 6 Thomas Woltjer 2017-02-19 17:17:22 UTC
Also reproduced on LO 5.3.0.3 on 64-bit Manjaro Linux.
Comment 7 Bartosz 2017-03-28 14:21:35 UTC
Created attachment 132223 [details]
Extracted emf imaged which illustrate the issue.
Comment 8 Julien Nabet 2017-03-28 19:02:23 UTC
Bartosz: since you assigned yourself, let's put the status to ASSIGNED.

If it was a mistake, don't hesitate to revert the statut and reset Assignee field.
Comment 9 Bartosz 2017-04-09 00:44:43 UTC
Review for this issue is available at:
https://gerrit.libreoffice.org/36287
Comment 10 Commit Notification 2017-04-13 16:37:29 UTC
Bartosz Kosiorek committed a patch related to this issue.
It has been pushed to "master":

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

tdf#106084 EMF+ Add support for EmfPlusScaleWorldTransform record

It will be available in 5.4.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 11 Bartosz 2017-04-19 13:48:43 UTC
Created attachment 132687 [details]
Image which shows lack of drawing Bezier lines and transformations
Comment 12 Bartosz 2017-04-19 21:26:12 UTC
You could find comparison of images after fixes on website:
https://wiki.documentfoundation.org/ReleaseNotes/5.4#Filters
Comment 13 Bartosz 2017-04-27 14:47:40 UTC
Created attachment 132904 [details]
Interested image extracted from document, which could be used for testing purposes
Comment 14 Commit Notification 2017-04-29 18:54:52 UTC
Bartosz Kosiorek committed a patch related to this issue.
It has been pushed to "libreoffice-5-3":

http://cgit.freedesktop.org/libreoffice/core/commit/?id=cb2f3e524919444d84974fe3216edd8fafc28e10&h=libreoffice-5-3

tdf#106084 EMF+ Add support for EmfPlusTranslateWorldTransform record

It will be available in 5.3.4.

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 15 Bartosz 2017-05-08 23:02:53 UTC
The issue was resolved with commit https://gerrit.libreoffice.org/#/c/37319/
Comment 16 Xisco Faulí 2017-06-09 09:53:47 UTC
Hello,
Is this bug fixed?
If so, could you please close it as RESOLVED FIXED?
Comment 17 V Stuart Foote 2017-06-09 12:07:02 UTC
Created attachment 133925 [details]
image1 emf inserted into LO 550alpha0 master

(In reply to Xisco Faulí from comment #16)
> Hello,
> Is this bug fixed?
> If so, could you please close it as RESOLVED FIXED?

Looks to be only partially resolved. See for example EMF image1.emf image from the zip'd media directory extracted from the OOXML (attachment 132223 [details])

On Windows 10 Home 64-bit en-US with
Version: 5.5.0.0.alpha0+
Build ID: d8e704ef30a6d7f606e58b25be54bbe79c9e40b6
CPU threads: 4; OS: Windows 6.19; UI render: GL; 
TinderBox: Win-x86@42, Branch:master, Time: 2017-06-02_00:43:23
Locale: en-US (en_US); Calc: CL
Comment 18 Xisco Faulí 2017-09-11 08:44:01 UTC
Dear developer,
This bug has been in ASSIGNED status for more than 3 months without any
activity. Resetting it to NEW.
Please assigned it back to yourself if you're still working on this.
Comment 19 MALLESH SUBRAMANI M 2017-10-23 15:39:50 UTC
this bug is not completely resolved it is partially resolved as suggested by V Stuart Foote in comment 17
Comment 20 V Stuart Foote 2017-10-23 18:39:28 UTC
Most lines from the EMF--in the media directory extracted from the OOXML, attachment 132223 [details] (comment 7)--are not being fully/correctly rendered.

=-testing-=
Windows 10 Ent 64-bit en-US with nVidia K2000 (drv. 21.21.13.7755)
 
Version: 6.0.0.0.alpha0+ (x64)
Build ID: 38f9bb33dd6ef4870a71440cf6a86caf5576eaef
CPU threads: 8; OS: Windows 10.0; UI render: GL; 
TinderBox: Win-x86_64@42, Branch:master, Time: 2017-10-12_01:44:44
Locale: en-US (en_US); Calc: CL

Version: 5.4.3.1 (x64)
Build ID: 32c8895c6cae21571f364dbb059f419a743ee44d
CPU threads: 8; OS: Windows 6.19; UI render: GL; 
Locale: en-US (en_US); Calc: group
Comment 21 Commit Notification 2017-10-28 02:12:28 UTC
Bartosz Kosiorek committed a patch related to this issue.
It has been pushed to "master":

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

tdf#106084 EMF+ Add support for RotateWorldTransform record

It will be available in 6.0.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 22 Xisco Faulí 2017-11-28 09:15:18 UTC
A polite ping to Bartosz Kosiorek: is this bug fixed? if so, could you
please close it as RESOLVED FIXED ? Thanks
Comment 23 Bartosz 2017-11-30 23:24:42 UTC
Still there are some remaining issues with rotating and shifting.
I'm investigating it, but it is very complicated to resolve that.
I'm sure that solution is trivial, but it is very hard to find it.
Comment 24 Bartosz 2017-12-01 01:11:47 UTC
After add dependency to DrawString record to string length, everything seems displayed perfectly (see: lx-0.25*font->emSize*stringLength) :

::basegfx::B2DSize mappedSize(MapSize(font->emSize,font->emSize));
::basegfx::B2DPoint mappedPoint(Map(lx-0.25*font->emSize*stringLength,ly+font->emSize));
::basegfx::B2DHomMatrix transformMatrix = basegfx::utils::createScaleTranslateB2DHomMatrix(mappedSize.getX(), mappedSize.getY(), mappedPoint.getX(), mappedPoint.getY());

Unfortunately it regress in ChemDraw objects.
Comment 25 Patrick Jaap 2017-12-01 10:17:28 UTC
Hi Bartosz,

thanks for adding me to this bug. This looks like an ugly bug from hell :) ... I am confident to solve this! It looks indeed like a real challenge to find the correct transformations here. 

Do you have a WIP patch on gerrit with the modified DrawString record handling? Maybe we can work together on this one.
Comment 26 Xisco Faulí 2018-03-02 09:14:19 UTC
Dear Bartosz,
This bug has been in ASSIGNED status for more than 3 months without any
activity. Resetting it to NEW.
Please assigned it back to yourself if you're still working on this.
Comment 27 Bartosz 2018-04-09 22:57:28 UTC
With ChemDraw objects, the font attributes looks like:

emfpstringformat.cxx:55: EMF+	 string format
EMF+	header: 0xdbc01 version: 0x1001 StringFormatFlags: 26628 Language: 18
EMF+	 StringAlignment: 0 LineAlign: 0 DigitSubstitution: 0 DigitLanguage: 2029
EMF+	 FirstTabOffset: 0 HotkeyPrefix: 0 LeadingMargin: 0 TrailingMargin: 0 Tracking: 1
EMF+	 Trimming: 0 TabStopCount: 0 RangeCount: 0


With graphics from this file, it looks like:
emfphelperdata.cxx:113: EMF+ Object slot: 2 flags: 1792
EMF+	 string format
EMF+	header: 0xdbc01 version: 0x1002 StringFormatFlags: 18432 Language: 18
EMF+	 StringAlignment: 1 LineAlign: 0 DigitSubstitution: 0 DigitLanguage: 1357
EMF+	 FirstTabOffset: 0 HotkeyPrefix: 0 LeadingMargin: 0.166667 TrailingMargin: 0.166667 Tracking: 1.03
EMF+	 Trimming: 1 TabStopCount: 0 RangeCount: 0

Main difference is:
- StringAlignment
- LeadingMargin
- TrailingMargin
Comment 28 Bartosz 2018-04-10 23:03:16 UTC
Created attachment 141275 [details]
Comparison of reference document with patch and without

With patch:
https://gerrit.libreoffice.org/#/c/52696/
the issue with test shifting was already resolved.
Waiting for review.
Comment 29 Commit Notification 2018-04-13 07:06:19 UTC
Bartosz Kosiorek committed a patch related to this issue.
It has been pushed to "master":

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

tdf#106084 EMF+ Implement String aligment and Leading/Trailing Margin.

It will be available in 6.1.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 30 Commit Notification 2018-04-19 11:20:01 UTC
Bartosz Kosiorek committed a patch related to this issue.
It has been pushed to "libreoffice-6-0":

http://cgit.freedesktop.org/libreoffice/core/commit/?id=32e7640dc6113945fcd48ce3c0e74cf095da9670&h=libreoffice-6-0

tdf#106084 EMF+ Implement String aligment and Leading/Trailing Margin.

It will be available in 6.0.5.

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 31 Commit Notification 2018-11-05 18:29:39 UTC
Bartosz Kosiorek committed a patch related to this issue.
It has been pushed to "master":

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

tdf#55058 tdf#106084 tdf#114738 EMF+ Add rotation support for String drawing

It will be available in 6.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 32 Commit Notification 2018-11-07 22:28:37 UTC
Bartosz Kosiorek committed a patch related to this issue.
It has been pushed to "master":

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

tdf#55058 tdf#106084 EMF+ Add support for Underline and Strikeout

It will be available in 6.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 33 Commit Notification 2018-11-19 14:32:18 UTC
Bartosz Kosiorek committed a patch related to this issue.
It has been pushed to "libreoffice-6-1":

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

tdf#55058 tdf#106084 tdf#114738 EMF+ Add rotation support for String drawing

It will be available in 6.1.4.

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 34 Commit Notification 2018-11-27 00:59:34 UTC
Bartosz Kosiorek committed a patch related to this issue.
It has been pushed to "libreoffice-6-1":

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

tdf#55058 tdf#106084 EMF+ Add support for Underline and Strikeout

It will be available in 6.1.4.

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 35 Xisco Faulí 2019-01-01 19:31:59 UTC
A polite ping to Bartosz:
Is this bug fixed? if so, could you please close it as RESOLVED FIXED ? Otherwise, Could you please explain what's missing?
Thanks
Comment 36 Bartosz 2019-01-04 15:26:55 UTC
Created attachment 148035 [details]
Comparison of the EMF+ image under LO master and Xnview (Wine) on Ubuntu 18.04

After comparison EMF+ images from  LO master and Xnview (Wine) on Ubuntu 18.04, I think we could close this ticket.

There are still some minor shifts in text labels (in attached image it is "220VDC" and "SUPPLY"), but in my opinion it is acceptable.

During creating bug report there was only blank image, so it is huge improvement compared to that.
Comment 37 V Stuart Foote 2019-01-04 16:56:18 UTC
(In reply to Bartosz from comment #36)
> ...
> There are still some minor shifts in text labels (in attached image it is
> "220VDC" and "SUPPLY"), but in my opinion it is acceptable.
> 
> During creating bug report there was only blank image, so it is huge
> improvement compared to that.

Agree, much better now, and OK to close this.  

But I did notice one substantive issue with the image1.emf of attachment 132223 [details] -- the two Circled Arrow symbols (circuit Galvonometer symbols?) show the arrow intersecting the line -- the circle should mask/clip the line below but is missing. Into a new bug?
Comment 38 Bartosz 2019-01-04 20:26:14 UTC
Created attachment 148046 [details]
Visualisation of issue with missing Circles - arrow intersecting the the line

@V Stuart Foote
Please create separate bug report regarding that issue.
Comment 39 V Stuart Foote 2019-01-04 21:46:26 UTC
(In reply to Bartosz from comment #38)
> Please create separate bug report regarding that issue.

done -> bug 122498