[dia] Kludge for wrong clipboard clipping of EMF on Vista/Win7



commit 7bd505876c12ee6d83c5e7ffb73b4a9b085390ff
Author: Hans Breuer <hans breuer org>
Date:   Wed Jun 1 16:52:59 2011 +0200

    Kludge for wrong clipboard clipping of EMF on Vista/Win7
    
    Make dia/cairo scale of EMF OS version dependent. It works as
    intended on WinXP, but on Vista and Win7 /64 only around 70% of
    the "Copy Diagram" is within the automatic clipping region.
    
    All experiments to make it work without kludge failed, I also
    could not find an explanation for the behavior change on the
    Internet.

 plug-ins/cairo/diacairo.c |   21 ++++++++++++++++++++-
 1 files changed, 20 insertions(+), 1 deletions(-)
---
diff --git a/plug-ins/cairo/diacairo.c b/plug-ins/cairo/diacairo.c
index 295f09f..d899a95 100644
--- a/plug-ins/cairo/diacairo.c
+++ b/plug-ins/cairo/diacairo.c
@@ -234,10 +234,29 @@ export_data(DiagramData *data, const gchar *filename,
       RECT bbox = { 0, 0, 
                    (int)((data->extents.right - data->extents.left) * data->paper.scaling * 1000.0),
 		   (int)((data->extents.bottom - data->extents.top) * data->paper.scaling * 1000.0) };
+      RECT clip;
+      /* CreateEnhMetaFile() takes resolution 0.01 mm,  */
       hFileDC = CreateEnhMetaFile (NULL, NULL, &bbox, "DiaCairo\0Diagram\0");
+
+#if 0
+      /* On Windows 7/64 with two wide screen monitors, the clipping of the resulting 
+       * metafile is too small. Scaling the bbox or via SetWorldTransform() does not help. 
+       * Maybe we need to explitily set the clipping for cairo?
+       */
+      GetClipBox (hFileDC, &clip); /* this is the display resolution */
+      if (clip.right / (real)bbox.right > clip.bottom / (real)bbox.bottom)
+	clip.right = clip.bottom * bbox.right / bbox.bottom;
+      else
+	clip.bottom = clip.bottom * bbox.right / bbox.bottom;
+
+      IntersectClipRect(hFileDC, clip.left, clip.top, clip.right, clip.bottom);
+#endif
       renderer->surface = cairo_win32_printing_surface_create (hFileDC);
-      /* CreateEnhMetaFile() takes resolution 0.01 mm,  */
+
       renderer->scale = 1000.0/25.4 * data->paper.scaling;
+      if (LOBYTE (g_win32_get_windows_version()) > 0x05 ||
+	  LOWORD (g_win32_get_windows_version()) > 0x0105)
+	renderer->scale *= 0.72; /* Works w/o for XP, but not on Vista/Win7 */
     }
     break;
 #endif



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]