Bug 38580 - EMF/EMF+ file: import issue
Summary: EMF/EMF+ file: import issue
Alias: None
Product: LibreOffice
Classification: Unclassified
Component: filters and storage (show other bugs)
(earliest affected)
Hardware: Other All
: medium normal
Assignee: Patrick Jaap
Whiteboard: interoperability
Keywords: filter:emf
Depends on:
Blocks: EMF-WMF
  Show dependency treegraph
Reported: 2011-06-22 15:49 UTC by Valek Filippov
Modified: 2017-08-24 08:51 UTC (History)
8 users (show)

See Also:
Crash report or crash signature:

EMF file with problem (188.44 KB, image/x-emf)
2011-06-22 15:49 UTC, Valek Filippov
Screenshot of the same file in MSO (36.64 KB, image/png)
2011-06-22 15:50 UTC, Valek Filippov
Comparision of 2 images (112.75 KB, image/png)
2011-07-03 09:47 UTC, tester8
Reduced file (484 bytes, image/x-emf)
2011-10-08 21:57 UTC, Valek Filippov
Paste/open Metafile error (48.32 KB, image/png)
2012-03-06 23:50 UTC, tam
Reduced test file as per Radek request (11.67 KB, image/x-emf)
2012-04-12 19:09 UTC, Valek Filippov
File reduced even more (1.02 KB, image/x-emf)
2012-04-12 19:10 UTC, Valek Filippov
Reduced file00023.emf with a couple of PathGradienBrush sub-records. (13.73 KB, image/x-emf)
2012-04-13 21:43 UTC, Valek Filippov
Screenshot with highlighted PathGradienBrush problems (70.51 KB, image/png)
2012-04-13 21:45 UTC, Valek Filippov

Note You need to log in before you can comment on or make changes to this bug.
Description Valek Filippov 2011-06-22 15:49:46 UTC
Created attachment 48309 [details]
EMF file with problem

LibreOffice doesn't import attached EMF file properly.

1. Some strokes are missed.
2. There are glitches around yellow/green leds, fiber and db9 connectors.

I'm attaching also a screenshot (half of the picture, because it's symmetrical) how it looks in MS Office.
Comment 1 Valek Filippov 2011-06-22 15:50:26 UTC
Created attachment 48310 [details]
Screenshot of the same file in MSO
Comment 2 Radek Doulik 2011-06-23 00:08:25 UTC
Looks like problem in path rendering and radial gradients
Comment 3 tester8 2011-07-03 09:43:44 UTC
Reproduced with

LO 3.4.1 (OOO340m1 (Build:101))
Ubuntu 10.04.2 x86
Linux 2.6.32-32-generic Russian UI
Comment 4 tester8 2011-07-03 09:47:49 UTC
Created attachment 48711 [details]
Comparision of 2 images

2 images with highlighted differences.
Comment 5 Rainer Bielefeld Retired 2011-10-08 00:00:52 UTC
My results are very similar with 
"LibreOffice Portable 3.3.3  - WIN7  Home Premium (64bit) German UI [OOO330m19 (Build:301  Tag]" 
"LibreOffice 3.4.3  - WIN7 Home Premium (64bit) German UI [OOO340m1 (Build:302)]" 
Server installation of Master "LibO-dev 3.5.0 – WIN7 Home Premium (64bit) English UI [(Build ID:  3b32204-7f92fce-2ba0a9f)]" (110903)

For details see "screenshots.pdf) (tests without anti aliasing, no ibg changes activating anti aliasing)

My PC:
64 bit AMD Phenom II X4 955 Processor 3.2 GHz, 4GB RAM, 
Graphic Card: NVIDIA GeForce GT 430

I can confirm some of reporter's problems (screenshots item 4
Most other are not visible-
Some problems I see were not visible in reporter's comparision to MSO (screenshots items 11-16). So some problems might be OS or video card related (or even LibO version related, but I doubt.)

@Valek Filippov:
With what LibO version and OS did you do your tests?
Comment 6 Valek Filippov 2011-10-08 07:30:07 UTC
> @Valek Filippov:
> With what LibO version and OS did you do your tests?
Most likely it was 3.3.3 on Linux.
I've just tried with LibO from few days old git master -- same result.

EMF is vector, so it's possible to scale and exclude any possible videocard rasterisation problem.
Close look shows that all 'glitches' could be just one problem with elliptic arc radii calculations.
I will try to reduce test file to few dozens of records.
Comment 7 Valek Filippov 2011-10-08 21:57:58 UTC
Created attachment 52134 [details]
Reduced file

You need to scale ~800% to see the image.
The only important record is the 2nd 'GDI Comment'.
It has one path with 13 coord pairs, which make 
 Start/11 Bezier/CloseSubPath Bezier.

(This one could be useful to review EmrPlusPath Object
Comment 8 Björn Michaelsen 2011-12-23 13:26:01 UTC
Since all new unconfirmed bugs start in state UNCONFIRMED now and old unconfirmed bugs were moved to NEEDINFO with a explanatory comment, all bugs promoted above those bug states to NEW and later are automatically confirmed making the CONFIRMED whiteboard status redundant. Thus it will be removed.
Comment 9 tam 2012-03-06 23:50:31 UTC
Created attachment 58105 [details]
Paste/open Metafile error
Comment 10 tam 2012-03-06 23:51:36 UTC
I have similar problems with my EMF files and same with paste as GDI metafile. Example see attachment https://www.libreoffice.org/bugzilla/attachment.cgi?id=58105
Comment 11 tam 2012-03-15 06:42:42 UTC
Problem still exists in version 3.5.1
Comment 12 tam 2012-04-09 23:59:20 UTC
Problem still exists in version 3.5.2

btw, anybody listening?
Comment 13 Radek Doulik 2012-04-10 00:37:58 UTC
I am trying to fix that problem. Meanwhile you can switch off cairo canvas (Options: View/Use Hardware acceleration) as workaround.
Comment 14 Radek Doulik 2012-04-12 01:16:27 UTC
The problem with broken circles (generally with bezier polygons in cairo canvas) is now fixed in master.

There still remains problem with border lines around connectors. Valek, could you please extract simple test case for that issue as well?
Comment 15 Valek Filippov 2012-04-12 19:09:35 UTC
Created attachment 59884 [details]
Reduced test file as per Radek request

Problem is reproduced with this reduced file too
Comment 16 Valek Filippov 2012-04-12 19:10:25 UTC
Created attachment 59885 [details]
File reduced even more

With this file there is no problem
Comment 17 Valek Filippov 2012-04-12 19:20:21 UTC
Radek, this one is quite interesting...
I've reduced file by removing most of the records from it.
Content of the reduced file is ~ 3 polygon16 and 1 polyline16.
(That's the file in the attachment id=59885).
LibO draws polygons and line.

I've added few records back (attachment id=59884) and finally triaged it to the 2nd EMF+ record. This is the 3rd record in the original (and id=59884) files and it has "path/fill path" commands.
Polygons/polyline are record 40 to 43 in file 59884, hence they should be stroked on top of anything painted before.
Somehow they probably appear under "path" from record 3.

(I can't ungroup opened EMF image, therefore cannot prove that polygons were actually stroked under grey shape. I will try to replace "fill path" with "stroke path" in the record 3 later, to check it.)
Comment 18 Radek Doulik 2012-04-13 02:16:19 UTC
Attachment id=59884 is emf only (not plus) metafile. So it might even be related to emf/emf+ records switching.
Comment 19 Radek Doulik 2012-04-13 07:29:15 UTC
Valek, thanks a lot for the reduced test case. Because of it I was able to trace it to pen with width set to zero, which turned out to mean "use minimal width".
Comment 20 Valek Filippov 2012-04-13 21:43:11 UTC
Created attachment 59953 [details]
Reduced file00023.emf with a couple of PathGradienBrush sub-records.
Comment 21 Valek Filippov 2012-04-13 21:45:16 UTC
Created attachment 59954 [details]
Screenshot with highlighted PathGradienBrush problems
Comment 22 Valek Filippov 2012-04-13 21:47:17 UTC
Radek, see attached file reduced for PathBrushGradient records and screenshot with the problem.
Looks like PathGradient centre is placed at wrong place (swapped centre and edges?)
Comment 23 Valek Filippov 2012-04-13 21:50:26 UTC

Docs on PathGradientBrush.
Comment 24 tam 2012-04-17 07:09:24 UTC
Switching off hardware acc. as in 
does not help. 

I think I wait for next release and see if your fixes help.
Comment 25 Radek Doulik 2012-04-18 07:06:23 UTC
I have looked at the problematic gradients. They are Path gradients and unfortunately we don't have necessary feature available in Canvas yet.

Good news is that since I last checked that, Cairo now supports Mesh gradients, which might be used for Path gradients. OTOH, it will need quite some time to support, as we will need to extend Canvas API and add support to Cairo canvas backend and maybe even extend cppcanvas module and use these in emf+ renderer. 

Not sure yet what to do in other backends - probably use circular gradients as we do now. Hopefully DirectX might have some feature to use for Path gradients as well. Didn't check that yet.
Comment 26 Florian Reisinger 2012-05-19 10:42:11 UTC
Please do not use https://www.libreoffice.org/bugzilla/*, use https://bugs.freedesktop.org/* URLs instead..

Florian R.
Comment 27 tommy27 2014-02-17 18:34:57 UTC
(In reply to comment #24)
> Switching off hardware acc. as in 
> https://bugs.freedesktop.org/show_bug.cgi?id=38580#c13
> does not help. 
> I think I wait for next release and see if your fixes help.

hi could you please give us an update about this issue with current 4.1.5 or 4.2.0 releases?
Comment 28 tam 2014-02-17 18:43:01 UTC
No, still doesn't work. To import my drawings I use OpenOffice 2.4, this still works.
Comment 29 Mike Kaganski 2014-02-28 00:56:01 UTC
(In reply to comment #10)
I suppose that you are describing some different problem in your comment 10.
I cannot decide on the status of the original issue (because it was reopen by an expert in this area, while I see the original image is imported MUCH better and closer to MSO), but your case is clearly different, as you say it hasn't improved. To help developers concentrate on specific problems, and keep track of the progress, it is required to limit each issue to one problem.
Also, to be able to reproduce your specific problem, devs need to be able to paste from clipboard the same data as you.

So, I advise you co file a separate issue here for your problem, and attach the problematic clipboard data captured with a tool like InsideClipboard, so that one could reproduce this without having CorelDRAW or some other software installed.

I'll try to reproduce it and confirm if you CC me there.
Thank you for reporting!

Radek, please tell if it is OK to CC you to NEW bug reports regarding WMF/EMF(+), as you are expert LO hacker in this area?
Comment 30 Joel Madero 2014-11-04 03:46:19 UTC
never confirmed by QA team - moving to UNCONFIRMED.
Comment 31 Buovjaga 2014-11-16 09:44:49 UTC
(In reply to Valek Filippov from comment #20)
> Created attachment 59953 [details]
> Reduced file00023.emf with a couple of PathGradienBrush sub-records.

I confirm it still looks like the screenshot in attachment 59954 [details].
Tam should file a separate report like suggested in comment 29.
I'm setting this as NEW since Radek is not apparently working on LibO anymore.

Win 7 64-bit Version:
Build ID: b021b5983c62e266b82d9f0c5c6d8d8900553827
TinderBox: Win-x86@39, Branch:master, Time: 2014-11-12_01:10:08
Comment 32 QA Administrators 2015-12-20 16:19:41 UTC Comment hidden (obsolete)
Comment 33 Aron Budea 2016-08-24 00:09:36 UTC
Still the same as in Comment 31.
LibreOffice 7.
Comment 34 Xisco Faulí 2017-07-13 12:24:25 UTC
Setting Assignee back to default. Please assign it back to yourself if you're
still working on this issue
Comment 35 Patrick Jaap 2017-08-21 10:19:40 UTC
Hi, there is a completely new EMF+ parser in development. Code is already to find in cppcanvas/source/tools. Your picture was one of my benchmarks for the implementation, thanks! In a few days the new parser will be activated and completely resolves this bug! Feedback is always welcome :)
Comment 36 Patrick Jaap 2017-08-24 08:51:50 UTC
Bug is fixed in current master, due to the new EMF+ renderer!

Feedback is welcome :)