The patch below will fix PageSize A4 selection bug for the Win32 code

Win32 sends units in inch and A4 is defined in mm.  As a result it drops to
Custom page and crashes.  This patch corrects the unit conversion.  Abi will
still crash on Custom page size and I will investigate further - given time.

Win32 PageSetup also does not correctly update paper size label in the
dialog.

As for the patch, I am sure there is a better way at fixing this problem,
but the solution isn't in the frontal lobes.  I don't think it will break
other platforms, but it is better to check first.

Cheers!


Michael D. Pritchett




Index: fp_PageSize.cpp
===================================================================
RCS file: /cvsroot/abi/src/text/fmt/xp/fp_PageSize.cpp,v
retrieving revision 1.16
diff -u -r1.16 fp_PageSize.cpp
--- fp_PageSize.cpp 2001/04/21 19:24:01 1.16
+++ fp_PageSize.cpp 2001/05/18 17:53:30
@@ -137,6 +137,7 @@
 void fp_PageSize::Set(double w, double h, Unit u)
 {
  int i;
+ double converted_w, converted_h;

  UT_ASSERT(u >= 0 && u < _last_predefined_unit_dont_use_);

@@ -144,16 +145,31 @@

  for (i = 0; i < (int)_last_predefined_pagesize_dont_use_; i++)
  {
-     if ((pagesizes [i].w == w) &&
-   (pagesizes [i].h == h) &&
-   (pagesizes [i].u == u))
+  if (pagesizes[i].u != u )  // Convert to local defined units and round
off
   {
+   converted_w = w * ScaleFactors[u]/ScaleFactors[pagesizes[i].u];
+   int w_int = (int) (converted_w*10.0);
+   if ( converted_w*10 - w_int >= 0.5 ) w_int++;
+   converted_w = (double) w_int/10.0;
+   converted_h = h * ScaleFactors[u]/ScaleFactors[pagesizes[i].u];
+   int h_int = (int) (converted_h*10.0);
+   if ( converted_h*10 - h_int >= 0.5 ) h_int++;
+   converted_h = (double) h_int/10.0;
+  }
+  else
+  {
+   converted_w = w;
+   converted_h = h;
+  }
+
+     if ((pagesizes [i].w == converted_w) &&
+   (pagesizes [i].h == converted_h))
+  {
    Set(static_cast<Predefined>(i), u);
    break;
   }
-  if ((pagesizes [i].h == w) &&
-   (pagesizes [i].w == h) &&
-   (pagesizes [i].u == u))
+  if ((pagesizes [i].h == converted_w) &&
+   (pagesizes [i].w == converted_h))
   {
    Set(static_cast<Predefined>(i), u);
    m_bisPortrait = false;




Reply via email to