]> git.ipfire.org Git - thirdparty/cups-filters.git/commitdiff
libcupsfilters: Removed cfRasterMatchIPPSize() function
authorTill Kamppeter <till.kamppeter@gmail.com>
Sat, 20 Aug 2022 18:16:58 +0000 (20:16 +0200)
committerTill Kamppeter <till.kamppeter@gmail.com>
Sat, 20 Aug 2022 18:16:58 +0000 (20:16 +0200)
This function is not needed any more. It is replaced by the more
sophisticated cfGetPageDimensions().

cupsfilters/raster.c
cupsfilters/raster.h

index de39c89e2d01c037da5be291032475ba9b40ff22..83402a797e82f3c8062f93f343a51205806d712a 100644 (file)
@@ -149,275 +149,6 @@ cfRasterColorSpaceString(cups_cspace_t cspace)    /* I - cupsColorSpace value */
 }
 
 
-/*
- * 'cfRasterMatchIPPSize()' - Match IPP page size to header page size.
- */
-
-int 
-cfRasterMatchIPPSize(
-    cups_page_header2_t *header,       /* I - Page header to match */
-    cf_filter_data_t   *data,          /* I - Filter data */
-    double             margins[4],     /* O - Margins of media in points */
-    double             dimensions[2],  /* O - Width and Length of media in points */
-    int                *image_fit,     /* O - Imageable Area Fit */
-    int                *landscape)     /* O - Landscape / Portrait Fit */
-{
-  cups_array_t         *printer_sizes; /* Media sizes we obtained from printer-attributes */
-  cups_size_t          *size,          /* Current media size */
-                       *size_matched = NULL;
-                                       /* Matched size */
-  cf_logfunc_t log = data->logfunc; /* logging function for debugging */
-  void          *ld = data->logdata;
-  ipp_attribute_t      *defattr;       /* default value of attr */
-  int                  i,              /* looping var */
-                       bottom,         /* Smallest bottom margin supported by printer */
-                       left,           /* Smallest left margin supported by printer */
-                       right,          /* Smallest right margin supported by printer */
-                       top,            /* Smallest top margin supported by printer */
-                       max_length = 0, /* Maximum custom size */
-                       max_width = 0,
-                       all_borderless = 1,
-                                       /* if all available printer-sizes
-                                       from printer-ipp-attrs are borderless */
-                       min_length = 2147483647,
-                                       /* Minimum custom size */
-                       min_width = 2147483647;
-  ipp_t                *printer_attrs; /* Printer-attributes obtained from printer data */
-  char                 defsize[41],    /* Default size */
-                       *suffix,
-                       ippsizename[128],
-                       pageSizeRequested[64];  
-                                       /* Requested PageSize */
-
-  printer_attrs = data->printer_attrs;
-
-  if (!header)
-  {
-    if(log) log(ld, CF_LOGLEVEL_ERROR, "Page header cannot be NULL!");
-    return (-1);
-  }
-
-  if (!printer_attrs)
-  {
-    if(log) log(ld, CF_LOGLEVEL_ERROR, "Printer-attributes info not supplied!");
-    return (-1);
-  }
-
-  cfGenerateSizes(printer_attrs, CF_GEN_SIZES_DEFAULT, &printer_sizes, &defattr,
-                 NULL, NULL, NULL, NULL, NULL, NULL,
-                 &min_width, &min_length,
-                 &max_width, &max_length,
-                 &left, &bottom, &right, &top, defsize, NULL);
-
-  strncpy(pageSizeRequested, header->cupsPageSizeName, 64);
-    /* Prefer user-selected page size. */
-  memset(dimensions, 0, sizeof(double)*2);
-  memset(margins, 0, sizeof(double)*4);
-  size_matched = NULL;
-
-  /* XXX FullBleed? FB? */
-    /* Find a page size without ".Borderless" suffix */
-    /* (if all are ".Borderless" we drop the suffix in the size's names) */
-    for (size = (cups_size_t *)cupsArrayFirst(printer_sizes); size;
-        size = (cups_size_t *)cupsArrayNext(printer_sizes))
-      if (strcasestr(size->media, ".Borderless") == NULL)
-       break;
-    if (size)
-      all_borderless = 0;
-
-    if (all_borderless) {
-      suffix = strcasestr(defsize, ".Borderless");
-      if (suffix)
-       *suffix = '\0';
-    }
-
-  for(size = (cups_size_t*)cupsArrayFirst(printer_sizes); size;
-       size = cupsArrayNext(printer_sizes))
-  {
-       double length, width;
-       length = size->length * 72.0/2540.0;
-       width = size->width * 72.0/2540.0;
-       _strlcpy(ippsizename, size->media, sizeof(ippsizename));
-       if((suffix = strchr(ippsizename,' '))!=NULL){
-               *suffix = '\0';
-       }
-
-       if(all_borderless){
-               suffix = strcasestr(ippsizename, ".Borderless");
-               if(suffix){
-                       *suffix = '\0'; 
-               }
-       }
-
-       /* Skip page sizes which conflict with settings of the other options */
-       /* Find size of document's page under the IPP page sizes */
-       if(fabs(header->PageSize[1] - length) / length < 0.01   &&
-          fabs(header->PageSize[0] - width) / width < 0.01     &&
-          (size_matched==NULL || !strcasecmp(pageSizeRequested, ippsizename))){
-               size_matched = size;
-               if(landscape) *landscape = 0;
-               if(image_fit) *image_fit = 0;
-       }
-  }
-
-  if(size_matched==NULL)
-  /* Input page size does not fit any of the IPP's sizes, try to fit
-     the input page size into the imageable areas of the IPP's sizes */
-  for(size = (cups_size_t*)cupsArrayFirst(printer_sizes); size;
-       size = cupsArrayNext(printer_sizes))
-  {
-       _strlcpy(ippsizename, size->media, sizeof(ippsizename));
-       if((suffix = strchr(ippsizename,' '))!=NULL){
-               *suffix = '\0';
-       }
-
-       if(all_borderless){
-               suffix = strcasestr(ippsizename, ".Borderless");
-               if(suffix){
-                       *suffix = '\0'; 
-               }
-       }
-
-       double temptop = size->top * 72.0/2540.0, 
-               tempbottom = size->bottom * 72.0/2540.0, 
-               templeft = size->left * 72.0/ 2540.0, 
-               tempright = size->right * 72.0/2540, 
-               templength = size->length * 72.0/2540.0, 
-               tempwidth = size->width * 72.0/2540.0;
-       /* Skip page sizes which conflict with settings of the other options */
-       /* Find size of document's page under the IPP page sizes */
-       if(fabs(header->PageSize[1] - temptop + tempbottom) / templength < 0.01 &&
-          fabs(header->PageSize[0] - tempright + templeft) / tempwidth < 0.01  &&
-          (size_matched==NULL || !strcasecmp(pageSizeRequested, ippsizename))){
-               if(log)log(ld,CF_LOGLEVEL_DEBUG,"Imageable area fit");
-               size_matched = size;
-               if (landscape) *landscape = 0;
-               if (image_fit) *image_fit = 1;
-       }
-  }
-
-  if (size_matched)
-  {
-   /*
-    * Standard size...
-    */
-    if(log)log(ld,CF_LOGLEVEL_DEBUG,"IPP matched size = %s", size_matched->media);
-    size = size_matched;
-    dimensions[0] = size->width * 72.0 / 2540.0;
-    dimensions[1] = size->length * 72.0 / 2540.0;
-    margins[0] = size->left * 72.0 / 2540.0;
-    margins[1] = size->bottom * 72.0 / 2540.0;
-    margins[2] = size->right * 72.0 / 2540.0;
-    margins[3] = size->top * 72.0 / 2540.0;
-    snprintf(header->cupsPageSizeName, sizeof(header->cupsPageSizeName),
-            "%.63s", size->media);
-  }
-  else
-  {
-   /*
-    * No matching portrait size; look for a matching size in
-    * landscape orientation...
-    */
-       size_matched = 0;
-       for(size = (cups_size_t*)cupsArrayFirst(printer_sizes); size;
-               size = cupsArrayNext(printer_sizes))
-       {
-               double length, width;
-               length = size->length * 72.0/2540.0;
-               width = size->width * 72.0/2540.0;
-               _strlcpy(ippsizename, size->media, sizeof(ippsizename));
-               if((suffix = strchr(ippsizename,' '))!=NULL){
-                       *suffix = '\0';
-               }
-
-               if(all_borderless){
-                       suffix = strcasestr(ippsizename, ".Borderless");
-                       if(suffix){
-                               *suffix = '\0'; 
-                       }
-               }
-
-               /* Skip page sizes which conflict with settings of the other options */
-               /* Find size of document's page under the IPP page sizes */
-               if(fabs(header->PageSize[0] - length) / length < 0.01   &&
-               fabs(header->PageSize[1] - width) / width < 0.01        &&
-               (size_matched==NULL || !strcasecmp(pageSizeRequested, ippsizename))){
-                       size_matched = size;
-                       if(landscape) *landscape = 1;
-                       if(image_fit) *image_fit = 0;
-               }
-       }
-       if (size_matched == NULL)
-       /* Input page size does not fit any of the IPP's sizes, try to fit
-       the input page size into the imageable areas of the IPP's sizes */
-       for(size = (cups_size_t*)cupsArrayFirst(printer_sizes); size;
-               size = cupsArrayNext(printer_sizes))
-       {
-               _strlcpy(ippsizename, size->media, sizeof(ippsizename));
-               if((suffix = strchr(ippsizename,' '))!=NULL){
-                       *suffix = '\0';
-               }
-
-               if(all_borderless){
-                       suffix = strcasestr(ippsizename, ".Borderless");
-                       if(suffix){
-                               *suffix = '\0'; 
-                       }
-               }
-
-               double temptop = size->top * 72.0/2540.0, 
-                       tempbottom = size->bottom * 72.0/2540.0, 
-                       templeft = size->left * 72.0/ 2540.0, 
-                       tempright = size->right * 72.0/2540, 
-                       templength = size->length * 72.0/2540.0, 
-                       tempwidth = size->width * 72.0/2540.0;
-               /* Skip page sizes which conflict with settings of the other options */
-               /* Find size of document's page under the IPP page sizes */
-               if(fabs(header->PageSize[0] - temptop + tempbottom) / templength < 0.01 &&
-               fabs(header->PageSize[1] - tempright + templeft) / tempwidth < 0.01     &&
-               (size_matched==NULL || !strcasecmp(pageSizeRequested, ippsizename))){
-                       if(log) log(ld, CF_LOGLEVEL_DEBUG, "Imageable area fit");
-                       size_matched = size;
-                       if (landscape) *landscape = 1;
-                       if (image_fit) *image_fit = 1;
-               }
-       }       
-       if (size_matched)
-       {
-        /*
-         * Standard size in landscape orientation...
-         */
-         size = size_matched;
-         if(log) log(ld, CF_LOGLEVEL_DEBUG, "landscape size = %s", size->media);
-         dimensions[0] = size->width * 72.0 / 2540.0;
-         dimensions[1] = size->length * 72.0 / 2540.0;
-         margins[0] = size->left * 72.0 / 2540.0;
-         margins[1] = size->bottom * 72.0 / 2540.0;
-         margins[2] = size->right * 72.0 / 2540.0;
-         margins[3] = size->top * 72.0 / 2540.0;
-         snprintf(header->cupsPageSizeName, sizeof(header->cupsPageSizeName),
-                  "%.63s", size->media);
-       }
-       else
-       {
-        /*
-         * Custom size...
-         */
-         if(log) log(ld, CF_LOGLEVEL_DEBUG, "size = custom");
-         for (i = 0; i < 2; i ++)
-           dimensions[i] = header->PageSize[i];
-         margins[0] = left * 72.0 / 2540.0;
-         margins[1] = bottom * 72.0 / 2540.0;
-         margins[2] = right * 72.0 / 2540.0;
-         margins[3] = top * 72.0 / 2540.0;
-         snprintf(header->cupsPageSizeName, 64, "Custom.%dx%d", header->PageSize[0], header->PageSize[1]);
-       }
-  }
-
-  return 0;
-
-}
-
 /*
  *  'cfGetBackSideOrientation()' - This functions returns the back
  *                                side orientation using printer
index f866dafa559b3c6052f592b9486c63dcf918bd8e..1dac191a6431a3307a297529e527107fadde482f 100644 (file)
@@ -68,12 +68,6 @@ extern int              cfRasterSetColorSpace(cups_page_header2_t *h,
 extern int             cfJoinJobOptionsAndAttrs(cf_filter_data_t *data,
                                                 int num_options,
                                                 cups_option_t **options);
-extern int             cfRasterMatchIPPSize(cups_page_header2_t *header,
-                                            cf_filter_data_t *data,
-                                            double margins[4],
-                                            double dimensions[2],
-                                            int *image_fit,
-                                            int *landscape);
 extern int             cfGetBackSideOrientation(cf_filter_data_t *data);
 extern const char      *cfGetPrintRenderIntent(cf_filter_data_t *data,
                                                char *ri, int ri_len);