From: mike Date: Wed, 23 Jan 2002 22:30:42 +0000 (+0000) Subject: Fix number-up=2 and classification/page label orientation. X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=e85cee1c15904c8801f1918e010a20ae63f7487f;p=thirdparty%2Fcups.git Fix number-up=2 and classification/page label orientation. git-svn-id: svn+ssh://src.apple.com/svn/cups/cups.org/trunk@2062 7a7537e8-13f0-0310-91df-b6672ffda945 --- diff --git a/CHANGES.txt b/CHANGES.txt index f2e83eeb22..71ff0c93ef 100644 --- a/CHANGES.txt +++ b/CHANGES.txt @@ -3,6 +3,8 @@ CHANGES.txt - 01/23/2002 CHANGES IN CUPS V1.1.13 + - Classification and page labels were not rotated to + match the page orientation. - Now set the TCP "no delay" option on network connections to improve performance/response time. - Improved the IRIX printing tools support with patches diff --git a/conf/mime.convs b/conf/mime.convs index f675e0c99f..7b86bf84d0 100644 --- a/conf/mime.convs +++ b/conf/mime.convs @@ -1,5 +1,5 @@ # -# "$Id: mime.convs,v 1.14 2002/01/02 17:58:38 mike Exp $" +# "$Id: mime.convs,v 1.15 2002/01/23 22:30:41 mike Exp $" # # MIME converts file for the Common UNIX Printing System (CUPS). # @@ -80,8 +80,8 @@ application/vnd.cups-postscript application/vnd.cups-raster 100 pstoraster # option. # -#*/* application/vnd.cups-raw 0 - +#application/octet-stream application/vnd.cups-raw 0 - # -# End of "$Id: mime.convs,v 1.14 2002/01/02 17:58:38 mike Exp $". +# End of "$Id: mime.convs,v 1.15 2002/01/23 22:30:41 mike Exp $". # diff --git a/filter/Makefile b/filter/Makefile index 5d486b51c9..1958a19bbf 100644 --- a/filter/Makefile +++ b/filter/Makefile @@ -1,5 +1,5 @@ # -# "$Id: Makefile,v 1.56 2002/01/23 17:25:38 mike Exp $" +# "$Id: Makefile,v 1.57 2002/01/23 22:30:42 mike Exp $" # # Filter makefile for the Common UNIX Printing System (CUPS). # @@ -169,7 +169,7 @@ imagetops: imagetops.o common.o $(LIBCUPSIMAGE) ../Makedefs \ echo Linking $@... $(CC) $(LDFLAGS) -o $@ imagetops.o common.o $(LINKCUPSIMAGE) \ $(IMGLIBS) $(LIBS) -imagetops: common.h image.h +imagetops.o: common.h image.h # @@ -181,7 +181,7 @@ imagetoraster: imagetoraster.o common.o $(LIBCUPSIMAGE) ../Makedefs \ echo Linking $@... $(CC) $(LDFLAGS) -o $@ imagetoraster.o common.o $(LINKCUPSIMAGE) \ $(IMGLIBS) $(LIBS) -imagetoraster: common.h image.h raster.h +imagetoraster.o: common.h image.h raster.h # @@ -242,5 +242,5 @@ $(OBJS): ../Makedefs ../cups/cups.h ../cups/ppd.h ../cups/language.h # -# End of "$Id: Makefile,v 1.56 2002/01/23 17:25:38 mike Exp $". +# End of "$Id: Makefile,v 1.57 2002/01/23 22:30:42 mike Exp $". # diff --git a/filter/common.c b/filter/common.c index 3f96539681..8d693f63f1 100644 --- a/filter/common.c +++ b/filter/common.c @@ -1,5 +1,5 @@ /* - * "$Id: common.c,v 1.17 2002/01/02 17:58:56 mike Exp $" + * "$Id: common.c,v 1.18 2002/01/23 22:30:42 mike Exp $" * * Common filter routines for the Common UNIX Printing System (CUPS). * @@ -23,12 +23,12 @@ * * Contents: * - * SetCommonOptions() - Set common filter options for media size, - * etc. - * UpdatePageVars() - Update the page variables for the - * orientation. - * WriteClassificationProlog() - Write the prolog with the classification - * and page label. + * SetCommonOptions() - Set common filter options for media size, + * etc. + * UpdatePageVars() - Update the page variables for the orientation. + * WriteLabelProlog() - Write the prolog with the classification + * and page label. + * WriteLabels() - Write the actual page labels. */ /* @@ -113,7 +113,7 @@ SetCommonOptions(int num_options, /* I - Number of options */ if ((val = cupsGetOption("page-left", num_options, options)) != NULL) { - switch (Orientation) + switch (Orientation & 3) { case 0 : PageLeft = (float)atof(val); @@ -132,7 +132,7 @@ SetCommonOptions(int num_options, /* I - Number of options */ if ((val = cupsGetOption("page-right", num_options, options)) != NULL) { - switch (Orientation) + switch (Orientation & 3) { case 0 : PageRight = PageWidth - (float)atof(val); @@ -151,7 +151,7 @@ SetCommonOptions(int num_options, /* I - Number of options */ if ((val = cupsGetOption("page-bottom", num_options, options)) != NULL) { - switch (Orientation) + switch (Orientation & 3) { case 0 : PageBottom = (float)atof(val); @@ -170,7 +170,7 @@ SetCommonOptions(int num_options, /* I - Number of options */ if ((val = cupsGetOption("page-top", num_options, options)) != NULL) { - switch (Orientation) + switch (Orientation & 3) { case 0 : PageTop = PageLength - (float)atof(val); @@ -214,7 +214,7 @@ UpdatePageVars(void) float temp; /* Swapping variable */ - switch (Orientation) + switch (Orientation & 3) { case 0 : /* Portait */ break; @@ -269,12 +269,15 @@ UpdatePageVars(void) /* - * 'WriteClassificationProlog()' - Write the prolog with the classification - * and page label. + * 'WriteLabelProlog()' - Write the prolog with the classification + * and page label. */ void -WriteLabelProlog(const char *label) /* I - Page label */ +WriteLabelProlog(const char *label, /* I - Page label */ + float bottom, /* I - Bottom position in points */ + float top, /* I - Top position in points */ + float width) /* I - Width in points */ { const char *classification; /* CLASSIFICATION environment variable */ @@ -336,20 +339,62 @@ WriteLabelProlog(const char *label) /* I - Page label */ puts("/espWL{"); puts(" espPF setfont"); printf(" espPL stringwidth pop dup 12 add exch -0.5 mul %.0f add\n", - PageWidth * 0.5f); + width * 0.5f); puts(" 1 setgray"); - printf(" dup 6 sub %.0f 3 index 20 rectfill\n", PageBottom - 2.0); - printf(" dup 6 sub %.0f 3 index 20 rectfill\n", PageTop - 18.0); + printf(" dup 6 sub %.0f 3 index 20 rectfill\n", bottom - 2.0); + printf(" dup 6 sub %.0f 3 index 20 rectfill\n", top - 18.0); puts(" 0 setgray"); - printf(" dup 6 sub %.0f 3 index 20 rectstroke\n", PageBottom - 2.0); - printf(" dup 6 sub %.0f 3 index 20 rectstroke\n", PageTop - 18.0); - printf(" dup %.0f moveto espPL show\n", PageBottom + 2.0); - printf(" %.0f moveto espPL show\n", PageTop - 14.0); + printf(" dup 6 sub %.0f 3 index 20 rectstroke\n", bottom - 2.0); + printf(" dup 6 sub %.0f 3 index 20 rectstroke\n", top - 18.0); + printf(" dup %.0f moveto espPL show\n", bottom + 2.0); + printf(" %.0f moveto espPL show\n", top - 14.0); puts("pop"); puts("}bind def"); } /* - * End of "$Id: common.c,v 1.17 2002/01/02 17:58:56 mike Exp $". + * 'WriteLabels()' - Write the actual page labels. + */ + +void +WriteLabels(int orient) /* I - Orientation of the page */ +{ + float width, /* Width of page */ + length; /* Length of page */ + + + puts("gsave"); + + if ((orient ^ Orientation) & 1) + { + width = PageLength; + length = PageWidth; + } + else + { + width = PageWidth; + length = PageLength; + } + + switch (orient & 3) + { + case 1 : /* Landscape */ + printf("%.1f 0.0 translate 90 rotate\n", length); + break; + case 2 : /* Reverse Portrait */ + printf("%.1f %.1f translate 180 rotate\n", width, length); + break; + case 3 : /* Reverse Landscape */ + printf("0.0 %.1f translate -90 rotate\n", width); + break; + } + + puts("espWL"); + puts("grestore"); +} + + +/* + * End of "$Id: common.c,v 1.18 2002/01/23 22:30:42 mike Exp $". */ diff --git a/filter/common.h b/filter/common.h index ccf277985b..ed0c5a822d 100644 --- a/filter/common.h +++ b/filter/common.h @@ -1,5 +1,5 @@ /* - * "$Id: common.h,v 1.8 2002/01/02 17:58:56 mike Exp $" + * "$Id: common.h,v 1.9 2002/01/23 22:30:42 mike Exp $" * * Common filter definitions for the Common UNIX Printing System (CUPS). * @@ -61,10 +61,11 @@ extern float PageLeft, /* Left margin */ extern ppd_file_t *SetCommonOptions(int num_options, cups_option_t *options, int change_size); extern void UpdatePageVars(void); -extern void WriteLabelProlog(const char *label); -#define WriteLabels() puts("espWL"); +extern void WriteLabelProlog(const char *label, float bottom, + float top, float width); +extern void WriteLabels(int orient); /* - * End of "$Id: common.h,v 1.8 2002/01/02 17:58:56 mike Exp $". + * End of "$Id: common.h,v 1.9 2002/01/23 22:30:42 mike Exp $". */ diff --git a/filter/imagetops.c b/filter/imagetops.c index 4abc1d702c..0708c30cee 100644 --- a/filter/imagetops.c +++ b/filter/imagetops.c @@ -1,5 +1,5 @@ /* - * "$Id: imagetops.c,v 1.41 2002/01/02 17:59:00 mike Exp $" + * "$Id: imagetops.c,v 1.42 2002/01/23 22:30:42 mike Exp $" * * Image file to PostScript filter for the Common UNIX Printing System (CUPS). * @@ -577,7 +577,8 @@ main(int argc, /* I - Number of command-line arguments */ printf("{ neg 1 add dup 0 lt { pop 1 } { %.3f exp neg 1 add } " "ifelse %.3f mul } bind settransfer\n", g, b); - WriteLabelProlog(cupsGetOption("page-label", num_options, options)); + WriteLabelProlog(cupsGetOption("page-label", num_options, options), + PageBottom, PageTop, PageWidth); if (realcopies > 1) { @@ -720,7 +721,7 @@ main(int argc, /* I - Number of command-line arguments */ } puts("grestore"); - WriteLabels(); + WriteLabels(Orientation); puts("showpage"); } @@ -865,5 +866,5 @@ ps_ascii85(ib_t *data, /* I - Data to print */ /* - * End of "$Id: imagetops.c,v 1.41 2002/01/02 17:59:00 mike Exp $". + * End of "$Id: imagetops.c,v 1.42 2002/01/23 22:30:42 mike Exp $". */ diff --git a/filter/pstops.c b/filter/pstops.c index af9feb4446..0e0d7509eb 100644 --- a/filter/pstops.c +++ b/filter/pstops.c @@ -1,5 +1,5 @@ /* - * "$Id: pstops.c,v 1.71 2002/01/23 17:25:38 mike Exp $" + * "$Id: pstops.c,v 1.72 2002/01/23 22:30:42 mike Exp $" * * PostScript filter for the Common UNIX Printing System (CUPS). * @@ -308,7 +308,21 @@ main(int argc, /* I - Number of command-line arguments */ UseESPsp = 1; } - WriteLabelProlog(val); + if (NUp == 2) + { + /* + * For 2-up output, rotate the labels to match the orientation + * of the pages... + */ + + if (Orientation & 1) + WriteLabelProlog(val, PageBottom, PageWidth - PageLength + PageTop, + PageLength); + else + WriteLabelProlog(val, PageLeft, PageRight, PageLength); + } + else + WriteLabelProlog(val, PageBottom, PageTop, PageWidth); if (UseESPsp) puts("userdict begin\n" @@ -887,7 +901,7 @@ end_nup(int number) /* I - Page number */ case 1 : if (UseESPsp) { - WriteLabels(); + WriteLabels(Orientation); puts("ESPshowpage"); } break; @@ -895,7 +909,23 @@ end_nup(int number) /* I - Page number */ case 2 : if ((number & 1) == 1 && UseESPsp) { - WriteLabels(); + if (Orientation & 1) + { + /* + * Rotate the labels back to portrait... + */ + + WriteLabels(Orientation - 1); + } + else + { + /* + * Rotate the labels to landscape... + */ + + WriteLabels(Orientation + 1); + } + puts("ESPshowpage"); } break; @@ -903,7 +933,7 @@ end_nup(int number) /* I - Page number */ case 4 : if ((number & 3) == 3 && UseESPsp) { - WriteLabels(); + WriteLabels(Orientation); puts("ESPshowpage"); } break; @@ -1113,5 +1143,5 @@ start_nup(int number) /* I - Page number */ /* - * End of "$Id: pstops.c,v 1.71 2002/01/23 17:25:38 mike Exp $". + * End of "$Id: pstops.c,v 1.72 2002/01/23 22:30:42 mike Exp $". */