]> git.ipfire.org Git - thirdparty/cups-filters.git/commitdiff
libcupsfilters: Do not feed CUPS Raster into cfFilterPWGToPDF()
authorTill Kamppeter <till.kamppeter@gmail.com>
Sat, 3 Sep 2022 16:31:42 +0000 (18:31 +0200)
committerTill Kamppeter <till.kamppeter@gmail.com>
Sat, 3 Sep 2022 16:31:42 +0000 (18:31 +0200)
- In cfFilterUniversal() correct filter chains to always feed PWG
  Raster (or Apple Raster) into cfFilterPWGToPDF():

  o After cfFilterImageToRaster() call cfFilterRasterToPWG() before
    cfFilterPWGToPDF()

  o Do not accept CUPS Raster as input format for cfFilterUniversal(),
    so we only need to convert PWG Raster and Apple Raster to PDF,
    which works with cfFilterPWGToPDF(). CUPS Raster as input is
    actually not needed, as it is not used as network format for print
    jobs but only internally by CUPS, usually for Raster drivers. Also
    updated the MIME rules to not accept CUPS Raster.

  o Convert application/vnd.adobe-reader-postscript (PostScript from
    Adobe Reader) always to PDF via cfFilterGhostscript() (to PWG
    Raster) and cfFilterPWGToPDF() (to PDF). Removed the other paths
    for simplification. Also made sure that the filters to convert PDF
    to the final format get added to the chain.

- Let cfFilterRasterToPWG() also accept the final output format PCLm
  and then create PWG Raster, in preparation for cfFilterPWGToPDF().

- Let cfFilterPWGToRaster() not accept PCLm as final output format as
  its input format (PWG or Apple Raster) is directly accepted by
  cfFilterPWGToPDF() and so this filter is not needed for PCLm as
  final output format.

- These changes also fix printing
  application/vnd.adobe-reader-postscript (PostScript from Adobe
  Reader) with the cfFilterUniversal() filter function.

cupsfilters/filter.h
cupsfilters/pwgtoraster.c
cupsfilters/rastertopwg.c
cupsfilters/universal.c
mime/cupsfilters-universal.convs

index 0719e46ac54af14dc470550563ecedc782fdb26a..233fc628ad0d1bd9889be4d52caa66efdf525b8b 100644 (file)
@@ -320,12 +320,7 @@ extern int cfFilterPWGToRaster(int inputfd,
 
 /* Requires specification of output format via data->final_content_type
 
-   Output formats: CUPS Raster, PWG Raster, Apple Raster, PCLm
-
-   Note: On the PCLM selection the output is actually CUPS Raster but
-   information about available color spaces and depths is taken from
-   the pclm-... printer IPP attributes. This mode is for further
-   processing with pwgtopclm. */
+   Output formats: CUPS Raster, PWG Raster, Apple Raster */
 
 
 extern int cfFilterPWGToPDF(int inputfd,
@@ -347,7 +342,9 @@ extern int cfFilterRasterToPWG(int inputfd,
 
 /* Requires specification of output format via data->final_content_type
 
-   Output formats: Apple Raster or PWG Raster */
+   Output formats: Apple Raster or PWG Raster, if PCLM is specified
+   PWG Raster is produced to feed into the cfFilterPWGToPDF() filter
+   function. */
 
 
 extern int cfFilterTextToPDF(int inputfd,
index c3e15a480b8f2629da614799834b87d5e6a382fd..07dc0ec754fd8d4c1165a381bc1cf94ec2e66b98 100644 (file)
@@ -268,11 +268,9 @@ static int parse_opts(cf_filter_out_format_t outformat,
      cupsGetOption("media-size", num_options, options) ||
      cupsGetOption("media-col", num_options, options));
 
-  // We can directly create CUPS Raster, PWG Raster, and Apple Raster but
-  // for PCLm we have to output CUPS Raster and feed it into cfFilterPWGToPDF()
+  // We can directly create CUPS Raster, PWG Raster, and Apple Raster
   cfRasterPrepareHeader(&(doc->outheader), data, outformat,
-                         outformat == CF_FILTER_OUT_FORMAT_PCLM ?
-                         CF_FILTER_OUT_FORMAT_CUPS_RASTER : outformat, 0, &cspace);
+                         outformat, 0, &cspace);
 
   if (doc->outheader.Duplex)
   {
@@ -2075,8 +2073,6 @@ int cfFilterPWGToRaster(int inputfd,        /* I - File descriptor input stream
       outformat = CF_FILTER_OUT_FORMAT_PWG_RASTER;
     else if (strcasestr(val, "urf"))
       outformat = CF_FILTER_OUT_FORMAT_APPLE_RASTER;
-    else if (strcasestr(val, "pclm"))
-      outformat = CF_FILTER_OUT_FORMAT_PCLM;
     else
       outformat = CF_FILTER_OUT_FORMAT_CUPS_RASTER;
   }
@@ -2087,8 +2083,7 @@ int cfFilterPWGToRaster(int inputfd,        /* I - File descriptor input stream
               "cfFilterPWGToRaster: Output format: %s",
               (outformat == CF_FILTER_OUT_FORMAT_CUPS_RASTER ? "CUPS Raster" :
                (outformat == CF_FILTER_OUT_FORMAT_PWG_RASTER ? "PWG Raster" :
-                (outformat == CF_FILTER_OUT_FORMAT_APPLE_RASTER ? "Apple Raster" :
-                 "PCLM"))));
+                "Apple Raster")));
 
   cmsSetLogErrorHandler(lcms_error_handler);
 
index 30a7ee4c141a63f5cee16c52ee75c8381ea7db12..0c69234551932335aa7e3129157ddeb8a7e9848e 100644 (file)
@@ -69,14 +69,14 @@ cfFilterRasterToPWG(int inputfd,         /* I - File descriptor input stream */
 
   val = data->final_content_type;
   if (val) {
-    if (strcasestr(val, "pwg"))
+    if (strcasestr(val, "pwg") || strcasestr(val, "pclm"))
       outras = cupsRasterOpen(outputfd, CUPS_RASTER_WRITE_PWG);
     else if (strcasestr(val, "urf"))
       outras = cupsRasterOpen(outputfd, CUPS_RASTER_WRITE_APPLE);
     else
     {
       if (log) log(ld, CF_LOGLEVEL_ERROR,
-                  "cfFilterRasterToPWG: Invalid output format specified. Only PWG Raster and Apple Raster/URF are supported.");
+                  "cfFilterRasterToPWG: Invalid output format specified. Only PWG Raster, Apple Raster/URF, and PCLm are supported.");
 
       close(inputfd);
       close(outputfd);
index 44a888ba1a60e9866b131bf1f4ce07d9798937ec..df62375e9371d6ba680665e4c883d1256eb6aad0 100644 (file)
@@ -104,7 +104,8 @@ cfFilterUniversal(int inputfd,         /* I - File descriptor input stream */
       if (log) log(ld, CF_LOGLEVEL_DEBUG,
                   "cfFilterUniversal: Adding %s to chain", filter->name);
 
-      if (!strcasecmp(output, "image/pwg-raster"))
+      if (!strcasecmp(output, "image/pwg-raster") ||
+         !strcasecmp(output, "application/PCLm"))
       {
        filter = malloc(sizeof(cf_filter_filter_in_chain_t));
        outformat = malloc(sizeof(cf_filter_out_format_t));
@@ -115,18 +116,19 @@ cfFilterUniversal(int inputfd,         /* I - File descriptor input stream */
        cupsArrayAdd(filter_chain, filter);
        if (log) log(ld, CF_LOGLEVEL_DEBUG,
                     "cfFilterUniversal: Adding %s to chain", filter->name);
-      }
-      else if (!strcasecmp(output, "application/PCLm"))
-      {
-       outformat = malloc(sizeof(cf_filter_out_format_t));
-       *outformat = CF_FILTER_OUT_FORMAT_PCLM;
-       filter = malloc(sizeof(cf_filter_filter_in_chain_t));
-       filter->function = cfFilterPWGToPDF;
-       filter->parameters = outformat;
-       filter->name = "pwgtopclm";
-       cupsArrayAdd(filter_chain, filter);
-       if (log) log(ld, CF_LOGLEVEL_DEBUG,
-                    "cfFilterUniversal: Adding %s to chain", filter->name);
+
+       if (!strcasecmp(output, "application/PCLm"))
+        {
+         outformat = malloc(sizeof(cf_filter_out_format_t));
+         *outformat = CF_FILTER_OUT_FORMAT_PCLM;
+         filter = malloc(sizeof(cf_filter_filter_in_chain_t));
+         filter->function = cfFilterPWGToPDF;
+         filter->parameters = outformat;
+         filter->name = "pwgtopclm";
+         cupsArrayAdd(filter_chain, filter);
+         if (log) log(ld, CF_LOGLEVEL_DEBUG,
+                      "cfFilterUniversal: Adding %s to chain", filter->name);
+       }
       }
       else if (!strcasecmp(output, "image/urf"))
       {
@@ -185,8 +187,7 @@ cfFilterUniversal(int inputfd,         /* I - File descriptor input stream */
                   filter->name);
     }
     else if (!strcasecmp(input, "image/urf") ||
-            !strcasecmp(input, "image/pwg-raster") ||
-            !strcasecmp(input, "application/vnd.cups-raster"))
+            !strcasecmp(input, "image/pwg-raster"))
     {
       outformat = malloc(sizeof(cf_filter_out_format_t));
       *outformat = CF_FILTER_OUT_FORMAT_PDF;
@@ -202,13 +203,7 @@ cfFilterUniversal(int inputfd,         /* I - File descriptor input stream */
     else if (!strcasecmp(input_type, "vnd.adobe-reader-postscript"))
     {
       outformat = malloc(sizeof(cf_filter_out_format_t));
-      *outformat = CF_FILTER_OUT_FORMAT_CUPS_RASTER;
-      if (!strcasecmp(output_type, "pwg-raster"))
-       *outformat = CF_FILTER_OUT_FORMAT_PWG_RASTER;
-      else if(!strcasecmp(output_type, "urf"))
-       *outformat = CF_FILTER_OUT_FORMAT_APPLE_RASTER;
-      else if(!strcasecmp(output_type, "PCLm"))
-       *outformat = CF_FILTER_OUT_FORMAT_PCLM;
+      *outformat = CF_FILTER_OUT_FORMAT_PWG_RASTER;
       filter = malloc(sizeof(cf_filter_filter_in_chain_t));
       filter->function = cfFilterGhostscript;
       filter->parameters = outformat;
@@ -217,20 +212,15 @@ cfFilterUniversal(int inputfd,         /* I - File descriptor input stream */
       if (log) log(ld, CF_LOGLEVEL_DEBUG,
                   "cfFilterUniversal: Adding %s to chain", filter->name);
 
-      if (strcasecmp(output_type, "pwg-raster") &&
-         strcasecmp(output_type, "vnd.cups-raster") &&
-         strcasecmp(output_type, "PCLm"))
-      {
-       outformat = malloc(sizeof(cf_filter_out_format_t));
-       *outformat = CF_FILTER_OUT_FORMAT_PDF;
-       filter = malloc(sizeof(cf_filter_filter_in_chain_t));
-       filter->function = cfFilterPWGToPDF;
-       filter->parameters = outformat;
-       filter->name = "pwgtopdf";
-       cupsArrayAdd(filter_chain, filter);
-       if (log) log(ld, CF_LOGLEVEL_DEBUG,
-                    "cfFilterUniversal: Adding %s to chain", filter->name);
-      }
+      outformat = malloc(sizeof(cf_filter_out_format_t));
+      *outformat = CF_FILTER_OUT_FORMAT_PDF;
+      filter = malloc(sizeof(cf_filter_filter_in_chain_t));
+      filter->function = cfFilterPWGToPDF;
+      filter->parameters = outformat;
+      filter->name = "pwgtopdf";
+      cupsArrayAdd(filter_chain, filter);
+      if (log) log(ld, CF_LOGLEVEL_DEBUG,
+                  "cfFilterUniversal: Adding %s to chain", filter->name);
     }
 #endif /* HAVE_GHOSTSCRIPT */
     else if (!strcasecmp(input, "application/vnd.cups-pdf-banner"))
@@ -251,13 +241,12 @@ cfFilterUniversal(int inputfd,         /* I - File descriptor input stream */
       goto out;
     }
   }
-  if (((strcasecmp(input_super, "image") &&
-       strcasecmp(input_type, "vnd.adobe-reader-postscript")) ||
-       (strcasecmp(output_type, "vnd.cups-raster") &&
-       strcasecmp(output_type, "urf") && strcasecmp(output_type, "pwg-raster") &&
-       strcasecmp(output_type, "PCLm")) ||
-       !strcasecmp(input_type, "urf") ||
-       !strcasecmp(input_type, "pwg-raster")))
+  if (strcasecmp(input_super, "image") ||
+      (strcasecmp(output_type, "vnd.cups-raster") &&
+       strcasecmp(output_type, "urf") && strcasecmp(output_type, "pwg-raster") &&
+       strcasecmp(output_type, "PCLm")) ||
+      !strcasecmp(input_type, "urf") ||
+      !strcasecmp(input_type, "pwg-raster"))
   {
     if (strcasecmp(output_type, "pdf")) {
       if (strcasecmp(input_type, "vnd.cups-pdf"))
index a23f62b524531ea746006c0a6de7938767f41f53..2e1fde42371f494745d06bb25d398672d9b08054 100644 (file)
@@ -50,7 +50,6 @@ image/x-xwindowdump             application/vnd.universal-input      0    -
 image/x-sun-raster              application/vnd.universal-input      0    -
 image/pwg-raster                application/vnd.universal-input      0    -
 application/vnd.cups-pdf        application/vnd.universal-input      0    -
-application/vnd.cups-raster     application/vnd.universal-input      0    -
 image/urf                       application/vnd.universal-input      0    -
 application/pdf                 application/vnd.universal-input      0    -
 text/plain                      application/vnd.universal-input      0    -