After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 85831 - Printing (and export to WMF) clip diagram incorrectly
Printing (and export to WMF) clip diagram incorrectly
Status: RESOLVED FIXED
Product: dia
Classification: Other
Component: win32
0.90
Other Windows
: Normal normal
: 0.95
Assigned To: Steffen Macke
Dia maintainers
: 84868 90817 92553 126769 130907 134377 151491 160891 165978 166300 323012 (view as bug list)
Depends on:
Blocks:
 
 
Reported: 2002-06-19 00:20 UTC by ians
Modified: 2014-05-04 20:55 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
A hopefully reasonably patch for WMF export plugin (3.11 KB, patch)
2004-10-21 19:01 UTC, Robert Ögren
none Details | Review

Description ians 2002-06-19 00:20:20 UTC
When printing (and export to .wmf), the diagram is scaled incorrectly. The
image is too big for the page (or image), and is clipped on the right and
bottom. In other words, the blue page break lines are incorrect. You can
get the diagram to fit ok by using a scale value of around 60 to 70 and
ignoring the page break lines, but this varies.

(Tried on Win98 and WinNT4 with 0.88, 0.90RC1 and 0.90)
Comment 1 Steffen Macke 2002-06-19 15:32:36 UTC
*** Bug 84868 has been marked as a duplicate of this bug. ***
Comment 2 Cyrille Chépélov 2002-09-25 17:13:18 UTC
*** Bug 92553 has been marked as a duplicate of this bug. ***
Comment 3 Cyrille Chépélov 2002-09-25 17:35:09 UTC
*** Bug 90817 has been marked as a duplicate of this bug. ***
Comment 4 Steffen Macke 2003-01-04 16:39:40 UTC
The problem still exists in the current CVS version.

Steffen
Comment 5 Hans Breuer 2004-01-10 18:06:17 UTC
Still exists with 0.92 and it probably will for 0.93 and later
versions as well. There is some code to magically scale the output but
it doesn't work that well. IIRC there also are some bits missing from
the specification which (WMF placeable header). But as always :
reasonable patches accepted ;-)

Comment 6 Hans Breuer 2004-01-10 18:07:42 UTC
cced myself just to let me get notice those reasonable patches ...
Comment 7 Hans Breuer 2004-01-10 18:08:48 UTC
*** Bug 130907 has been marked as a duplicate of this bug. ***
Comment 8 Lars Clausen 2004-02-23 14:30:53 UTC
*** Bug 126769 has been marked as a duplicate of this bug. ***
Comment 9 Lars Clausen 2004-02-23 15:06:03 UTC
*** Bug 134377 has been marked as a duplicate of this bug. ***
Comment 10 Hans Breuer 2004-09-19 16:20:11 UTC
*** Bug 151491 has been marked as a duplicate of this bug. ***
Comment 11 Robert Ögren 2004-10-21 19:00:02 UTC
The reason the WMF files are clipped is that the bounding rect passed to
CreateEnhMetaFile is not calculated correctly. The SDK documentation is not very
instructive, but the following page gives some info on how to calculate it:

http://support.microsoft.com/kb/145999/EN-US/

To convert device units to 0.01 mm units, multiply the size in device units by

100.0 * GetDeviceCaps(refDC, HORZSIZE) / GetDeviceCaps(refDC, HORZRES)
and
100.0 * GetDeviceCaps(refDC, VERTSIZE) / GetDeviceCaps(refDC, VERTRES)

where refDC is the DC passed to CreateEnhMetaFile.

The existing code sort of uses the factor 25.4 instead, but that is not correct.
On my system the above expression evaluates to 31.25

I have tested this on a few drawings on which it seems to work fine, the image
fits exactly inside the boundary. I use Windows XP and have checked the WMF
files using Powerpoint 2002 (XP) and the built-in image viewer in Win XP.

I'll attach a patch. There is one think I don't like about it, and that is that
I had to divide scale by 2 (exact value not important I think), otherwise a
small strip at the right and bottom of the image was missing even though the
bounding rectangle was correct, possibly due to some smallint overflow. If one
does not want to pass values larger than what will fit in a smallint to
CreateEnhMetaFile then it would be possible to divide scale by 

MAX(100.0 * GetDeviceCaps(refDC, HORZSIZE) / GetDeviceCaps(refDC, HORZRES),
    100.0 * GetDeviceCaps(refDC, VERTSIZE) / GetDeviceCaps(refDC, VERTRES))

instead. What do you think?
Comment 12 Robert Ögren 2004-10-21 19:01:56 UTC
Created attachment 32893 [details] [review]
A hopefully reasonably  patch for WMF export plugin
Comment 13 Hans Breuer 2004-10-31 18:28:11 UTC
Beside some small namespace glitch reasonable enough to apply it!
(Robert: are there any more patches of you I should look at ;-)

2004-10-31  Hans Breuer  <hans@breuer.org>

        * plug-ins/wmf/wmf_gdi.cpp plug-ins/wmf/wmf_gdi.h :
        added GetDeviceCaps() dummy implementation to make 
       'wmf' compile on Linux, too.

2004-10-31  Hans Breuer  <hans@breuer.org>

	* plug-ins/wmf/wmf.cpp : patch from Robert Ögren <gtk@roboros.com>
	to finally fix the long lasting clipping issue, bug #85831
	Also fixed the line style issue for printing on XP and don't 
	miss to ReleaseDC()

	* plug-ins/wmf/wmf_gdi.[hc] : added ReleaseDC()


Comment 14 Robert Ögren 2004-10-31 19:19:49 UTC
Hans: yes, you might want to look at my patch for bug #137551 in GTK+, which
affects Dia as well on win32.
Comment 15 Hans Breuer 2004-12-10 10:07:43 UTC
*** Bug 160891 has been marked as a duplicate of this bug. ***
Comment 16 Steffen Macke 2005-02-02 06:08:11 UTC
*** Bug 165978 has been marked as a duplicate of this bug. ***
Comment 17 Lars Clausen 2005-02-06 17:46:55 UTC
*** Bug 166300 has been marked as a duplicate of this bug. ***
Comment 18 Hans Breuer 2005-12-18 13:32:05 UTC
*** Bug 323012 has been marked as a duplicate of this bug. ***
Comment 19 Stephen Parry 2014-05-04 20:55:14 UTC
This bug is back / still present in 0.97.2 on Windows. It affects export to EMF, WMF and Copy Drawing. Please can we fix again?