|
From: Ethan M. <merritt@u.washington.edu> - 2010-02-02 17:25:18
|
On Monday 01 February 2010 13:37:04 Benjamin Lindner wrote: > Hans-Bernhard Bröker wrote: > > Benjamin Lindner wrote: > > > > [about wgnuplot 4.4 candidate:] > >> There is still one issue open I believe: > >> - Copying to clipboard as metafile is broken. > > > > Broken how, exactly? > > > > in the way that the command > > plot sin(x) with linespoints, cos(x) with linespoints > > produces the attached term window, but when doing Options->Copy to Clipboard > and then pasting as Metafile in openoffice the result looks like the > second attachment. > > benjamin I am totally unfamiliar with the mechanisms for loading or dumping the MSWin clipboard. But that doesn't stop me from looking at the code :-) Two thoughts: In wgraph.c (CopyClip) line 1434: hdc = CreateMetaFile((LPSTR)NULL); According to the on-line docs at msdn.microsoft.com, since 2000 it is better to use CreateEnhMetaFile(), and if necessary convert this afterwards to a backwards compatible [unenhanced] metafile. Can the clipboard not handle an enhanced metafile? I also notice the following in the current code, and I wonder if it explains the lack of text output in your clipboard screenshots: wgraph.c line 849: /* HBB 20010218: the GDI status query functions don't work on Metafile * handles, so can't know whether the screen is actually showing * color or not, if drawgraph() is being called from CopyClip(). * Solve by defaulting isColor to 1 if hdc is a metafile. */ isColor = (((GetDeviceCaps(hdc, PLANES) * GetDeviceCaps(hdc,BITSPIXEL))>2) || (GetDeviceCaps(hdc, TECHNOLOGY) == DT_METAFILE)); The comment indicates that GetDeviceCaps() can fail if the context is creation of a metafile, as it is when loading the clipboard. But then elsewhere in the code.... wgraph.c (MakeFonts) line 661: lpgw->lf.lfHeight = -MulDiv(lpgw->fontsize, GetDeviceCaps(hdc, LOGPIXELSY), 72); line 689: /* CMW: Base tick size on character size */ lpgw->htic = lpgw->hchar / 2; cy = MulDiv(cx/20, GetDeviceCaps(hdc, LOGPIXELSY), GetDeviceCaps(hdc, LOGPIXELSX)); lpgw->vtic = MulDiv(cy,lpgw->ymax,lprect->bottom - lprect->top); /* find out if we can rotate text 90deg */ SelectObject(hdc, lpgw->hfontv); result = GetDeviceCaps(hdc, TEXTCAPS); If the comment is correct, then maybe other places where there is a call to GetDeviceCaps() must be modified to do something else during metafile creation. I.e., maybe the font size is being set to 0 because GetDeviceCaps() returns something other than a useful screen resolution. Finally, if the clipboard wants an enhanced metafile, is it possible that an alternative approach is to replace CopyClip() with an equivalent to tmpgc = CreateEnhMetaFile(...) set term push set term emf [some new option to attach the output to tmpgc] replot set term pop -- Ethan A Merritt Biomolecular Structure Center University of Washington, Seattle 98195-7742 |