Index: plug-ins/wmf/wmf.cpp
===================================================================
RCS file: /cvs/gnome/dia/plug-ins/wmf/wmf.cpp,v
retrieving revision 1.25
diff -u -r1.25 wmf.cpp
--- plug-ins/wmf/wmf.cpp	22 Jul 2004 21:56:10 -0000	1.25
+++ plug-ins/wmf/wmf.cpp	21 Oct 2004 18:40:01 -0000
@@ -1104,6 +1104,7 @@
 {
     WmfRenderer *renderer;
     W32::HDC  file;
+    W32::HDC refDC;
     Rectangle *extent;
     gint len;
     double scale;
@@ -1120,11 +1121,17 @@
     else {
         scale = floor (32000.0 / (data->extents.bottom - data->extents.top));
     }
-    bbox.right = (int)((data->extents.right - data->extents.left) * scale);
-    bbox.bottom = (int)((data->extents.bottom - data->extents.top) * scale);
+    scale/= 2; // Without this there can be some smallint overflow, dunno why
+
+    refDC = W32::GetDC(NULL);
+    
+    bbox.right = (int)((data->extents.right - data->extents.left) * scale *
+        100 * GetDeviceCaps(refDC, HORZSIZE) / GetDeviceCaps(refDC, HORZRES));
+    bbox.bottom = (int)((data->extents.bottom - data->extents.top) * scale *
+        100 * GetDeviceCaps(refDC, VERTSIZE) / GetDeviceCaps(refDC, VERTRES));
 
     file = (W32::HDC)W32::CreateEnhMetaFile(
-                    W32::GetDC(NULL), // handle to a reference device context
+                    refDC, // handle to a reference device context
 #ifdef SAVE_EMF
                     filename, // pointer to a filename string
 #else
@@ -1152,16 +1159,16 @@
     /* calculate offsets */
     renderer->xoff = - data->extents.left;
     renderer->yoff = - data->extents.top;
-    renderer->scale = scale / 25.4; /* don't know why this is required ... */
-
+    renderer->scale = scale;
+    
     /* initialize placeable header */
     /* bounding box in twips 1/1440 of an inch */
     renderer->pmh.Key = 0x9AC6CDD7;
     renderer->pmh.Handle = 0;
     renderer->pmh.Left   = 0;
     renderer->pmh.Top    = 0;
-    renderer->pmh.Right  = (gint16)(SC(data->extents.right - data->extents.left) * 25.4);
-    renderer->pmh.Bottom = (gint16)(SC(data->extents.bottom - data->extents.top) * 25.4);
+    renderer->pmh.Right  = (gint16)SC(data->extents.right - data->extents.left);
+    renderer->pmh.Bottom = (gint16)SC(data->extents.bottom - data->extents.top);
     renderer->pmh.Inch   = 1440 * 10;
     renderer->pmh.Reserved = 0;
 
@@ -1178,8 +1185,8 @@
     /* bounding box in device units */
     bbox.left = 0;
     bbox.top = 0;
-    bbox.right = (int)(SC(data->extents.right - data->extents.left) * 25.4);
-    bbox.bottom = (int)(SC(data->extents.bottom - data->extents.top) * 25.4);
+    bbox.right = (int)SC(data->extents.right - data->extents.left);
+    bbox.bottom = (int)SC(data->extents.bottom - data->extents.top);
 
     /* initialize drawing */
     W32::SetBkMode(renderer->hFileDC, TRANSPARENT);
@@ -1188,8 +1195,6 @@
                            bbox.left, bbox.top,
                            bbox.right, bbox.bottom);
 
-    renderer->scale *= 0.95; /* just a little smaller ... */
-
     /* write extents */
     DIAG_NOTE(renderer, "export_data extents %f,%f -> %f,%f\n", 
               extent->left, extent->top, extent->right, extent->bottom);
