2007-11-30 11:29:46 +00:00
|
|
|
diff -pruN paps-0.6.8.orig/configure.in paps-0.6.8/configure.in
|
|
|
|
--- paps-0.6.8.orig/configure.in 2007-01-19 20:06:10.000000000 +0900
|
|
|
|
+++ paps-0.6.8/configure.in 2007-11-30 18:40:32.000000000 +0900
|
|
|
|
@@ -7,6 +7,19 @@ AC_LANG_C
|
2006-09-14 08:15:57 +00:00
|
|
|
AC_PROG_CC
|
|
|
|
AM_PROG_LIBTOOL
|
|
|
|
|
|
|
|
+dnl ======================================================
|
|
|
|
+dnl check for CUPS
|
|
|
|
+dnl ======================================================
|
|
|
|
+AC_PATH_PROG(CUPS_CONFIG, cups-config, no)
|
|
|
|
+if test "$CUPS_CONFIG" = "no"; then
|
2007-11-30 11:29:46 +00:00
|
|
|
+ AC_MSG_ERROR([Please install cups development packages/files])
|
2006-09-14 08:15:57 +00:00
|
|
|
+fi
|
2007-11-30 11:29:46 +00:00
|
|
|
+CUPS_CFLAGS=`$CUPS_CONFIG --cflags | sed -e 's/-O[0-9]*//' -e 's/-m[^\t]*//g'`
|
2006-09-14 08:15:57 +00:00
|
|
|
+CUPS_LIBS=`$CUPS_CONFIG --libs`
|
|
|
|
+
|
|
|
|
+AC_SUBST(CUPS_CFLAGS)
|
|
|
|
+AC_SUBST(CUPS_LIBS)
|
|
|
|
+
|
2007-11-30 11:29:46 +00:00
|
|
|
DX_HTML_FEATURE(ON)
|
|
|
|
DX_CHM_FEATURE(OFF)
|
|
|
|
DX_CHI_FEATURE(OFF)
|
|
|
|
diff -pruN paps-0.6.8.orig/src/Makefile.am paps-0.6.8/src/Makefile.am
|
|
|
|
--- paps-0.6.8.orig/src/Makefile.am 2007-11-30 18:40:15.000000000 +0900
|
|
|
|
+++ paps-0.6.8/src/Makefile.am 2007-11-30 18:40:32.000000000 +0900
|
|
|
|
@@ -5,10 +5,10 @@ libpapsinc_HEADERS = libpaps.h
|
|
|
|
libpapsincdir = $(includedir)
|
2006-06-29 10:55:20 +00:00
|
|
|
|
|
|
|
bin_PROGRAMS = paps
|
|
|
|
-paps_CFLAGS = -Wall
|
|
|
|
+paps_CFLAGS = -Wall $(CUPS_CFLAGS)
|
|
|
|
paps_SOURCES = paps.c
|
2007-11-30 11:29:46 +00:00
|
|
|
paps_LDADD = $(lib_LTLIBRARIES) $(all_libraries)
|
2006-06-29 10:55:20 +00:00
|
|
|
-paps_LDFLAGS = `pkg-config --libs pangoft2`
|
|
|
|
+paps_LDFLAGS = `pkg-config --libs pangoft2` $(CUPS_LIBS)
|
2007-11-30 11:29:46 +00:00
|
|
|
paps_DEPENDENCIES = $(lib_LTLIBRARIES)
|
2006-06-29 10:55:20 +00:00
|
|
|
|
|
|
|
EXTRA_DIST = test_libpaps.c paps.1
|
2007-11-30 11:29:46 +00:00
|
|
|
diff -pruN paps-0.6.8.orig/src/paps.c paps-0.6.8/src/paps.c
|
|
|
|
--- paps-0.6.8.orig/src/paps.c 2007-11-30 18:40:15.000000000 +0900
|
|
|
|
+++ paps-0.6.8/src/paps.c 2007-11-30 18:47:28.000000000 +0900
|
|
|
|
@@ -31,6 +31,7 @@
|
|
|
|
#include <string.h>
|
2006-06-29 10:55:20 +00:00
|
|
|
#include <time.h>
|
|
|
|
#include <locale.h>
|
|
|
|
+#include <cups/cups.h>
|
|
|
|
|
|
|
|
#define BUFSIZE 1024
|
|
|
|
#define DEFAULT_FONT_FAMILY "Monospace"
|
2007-11-30 11:29:46 +00:00
|
|
|
@@ -86,9 +87,11 @@ typedef struct {
|
2006-09-14 08:15:57 +00:00
|
|
|
gboolean do_wordwrap;
|
2007-11-30 11:29:46 +00:00
|
|
|
gboolean do_use_markup;
|
|
|
|
gboolean do_stretch_chars;
|
2006-09-14 08:15:57 +00:00
|
|
|
+ gboolean cups_mode;
|
2006-07-17 05:03:29 +00:00
|
|
|
PangoDirection pango_dir;
|
|
|
|
gchar *filename;
|
|
|
|
gchar *header_font_desc;
|
|
|
|
+ gchar *owner;
|
2007-11-30 11:29:46 +00:00
|
|
|
gint lpi;
|
|
|
|
gint cpi;
|
2006-07-17 05:03:29 +00:00
|
|
|
} page_layout_t;
|
2007-11-30 11:29:46 +00:00
|
|
|
@@ -320,8 +323,8 @@ int main(int argc, char *argv[])
|
2006-06-29 10:55:20 +00:00
|
|
|
int num_pages = 1;
|
|
|
|
int gutter_width = 40;
|
|
|
|
int total_gutter_width;
|
|
|
|
- int page_width = paper_sizes[0].width;
|
|
|
|
- int page_height = paper_sizes[0].height;
|
|
|
|
+ int page_width = -1;
|
|
|
|
+ int page_height = -1;
|
|
|
|
int do_tumble = -1; /* -1 means not initialized */
|
|
|
|
int do_duplex = -1;
|
|
|
|
gchar *paps_header = NULL;
|
2007-11-30 11:29:46 +00:00
|
|
|
@@ -331,6 +334,8 @@ int main(int argc, char *argv[])
|
2006-07-04 05:12:40 +00:00
|
|
|
int max_width = 0, w;
|
2006-06-29 10:55:20 +00:00
|
|
|
GIConv cvh = NULL;
|
2007-11-30 11:29:46 +00:00
|
|
|
GOptionGroup *options;
|
2006-07-04 05:12:40 +00:00
|
|
|
+ gboolean cups_mode = FALSE;
|
2006-07-17 05:03:29 +00:00
|
|
|
+ gchar *page_owner = NULL;
|
2006-06-29 10:55:20 +00:00
|
|
|
|
2007-01-23 12:25:25 +00:00
|
|
|
/* Set locale from environment. */
|
|
|
|
setlocale(LC_ALL, "");
|
2007-11-30 11:29:46 +00:00
|
|
|
@@ -348,6 +353,134 @@ int main(int argc, char *argv[])
|
2006-06-29 10:55:20 +00:00
|
|
|
g_option_context_add_main_entries(ctxt, entries, NULL);
|
2007-11-30 11:29:46 +00:00
|
|
|
#endif
|
2006-06-29 10:55:20 +00:00
|
|
|
|
|
|
|
+ /* check if the process is being invoked as CUPS filter */
|
|
|
|
+ G_STMT_START {
|
|
|
|
+ gchar *prgname = g_path_get_basename(argv[0]);
|
|
|
|
+ cups_option_t *options = NULL;
|
|
|
|
+ ppd_file_t *ppd;
|
|
|
|
+ ppd_size_t *pagesize;
|
|
|
|
+ int num_options;
|
|
|
|
+ const char *val;
|
|
|
|
+
|
2006-06-29 13:31:33 +00:00
|
|
|
+ if (strncmp(prgname, "texttopaps", 10) == 0 ||
|
2007-11-30 11:29:46 +00:00
|
|
|
+ getenv("CUPS_SERVER") != NULL) {
|
2006-09-29 18:18:36 +00:00
|
|
|
+ g_set_prgname(prgname);
|
2006-06-29 10:55:20 +00:00
|
|
|
+ /* argument format should be job-id user title copies options [file] */
|
|
|
|
+ cups_mode = TRUE;
|
2007-03-07 12:02:43 +00:00
|
|
|
+ /* set default values */
|
2007-11-30 11:29:46 +00:00
|
|
|
+ page_layout.lpi = 6.0L;
|
|
|
|
+ page_layout.cpi = 10.0L;
|
2007-03-07 12:02:43 +00:00
|
|
|
+ left_margin = 18;
|
|
|
|
+ right_margin = 18;
|
|
|
|
+ top_margin = 36;
|
|
|
|
+ bottom_margin = 36;
|
|
|
|
+ page_width = 612;
|
|
|
|
+ page_height = 792;
|
|
|
|
+
|
2006-06-29 10:55:20 +00:00
|
|
|
+ if (argc < 6 || argc > 7) {
|
|
|
|
+ fprintf(stderr, "ERROR: %s job-id user title copies options [file]\n", prgname);
|
|
|
|
+ exit(1);
|
|
|
|
+ }
|
|
|
|
+ if (argc == 6) {
|
|
|
|
+ filename_in = "stdin";
|
|
|
|
+ IN = stdin;
|
|
|
|
+ } else {
|
|
|
|
+ filename_in = argv[6];
|
2007-11-30 11:29:46 +00:00
|
|
|
+ if ((IN = fopen(filename_in, "rb")) == NULL) {
|
2006-06-29 10:55:20 +00:00
|
|
|
+ fprintf(stderr, "ERROR: unable to open print file -\n");
|
|
|
|
+ exit(1);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ title = argv[3];
|
2006-07-17 05:03:29 +00:00
|
|
|
+ page_owner = argv[2];
|
2006-06-29 10:55:20 +00:00
|
|
|
+ num_options = cupsParseOptions(argv[5], 0, &options);
|
|
|
|
+
|
|
|
|
+ if ((val = cupsGetOption("prettyprint", num_options, options)) != NULL &&
|
|
|
|
+ g_ascii_strcasecmp(val, "no") &&
|
|
|
|
+ g_ascii_strcasecmp(val, "off") &&
|
|
|
|
+ g_ascii_strcasecmp(val, "false")) {
|
|
|
|
+ /* XXX: need to support the keywords highlighting */
|
|
|
|
+ }
|
|
|
|
+ ppd = ppdOpenFile(getenv("PPD"));
|
|
|
|
+ ppdMarkDefaults(ppd);
|
|
|
|
+ cupsMarkOptions(ppd, num_options, options);
|
|
|
|
+
|
|
|
|
+ if ((pagesize = ppdPageSize(ppd, NULL)) != NULL) {
|
|
|
|
+ page_width = pagesize->width;
|
|
|
|
+ page_height = pagesize->length;
|
|
|
|
+ top_margin = pagesize->length - pagesize->top;
|
|
|
|
+ bottom_margin = pagesize->bottom;
|
|
|
|
+ left_margin = pagesize->left;
|
|
|
|
+ right_margin = pagesize->width - pagesize->right;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ if ((val = cupsGetOption("landscape", num_options, options)) != NULL) {
|
2007-01-23 12:25:25 +00:00
|
|
|
+ if (g_ascii_strcasecmp(val, "no") &&
|
|
|
|
+ g_ascii_strcasecmp(val, "off") &&
|
|
|
|
+ g_ascii_strcasecmp(val, "false")) {
|
2007-11-30 11:29:46 +00:00
|
|
|
+ /* We really need to deal with the landscape orientation because
|
|
|
|
+ * pstops doesn't deal with the position where it should appears.
|
|
|
|
+ * However this causes the unnecessary rotation by pstops. so paps
|
|
|
|
+ * will puts the fake Orientation tag and stop rotating in PS.
|
2007-01-23 12:25:25 +00:00
|
|
|
+ */
|
2007-11-30 11:29:46 +00:00
|
|
|
+ do_landscape = TRUE;
|
2006-06-29 10:55:20 +00:00
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ /* XXX: need to support orientation-requested? */
|
|
|
|
+ if ((val = cupsGetOption("page-left", num_options, options)) != NULL) {
|
|
|
|
+ left_margin = (int)atof(val);
|
|
|
|
+ }
|
|
|
|
+ if ((val = cupsGetOption("page-right", num_options, options)) != NULL) {
|
|
|
|
+ right_margin = (int)atof(val);
|
|
|
|
+ }
|
|
|
|
+ if ((val = cupsGetOption("page-bottom", num_options, options)) != NULL) {
|
|
|
|
+ bottom_margin = (int)atof(val);
|
|
|
|
+ }
|
|
|
|
+ if ((val = cupsGetOption("page-top", num_options, options)) != NULL) {
|
|
|
|
+ top_margin = (int)atof(val);
|
|
|
|
+ }
|
|
|
|
+ if (ppdIsMarked(ppd, "Duplex", "DuplexNoTumble") ||
|
|
|
|
+ ppdIsMarked(ppd, "Duplex", "DuplexTumble") ||
|
|
|
|
+ ppdIsMarked(ppd, "JCLDuplex", "DuplexNoTumble") ||
|
|
|
|
+ ppdIsMarked(ppd, "JCLDuplex", "DuplexTumble") ||
|
|
|
|
+ ppdIsMarked(ppd, "EFDuplex", "DuplexNoTumble") ||
|
|
|
|
+ ppdIsMarked(ppd, "EFDuplex", "DuplexTumble") ||
|
|
|
|
+ ppdIsMarked(ppd, "KD03Duplex", "DuplexNoTumble") ||
|
2007-11-30 11:29:46 +00:00
|
|
|
+ ppdIsMarked(ppd, "KD03Duplex", "DuplexTumble")) {
|
2006-06-29 10:55:20 +00:00
|
|
|
+ do_duplex = TRUE;
|
2007-11-30 11:29:46 +00:00
|
|
|
+ }
|
2006-06-29 10:55:20 +00:00
|
|
|
+ if ((val = cupsGetOption("wrap", num_options, options)) != NULL) {
|
|
|
|
+ do_wordwrap = !g_ascii_strcasecmp(val, "true") ||
|
|
|
|
+ !g_ascii_strcasecmp(val, "on") ||
|
|
|
|
+ !g_ascii_strcasecmp(val, "yes");
|
|
|
|
+ }
|
|
|
|
+ if ((val = cupsGetOption("columns", num_options, options)) != NULL) {
|
|
|
|
+ num_columns = atoi(val);
|
|
|
|
+ }
|
|
|
|
+ if ((val = cupsGetOption("cpi", num_options, options)) != NULL) {
|
2007-11-30 11:29:46 +00:00
|
|
|
+ page_layout.cpi = atof(val);
|
2006-06-29 10:55:20 +00:00
|
|
|
+ }
|
|
|
|
+ if ((val = cupsGetOption("lpi", num_options, options)) != NULL) {
|
2007-11-30 11:29:46 +00:00
|
|
|
+ page_layout.lpi = atof(val);
|
2006-06-29 10:55:20 +00:00
|
|
|
+ }
|
2006-08-17 11:40:04 +00:00
|
|
|
+ if (getenv("CHARSET") != NULL) {
|
|
|
|
+ char *charset = getenv("CHARSET");
|
2007-01-23 12:25:25 +00:00
|
|
|
+ /* Map CUPS charset names to real ones.
|
|
|
|
+ * http://cups.org/newsgroups.php?s9797+gcups.general+v9797+T1
|
|
|
|
+ */
|
2007-11-30 11:29:46 +00:00
|
|
|
+ if (!g_ascii_strcasecmp(charset, "windows-932")) {
|
2006-08-17 11:40:04 +00:00
|
|
|
+ charset = "WINDOWS-31J";
|
2007-11-30 11:29:46 +00:00
|
|
|
+ }
|
2006-09-29 14:59:28 +00:00
|
|
|
+ if (g_ascii_strcasecmp(charset, "utf-8") &&
|
2007-11-30 11:29:46 +00:00
|
|
|
+ g_ascii_strcasecmp(charset, "utf8")) {
|
2006-09-29 14:59:28 +00:00
|
|
|
+ encoding = g_strdup(charset);
|
2007-11-30 11:29:46 +00:00
|
|
|
+ }
|
2006-08-17 11:40:04 +00:00
|
|
|
+ }
|
2006-06-29 10:55:20 +00:00
|
|
|
+ }
|
|
|
|
+ } G_STMT_END;
|
|
|
|
+
|
|
|
|
+ if (!cups_mode) {
|
|
|
|
+
|
|
|
|
/* Parse command line */
|
|
|
|
if (!g_option_context_parse(ctxt, &argc, &argv, &error))
|
|
|
|
{
|
2007-11-30 11:29:46 +00:00
|
|
|
@@ -374,6 +507,8 @@ int main(int argc, char *argv[])
|
2006-06-29 10:55:20 +00:00
|
|
|
IN = stdin;
|
|
|
|
}
|
|
|
|
title = filename_in;
|
|
|
|
+
|
|
|
|
+ } /* if (!cups_mode) */
|
|
|
|
|
|
|
|
paps = paps_new();
|
|
|
|
pango_context = paps_get_pango_context (paps);
|
2007-11-30 11:29:46 +00:00
|
|
|
@@ -392,8 +527,10 @@ int main(int argc, char *argv[])
|
2006-06-29 10:55:20 +00:00
|
|
|
pango_context_set_font_description (pango_context, font_description);
|
|
|
|
|
|
|
|
/* Page layout */
|
|
|
|
- page_width = paper_sizes[(int)paper_type].width;
|
|
|
|
- page_height = paper_sizes[(int)paper_type].height;
|
|
|
|
+ if (page_width < 0)
|
2007-11-30 11:29:46 +00:00
|
|
|
+ page_width = paper_sizes[(int)paper_type].width;
|
2006-06-29 10:55:20 +00:00
|
|
|
+ if (page_height < 0)
|
2007-11-30 11:29:46 +00:00
|
|
|
+ page_height = paper_sizes[(int)paper_type].height;
|
2006-06-29 10:55:20 +00:00
|
|
|
|
|
|
|
if (num_columns == 1)
|
|
|
|
total_gutter_width = 0;
|
2007-11-30 11:29:46 +00:00
|
|
|
@@ -456,6 +593,8 @@ int main(int argc, char *argv[])
|
2006-07-17 05:03:29 +00:00
|
|
|
page_layout.pango_dir = pango_dir;
|
|
|
|
page_layout.filename = filename_in;
|
|
|
|
page_layout.header_font_desc = header_font_desc;
|
|
|
|
+ page_layout.owner = page_owner;
|
2006-09-14 08:15:57 +00:00
|
|
|
+ page_layout.cups_mode = cups_mode;
|
2006-07-17 05:03:29 +00:00
|
|
|
|
|
|
|
/* calculate x-coordinate scale */
|
2007-11-30 11:29:46 +00:00
|
|
|
if (page_layout.cpi > 0.0L)
|
|
|
|
@@ -756,6 +895,12 @@ split_text_into_paragraphs (PangoContext
|
|
|
|
if (wc == (gunichar)-1)
|
|
|
|
{
|
|
|
|
fprintf (stderr, "%s: Invalid character in input\n", g_get_prgname ());
|
|
|
|
+ if (page_layout->cups_mode)
|
|
|
|
+ {
|
|
|
|
+ /* try to continue parsing texts */
|
|
|
|
+ p = next;
|
|
|
|
+ continue;
|
|
|
|
+ }
|
|
|
|
wc = 0;
|
|
|
|
}
|
|
|
|
if (!*p || !wc || wc == '\n' || wc == '\f')
|
|
|
|
@@ -925,6 +1070,7 @@ void print_postscript_header(FILE *OUT,
|
2006-07-17 05:03:29 +00:00
|
|
|
int orientation = page_layout->page_width > page_layout->page_height;
|
|
|
|
int bb_page_width = page_layout->page_width;
|
|
|
|
int bb_page_height = page_layout->page_height;
|
|
|
|
+ char *owner = NULL;
|
|
|
|
|
|
|
|
/* Keep bounding box non-rotated to make ggv happy */
|
|
|
|
if (orientation)
|
2007-11-30 11:29:46 +00:00
|
|
|
@@ -934,12 +1080,20 @@ void print_postscript_header(FILE *OUT,
|
2006-07-17 05:03:29 +00:00
|
|
|
bb_page_height = tmp;
|
|
|
|
}
|
|
|
|
|
|
|
|
+ if (page_layout->owner)
|
|
|
|
+ {
|
|
|
|
+ owner = g_strdup_printf("%%%%For: %s\n", page_layout->owner);
|
|
|
|
+ }
|
|
|
|
+ else
|
|
|
|
+ {
|
|
|
|
+ owner = g_strdup("");
|
|
|
|
+ }
|
|
|
|
fprintf(OUT,
|
|
|
|
"%%!PS-Adobe-3.0\n"
|
|
|
|
"%%%%Title: %s\n"
|
2007-11-30 11:29:46 +00:00
|
|
|
"%%%%Creator: paps version 0.6.7 by Dov Grobgeld\n"
|
2006-07-17 05:03:29 +00:00
|
|
|
"%%%%Pages: (atend)\n"
|
|
|
|
- "%%%%BoundingBox: 0 0 %d %d\n"
|
|
|
|
+ "%%%%BoundingBox: 0 0 %d %d\n%s"
|
|
|
|
"%%%%BeginProlog\n"
|
|
|
|
"%%%%Orientation: %s\n"
|
|
|
|
"/papsdict 1 dict def\n"
|
2007-11-30 11:29:46 +00:00
|
|
|
@@ -989,8 +1143,13 @@ void print_postscript_header(FILE *OUT,
|
2006-07-17 05:03:29 +00:00
|
|
|
title,
|
|
|
|
bb_page_width,
|
|
|
|
bb_page_height,
|
2007-11-30 11:29:46 +00:00
|
|
|
- orientation_names[orientation]
|
2006-07-17 05:03:29 +00:00
|
|
|
+ owner,
|
2007-11-30 11:29:46 +00:00
|
|
|
+ /* Put the fake orientation tag if paps is currently running under
|
|
|
|
+ * the CUPS filter mode. (#222137)
|
|
|
|
+ */
|
|
|
|
+ orientation_names[orientation && !page_layout->cups_mode]
|
2006-07-17 05:03:29 +00:00
|
|
|
);
|
|
|
|
+ g_free(owner);
|
|
|
|
|
|
|
|
fprintf(OUT,
|
|
|
|
"%% User settings\n"
|
2007-11-30 11:29:46 +00:00
|
|
|
@@ -1015,7 +1174,11 @@ void print_postscript_header(FILE *OUT,
|
|
|
|
page_layout->left_margin,
|
|
|
|
page_layout->page_height - bodytop,
|
|
|
|
bool_name[page_layout->do_separation_line>0],
|
|
|
|
- bool_name[page_layout->do_landscape>0],
|
|
|
|
+ /* just ignore the landscape flag when paps is currently running
|
|
|
|
+ * under the CUPS filter mode. this will stop rotating in PS that
|
|
|
|
+ * paps generates. (#222137)
|
|
|
|
+ */
|
|
|
|
+ bool_name[page_layout->do_landscape>0 && !page_layout->cups_mode],
|
|
|
|
bool_name[page_layout->do_tumble>0],
|
|
|
|
bool_name[page_layout->do_duplex>0]
|
|
|
|
);
|