]> git.ipfire.org Git - thirdparty/cups.git/commitdiff
Mirror 1.1.x changes.
authormike <mike@7a7537e8-13f0-0310-91df-b6672ffda945>
Thu, 28 Aug 2003 14:36:57 +0000 (14:36 +0000)
committermike <mike@7a7537e8-13f0-0310-91df-b6672ffda945>
Thu, 28 Aug 2003 14:36:57 +0000 (14:36 +0000)
git-svn-id: svn+ssh://src.apple.com/svn/cups/cups.org/branches/branch-1.2@3887 7a7537e8-13f0-0310-91df-b6672ffda945

CHANGES-1.1.txt
backend/lpd.c
cups/http-support.c
filter/hpgl-main.c
filter/pstops.c
filter/textcommon.c
pdftops/GlobalParams.cxx
pdftops/GlobalParams.h
pdftops/PSOutputDev.cxx
pdftops/pdftops.cxx

index d9b4df3faff3865fab64d793dd59f331bf02484c..184ec97eb4aff4da67a02bb91b83e1c23e960b6d 100644 (file)
@@ -3,6 +3,16 @@ CHANGES-1.1.txt
 
 CHANGES IN CUPS V1.1.20rc1
 
+       - The PDF filter always scaled and offset pages; this
+         caused problems under MacOS X, so now the "fitplot"
+         option controls whether PDF files are scaled to fit
+         within the printable area of the page (STR #250)
+       - The LPD backend did not support the port number in a
+         URI (STR #247)
+       - Some filters didn't properly support boolean options
+         (STR #249)
+       - Landscape PDF files were not always offset by the
+         correct amount when rotating (STR #243)
        - The scheduler could hang in a call to localtime() when
          logging messages from the signal handler (STR #242)
        - The PDF filter no longer prints form widgets; this
index 2295a18e8b1961cc4338af1bf79e0bfd56ea98cc..cc7c919bc4a273729a9c850813c3fd7d417a30f1 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * "$Id: lpd.c,v 1.28.2.23 2003/07/29 12:53:01 mike Exp $"
+ * "$Id: lpd.c,v 1.28.2.24 2003/08/28 14:36:51 mike Exp $"
  *
  *   Line Printer Daemon backend for the Common UNIX Printing System (CUPS).
  *
@@ -119,8 +119,9 @@ extern int  rresvport(int *port);
  */
 
 static int     lpd_command(int lpd_fd, int timeout, char *format, ...);
-static int     lpd_queue(char *hostname, char *printer, char *filename,
-                         char *user, char *title, int copies,
+static int     lpd_queue(const char *hostname, int port, const char *printer,
+                         const char *filename,
+                         const char *user, const char *title, int copies,
                          int banner, int format, int order, int reserve,
                          int manual_copies, int timeout);
 static void    lpd_timeout(int sig);
@@ -424,7 +425,7 @@ main(int  argc,                             /* I - Number of command-line arguments (6 or 7) */
       copies        = atoi(argv[4]);
     }
 
-    status = lpd_queue(hostname, resource + 1, filename,
+    status = lpd_queue(hostname, port, resource + 1, filename,
                        argv[2] /* user */, title, copies,
                       banner, format, order, reserve, manual_copies, timeout);
 
@@ -432,7 +433,7 @@ main(int  argc,                             /* I - Number of command-line arguments (6 or 7) */
       fprintf(stderr, "PAGE: 1 %d\n", atoi(argv[4]));
   }
   else
-    status = lpd_queue(hostname, resource + 1, filename,
+    status = lpd_queue(hostname, port, resource + 1, filename,
                        argv[2] /* user */, title, 1,
                       banner, format, order, reserve, 1, timeout);
 
@@ -517,24 +518,25 @@ lpd_command(int  fd,              /* I - Socket connection to LPD host */
  */
 
 static int                             /* O - Zero on success, non-zero on failure */
-lpd_queue(char *hostname,              /* I - Host to connect to */
-          char *printer,               /* I - Printer/queue name */
-         char *filename,               /* I - File to print */
-          char *user,                  /* I - Requesting user */
-         char *title,                  /* I - Job title */
-         int  copies,                  /* I - Number of copies */
-         int  banner,                  /* I - Print LPD banner? */
-          int  format,                 /* I - Format specifier */
-          int  order,                  /* I - Order of data/control files */
-         int  reserve,                 /* I - Reserve ports? */
-         int  manual_copies,           /* I - Do copies by hand... */
-         int  timeout)                 /* I - Timeout... */
+lpd_queue(const char *hostname,                /* I - Host to connect to */
+          int        port,             /* I - Port to connect on */
+          const char *printer,         /* I - Printer/queue name */
+         const char *filename,         /* I - File to print */
+          const char *user,            /* I - Requesting user */
+         const char *title,            /* I - Job title */
+         int        copies,            /* I - Number of copies */
+         int        banner,            /* I - Print LPD banner? */
+          int        format,           /* I - Format specifier */
+          int        order,            /* I - Order of data/control files */
+         int        reserve,           /* I - Reserve ports? */
+         int        manual_copies,     /* I - Do copies by hand... */
+         int        timeout)           /* I - Timeout... */
 {
   FILE                 *fp;            /* Job file */
   char                 localhost[255]; /* Local host name */
   int                  error;          /* Error number */
   struct stat          filestats;      /* File statistics */
-  int                  port;           /* LPD connection port */
+  int                  lport;          /* LPD connection local port */
   int                  fd;             /* LPD socket */
   char                 control[10240], /* LPD control 'file' */
                        *cptr;          /* Pointer into control file string */
@@ -589,9 +591,9 @@ lpd_queue(char *hostname,           /* I - Host to connect to */
     memset(&addr, 0, sizeof(addr));
     memcpy(&(addr.sin_addr), hostaddr->h_addr, hostaddr->h_length);
     addr.sin_family = hostaddr->h_addrtype;
-    addr.sin_port   = htons(515);      /* LPD/printer service */
+    addr.sin_port   = htons(port);
 
-    for (port = 732;;)
+    for (lport = 732;;)
     {
       if (getuid() || !reserve)
       {
@@ -605,16 +607,16 @@ lpd_queue(char *hostname,         /* I - Host to connect to */
           return (1);
        }
 
-       port = 515;
+        lport = 0;
       }
       else
       {
        /*
        * We're running as root and want to comply with RFC 1179.  Reserve a
-       * priviledged port between 721 and 732...
+       * priviledged lport between 721 and 732...
        */
 
-       if ((fd = rresvport(&port)) < 0)
+       if ((fd = rresvport(&lport)) < 0)
        {
          perror("ERROR: Unable to reserve port");
          sleep(30);
@@ -651,7 +653,9 @@ lpd_queue(char *hostname,           /* I - Host to connect to */
        break;
     }
 
-    fprintf(stderr, "INFO: Connected from port %d...\n", port);
+    fprintf(stderr, "INFO: Connected to %s...\n", hostname);
+    fprintf(stderr, "DEBUG: Connected on ports %d (local %d)...\n", port,
+            lport);
 
    /*
     * Next, open the print file and figure out its size...
@@ -1022,5 +1026,5 @@ sigterm_handler(int sig)          /* I - Signal */
 
 
 /*
- * End of "$Id: lpd.c,v 1.28.2.23 2003/07/29 12:53:01 mike Exp $".
+ * End of "$Id: lpd.c,v 1.28.2.24 2003/08/28 14:36:51 mike Exp $".
  */
index bb505f1fb846f16375c77f30ba547e5e402798e7..4f8527587e4622ea0516b11115efa936543e8e76 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * "$Id: http-support.c,v 1.1.2.3 2003/02/04 05:10:17 mike Exp $"
+ * "$Id: http-support.c,v 1.1.2.4 2003/08/28 14:36:52 mike Exp $"
  *
  *   HTTP support routines for the Common UNIX Printing System (CUPS) scheduler.
  *
@@ -224,6 +224,8 @@ httpSeparate(const char *uri,               /* I - Universal Resource Identifier */
       *port = 443;
     else if (strcasecmp(method, "ipp") == 0)
       *port = ippPort();
+    else if (strcasecmp(method, "lpd") == 0)
+      *port = 515;
     else if (strcasecmp(method, "socket") == 0)        /* Not registered yet... */
       *port = 9100;
     else
@@ -264,5 +266,5 @@ httpSeparate(const char *uri,               /* I - Universal Resource Identifier */
 
 
 /*
- * End of "$Id: http-support.c,v 1.1.2.3 2003/02/04 05:10:17 mike Exp $".
+ * End of "$Id: http-support.c,v 1.1.2.4 2003/08/28 14:36:52 mike Exp $".
  */
index 05953a5c2d4560c35e3e2db743bc1b042385443f..38b4cde60ee5a2e50ad4fcc018cebd80c59c5c4c 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * "$Id: hpgl-main.c,v 1.22.2.4 2003/03/21 02:45:03 mike Exp $"
+ * "$Id: hpgl-main.c,v 1.22.2.5 2003/08/28 14:36:53 mike Exp $"
  *
  *   HP-GL/2 filter main entry for the Common UNIX Printing System (CUPS).
  *
@@ -192,10 +192,14 @@ main(int  argc,           /* I - Number of command-line arguments */
   shading  = 1;
   PenWidth = 1.0;
 
-  if ((val = cupsGetOption("blackplot", num_options, options)) != NULL)
+  if ((val = cupsGetOption("blackplot", num_options, options)) != NULL &&
+      strcasecmp(val, "no") && strcasecmp(val, "off") &&
+      strcasecmp(val, "false"))
     shading = 0;
 
-  if ((val = cupsGetOption("fitplot", num_options, options)) != NULL)
+  if ((val = cupsGetOption("fitplot", num_options, options)) != NULL &&
+      strcasecmp(val, "no") && strcasecmp(val, "off") &&
+      strcasecmp(val, "false"))
     FitPlot = 1;
 
   if ((val = cupsGetOption("penwidth", num_options, options)) != NULL)
@@ -264,5 +268,5 @@ compare_names(const void *p1,       /* I - First name */
 
 
 /*
- * End of "$Id: hpgl-main.c,v 1.22.2.4 2003/03/21 02:45:03 mike Exp $".
+ * End of "$Id: hpgl-main.c,v 1.22.2.5 2003/08/28 14:36:53 mike Exp $".
  */
index 9ac12ca678819e76b1bc8e5b565fcc3734e30e62..400b0f25a5a8f6b9c5576aadfb73fb150e303a77 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * "$Id: pstops.c,v 1.54.2.44 2003/08/11 18:40:58 mike Exp $"
+ * "$Id: pstops.c,v 1.54.2.45 2003/08/28 14:36:53 mike Exp $"
  *
  *   PostScript filter for the Common UNIX Printing System (CUPS).
  *
@@ -230,7 +230,8 @@ main(int  argc,                     /* I - Number of command-line arguments */
   }
 
   if ((val = cupsGetOption("Collate", num_options, options)) != NULL &&
-      !strcasecmp(val, "True"))
+      (!strcasecmp(val, "true") ||!strcasecmp(val, "on") ||
+       !strcasecmp(val, "yes")))
     Collate = 1;
 
   if ((val = cupsGetOption("OutputOrder", num_options, options)) != NULL &&
@@ -281,7 +282,8 @@ main(int  argc,                     /* I - Number of command-line arguments */
     b = atoi(val) * 0.01f;
 
   if ((val = cupsGetOption("mirror", num_options, options)) != NULL &&
-      !strcasecmp(val, "True"))
+      (!strcasecmp(val, "true") ||!strcasecmp(val, "on") ||
+       !strcasecmp(val, "yes")))
     Flip = 1;
 
  /*
@@ -1890,5 +1892,5 @@ start_nup(int number,                     /* I - Page number */
 
 
 /*
- * End of "$Id: pstops.c,v 1.54.2.44 2003/08/11 18:40:58 mike Exp $".
+ * End of "$Id: pstops.c,v 1.54.2.45 2003/08/28 14:36:53 mike Exp $".
  */
index 3800b8356b2b4b6f3b1e3caecbbbd3a6d907fd8d..eac0e9932ed8eb056f217374b29db7bd8f9b9c20 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * "$Id: textcommon.c,v 1.16.2.12 2003/04/25 14:42:38 mike Exp $"
+ * "$Id: textcommon.c,v 1.16.2.13 2003/08/28 14:36:54 mike Exp $"
  *
  *   Common text filter routines for the Common UNIX Printing System (CUPS).
  *
@@ -555,8 +555,8 @@ TextMain(const char *name,  /* I - Name of filter */
   num_options = cupsParseOptions(argv[5], 0, &options);
 
   if ((val = cupsGetOption("prettyprint", num_options, options)) != NULL &&
-      strcasecmp(val, "no") != 0 && strcasecmp(val, "off") != 0 &&
-      strcasecmp(val, "false") != 0)
+      strcasecmp(val, "no") && strcasecmp(val, "off") &&
+      strcasecmp(val, "false"))
   {
     PageLeft     = 72.0f;
     PageRight    = PageWidth - 36.0f;
@@ -602,7 +602,8 @@ TextMain(const char *name,  /* I - Name of filter */
   if ((val = cupsGetOption("wrap", num_options, options)) == NULL)
     WrapLines = 1;
   else
-    WrapLines = strcasecmp(val, "true") == 0;
+    WrapLines = !strcasecmp(val, "true") || !strcasecmp(val, "on") ||
+                !strcasecmp(val, "yes");
 
   if ((val = cupsGetOption("columns", num_options, options)) != NULL)
     PageColumns = atoi(val);
@@ -1181,5 +1182,5 @@ getutf8(FILE *fp) /* I - File to read from */
 
 
 /*
- * End of "$Id: textcommon.c,v 1.16.2.12 2003/04/25 14:42:38 mike Exp $".
+ * End of "$Id: textcommon.c,v 1.16.2.13 2003/08/28 14:36:54 mike Exp $".
  */
index 507ca3675ada0ad5d706814b647975d5b1d22e8b..875cf0746cb641f7226138529f0bb1e7788ca3fa 100644 (file)
@@ -967,6 +967,15 @@ GBool GlobalParams::getPSDuplex() {
   return d;
 }
 
+GBool GlobalParams::getPSFit() {
+  GBool d;
+
+  globalParamsLock;
+  d = psFit;
+  globalParamsUnlock;
+  return d;
+}
+
 PSLevel GlobalParams::getPSLevel() {
   PSLevel level;
 
@@ -1290,6 +1299,12 @@ void GlobalParams::setPSDuplex(GBool duplex) {
   globalParamsUnlock;
 }
 
+void GlobalParams::setPSFit(GBool fit) {
+  globalParamsLock;
+  psFit = fit;
+  globalParamsUnlock;
+}
+
 void GlobalParams::setPSLevel(PSLevel level) {
   globalParamsLock;
   psLevel = level;
index 99c04745e88c5390a3bce06832109fcb60c098d3..28f3508456df3d2906ce277ab9f2ebabf659eb76 100644 (file)
@@ -146,6 +146,7 @@ public:
   int getPSPaperWidth();
   int getPSPaperHeight();
   GBool getPSDuplex();
+  GBool getPSFit();
   PSLevel getPSLevel();
   PSFontParam *getPSFont(GString *fontName);
   PSFontParam *getPSFont16(GString *fontName, GString *collection, int wMode);
@@ -181,6 +182,7 @@ public:
   void setPSPaperWidth(int width);
   void setPSPaperHeight(int height);
   void setPSDuplex(GBool duplex);
+  void setPSFit(GBool fit);
   void setPSLevel(PSLevel level);
   void setPSEmbedType1(GBool embed);
   void setPSEmbedTrueType(GBool embed);
@@ -261,6 +263,7 @@ private:
   int psRight;                 //   ...
   int psTop;                   //   ...
   GBool psDuplex;              // enable duplexing in PostScript?
+  GBool psFit;                 // fit pages to device?
   PSLevel psLevel;             // PostScript level to generate
   GHash *psFonts;              // PostScript font info, indexed by PDF
                                //   font name [PSFontParam]
index 85b0a85d9af2941171c030b8f0784f6c4dca7ec6..1e9039aebf65aca6918507a5d9b90004e9caac58 100644 (file)
@@ -1746,7 +1746,14 @@ void PSOutputDev::startPage(int pageNum, GfxState *state) {
   int imageWidth, imageHeight;
   int left, bottom, right, top;
 
-  globalParams->getPSImageableArea(left, bottom, right, top);
+  if (globalParams->getPSFit()) {
+    globalParams->getPSImageableArea(left, bottom, right, top);
+  } else {
+    left = bottom = 0;
+    right = globalParams->getPSPaperWidth();
+    top = globalParams->getPSPaperHeight();
+  }
+
   imageWidth  = right - left;
   imageHeight = top - bottom;
 
@@ -1755,7 +1762,7 @@ void PSOutputDev::startPage(int pageNum, GfxState *state) {
   case psModePS:
     writePSFmt("%%%%Page: %d %d\n", pageNum, seqPage);
 
-    // rotate, translate, and scale page
+    // possibly rotate, translate, and scale page
     x1 = (int)(state->getX1() + 0.5);
     y1 = (int)(state->getY1() + 0.5);
     x2 = (int)(state->getX2() + 0.5);
@@ -1766,14 +1773,15 @@ void PSOutputDev::startPage(int pageNum, GfxState *state) {
     writePS("%%BeginPageSetup\n");
     width = x2 - x1;
     height = y2 - y1;
+    tx = 0;
+    ty = 0;
     if (width > height && width > imageWidth) {
       landscape = gTrue;
       writePSFmt("%%%%PageOrientation: %s\n",
                 state->getCTM()[0] ? "Landscape" : "Portrait");
       writePS("pdfStartPage\n");
       writePS("90 rotate\n");
-      tx = -x1;
-      ty = -(y1 + imageWidth);
+      ty = -globalParams->getPSPaperWidth();
       t = width;
       width = height;
       height = t;
@@ -1782,8 +1790,10 @@ void PSOutputDev::startPage(int pageNum, GfxState *state) {
       writePSFmt("%%%%PageOrientation: %s\n",
                 state->getCTM()[0] ? "Portrait" : "Landscape");
       writePS("pdfStartPage\n");
-      tx = -x1;
-      ty = -y1;
+    }
+    if (globalParams->getPSFit()) {
+      tx -= x1;
+      ty -= y1;
     }
     tx += left;
     ty += bottom;
@@ -1796,7 +1806,7 @@ void PSOutputDev::startPage(int pageNum, GfxState *state) {
     if (tx != 0 || ty != 0) {
       writePSFmt("%g %g translate\n", tx, ty);
     }
-    if (width > imageWidth || height > imageHeight) {
+    if ((width > imageWidth || height > imageHeight) && globalParams->getPSFit()) {
       xScale = (double)imageWidth / (double)width;
       yScale = (double)imageHeight / (double)height;
       if (yScale < xScale) {
index b09a9d020ff029b51f25a440646f0c6ef98a4285..f29640bf8d810c99c47c53f0a7f0bab77e26a767 100644 (file)
@@ -1,5 +1,5 @@
 //
-// "$Id: pdftops.cxx,v 1.6.2.6 2003/07/25 20:26:21 mike Exp $"
+// "$Id: pdftops.cxx,v 1.6.2.7 2003/08/28 14:36:57 mike Exp $"
 //
 //   PDF to PostScript filter front-end for the Common UNIX Printing
 //   System (CUPS).
@@ -62,26 +62,28 @@ int                                 // O - Exit status
 main(int  argc,                                // I - Number of command-line args
      char *argv[])                     // I - Command-line arguments
 {
-  PDFDoc       *doc;
-  GString      *fileName;
-  GString      *psFileName;
-  PSLevel      level;
-  PSOutputDev  *psOut;
-  int          num_options;
-  cups_option_t        *options;
-  const char   *val;
-  ppd_file_t   *ppd;
-  ppd_size_t   *size;
-  FILE         *fp;
-  const char   *server_root;
-  char         tempfile[1024];
-  char         buffer[8192];
-  int          bytes;
-  int          width, length;
+  PDFDoc       *doc;                   // Input file
+  GString      *fileName;              // Input filename
+  GString      *psFileName;            // Output filename
+  PSLevel      level;                  // PostScript level
+  PSOutputDev  *psOut;                 // Output device
+  int          num_options;            // Number of options
+  cups_option_t        *options;               // Options
+  const char   *val;                   // Option value
+  ppd_file_t   *ppd;                   // Current PPD
+  ppd_size_t   *size;                  // Current media size
+  FILE         *fp;                    // Copy file
+  const char   *server_root;           // Location of config files
+  char         tempfile[1024];         // Temporary file
+  char         buffer[8192];           // Copy buffer
+  int          bytes;                  // Bytes copied
+  int          width, length;          // Size in points
   int          left, bottom, right, top;
-  int          orientation;
-  int          temp;
-  int          duplex;
+                                       // Imageable area in points
+  int          orientation;            // Orientation
+  int          temp;                   // Temporary var
+  int          duplex;                 // Duplex the output?
+  int          fit;                    // Fit the pages to the output
 
 
   // Make sure status messages are not buffered...
@@ -122,6 +124,7 @@ main(int  argc,                             // I - Number of command-line args
   length = 792;
   level  = psLevel2;
   duplex = 0;
+  fit    = 0;
 
   // Get PPD and initialize options as needed...
   num_options = cupsParseOptions(argv[5], 0, &options);
@@ -224,6 +227,11 @@ main(int  argc,                            // I - Number of command-line args
        break;
   }
 
+  if ((val = cupsGetOption("fitplot", num_options, options)) != NULL &&
+      strcasecmp(val, "no") && strcasecmp(val, "off") &&
+      strcasecmp(val, "false"))
+    fit = 1;
+
   if ((val = cupsGetOption("sides", num_options, options)) != NULL &&
       strncasecmp(val, "two-", 4) == 0)
     duplex = 1;
@@ -269,6 +277,7 @@ main(int  argc,                             // I - Number of command-line args
   globalParams->setPSPaperHeight(length);
   globalParams->setPSImageableArea(left, bottom, right, top);
   globalParams->setPSDuplex(duplex);
+  globalParams->setPSFit(fit);
   globalParams->setPSLevel(level);
   globalParams->setPSASCIIHex(level == psLevel1);
   globalParams->setPSEmbedType1(1);
@@ -318,5 +327,5 @@ main(int  argc,                             // I - Number of command-line args
 
 
 //
-// End of "$Id: pdftops.cxx,v 1.6.2.6 2003/07/25 20:26:21 mike Exp $".
+// End of "$Id: pdftops.cxx,v 1.6.2.7 2003/08/28 14:36:57 mike Exp $".
 //