]> git.ipfire.org Git - thirdparty/cups.git/blobdiff - cups/page.c
Merge changes from CUPS 1.6svn-r9939.
[thirdparty/cups.git] / cups / page.c
index 34f0a02d7a4dd9c6e4cbac01cea33e1099215cec..8e79889ab773b04a666ca9b2d8695d67ce328978 100644 (file)
@@ -1,9 +1,9 @@
 /*
  * "$Id: page.c 7791 2008-07-24 00:55:30Z mike $"
  *
- *   Page size functions for the Common UNIX Printing System (CUPS).
+ *   Page size functions for CUPS.
  *
- *   Copyright 2007-2009 by Apple Inc.
+ *   Copyright 2007-2011 by Apple Inc.
  *   Copyright 1997-2007 by Easy Software Products, all rights reserved.
  *
  *   These coded instructions, statements, and computer programs are the
  * Include necessary headers...
  */
 
+#include "string-private.h"
+#include "debug-private.h"
 #include "ppd.h"
-#include "string.h"
-#include <ctype.h>
-#include "debug.h"
 
 
 /*
@@ -44,7 +43,7 @@ ppdPageSize(ppd_file_t *ppd,          /* I - PPD file record */
 {
   int          i;                      /* Looping var */
   ppd_size_t   *size;                  /* Current page size */
-  float                w, l;                   /* Width and length of page */
+  double       w, l;                   /* Width and length of page */
   char         *nameptr;               /* Pointer into name */
   struct lconv *loc;                   /* Locale data */
   ppd_coption_t        *coption;               /* Custom option for page size */
@@ -81,52 +80,54 @@ ppdPageSize(ppd_file_t *ppd,                /* I - PPD file record */
       * Variable size; size name can be one of the following:
       *
       *    Custom.WIDTHxLENGTHin    - Size in inches
+      *    Custom.WIDTHxLENGTHft    - Size in feet
       *    Custom.WIDTHxLENGTHcm    - Size in centimeters
       *    Custom.WIDTHxLENGTHmm    - Size in millimeters
+      *    Custom.WIDTHxLENGTHm     - Size in meters
       *    Custom.WIDTHxLENGTH[pt]  - Size in points
       */
 
       loc = localeconv();
-      w   = (float)_cupsStrScand(name + 7, &nameptr, loc);
+      w   = _cupsStrScand(name + 7, &nameptr, loc);
       if (!nameptr || *nameptr != 'x')
         return (NULL);
 
-      l = (float)_cupsStrScand(nameptr + 1, &nameptr, loc);
+      l = _cupsStrScand(nameptr + 1, &nameptr, loc);
       if (!nameptr)
         return (NULL);
 
-      if (!strcasecmp(nameptr, "in"))
+      if (!_cups_strcasecmp(nameptr, "in"))
       {
-        w *= 72.0f;
-       l *= 72.0f;
+        w *= 72.0;
+       l *= 72.0;
       }
-      else if (!strcasecmp(nameptr, "ft"))
+      else if (!_cups_strcasecmp(nameptr, "ft"))
       {
-        w *= 12.0f * 72.0f;
-       l *= 12.0f * 72.0f;
+        w *= 12.0 * 72.0;
+       l *= 12.0 * 72.0;
       }
-      else if (!strcasecmp(nameptr, "mm"))
+      else if (!_cups_strcasecmp(nameptr, "mm"))
       {
-        w *= 72.0f / 25.4f;
-        l *= 72.0f / 25.4f;
+        w *= 72.0 / 25.4;
+        l *= 72.0 / 25.4;
       }
-      else if (!strcasecmp(nameptr, "cm"))
+      else if (!_cups_strcasecmp(nameptr, "cm"))
       {
-        w *= 72.0f / 2.54f;
-        l *= 72.0f / 2.54f;
+        w *= 72.0 / 2.54;
+        l *= 72.0 / 2.54;
       }
-      else if (!strcasecmp(nameptr, "m"))
+      else if (!_cups_strcasecmp(nameptr, "m"))
       {
-        w *= 72.0f / 0.0254f;
-        l *= 72.0f / 0.0254f;
+        w *= 72.0 / 0.0254;
+        l *= 72.0 / 0.0254;
       }
 
-      size->width  = w;
-      size->length = l;
+      size->width  = (float)w;
+      size->length = (float)l;
       size->left   = ppd->custom_margins[0];
       size->bottom = ppd->custom_margins[1];
-      size->right  = w - ppd->custom_margins[2];
-      size->top    = l - ppd->custom_margins[3];
+      size->right  = (float)(w - ppd->custom_margins[2]);
+      size->top    = (float)(l - ppd->custom_margins[3]);
 
      /*
       * Update the custom option records for the page size, too...
@@ -135,10 +136,10 @@ ppdPageSize(ppd_file_t *ppd,              /* I - PPD file record */
       if ((coption = ppdFindCustomOption(ppd, "PageSize")) != NULL)
       {
         if ((cparam = ppdFindCustomParam(coption, "Width")) != NULL)
-         cparam->current.custom_points = w;
+         cparam->current.custom_points = (float)w;
 
         if ((cparam = ppdFindCustomParam(coption, "Height")) != NULL)
-         cparam->current.custom_points = l;
+         cparam->current.custom_points = (float)l;
       }
 
      /*
@@ -157,7 +158,7 @@ ppdPageSize(ppd_file_t *ppd,                /* I - PPD file record */
       */
 
       for (i = ppd->num_sizes, size = ppd->sizes; i > 0; i --, size ++)
-       if (!strcasecmp(name, size->name))
+       if (!_cups_strcasecmp(name, size->name))
        {
          DEBUG_printf(("3ppdPageSize: Returning %p (\"%s\", %gx%g)", size,
                        size->name, size->width, size->length));
@@ -250,6 +251,9 @@ ppdPageSizeLimits(ppd_file_t *ppd,  /* I - PPD file record */
   * Figure out the current minimum width and length...
   */
 
+  width  = ppd->custom_min[0];
+  length = ppd->custom_min[1];
+
   if (qualifier2)
   {
    /*
@@ -284,11 +288,6 @@ ppdPageSizeLimits(ppd_file_t *ppd, /* I - PPD file record */
       length = ppd->custom_min[1];
     }
   }
-  else
-  {
-    width  = ppd->custom_min[0];
-    length = ppd->custom_min[1];
-  }
 
   minimum->width  = width;
   minimum->length = length;
@@ -301,6 +300,9 @@ ppdPageSizeLimits(ppd_file_t *ppd,  /* I - PPD file record */
   * Figure out the current maximum width and length...
   */
 
+  width  = ppd->custom_max[0];
+  length = ppd->custom_max[1];
+
   if (qualifier2)
   {
    /*
@@ -335,11 +337,6 @@ ppdPageSizeLimits(ppd_file_t *ppd, /* I - PPD file record */
       length = ppd->custom_max[1];
     }
   }
-  else
-  {
-    width  = ppd->custom_max[0];
-    length = ppd->custom_max[1];
-  }
 
   maximum->width  = width;
   maximum->length = length;