From 84dd2ced9326165b7c32c4931ead8fceccbe89ce Mon Sep 17 00:00:00 2001 From: mike Date: Fri, 25 Jul 2003 20:26:21 +0000 Subject: [PATCH] Mirror 1.1.x changes. git-svn-id: svn+ssh://src.apple.com/svn/cups/cups.org/branches/branch-1.2@3833 7a7537e8-13f0-0310-91df-b6672ffda945 --- CHANGES-1.1.txt | 3 ++ pdftops/pdftops.cxx | 128 ++++++++++++++++++++++++++++++++++++++++++-- 2 files changed, 126 insertions(+), 5 deletions(-) diff --git a/CHANGES-1.1.txt b/CHANGES-1.1.txt index 4e4f37e562..e15e842fd2 100644 --- a/CHANGES-1.1.txt +++ b/CHANGES-1.1.txt @@ -3,6 +3,9 @@ CHANGES-1.1.txt CHANGES IN CUPS V1.1.20rc1 + - The pdftops filter incorrectly auto-rotated pages when + the user already had specified the proper orientation + (STR #207) - Fixed AIX shared library support (STR #201) - Added support for live testing with Valgrind (STR #193) diff --git a/pdftops/pdftops.cxx b/pdftops/pdftops.cxx index 422295aa1e..b09a9d020f 100644 --- a/pdftops/pdftops.cxx +++ b/pdftops/pdftops.cxx @@ -1,10 +1,35 @@ -//======================================================================== // -// pdftops.cc +// "$Id: pdftops.cxx,v 1.6.2.6 2003/07/25 20:26:21 mike Exp $" // -// Copyright 1996 Derek B. Noonburg +// PDF to PostScript filter front-end for the Common UNIX Printing +// System (CUPS). +// +// Copyright 1997-2003 by Easy Software Products. +// +// These coded instructions, statements, and computer programs are the +// property of Easy Software Products and are protected by Federal +// copyright law. Distribution and use rights are outlined in the file +// "LICENSE.txt" which should have been included with this file. If this +// file is missing or damaged please contact Easy Software Products +// at: +// +// Attn: CUPS Licensing Information +// Easy Software Products +// 44141 Airport View Drive, Suite 204 +// Hollywood, Maryland 20636-3111 USA +// +// Voice: (301) 373-9600 +// EMail: cups-info@cups.org +// WWW: http://www.cups.org +// +// Contents: +// +// main() - Main entry for filter... +// + +// +// Include necessary headers... // -//======================================================================== #include #include @@ -28,7 +53,15 @@ #include -int main(int argc, char *argv[]) { + +// +// 'main()' - Main entry for filter... +// + +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; @@ -46,6 +79,8 @@ int main(int argc, char *argv[]) { int bytes; int width, length; int left, bottom, right, top; + int orientation; + int temp; int duplex; @@ -111,6 +146,84 @@ int main(int argc, char *argv[]) { level = ppd->language_level == 1 ? psLevel1 : psLevel2; } + // Track the orientation of the print job and update the page + // dimensions and margins as needed... + orientation = 0; + + if ((val = cupsGetOption("landscape", num_options, options)) != NULL) + { + if (strcasecmp(val, "no") != 0 && strcasecmp(val, "off") != 0 && + strcasecmp(val, "false") != 0) + orientation = 1; + } + else if ((val = cupsGetOption("orientation-requested", num_options, options)) != NULL) + { + /* + * Map IPP orientation values to 0 to 3: + * + * 3 = 0 degrees = 0 + * 4 = 90 degrees = 1 + * 5 = -90 degrees = 3 + * 6 = 180 degrees = 2 + */ + + orientation = atoi(val) - 3; + if (orientation >= 2) + orientation ^= 1; + } + + switch (orientation & 3) + { + case 0 : /* Portait */ + break; + + case 1 : /* Landscape */ + temp = left; + left = bottom; + bottom = temp; + + temp = right; + right = top; + top = temp; + + temp = width; + width = length; + length = temp; + break; + + case 2 : /* Reverse Portrait */ + temp = width - left; + left = width - right; + right = temp; + + temp = length - bottom; + bottom = length - top; + top = temp; + break; + + case 3 : /* Reverse Landscape */ + temp = width - left; + left = width - right; + right = temp; + + temp = length - bottom; + bottom = length - top; + top = temp; + + temp = left; + left = bottom; + bottom = temp; + + temp = right; + right = top; + top = temp; + + temp = width; + width = length; + length = temp; + break; + } + if ((val = cupsGetOption("sides", num_options, options)) != NULL && strncasecmp(val, "two-", 4) == 0) duplex = 1; @@ -202,3 +315,8 @@ int main(int argc, char *argv[]) { return 0; } + + +// +// End of "$Id: pdftops.cxx,v 1.6.2.6 2003/07/25 20:26:21 mike Exp $". +// -- 2.47.2